Page MenuHomeFeedback Tracker

PlayerBase::CommandHandler may use stale pCurrentCommandID
Assigned, NormalPublic

Description

The PlayerBase command handler calls super at the top. This calls the DayZPlayerImplement command handler, which may start another command, but PlayerBase CmdHandler keeps using the originally passed in pCurrentCommandID which may now be stale and can only be used to check for finished commands in PlayerBase CmdHandler. All other checks for current cmd should call GetMovementState after the super, and then use
m_MovementState.m_CommandTypeId instead.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

lava76 created this task.Fri, Feb 14, 5:19 PM
Geez changed the task status from New to Assigned.Mon, Feb 17, 1:11 PM
Geez added a subscriber: Geez.Tue, Feb 18, 3:23 PM

Hello lava76.
This is intended. When you need the current command ID, use 'Human.GetCurrentCommandID'. For a reference in scripts, see the comment above 'ActionManagerClient.Update'.

pCurrentCommandID is command ID at time of call command handler, some called methods can change actual true value (need call m_Player.GetCurrentCommandID() for actual command ID)
Geez closed this task as Resolved.Tue, Feb 18, 3:23 PM
Geez claimed this task.

This is not my code, that is vanilla code. The vanilla PlayerBase::CommandHandler uses the stale pCurrentCommandID.

Geez added a comment.Tue, Feb 18, 3:45 PM

This is not my code, that is vanilla code. The vanilla PlayerBase::CommandHandler uses the stale pCurrentCommandID.

Is there any issue you have had in particular? All places in vanilla script that use the value from CommandHandler inside PlayerBase class are using it correctly where they are intended to be looking for the previously playing command. SymptomManager and ActionManager update their pCurrentCommandID to use 'Human.GetCurrentCommandID' to query for the current playing command and not the previously playing command

lava76 added a comment.EditedTue, Feb 18, 4:47 PM

Vanilla PlayerBase::CommandHandler, line 2990 (1.27):

if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)

This won't work as intended, since it uses the stale pCurrentCommandID.

Line 3000:

else if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH && pCurrentCommandID != DayZPlayerConstants.COMMANDID_FALL && !isTransitioning)

Death gate won't work. COMMANDID_DEATH is started in DayZPlayerImplement, but PlayerBase will not catch it until next CommandHandler tick because it uses the stale pCurrentCommandID. This can lead to awkward situations where player becomes "unconscious" after death, the very thing this death gate was supposed to prevent.

Line 3023:

		if (hcu && pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)

Same issue, stale pCurrentCommandID is used by the game.

Geez reopened this task as Assigned.Wed, Feb 19, 11:40 AM