Shared: Go over the weapon pickup logic for all the weapons to ensure

we guarantee new pickups properly.
This commit is contained in:
Marco Cawthorne 2022-01-03 16:45:24 -08:00
parent 3049576c5b
commit 8d1dbdd79c
Signed by: eukara
GPG key ID: C196CD8BA993248A
12 changed files with 51 additions and 32 deletions

View file

@ -87,13 +87,16 @@ w_crossbow_pickup(int new, int startammo)
if (new) { if (new) {
pl.crossbow_mag = 5; pl.crossbow_mag = 5;
} else { return (1);
}
if (pl.ammo_bolt < MAX_A_BOLT) { if (pl.ammo_bolt < MAX_A_BOLT) {
pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, MAX_A_BOLT); pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, MAX_A_BOLT);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -92,6 +92,7 @@ int w_egon_pickup(int new, int startammo)
if (pl.ammo_uranium < MAX_A_URANIUM) { if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM); pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif

View file

@ -79,6 +79,7 @@ int w_gauss_pickup(int new, int startammo)
if (pl.ammo_uranium < MAX_A_URANIUM) { if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM); pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif

View file

@ -126,13 +126,15 @@ w_glock_pickup(int new, int startammo)
if (new) { if (new) {
pl.glock_mag = 18; pl.glock_mag = 18;
} else { return (1);
}
if (pl.ammo_9mm < MAX_A_9MM) { if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, MAX_A_9MM); pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, MAX_A_9MM);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -70,6 +70,7 @@ int w_handgrenade_pickup(int new, int startammo)
if (pl.ammo_handgrenade < MAX_A_HANDGRENADE) { if (pl.ammo_handgrenade < MAX_A_HANDGRENADE) {
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, MAX_A_HANDGRENADE); pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, MAX_A_HANDGRENADE);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif

View file

@ -72,13 +72,15 @@ w_mp5_pickup(int new, int startammo)
if (new) { if (new) {
pl.mp5_mag = 25; pl.mp5_mag = 25;
} else { return (1);
}
if (pl.ammo_9mm < MAX_A_9MM) { if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, MAX_A_9MM); pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, MAX_A_9MM);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -67,13 +67,15 @@ w_python_pickup(int new, int startammo)
if (new) { if (new) {
pl.python_mag = 6; pl.python_mag = 6;
} else { return (1);
}
if (pl.ammo_357 < MAX_A_357) { if (pl.ammo_357 < MAX_A_357) {
pl.ammo_357 = bound(0, pl.ammo_357 + 6, MAX_A_357); pl.ammo_357 = bound(0, pl.ammo_357 + 6, MAX_A_357);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -74,13 +74,15 @@ int w_rpg_pickup(int new, int startammo)
if (new) { if (new) {
pl.rpg_mag = 1; pl.rpg_mag = 1;
} else { return (1);
}
if (pl.ammo_rocket < MAX_A_ROCKET) { if (pl.ammo_rocket < MAX_A_ROCKET) {
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET); pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -130,6 +130,7 @@ w_satchel_pickup(int new, int startammo)
if (pl.ammo_satchel < MAX_A_SATCHEL) { if (pl.ammo_satchel < MAX_A_SATCHEL) {
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, MAX_A_SATCHEL); pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, MAX_A_SATCHEL);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif

View file

@ -127,13 +127,15 @@ w_shotgun_pickup(int new, int startammo)
if (new) { if (new) {
pl.shotgun_mag = 8; pl.shotgun_mag = 8;
} else { return (1);
}
if (pl.ammo_buckshot < MAX_A_BUCKSHOT) { if (pl.ammo_buckshot < MAX_A_BUCKSHOT) {
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, MAX_A_BUCKSHOT); pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, MAX_A_BUCKSHOT);
} else { } else {
if (!new)
return (0); return (0);
} }
}
#endif #endif
return (1); return (1);
} }

View file

@ -155,6 +155,7 @@ int w_snark_pickup(int new, int startammo)
if (pl.ammo_snark < MAX_A_SNARK) { if (pl.ammo_snark < MAX_A_SNARK) {
pl.ammo_snark = bound(0, pl.ammo_snark + 5, MAX_A_SNARK); pl.ammo_snark = bound(0, pl.ammo_snark + 5, MAX_A_SNARK);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif

View file

@ -240,6 +240,7 @@ int w_tripmine_pickup(int new, int startammo)
if (pl.ammo_tripmine < MAX_A_TRIPMINE) { if (pl.ammo_tripmine < MAX_A_TRIPMINE) {
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, MAX_A_TRIPMINE); pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, MAX_A_TRIPMINE);
} else { } else {
if (!new)
return (0); return (0);
} }
#endif #endif