The TalkNPC of MapRoute makes Disconnection from Map server

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderators: Moderators, Developers

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

The TalkNPC of MapRoute makes Disconnection from Map server

#1 Post by sofax222 »

Actually, I think this is a "trouble" but not a "bug".

The Scenario:
When my role routes from ama_in02 into ama_dun01 or from ama_dun01 back to ama_in02 with npc-talking portal,
it ("MapRoute" task) make disconnection from Map server.

What Happen:
The iterate of MapRoute is more fast then Map Wrap !
Or, I can say that
The "close" of NPC-Talking subtask is too quickly than Map Wrap !

After my tracing as following :
(I has simplized the tracing messages. The "...." indents are tracing messages):

士兵#10: 那麼,我就幫你打開門了
士兵#10: 千萬好好保重囉...
士兵#10: Done talking
.......Sent 士兵#10: Done talking
.......Sent talk cancel: 1A CC 00 00

Done talking with 士兵#10.
.......Target NPC Not Started !
.......Target NPC 士兵#10 at (115,177) found.
.......Sent look: 3
.......Sent talk: 1A CC 00 00

Map Change: ama_dun01.gat (229, 10)
.......Sending Map Loaded
.......Checking for new portals...
.......No source portal found.

Done talking with 士兵#10.
.......Map Router has finished traversing the map solution
Calculating random route to: 榻榻米 迷宮 (ama_dun01): 220, 228
.......You on route to: 榻榻米 迷宮(ama_dun01): 220, 228
Disconnected from Map Server, connecting to Account Server in 30 seconds...


The black is the normal console messages.
The green is the ending of first TalkNPC subtask for npc-taliking portal.
The red is the starting of second TalkNPC subtask for npc-taliking portal and the disconnection message.
The blue is the random route after map wrap.

You can see that the "Map Change" is between two "Done talking"'s.
Because, it (iterate of MapRoute) is too fast, it re-generate a New TalkNPC subtask before the complete of "Map Change".
So, the second TalkNPC subtask make opnekore to disconect from Map server.

My solution is to add a timeOut check (2 seconds) for the "close" of npc-talking. As following:
Original Code in src/Task/MapRoute.pm:

Code: Select all

......
		if ( $self->{substage} eq 'Waiting for Warp' ) {
			$self->{timeout} = time unless $self->{timeout};
			if (timeOut($self->{timeout}, $timeout{ai_route_npcTalk}{timeout} || 10)
			 || $ai_v{npc_talk}{talk} eq 'close') {
				# We waited for 10 seconds and got nothing
				delete $self->{substage};
				delete $self->{timeout};
				if (++$self->{mapSolution}[0]{retry} >= ($config{route_maxNpcTries} || 5)) {
					# NPC sequence is a failure
					# We delete that portal and try again
					delete $portals_lut{"$self->{mapSolution}[0]{map} $self->{mapSolution}[0]{pos}{x} $self->{mapSolution}[0]{pos}{y}"};
					warning TF("Unable to talk to NPC at %s (%s,%s).\n", $field->baseName, $self->{mapSolution}[0]{pos}{x}, $self->{mapSolution}[0]{pos}{y}), "route";
					$self->initMapCalculator();	# redo MAP router
				}
			}

......
My New Code in src/Task/MapRoute.pm:

Code: Select all

......
		if ( $self->{substage} eq 'Waiting for Warp' ) {
			$self->{timeout} = time unless $self->{timeout};
			if (timeOut($self->{timeout}, $timeout{ai_route_npcTalk}{timeout} || 10)
			 || (($ai_v{npc_talk}{talk} eq 'close') && (timeOut($self->{timeout}, 2)))) {
				# We waited for 10 seconds and got nothing
				delete $self->{substage};
				delete $self->{timeout};
				if (++$self->{mapSolution}[0]{retry} >= ($config{route_maxNpcTries} || 5)) {
					# NPC sequence is a failure
					# We delete that portal and try again
					delete $portals_lut{"$self->{mapSolution}[0]{map} $self->{mapSolution}[0]{pos}{x} $self->{mapSolution}[0]{pos}{y}"};
					warning TF("Unable to talk to NPC at %s (%s,%s).\n", $field->baseName, $self->{mapSolution}[0]{pos}{x}, $self->{mapSolution}[0]{pos}{y}), "route";
					$self->initMapCalculator();	# redo MAP router
				}
			}

......
I think this is a bad solution, but it is a tempelate solution.
There should be a better solution than this.
Or
There should be better solutions than this.

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#2 Post by EternalHarvest »

Try to remove "|| $ai_v{npc_talk}{talk} eq 'close'" instead. If NPC warp fails due to wrong talk sequence, ai_route_npcTalk timeout should handle it anyway.

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

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#3 Post by sofax222 »

EternalHarvest wrote:Try to remove "|| $ai_v{npc_talk}{talk} eq 'close'" instead. If NPC warp fails due to wrong talk sequence, ai_route_npcTalk timeout should handle it anyway.
But, it still need a conditional moment to do the following actions:
delete $self->{substage};
delete $self->{timeout};


In another words, it need to delete the TalkNPC subtask after success wrap !

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#4 Post by EternalHarvest »

Doesn't it happen there?

Code: Select all

	} elsif ( $field->baseName ne $self->{mapSolution}[0]{map}
	     || ( $self->{mapChanged} && !$self->{teleport} ) ) {
		# Solution Map does not match current map
		debug "Current map " . $field->baseName . " does not match solution [ $self->{mapSolution}[0]{portal} ].\n", "route";
		delete $self->{substage};
		delete $self->{timeout};
		delete $self->{mapChanged};
		shift @{$self->{mapSolution}};
I haven't tested it, but it's the only place (except route_teleport logic) which handles map change in MapRoute. The one with "if ( $self->{substage} eq 'Waiting for Warp' ) {" is only for the case where warp failed?

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

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#5 Post by sofax222 »

EternalHarvest wrote:Doesn't it happen there?

Code: Select all

	} elsif ( $field->baseName ne $self->{mapSolution}[0]{map}
	     || ( $self->{mapChanged} && !$self->{teleport} ) ) {
		# Solution Map does not match current map
		debug "Current map " . $field->baseName . " does not match solution [ $self->{mapSolution}[0]{portal} ].\n", "route";
		delete $self->{substage};
		delete $self->{timeout};
		delete $self->{mapChanged};
		shift @{$self->{mapSolution}};
I haven't tested it, but it's the only place (except route_teleport logic) which handles map change in MapRoute. The one with "if ( $self->{substage} eq 'Waiting for Warp' ) {" is only for the case where warp failed?
Thank you very much !!
Yes ! it works fine !

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#6 Post by EternalHarvest »

How about committing it?

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

Re: The TalkNPC of MapRoute makes Disconnection from Map server

#7 Post by sofax222 »

EternalHarvest wrote:How about committing it?
Yes, thank you very much !

Locked