Page MenuHomeFeedback Tracker

PlayerIdentity returning values of other players / invalid data
Closed, ResolvedPublic


PlayerIdentity seems to suffer from memory issues. When calling it there is a random chance that part of the struct data is from another player.
The issue is present in two completely unrelated mods.

The plain id is getting mixed up and the player name sometimes returns random memory.

SCRIPT       : string msg =  '[Admin Log] - Grim(76561198022879703) teleported to: Joni(76561198071370946)'
SCRIPT       : string msg =  '[Admin Log] - Grim(76561198071370946) teleported to: 4519.127441 339.000000 9628.681641'

The sender identity already returns invalid values on the script invoker:

[20:23:25][Admin Log] - hó֍k(76561198071370946) teleported to: 5664.659668 178.526581 12906.628906


Operating System
Windows 10 x64
Steps To Reproduce

Plain ID issue:

void RPCTeleportPlayer(PlayerIdentity sender, Object target,ParamsReadContext ctx)
    Param2<SyncPlayer,vector> teleportPlayerPacket;
    Man teleportTarget = GetPlayerObjectFromID(teleportPlayerPacket.param1.m_UID);
        Logger.Log(sender.GetName() + "(" + sender.GetPlainId() + ") teleported to: " + teleportPlayerPacket.param2.ToString(false),LogType.AdminLog);

void RPCTeleportToPlayer(PlayerIdentity sender, Object target,ParamsReadContext ctx)
    Param1<SyncPlayer> teleportToPlayerPacket;
    Man teleportToTarget = GetPlayerObjectFromID(teleportToPlayerPacket.param1.m_UID);

        Man player = Man.Cast(GetPlayerObjectFromIdentity(sender));
        Logger.Log(sender.GetName() + "(" + sender.GetPlainId() + ") teleported to: " + teleportToTarget.GetIdentity().GetName() + "(" + teleportToTarget.GetIdentity().GetPlainId() + ")",LogType.AdminLog);
Additional Information

Suspected causes - Grim: PlayerIdentity cleanup/destructor or some weird scope thing

Event Timeline

Grim added a subscriber: Grim.Sep 15 2019, 12:21 PM
Camino added a subscriber: Camino.Sep 15 2019, 12:59 PM
Grim added a comment.Sep 15 2019, 2:04 PM

Line that causes the issue is

Logger.Log(sender.GetName() + "(" + sender.GetPlainId() + ") teleported to: " + teleportToTarget.GetIdentity().GetName() + "(" + teleportToTarget.GetIdentity().GetPlainId() + ")",LogType.AdminLog);

after that point PlayerIdentity is corrupted in one way or another

Remoz added a subscriber: Remoz.Sep 15 2019, 3:45 PM
Geez changed the task status from New to Assigned.Sep 16 2019, 2:34 PM
nigel added a subscriber: nigel.Sep 16 2019, 2:48 PM
sileed added a subscriber: sileed.Sep 16 2019, 2:56 PM

I had some hard hours trying to figure out the Issue causing this Problem. It's happening when you want to use the PlainId (maybe other values too) of the Player and not save the PlainId in a variable first ! I fixed I by always using string steamid = player.GetIdentity().GetPlainId(); and then compare those values ! I did not test if this is enough, but what should be enough is this code:

void OnRPC( PlayerIdentity sender, int rpc_type, ParamsReadContext  ctx) {
	GetGame().RPCSingleParam(NULL, rpc_type, new Param1<string>(sender.GetPlainId()), true, sender);

Fixed version would be:

void OnRPC( PlayerIdentity sender, int rpc_type, ParamsReadContext  ctx) {
	string steamid = sender.GetPlainId(); 
	GetGame().RPCSingleParam(NULL, rpc_type, new Param1<string>(steamid), true, sender);

what it should do is sending the Players Steam Id back to himself, but this will somehow mix up everything.
Thats the reason why

The issue is present in two completely unrelated mods.

It's enough to have this error in ANY mod and every mod will be affected

I hate to ping you, brother, but is there any update on this issue. It's something that is still happening and it's really annoying.

Any action on this? It's still a huge problem patches later.

Geez closed this task as Resolved.Fri, Aug 12, 1:24 PM
Geez claimed this task.

Hello everyone.
The problem has been tackled internally and the fix will appear in one of the upcoming updates.

lava76 added a subscriber: lava76.Sun, Aug 14, 7:21 PM
NATION added a subscriber: NATION.Mon, Aug 15, 8:06 PM