diff --git a/datasrc/network.py b/datasrc/network.py index 01c6661e2..08fa59c54 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -199,7 +199,7 @@ Objects = [ NetIntRange("m_Health", 0, 10), NetIntRange("m_Armor", 0, 10), NetIntRange("m_AmmoCount", 0, 10), - NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'), + NetIntRange("m_Weapon", -1, 'NUM_WEAPONS-1'), NetIntRange("m_Emote", 0, len(Emotes)), NetIntRange("m_AttackTick", 0, 'max_int'), ]), diff --git a/datasrc/seven/network.py b/datasrc/seven/network.py index 2b08f0285..bc22a8783 100644 --- a/datasrc/seven/network.py +++ b/datasrc/seven/network.py @@ -166,7 +166,7 @@ Objects = [ NetIntRange("m_Health", 0, 10), NetIntRange("m_Armor", 0, 10), NetIntAny("m_AmmoCount"), - NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'), + NetIntRange("m_Weapon", -1, 'NUM_WEAPONS-1'), NetEnum("m_Emote", Emotes), NetTick("m_AttackTick"), NetFlag("m_TriggeredEvents", CoreEventFlags), diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index fffb564d8..2ee2fe3db 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -174,7 +174,7 @@ void CControls::OnMessage(int Msg, void *pRawMsg) if(g_Config.m_ClAutoswitchWeapons) m_aInputData[g_Config.m_ClDummy].m_WantedWeapon = pMsg->m_Weapon + 1; // We don't really know ammo count, until we'll switch to that weapon, but any non-zero count will suffice here - m_aAmmoCount[pMsg->m_Weapon % NUM_WEAPONS] = 10; + m_aAmmoCount[maximum(0, pMsg->m_Weapon % NUM_WEAPONS)] = 10; } } @@ -334,7 +334,7 @@ void CControls::OnRender() if(g_Config.m_ClAutoswitchWeaponsOutOfAmmo && !GameClient()->m_GameInfo.m_UnlimitedAmmo && m_pClient->m_Snap.m_pLocalCharacter) { // Keep track of ammo count, we know weapon ammo only when we switch to that weapon, this is tracked on server and protocol does not track that - m_aAmmoCount[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS] = m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount; + m_aAmmoCount[maximum(0, m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS)] = m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount; // Autoswitch weapon if we're out of ammo if(m_aInputData[g_Config.m_ClDummy].m_Fire % 2 != 0 && m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount == 0 && diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 91aa90842..a4bb1a641 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -593,7 +593,7 @@ void CHud::RenderCursor() RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y); // render cursor - int CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS; + int CurWeapon = maximum(0, m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS); Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); Graphics()->TextureSet(m_pClient->m_GameSkin.m_aSpriteWeaponCursors[CurWeapon]); Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, m_aCursorOffset[CurWeapon], m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy].x, m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy].y); @@ -684,7 +684,7 @@ void CHud::RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter) // ammo display float AmmoOffsetY = GameClient()->m_GameInfo.m_HudHealthArmor ? 24 : 0; int CurWeapon = pCharacter->m_Weapon % NUM_WEAPONS; - if(m_pClient->m_GameSkin.m_aSpriteWeaponProjectiles[CurWeapon].IsValid()) + if(CurWeapon >= 0 && m_pClient->m_GameSkin.m_aSpriteWeaponProjectiles[CurWeapon].IsValid()) { Graphics()->TextureSet(m_pClient->m_GameSkin.m_aSpriteWeaponProjectiles[CurWeapon]); if(AmmoOffsetY > 0) diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 19fc26a29..100e9824d 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -538,6 +538,7 @@ void CPlayers::RenderPlayer( } // draw gun + if(Player.m_Weapon >= 0) { if(!(RenderInfo.m_TeeRenderFlags & TEE_NO_WEAPON)) {