Add strong/weak id to ddnetcharacter

This commit is contained in:
trml 2019-05-02 00:34:20 +02:00
parent ae57b7f205
commit 09401a83ec
4 changed files with 12 additions and 0 deletions

View file

@ -216,6 +216,7 @@ Objects = [
NetTick("m_FreezeEnd"), NetTick("m_FreezeEnd"),
NetIntRange("m_Jumps", 0, 255), NetIntRange("m_Jumps", 0, 255),
NetIntAny("m_TeleCheckpoint"), NetIntAny("m_TeleCheckpoint"),
NetIntRange("m_StrongWeakID", 0, 'MAX_CLIENTS-1'),
]), ]),
## Events ## Events

View file

@ -24,6 +24,7 @@ CCharacter::CCharacter(CGameWorld *pWorld)
m_ProximityRadius = ms_PhysSize; m_ProximityRadius = ms_PhysSize;
m_Health = 0; m_Health = 0;
m_Armor = 0; m_Armor = 0;
m_StrongWeakID = 0;
} }
void CCharacter::Reset() void CCharacter::Reset()
@ -1216,6 +1217,7 @@ void CCharacter::Snap(int SnappingClient)
pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTick + m_FreezeTime; pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTick + m_FreezeTime;
pDDNetCharacter->m_Jumps = m_Core.m_Jumps; pDDNetCharacter->m_Jumps = m_Core.m_Jumps;
pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint; pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint;
pDDNetCharacter->m_StrongWeakID = m_StrongWeakID;
} }
int CCharacter::NetworkClipped(int SnappingClient) int CCharacter::NetworkClipped(int SnappingClient)

View file

@ -258,6 +258,7 @@ public:
vec2 m_TeleGunPos; vec2 m_TeleGunPos;
bool m_TeleGunTeleport; bool m_TeleGunTeleport;
bool m_IsBlueTeleGunTeleport; bool m_IsBlueTeleGunTeleport;
int m_StrongWeakID;
// Setters/Getters because i don't want to modify vanilla vars access modifiers // Setters/Getters because i don't want to modify vanilla vars access modifiers
int GetLastWeapon() { return m_LastWeapon; }; int GetLastWeapon() { return m_LastWeapon; };

View file

@ -280,6 +280,14 @@ void CGameWorld::Tick()
RemoveEntities(); RemoveEntities();
UpdatePlayerMaps(); UpdatePlayerMaps();
// find the characters' strong/weak id
int StrongWeakID = 0;
for(CCharacter *pChar = (CCharacter*) FindFirst(ENTTYPE_CHARACTER); pChar; pChar = (CCharacter*) pChar->TypeNext())
{
pChar->m_StrongWeakID = StrongWeakID;
StrongWeakID++;
}
} }
// TODO: should be more general // TODO: should be more general