dabo123148 / WarlightMod

Warlight Mod
MIT License
5 stars 12 forks source link

Cannot accept alliance #14

Closed dabnug closed 6 years ago

dabnug commented 6 years ago

Hi,

Someone in the game with your mod sent me an alliance request. Using the mobile app, when I click accept, it throws an error with the below message

ServerException: Warzone Server returned ModFailed x=ModFailed: Mod "Advanced Diplo Mod V3" Failed: [string "Server_GameCustomMessage.lua"]:310: attempt to index field '?' (a nil value) addmessagecustom (Server_GameCustomMessage.lua:310) (Unknown Function) (Server_GameCustomMessage.lua:24)

GameID=15593128 Hook=Server_GameCustomMessage

Is your code base public?

dabnug commented 6 years ago

Was just looking at the code block and I am wondering if the game parameters make a difference. Let me give you sequence.

Turn N I sent an alliance request to player 1. That player never made a move and got booted thus becoming an AI.

turn N+1 I sent another alliance to a human player2. They did not accept, (no explanation yet) but rather sent a alliance request to me.

turn N+2 I try to accept the alliance request from player2(human) via the pending requests menu. The error is throw.

The block this is coming from

for _,pd in pairs(game.ServerGame.Game.Players)do if(pd.IsAI == false)then addmessagecustom(message,pd.ID);

what language is this? I am not familiar with the syntax ',' in the statement 'for ,pd in pairs'

I am not sure why this is null playerGameData[spieler].Nachrichten but when you call 'function addmessagecustom(message,spieler)' in this workflow message is a null string '{}'

Anyways hope this helps. I would be happy to test further if you could point me in the right direction. Does fiser offer any kind of test harness or dev API to test specific instances?

Thanks Chris

dabo123148 commented 6 years ago

if(playerGameData[spieler].Nachrichten == nil)then that line has the error and since playerGameData and spieler is defined it means somewhere i accidentialy have deleted the playerdata

dabnug commented 6 years ago

Here it is.

For some reason during the iteration of the for loop the playerID of ? is being passed in.

Your code does not null check the array index 'spieler'

if(playerGameData[spieler].Nachrichten == nil)then

when spieler = '?'

I assuming this is the null char in the language you are using?

dabo123148 commented 6 years ago

spieler isn't nil and playerGameData[spieler] also shouldn't become nil since it is defined for all players at the start of the game

dabnug commented 6 years ago

ahh yes. I am discovering. Its not playerGameData[nil] but rather nil[spieler]...

dabnug commented 6 years ago

too bad the stack trace does not go further..

dabnug commented 6 years ago

where does Mod.PlayerGameData come from?

dabnug commented 6 years ago

you define playerGameData from Mod.PlayerGameData in two location(separate files). Is this correct? Server_StartGame(game,standing) local playerGameData = Mod.PlayerGameData; Server_GameCustomMessage(game, playerID, payload, setReturnTable) playerGameData = Mod.PlayerGameData;

dabo123148 commented 6 years ago

Mod.PlayerGameData is given by warzone

I implemented now something that should recreate the account data when it gets lost so that should fix the bug but will also lead to the lose of data. And it is a bit different, it is not really a declaration, it is rather a change of data, that needs to be made as declaration since the engine wants it that way. https://www.warzone.com/wiki/Mod_Game_Data_Storage

dabo123148 commented 6 years ago

found the reason for the problem, I only created the data for players that were playing the game, but since a player got removed from the game by the host, it tried to access the data of the removed player who has no data. It should work now without any problems and data lose

dabnug commented 6 years ago

ok. like .net protected content of the object?

So when a player get booted, the AI that replaces them is a "New" player? What about when the player returns and retakes control from the AI? Does that player resume his previous player object or is a new instance assigned?

Thanks Chris

dabnug commented 6 years ago

Also, do your updates get pushed out in realtime, I am assuming this mod is part of the map? So each time you load the app it will auto pull new content?

dabo123148 commented 6 years ago

Yes, Mod Updates are automatically spread

On May 29, 2018 21:34, dabnug notifications@github.com wrote:

Also, do your updates get pushed out in realtime, I am assuming this mod is part of the map? So each time you load the app it will auto pull new content?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdabo123148%2FWarlightMod%2Fissues%2F14%23issuecomment-392914423&data=02%7C01%7C%7C15232d63cd4d49ce6b2008d5c59b3ab9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636632192845658827&sdata=637Y7Q73o3goPftCSCTLw0X3wnEXad7NyVfXttzeFN0%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAS9Ie9YzLftAb8a1RZEQ9xYFy4W1-Y_Nks5t3aLRgaJpZM4USBVn&data=02%7C01%7C%7C15232d63cd4d49ce6b2008d5c59b3ab9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636632192845658827&sdata=o3DDkq2h0rXtmC2K64JkfP6Pt4MOSeSMNMLkhNhOq0o%3D&reserved=0.