mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-07-11 14:08:37 -04:00
Introduce g_BeamsActive so we can avoid iterating props
This commit is contained in:
+8
-5
@@ -7508,18 +7508,21 @@ void bgunTickGameplay2(void)
|
||||
bgunIsUsingSecondaryFunction();
|
||||
}
|
||||
|
||||
s8 bgunFreeFireslotWrapper(s32 slotnum)
|
||||
void bgunFreeFireslotWrapper(s32 slotnum)
|
||||
{
|
||||
return bgunFreeFireslot(slotnum);
|
||||
bgunFreeFireslot(slotnum);
|
||||
}
|
||||
|
||||
s8 bgunFreeFireslot(s32 fireslot_id)
|
||||
void bgunFreeFireslot(s32 fireslot_id)
|
||||
{
|
||||
if (fireslot_id >= 0 && fireslot_id < NUM_FIRESLOTS) {
|
||||
if (g_Fireslots[fireslot_id].endlvframe >= 0 && g_Fireslots[fireslot_id].beam.age >= 0) {
|
||||
g_Fireslots[fireslot_id].beam.age = -1;
|
||||
g_BeamsActive--;
|
||||
}
|
||||
|
||||
g_Fireslots[fireslot_id].endlvframe = -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 bgunAllocateFireslot(void)
|
||||
|
||||
@@ -8572,8 +8572,11 @@ void chrStopFiring(struct chrdata *chr)
|
||||
|
||||
chrResetAimEndProperties(chr);
|
||||
|
||||
chr->fireslots[0] = bgunFreeFireslot(chr->fireslots[0]);
|
||||
chr->fireslots[1] = bgunFreeFireslot(chr->fireslots[1]);
|
||||
bgunFreeFireslot(chr->fireslots[0]);
|
||||
bgunFreeFireslot(chr->fireslots[1]);
|
||||
|
||||
chr->fireslots[0] = -1;
|
||||
chr->fireslots[1] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ struct casing g_Casings[20];
|
||||
struct boltbeam g_BoltBeams[8];
|
||||
struct lasersight g_LaserSights[4];
|
||||
|
||||
s32 g_BeamsActive;
|
||||
|
||||
void beamCreate(struct beam *beam, s32 weaponnum, struct coord *from, struct coord *to)
|
||||
{
|
||||
f32 distance;
|
||||
@@ -96,6 +98,8 @@ void beamCreate(struct beam *beam, s32 weaponnum, struct coord *from, struct coo
|
||||
|
||||
if (beam->dist >= beam->maxdist) {
|
||||
beam->age = -1;
|
||||
} else {
|
||||
g_BeamsActive++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +124,12 @@ void beamCreateForHand(s32 handnum)
|
||||
}
|
||||
|
||||
beam = &hand->beam;
|
||||
|
||||
if (beam->age >= 0) {
|
||||
beam->age = -1;
|
||||
g_BeamsActive--;
|
||||
}
|
||||
|
||||
beamCreate(beam, weaponnum, &hand->muzzlepos, &hand->hitpos);
|
||||
|
||||
if (beam->weaponnum == WEAPON_MAULER) {
|
||||
@@ -611,6 +621,7 @@ void beamTick(struct beam *beam)
|
||||
|
||||
if (beam->age > 1) {
|
||||
beam->age = -1;
|
||||
g_BeamsActive--;
|
||||
}
|
||||
} else {
|
||||
if (g_Vars.lvupdate240 <= 8) {
|
||||
@@ -623,6 +634,7 @@ void beamTick(struct beam *beam)
|
||||
|
||||
if (beam->dist >= beam->maxdist) {
|
||||
beam->age = -1;
|
||||
g_BeamsActive--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ void boltbeamsReset(void)
|
||||
for (i = 0; i < 8; i++) {
|
||||
g_BoltBeams[i].unk00 = -1;
|
||||
}
|
||||
|
||||
g_BeamsActive = 0;
|
||||
}
|
||||
|
||||
void lasersightsReset(void)
|
||||
|
||||
+5
-1
@@ -1288,7 +1288,11 @@ Gfx *lvRender(Gfx *gdl)
|
||||
PROFILE(PROFILEMARKER_LVR_PICKUP, propsTestForPickup());
|
||||
PROFILE(PROFILEMARKER_LVR_BG, gdl = bgRender(gdl));
|
||||
chr0f028498(false);
|
||||
PROFILE(PROFILEMARKER_LVR_BEAMS, gdl = propsRenderBeams(gdl));
|
||||
|
||||
if (g_BeamsActive > 0) {
|
||||
PROFILE(PROFILEMARKER_LVR_BEAMS, gdl = propsRenderBeams(gdl));
|
||||
}
|
||||
|
||||
PROFILE(PROFILEMARKER_LVR_SHARDS, gdl = shardsRender(gdl));
|
||||
PROFILE(PROFILEMARKER_LVR_SPARKS, gdl = sparksRender(gdl));
|
||||
PROFILE(PROFILEMARKER_LVR_WEATHER, gdl = weatherRender(gdl));
|
||||
|
||||
+2
-15
@@ -18160,8 +18160,6 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct
|
||||
f32 sqdist;
|
||||
struct prop *obstacle = NULL;
|
||||
s16 sp1c8[8];
|
||||
u8 forcebeam = false;
|
||||
struct beam beam;
|
||||
struct coord frompos;
|
||||
u32 stack2;
|
||||
u8 drug = false;
|
||||
@@ -18170,10 +18168,7 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct
|
||||
frompos = *pos;
|
||||
|
||||
if (weaponnum == WEAPON_TRANQUILIZER) {
|
||||
forcebeam = true;
|
||||
beam.age = -1;
|
||||
drug = true;
|
||||
frompos.y -= 40.0f;
|
||||
}
|
||||
|
||||
if (arg1 && arg1->unk08 < g_Vars.lvframe60) {
|
||||
@@ -18367,16 +18362,8 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct
|
||||
}
|
||||
}
|
||||
|
||||
if (forcebeam || (arg1 && arg1->unk01)) {
|
||||
struct beam *beamptr;
|
||||
|
||||
if (forcebeam) {
|
||||
beamptr = &beam;
|
||||
} else {
|
||||
beamptr = arg1->beam;
|
||||
}
|
||||
|
||||
beamCreate(beamptr, forcebeam ? WEAPON_FALCON2 : weaponnum, &frompos, &endpos);
|
||||
if (arg1 && arg1->unk01) {
|
||||
beamCreate(arg1->beam, weaponnum, &frompos, &endpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,5 +286,6 @@ extern u8 g_AmBotCommands[16];
|
||||
extern struct mpsetup g_MpSetup;
|
||||
extern struct bossfile g_BossFile;
|
||||
extern struct chrdata *g_MpBotChrPtrs[MAX_BOTS];
|
||||
extern s32 g_BeamsActive;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -182,7 +182,7 @@ void bgunSetSightVisible(u32 bits, bool visible);
|
||||
Gfx *bgunDrawSight(Gfx *gdl);
|
||||
void bgun0f0abd30(s32 handnum);
|
||||
s32 bgunGetWeaponNum2(s32 handnum);
|
||||
s8 bgunFreeFireslotWrapper(s32 fireslot);
|
||||
s8 bgunFreeFireslot(s32 fireslot);
|
||||
void bgunFreeFireslotWrapper(s32 fireslot);
|
||||
void bgunFreeFireslot(s32 fireslot);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user