ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.65k stars 617 forks source link

[CS1.6,CS/CZ]armoury_entity counts are not restored at new round #1930

Open ConnorMcLeod opened 11 years ago

ConnorMcLeod commented 11 years ago

armoury_entity property that is handled with keyvalue "count" is always restore to 1 at new round, so it is only taken in account at first round (when there are only players in 1 team or when server is empty). Dunno what is exactly the problem but it is located in CArmoury::Restart

SamVanheer commented 5 years ago

CArmoury::Restart has logic to count the number of terrorists, grenades, weapons and armor in the map and determine how many items to give based on that. I don't think this entity was designed to be used outside of the escape map type, that would explain it.

I recommend adding a keyvalue that ignores those calculations and just stores and restores the initial count as set by the mapper.

Add 1 new member variables:

BOOL m_bUseInitialCountOnRestart;

Initialize it in CArmoury::KeyValue:

//...Other keyvalue logic
if( FStrEq( pkvd->szKeyName, "UseInitialCountOnRestart" ) )
{
  m_bUseInitialCountOnRestart = atoi( pkvd->szValue ) != 0;
  pkvd->fHandled = TRUE;
}
//...Remaining logic

In CArmoury::Restart:

if( m_bUseInitialCountOnRestart )
{
  m_iCount = m_iInitialCount;
}
else
{
  //Original code
}

m_iInitialCount already exists and is initialized to m_iCount in CArmoury::Spawn so it should work fine.