From 820bd2545c90a65aa031273e7d1bbc72396a5fe2 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:44:42 +0000 Subject: [PATCH 1/7] SW: Get widescreen aspect working git-svn-id: https://svn.eduke32.com/eduke32@8346 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/draw.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 84934cff7..8a245cea3 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2198,6 +2198,8 @@ drawscreen(PLAYERp pp) static short lv_sectnum = -1; static int lv_x, lv_y, lv_z; + int const viewingRange = viewingrange; + if (HelpInputMode) { renderFlushPerms(); @@ -2363,6 +2365,12 @@ drawscreen(PLAYERp pp) thoriz = min(thoriz, PLAYER_HORIZ_MAX); } + if (r_usenewaspect) + { + newaspect_enable = 1; + videoSetCorrectedAspect(); + } + if (FAF_DebugView) videoClearViewableArea(255L); @@ -2387,6 +2395,12 @@ drawscreen(PLAYERp pp) post_analyzesprites(); renderDrawMasks(); + if (r_usenewaspect) + { + newaspect_enable = 0; + renderSetAspect(viewingRange, tabledivide32_noinline(65536 * ydim * 8, xdim * 5)); + } + UpdatePanel(); #define SLIME 2305 From f19848a1b39308a13c9f839ffd189a768e9fcdc3 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:44:46 +0000 Subject: [PATCH 2/7] SW: Address Sanitization commenceth git-svn-id: https://svn.eduke32.com/eduke32@8347 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/game.h | 4 ++-- source/sw/src/player.cpp | 6 +++--- source/sw/src/scrip2.cpp | 3 ++- source/sw/src/weapon.cpp | 43 +++++++++++++++++++++++----------------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index da5d2ad94..ab94a1f7d 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -378,8 +378,8 @@ extern char MessageOutputString[256]; #define TEST_SYNC_KEY(player, sync_num) TEST((player)->input.bits, (1 << (sync_num))) #define RESET_SYNC_KEY(player, sync_num) RESET((player)->input.bits, (1 << (sync_num))) -#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = nextspritesect[o], (o) != -1; (o) = (n)) -#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = nextspritestat[o], (o) != -1; (o) = (n)) +#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritesect[o], (o) != -1; (o) = (n)) +#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritestat[o], (o) != -1; (o) = (n)) #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 79a4f332a..f6d2a1015 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -3641,7 +3641,7 @@ void StackedWaterSplash(PLAYERp pp) updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), §num); - if (SectorIsUnderwaterArea(sectnum)) + if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum)) { PlaySound(DIGI_SPLASH1, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan); } @@ -4094,7 +4094,7 @@ DoPlayerWadeSuperJump(PLAYERp pp) { hitinfo.sect = wall[hitinfo.wall].nextsector; - if (labs(sector[hitinfo.sect].floorz - pp->posz) < Z(50)) + if (hitinfo.sect >= 0 && labs(sector[hitinfo.sect].floorz - pp->posz) < Z(50)) { if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->SpriteP->clipdist)<<2) + 256)) return TRUE; @@ -4694,7 +4694,7 @@ PlayerCanDiveNoWarp(PLAYERp pp) updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), §num); - if (SectorIsUnderwaterArea(sectnum)) + if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum)) { pp->cursectnum = sectnum; pp->posz = sector[sectnum].ceilingz; diff --git a/source/sw/src/scrip2.cpp b/source/sw/src/scrip2.cpp index aa770c3c2..10a95f557 100644 --- a/source/sw/src/scrip2.cpp +++ b/source/sw/src/scrip2.cpp @@ -89,7 +89,7 @@ SWBOOL LoadScriptFile(const char *filename) size = fp.GetLength(); - scriptbuffer = (char *)AllocMem(size); + scriptbuffer = (char *)AllocMem(size+1); ASSERT(scriptbuffer != NULL); @@ -97,6 +97,7 @@ SWBOOL LoadScriptFile(const char *filename) ASSERT(readsize == size); + scriptbuffer[readsize] = '\0'; // Convert filebuffer to all upper case //Bstrupr(scriptbuffer); diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index fdfcd7b56..b84819017 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -2653,12 +2653,12 @@ STATE s_PaperShrapC[] = SWBOOL MissileHitMatch(short Weapon, short WeaponNum, short hit_sprite) { SPRITEp hsp = &sprite[hit_sprite]; - SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; if (WeaponNum <= -1) { ASSERT(Weapon >= 0); + SPRITEp wp = &sprite[Weapon]; + USERp wu = User[Weapon]; WeaponNum = wu->WeaponNum; // can be hit by SO only @@ -5760,8 +5760,6 @@ PlayerCheckDeath(PLAYERp pp, short Weapon) { SPRITEp sp = pp->SpriteP; USERp u = User[pp->PlayerSprite]; - SPRITEp wp = &sprite[Weapon]; - USERp wu = User[Weapon]; int SpawnZombie(PLAYERp pp, short); @@ -5786,6 +5784,9 @@ PlayerCheckDeath(PLAYERp pp, short Weapon) return TRUE; } + SPRITEp wp = &sprite[Weapon]; + USERp wu = User[Weapon]; + if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) pp->DeathType = PLAYER_DEATH_RIPPER; @@ -5828,14 +5829,14 @@ PlayerCheckDeath(PLAYERp pp, short Weapon) SWBOOL PlayerTakeDamage(PLAYERp pp, short Weapon) { + if (Weapon < 0) + return TRUE; + SPRITEp sp = pp->SpriteP; USERp u = User[pp->PlayerSprite]; SPRITEp wp = &sprite[Weapon]; USERp wu = User[Weapon]; - if (Weapon < 0) - return TRUE; - if (gNet.MultiGameType == MULTI_GAME_NONE) { // ZOMBIE special case for single play @@ -7607,9 +7608,11 @@ DoDamageTest(short Weapon) return 0; } -int -DoHitscanDamage(short Weapon, short hit_sprite) +static int DoHitscanDamage(short Weapon, uint16_t hit_sprite) { + if (hit_sprite >= MAXSPRITES) + return 0; + SPRITEp wp = &sprite[Weapon]; USERp wu = User[Weapon]; unsigned stat; @@ -10832,8 +10835,8 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; - SPRITEp ep = &sprite[enemy]; - USERp eu = User[enemy]; + SPRITEp ep; + USERp eu; SPRITEp np; USERp nu; short New; @@ -10843,6 +10846,9 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) if (enemy >= 0) { + ep = &sprite[enemy]; + eu = User[enemy]; + // test for already burned if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40) return -1; @@ -17843,17 +17849,18 @@ SWBOOL HitscanSpriteAdjust(short SpriteNum, short hit_wall) { SPRITEp sp = &sprite[SpriteNum]; - short w, nw, ang = sp->ang, wall_ang; + int16_t ang; int xvect,yvect; short sectnum; #if 1 - w = hit_wall; - nw = wall[w].point2; - wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y)); - if (hit_wall >= 0) + { + uint16_t const w = hit_wall; + uint16_t const nw = wall[hit_wall].point2; + int16_t const wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y)); ang = sp->ang = NORM_ANGLE(wall_ang + 512); + } else ang = sp->ang; #endif @@ -20638,13 +20645,13 @@ void QueueReset(void) SWBOOL TestDontStick(short SpriteNum, short hit_sect, short hit_wall, int hit_z) { - SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum]; WALLp wp; if (hit_wall < 0) { ASSERT(SpriteNum>=0); + SPRITEp sp = &sprite[SpriteNum]; + USERp u = User[SpriteNum]; hit_wall = NORM_WALL(u->ret); } From 823e47f3e8979a44326d5780d9d95bb3748ae614 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:44:51 +0000 Subject: [PATCH 3/7] SW: Fix assertions and OOB so that the player can noclip OOB git-svn-id: https://svn.eduke32.com/eduke32@8348 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/draw.cpp | 28 ++++++++------- source/sw/src/jweapon.cpp | 6 ++++ source/sw/src/panel.cpp | 27 ++++++++------ source/sw/src/player.cpp | 41 ++++++++++++--------- source/sw/src/rooms.cpp | 18 +++++----- source/sw/src/sector.cpp | 18 ++++++---- source/sw/src/sprite.cpp | 2 +- source/sw/src/warp.cpp | 2 +- source/sw/src/weapon.cpp | 75 ++++++++++++++++++++++++++++++++++++--- 9 files changed, 157 insertions(+), 60 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 8a245cea3..b1301efa8 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2186,7 +2186,6 @@ drawscreen(PLAYERp pp) int tx, ty, tz,thoriz,pp_siz; short tang,tsectnum; short i,j; - walltype *wal; int tiltlock; int bob_amt = 0; int quake_z, quake_x, quake_y; @@ -2285,11 +2284,13 @@ drawscreen(PLAYERp pp) if (tsectnum < 0) { +#if 0 // if we hit an invalid sector move to the last valid position for drawing tsectnum = lv_sectnum; tx = lv_x; ty = lv_y; tz = lv_z; +#endif } else { @@ -2301,7 +2302,7 @@ drawscreen(PLAYERp pp) } // with "last valid" code this should never happen - ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); + // ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); pp->six = tx; pp->siy = ty; @@ -2420,18 +2421,21 @@ drawscreen(PLAYERp pp) i = pp->cursectnum; - show2dsector[i>>3] |= (1<<(i&7)); - wal = &wall[sector[i].wallptr]; - for (j=sector[i].wallnum; j>0; j--,wal++) + if (i >= 0) { - i = wal->nextsector; - if (i < 0) continue; - if (wal->cstat&0x0071) continue; - uint16_t const nextwall = wal->nextwall; - if (nextwall < MAXWALLS && wall[nextwall].cstat&0x0071) continue; - if (sector[i].lotag == 32767) continue; - if (sector[i].ceilingz >= sector[i].floorz) continue; show2dsector[i>>3] |= (1<<(i&7)); + walltype *wal = &wall[sector[i].wallptr]; + for (j=sector[i].wallnum; j>0; j--,wal++) + { + i = wal->nextsector; + if (i < 0) continue; + if (wal->cstat&0x0071) continue; + uint16_t const nextwall = wal->nextwall; + if (nextwall < MAXWALLS && wall[nextwall].cstat&0x0071) continue; + if (sector[i].lotag == 32767) continue; + if (sector[i].ceilingz >= sector[i].floorz) continue; + show2dsector[i>>3] |= (1<<(i&7)); + } } if ((dimensionmode == 5 || dimensionmode == 6) && pp == Player+myconnectindex) diff --git a/source/sw/src/jweapon.cpp b/source/sw/src/jweapon.cpp index 58aa92bc9..823169808 100644 --- a/source/sw/src/jweapon.cpp +++ b/source/sw/src/jweapon.cpp @@ -1389,6 +1389,9 @@ PlayerInitChemBomb(PLAYERp pp) PlaySound(DIGI_THROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan | v3df_doppler); + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; nz = pp->posz + pp->bob_z + Z(8); @@ -1834,6 +1837,9 @@ PlayerInitCaltrops(PLAYERp pp) PlaySound(DIGI_THROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan | v3df_doppler); + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; nz = pp->posz + pp->bob_z + Z(8); diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 21b0defb9..e4a1f743e 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -7347,7 +7347,6 @@ pDisplaySprites(PLAYERp pp) int smoothratio; unsigned i; - SECT_USERp sectu = SectUser[pp->cursectnum]; uint8_t pal = 0; short ang; int flags; @@ -7488,17 +7487,23 @@ pDisplaySprites(PLAYERp pp) // if its a weapon sprite and the view is set to the outside don't draw the sprite if (TEST(psp->flags, PANF_WEAPON_SPRITE)) { - pal = sector[pp->cursectnum].floorpal; - - if (sector[pp->cursectnum].floorpal != PALETTE_DEFAULT) + SECT_USERp sectu = nullptr; + int16_t floorshade = 0; + if (pp->cursectnum >= 0) { - SECT_USERp sectu = SectUser[pp->cursectnum]; - if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) - pal = PALETTE_DEFAULT; - } + sectu = SectUser[pp->cursectnum]; + pal = sector[pp->cursectnum].floorpal; + floorshade = sector[pp->cursectnum].floorshade; - if (pal == PALETTE_FOG || pal == PALETTE_DIVE || pal == PALETTE_DIVE_LAVA) - pal = psp->pal; // Set it back + if (pal != PALETTE_DEFAULT) + { + if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) + pal = PALETTE_DEFAULT; + } + + if (pal == PALETTE_FOG || pal == PALETTE_DIVE || pal == PALETTE_DIVE_LAVA) + pal = psp->pal; // Set it back + } /////////// @@ -7508,7 +7513,7 @@ pDisplaySprites(PLAYERp pp) } //shade = overlay_shade = DIV2(sector[pp->cursectnum].floorshade + sector[pp->cursectnum].ceilingshade); - shade = overlay_shade = sector[pp->cursectnum].floorshade - 10; + shade = overlay_shade = floorshade - 10; if (TEST(psp->PlayerP->Flags, PF_VIEW_FROM_OUTSIDE)) { diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index f6d2a1015..5c1753a4b 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1794,13 +1794,14 @@ DoPlayerTurnTurret(PLAYERp pp) void SlipSlope(PLAYERp pp) { - short wallptr = sector[pp->cursectnum].wallptr; short ang; - SECT_USERp sectu = SectUser[pp->cursectnum]; + SECT_USERp sectu; - if (!sectu || !TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) + if (pp->cursectnum < 0 || !(sectu = SectUser[pp->cursectnum]) || !TEST(sectu->flags, SECTFU_SLIDE_SECTOR) || !TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) return; + short wallptr = sector[pp->cursectnum].wallptr; + ang = getangle(wall[wall[wallptr].point2].x - wall[wallptr].x, wall[wall[wallptr].point2].y - wall[wallptr].y); ang = NORM_ANGLE(ang + 512); @@ -2537,6 +2538,9 @@ DoPlayerMenuKeys(PLAYERp pp) void PlayerSectorBound(PLAYERp pp, int amt) { + if (pp->cursectnum < 9) + return; + int cz,fz; // player should never go into a sector @@ -2680,7 +2684,7 @@ DoPlayerMove(PLAYERp pp) DoPlayerHorizon(pp); - if (TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) + if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) { if (TEST(pp->Flags, PF_FLYING|PF_JUMPING|PF_FALLING)) { @@ -2722,6 +2726,9 @@ DoPlayerSectorUpdatePreMove(PLAYERp pp) { short sectnum = pp->cursectnum; + if (sectnum < 0) + return; + if (TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) { updatesectorz(pp->posx, pp->posy, pp->posz, §num); @@ -2749,13 +2756,12 @@ DoPlayerSectorUpdatePreMove(PLAYERp pp) void DoPlayerSectorUpdatePostMove(PLAYERp pp) { - short sectnum; + short sectnum = pp->cursectnum; int fz,cz; // need to do updatesectorz if in connect area - if (FAF_ConnectArea(pp->cursectnum)) + if (sectnum >= 0 && FAF_ConnectArea(sectnum)) { - sectnum = pp->cursectnum; updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum); // can mess up if below @@ -2773,7 +2779,7 @@ DoPlayerSectorUpdatePostMove(PLAYERp pp) // try again updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum); - ASSERT(pp->cursectnum >= 0); + // ASSERT(pp->cursectnum >= 0); } } else @@ -3662,7 +3668,7 @@ DoPlayerFall(PLAYERp pp) FLAG_KEY_RESET(pp, SK_JUMP); } - if (SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { StackedWaterSplash(pp); DoPlayerBeginDiveNoWarp(pp); @@ -4245,7 +4251,7 @@ DoPlayerCrawl(PLAYERp pp) { USERp u = User[pp->PlayerSprite]; - if (SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { // if stacked water - which it should be if (FAF_ConnectArea(pp->cursectnum)) @@ -4348,7 +4354,7 @@ DoPlayerCrawl(PLAYERp pp) return; } - if (TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) + if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) { pp->posz = pp->loz - PLAYER_CRAWL_HEIGHT; } @@ -4430,7 +4436,7 @@ DoPlayerFly(PLAYERp pp) { USERp u = User[pp->PlayerSprite]; - if (SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { DoPlayerBeginDiveNoWarp(pp); return; @@ -5116,7 +5122,7 @@ void DoPlayerBeginDiveNoWarp(PLAYERp pp) if (Prediction) return; - if (!SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum)) return; if (pp->Bloody) pp->Bloody = FALSE; // Water washes away the blood @@ -5282,7 +5288,7 @@ DoPlayerDive(PLAYERp pp) SECT_USERp sectu = SectUser[pp->cursectnum]; // whenever your view is not in a water area - if (!SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum)) { DoPlayerStopDiveNoWarp(pp); DoPlayerBeginRun(pp); @@ -7356,7 +7362,7 @@ DoPlayerRun(PLAYERp pp) { USERp u = User[pp->PlayerSprite]; - if (SectorIsUnderwaterArea(pp->cursectnum)) + if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum)) { DoPlayerBeginDiveNoWarp(pp); return; @@ -7428,7 +7434,7 @@ DoPlayerRun(PLAYERp pp) { if (TEST_SYNC_KEY(pp, SK_OPERATE)) { - if (FLAG_KEY_PRESSED(pp, SK_OPERATE)) + if (FLAG_KEY_PRESSED(pp, SK_OPERATE) && pp->cursectnum >= 0) { if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL)) { @@ -8405,6 +8411,9 @@ DoFootPrints(short SpriteNum) if (u->PlayerP) { + if (u->PlayerP->cursectnum < 0) + return 0; + if (FAF_ConnectArea(u->PlayerP->cursectnum)) return 0; diff --git a/source/sw/src/rooms.cpp b/source/sw/src/rooms.cpp index 92a258c6f..bf3befdfe 100644 --- a/source/sw/src/rooms.cpp +++ b/source/sw/src/rooms.cpp @@ -59,7 +59,7 @@ SWBOOL FAF_DebugView = 0; void COVERupdatesector(int32_t x, int32_t y, int16_t* newsector) { - ASSERT(*newsector>=0 && *newsector=0 && *newsector= 0 && secte >= 0); + // ASSERT(sects >= 0 && secte >= 0); // early out to regular routine - if (!FAF_Sector(sects) && !FAF_Sector(secte)) + if ((sects < 0 || !FAF_Sector(sects)) && (secte < 0 || !FAF_Sector(secte))) { return cansee(xs,ys,zs,sects,xe,ye,ze,secte); } @@ -356,7 +356,7 @@ GetZadjustment(short sectnum, short hitag) short i, nexti; SPRITEp sp; - if (!TEST(sector[sectnum].extra, SECTFX_Z_ADJUST)) + if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_Z_ADJUST)) return 0L; TRAVERSE_SPRITE_STAT(headspritestat[STAT_ST1], i, nexti) @@ -517,7 +517,7 @@ void FAFgetzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, // because the ceiling and floors get moved out of the way for drawing. // early out to regular routine - if (!FAF_ConnectArea(sectnum)) + if (sectnum < 0 || !FAF_ConnectArea(sectnum)) { getzrange_old(x, y, z, sectnum, hiz, ceilhit, loz, florhit, clipdist, clipmask); SectorZadjust(*ceilhit, hiz, *florhit, loz); @@ -545,7 +545,7 @@ void FAFgetzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, updatesectorz(x, y, newz, &uppersect); if (uppersect < 0) - _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz); + return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz); getzrange_old(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2, clipdist, clipmask); SectorZadjust(*ceilhit, hiz, -1, NULL); } @@ -568,7 +568,7 @@ void FAFgetzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, updatesectorz(x, y, newz, &lowersect); if (lowersect < 0) - _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz); + return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d", x, y, newz); getzrange_old(x, y, newz, lowersect, &foo1, &foo2, loz, florhit, clipdist, clipmask); SectorZadjust(-1, NULL, *florhit, loz); WaterAdjust(*florhit, loz); @@ -614,7 +614,7 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum, } updatesectorz(x, y, newz, &uppersect); if (uppersect < 0) - _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum); + return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum); getzrangepoint(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2); SectorZadjust(*ceilhit, hiz, -1, NULL); } @@ -630,7 +630,7 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum, } updatesectorz(x, y, newz, &lowersect); if (lowersect < 0) - _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum); + return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum); getzrangepoint(x, y, newz, lowersect, &foo1, &foo2, loz, florhit); SectorZadjust(-1, NULL, *florhit, loz); WaterAdjust(*florhit, loz); diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 93611bec3..24b1947d6 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -2087,11 +2087,14 @@ int DoTrapMatch(short match) void OperateTripTrigger(PLAYERp pp) { - SECTORp sectp = §or[pp->cursectnum]; - if (Prediction) return; + if (pp->cursectnum < 0) + return; + + SECTORp sectp = §or[pp->cursectnum]; + #if 0 // new method if (TEST(sectp->extra, SECTFX_TRIGGER)) @@ -2249,6 +2252,9 @@ OperateContinuousTrigger(PLAYERp pp) if (Prediction) return; + if (pp->cursectnum < 0) + return; + switch (LOW_TAG(pp->cursectnum)) { case TAG_TRIGGER_MISSILE_TRAP: @@ -2589,8 +2595,6 @@ int DoPlayerGrabStar(PLAYERp pp) void PlayerOperateEnv(PLAYERp pp) { - SECT_USERp sectu = SectUser[pp->cursectnum]; - SECTORp sectp = §or[pp->cursectnum]; SWBOOL found; if (Prediction) @@ -2730,8 +2734,10 @@ PlayerOperateEnv(PLAYERp pp) // // //////////////////////////// - if (sectu && sectu->damage) + SECT_USERp sectu; + if (pp->cursectnum >= 0 && (sectu = SectUser[pp->cursectnum]) && sectu->damage) { + SECTORp sectp = §or[pp->cursectnum]; if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR)) { PlayerTakeSectorDamage(pp); @@ -2761,7 +2767,7 @@ PlayerOperateEnv(PLAYERp pp) { OperateTripTrigger(pp); - if (TEST(sector[pp->cursectnum].extra, SECTFX_WARP_SECTOR)) + if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_WARP_SECTOR)) { if (!TEST(pp->Flags2, PF2_TELEPORTED)) { diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index ae1fda491..d3ea67e97 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -962,7 +962,7 @@ SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, int y, int ASSERT(!Prediction); - PRODUCTION_ASSERT(sectnum >= 0 && sectnum < MAXSECTORS); + // PRODUCTION_ASSERT(sectnum >= 0 && sectnum < MAXSECTORS); SpriteNum = COVERinsertsprite(sectnum, stat); diff --git a/source/sw/src/warp.cpp b/source/sw/src/warp.cpp index 8410530ac..0a801baba 100644 --- a/source/sw/src/warp.cpp +++ b/source/sw/src/warp.cpp @@ -54,7 +54,7 @@ WarpPlaneSectorInfo(short sectnum, SPRITEp *sp_ceiling, SPRITEp *sp_floor) if (Prediction) return FALSE; - if (!TEST(sector[sectnum].extra, SECTFX_WARP_SECTOR)) + if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_WARP_SECTOR)) return FALSE; TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP], i, nexti) diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index b84819017..d5f64cc72 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -2777,7 +2777,7 @@ int DoLavaErupt(short SpriteNum) TRAVERSE_CONNECT(pnum) { pp = Player + pnum; - if (TEST(sector[pp->cursectnum].extra, SECTFX_TRIGGER)) + if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_TRIGGER)) { TRAVERSE_SPRITE_SECT(headspritesect[pp->cursectnum],i,nexti) { @@ -13027,6 +13027,9 @@ InitSpellRing(PLAYERp pp) if (!SW_SHAREWARE) PlaySound(DIGI_RFWIZ, &pp->posx, &pp->posy, &pp->posz, v3df_none); + if (pp->cursectnum < 0) + return; + for (missiles = 0, ang = ang_start; missiles < max_missiles; ang += ang_diff, missiles++) { SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, FIREBALL1, s_Ring, pp->cursectnum, pp->posx, pp->posy, pp->posz, ang, 0); @@ -13575,6 +13578,9 @@ InitSpellNapalm(PLAYERp pp) PlaySound(DIGI_NAPFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_none); + if (pp->cursectnum < 0) + return; + for (i = 0; i < SIZ(mp); i++) { SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Napalm, pp->cursectnum, @@ -13735,6 +13741,9 @@ InitSpellMirv(PLAYERp pp) PlaySound(DIGI_MIRVFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_none); + if (pp->cursectnum < 0) + return 0; + SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Mirv, pp->cursectnum, pp->posx, pp->posy, pp->posz + Z(12), pp->pang, MIRV_VELOCITY); @@ -14746,13 +14755,16 @@ InitStar(PLAYERp pp) PlayerUpdateAmmo(pp, u->WeaponNum, -3); + PlaySound(DIGI_STAR, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); + + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; nz = pp->posz + pp->bob_z + Z(8); - PlaySound(DIGI_STAR, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); - // Spawn a shot // Inserting and setting up variables @@ -14877,6 +14889,9 @@ InitHeartAttack(PLAYERp pp) PlayerUpdateAmmo(pp, WPN_HEART, -1); + if (pp->cursectnum < 0) + return; + SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, pp->posx, pp->posy, pp->posz + Z(12), pp->pang, BLOOD_WORM_VELOCITY*2); @@ -14950,6 +14965,9 @@ InitHeartAttack(PLAYERp pp) PlayerUpdateAmmo(pp, WPN_HEART, -1); + if (pp->cursectnum < 0) + return; + SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, pp->posx, pp->posy, pp->posz + Z(12), pp->pang, BLOOD_WORM_VELOCITY*2); @@ -15265,6 +15283,9 @@ InitLaser(PLAYERp pp) PlaySound(DIGI_RIOTFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; @@ -15374,6 +15395,9 @@ InitRail(PLAYERp pp) // Make sprite shade brighter u->Vis = 128; + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; @@ -15555,17 +15579,30 @@ InitRocket(PLAYERp pp) DoPlayerBeginRecoil(pp, ROCKET_RECOIL_AMT); PlayerUpdateAmmo(pp, u->WeaponNum, -1); + if (pp->WpnRocketHeat) + { + switch (pp->WpnRocketType) + { + case 1: + pp->WpnRocketHeat--; + break; + } + } PlaySound(DIGI_RIOTFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); // Make sprite shade brighter u->Vis = 128; + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; // Spawn a shot // Inserting and setting up variables + //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, @@ -15601,7 +15638,6 @@ InitRocket(PLAYERp pp) switch (pp->WpnRocketType) { case 1: - pp->WpnRocketHeat--; SET(wu->Flags, SPR_FIND_PLAYER); wp->pal = wu->spal = 20; // Yellow break; @@ -15679,11 +15715,15 @@ InitBunnyRocket(PLAYERp pp) PlaySound(DIGI_BUNNYATTACK, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; // Spawn a shot // Inserting and setting up variables + //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R4, &s_BunnyRocket[0][0], pp->cursectnum, @@ -15789,11 +15829,15 @@ InitNuke(PLAYERp pp) // Make sprite shade brighter u->Vis = 128; + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; // Spawn a shot // Inserting and setting up variables + //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, @@ -15978,6 +16022,9 @@ InitMicro(PLAYERp pp) if (TargetSortCount > MAX_MICRO) TargetSortCount = MAX_MICRO; + if (pp->cursectnum < 0) + return 0; + for (i = 0; i < MAX_MICRO; i++) { if (ts < &TargetSort[TargetSortCount] && ts->sprite_num >= 0) @@ -17534,6 +17581,9 @@ DoDefaultStat(short SpriteNum) int InitTracerUzi(PLAYERp pp) { + if (pp->cursectnum < 0) + return 0; + USERp u = User[pp->PlayerSprite]; SPRITEp wp, hsp; USERp wu; @@ -17552,6 +17602,7 @@ InitTracerUzi(PLAYERp pp) // Spawn a shot // Inserting and setting up variables + w = SpawnSprite(STAT_MISSILE, 0, s_Tracer, pp->cursectnum, nx, ny, nz, pp->pang, TRACER_VELOCITY); @@ -18549,6 +18600,9 @@ InitTurretRail(short SpriteNum, PLAYERp pp) if (SW_SHAREWARE) return FALSE; // JBF: verify + if (pp->cursectnum < 0) + return 0; + nx = sp->x; ny = sp->y; nz = sp->z; @@ -18605,6 +18659,8 @@ InitTurretLaser(short SpriteNum, PLAYERp pp) if (SW_SHAREWARE) return FALSE; // JBF: verify + if (pp->cursectnum < 0) + return 0; nx = sp->x; ny = sp->y; @@ -19394,12 +19450,16 @@ InitGrenade(PLAYERp pp) // Make sprite shade brighter u->Vis = 128; + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; nz = pp->posz + pp->bob_z + Z(8); // Spawn a shot // Inserting and setting up variables + w = SpawnSprite(STAT_MISSILE, GRENADE, &s_Grenade[0][0], pp->cursectnum, nx, ny, nz, pp->pang, GRENADE_VELOCITY); @@ -19561,12 +19621,16 @@ InitMine(PLAYERp pp) PlaySound(DIGI_MINETHROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); + if (pp->cursectnum < 0) + return 0; + nx = pp->posx; ny = pp->posy; nz = pp->posz + pp->bob_z + Z(8); // Spawn a shot // Inserting and setting up variables + w = SpawnSprite(STAT_MISSILE, MINE, s_Mine, pp->cursectnum, nx, ny, nz, pp->pang, MINE_VELOCITY); @@ -19740,6 +19804,9 @@ InitFireball(PLAYERp pp) // Make sprite shade brighter u->Vis = 128; + if (pp->cursectnum < 0) + return 0; + nx += pp->posx; ny += pp->posy; From 863d35d7c215803918e1802a4ece329692ec2534 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:44:56 +0000 Subject: [PATCH 4/7] SW: Activate ASSERT macro with RELEASE=0 builds git-svn-id: https://svn.eduke32.com/eduke32@8349 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/game.h | 32 ++++++++++++++------------------ source/sw/src/panel.cpp | 2 +- source/sw/src/sector.cpp | 2 +- source/sw/src/sprite.cpp | 4 ++-- source/sw/src/track.cpp | 7 ++++--- source/sw/src/weapon.cpp | 4 ++-- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index ab94a1f7d..efe03ec41 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -60,19 +60,23 @@ extern char isShareware; #define ERR_STD_ARG __FILE__, __LINE__ +void _Assert(const char *expr, const char *strFile, unsigned uLine); +#define PRODUCTION_ASSERT(f) \ + do { \ + if (!(f)) \ + _Assert(#f,ERR_STD_ARG); \ + } while (0) + +#if DEBUG || defined DEBUGGINGAIDS +#define ASSERT(f) PRODUCTION_ASSERT(f) +#else +#define ASSERT(f) do { } while (0) +#endif + #if DEBUG void HeapCheck(char *, int); #define HEAP_CHECK() HeapCheck(__FILE__, __LINE__) -void _Assert(const char *expr, const char *strFile, unsigned uLine); -#define ASSERT(f) \ - if (f) \ - do { } while(0); \ - else \ - _Assert(#f,ERR_STD_ARG); - -#define PRODUCTION_ASSERT(f) ASSERT(f) - void dsprintf(char *, char *, ...); #define DSPRINTF dsprintf @@ -90,16 +94,8 @@ extern int DispMono; #define RANDOM_DEBUG 1 // Set this to 1 for network testing. #else -#define ASSERT(f) do { } while(0) #define MONO_PRINT(str) -void _Assert(const char *expr, const char *strFile, unsigned uLine); -#define PRODUCTION_ASSERT(f) \ - if (f) \ - do { } while(0); \ - else \ - _Assert(#f,ERR_STD_ARG); - void dsprintf_null(char *str, const char *format, ...); #define DSPRINTF dsprintf_null //#define DSPRINTF() @@ -1164,7 +1160,7 @@ struct PLAYERstruct short DiveDamageTics; // Death stuff - short DeathType; + uint16_t DeathType; short Kills; short Killer; //who killed me short KilledPlayer[MAX_SW_PLAYERS_REG]; diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index e4a1f743e..12361d022 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -7671,7 +7671,7 @@ pSpriteControl(PLAYERp pp) // RULE: Sprites can only kill themselves PRODUCTION_ASSERT(psp); ASSERT(ValidPtr(psp)); - ASSERT((uint32_t) psp->Next != 0xCCCCCCCC); + // ASSERT((uint32_t) psp->Next != 0xCCCCCCCC); if (psp->State) pStateControl(psp); diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 24b1947d6..bc79eda0b 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -486,7 +486,7 @@ SectorSetup(void) { SINE_WAVE_FLOOR *swf; short near_sect = i, base_sect = i; - short swf_ndx = 0; + uint16_t swf_ndx = 0; short cnt = 0, sector_cnt; int range; int range_diff = 0; diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index d3ea67e97..1083ba77d 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -6812,11 +6812,11 @@ SpriteControl(void) u = User[i]; sp = User[i]->SpriteP; STATE_CONTROL(i, sp, u, StateTics) - ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); + // ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); #else ASSERT(User[i]); StateControl(i); - ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); + // ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); #endif } diff --git a/source/sw/src/track.cpp b/source/sw/src/track.cpp index a3a147f32..68935f81c 100644 --- a/source/sw/src/track.cpp +++ b/source/sw/src/track.cpp @@ -726,7 +726,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop) { int xlow, ylow, xhigh, yhigh; - short sp_num, next_sp_num, sn, startwall, endwall; + short sp_num, next_sp_num, startwall, endwall; int i, k, j; SPRITEp BoundSprite; SWBOOL FoundOutsideLoop = FALSE, FoundSector = FALSE; @@ -846,7 +846,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) sop->num_sectors++; } - ASSERT(sop->num_sectors < SIZ(SectorObject[0].sector)); + ASSERT((uint16_t)sop->num_sectors < SIZ(SectorObject[0].sector)); } // @@ -967,6 +967,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // sector // place all sprites on list + uint16_t sn; for (sn = 0; sn < (int)SIZ(sop->sp_num); sn++) { if (sop->sp_num[sn] == -1) @@ -1498,7 +1499,7 @@ PlaceSectorObjectsOnTracks(void) } } - ASSERT(sop->num_walls < SIZ(sop->xorig)); + ASSERT((uint16_t)sop->num_walls < SIZ(sop->xorig)); if (sop->track <= -1) continue; diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index d5f64cc72..a22b0b22c 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -7748,7 +7748,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in { sect = sectlist[sectlistplc++]; - ASSERT(sectlistplc < SIZ(sectlist)); + ASSERT((uint16_t)sectlistplc < SIZ(sectlist)); startwall = sector[sect].wallptr; endwall = startwall + sector[sect].wallnum; @@ -7798,7 +7798,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in if (k < 0) { sectlist[sectlistend++] = nextsector; - ASSERT(sectlistend < SIZ(sectlist)); + ASSERT((uint16_t)sectlistend < SIZ(sectlist)); } } From c27616508ea4e61e8c7f5d4cb4d3bba56bfc1385 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:45:00 +0000 Subject: [PATCH 5/7] SW: Move HIT_PLAX_WALL out of the bit range used for limit raised struct IDs git-svn-id: https://svn.eduke32.com/eduke32@8350 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/game.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index efe03ec41..b86e20953 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -527,11 +527,11 @@ int StdRandomRange(int range); #define MDA_REVERSEBLINK 0xF0 // defines for move_sprite return value -#define HIT_MASK (BIT(13)|BIT(14)|BIT(15)) +#define HIT_MASK (BIT(14)|BIT(15)|BIT(16)) #define HIT_SPRITE (BIT(14)|BIT(15)) #define HIT_WALL BIT(15) #define HIT_SECTOR BIT(14) -#define HIT_PLAX_WALL BIT(13) +#define HIT_PLAX_WALL BIT(16) #define NORM_SPRITE(val) ((val) & (MAXSPRITES - 1)) #define NORM_WALL(val) ((val) & (MAXWALLS - 1)) From 53e2a8297d317d8c74a20c4f5c29bc989ec8ba83 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 3 Dec 2019 09:45:05 +0000 Subject: [PATCH 6/7] Fix STARTUP_WINDOW=0 on modern macOS git-svn-id: https://svn.eduke32.com/eduke32@8351 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/sdlayer.cpp # source/build/src/startosx.editor.mm # source/platform/macos/osxbits.h # source/platform/macos/startosx.game.mm --- source/platform/macos/osxbits.h | 3 +++ source/platform/macos/osxbits.mm | 14 ++++++++++++++ source/platform/macos/startosx.game.mm | 9 +-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/source/platform/macos/osxbits.h b/source/platform/macos/osxbits.h index 8a35e14df..639e48869 100644 --- a/source/platform/macos/osxbits.h +++ b/source/platform/macos/osxbits.h @@ -2,6 +2,9 @@ #define osxbits_h_ #include +void osx_preopen(void); +void osx_postopen(void); + int osx_msgbox(const char *name, const char *msg); int osx_ynbox(const char *name, const char *msg); diff --git a/source/platform/macos/osxbits.mm b/source/platform/macos/osxbits.mm index 613d6b554..16f04ec01 100644 --- a/source/platform/macos/osxbits.mm +++ b/source/platform/macos/osxbits.mm @@ -23,6 +23,20 @@ # define MAC_OS_VERSION_10_3 1030 #endif +id nsapp; + +void osx_preopen(void) +{ + // fix for "ld: absolute address to symbol _NSApp in a different linkage unit not supported" + // (OS X 10.6) when building for PPC + nsapp = [NSApplication sharedApplication]; +} + +void osx_postopen(void) +{ + [nsapp finishLaunching]; +} + int osx_msgbox(const char *name, const char *msg) { NSString *mmsg = [[NSString alloc] initWithUTF8String:msg]; diff --git a/source/platform/macos/startosx.game.mm b/source/platform/macos/startosx.game.mm index 731a4634f..b88b589e8 100644 --- a/source/platform/macos/startosx.game.mm +++ b/source/platform/macos/startosx.game.mm @@ -11,6 +11,7 @@ #include "compat.h" #include "baselayer.h" #include "grpscan.h" +#include "osxbits.h" #import "GrpFile.game.h" #import "GameListSource.game.h" @@ -105,8 +106,6 @@ static NSPopUpButton * makeComboBox(void) return comboBox; } -static id nsapp; - /* setAppleMenu disappeared from the headers in 10.4 */ @interface NSApplication(NSAppleMenu) - (void)setAppleMenu:(NSMenu *)menu; @@ -599,10 +598,6 @@ static StartupWindow *startwin = nil; int startwin_open(void) { - // fix for "ld: absolute address to symbol _NSApp in a different linkage unit not supported" - // (OS X 10.6) when building for PPC - nsapp = [NSApplication sharedApplication]; - if (startwin != nil) return 1; startwin = [[StartupWindow alloc] init]; @@ -610,8 +605,6 @@ int startwin_open(void) [startwin setupMessagesMode]; - [nsapp finishLaunching]; - [startwin center]; [startwin makeKeyAndOrderFront:nil]; From 6f9494435a820816ee3f66de5e4a559ce4e4ed70 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Dec 2019 17:40:35 +0100 Subject: [PATCH 7/7] - adjustment for last commit. --- source/sw/src/draw.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index b1301efa8..6c8bbb330 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2248,12 +2248,6 @@ drawscreen(PLAYERp pp) PreUpdatePanel(); - if (r_usenewaspect) - { - newaspect_enable = 1; - videoSetCorrectedAspect(); - } - smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536); if (!ScreenSavePic) @@ -2478,12 +2472,6 @@ drawscreen(PLAYERp pp) SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR); } - if (r_usenewaspect) - { - newaspect_enable = 0; - videoSetCorrectedAspect(); - } - // if doing a screen save don't need to process the rest if (ScreenSavePic)