diff --git a/CMakeLists.txt b/CMakeLists.txt index d53bc851e..f504a55d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,7 +236,7 @@ if( MSVC ) set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" ) # Disable warnings for unsecure CRT functions from VC8+ - set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996 /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600" ) + set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS" ) # These must be silenced because the code is full of them. Expect some of undefined behavior hidden in this mess. :( #set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4244 /wd4018 /wd4267" ) diff --git a/source/build/include/build.h b/source/build/include/build.h index c84f28c57..d2cc9ac7b 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -403,7 +403,14 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in, #define MAXUPDATESECTORDIST 1536 #define INITIALUPDATESECTORDIST 256 -void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3))); +void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3))); +[[deprecated]] +inline void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3))) +{ + int snum = *sectnum; + updatesector(x, y, &snum); + *sectnum = snum; +} void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum) ATTRIBUTE((nonnull(4))); void updatesectorneighbor(int32_t const x, int32_t const y, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3))); void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4))); diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 40bb31d11..80dfe3dae 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -43,7 +43,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, int32_t* tposx, int32_t* tposy, fixed_t* tang); void renderCompleteMirror(void); -int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int16_t dacursectnum); +int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int dacursectnum); void renderDrawMasks(void); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 077ef0478..a78c28a2c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1356,7 +1356,7 @@ int findwallbetweensectors(int sect1, int sect2) // // updatesector[z] // -void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) +void updatesector(int32_t const x, int32_t const y, int * const sectnum) { int16_t sect = *sectnum; updatesectorneighbor(x, y, §, INITIALUPDATESECTORDIST, MAXUPDATESECTORDIST); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index bfb409227..22390431d 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3307,7 +3307,7 @@ void renderCompleteMirror(void) EXTERN_CVAR(Int, gl_fogmode) int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, - fixed_t daang, fixed_t dahoriz, int16_t dacursectnum) + fixed_t daang, fixed_t dahoriz, int dacursectnum) { pm_spritesortcnt = 0; checkRotatedWalls(); diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index a643719e7..dee143086 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -475,7 +475,7 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con int const shift = -(isBlood() ? BLOODSINSHIFT : DEFSINSHIFT); int const x = pos.x + ang.bcos(shift); int const y = pos.y + ang.bsin(shift); - int16_t tempsect = cursectnum; + int tempsect = cursectnum; updatesector(x, y, &tempsect); if (tempsect >= 0) // If the new point is inside a valid sector... diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index a9dd0cb1a..e07bd2c75 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -314,9 +314,7 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect if (gl_fogmode == 1) gl_fogmode = 2; // still needed? - int16_t sect = sectnum; - updatesector(position.x, position.y, §); - if (sect >= 0) sectnum = sect; + updatesector(position.x, position.y, §num); if (sectnum < 0) return; iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0; @@ -369,9 +367,7 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect void render_camtex(spritetype* playersprite, const vec3_t& position, int sectnum, binangle angle, fixedhoriz horizon, binangle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio) { - int16_t sect = sectnum; - updatesector(position.x, position.y, §); - if (sect >= 0) sectnum = sect; + updatesector(position.x, position.y, §num); if (sectnum < 0) return; screen->RenderState()->SetVertexBuffer(screen->mVertexData); diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 66ba043ee..efa510aed 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2770,7 +2770,7 @@ static void actNapalmMove(DBloodActor* actor) static DBloodActor* actSpawnFloor(DBloodActor* actor) { auto pSprite = &actor->s(); - short sector = pSprite->sectnum; + int sector = pSprite->sectnum; int x = pSprite->x; int y = pSprite->y; updatesector(x, y, §or); @@ -5392,7 +5392,7 @@ int MoveMissile(DBloodActor* actor) enginecompatibility_mode = bakCompat; // restore pSprite->cstat = bakSpriteCstat; clipmoveboxtracenum = 3; - short nSector = nSector2; + int nSector = nSector2; if (nSector2 < 0) { cliptype = -1; diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index 846f595cc..9b882e900 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -196,7 +196,7 @@ void CFX::fxProcess(void) { spritetype *pSprite = &actor->s(); viewBackupSpriteLoc(actor); - short nSector = pSprite->sectnum; + int nSector = pSprite->sectnum; assert(nSector >= 0 && nSector < kMaxSectors); assert(pSprite->type < kFXMax); FXDATA *pFXData = &gFXData[pSprite->type]; diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index f09280d1e..4502ced7d 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -243,7 +243,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput) int z1 = getflorzofslope(nSector, predict.x, predict.y); int x2 = predict.x+MulScale(64, Cos(predict.angle.asbuild()), 30); int y2 = predict.y+MulScale(64, Sin(predict.angle.asbuild()), 30); - short nSector2 = nSector; + int nSector2 = nSector; updatesector(x2, y2, &nSector2); if (nSector2 == nSector) { diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 41a4b3f61..e4d32926d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -2894,7 +2894,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) auto psp = ps[p].GetActor(); if (psp->s->extra > 0) { - short k = ps[p].cursectnum; + int k = ps[p].cursectnum; updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { @@ -2978,7 +2978,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) { if (ps[p].GetActor()->s->extra > 0) { - short k = ps[p].cursectnum; + int k = ps[p].cursectnum; updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { @@ -3000,7 +3000,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) { if (a2->s->statnum == 1 && badguy(a2) && a2->s->picnum != SECTOREFFECTOR && a2->s->picnum != LOCATORS) { - short k = a2->s->sectnum; + int k = a2->s->sectnum; updatesector(a2->s->x, a2->s->y, &k); if (a2->s->extra >= 0 && k == s->sectnum) { @@ -3083,7 +3083,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) auto psp = ps[p].GetActor(); if (psp->s->extra > 0) { - short k = ps[p].cursectnum; + int k = ps[p].cursectnum; updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { @@ -3146,7 +3146,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].GetActor()->s->extra > 0) { - short k = ps[p].cursectnum; + int k = ps[p].cursectnum; updatesector(ps[p].pos.x, ps[p].pos.y, &k); if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && ps[p].cursectnum != s->sectnum)) { @@ -3172,7 +3172,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) { // if(a2->s.sectnum != s->sectnum) { - short k = a2->s->sectnum; + int k = a2->s->sectnum; updatesector(a2->s->x, a2->s->y, &k); if (a2->s->extra >= 0 && k == s->sectnum) { diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 00be62fdb..6bd2d496d 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -342,7 +342,8 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h walltype* wal; int d, q, x1, y1; int sectcnt, sectend, dasect, startwall, endwall, nextsect; - short p, x, sect; + short p, x; + int sect; static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC }; short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64. @@ -705,7 +706,8 @@ void guts_d(DDukeActor* actor, short gtype, short n, short p) void movefta_d(void) { int x, px, py, sx, sy; - short p, psect, ssect; + short p; + int psect, ssect; int j; DukeStatIterator iti(STAT_ZOMBIEACTOR); diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 2b9f8a34f..519b86194 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -219,7 +219,8 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h walltype* wal; int d, q, x1, y1; int sectcnt, sectend, dasect, startwall, endwall, nextsect; - short p, x, sect; + short p, x; + int sect; static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC }; short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64. @@ -526,7 +527,8 @@ void guts_r(DDukeActor* actor, short gtype, short n, short p) void movefta_r(void) { int x, px, py, sx, sy; - short j, p, psect, ssect; + short j, p; + int psect, ssect; DukeStatIterator it(STAT_ZOMBIEACTOR); while(auto act = it.Next()) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 29e3f5894..bb74b28e3 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2780,7 +2780,7 @@ int ParseState::parse(void) break; case concmd_ifawayfromwall: { - short s1; + int s1; s1 = g_sp->sectnum; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 6666ac7e5..ff14829e7 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -134,7 +134,7 @@ void forceplayerangle(int snum) void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n) { int i, xv, yv, zv; - short sect = -1; + int sect = -1; i = n + 1; xv = (x2 - x1) / i; diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 4163ab4ee..92a9d9e2e 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -641,7 +641,7 @@ void activatebysector_d(int sect, DDukeActor* activator) void checkhitwall_d(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith) { - short j, sn = -1, darkestwall; + int j, sn = -1, darkestwall; walltype* wal; wal = &wall[dawallnum]; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 5eec9e79f..7c4196d55 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -919,10 +919,10 @@ void activatebysector_r(int sect, DDukeActor* activator) // //--------------------------------------------------------------------------- -static void lotsofpopcorn(DDukeActor *actor, short wallnum, short n) +static void lotsofpopcorn(DDukeActor *actor, int wallnum, int n) { int j, xv, yv, z, x1, y1; - short sect, a; + int sect, a; sect = -1; auto sp = actor->s; @@ -976,7 +976,8 @@ static void lotsofpopcorn(DDukeActor *actor, short wallnum, short n) void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atwith) { - short j, i, sn = -1, darkestwall; + short j, i; + int sn = -1, darkestwall; walltype* wal; spritetype* s; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 8f958bbb0..41a8fe3e8 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -343,7 +343,7 @@ void spawntransporter(DDukeActor *actj, DDukeActor* acti, bool beam) int spawnbloodpoolpart1(DDukeActor *actj, DDukeActor* acti) { auto sp = acti->s; - short s1 = sp->sectnum; + int s1 = sp->sectnum; updatesector(sp->x + 108, sp->y + 108, &s1); if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) @@ -386,21 +386,19 @@ void initfootprint(DDukeActor* actj, DDukeActor* acti) int sect = sp->sectnum; if (actj) { - short s1; - s1 = sp->sectnum; - auto sect1 = §or[s1]; + int s1 = sp->sectnum; updatesector(sp->x + 84, sp->y + 84, &s1); - if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x - 84, sp->y - 84, &s1); - if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x + 84, sp->y - 84, &s1); - if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x - 84, sp->y + 84, &s1); - if (s1 >= 0 && sect1->floorz != sp->sector()->floorz) + if (s1 >= 0 && sector[s1].floorz != sp->sector()->floorz) { sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return; } @@ -1126,7 +1124,7 @@ void spawneffector(DDukeActor* actor) void lotsofglass(DDukeActor *actor, int wallnum, int n) { int j, xv, yv, z, x1, y1, a; - short sect; + int sect; auto sp = actor->s; sect = -1; @@ -1234,7 +1232,7 @@ void ceilingglass(DDukeActor* actor, int sectnum, int n) void lotsofcolourglass(DDukeActor* actor, int wallnum, int n) { int j, xv, yv, z, x1, y1; - short sect = -1; + int sect = -1; int a;; auto sp = actor->s; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 1224837dc..bca04680d 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -274,7 +274,7 @@ DoShadows(spritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int viewz, int loz; short xrepeat; short yrepeat; - short sectnum; + int sectnum; sectnum = tsp->sectnum; // make sure its the correct sector