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_ #define osxbits_h_
#include <sys/types.h> #include <sys/types.h>
void osx_preopen(void);
void osx_postopen(void);
int osx_msgbox(const char *name, const char *msg); int osx_msgbox(const char *name, const char *msg);
int osx_ynbox(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 # define MAC_OS_VERSION_10_3 1030
#endif #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) int osx_msgbox(const char *name, const char *msg)
{ {
NSString *mmsg = [[NSString alloc] initWithUTF8String:msg]; NSString *mmsg = [[NSString alloc] initWithUTF8String:msg];

View file

@ -11,6 +11,7 @@
#include "compat.h" #include "compat.h"
#include "baselayer.h" #include "baselayer.h"
#include "grpscan.h" #include "grpscan.h"
#include "osxbits.h"
#import "GrpFile.game.h" #import "GrpFile.game.h"
#import "GameListSource.game.h" #import "GameListSource.game.h"
@ -105,8 +106,6 @@ static NSPopUpButton * makeComboBox(void)
return comboBox; return comboBox;
} }
static id nsapp;
/* setAppleMenu disappeared from the headers in 10.4 */ /* setAppleMenu disappeared from the headers in 10.4 */
@interface NSApplication(NSAppleMenu) @interface NSApplication(NSAppleMenu)
- (void)setAppleMenu:(NSMenu *)menu; - (void)setAppleMenu:(NSMenu *)menu;
@ -599,10 +598,6 @@ static StartupWindow *startwin = nil;
int startwin_open(void) 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; if (startwin != nil) return 1;
startwin = [[StartupWindow alloc] init]; startwin = [[StartupWindow alloc] init];
@ -610,8 +605,6 @@ int startwin_open(void)
[startwin setupMessagesMode]; [startwin setupMessagesMode];
[nsapp finishLaunching];
[startwin center]; [startwin center];
[startwin makeKeyAndOrderFront:nil]; [startwin makeKeyAndOrderFront:nil];

View file

@ -2169,7 +2169,6 @@ drawscreen(PLAYERp pp)
int tx, ty, tz,thoriz,pp_siz; int tx, ty, tz,thoriz,pp_siz;
short tang,tsectnum; short tang,tsectnum;
short i,j; short i,j;
walltype *wal;
int tiltlock; int tiltlock;
int bob_amt = 0; int bob_amt = 0;
int quake_z, quake_x, quake_y; int quake_z, quake_x, quake_y;
@ -2181,6 +2180,8 @@ drawscreen(PLAYERp pp)
static short lv_sectnum = -1; static short lv_sectnum = -1;
static int lv_x, lv_y, lv_z; static int lv_x, lv_y, lv_z;
int const viewingRange = viewingrange;
if (HelpInputMode) if (HelpInputMode)
{ {
renderFlushPerms(); renderFlushPerms();
@ -2230,12 +2231,6 @@ drawscreen(PLAYERp pp)
PreUpdatePanel(); PreUpdatePanel();
if (r_usenewaspect)
{
newaspect_enable = 1;
videoSetCorrectedAspect();
}
smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536); smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536);
if (!ScreenSavePic) if (!ScreenSavePic)
@ -2266,11 +2261,13 @@ drawscreen(PLAYERp pp)
if (tsectnum < 0) if (tsectnum < 0)
{ {
#if 0
// if we hit an invalid sector move to the last valid position for drawing // if we hit an invalid sector move to the last valid position for drawing
tsectnum = lv_sectnum; tsectnum = lv_sectnum;
tx = lv_x; tx = lv_x;
ty = lv_y; ty = lv_y;
tz = lv_z; tz = lv_z;
#endif
} }
else else
{ {
@ -2282,7 +2279,7 @@ drawscreen(PLAYERp pp)
} }
// with "last valid" code this should never happen // with "last valid" code this should never happen
ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); // ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS);
pp->six = tx; pp->six = tx;
pp->siy = ty; pp->siy = ty;
@ -2346,6 +2343,12 @@ drawscreen(PLAYERp pp)
thoriz = min(thoriz, PLAYER_HORIZ_MAX); thoriz = min(thoriz, PLAYER_HORIZ_MAX);
} }
if (r_usenewaspect)
{
newaspect_enable = 1;
videoSetCorrectedAspect();
}
if (FAF_DebugView) if (FAF_DebugView)
videoClearViewableArea(255L); videoClearViewableArea(255L);
@ -2370,6 +2373,12 @@ drawscreen(PLAYERp pp)
post_analyzesprites(); post_analyzesprites();
renderDrawMasks(); renderDrawMasks();
if (r_usenewaspect)
{
newaspect_enable = 0;
renderSetAspect(viewingRange, tabledivide32_noinline(65536 * ydim * 8, xdim * 5));
}
UpdatePanel(); UpdatePanel();
#define SLIME 2305 #define SLIME 2305
@ -2389,18 +2398,21 @@ drawscreen(PLAYERp pp)
i = pp->cursectnum; i = pp->cursectnum;
show2dsector[i>>3] |= (1<<(i&7)); if (i >= 0)
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)); 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) if ((dimensionmode == 5 || dimensionmode == 6) && pp == Player+myconnectindex)
@ -2443,12 +2455,6 @@ drawscreen(PLAYERp pp)
SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR); 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 doing a screen save don't need to process the rest
if (ScreenSavePic) if (ScreenSavePic)

