- use a dedicated variable to store the vehicle ammo for RRRA's bike and boat.

owner should be reserved for pointers.
This commit is contained in:
Christoph Oelckers 2020-10-28 07:30:17 +01:00
parent 803cf4aece
commit 10d4f92232
3 changed files with 15 additions and 14 deletions

View file

@ -1491,7 +1491,7 @@ void checkweapons_r(struct player_struct* p)
{ {
auto j = spawn(p->GetActor(), 7220); auto j = spawn(p->GetActor(), 7220);
j->s.ang = p->angle.ang.asbuild(); j->s.ang = p->angle.ang.asbuild();
j->s.owner = p->ammo_amount[MOTORCYCLE_WEAPON]; // hijack! j->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
p->OnMotorcycle = 0; p->OnMotorcycle = 0;
p->gotweapon.Clear(MOTORCYCLE_WEAPON); p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->horizon.horiz = q16horiz(0); p->horizon.horiz = q16horiz(0);
@ -1507,7 +1507,7 @@ void checkweapons_r(struct player_struct* p)
{ {
auto j = spawn(p->GetActor(), 7233); auto j = spawn(p->GetActor(), 7233);
j->s.ang = p->angle.ang.asbuild(); j->s.ang = p->angle.ang.asbuild();
j->s.owner = p->ammo_amount[BOAT_WEAPON]; // hijack! j->saved_ammo = p->ammo_amount[BOAT_WEAPON];
p->OnBoat = 0; p->OnBoat = 0;
p->gotweapon.Clear(BOAT_WEAPON); p->gotweapon.Clear(BOAT_WEAPON);
p->horizon.horiz = q16horiz(0); p->horizon.horiz = q16horiz(0);
@ -2384,7 +2384,6 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int
static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz)
{ {
int j;
auto p = &ps[snum]; auto p = &ps[snum];
auto pact = p->GetActor(); auto pact = p->GetActor();
int psectlotag = sector[psect].lotag; int psectlotag = sector[psect].lotag;
@ -4186,7 +4185,7 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite)
p->posx = motosprite->s.x; p->posx = motosprite->s.x;
p->posy = motosprite->s.y; p->posy = motosprite->s.y;
p->angle.ang = buildang(motosprite->s.ang); p->angle.ang = buildang(motosprite->s.ang);
p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->s.owner; // hijack p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo;
deletesprite(motosprite); deletesprite(motosprite);
} }
p->over_shoulder_on = 0; p->over_shoulder_on = 0;
@ -4243,7 +4242,7 @@ void OffMotorcycle(struct player_struct *p)
spawned->s.ang = p->angle.ang.asbuild(); spawned->s.ang = p->angle.ang.asbuild();
spawned->s.xvel += sintable[(p->angle.ang.asbuild()+512)&2047]<<7; spawned->s.xvel += sintable[(p->angle.ang.asbuild()+512)&2047]<<7;
spawned->s.yvel += sintable[p->angle.ang.asbuild()&2047]<<7; spawned->s.yvel += sintable[p->angle.ang.asbuild()&2047]<<7;
spawned->s.owner = p->ammo_amount[MOTORCYCLE_WEAPON]; spawned->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
} }
} }
@ -4262,7 +4261,7 @@ void OnBoat(struct player_struct *p, DDukeActor* boat)
p->posx = boat->s.x; p->posx = boat->s.x;
p->posy = boat->s.y; p->posy = boat->s.y;
p->angle.ang = buildang(boat->s.ang); p->angle.ang = buildang(boat->s.ang);
p->ammo_amount[BOAT_WEAPON] = boat->s.owner; p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo;
deletesprite(boat); deletesprite(boat);
} }
p->over_shoulder_on = 0; p->over_shoulder_on = 0;
@ -4307,7 +4306,7 @@ void OffBoat(struct player_struct *p)
spawned->s.ang = p->angle.ang.asbuild(); spawned->s.ang = p->angle.ang.asbuild();
spawned->s.xvel += sintable[(p->angle.ang.asbuild()+512)&2047]<<7; spawned->s.xvel += sintable[(p->angle.ang.asbuild()+512)&2047]<<7;
spawned->s.yvel += sintable[p->angle.ang.asbuild()&2047]<<7; spawned->s.yvel += sintable[p->angle.ang.asbuild()&2047]<<7;
spawned->s.owner = p->ammo_amount[BOAT_WEAPON]; spawned->saved_ammo = p->ammo_amount[BOAT_WEAPON];
} }
} }

