MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiDoStripPlayer

Function MultiDoStripPlayer

Descent3/multi.cpp:9179–9234  ·  view source on GitHub ↗

Server is telling me to strip bare!

Source from the content-addressed store, hash-verified

9177
9178// Server is telling me to strip bare!
9179void MultiDoStripPlayer(int slot, uint8_t *data) {
9180 if (slot != 0) {
9181 // server didnt send this to us?!
9182 Int3();
9183 return;
9184 }
9185
9186 int count = 0;
9187 SKIP_HEADER(data, &count);
9188 slot = MultiGetByte(data, &count);
9189 if (Game_mode & GM_MULTI && Netgame.local_role != LR_SERVER && (slot != Player_num)) {
9190 Int3();
9191 return;
9192 }
9193
9194 mprintf(0, "I'm stripping %d bare! (of weapons)\n", slot);
9195
9196 object *pobj = &Objects[Players[slot].objnum];
9197
9198 // take quad fire
9199 static int quad_id = -2;
9200 if (pobj->dynamic_wb[LASER_INDEX].flags & DWBF_QUAD || pobj->dynamic_wb[SUPER_LASER_INDEX].flags & DWBF_QUAD) {
9201 pobj->dynamic_wb[LASER_INDEX].flags &= ~DWBF_QUAD;
9202 pobj->dynamic_wb[SUPER_LASER_INDEX].flags &= ~DWBF_QUAD;
9203
9204 if (quad_id == -2)
9205 quad_id = FindObjectIDName("QuadLaser");
9206
9207 if (quad_id > -1) {
9208 Players[slot].inventory.Remove(OBJ_POWERUP, quad_id);
9209 }
9210 }
9211
9212 int i;
9213
9214 // remove weapons
9215 for (i = 0; i < MAX_PLAYER_WEAPONS; i++) {
9216 Players[slot].weapon_ammo[i] = 0;
9217 Players[slot].weapon_flags &= ~HAS_FLAG(i);
9218 }
9219
9220 // reset lasers back on
9221 Players[slot].weapon_flags = HAS_FLAG(LASER_INDEX) + HAS_FLAG(FLARE_INDEX) + HAS_FLAG(CONCUSSION_INDEX);
9222 Players[slot].weapon[PW_PRIMARY].index = LASER_INDEX;
9223 Players[slot].weapon[PW_PRIMARY].firing_time = 0;
9224 Players[slot].weapon[PW_PRIMARY].sound_handle = -1;
9225 Players[slot].weapon[PW_SECONDARY].index = CONCUSSION_INDEX;
9226 Players[slot].weapon[PW_SECONDARY].firing_time = 0;
9227 Players[slot].weapon[PW_SECONDARY].sound_handle = -1;
9228
9229 // set energy to 0
9230 Players[slot].energy = 0;
9231
9232 // remove counter measures
9233 Players[slot].counter_measures.Reset(true, INVRESET_DEATHSPEW);
9234}
9235
9236// Strips a player bare of weapons

Callers 2

MultiSendStripPlayerFunction · 0.85
MultiProcessDataFunction · 0.85

Calls 5

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
FindObjectIDNameFunction · 0.85
RemoveMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected