Closed BinuDR closed 3 years ago
To be honest i'm not sure.
When i was first doing performance profiling in the early iterations i noticed i wasn't getting the same movement speed as i did in my stormfront scripts and for all the testing i never found a definitive answer. None of the optimizations (disabling the nagle algorithm etc) made much difference and i mostly attributed this to flaws in my scripting implementation.
Now with lich It's a whole other situation as lich is taking care of everything. I'm pretty sure the commands are being pushed through lich directly since it's a kind of a man-in-the-middle setup. There's no way lich can send commands to frontends. As far as i know it just comes down to displaying the data on the frontend side and not much more than that.
All i can think of is that there could be some kind of a IO blockage that's holding up the network traffic but programmatically speaking the data is being picked up very fast (~0.02ms for average packets) as soon as it becomes available. It's hard to tell if it has something to do with the network implementation that i'm using, a bug in the code or something else entirely.
I need to look into this more but at the moment i don't have any good leads.
I see. I was looking through the code for profanity trying to sort out where the section is that sends commands but I am not sure if I found the correct place.
I'd suggest talking to Matt Lowe who programmed it and see if he has any insights. I'm not sure how to contact him, but I'll ask if anyone has his info.
I do really love frostbite but it's hard to get used to not having that typeahead buffer, or whatever it actually is code wise.
Thanks again for all the work on it!
Looking at profanity.
https://github.com/matt-lowe/ProfanityFE/blob/master/profanity.rb
It only connects directly to lich (that's something i want to explore -- the fact that lich is initating the server connection).
server = TCPSocket.open('127.0.0.1', PORT)
Doesn't seem to be doing anything special. It puts directly to tcpsocket (called server).
key_action['send_command'] = proc
..
<!-- command parsing -->
..
server.puts cmd.sub(/^\./, ';')
None of this really matters since lich is doing all the work when you run scripts anyway.
It's mostly the same as far as lich goes. There was a slight difference in the way they set up game sessions but it didn't seem to make much difference when i tried it (they push empty commands after the connection string).
https://github.com/rcuhljr/dr-lich/blob/master/lich.rbw
client_string = "/FE:WIZARD /VERSION:1.0.1.22 /P:#{RUBY_PLATFORM} /XML"
$_CLIENTBUFFER_.push(client_string.dup)
Game._puts(client_string)
#
# tell the server we're ready
#
2.times {
sleep 0.3
$_CLIENTBUFFER_.push("<c>\r\n")
Game._puts("<c>")
}
I'm doing a:
this->writeCommand("");
this->writeCommand("_STATE CHATMODE OFF");
void TcpClient::writeCommand(QString cmd) {
QByteArray sendCmd = "<c>" + cmd.append("\n").toUtf8();
this->logDebug(sendCmd);
tcpSocket->write(sendCmd);
tcpSocket->flush();
}
Go2 uses an overriden "put" method from lich core. Nothing different here.
https://github.com/rpherbig/dr-scripts/blob/master/go2.lic
put room.wayto[next_id]
https://github.com/rcuhljr/dr-lich/blob/master/lich.rbw
def put(*messages)
messages.each { |message| Game.puts(message) }
end
def Game.puts(str) -> Game._puts "#{$cmd_prefix}#{str}"
def Game._puts(str)
@@mutex.synchronize {
@@socket.puts(str)
}
end
Again this all goes straight to the tcpsocket.
This is all obviously high level business logic. We're using completely different technologies underneath. What comes after "sockets.puts" or "tcpSocket->write" is something none of us have much control over and where everything gets pretty foggy.
It's no mystery when looking at the code and the way lich fundamentally works (it's a proxy). The frontend really doesn't play any part in lich when it runs scripts. It directly communicates with the server. That's what makes it so hard to figure out, doesn't make much sense why it would slow down at all (even if the client is slow shouldn't matter).
This is all going into programming territory I've never covered.
Something to wonder about for sure. Hopefully it can get figured out, but if not that's okay.
Thanks again for checking and responding. If I think of anything else that might be useful I'll make a note here.
I have something ready to experiment with. It's not a sure thing but when i tried it i was at least able to cover some ground (~100 rooms) using typeahead 9.
I tried to mimic profanity in the way that it interacts with lich.
It works by running lich as detachable client just like you would with profanity:
ruby lich.rbw --login <user> --without-frontend --detachable-client=8000
Then running frostbite instead of profanity:
frostbite --port=8000
Can you try and see if it does anything?
https://github.com/matoom/frostbite/releases/download/v1.9.6-beta/frostbite-win-exp.zip
Downloading it now. I'll report back when I'm done testing.
Yes, that's working!! One question though, I'm running these commands from two command prompt windows. Is that the way you meant for me to do it?
One thing I'm noticing though is that while go2 is super fast now, commands I enter seem to have a slight lag for the response from the server. INFO, ENC, look, etc for example.
Edit 1: It's not much, probably less than half a second. It just feels like when the game is slightly laggy.
Edit2: Testing with another character connected by stormfront, it seems like it's just the connection to the game itself and not frostbite specifically.
It's possible that it lags behind a little bit considering that everything goes through lich first and then gets pushed to the fontend but i'm still trying to figure out why it works when using the detachable-client option. It might be just the way lich works.
When it runs fast for you in stormfront, how do you run it with lich? Do you use the lich SGE? I'm kind of having hard time testing with stormfront myself since i have my lich set up on linux.
Either way, lich's game entry or login via Simu's game entry with lich linked to it. Lately I only use the lich game entry though.
Binu, thanks for bringing this up! I'm also interested in more typeahead. I'll download and try this new version.
Is there a way to access this through the Script Setting and not running CMD?
I'm afraid right now all i have is the detachable client work-around and i'm not entirely sure if it's possible to build a client side lich launcher around this mechanic. I had to actually put in some custom code in lich to get it working in the first place. As far as i know there's no way to make a character selection or add login credentials? According to the manual it uses previous login info from lich SGE to start up the game session. All i can do is add a port connector to the game launcher but lich would have to be run from the CMD.
I'm not ruling anything out at this point but i'm still trying to figure out why it's not working as it was intended by the lich creators and how it runs on stormfront. I actually tried stripping everything down to a most basic client possible with only networking remaining and logging directly to console but even that didn't make any difference. That mostly rules out blocking code in the processing parts but doesn't really help me get any closer to a solution.
You have to save your login info with the lich launcher first so that it's saved in entry.dat file. Then the command line login works without any adjustments to lich.
I'll go ahead and close this as well, thanks for looking into it.
When using go2, I can use typeahead=9 in stormfront and profanity but only 2-3 in frostbite.
Is there any way to adjust the command buffer (or whatever it is that allows the other FEs to do that) so that Frostbite can work like those?