Skip to content

Commit

Permalink
Merge pull request #23 from UndeadZeratul/main
Browse files Browse the repository at this point in the history
Refactor RemovedClasses CVARs
  • Loading branch information
UndeadZeratul authored Aug 14, 2023
2 parents 2f7695a + 8132e1e commit e28fcdd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions zscript/ReusableAmmoboxes/spawnReplacer.zs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ class ReusableAmmoboxesSpawner : EventHandler {

cvarsAvailable = true;

// Init enabled ammo CVARs
for (let i = 0; i < 1 + HDBulletLibHandler.removedClasses.Size() / 32; ++i) {
if (!ammoSpawns[i]) {
ammoSpawns[i] = CVar.GetCVar("hdblib_enableammo_"..(i + 1));
}
}

//------------
// Ammunition
//------------
Expand Down Expand Up @@ -391,18 +398,10 @@ class ReusableAmmoboxesSpawner : EventHandler {
// Populates the main arrays if they haven't been already.
if (!cvarsAvailable) init();

let handler = HDBulletLibHandler(EventHandler.find('HDBulletLibHandler'));

for (let i = 0; i < 1 + handler.removedClasses.Size() / 32; ++i) {
if (!ammoSpawns[i]) {
ammoSpawns[i] = CVar.GetCVar("hdblib_enableammo_"..(i + 1));
}
}

for (let i = 0; i < handler.removedClasses.size(); i++) {
for (let i = 0; i < HDBulletLibHandler.removedClasses.size(); i++) {
if (!(ammoSpawns[i / 32].GetInt() & (1 << (i % 32)))) {
foreach (itemSpawn : itemSpawnList) {
string ammoName = handler.removedClasses[i].getClassName();
string ammoName = HDBulletLibHandler.removedClasses[i].getClassName();

if (itemSpawn.ammoName ~== ammoName) {
if (hd_debug) console.printf("Removing "..itemSpawn.replaceName.." from Backpack Spawn Pool");
Expand All @@ -416,6 +415,9 @@ class ReusableAmmoboxesSpawner : EventHandler {

override void worldThingSpawned(WorldEvent e) {

// Populates the main arrays if they haven't been already.
if (!cvarsAvailable) init();

// If thing spawned doesn't exist, quit
if (!e.thing) return;

Expand Down

0 comments on commit e28fcdd

Please sign in to comment.