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

Function PlayerSpewInventory

Descent3/Player.cpp:2892–3085  ·  view source on GitHub ↗

Spews the inventory of the passed in player object

Source from the content-addressed store, hash-verified

2890
2891// Spews the inventory of the passed in player object
2892void PlayerSpewInventory(object *obj, bool spew_energy_and_shield, bool spew_nonspewable) {
2893 ASSERT(obj->type == OBJ_PLAYER || obj->type == OBJ_GHOST || obj->type == OBJ_OBSERVER);
2894 int slot = obj->id;
2895 int id, type;
2896 player *playp = &Players[slot];
2897
2898 if (slot == Player_num || (Game_mode & GM_MULTI && Netgame.local_role == LR_SERVER)) {
2899 // turn off quad firing flag (becuase they will be spewing quad fire here
2900 for (int weapon_battery = 0; weapon_battery < MAX_WBS_PER_OBJ; weapon_battery++) {
2901 obj->dynamic_wb[weapon_battery].flags &= ~DWBF_QUAD;
2902 }
2903 }
2904
2905 if (obj->type == OBJ_OBSERVER)
2906 return; // don't do anything if observer
2907
2908 if (Game_mode & GM_MULTI) {
2909 if (Netgame.local_role != LR_SERVER) {
2910 playp->inventory.Reset(true, (spew_nonspewable) ? INVRESET_ALL : INVRESET_DEATHSPEW);
2911 playp->counter_measures.Reset(true, (spew_nonspewable) ? INVRESET_ALL : INVRESET_DEATHSPEW);
2912 return;
2913 }
2914 }
2915
2916 // spew a shield and energy
2917 if (spew_energy_and_shield) {
2918 id = FindObjectIDName("Shield");
2919 if (id >= 0)
2920 PlayerSpewObject(obj, OBJ_POWERUP, id, 1, NULL);
2921
2922 id = FindObjectIDName("Energy");
2923 if (id >= 0)
2924 PlayerSpewObject(obj, OBJ_POWERUP, id, 1, NULL);
2925 }
2926
2927 // Spew the primary weapon powerups
2928 if (Game_mode & GM_MULTI) {
2929 if (playp->weapon[PW_PRIMARY].index > 0) {
2930 id = Ships[playp->ship_index].spew_powerup[playp->weapon[PW_PRIMARY].index];
2931 if (id != -1) {
2932 ASSERT(Object_info[id].type == OBJ_POWERUP);
2933 PlayerSpewObject(obj, OBJ_POWERUP, id, 2, NULL);
2934 }
2935 }
2936
2937 // Spew the secondary weapon powerups
2938 id = Ships[playp->ship_index].spew_powerup[playp->weapon[PW_SECONDARY].index];
2939 if (id != -1) {
2940 ASSERT(Object_info[id].type == OBJ_POWERUP);
2941 int count = std::min<int>(playp->weapon_ammo[playp->weapon[PW_SECONDARY].index], MAX_SECONDARY_SPEW);
2942 for (int t = 0; t < count; t++)
2943 PlayerSpewObject(obj, OBJ_POWERUP, id, 2, NULL);
2944 }
2945 } else // Single player
2946 {
2947 int w;
2948
2949 // Spew the primary weapon powerups

Callers 4

MultiDoLeaveGameFunction · 0.85
MultiDisconnectPlayerFunction · 0.85
PlayerShipExplodeFunction · 0.85
PlayerSwitchToObserverFunction · 0.85

Calls 15

FindObjectIDNameFunction · 0.85
PlayerSpewObjectFunction · 0.85
FindMultipackPowerupFunction · 0.85
ObjGetFunction · 0.85
ObjUnGhostObjectFunction · 0.85
MultiSendGhostObjectFunction · 0.85
ps_randFunction · 0.85
ResetPosMethod · 0.80
SizeMethod · 0.80
GetPosCountMethod · 0.80
GetPosTypeIDMethod · 0.80
GetPosInfoMethod · 0.80

Tested by

no test coverage detected