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