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

Function InitPlayerNewLevel

Descent3/Player.cpp:1402–1483  ·  view source on GitHub ↗

Called when a player is entering a new level

Source from the content-addressed store, hash-verified

1400
1401// Called when a player is entering a new level
1402void InitPlayerNewLevel(int slot) {
1403 ASSERT(slot >= 0 && slot < MAX_PLAYERS);
1404
1405 if (Player_num == slot && (!(Game_mode & GM_MULTI))) {
1406 // see if we should restore our shields (which were saved in the last call
1407 // to ResetPlayerObject. Only restore if shields are >INITIAL_SHIELDS
1408 if (Player_shields_saved_from_last_level > INITIAL_SHIELDS)
1409 Objects[Players[slot].objnum].shields = Player_shields_saved_from_last_level;
1410 if (Player_energy_saved_from_last_level > INITIAL_ENERGY)
1411 Players[slot].energy = Player_energy_saved_from_last_level;
1412
1413 // set this to -1 to prevent any unneeded madness
1414 Player_shields_saved_from_last_level = -1.0f;
1415 Player_energy_saved_from_last_level = -1.0f;
1416 }
1417
1418 Players[slot].num_kills_level = 0;
1419 Players[slot].friendly_kills_level = 0;
1420 Players[slot].num_hits_level = 0;
1421 Players[slot].num_discharges_level = 0;
1422 Players[slot].num_markers = 0;
1423 Players[slot].inventory.Reset(true, (Game_mode & GM_MULTI) ? INVRESET_ALL : INVRESET_LEVELCHANGE);
1424 Players[slot].counter_measures.Reset(true, (Game_mode & GM_MULTI) ? INVRESET_ALL : INVRESET_LEVELCHANGE);
1425 Players[slot].keys = 0;
1426 Players[slot].num_deaths_level = 0;
1427
1428 if (Game_mode & GM_MULTI)
1429 NetPlayers[slot].packet_time = 0;
1430
1431 if (slot == Player_num)
1432 Player_camera_objnum = -1;
1433
1434 // Turn off rear view
1435 Players[slot].flags &= ~PLAYER_FLAGS_REARVIEW;
1436
1437 // Kill autowaypoint
1438 Players[slot].current_auto_waypoint_room = -1;
1439
1440 // Restore Quad Lasers if they are still in inventory
1441 static int quad_laser_id = -2;
1442 if (quad_laser_id == -2)
1443 quad_laser_id = FindObjectIDName("QuadLaser");
1444 if (quad_laser_id != -1) {
1445 if (Players[slot].inventory.CheckItem(OBJ_POWERUP, quad_laser_id)) {
1446 object *pobj = &Objects[Players[slot].objnum];
1447 pobj->dynamic_wb[LASER_INDEX].flags |= DWBF_QUAD;
1448 pobj->dynamic_wb[SUPER_LASER_INDEX].flags |= DWBF_QUAD;
1449 }
1450 }
1451
1452 uint32_t bit = (0x01 << slot);
1453 Players_typing &= ~bit;
1454
1455 // Give the player a GuideBot if he doesn't have one and if the GB isn't out there
1456 if ((!(Game_mode & GM_MULTI)) && (Demo_flags != DF_PLAYBACK)) {
1457 if ((!Players[slot].inventory.CheckItem(OBJ_ROBOT, ROBOT_GUIDEBOT)) &&
1458 (ObjGet(Buddy_handle[slot])->type != OBJ_ROBOT))
1459 Players[slot].inventory.Add(OBJ_ROBOT, ROBOT_GUIDEBOT);

Callers 4

StartLevelFunction · 0.85
MultiDoPlayerFunction · 0.85
MultiDoPlayerEnteredGameFunction · 0.85
MultiStartNewLevelFunction · 0.85

Calls 6

FindObjectIDNameFunction · 0.85
ObjGetFunction · 0.85
MakePlayerInvulnerableFunction · 0.85
CheckItemMethod · 0.80
ResetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected