From ae57b7f205a9cb245f5c48f2a5fe25712a8b8dc9 Mon Sep 17 00:00:00 2001 From: trml Date: Wed, 1 May 2019 23:47:40 +0200 Subject: [PATCH 1/2] Add more fields to ddnetcharacter --- datasrc/network.py | 5 ++++- src/game/server/entities/character.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/datasrc/network.py b/datasrc/network.py index fadbc4f1e..a54c6efa0 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -6,7 +6,8 @@ GameFlags = ["TEAMS", "FLAGS"] GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED", "RACETIME"] CharacterFlags = ["SOLO", "JETPACK", "NO_COLLISION", "ENDLESS_HOOK", "ENDLESS_JUMP", "SUPER", "NO_HAMMER_HIT", "NO_SHOTGUN_HIT", "NO_GRENADE_HIT", "NO_RIFLE_HIT", "NO_HOOK", - "TELEGUN_GUN", "TELEGUN_GRENADE", "TELEGUN_LASER"] + "TELEGUN_GUN", "TELEGUN_GRENADE", "TELEGUN_LASER", + "WEAPON_HAMMER", "WEAPON_GUN", "WEAPON_SHOTGUN", "WEAPON_GRENADE", "WEAPON_LASER", "WEAPON_NINJA"] Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"] @@ -213,6 +214,8 @@ Objects = [ NetObjectEx("DDNetCharacter", "character@netobj.ddnet.tw", [ NetIntAny("m_Flags"), NetTick("m_FreezeEnd"), + NetIntRange("m_Jumps", 0, 255), + NetIntAny("m_TeleCheckpoint"), ]), ## Events diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index b6e2ecd92..c7e8fdd0d 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1200,8 +1200,22 @@ void CCharacter::Snap(int SnappingClient) pDDNetCharacter->m_Flags |= CHARACTERFLAG_TELEGUN_GRENADE; if(m_HasTeleLaser) pDDNetCharacter->m_Flags |= CHARACTERFLAG_TELEGUN_LASER; + if(m_aWeapons[WEAPON_HAMMER].m_Got) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_HAMMER; + if(m_aWeapons[WEAPON_GUN].m_Got) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_GUN; + if(m_aWeapons[WEAPON_SHOTGUN].m_Got) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_SHOTGUN; + if(m_aWeapons[WEAPON_GRENADE].m_Got) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_GRENADE; + if(m_aWeapons[WEAPON_RIFLE].m_Got) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_LASER; + if(m_Core.m_ActiveWeapon == WEAPON_NINJA) + pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_NINJA; pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTick + m_FreezeTime; + pDDNetCharacter->m_Jumps = m_Core.m_Jumps; + pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint; } int CCharacter::NetworkClipped(int SnappingClient) From 09401a83ec9c6c9bb3e85ed0cab239fc8ef5738a Mon Sep 17 00:00:00 2001 From: trml Date: Thu, 2 May 2019 00:34:20 +0200 Subject: [PATCH 2/2] Add strong/weak id to ddnetcharacter --- datasrc/network.py | 1 + src/game/server/entities/character.cpp | 2 ++ src/game/server/entities/character.h | 1 + src/game/server/gameworld.cpp | 8 ++++++++ 4 files changed, 12 insertions(+) diff --git a/datasrc/network.py b/datasrc/network.py index a54c6efa0..1ed5a09bb 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -216,6 +216,7 @@ Objects = [ NetTick("m_FreezeEnd"), NetIntRange("m_Jumps", 0, 255), NetIntAny("m_TeleCheckpoint"), + NetIntRange("m_StrongWeakID", 0, 'MAX_CLIENTS-1'), ]), ## Events diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c7e8fdd0d..601c20f53 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -24,6 +24,7 @@ CCharacter::CCharacter(CGameWorld *pWorld) m_ProximityRadius = ms_PhysSize; m_Health = 0; m_Armor = 0; + m_StrongWeakID = 0; } void CCharacter::Reset() @@ -1216,6 +1217,7 @@ void CCharacter::Snap(int SnappingClient) pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTick + m_FreezeTime; pDDNetCharacter->m_Jumps = m_Core.m_Jumps; pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint; + pDDNetCharacter->m_StrongWeakID = m_StrongWeakID; } int CCharacter::NetworkClipped(int SnappingClient) diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 28ef6bc3b..90893c72b 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -258,6 +258,7 @@ public: vec2 m_TeleGunPos; bool m_TeleGunTeleport; bool m_IsBlueTeleGunTeleport; + int m_StrongWeakID; // Setters/Getters because i don't want to modify vanilla vars access modifiers int GetLastWeapon() { return m_LastWeapon; }; diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index 3b2863a8a..e08bc5521 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -280,6 +280,14 @@ void CGameWorld::Tick() RemoveEntities(); 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