View file

@ -64,18 +64,19 @@ static void recreateinterpolations()
StatIterator it(STAT_EFFECTOR); StatIterator it(STAT_EFFECTOR);
while ((k = it.NextIndex()) >= 0) while ((k = it.NextIndex()) >= 0)
{ {
auto sectnum = sprite[k].sectnum;
switch (sprite[k].lotag) switch (sprite[k].lotag)
{ {
case SE_31_FLOOR_RISE_FALL: case SE_31_FLOOR_RISE_FALL:
setinterpolation(&sector[sprite[k].sectnum].floorz); setinterpolation(&sector[sectnum].floorz);
break; break;
case SE_32_CEILING_RISE_FALL: case SE_32_CEILING_RISE_FALL:
setinterpolation(&sector[sprite[k].sectnum].ceilingz); setinterpolation(&sector[sectnum].ceilingz);
break; break;
case SE_17_WARP_ELEVATOR: case SE_17_WARP_ELEVATOR:
case SE_25_PISTON: case SE_25_PISTON:
setinterpolation(&sector[sprite[k].sectnum].floorz); setinterpolation(&sector[sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz); setinterpolation(&sector[sectnum].ceilingz);
break; break;
case SE_0_ROTATING_SECTOR: case SE_0_ROTATING_SECTOR:
case SE_5_BOSS: case SE_5_BOSS:
@ -86,7 +87,7 @@ static void recreateinterpolations()
case SE_16_REACTOR: case SE_16_REACTOR:
case SE_26: case SE_26:
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
setsectinterpolate(sprite[k].sectnum); setsectinterpolate(sectnum);
break; break;
} }
} }
@ -335,6 +336,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, weaponhit& w, weap
("bposy", w.bposy, def->bposy) ("bposy", w.bposy, def->bposy)
("bposz", w.bposz, def->bposz) ("bposz", w.bposz, def->bposz)
("aflags", w.aflags, def->aflags) ("aflags", w.aflags, def->aflags)
("saved_ammo", w.saved_ammo, def->saved_ammo)
("temp_actor", w.temp_actor, def->temp_actor) ("temp_actor", w.temp_actor, def->temp_actor)
("seek_actor", w.seek_actor, def->seek_actor) ("seek_actor", w.seek_actor, def->seek_actor)
.Array("temp_data", w.temp_data, def->temp_data, 6) .Array("temp_data", w.temp_data, def->temp_data, 6)

View file

@ -28,7 +28,7 @@ struct weaponhit
short picnum, ang, extra, owner, movflag; short picnum, ang, extra, owner, movflag;
short tempang, actorstayput, dispicnum; short tempang, actorstayput, dispicnum;
short timetosleep; short timetosleep;
int floorz, ceilingz, lastvx, lastvy, bposx, bposy, bposz, aflags; int floorz, ceilingz, lastvx, lastvy, bposx, bposy, bposz, aflags, saved_ammo;
int temp_data[6]; int temp_data[6];
weaponhit* temp_actor, *seek_actor; weaponhit* temp_actor, *seek_actor;
spritetype& s; // direct reference to the corresponding sprite. spritetype& s; // direct reference to the corresponding sprite.
@ -42,7 +42,7 @@ struct weaponhit
{ {
cgg = spriteextra = 0; cgg = spriteextra = 0;
picnum = ang = extra = owner = movflag = tempang = actorstayput = dispicnum = timetosleep = 0; picnum = ang = extra = owner = movflag = tempang = actorstayput = dispicnum = timetosleep = 0;
floorz = ceilingz = lastvx = lastvy = bposx = bposy = bposz = aflags = 0; floorz = ceilingz = lastvx = lastvy = bposx = bposy = bposz = aflags = saved_ammo = 0;
memset(temp_data, 0, sizeof(temp_data)); memset(temp_data, 0, sizeof(temp_data));
} }
int GetIndex() const { return this - array(); } int GetIndex() const { return this - array(); }