Page 1 of 2

[Fixed] CSmMlScriptIngame.GUIPlayer

Posted: 15 Feb 2013, 20:25
by steeffeen
hey there,

i stumbled upon a weird crash in my manialink script and i can't figure out why it happens...

Code: Select all

declare PlayerId = NullId;
if (InputPlayer != Null) {
	PlayerId = InputPlayer.Id;
} else {
	if (GUIPlayer != Null) {
		PlayerId = GUIPlayer.Id;
	}
}
my script crashes when accessing GUIPlayer.Id
See Screenshot
but GUIPlayer shouldn't be Null as i'm checking it beforehands

any help would be appreciated

thanks in advance
steff

//Edit: fixed

Re: CSmMlScriptIngame.GUIPlayer

Posted: 15 Feb 2013, 20:57
by steeffeen
it seems like i was able to fix it:

Code: Select all

declare PlayerId = NullId;
if (InputPlayer != Null && Players.exists(InputPlayer)) {
	PlayerId = InputPlayer.Id;
} else {
	if (GUIPlayer != Null && Players.exists(GUIPlayer)) {
		PlayerId = GUIPlayer.Id;
	}
}
Edit: nope, that doesn't do the trick.. would have been strange anyways

Re: CSmMlScriptIngame.GUIPlayer

Posted: 18 Feb 2013, 18:41
by Eole
I had this bug a long time ago but never found a way to make it happen 100% of the time. So if you have the steps to reproduce it, it would be really helpful.

Re: CSmMlScriptIngame.GUIPlayer

Posted: 20 Feb 2013, 12:45
by steeffeen
Eole wrote:I had this bug a long time ago but never found a way to make it happen 100% of the time. So if you have the steps to reproduce it, it would be really helpful.
it's quite hard to reproduce it.. :/
for me it seems like it's only happening on non-local servers (in a multiplayer game or on a dedicated server hosted on my computer everything works fine, but on serious servers it crashes...), maybe it depends on the operating system.. i have windows and it only crashes on linux servers..

anyway, how is it possible, that a null object passes the null check??

Code: Select all

if (GUIPlayer != Null) {
      PlayerId = GUIPlayer.Id;
}
the scripts crashes on accessing the Id property of the obviously not null object GUIPlayer because it happens to be null anyways -.-

Re: CSmMlScriptIngame.GUIPlayer

Posted: 21 Feb 2013, 12:09
by Slig
Then perhaps that Eole can reply to this one : are there other/external events on the server which can happen while the maniascript is executed (so races conditions would make possible to have the GUIPlayer modified between the test and the next line) ?

Re: CSmMlScriptIngame.GUIPlayer

Posted: 21 Feb 2013, 13:00
by Eole
Slig wrote:are there other/external events on the server which can happen while the maniascript is executed
No, the value of GUIPlayer can't change between the test and the next line if there's no yield, wait, sleep or instructions like that in between.

Maybe what could happen is that the player you were spectating disconnected and the GUIPlayer value is not updated/cleaned right away. So the GUIPlayer is not null but try to access to something that doesn't exist anymore.
Another hint could be that the client is not synchronized right away with the server and it creates some problems with the data accessible in the UI. That would explain why you don't encounter this error on a local server.

Re: CSmMlScriptIngame.GUIPlayer

Posted: 21 Feb 2013, 13:02
by steeffeen
Eole wrote:
Slig wrote:are there other/external events on the server which can happen while the maniascript is executed
No, the value of GUIPlayer can't change between the test and the next line if there's no yield, wait, sleep or instructions like that in between.

Maybe what could happen is that the player you were spectating disconnected and the GUIPlayer value is not updated/cleaned right away. So the GUIPlayer is not null but try to access to something that doesn't exist anymore.
Another hint could be that the client is not synchronized right away with the server and it creates some problems with the data accessible in the UI. That would explain why you don't encounter this error on a local server.
seems legit.
now my question: how to fix it? :)

Re: CSmMlScriptIngame.GUIPlayer

Posted: 21 Feb 2013, 13:13
by Eole
Well on your side I don't really see what you can do. We have to find how to solve the problem on our side.

One thing you can try is to add this in your script loop:

Code: Select all

while (True) {
  if (InputPlayer == Null) continue;

  // Do things ...
}
When a player connect to a server he receives the manilinks and starts to execute the scripts inside it before the synchro between the server and the client is done. And so, some data are not the same between the UI and the server, maybe that'll help to avoid the error.

Re: CSmMlScriptIngame.GUIPlayer

Posted: 21 Feb 2013, 13:23
by steeffeen
Eole wrote:Well on your side I don't really see what you can do. We have to find how to solve the problem on our side.

One thing you can try is to add this in your script loop:

Code: Select all

while (True) {
  if (InputPlayer == Null) continue;

  // Do things ...
}
When a player connect to a server he receives the manilinks and starts to execute the scripts inside it before the synchro between the server and the client is done. And so, some data are not the same between the UI and the server, maybe that'll help to avoid the error.
Thanks, i will give it a try asap :thumbsup:

Re: CSmMlScriptIngame.GUIPlayer

Posted: 24 Feb 2013, 03:18
by steeffeen
Tested it and it doesn't help :( :(