What mean is the statement in funcion.pl ??

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

Moderator: Moderators

sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

What mean is the statement in funcion.pl ??

#1 Post by sofax222 »

I just try to make r7998 openkore could run with XKore 2 mode on twRO !
When I traced the code lines, I got a problem in the function.pl file.
As following segment code lines:

Code: Select all

...................
sub mainLoop_initialized {
	Benchmark::begin("mainLoop_part1") if DEBUG;

	# Handle connection states
	$net->checkConnection();

	# Receive and handle data from the RO server
	my $data = $net->serverRecv;
	if (defined($data) && length($data) > 0) {
		Benchmark::begin("parseMsg") if DEBUG;

		$incomingMessages->add($data);
		$net->clientSend($_) for $packetParser->process(
			$incomingMessages, $packetParser
		);
		$net->clientFlush() if (UNIVERSAL::isa($net, 'Network::XKoreProxy'));
		Benchmark::end("parseMsg") if DEBUG;
	}
.......................
In the mainLoop_initialized function of the function.pl file.
What mean is the statement of following ?

Code: Select all

		$net->clientSend($_) for $packetParser->process(
			$incomingMessages, $packetParser
		);
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: What mean is the statement in funcion.pl ??

#2 Post by EternalHarvest »

# Receive and handle data from the RO server

Code: Select all

		$net->clientSend($_) for $packetParser->process(
			$incomingMessages, $packetParser
		);
Process (parse and call handlers) all received packets from the server ($incomingMessages) using packet handlers in $packetParser (usually, an instance of Network::Receive). Pass each packet to clientSend which forwards packets to XKore client if there is any.
sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: What mean is the statement in funcion.pl ??

#3 Post by sofax222 »

EternalHarvest wrote:Process (parse and call handlers) all received packets from the server ($incomingMessages) using packet handlers in $packetParser (usually, an instance of Network::Receive). Pass each packet to clientSend which forwards packets to XKore client if there is any.
So, the forwarding packects to XKore client is after the handlding packets with Network::Receive, isn't ?
But in r7762 (old one), the forwarding packects to XKore client is prior to the handlding packets with Network::Receive !
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: What mean is the statement in funcion.pl ??

#4 Post by EternalHarvest »

In r7762, parseIncomingMessage handles packets with Network::Receive and sends them to the client with clientSend.
sofax222
Developers
Developers
Posts: 214
Joined: 24 Nov 2010, 03:08
Noob?: Yes

Re: What mean is the statement in funcion.pl ??

#5 Post by sofax222 »

EternalHarvest wrote:In r7762, parseIncomingMessage handles packets with Network::Receive and sends them to the client with clientSend.
Yes, I know it.
I means:
In r7762, the clientSend is before Network::Receive.
But in r7998, the clientSend is after Network::Receive.
Because, the $net->getState() changes with throungh portal,
it make some packets could not be sent to XKore 2 client.
PS: sending the packet to XKore 2 client only for $net->getState() == Network::IN_GAME