View file

@ -60,19 +60,23 @@ extern char isShareware;
#define ERR_STD_ARG __FILE__, __LINE__ #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 #if DEBUG
void HeapCheck(char *, int); void HeapCheck(char *, int);
#define HEAP_CHECK() HeapCheck(__FILE__, __LINE__) #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 *, ...); void dsprintf(char *, char *, ...);
#define DSPRINTF dsprintf #define DSPRINTF dsprintf
@ -91,16 +95,8 @@ extern int DispMono;
#define RANDOM_DEBUG 1 // Set this to 1 for network testing. #define RANDOM_DEBUG 1 // Set this to 1 for network testing.
#else #else
#define ASSERT(f) do { } while(0)
#define MONO_PRINT(str) #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, ...); void dsprintf_null(char *str, const char *format, ...);
#define DSPRINTF dsprintf_null #define DSPRINTF dsprintf_null
//#define DSPRINTF() //#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 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 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_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) = nextspritestat[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]) #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i])
@ -532,11 +528,11 @@ int StdRandomRange(int range);
#define MDA_REVERSEBLINK 0xF0 #define MDA_REVERSEBLINK 0xF0
// defines for move_sprite return value // 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_SPRITE (BIT(14)|BIT(15))
#define HIT_WALL BIT(15) #define HIT_WALL BIT(15)
#define HIT_SECTOR BIT(14) #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_SPRITE(val) ((val) & (MAXSPRITES - 1))
#define NORM_WALL(val) ((val) & (MAXWALLS - 1)) #define NORM_WALL(val) ((val) & (MAXWALLS - 1))
@ -1163,7 +1159,7 @@ struct PLAYERstruct
short DiveDamageTics; short DiveDamageTics;
// Death stuff // Death stuff
short DeathType; uint16_t DeathType;
short Kills; short Kills;
short Killer; //who killed me short Killer; //who killed me
short KilledPlayer[MAX_SW_PLAYERS_REG]; 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); PlaySound(DIGI_THROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan | v3df_doppler);
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); 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); PlaySound(DIGI_THROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan | v3df_doppler);
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);

View file

