ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.68k stars 623 forks source link

Doors can fire their open/close target at the same time. #3082

Open malortie opened 3 years ago

malortie commented 3 years ago

The following code sections are from DoorHitTop and DoorHitBottom.

https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/doors.cpp#L644-L648

https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/doors.cpp#L697-L701

If a door does not have SF_DOOR_START_OPEN set, and calls DoorHitBottom, it will fire its "open" and "close" targets. The same happens for doors that call DoorHitTop and have SF_DOOR_START_OPEN set.

It should probably only fire the appropriate target.

In DoorHitTop, the code above should be changed to this:

if (!(pev->spawnflags & SF_DOOR_START_OPEN))
{
  // Fire the "open" target.
  SUB_UseTargets(m_hActivator, USE_TOGGLE, 0);
}
else if (!FStringNull(pev->netname))
{
  // Doors with 'Start Open' flag set are currently closed, so fire the "close" target.
  FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 );
}

In DoorHitBottom, the code above should be changed to this:

if (!(pev->spawnflags & SF_DOOR_START_OPEN))
{
  // Fire the "close" target.
  if (!FStringNull(pev->netname))
    FireTargets(STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0);
}
else
{
  // Doors with 'Start Open' flag set are currently open, so fire the "open" target.
  SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
}
FreeSlave commented 3 years ago

I don't see it as a bug. The code clearly is not written to suggest that a Target of a func_door must work only when it reaches "Open" state. If you change the behavior, some maps logic can break.