From 79ef6c0e84db0df5e777b26d571730810ccccfc8 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 1 Jun 2020 11:40:11 +0200 Subject: [PATCH] Use CSaveTee for rescue (fixes #2241) --- src/game/server/entities/character.cpp | 38 ++++++-------------------- src/game/server/entities/character.h | 7 ++--- src/game/server/save.h | 6 +++- src/game/server/score/sql_score.h | 1 + 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index a523bb562..ba2aa4189 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -2154,16 +2154,8 @@ void CCharacter::DDRaceTick() int index = GameServer()->Collision()->GetPureMapIndex(m_Pos); int tile = GameServer()->Collision()->GetTileIndex(index); int ftile = GameServer()->Collision()->GetFTileIndex(index); - if(IsGrounded() && tile != TILE_FREEZE && tile != TILE_DFREEZE && ftile != TILE_FREEZE && ftile != TILE_DFREEZE) { - m_PrevSavePos = m_Pos; - for(int i = 0; i< NUM_WEAPONS; i++) - { - m_aPrevSaveWeapons[i].m_AmmoRegenStart = m_aWeapons[i].m_AmmoRegenStart; - m_aPrevSaveWeapons[i].m_Ammo = m_aWeapons[i].m_Ammo; - m_aPrevSaveWeapons[i].m_Ammocost = m_aWeapons[i].m_Ammocost; - m_aPrevSaveWeapons[i].m_Got = m_aWeapons[i].m_Got; - } - m_PrevSaveActiveWeapon = m_Core.m_ActiveWeapon; + if(IsGrounded() && tile != TILE_FREEZE && tile != TILE_DFREEZE && ftile != TILE_FREEZE && ftile != TILE_DFREEZE && !m_DeepFreeze) { + m_RescueTee.save(this); m_SetSavePos = true; } } @@ -2383,26 +2375,12 @@ void CCharacter::Rescue() return; } - m_LastRescue = Server()->Tick(); - m_Core.m_Pos = m_PrevSavePos; - m_Pos = m_PrevSavePos; - m_PrevPos = m_PrevSavePos; - m_Core.m_Vel = vec2(0, 0); - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_HookPos = m_Core.m_Pos; - m_DeepFreeze = false; - UnFreeze(); - for(int i = 0; i< NUM_WEAPONS; i++) - { - m_aWeapons[i].m_AmmoRegenStart = m_aPrevSaveWeapons[i].m_AmmoRegenStart; - m_aWeapons[i].m_Ammo = m_aPrevSaveWeapons[i].m_Ammo; - m_aWeapons[i].m_Ammocost = m_aPrevSaveWeapons[i].m_Ammocost; - m_aWeapons[i].m_Got = m_aPrevSaveWeapons[i].m_Got; - } - m_Core.m_ActiveWeapon = m_PrevSaveActiveWeapon; + float StartTime = m_StartTime; + m_RescueTee.load(this, Team()); + // Don't load these from saved tee: + m_Core.m_Vel = vec2(0, 0); + m_Core.m_HookState = HOOK_IDLE; + m_StartTime = StartTime; } } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 75b053c29..e6778873e 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -12,6 +13,7 @@ class CAntibot; class CGameTeams; +class CSaveTee; struct CAntibotCharacterData; enum @@ -112,9 +114,6 @@ private: } m_aWeapons[NUM_WEAPONS]; - struct WeaponStat m_aPrevSaveWeapons[NUM_WEAPONS]; - int m_PrevSaveActiveWeapon; - int m_LastWeapon; int m_QueuedWeapon; @@ -180,7 +179,7 @@ private: IAntibot *Antibot(); bool m_SetSavePos; - vec2 m_PrevSavePos; + CSaveTee m_RescueTee; bool m_Solo; public: diff --git a/src/game/server/save.h b/src/game/server/save.h index 6ea6c0305..d57c9f704 100644 --- a/src/game/server/save.h +++ b/src/game/server/save.h @@ -1,9 +1,13 @@ #ifndef GAME_SERVER_SAVE_H #define GAME_SERVER_SAVE_H -#include "entities/character.h" +#include +#include +#include + class IGameController; class CGameContext; +class CCharacter; class CSaveTee { diff --git a/src/game/server/score/sql_score.h b/src/game/server/score/sql_score.h index 43c5ebf24..7088186b6 100644 --- a/src/game/server/score/sql_score.h +++ b/src/game/server/score/sql_score.h @@ -5,6 +5,7 @@ #define GAME_SERVER_SCORE_SQL_H #include +#include #include #include