@ -7347,7 +7347,6 @@ pDisplaySprites(PLAYERp pp)
int smoothratio; int smoothratio;
unsigned i; unsigned i;
SECT_USERp sectu = SectUser[pp->cursectnum];
uint8_t pal = 0; uint8_t pal = 0;
short ang; short ang;
int flags; 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 its a weapon sprite and the view is set to the outside don't draw the sprite
if (TEST(psp->flags, PANF_WEAPON_SPRITE)) if (TEST(psp->flags, PANF_WEAPON_SPRITE))
{ {
pal = sector[pp->cursectnum].floorpal; SECT_USERp sectu = nullptr;
int16_t floorshade = 0;
if (sector[pp->cursectnum].floorpal != PALETTE_DEFAULT) if (pp->cursectnum >= 0)
{ {
SECT_USERp sectu = SectUser[pp->cursectnum]; sectu = SectUser[pp->cursectnum];
if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE)) pal = sector[pp->cursectnum].floorpal;
pal = PALETTE_DEFAULT; floorshade = sector[pp->cursectnum].floorshade;
}
if (pal == PALETTE_FOG || pal == PALETTE_DIVE || pal == PALETTE_DIVE_LAVA) if (pal != PALETTE_DEFAULT)
pal = psp->pal; // Set it back {
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 = 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)) if (TEST(psp->PlayerP->Flags, PF_VIEW_FROM_OUTSIDE))
{ {
@ -7666,7 +7671,7 @@ pSpriteControl(PLAYERp pp)
// RULE: Sprites can only kill themselves // RULE: Sprites can only kill themselves
PRODUCTION_ASSERT(psp); PRODUCTION_ASSERT(psp);
ASSERT(ValidPtr(psp)); ASSERT(ValidPtr(psp));
ASSERT((uint32_t) psp->Next != 0xCCCCCCCC); // ASSERT((uint32_t) psp->Next != 0xCCCCCCCC);
if (psp->State) if (psp->State)
pStateControl(psp); pStateControl(psp);

View file

@ -1795,13 +1795,14 @@ DoPlayerTurnTurret(PLAYERp pp)
void SlipSlope(PLAYERp pp) void SlipSlope(PLAYERp pp)
{ {
short wallptr = sector[pp->cursectnum].wallptr;
short ang; 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; 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 = getangle(wall[wall[wallptr].point2].x - wall[wallptr].x, wall[wall[wallptr].point2].y - wall[wallptr].y);
ang = NORM_ANGLE(ang + 512); ang = NORM_ANGLE(ang + 512);
@ -2548,6 +2549,9 @@ DoPlayerMenuKeys(PLAYERp pp)
void PlayerSectorBound(PLAYERp pp, int amt) void PlayerSectorBound(PLAYERp pp, int amt)
{ {
if (pp->cursectnum < 9)
return;
int cz,fz; int cz,fz;
// player should never go into a sector // player should never go into a sector
@ -2691,7 +2695,7 @@ DoPlayerMove(PLAYERp pp)
DoPlayerHorizon(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)) if (TEST(pp->Flags, PF_FLYING|PF_JUMPING|PF_FALLING))
{ {
@ -2733,6 +2737,9 @@ DoPlayerSectorUpdatePreMove(PLAYERp pp)
{ {
short sectnum = pp->cursectnum; short sectnum = pp->cursectnum;
if (sectnum < 0)
return;
if (TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) if (TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA))
{ {
updatesectorz(pp->posx, pp->posy, pp->posz, &sectnum); updatesectorz(pp->posx, pp->posy, pp->posz, &sectnum);
@ -2760,13 +2767,12 @@ DoPlayerSectorUpdatePreMove(PLAYERp pp)
void void
DoPlayerSectorUpdatePostMove(PLAYERp pp) DoPlayerSectorUpdatePostMove(PLAYERp pp)
{ {
short sectnum; short sectnum = pp->cursectnum;
int fz,cz; int fz,cz;
// need to do updatesectorz if in connect area // 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); updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
// can mess up if below // can mess up if below
@ -2784,7 +2790,7 @@ DoPlayerSectorUpdatePostMove(PLAYERp pp)
// try again // try again
updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum); updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
ASSERT(pp->cursectnum >= 0); // ASSERT(pp->cursectnum >= 0);
} }
} }
else else
@ -3652,7 +3658,7 @@ void StackedWaterSplash(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum); 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); PlaySound(DIGI_SPLASH1, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan);
} }
@ -3673,7 +3679,7 @@ DoPlayerFall(PLAYERp pp)
FLAG_KEY_RESET(pp, SK_JUMP); FLAG_KEY_RESET(pp, SK_JUMP);
} }
if (SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{ {
StackedWaterSplash(pp); StackedWaterSplash(pp);
DoPlayerBeginDiveNoWarp(pp); DoPlayerBeginDiveNoWarp(pp);
@ -4105,7 +4111,7 @@ DoPlayerWadeSuperJump(PLAYERp pp)
{ {
hitinfo.sect = wall[hitinfo.wall].nextsector; 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)) if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->SpriteP->clipdist)<<2) + 256))
return TRUE; return TRUE;
@ -4256,7 +4262,7 @@ DoPlayerCrawl(PLAYERp pp)
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
if (SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{ {
// if stacked water - which it should be // if stacked water - which it should be
if (FAF_ConnectArea(pp->cursectnum)) if (FAF_ConnectArea(pp->cursectnum))
@ -4359,7 +4365,7 @@ DoPlayerCrawl(PLAYERp pp)
return; 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; pp->posz = pp->loz - PLAYER_CRAWL_HEIGHT;
} }
@ -4441,7 +4447,7 @@ DoPlayerFly(PLAYERp pp)
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
if (SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{ {
DoPlayerBeginDiveNoWarp(pp); DoPlayerBeginDiveNoWarp(pp);
return; return;
@ -4705,7 +4711,7 @@ PlayerCanDiveNoWarp(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum); updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum);
if (SectorIsUnderwaterArea(sectnum)) if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
{ {
pp->cursectnum = sectnum; pp->cursectnum = sectnum;
pp->posz = sector[sectnum].ceilingz; pp->posz = sector[sectnum].ceilingz;
@ -5127,7 +5133,7 @@ void DoPlayerBeginDiveNoWarp(PLAYERp pp)
if (Prediction) if (Prediction)
return; return;
if (!SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum))
return; return;
if (pp->Bloody) pp->Bloody = FALSE; // Water washes away the blood if (pp->Bloody) pp->Bloody = FALSE; // Water washes away the blood
@ -5293,7 +5299,7 @@ DoPlayerDive(PLAYERp pp)
SECT_USERp sectu = SectUser[pp->cursectnum]; SECT_USERp sectu = SectUser[pp->cursectnum];
// whenever your view is not in a water area // whenever your view is not in a water area
if (!SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum < 0 || !SectorIsUnderwaterArea(pp->cursectnum))
{ {
DoPlayerStopDiveNoWarp(pp); DoPlayerStopDiveNoWarp(pp);
DoPlayerBeginRun(pp); DoPlayerBeginRun(pp);
@ -7368,7 +7374,7 @@ DoPlayerRun(PLAYERp pp)
{ {
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
if (SectorIsUnderwaterArea(pp->cursectnum)) if (pp->cursectnum >= 0 && SectorIsUnderwaterArea(pp->cursectnum))
{ {
DoPlayerBeginDiveNoWarp(pp); DoPlayerBeginDiveNoWarp(pp);
return; return;
@ -7440,7 +7446,7 @@ DoPlayerRun(PLAYERp pp)
{ {
if (TEST_SYNC_KEY(pp, SK_OPERATE)) 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)) if (TEST(sector[pp->cursectnum].extra, SECTFX_OPERATIONAL))
{ {
@ -8417,6 +8423,9 @@ DoFootPrints(short SpriteNum)
if (u->PlayerP) if (u->PlayerP)
{ {
if (u->PlayerP->cursectnum < 0)
return 0;
if (FAF_ConnectArea(u->PlayerP->cursectnum)) if (FAF_ConnectArea(u->PlayerP->cursectnum))
return 0; return 0;

View file

@ -59,7 +59,7 @@ SWBOOL FAF_DebugView = 0;
void COVERupdatesector(int32_t x, int32_t y, int16_t* newsector) 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); 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; SWBOOL plax_found = FALSE;
vec3_t s = { xs, ys, zs }; vec3_t s = { xs, ys, zs };
ASSERT(sects >= 0 && secte >= 0); // ASSERT(sects >= 0 && secte >= 0);
// early out to regular routine // 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); return cansee(xs,ys,zs,sects,xe,ye,ze,secte);
} }
@ -356,7 +356,7 @@ GetZadjustment(short sectnum, short hitag)
short i, nexti; short i, nexti;
SPRITEp sp; SPRITEp sp;
if (!TEST(sector[sectnum].extra, SECTFX_Z_ADJUST)) if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_Z_ADJUST))
return 0L; return 0L;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ST1], i, nexti) 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. // because the ceiling and floors get moved out of the way for drawing.
// early out to regular routine // 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); getzrange_old(x, y, z, sectnum, hiz, ceilhit, loz, florhit, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, *florhit, loz); 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); updatesectorz(x, y, newz, &uppersect);
if (uppersect < 0) 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); getzrange_old(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, -1, NULL); 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); updatesectorz(x, y, newz, &lowersect);
if (lowersect < 0) 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); getzrange_old(x, y, newz, lowersect, &foo1, &foo2, loz, florhit, clipdist, clipmask);
SectorZadjust(-1, NULL, *florhit, loz); SectorZadjust(-1, NULL, *florhit, loz);
WaterAdjust(*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); updatesectorz(x, y, newz, &uppersect);
if (uppersect < 0) 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); getzrangepoint(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2);
SectorZadjust(*ceilhit, hiz, -1, NULL); 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); updatesectorz(x, y, newz, &lowersect);
if (lowersect < 0) 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); getzrangepoint(x, y, newz, lowersect, &foo1, &foo2, loz, florhit);
SectorZadjust(-1, NULL, *florhit, loz); SectorZadjust(-1, NULL, *florhit, loz);
WaterAdjust(*florhit, loz); WaterAdjust(*florhit, loz);

View file

@ -89,7 +89,7 @@ SWBOOL LoadScriptFile(const char *filename)
size = fp.GetLength(); size = fp.GetLength();
scriptbuffer = (char *)AllocMem(size); scriptbuffer = (char *)AllocMem(size+1);
ASSERT(scriptbuffer != NULL); ASSERT(scriptbuffer != NULL);
@ -97,6 +97,7 @@ SWBOOL LoadScriptFile(const char *filename)
ASSERT(readsize == size); ASSERT(readsize == size);
scriptbuffer[readsize] = '\0';
// Convert filebuffer to all upper case // Convert filebuffer to all upper case
//Bstrupr(scriptbuffer); //Bstrupr(scriptbuffer);

View file

@ -486,7 +486,7 @@ SectorSetup(void)
{ {
SINE_WAVE_FLOOR *swf; SINE_WAVE_FLOOR *swf;
short near_sect = i, base_sect = i; short near_sect = i, base_sect = i;
short swf_ndx = 0; uint16_t swf_ndx = 0;
short cnt = 0, sector_cnt; short cnt = 0, sector_cnt;
int range; int range;
int range_diff = 0; int range_diff = 0;
@ -2087,11 +2087,14 @@ int DoTrapMatch(short match)
void void
OperateTripTrigger(PLAYERp pp) OperateTripTrigger(PLAYERp pp)
{ {
SECTORp sectp = &sector[pp->cursectnum];
if (Prediction) if (Prediction)
return; return;
if (pp->cursectnum < 0)
return;
SECTORp sectp = &sector[pp->cursectnum];
#if 0 #if 0
// new method // new method
if (TEST(sectp->extra, SECTFX_TRIGGER)) if (TEST(sectp->extra, SECTFX_TRIGGER))
@ -2249,6 +2252,9 @@ OperateContinuousTrigger(PLAYERp pp)
if (Prediction) if (Prediction)
return; return;
if (pp->cursectnum < 0)
return;
switch (LOW_TAG(pp->cursectnum)) switch (LOW_TAG(pp->cursectnum))
{ {
case TAG_TRIGGER_MISSILE_TRAP: case TAG_TRIGGER_MISSILE_TRAP:
@ -2589,8 +2595,6 @@ int DoPlayerGrabStar(PLAYERp pp)
void void
PlayerOperateEnv(PLAYERp pp) PlayerOperateEnv(PLAYERp pp)
{ {
SECT_USERp sectu = SectUser[pp->cursectnum];
SECTORp sectp = &sector[pp->cursectnum];
SWBOOL found; SWBOOL found;
if (Prediction) 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)) if (TEST(sectu->flags, SECTFU_DAMAGE_ABOVE_SECTOR))
{ {
PlayerTakeSectorDamage(pp); PlayerTakeSectorDamage(pp);
@ -2761,7 +2767,7 @@ PlayerOperateEnv(PLAYERp pp)
{ {
OperateTripTrigger(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)) 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); ASSERT(!Prediction);
PRODUCTION_ASSERT(sectnum >= 0 && sectnum < MAXSECTORS); // PRODUCTION_ASSERT(sectnum >= 0 && sectnum < MAXSECTORS);
SpriteNum = COVERinsertsprite(sectnum, stat); SpriteNum = COVERinsertsprite(sectnum, stat);
@ -6812,11 +6812,11 @@ SpriteControl(void)
u = User[i]; u = User[i];
sp = User[i]->SpriteP; sp = User[i]->SpriteP;
STATE_CONTROL(i, sp, u, StateTics) STATE_CONTROL(i, sp, u, StateTics)
ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); // ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE);
#else #else
ASSERT(User[i]); ASSERT(User[i]);
StateControl(i); StateControl(i);
ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE); // ASSERT(nexti >= 0 ? User[nexti] != NULL : TRUE);
#endif #endif
} }

View file

@ -726,7 +726,7 @@ void
SectorObjectSetupBounds(SECTOR_OBJECTp sop) SectorObjectSetupBounds(SECTOR_OBJECTp sop)
{ {
int xlow, ylow, xhigh, yhigh; 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; int i, k, j;
SPRITEp BoundSprite; SPRITEp BoundSprite;
SWBOOL FoundOutsideLoop = FALSE, FoundSector = FALSE; SWBOOL FoundOutsideLoop = FALSE, FoundSector = FALSE;
@ -846,7 +846,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
sop->num_sectors++; 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 // sector
// place all sprites on list // place all sprites on list
uint16_t sn;
for (sn = 0; sn < (int)SIZ(sop->sp_num); sn++) for (sn = 0; sn < (int)SIZ(sop->sp_num); sn++)
{ {
if (sop->sp_num[sn] == -1) 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) if (sop->track <= -1)
continue; continue;

View file

@ -54,7 +54,7 @@ WarpPlaneSectorInfo(short sectnum, SPRITEp *sp_ceiling, SPRITEp *sp_floor)
if (Prediction) if (Prediction)
return FALSE; return FALSE;
if (!TEST(sector[sectnum].extra, SECTFX_WARP_SECTOR)) if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_WARP_SECTOR))
return FALSE; return FALSE;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP], i, nexti) 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) SWBOOL MissileHitMatch(short Weapon, short WeaponNum, short hit_sprite)
{ {
SPRITEp hsp = &sprite[hit_sprite]; SPRITEp hsp = &sprite[hit_sprite];
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
if (WeaponNum <= -1) if (WeaponNum <= -1)
{ {
ASSERT(Weapon >= 0); ASSERT(Weapon >= 0);
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
WeaponNum = wu->WeaponNum; WeaponNum = wu->WeaponNum;
// can be hit by SO only // can be hit by SO only
@ -2777,7 +2777,7 @@ int DoLavaErupt(short SpriteNum)
TRAVERSE_CONNECT(pnum) TRAVERSE_CONNECT(pnum)
{ {
pp = Player + 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) TRAVERSE_SPRITE_SECT(headspritesect[pp->cursectnum],i,nexti)
{ {
@ -5760,8 +5760,6 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
{ {
SPRITEp sp = pp->SpriteP; SPRITEp sp = pp->SpriteP;
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
int SpawnZombie(PLAYERp pp, short); int SpawnZombie(PLAYERp pp, short);
@ -5786,6 +5784,9 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
return TRUE; return TRUE;
} }
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0))
pp->DeathType = PLAYER_DEATH_RIPPER; pp->DeathType = PLAYER_DEATH_RIPPER;
@ -5828,14 +5829,14 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
SWBOOL SWBOOL
PlayerTakeDamage(PLAYERp pp, short Weapon) PlayerTakeDamage(PLAYERp pp, short Weapon)
{ {
if (Weapon < 0)
return TRUE;
SPRITEp sp = pp->SpriteP; SPRITEp sp = pp->SpriteP;
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
SPRITEp wp = &sprite[Weapon]; SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon]; USERp wu = User[Weapon];
if (Weapon < 0)
return TRUE;
if (gNet.MultiGameType == MULTI_GAME_NONE) if (gNet.MultiGameType == MULTI_GAME_NONE)
{ {
// ZOMBIE special case for single play // ZOMBIE special case for single play
@ -7607,9 +7608,11 @@ DoDamageTest(short Weapon)
return 0; return 0;
} }
int static int DoHitscanDamage(short Weapon, uint16_t hit_sprite)
DoHitscanDamage(short Weapon, short hit_sprite)
{ {
if (hit_sprite >= MAXSPRITES)
return 0;
SPRITEp wp = &sprite[Weapon]; SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon]; USERp wu = User[Weapon];
unsigned stat; unsigned stat;
@ -7745,7 +7748,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in
{ {
sect = sectlist[sectlistplc++]; sect = sectlist[sectlistplc++];
ASSERT(sectlistplc < SIZ(sectlist)); ASSERT((uint16_t)sectlistplc < SIZ(sectlist));
startwall = sector[sect].wallptr; startwall = sector[sect].wallptr;
endwall = startwall + sector[sect].wallnum; 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) if (k < 0)
{ {
sectlist[sectlistend++] = nextsector; 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]; SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum]; USERp u = User[SpriteNum];
SPRITEp ep = &sprite[enemy]; SPRITEp ep;
USERp eu = User[enemy]; USERp eu;
SPRITEp np; SPRITEp np;
USERp nu; USERp nu;
short New; short New;
@ -10843,6 +10846,9 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy)
if (enemy >= 0) if (enemy >= 0)
{ {
ep = &sprite[enemy];
eu = User[enemy];
// test for already burned // test for already burned
if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40) if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40)
return -1; return -1;
@ -13021,6 +13027,9 @@ InitSpellRing(PLAYERp pp)
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
PlaySound(DIGI_RFWIZ, &pp->posx, &pp->posy, &pp->posz, v3df_none); 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++) 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); 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); PlaySound(DIGI_NAPFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_none);
if (pp->cursectnum < 0)
return;
for (i = 0; i < SIZ(mp); i++) for (i = 0; i < SIZ(mp); i++)
{ {
SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Napalm, pp->cursectnum, 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); 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, SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Mirv, pp->cursectnum,
pp->posx, pp->posy, pp->posz + Z(12), pp->pang, MIRV_VELOCITY); pp->posx, pp->posy, pp->posz + Z(12), pp->pang, MIRV_VELOCITY);
@ -14740,13 +14755,16 @@ InitStar(PLAYERp pp)
PlayerUpdateAmmo(pp, u->WeaponNum, -3); 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; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
PlaySound(DIGI_STAR, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler);
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
@ -14871,6 +14889,9 @@ InitHeartAttack(PLAYERp pp)
PlayerUpdateAmmo(pp, WPN_HEART, -1); PlayerUpdateAmmo(pp, WPN_HEART, -1);
if (pp->cursectnum < 0)
return;
SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, 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); 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); PlayerUpdateAmmo(pp, WPN_HEART, -1);
if (pp->cursectnum < 0)
return;
SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, 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); 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); PlaySound(DIGI_RIOTFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler);
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
@ -15368,6 +15395,9 @@ InitRail(PLAYERp pp)
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
@ -15549,17 +15579,30 @@ InitRocket(PLAYERp pp)
DoPlayerBeginRecoil(pp, ROCKET_RECOIL_AMT); DoPlayerBeginRecoil(pp, ROCKET_RECOIL_AMT);
PlayerUpdateAmmo(pp, u->WeaponNum, -1); 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); PlaySound(DIGI_RIOTFIRE, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler);
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
//nz = pp->posz + pp->bob_z + Z(12); //nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum,
@ -15595,7 +15638,6 @@ InitRocket(PLAYERp pp)
switch (pp->WpnRocketType) switch (pp->WpnRocketType)
{ {
case 1: case 1:
pp->WpnRocketHeat--;
SET(wu->Flags, SPR_FIND_PLAYER); SET(wu->Flags, SPR_FIND_PLAYER);
wp->pal = wu->spal = 20; // Yellow wp->pal = wu->spal = 20; // Yellow
break; break;
@ -15673,11 +15715,15 @@ InitBunnyRocket(PLAYERp pp)
PlaySound(DIGI_BUNNYATTACK, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler); PlaySound(DIGI_BUNNYATTACK, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler);
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
//nz = pp->posz + pp->bob_z + Z(12); //nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R4, &s_BunnyRocket[0][0], pp->cursectnum, w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R4, &s_BunnyRocket[0][0], pp->cursectnum,
@ -15783,11 +15829,15 @@ InitNuke(PLAYERp pp)
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
//nz = pp->posz + pp->bob_z + Z(12); //nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum,
@ -15972,6 +16022,9 @@ InitMicro(PLAYERp pp)
if (TargetSortCount > MAX_MICRO) if (TargetSortCount > MAX_MICRO)
TargetSortCount = MAX_MICRO; TargetSortCount = MAX_MICRO;
if (pp->cursectnum < 0)
return 0;
for (i = 0; i < MAX_MICRO; i++) for (i = 0; i < MAX_MICRO; i++)
{ {
if (ts < &TargetSort[TargetSortCount] && ts->sprite_num >= 0) if (ts < &TargetSort[TargetSortCount] && ts->sprite_num >= 0)
@ -17528,6 +17581,9 @@ DoDefaultStat(short SpriteNum)
int int
InitTracerUzi(PLAYERp pp) InitTracerUzi(PLAYERp pp)
{ {
if (pp->cursectnum < 0)
return 0;
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
SPRITEp wp, hsp; SPRITEp wp, hsp;
USERp wu; USERp wu;
@ -17546,6 +17602,7 @@ InitTracerUzi(PLAYERp pp)
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, 0, s_Tracer, pp->cursectnum, w = SpawnSprite(STAT_MISSILE, 0, s_Tracer, pp->cursectnum,
nx, ny, nz, pp->pang, TRACER_VELOCITY); nx, ny, nz, pp->pang, TRACER_VELOCITY);
@ -17843,17 +17900,18 @@ SWBOOL
HitscanSpriteAdjust(short SpriteNum, short hit_wall) HitscanSpriteAdjust(short SpriteNum, short hit_wall)
{ {
SPRITEp sp = &sprite[SpriteNum]; SPRITEp sp = &sprite[SpriteNum];
short w, nw, ang = sp->ang, wall_ang; int16_t ang;
int xvect,yvect; int xvect,yvect;
short sectnum; short sectnum;
#if 1 #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) 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); ang = sp->ang = NORM_ANGLE(wall_ang + 512);
}
else else
ang = sp->ang; ang = sp->ang;
#endif #endif
@ -18542,6 +18600,9 @@ InitTurretRail(short SpriteNum, PLAYERp pp)
if (SW_SHAREWARE) return FALSE; // JBF: verify if (SW_SHAREWARE) return FALSE; // JBF: verify
if (pp->cursectnum < 0)
return 0;
nx = sp->x; nx = sp->x;
ny = sp->y; ny = sp->y;
nz = sp->z; nz = sp->z;
@ -18598,6 +18659,8 @@ InitTurretLaser(short SpriteNum, PLAYERp pp)
if (SW_SHAREWARE) return FALSE; // JBF: verify if (SW_SHAREWARE) return FALSE; // JBF: verify
if (pp->cursectnum < 0)
return 0;
nx = sp->x; nx = sp->x;
ny = sp->y; ny = sp->y;
@ -19387,12 +19450,16 @@ InitGrenade(PLAYERp pp)
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, GRENADE, &s_Grenade[0][0], pp->cursectnum, w = SpawnSprite(STAT_MISSILE, GRENADE, &s_Grenade[0][0], pp->cursectnum,
nx, ny, nz, pp->pang, GRENADE_VELOCITY); 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); PlaySound(DIGI_MINETHROW, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan|v3df_doppler);
if (pp->cursectnum < 0)
return 0;
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, MINE, s_Mine, pp->cursectnum, w = SpawnSprite(STAT_MISSILE, MINE, s_Mine, pp->cursectnum,
nx, ny, nz, pp->pang, MINE_VELOCITY); nx, ny, nz, pp->pang, MINE_VELOCITY);
@ -19733,6 +19804,9 @@ InitFireball(PLAYERp pp)
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
if (pp->cursectnum < 0)
return 0;
nx += pp->posx; nx += pp->posx;
ny += pp->posy; ny += pp->posy;
@ -20638,13 +20712,13 @@ void QueueReset(void)
SWBOOL TestDontStick(short SpriteNum, short hit_sect, short hit_wall, int hit_z) SWBOOL TestDontStick(short SpriteNum, short hit_sect, short hit_wall, int hit_z)
{ {
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
WALLp wp; WALLp wp;
if (hit_wall < 0) if (hit_wall < 0)
{ {
ASSERT(SpriteNum>=0); ASSERT(SpriteNum>=0);
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
hit_wall = NORM_WALL(u->ret); hit_wall = NORM_WALL(u->ret);
} }