1#ifndef GAME_SERVER_SAVE_H
2#define GAME_SERVER_SAVE_H
3
4#include <base/vmath.h>
5
6#include <engine/shared/protocol.h>
7#include <game/generated/protocol.h>
8
9class IGameController;
10class CGameContext;
11class CGameWorld;
12class CCharacter;
13class CSaveTeam;
14
15enum
16{
17 RESCUEMODE_AUTO = 0,
18 RESCUEMODE_MANUAL,
19 NUM_RESCUEMODES
20};
21
22class CSaveTee
23{
24public:
25 CSaveTee();
26 ~CSaveTee() = default;
27 void Save(CCharacter *pchr);
28 void Load(CCharacter *pchr, int Team, bool IsSwap = false);
29 char *GetString(const CSaveTeam *pTeam);
30 int FromString(const char *pString);
31 void LoadHookedPlayer(const CSaveTeam *pTeam);
32 bool IsHooking() const;
33 vec2 GetPos() const { return m_Pos; }
34 const char *GetName() const { return m_aName; }
35 int GetClientId() const { return m_ClientId; }
36 void SetClientId(int ClientId) { m_ClientId = ClientId; }
37
38 enum
39 {
40 HIT_ALL = 0,
41 HAMMER_HIT_DISABLED = 1,
42 SHOTGUN_HIT_DISABLED = 2,
43 GRENADE_HIT_DISABLED = 4,
44 LASER_HIT_DISABLED = 8
45 };
46
47private:
48 int m_ClientId;
49
50 char m_aString[2048];
51 char m_aName[16];
52
53 int m_Alive;
54 int m_Paused;
55 int m_NeededFaketuning;
56
57 // Teamstuff
58 int m_TeeStarted;
59 int m_TeeFinished;
60 int m_IsSolo;
61
62 struct WeaponStat
63 {
64 int m_AmmoRegenStart;
65 int m_Ammo;
66 int m_Ammocost;
67 int m_Got;
68 } m_aWeapons[NUM_WEAPONS];
69
70 // ninja
71 struct
72 {
73 vec2 m_ActivationDir;
74 int m_ActivationTick;
75 int m_CurrentMoveTime;
76 int m_OldVelAmount;
77 } m_Ninja;
78
79 int m_LastWeapon;
80 int m_QueuedWeapon;
81
82 int m_EndlessJump;
83 int m_Jetpack;
84 int m_NinjaJetpack;
85 int m_FreezeTime;
86 int m_FreezeStart;
87 int m_DeepFrozen;
88 int m_LiveFrozen;
89 int m_EndlessHook;
90 int m_DDRaceState;
91
92 int m_HitDisabledFlags;
93 int m_CollisionEnabled;
94 int m_TuneZone;
95 int m_TuneZoneOld;
96 int m_HookHitEnabled;
97 int m_Time;
98 vec2 m_Pos;
99 vec2 m_PrevPos;
100 int m_TeleCheckpoint;
101 int m_LastPenalty;
102
103 int m_TimeCpBroadcastEndTime;
104 int m_LastTimeCp;
105 int m_LastTimeCpBroadcasted;
106 float m_aCurrentTimeCp[MAX_CHECKPOINTS];
107
108 int m_NotEligibleForFinish;
109
110 int m_HasTelegunGun;
111 int m_HasTelegunGrenade;
112 int m_HasTelegunLaser;
113
114 // Core
115 vec2 m_CorePos;
116 vec2 m_Vel;
117 int m_ActiveWeapon;
118 int m_Jumped;
119 int m_JumpedTotal;
120 int m_Jumps;
121 vec2 m_HookPos;
122 vec2 m_HookDir;
123 vec2 m_HookTeleBase;
124 int m_HookTick;
125 int m_HookState;
126 int m_HookedPlayer;
127 int m_NewHook;
128
129 // player input
130 int m_InputDirection;
131 int m_InputJump;
132 int m_InputFire;
133 int m_InputHook;
134
135 int m_ReloadTimer;
136
137 char m_aGameUuid[UUID_MAXSTRSIZE];
138};
139
140class CSaveTeam
141{
142public:
143 CSaveTeam();
144 ~CSaveTeam();
145 char *GetString();
146 int GetMembersCount() const { return m_MembersCount; }
147 // MatchPlayers has to be called afterwards
148 int FromString(const char *pString);
149 // returns true if a team can load, otherwise writes a nice error Message in pMessage
150 bool MatchPlayers(const char (*paNames)[MAX_NAME_LENGTH], const int *pClientId, int NumPlayer, char *pMessage, int MessageLen) const;
151 int Save(CGameContext *pGameServer, int Team, bool Dry = false);
152 void Load(CGameContext *pGameServer, int Team, bool KeepCurrentWeakStrong);
153
154 CSaveTee *m_pSavedTees = nullptr;
155
156 // returns true if an error occurred
157 static bool HandleSaveError(int Result, int ClientId, CGameContext *pGameContext);
158
159private:
160 CCharacter *MatchCharacter(CGameContext *pGameServer, int ClientId, int SaveId, bool KeepCurrentCharacter) const;
161
162 char m_aString[65536];
163
164 struct SSimpleSwitchers
165 {
166 int m_Status;
167 int m_EndTime;
168 int m_Type;
169 };
170 SSimpleSwitchers *m_pSwitchers = nullptr;
171
172 int m_TeamState = 0;
173 int m_MembersCount = 0;
174 int m_HighestSwitchNumber = 0;
175 int m_TeamLocked = 0;
176 int m_Practice = 0;
177};
178
179#endif // GAME_SERVER_SAVE_H
180