diff --git a/source/build/include/build.h b/source/build/include/build.h index f9e164ec7..d0dcc4079 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -168,6 +168,11 @@ inline walltype* walltype::nextWall() const return &::wall[nextwall]; } +inline walltype* walltype::point2Wall() const +{ + return &::wall[point2]; +} + inline walltype* sectortype::firstWall() const { return &wall[wallptr]; diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index 3cd8b9de9..c58f9fd94 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -138,6 +138,7 @@ struct walltype void addypan(float add) { ypan_ = fmodf(ypan_ + add + 512, 256); } // +512 is for handling negative offsets sectortype* nextSector() const; walltype* nextWall() const; + walltype* point2Wall() const; bool twoSided() const { return nextsector >= 0; } #if 0 diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 1494b31d8..6a9a8e158 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -152,3 +152,11 @@ inline int I_GetBuildTime() { return I_GetTime(120); } + +inline int32_t getangle(walltype* wal) +{ + return getangle( + wall[wal->point2].x - wal->x, + wall[wal->point2].y - wal->y); +} + diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 42f301927..1e697afe5 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -278,6 +278,19 @@ struct Collision else { index = -1; actor = &bloodActors[value & kHitIndexMask]; } return type; } + + walltype* wall() + { + assert(type == kHitWall); + return &::wall[index]; + } + + sectortype* sector() + { + assert(type == kHitSector); + return &::sector[index]; + } + }; inline DBloodActor* getUpperLink(int sect) diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index e7b7f46e6..d167f3cfa 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -40,7 +40,6 @@ BEGIN_DUKE_NS void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio) { int i, j, k, p; - short sect; int l, t1, t3, t4; spritetype* s; tspritetype* t; @@ -174,7 +173,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->pos = s->interpolatedvec3(smoothratio); } - sect = s->sectnum; + //sect = s->sectnum; + auto sectp = s->sector(); t1 = h->temp_data[1]; t3 = h->temp_data[3]; t4 = h->temp_data[4]; @@ -485,8 +485,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int PALONLY: - if (sector[sect].floorpal) - copyfloorpal(t, §or[sect]); + if (sectp->floorpal) + copyfloorpal(t, sectp); if (!h->GetOwner()) continue; @@ -617,8 +617,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->picnum = s->yvel; else t->picnum += h->temp_data[0]; - if (sector[sect].floorpal) - copyfloorpal(t, §or[sect]); + if (sectp->floorpal) + copyfloorpal(t, sectp); break; case WATERBUBBLE: @@ -630,8 +630,8 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int default: default_case: - if (sector[sect].floorpal) - copyfloorpal(t, §or[sect]); + if (sectp->floorpal) + copyfloorpal(t, sectp); break; } @@ -740,9 +740,9 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int { int daz; - if (isRRRA() && sector[sect].lotag == 160) continue; - if ((sector[sect].lotag & 0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE) - daz = sector[sect].floorz; + if (isRRRA() && sectp->lotag == 160) continue; + if ((sectp->lotag & 0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE) + daz = sectp->floorz; else daz = h->floorz; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 98f188316..2e1860644 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -19,6 +19,7 @@ #include "soundefs.h" #include "gamestruct.h" #include "v_draw.h" +#include "gamefuncs.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index f60a1adac..22b676816 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -136,7 +136,7 @@ int madenoise(int playerNum); int haskey(int sect, int snum); void shootbloodsplat(DDukeActor* i, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST); -void breakwall(short newpn, DDukeActor* spr, short dawallnum); +void breakwall(int newpn, DDukeActor* spr, int dawallnum); int callsound(int sectnum,DDukeActor* snum); int hitasprite(DDukeActor* snum,DDukeActor **hitSprite); int findplayer(const DDukeActor* s, int* dist); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 41ffc243e..cb827ad1b 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3330,8 +3330,8 @@ void processinput_r(int snum) { int i, k, doubvel, fz, cz, truefdist; Collision chz, clz; - char shrunk; - short psect, psectlotag; + bool shrunk; + int psect, psectlotag; auto p = &ps[snum]; auto pact = p->GetActor(); diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 656a36d8b..1458ed844 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -418,15 +418,15 @@ void cacheit_r(void) void prelevel_r(int g) { struct player_struct* p; - short i; - short j; - short startwall; - short endwall; - short lotaglist; + int i; + int j; + int startwall; + int endwall; + int lotaglist; short lotags[65]; int speed; int dist; - short sound; + int sound; sound = 0; prelevel_common(g); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index bf8af6cf9..a56580f0f 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -981,7 +981,7 @@ void operatesectors(int sn, DDukeActor *actor) case ST_30_ROTATE_RISE_BRIDGE: { - auto act = ScriptIndexToActor(sector[sn].hitag); + auto act = ScriptIndexToActor(sptr->hitag); if (!act) break; if (act->tempang == 0 || act->tempang == 256) callsound(sn, actor); if (act->s->extra == 1) act->s->extra = 3; @@ -991,7 +991,7 @@ void operatesectors(int sn, DDukeActor *actor) case ST_31_TWO_WAY_TRAIN: { - auto act = ScriptIndexToActor(sector[sn].hitag); + auto act = ScriptIndexToActor(sptr->hitag); if (!act) break; if (act->temp_data[4] == 0) act->temp_data[4] = 1; @@ -1218,7 +1218,7 @@ void operateforcefields_common(DDukeActor *effector, int low, const std::initial // //--------------------------------------------------------------------------- -void breakwall(short newpn, DDukeActor* spr, short dawallnum) +void breakwall(int newpn, DDukeActor* spr, int dawallnum) { wall[dawallnum].picnum = newpn; S_PlayActorSound(VENT_BUST, spr); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index f89dd8e7c..d83760e95 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -199,7 +199,7 @@ struct player_struct int aim_mode, ftt; - int cursectnum, one_parallax_sectnum; // sector references. Make them pointers later? + int cursectnum, one_parallax_sectnum, access_wallnum; // wall + sector references. Make them pointers later? short last_extra, subweapon; short ammo_amount[MAX_WEAPONS], frag, fraggedself; @@ -207,7 +207,7 @@ struct player_struct short curr_weapon, last_weapon, tipincs, wantweaponfire; short holoduke_amount, hurt_delay, hbomb_hold_delay; short jumping_counter, airleft, knee_incs, access_incs; - short ftq, access_wallnum; + short ftq; short got_access, weapon_ang, firstaid_amount; short i; short over_shoulder_on, fist_incs; @@ -374,6 +374,19 @@ struct Collision else { index = -1; actor = &hittype[value & kHitIndexMask]; } return type; } + + walltype* wall() const + { + assert(type == kHitWall); + return &::wall[index]; + } + + sectortype* sector() const + { + assert(type == kHitSector); + return &::sector[index]; + } + }; diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index c35e4c4a1..de2c58209 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -159,7 +159,7 @@ struct DukePlayer native int randomflamex, crack_time; native int aim_mode, ftt; - native int cursectnum, one_parallax_sectnum; + native int cursectnum, one_parallax_sectnum, access_wallnum; native int16 last_extra, subweapon; native int16 ammo_amount[DukeWpn.MAX_WEAPONS], frag, fraggedself; @@ -167,7 +167,7 @@ struct DukePlayer native int16 curr_weapon, last_weapon, tipincs, wantweaponfire; native int16 holoduke_amount, hurt_delay, hbomb_hold_delay; native int16 jumping_counter, airleft, knee_incs, access_incs; - native int16 ftq, access_wallnum; + native int16 ftq; native int16 got_access, weapon_ang, firstaid_amount; native int16 i; native int16 over_shoulder_on, fist_incs;