Opened 3 years ago

Closed 3 years ago

#5625 closed defect (fixed)

Petra tribute & diplomacy request yields undefined evt.amounts[request.type]

Reported by: elexis Owned by:
Priority: Should Have Milestone: Alpha 24
Component: AI Keywords:
Cc: Patch: Phab:D2703

Description

In this very short replay for r23076, the following error occurred after spamming tributes and friend requests to the opposing AI:

Turn 192 (500)...
WARNING: JavaScript warning: simulation/ai/petra/diplomacyManager.js line 136
reference to undefined property evt.amounts[request.type]

Adding the following debug print:

Index: binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js
===================================================================
--- binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js	(revision 23075)
+++ binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js	(working copy)
@@ -131,10 +131,12 @@ PETRA.DiplomacyManager.prototype.checkEv
 		if (evt.to === PlayerID && !gameState.isPlayerAlly(evt.from) && this.receivedDiplomacyRequests.has(evt.from))
 		{
 			let request = this.receivedDiplomacyRequests.get(evt.from);
 			if (request.status === "waitingForTribute")
 			{
+				warn(uneval(evt));
+				warn(uneval(request));
 				request.wanted -= evt.amounts[request.type];
 
 				if (request.wanted <= 0)
 				{
 					if (this.Config.debug > 1)

yields:

WARNING: ({to:6, from:1, amounts:{food:500}})
WARNING: ({status:"waitingForTribute", wanted:1000, type:"wood", warnTime:152, sentWarning:false, requestType:"neutral"})
WARNING: JavaScript warning: simulation/ai/petra/diplomacyManager.js line 138
reference to undefined property evt.amounts[request.type]
WARNING: ({to:6, from:1, amounts:{metal:500}})
WARNING: ({status:"waitingForTribute", wanted:NaN, type:"wood", warnTime:152, sentWarning:false, requestType:"neutral"})

Attachments (1)

commands.txt (32.4 KB ) - added by elexis 3 years ago.

Download all attachments as: .zip

Change History (6)

by elexis, 3 years ago

Attachment: commands.txt added

comment:2 by Silier, 3 years ago

Last edited 3 years ago by Silier (previous) (diff)

comment:3 by Freagarach, 3 years ago

Cause: r23065.

Last edited 3 years ago by Freagarach (previous) (diff)

comment:4 by Freagarach, 3 years ago

Milestone: BacklogWork In Progress
Patch: Phab:D2703

comment:5 by Silier, 3 years ago

Milestone: Work In ProgressAlpha 24
Resolution: fixed
Status: newclosed

In 23596/rP23596

[PetraAI] - Only try to subtract resource gift from "waitingfortribute" if gift contains required resource.

Check for existance of requested type in event message, since rP23065 stoped sending resource codes with 0 tribute and that was not even guaranteed to get before through another options how to trigger tribute event.

Differential Revision: https://code.wildfiregames.com/D2703 Patch by: Freagarach Reviewed by: Angen Comments by: elexis

Note: See TracTickets for help on using tickets.