Vice City Multiplayer

VC:MP 0.4 (Beta) => Bugs and Crashes => Resolved Bug Reports => Topic started by: S.L.C on September 20, 2014, 12:27:16 am

Title: [WONTFIX] Player instance isn't pointing to the same thing when player leaves
Post by: S.L.C on September 20, 2014, 12:27:16 am
Description
I'm trying to use the player instance as the key inside a table, but when the player leaves the server the player instance isn't pointing to the same thing it was previously pointing in the table.

Reproducible
Always

What you were doing when the bug happened
N/A

What you think caused the bug
I'm not sure if this is a feature of the module and not a bug. If this is not expected behavior then I'll look for a bug.

Code that can reproduce the issue that I'm having:
Code: [Select]
local t_Players = {}

function onPlayerJoin(i_player)
{     
t_Players[i_player] <- null;

print("OnJoin slot search result: " + t_Players.rawin(i_player).tostring());
}

function onPlayerPart(i_player, reason)
{
print("OnPart slot search result: " + t_Players.rawin(i_player).tostring());
}

Screenshot of the console output:
(http://s9.postimg.org/7j35bmn4r/console.jpg) (http://postimg.org/image/7j35bmn4r/)
Title: Re: [WONTFIX] Player instance isn't pointing to the same thing when player leaves
Post by: stormeus on September 20, 2014, 01:34:03 am
While this is not expected behavior per se, it is also not expected that the Squirrel VM will give you the exact instance every time you request it. It's for this reason that you absolutely must do player comparisons and indexing by player ID, and not an object instance verbatim.

Won't fix.
Title: Re: [WONTFIX] Player instance isn't pointing to the same thing when player leaves
Post by: S.L.C on September 20, 2014, 01:40:37 am
Ok. Thanks for the confirmation. I will review my code to comply with this limitation.