MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SV_Player_EndOfLevelSave

Function SV_Player_EndOfLevelSave

code/server/sv_ccmds.cpp:92–221  ·  view source on GitHub ↗

Save out some player data for later restore if this is a spawn point with KEEP_PREV (spawnflags&1) set... (now also called by auto-save code to setup the cvars correctly

Source from the content-addressed store, hash-verified

90//
91// (now also called by auto-save code to setup the cvars correctly
92void SV_Player_EndOfLevelSave(void)
93{
94 int i;
95
96 // I could just call GetClientState() but that's in sv_bot.cpp, and I'm not sure if that's going to be deleted for
97 // the single player build, so here's the guts again...
98 //
99 client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
100
101 if (cl
102 &&
103 cl->gentity && cl->gentity->client // crash fix for voy4->brig transition when you kill Foster.
104 // Shouldn't happen, but does sometimes...
105 )
106 {
107 Cvar_Set( sCVARNAME_PLAYERSAVE, ""); // default to blank
108
109// clientSnapshot_t* pFrame = &cl->frames[cl->netchan.outgoingSequence & PACKET_MASK];
110 playerState_t* pState = cl->gentity->client;
111 const char *s2;
112 const char *s;
113#ifdef JK2_MODE
114 s = va("%i %i %i %i %i %i %i %f %f %f %i %i %i %i %i %i",
115 pState->stats[STAT_HEALTH],
116 pState->stats[STAT_ARMOR],
117 pState->stats[STAT_WEAPONS],
118 pState->stats[STAT_ITEMS],
119 pState->weapon,
120 pState->weaponstate,
121 pState->batteryCharge,
122 pState->viewangles[0],
123 pState->viewangles[1],
124 pState->viewangles[2],
125 pState->forcePowersKnown,
126 pState->forcePower,
127 pState->saberActive,
128 pState->saberAnimLevel,
129 pState->saberLockEnemy,
130 pState->saberLockTime
131 );
132#else
133 // |general info |-force powers |-saber 1 |-saber 2 |-general saber
134 s = va("%i %i %i %i %i %i %i %f %f %f %i %i %i %i %i %s %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %s %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
135 pState->stats[STAT_HEALTH],
136 pState->stats[STAT_ARMOR],
137 pState->stats[STAT_WEAPONS],
138 pState->stats[STAT_ITEMS],
139 pState->weapon,
140 pState->weaponstate,
141 pState->batteryCharge,
142 pState->viewangles[0],
143 pState->viewangles[1],
144 pState->viewangles[2],
145 //force power data
146 pState->forcePowersKnown,
147 pState->forcePower,
148 pState->forcePowerMax,
149 pState->forcePowerRegenRate,

Callers 3

WriteGameFunction · 0.85
SV_MapTransition_fFunction · 0.85
SV_LoadTransition_fFunction · 0.85

Calls 2

Cvar_SetFunction · 0.50
vaFunction · 0.50

Tested by

no test coverage detected