Merge branch 'master' into menu_for_real

This commit is contained in:
Christoph Oelckers 2019-12-04 17:25:40 +01:00
commit 4cefc1db83
15 changed files with 247 additions and 133 deletions

View file

@ -2,6 +2,9 @@
#define osxbits_h_
#include <sys/types.h>
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);

View file

@ -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];

View file

@ -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];

View file

@ -2169,7 +2169,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;
@ -2181,6 +2180,8 @@ drawscreen(PLAYERp pp)
static short lv_sectnum = -1;
static int lv_x, lv_y, lv_z;
int const viewingRange = viewingrange;
if (HelpInputMode)
{
renderFlushPerms();
@ -2230,12 +2231,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)
@ -2266,11 +2261,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
{
@ -2282,7 +2279,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;
@ -2346,6 +2343,12 @@ drawscreen(PLAYERp pp)
thoriz = min(thoriz, PLAYER_HORIZ_MAX);
}
if (r_usenewaspect)
{
newaspect_enable = 1;
videoSetCorrectedAspect();
}
if (FAF_DebugView)
videoClearViewableArea(255L);
@ -2370,6 +2373,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
@ -2389,18 +2398,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)
@ -2443,12 +2455,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)

View file

@ -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
@ -91,16 +95,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()
@ -379,8 +375,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])
@ -532,11 +528,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))
@ -1163,7 +1159,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];

View file

@ -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);

View file

@ -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))
{
@ -7666,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);

View file

@ -1795,13 +1795,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);
@ -2548,6 +2549,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
@ -2691,7 +2695,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))
{
@ -2733,6 +2737,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, &sectnum);
@ -2760,13 +2767,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
@ -2784,7 +2790,7 @@ DoPlayerSectorUpdatePostMove(PLAYERp pp)
// try again
updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
ASSERT(pp->cursectnum >= 0);
// ASSERT(pp->cursectnum >= 0);
}
}
else
@ -3652,7 +3658,7 @@ void StackedWaterSplash(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum);
if (SectorIsUnderwaterArea(sectnum))
if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
{
PlaySound(DIGI_SPLASH1, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan);
}
@ -3673,7 +3679,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);
@ -4105,7 +4111,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;
@ -4256,7 +4262,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))
@ -4359,7 +4365,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;
}
@ -4441,7 +4447,7 @@ DoPlayerFly(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite];
if (SectorIsUnderwaterArea(pp->cursectnum))
if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{
DoPlayerBeginDiveNoWarp(pp);
return;
@ -4705,7 +4711,7 @@ PlayerCanDiveNoWarp(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum);
if (SectorIsUnderwaterArea(sectnum))
if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
{
pp->cursectnum = sectnum;
pp->posz = sector[sectnum].ceilingz;
@ -5127,7 +5133,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
@ -5293,7 +5299,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);
@ -7368,7 +7374,7 @@ DoPlayerRun(PLAYERp pp)
{
USERp u = User[pp->PlayerSprite];
if (SectorIsUnderwaterArea(pp->cursectnum))
if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{
DoPlayerBeginDiveNoWarp(pp);
return;
@ -7440,7 +7446,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))
{
@ -8417,6 +8423,9 @@ DoFootPrints(short SpriteNum)
if (u->PlayerP)
{
if (u->PlayerP->cursectnum < 0)
return 0;
if (FAF_ConnectArea(u->PlayerP->cursectnum))
return 0;

View file

@ -59,7 +59,7 @@ SWBOOL FAF_DebugView = 0;
void COVERupdatesector(int32_t x, int32_t y, int16_t* newsector)
{
ASSERT(*newsector>=0 && *newsector<MAXSECTORS);
// ASSERT(*newsector>=0 && *newsector<MAXSECTORS);
updatesector(x,y,newsector);
}
@ -281,10 +281,10 @@ FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects,
SWBOOL plax_found = FALSE;
vec3_t s = { xs, ys, zs };
ASSERT(sects >= 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);

View file

@ -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);

View file

@ -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;
@ -2087,11 +2087,14 @@ int DoTrapMatch(short match)
void
OperateTripTrigger(PLAYERp pp)
{
SECTORp sectp = &sector[pp->cursectnum];
if (Prediction)
return;
if (pp->cursectnum < 0)
return;
SECTORp sectp = &sector[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 = &sector[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 = &sector[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))
{

View file

@ -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);
@ -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
}

View file

@ -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;

View file

@ -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)

View file

@ -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
@ -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)
{
@ -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;
@ -7745,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;
@ -7795,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));
}
}
@ -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;
@ -13021,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);
@ -13569,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,
@ -13729,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);
@ -14740,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
@ -14871,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);
@ -14944,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);
@ -15259,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;
@ -15368,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;
@ -15549,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,
@ -15595,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;
@ -15673,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,
@ -15783,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,
@ -15972,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)
@ -17528,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;
@ -17546,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);
@ -17843,17 +17900,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
@ -18542,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;
@ -18598,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;
@ -19387,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);
@ -19554,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);
@ -19733,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;
@ -20638,13 +20712,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);
}