Created
September 9, 2017 20:25
-
-
Save argv-minus-one/e63c2e1db49f359632a1872634a0d53a to your computer and use it in GitHub Desktop.
Optimization patch for GZSHud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -rud GZSHud/ZSCRIPT.zsc GZSHud_optimized/ZSCRIPT.zsc | |
--- GZSHud/ZSCRIPT.zsc 2017-04-30 23:42:40.000000000 -0700 | |
+++ GZSHud_optimized/ZSCRIPT.zsc 2017-09-09 13:20:35.879475200 -0700 | |
@@ -121,27 +121,17 @@ | |
// create the list of owned ammo | |
// this only contains ammo that the player has weapons for | |
ownedAmmo.Clear(); | |
- int end = AllActorClasses.Size(); | |
- if (CPlayer) { | |
- for (int i = 0; i < end; i++) { | |
- let type = (Class<Ammo>)(AllActorClasses[i]); | |
- let item = Ammo(CPlayer.mo.FindInventory(type)); | |
+ if (CPlayer) for (let inv = CPlayer.mo.Inv; inv; inv = inv.Inv) { | |
+ // Look through the player pawn's inventory for weapons. | |
+ if (inv is "Weapon") { | |
+ // Take each ammo item, and add it to ownedAmmo if not already present. | |
+ let ammo = Weapon(inv).Ammo1; | |
+ if (ammo && ownedAmmo.Size() == ownedAmmo.Find(ammo)) | |
+ ownedAmmo.Push(ammo); | |
- if (item) { | |
- for (int wI = 0; wI < end; wI++) { | |
- let wType = (Class<Weapon>)(AllActorClasses[wI]); | |
- let wItem = Weapon(CPlayer.mo.FindInventory(wType)); | |
- | |
- if (wItem) { | |
- Ammo a1 = wItem.Ammo1; | |
- Ammo a2 = wItem.Ammo2; | |
- if (a1 == item || a2 == item) { | |
- ownedAmmo.Push(item); | |
- break; | |
- } | |
- } | |
- } | |
- } | |
+ ammo = Weapon(inv).Ammo2; | |
+ if (ammo && ownedAmmo.Size() == ownedAmmo.Find(ammo)) | |
+ ownedAmmo.Push(ammo); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment