changes in DirectConnection and Receive.pm for bRO

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

ever_boy_
Developers
Developers
Posts: 308
Joined: 06 Jul 2012, 13:44
Noob?: No

changes in DirectConnection and Receive.pm for bRO

#1 Post by ever_boy_ »

With the advent of the PIN code stuff, an unusual change had to be made on bRO.pm.
Since we firstly get char_login packet, and only then loginPinCode_request, we had to set a pause for the logging in proccess, releasing it after the loginPinCode_reply is sent. Otherwise, we'd get disconnected, even with correct PIN code.

Today, I've noticed that, upon entering a wrong PIN code on select char screen, the disconnect is almost instant, leaving us with no time left to even input a new PIN code. (Actually, we may get disconnected even BEFORE typing the PIN code, but due to the query, we'll only get the DC'd message after inputing the PIN)

So, I followed the "Timeout on Character Select Server" message and ended up on DirectConnection.pm. There, I found out that lines 565 to 572 cause us to disconnect. I thought it was a good idea to remove that timeout for bRO, due to our "unique" log in action, like this:

old

Code: Select all

	} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "") {
new

Code: Select all

	} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "" && $config{'master') !~ /bRO/) {
This way, it wouldn't affect any other servers, as well as leaving us with a 60 seconds timeout.
But since this is a global file, I thought of asking for better ideas before changing it.


Also, since our charBlockSize changed from 116 to 124, what should we do? Create a new 'return' for 124 size, or is it ok to leave it like this? (works just fine)

Code: Select all

return 'a4 V9 v V2 v14 Z24 C6 v2 x4' if $_ == 116 || 124; # TODO: (missing 2 last bytes)
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: changes in DirectConnection and Receive.pm for bRO

#2 Post by EternalHarvest »

ever_boy_ wrote:I thought it was a good idea to remove that timeout for bRO, due to our "unique" log in action, like this:

old

Code: Select all

	} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "") {
new

Code: Select all

	} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "" && $config{'master') !~ /bRO/) {
This way, it wouldn't affect any other servers, as well as leaving us with a 60 seconds timeout.
But since this is a global file, I thought of asking for better ideas before changing it.
Bad idea. Such things just heavily complicate the code which doesn't care about any particular server at this point. That's why we have serverType files. bRO has its own serverType shared with no other server, so all server-specific stuff goes into it.

Just setting the timeout in charSelectScreen hook handler is fine, because setting the timeout is one of things you're canceling with it.

Better solution would be to change Misc::charSelectScreen to always set "charlogin" timeout, even if a hook handler instructs it not to select any character, or to set that timeout early in some other place. That needs some investigation of why it was done that way.
Also, since our charBlockSize changed from 116 to 124, what should we do? Create a new 'return' for 124 size, or is it ok to leave it like this? (works just fine)

Code: Select all

return 'a4 V9 v V2 v14 Z24 C6 v2 x4' if $_ == 116 || 124; # TODO: (missing 2 last bytes)
Doesn't really matter, but your code looks like it would break charBlockSize 106, 108 and "unknown charBlockSize" case, so maybe a new line dedicated to 124 would be easier. Would need its own line anyway if we ever implement (or maybe just document) these 8 additional bytes here.
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: changes in DirectConnection and Receive.pm for bRO

#3 Post by EternalHarvest »

Actually, for bRO, Misc::charSelectScreen shouldn't be called at all for the first time, when it's prevented from doing anything, but to do that without much complication, received_characters handler needs to be refactored. Start with using the hook, maybe later we would refactor this stuff.
ever_boy_
Developers
Developers
Posts: 308
Joined: 06 Jul 2012, 13:44
Noob?: No

Re: changes in DirectConnection and Receive.pm for bRO

#4 Post by ever_boy_ »

do I use the same code you gave me, just increasing the timeout?
Kaspy
Halfway to Eternity
Halfway to Eternity
Posts: 398
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

Re: changes in DirectConnection and Receive.pm for bRO

#5 Post by Kaspy »

It's almost the same as the proposed solution ever_boy_...

1 - In the file servers.txt adds pin 1 on the servers that use the PIN (currently, the 3 of the bRO)
2 - No case cited, alter

Code: Select all

} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "") {
for

Code: Select all

} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "" && !$masterServer->{pin}) {
In other cases which might need, could use the $masterServer->{pin} also.
It is the least which alter codes OpenKore because of these conflicts, but would generate a configuration more.


Regarding charblocksize...
ever_boy_ wrote:Also, since our charBlockSize changed from 116 to 124, what should we do? Create a new 'return' for 124 size, or is it ok to leave it like this? (works just fine)

Code: Select all

return 'a4 V9 v V2 v14 Z24 C6 v2 x4' if $_ == 116 || 124; # TODO: (missing 2 last bytes)
That makes no sense. Better on separate lines.

Code: Select all

		return 'a4 V9 v V2 v14 Z24 C8 v Z16 x4' if $_ == 132;
		return 'a4 V9 v V2 v14 Z24 C6 v2 x4' if $_ == 124;
		return 'a4 V9 v V2 v14 Z24 C8 v Z16' if $_ == 128;
		return 'a4 V9 v V2 v14 Z24 C6 v2 x4' if $_ == 116; # TODO: (missing 2 last bytes)
Even taking up a little more space, thus maintaining the standards and later, can ease editions.
Image
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: changes in DirectConnection and Receive.pm for bRO

#6 Post by EternalHarvest »

ever_boy_ wrote:do I use the same code you gave me, just increasing the timeout?
That code worked? I've only tested it on local server without any pin, and it solved the timeout issue just fine.

It sets just the current time, isn't it? Duration of timeout (the only thing you could "increase") is already reasonably set in timeouts.txt and 12 seconds should be plenty for automatically sending the pin. If you need to change it for testing, do it in your control files.
KeplerBR wrote:

Code: Select all

} elsif (timeOut($timeout{'charlogin'}) && $config{'char'} ne "" && !$masterServer->{pin}) {
In other cases which might need, could use the $masterServer->{pin} also.
It is the least which alter codes OpenKore because of these conflicts, but would generate a configuration more.
Maybe I fail to see why this place should be edited? Just doing "$timeout{charlogin}{time} = time;" where you prevent its usual setting in Misc::charSelectScreen isn't enough?