More cleanup. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5830 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-08-27 01:41:33 +00:00
parent 4575148c02
commit c6617a98b2
20 changed files with 1500 additions and 1476 deletions

View file

@ -1189,7 +1189,7 @@ FORCE_INLINE int32_t E_SpriteIsValid(const int32_t i)
return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS); return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS);
} }
int32_t clipshape_idx_for_sprite(uspritetype const * const curspr, int32_t curidx); int clipshape_idx_for_sprite(uspritetype const * const curspr, int curidx);
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z); void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z); void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z);

View file

@ -34,7 +34,7 @@ int32_t openfrompath(const char *fn, int32_t flags, int32_t mode);
BFILE *fopenfrompath(const char *fn, const char *mode); BFILE *fopenfrompath(const char *fn, const char *mode);
extern int32_t numgroupfiles; extern int32_t numgroupfiles;
int32_t initgroupfile(const char *filename); int initgroupfile(const char *filename);
void uninitgroupfile(void); void uninitgroupfile(void);
int32_t kopen4load(const char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group int32_t kopen4load(const char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group
int32_t kread(int32_t handle, void *buffer, int32_t leng); int32_t kread(int32_t handle, void *buffer, int32_t leng);

View file

@ -51,7 +51,6 @@ typedef struct
extern mapinfo_t origmapinfo, clipmapinfo; extern mapinfo_t origmapinfo, clipmapinfo;
extern void clipmapinfo_init(); extern void clipmapinfo_init();
extern int32_t quickloadboard; extern int32_t quickloadboard;
extern int16_t *sectq; extern int16_t *sectq;
@ -73,8 +72,8 @@ extern int16_t clipnum;
extern int32_t clipsectnum, origclipsectnum, clipspritenum; extern int32_t clipsectnum, origclipsectnum, clipspritenum;
extern int16_t clipsectorlist[MAXCLIPNUM], origclipsectorlist[MAXCLIPNUM]; extern int16_t clipsectorlist[MAXCLIPNUM], origclipsectorlist[MAXCLIPNUM];
int32_t clipinsidebox(vec2_t *vect, int16_t wallnum, int32_t walldist); int clipinsidebox(vec2_t *vect, int wallnum, int walldist);
int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t walldist); int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist);
extern int32_t clipmoveboxtracenum; extern int32_t clipmoveboxtracenum;

View file

@ -739,7 +739,7 @@ static void initgroupfile_crc32(int32_t handle)
Bfree(buf); Bfree(buf);
} }
int32_t initgroupfile(const char *filename) int initgroupfile(const char *filename)
{ {
char buf[70]; char buf[70];

View file

@ -504,14 +504,12 @@ int32_t clipmapinfo_load(void)
} }
int32_t clipshape_idx_for_sprite(uspritetype const * const curspr, int32_t curidx) int clipshape_idx_for_sprite(uspritetype const * const curspr, int curidx)
{ {
if (curidx < 0) // per-sprite init // per-sprite init
curidx = pictoidx[curspr->picnum]; curidx = (curidx < 0) ? pictoidx[curspr->picnum] : clipinfo[curidx].next;
else
curidx = clipinfo[curidx].next;
while (curidx>=0 && (curspr->cstat&32) != (sector[sectq[clipinfo[curidx].qbeg]].CM_CSTAT&32)) while (curidx >= 0 && (curspr->cstat & 32) != (sector[sectq[clipinfo[curidx].qbeg]].CM_CSTAT & 32))
curidx = clipinfo[curidx].next; curidx = clipinfo[curidx].next;
return curidx; return curidx;
@ -533,62 +531,64 @@ int32_t clipmoveboxtracenum = 3;
// //
// clipinsidebox // clipinsidebox
// //
int32_t clipinsidebox(vec2_t *vect, int16_t wallnum, int32_t walldist) int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
{ {
int32_t const r = walldist<<1; int const r = walldist << 1;
uwalltype const *wal = (uwalltype *) &wall[wallnum]; uwalltype const *wal = (uwalltype *)&wall[wallnum];
vec2_t const v1 ={ wal->x + walldist - vect->x, wal->y + walldist - vect->y }; vec2_t const v1 = { wal->x + walldist - vect->x, wal->y + walldist - vect->y };
wal = (uwalltype *) &wall[wal->point2]; wal = (uwalltype *)&wall[wal->point2];
vec2_t v2 ={ wal->x + walldist - vect->x, wal->y + walldist - vect->y }; vec2_t v2 = { wal->x + walldist - vect->x, wal->y + walldist - vect->y };
if (((v1.x < 0) && (v2.x < 0)) || ((v1.y < 0) && (v2.y < 0)) || if (((v1.x < 0) && (v2.x < 0)) || ((v1.y < 0) && (v2.y < 0)) || ((v1.x >= r) && (v2.x >= r)) || ((v1.y >= r) && (v2.y >= r)))
((v1.x >= r) && (v2.x >= r)) || ((v1.y >= r) && (v2.y >= r)))
return 0; return 0;
v2.x -= v1.x; v2.y -= v1.y; v2.x -= v1.x; v2.y -= v1.y;
if (v2.x*(walldist-v1.y) >= v2.y*(walldist-v1.x)) //Front if (v2.x * (walldist - v1.y) >= v2.y * (walldist - v1.x)) // Front
{ {
v2.x *= ((v2.x > 0) ? (0 - v1.y) : (r - v1.y)); v2.x *= ((v2.x > 0) ? (0 - v1.y) : (r - v1.y));
v2.y *= ((v2.y > 0) ? (r-v1.x) : (0-v1.x)); v2.y *= ((v2.y > 0) ? (r - v1.x) : (0 - v1.x));
return v2.x < v2.y; return v2.x < v2.y;
} }
v2.x *= ((v2.x > 0) ? (r-v1.y) : (0-v1.y)); v2.x *= ((v2.x > 0) ? (r - v1.y) : (0 - v1.y));
v2.y *= ((v2.y > 0) ? (0-v1.x) : (r-v1.x)); v2.y *= ((v2.y > 0) ? (0 - v1.x) : (r - v1.x));
return (v2.x >= v2.y)<<1; return (v2.x >= v2.y) << 1;
} }
// //
// clipinsideboxline // clipinsideboxline
// //
int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t walldist) int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist)
{ {
int32_t const r = walldist<<1; int const r = walldist << 1;
x1 += walldist-x; x2 += walldist-x; x1 += walldist - x;
x2 += walldist - x;
if (((x1 < 0) && (x2 < 0)) || ((x1 >= r) && (x2 >= r))) if (((x1 < 0) && (x2 < 0)) || ((x1 >= r) && (x2 >= r)))
return 0; return 0;
y1 += walldist-y; y2 += walldist-y; y1 += walldist - y;
y2 += walldist - y;
if (((y1 < 0) && (y2 < 0)) || ((y1 >= r) && (y2 >= r))) if (((y1 < 0) && (y2 < 0)) || ((y1 >= r) && (y2 >= r)))
return 0; return 0;
x2 -= x1; y2 -= y1; x2 -= x1;
y2 -= y1;
if (x2*(walldist-y1) >= y2*(walldist-x1)) //Front if (x2 * (walldist - y1) >= y2 * (walldist - x1)) // Front
{ {
x2 *= ((x2 > 0) ? (0-y1) : (r-y1)); x2 *= ((x2 > 0) ? (0 - y1) : (r - y1));
y2 *= ((y2 > 0) ? (r-x1) : (0-x1)); y2 *= ((y2 > 0) ? (r - x1) : (0 - x1));
return x2 < y2; return x2 < y2;
} }
x2 *= ((x2 > 0) ? (r-y1) : (0-y1)); x2 *= ((x2 > 0) ? (r - y1) : (0 - y1));
y2 *= ((y2 > 0) ? (0-x1) : (r-x1)); y2 *= ((y2 > 0) ? (0 - x1) : (r - x1));
return (x2 >= y2)<<1; return (x2 >= y2) << 1;
} }

View file

@ -442,7 +442,7 @@ static int32_t E_ReadArtFileOfID(int32_t tilefilei)
if (faketile[i>>3] & pow2char[i&7] || walock[i] >= 200) if (faketile[i>>3] & pow2char[i&7] || walock[i] >= 200)
{ {
initprintf("loadpics: per-map ART file \"%s\": " initprintf("loadpics: per-map ART file \"%s\": "
"tile %d has dummytile or is locked\n", fn, i); "tile %zd has dummytile or is locked\n", fn, i);
kclose(fil); kclose(fil);
return -3; return -3;
} }

File diff suppressed because it is too large Load diff

View file

@ -8082,10 +8082,10 @@ static void G_CheckCommandLine(int32_t argc, char const * const * argv)
{ {
if (argc > i+1) if (argc > i+1)
{ {
g_usingAddon = Batoi(argv[i+1]); g_addonNum = Batoi(argv[i+1]);
if (!(g_usingAddon > ADDON_NONE && g_usingAddon < NUMADDONS)) if (!(g_addonNum > ADDON_NONE && g_addonNum < NUMADDONS))
g_usingAddon = ADDON_NONE; g_addonNum = ADDON_NONE;
COPYARG(i); COPYARG(i);
COPYARG(i+1); COPYARG(i+1);
@ -8295,7 +8295,7 @@ static void G_CheckCommandLine(int32_t argc, char const * const * argv)
} }
if (!Bstrcasecmp(c+1,"usecwd")) if (!Bstrcasecmp(c+1,"usecwd"))
{ {
usecwd = 1; g_useCwd = 1;
COPYARG(i); COPYARG(i);
i++; i++;
continue; continue;
@ -9945,7 +9945,7 @@ int32_t ExtInit(void)
set_memerr_handler(&M32_HandleMemErr); set_memerr_handler(&M32_HandleMemErr);
if (!usecwd) if (!g_useCwd)
G_AddSearchPaths(); G_AddSearchPaths();
G_ExtInit(); G_ExtInit();
@ -9999,7 +9999,7 @@ int32_t ExtPostStartupWindow(void)
{ {
G_LoadGroups(!NoAutoLoad); G_LoadGroups(!NoAutoLoad);
if (!usecwd) if (!g_useCwd)
G_CleanupSearchPaths(); G_CleanupSearchPaths();
if (initengine()) if (initengine())

View file

@ -261,9 +261,11 @@ void G_DoCheats(void)
if (pPlayer->cheat_phase == 1) if (pPlayer->cheat_phase == 1)
{ {
int ch;
while (KB_KeyWaiting()) while (KB_KeyWaiting())
{ {
int const ch = Btolower(KB_GetCh()); ch = Btolower(KB_GetCh());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{ {

View file

@ -229,11 +229,11 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
{ {
if (argc > i+1) if (argc > i+1)
{ {
g_usingAddon = Batoi(argv[i+1]); g_addonNum = Batoi(argv[i+1]);
if (g_usingAddon > ADDON_NONE && g_usingAddon < NUMADDONS) if (g_addonNum > ADDON_NONE && g_addonNum < NUMADDONS)
g_noSetup = 1; g_noSetup = 1;
else g_usingAddon = ADDON_NONE; else g_addonNum = ADDON_NONE;
i++; i++;
} }
@ -512,7 +512,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
} }
if (!Bstrcasecmp(c+1, "usecwd")) if (!Bstrcasecmp(c+1, "usecwd"))
{ {
usecwd = 1; g_useCwd = 1;
i++; i++;
continue; continue;
} }

View file

@ -26,8 +26,7 @@
struct grpfile_t const *g_selectedGrp; struct grpfile_t const *g_selectedGrp;
int32_t g_gameType = GAMEFLAG_DUKE; int32_t g_gameType = GAMEFLAG_DUKE;
int g_addonNum = 0;
int32_t g_usingAddon = 0;
// g_gameNamePtr can point to one of: grpfiles[].name (string literal), string // g_gameNamePtr can point to one of: grpfiles[].name (string literal), string
// literal, malloc'd block (XXX: possible leak) // literal, malloc'd block (XXX: possible leak)
@ -125,81 +124,72 @@ const char *G_DefaultConFile(void)
const char *G_GrpFile(void) const char *G_GrpFile(void)
{ {
if (g_grpNamePtr == NULL) return (g_grpNamePtr == NULL) ? G_DefaultGrpFile() : g_grpNamePtr;
return G_DefaultGrpFile();
else
return g_grpNamePtr;
} }
const char *G_DefFile(void) const char *G_DefFile(void)
{ {
if (g_defNamePtr == NULL) return (g_defNamePtr == NULL) ? G_DefaultDefFile() : g_defNamePtr;
return G_DefaultDefFile();
else
return g_defNamePtr;
} }
const char *G_ConFile(void) const char *G_ConFile(void)
{ {
if (g_scriptNamePtr == NULL) return (g_scriptNamePtr == NULL) ? G_DefaultConFile() : g_scriptNamePtr;
return G_DefaultConFile();
else
return g_scriptNamePtr;
} }
////////// //////////
// Set up new-style multi-psky handling. // Set up new-style multi-psky handling.
void G_InitMultiPsky(int32_t const CLOUDYOCEAN__DYN, int32_t const MOONSKY1__DYN, int32_t const BIGORBIT1__DYN, int32_t const LA__DYN) void G_InitMultiPsky(int CLOUDYOCEAN__DYN, int MOONSKY1__DYN, int BIGORBIT1__DYN, int LA__DYN)
{ {
// When adding other multi-skies, take care that the tileofs[] values are // When adding other multi-skies, take care that the tileofs[] values are
// <= PSKYOFF_MAX. (It can be increased up to MAXPSKYTILES, but should be // <= PSKYOFF_MAX. (It can be increased up to MAXPSKYTILES, but should be
// set as tight as possible.) // set as tight as possible.)
// The default sky properties (all others are implicitly zero): // The default sky properties (all others are implicitly zero):
psky_t * const defaultsky = E_DefinePsky(DEFAULTPSKY); psky_t *sky = E_DefinePsky(DEFAULTPSKY);
defaultsky->lognumtiles = 3; sky->lognumtiles = 3;
defaultsky->horizfrac = 32768; sky->horizfrac = 32768;
// CLOUDYOCEAN // CLOUDYOCEAN
// Aligns with the drawn scene horizon because it has one itself. // Aligns with the drawn scene horizon because it has one itself.
psky_t * const oceansky = E_DefinePsky(CLOUDYOCEAN__DYN); sky = E_DefinePsky(CLOUDYOCEAN__DYN);
oceansky->lognumtiles = 3; sky->lognumtiles = 3;
oceansky->horizfrac = 65536; sky->horizfrac = 65536;
// MOONSKY1 // MOONSKY1
// earth mountain mountain sun // earth mountain mountain sun
psky_t * const moonsky = E_DefinePsky(MOONSKY1__DYN); sky = E_DefinePsky(MOONSKY1__DYN);
moonsky->lognumtiles = 3; sky->lognumtiles = 3;
moonsky->horizfrac = 32768; sky->horizfrac = 32768;
moonsky->tileofs[6] = 1; sky->tileofs[6] = 1;
moonsky->tileofs[1] = 2; sky->tileofs[1] = 2;
moonsky->tileofs[4] = 2; sky->tileofs[4] = 2;
moonsky->tileofs[2] = 3; sky->tileofs[2] = 3;
// BIGORBIT1 // orbit // BIGORBIT1 // orbit
// earth1 2 3 moon/sun // earth1 2 3 moon/sun
psky_t * const spacesky = E_DefinePsky(BIGORBIT1__DYN); sky = E_DefinePsky(BIGORBIT1__DYN);
spacesky->lognumtiles = 3; sky->lognumtiles = 3;
spacesky->horizfrac = 32768; sky->horizfrac = 32768;
spacesky->tileofs[5] = 1; sky->tileofs[5] = 1;
spacesky->tileofs[6] = 2; sky->tileofs[6] = 2;
spacesky->tileofs[7] = 3; sky->tileofs[7] = 3;
spacesky->tileofs[2] = 4; sky->tileofs[2] = 4;
// LA // la city // LA // la city
// earth1 2 3 moon/sun // earth1 2 3 moon/sun
psky_t * const citysky = E_DefinePsky(LA__DYN); sky = E_DefinePsky(LA__DYN);
citysky->lognumtiles = 3; sky->lognumtiles = 3;
citysky->horizfrac = 16384+1024; sky->horizfrac = 16384 + 1024;
citysky->tileofs[0] = 1; sky->tileofs[0] = 1;
citysky->tileofs[1] = 2; sky->tileofs[1] = 2;
citysky->tileofs[2] = 1; sky->tileofs[2] = 1;
citysky->tileofs[3] = 3; sky->tileofs[3] = 3;
citysky->tileofs[4] = 4; sky->tileofs[4] = 4;
citysky->tileofs[5] = 0; sky->tileofs[5] = 0;
citysky->tileofs[6] = 2; sky->tileofs[6] = 2;
citysky->tileofs[7] = 3; sky->tileofs[7] = 3;
#if 0 #if 0
// This assertion should hold. See note above. // This assertion should hold. See note above.
@ -211,21 +201,21 @@ void G_InitMultiPsky(int32_t const CLOUDYOCEAN__DYN, int32_t const MOONSKY1__DYN
void G_SetupGlobalPsky(void) void G_SetupGlobalPsky(void)
{ {
int32_t i, mskyidx=0; int skyIdx = 0;
// NOTE: Loop must be running backwards for the same behavior as the game // NOTE: Loop must be running backwards for the same behavior as the game
// (greatest sector index with matching parallaxed sky takes precedence). // (greatest sector index with matching parallaxed sky takes precedence).
for (i=numsectors-1; i>=0; i--) for (bssize_t i = numsectors - 1; i >= 0; i--)
{ {
if (sector[i].ceilingstat & 1) if (sector[i].ceilingstat & 1)
{ {
mskyidx = getpskyidx(sector[i].ceilingpicnum); skyIdx = getpskyidx(sector[i].ceilingpicnum);
if (mskyidx > 0) if (skyIdx > 0)
break; break;
} }
} }
g_pskyidx = mskyidx; g_pskyidx = skyIdx;
} }
////////// //////////
@ -233,31 +223,27 @@ void G_SetupGlobalPsky(void)
static char g_rootDir[BMAX_PATH]; static char g_rootDir[BMAX_PATH];
char g_modDir[BMAX_PATH] = "/"; char g_modDir[BMAX_PATH] = "/";
int32_t kopen4loadfrommod(const char *filename, char searchfirst) int kopen4loadfrommod(const char *fileName, char searchfirst)
{ {
int32_t r=-1; int kFile = -1;
if (g_modDir[0]!='/' || g_modDir[1]!=0) if (g_modDir[0] != '/' || g_modDir[1] != 0)
{ {
static char fn[BMAX_PATH]; static char staticFileName[BMAX_PATH];
Bsnprintf(staticFileName, sizeof(staticFileName), "%s/%s", g_modDir, fileName);
Bsnprintf(fn, sizeof(fn), "%s/%s",g_modDir,filename); kFile = kopen4load(staticFileName, searchfirst);
r = kopen4load(fn,searchfirst);
} }
if (r < 0) return (kFile < 0) ? kopen4load(fileName, searchfirst) : kFile;
r = kopen4load(filename,searchfirst);
return r;
} }
int32_t usecwd; int g_useCwd;
static void G_LoadAddon(void); static void G_LoadAddon(void);
int32_t g_groupFileHandle; int32_t g_groupFileHandle;
void G_ExtPreInit(int32_t argc,char const * const * argv) void G_ExtPreInit(int32_t argc,char const * const * argv)
{ {
usecwd = G_CheckCmdSwitch(argc, argv, "-usecwd"); g_useCwd = G_CheckCmdSwitch(argc, argv, "-usecwd");
#ifdef _WIN32 #ifdef _WIN32
GetModuleFileName(NULL,g_rootDir,BMAX_PATH); GetModuleFileName(NULL,g_rootDir,BMAX_PATH);
@ -305,7 +291,7 @@ void G_ExtInit(void)
#if defined(_WIN32) #if defined(_WIN32)
if (!access("user_profiles_enabled", F_OK)) if (!access("user_profiles_enabled", F_OK))
#else #else
if (usecwd == 0 && access("user_profiles_disabled", F_OK)) if (g_useCwd == 0 && access("user_profiles_disabled", F_OK))
#endif #endif
{ {
char *homedir; char *homedir;
@ -420,7 +406,7 @@ void G_LoadGroups(int32_t autoload)
#endif #endif
} }
if (g_usingAddon) if (g_addonNum)
G_LoadAddon(); G_LoadAddon();
const char *grpfile; const char *grpfile;
@ -524,7 +510,7 @@ static void G_LoadAddon(void)
{ {
int32_t crc = 0; // compiler-happy int32_t crc = 0; // compiler-happy
switch (g_usingAddon) switch (g_addonNum)
{ {
case ADDON_DUKEDC: case ADDON_DUKEDC:
crc = DUKEDC_CRC; crc = DUKEDC_CRC;

View file

@ -13,7 +13,7 @@
extern "C" { extern "C" {
#endif #endif
extern int32_t usecwd; extern int g_useCwd;
#define GAMEFLAG_DUKE 0x00000001 #define GAMEFLAG_DUKE 0x00000001
#define GAMEFLAG_NAM 0x00000002 #define GAMEFLAG_NAM 0x00000002
@ -27,8 +27,7 @@ extern int32_t usecwd;
extern struct grpfile_t const *g_selectedGrp; extern struct grpfile_t const *g_selectedGrp;
extern int32_t g_gameType; extern int32_t g_gameType;
extern int g_addonNum;
extern int32_t g_usingAddon;
#define DUKE (g_gameType & GAMEFLAG_DUKE) #define DUKE (g_gameType & GAMEFLAG_DUKE)
#define NAM (g_gameType & GAMEFLAG_NAM) #define NAM (g_gameType & GAMEFLAG_NAM)
@ -99,13 +98,13 @@ extern int32_t g_groupFileHandle;
////////// //////////
extern void G_InitMultiPsky(int32_t CLOUDYOCEAN__DYN, int32_t MOONSKY1__DYN, int32_t BIGORBIT1__DYN, int32_t LA__DYN); extern void G_InitMultiPsky(int CLOUDYOCEAN__DYN, int MOONSKY1__DYN, int BIGORBIT1__DYN, int LA__DYN);
extern void G_SetupGlobalPsky(void); extern void G_SetupGlobalPsky(void);
////////// //////////
extern char g_modDir[BMAX_PATH]; extern char g_modDir[BMAX_PATH];
extern int32_t kopen4loadfrommod(const char *filename, char searchfirst); extern int kopen4loadfrommod(const char *filename, char searchfirst);
extern void G_AddSearchPaths(void); extern void G_AddSearchPaths(void);
extern void G_CleanupSearchPaths(void); extern void G_CleanupSearchPaths(void);

View file

@ -585,7 +585,7 @@ int32_t CONFIG_ReadSetup(void)
} }
// #endif // #endif
if (g_grpNamePtr == NULL && g_usingAddon == 0) if (g_grpNamePtr == NULL && g_addonNum == 0)
{ {
SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr); SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr);
if (g_grpNamePtr && !Bstrlen(g_grpNamePtr)) if (g_grpNamePtr && !Bstrlen(g_grpNamePtr))
@ -712,7 +712,7 @@ void CONFIG_WriteSetup(uint32_t flags)
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,FALSE,FALSE); // JBF 20031206 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,FALSE,FALSE); // JBF 20031206
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,FALSE,FALSE); // JBF 20031206 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,FALSE,FALSE); // JBF 20031206
if (g_grpNamePtr && !g_usingAddon) if (g_grpNamePtr && !g_addonNum)
SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",g_grpNamePtr); SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",g_grpNamePtr);
// XXX: should be "if compiled without startup GUI" // XXX: should be "if compiled without startup GUI"

View file

@ -6069,7 +6069,7 @@ int app_main(int argc, char const * const * argv)
OSD_SetParameters(0,0, 0,12, 2,12); OSD_SetParameters(0,0, 0,12, 2,12);
#ifdef __APPLE__ #ifdef __APPLE__
if (!usecwd) if (!g_useCwd)
{ {
char cwd[BMAX_PATH]; char cwd[BMAX_PATH];
char *homedir = Bgethomedir(); char *homedir = Bgethomedir();
@ -6098,7 +6098,7 @@ int app_main(int argc, char const * const * argv)
initprintf(HEAD2 " %s %s\n", s_buildRev, s_buildInfo); initprintf(HEAD2 " %s %s\n", s_buildRev, s_buildInfo);
initprintf("Compiled %s\n", s_buildTimestamp); initprintf("Compiled %s\n", s_buildTimestamp);
if (!usecwd) if (!g_useCwd)
G_AddSearchPaths(); G_AddSearchPaths();
g_numSkills = 4; g_numSkills = 4;
@ -6203,7 +6203,7 @@ int app_main(int argc, char const * const * argv)
G_SetupCheats(); G_SetupCheats();
if (!usecwd) if (!g_useCwd)
G_CleanupSearchPaths(); G_CleanupSearchPaths();
if (SHAREWARE) if (SHAREWARE)
@ -6289,8 +6289,8 @@ int app_main(int argc, char const * const * argv)
loaddefinitions_game(defsfile, FALSE); loaddefinitions_game(defsfile, FALSE);
} }
for (bssize_t i=0; i < g_defModulesNum; ++i) for (bssize_t i = 0; i < g_defModulesNum; ++i) Bfree(g_defModules[i]);
Bfree(g_defModules[i]);
DO_FREE_AND_NULL(g_defModules); DO_FREE_AND_NULL(g_defModules);
g_defModulesNum = 0; g_defModulesNum = 0;
@ -6389,7 +6389,8 @@ int app_main(int argc, char const * const * argv)
system_getcvars(); system_getcvars();
char *ptr = Xstrdup(setupfilename), *p = strtok(ptr, "."); char *const setupFileName = Xstrdup(setupfilename);
char *const p = strtok(setupFileName, ".");
if (!Bstrcmp(setupfilename, SETUPFILENAME)) if (!Bstrcmp(setupfilename, SETUPFILENAME))
Bsprintf(tempbuf, "settings.cfg"); Bsprintf(tempbuf, "settings.cfg");
@ -6397,40 +6398,44 @@ int app_main(int argc, char const * const * argv)
Bsprintf(tempbuf, "%s_settings.cfg", p); Bsprintf(tempbuf, "%s_settings.cfg", p);
OSD_Exec(tempbuf); OSD_Exec(tempbuf);
Bfree(ptr); Bfree(setupFileName);
if (g_networkMode != NET_DEDICATED_SERVER) if (g_networkMode != NET_DEDICATED_SERVER)
{ {
if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0) if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0)
{ {
int32_t i = 0; vec2_t const res[] = {
int32_t j = 0; { ud.config.ScreenWidth, ud.config.ScreenHeight }, { 800, 600 }, { 640, 480 }, { 320, 240 },
int32_t xres[] = {ud.config.ScreenWidth,800,640,320}; };
int32_t yres[] = {ud.config.ScreenHeight,600,480,240};
#ifdef USE_OPENGL #ifdef USE_OPENGL
int32_t bpp[] = {32,16,8}; int const bpp[] = { 32, 16, 8 };
#else #else
int32_t bpp[] = {8}; int const bpp[] = { 8 };
#endif #endif
initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", ud.config.ScreenWidth, ud.config.ScreenHeight,
ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.config.ScreenMode?"fullscreen":"windowed"); ud.config.ScreenBPP, ud.config.ScreenMode ? "fullscreen" : "windowed");
while (setgamemode(0,xres[i],yres[i],bpp[j]) < 0) int resIdx = 0;
{ int bppIdx = 0;
initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],bpp[j]);
if (++j == ARRAY_SIZE(bpp)) while (setgamemode(0, res[resIdx].x, res[resIdx].y, bpp[bppIdx]) < 0)
{ {
if (++i == ARRAY_SIZE(xres)) initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n", res[resIdx].x, res[resIdx].y,
bpp[bppIdx]);
if (++bppIdx == ARRAY_SIZE(bpp))
{
if (++resIdx == ARRAY_SIZE(res))
G_GameExit("Unable to set failsafe video mode!"); G_GameExit("Unable to set failsafe video mode!");
j = 0; bppIdx = 0;
} }
} }
ud.config.ScreenWidth = xres[i]; ud.config.ScreenWidth = res[resIdx].x;
ud.config.ScreenHeight = yres[i]; ud.config.ScreenHeight = res[resIdx].y;
ud.config.ScreenBPP = bpp[j]; ud.config.ScreenBPP = bpp[bppIdx];
} }
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
@ -6540,7 +6545,7 @@ MAIN_LOOP_RESTART:
do //main loop do //main loop
{ {
static uint32_t nextRender = 0, frameWaiting = 0; static uint32_t nextRender = 0, frameWaiting = 0;
uint32_t j; uint32_t frameTime;
if (handleevents() && quitevent) if (handleevents() && quitevent)
{ {
@ -6552,7 +6557,7 @@ MAIN_LOOP_RESTART:
Net_GetPackets(); Net_GetPackets();
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
CONTROL_BindsEnabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO); CONTROL_BindsEnabled = !!(g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO));
#ifndef _WIN32 #ifndef _WIN32
// stdin -> OSD input for dedicated server // stdin -> OSD input for dedicated server
@ -6614,7 +6619,7 @@ MAIN_LOOP_RESTART:
ototalclock += TICSPERFRAME; ototalclock += TICSPERFRAME;
int const prevClock = totalclock; int const moveClock = totalclock;
if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) &&
(g_player[myconnectindex].ps->gm&MODE_GAME)) (g_player[myconnectindex].ps->gm&MODE_GAME))
@ -6630,7 +6635,7 @@ MAIN_LOOP_RESTART:
sampletimer(); sampletimer();
if (totalclock - prevClock >= TICSPERFRAME) if (totalclock - moveClock >= TICSPERFRAME)
{ {
// computing a tic takes longer than a tic, so we're slowing // computing a tic takes longer than a tic, so we're slowing
// the game down. rather than tightly spinning here, go draw // the game down. rather than tightly spinning here, go draw
@ -6664,12 +6669,12 @@ MAIN_LOOP_RESTART:
nextpage(); nextpage();
} }
j = getticks(); frameTime = getticks();
if (r_maxfps == 0 || j >= nextRender) if (r_maxfps == 0 || frameTime >= nextRender)
{ {
if (j > nextRender + g_frameDelay) if (frameTime > nextRender + g_frameDelay)
nextRender = j; nextRender = frameTime;
nextRender += g_frameDelay; nextRender += g_frameDelay;
@ -6698,7 +6703,7 @@ skipframe:
return 0; // not reached (duh) return 0; // not reached (duh)
} }
GAME_STATIC GAME_INLINE int32_t G_MoveLoop() GAME_STATIC GAME_INLINE int G_MoveLoop()
{ {
Net_GetPackets(); Net_GetPackets();
@ -6868,7 +6873,7 @@ int G_DoMoveThings(void)
return 0; return 0;
} }
void A_SpawnWallGlass(int spriteNum,int wallNum,int glassCnt) void A_SpawnWallGlass(int spriteNum, int wallNum, int glassCnt)
{ {
if (wallNum < 0) if (wallNum < 0)
{ {
@ -6881,113 +6886,102 @@ void A_SpawnWallGlass(int spriteNum,int wallNum,int glassCnt)
return; return;
} }
int32_t j, xv, yv, z, x1, y1; vec2_t v1 = { wall[wallNum].x, wall[wallNum].y };
int32_t a; vec2_t v = { wall[wall[wallNum].point2].x - v1.x, wall[wall[wallNum].point2].y - v1.y };
j = glassCnt+1; v1.x -= ksgn(v.y);
v1.y += ksgn(v.x);
x1 = wall[wallNum].x; v.x = tabledivide32_noinline(v.x, glassCnt+1);
y1 = wall[wallNum].y; v.y = tabledivide32_noinline(v.y, glassCnt+1);
xv = wall[wall[wallNum].point2].x-x1;
yv = wall[wall[wallNum].point2].y-y1;
x1 -= ksgn(yv);
y1 += ksgn(xv);
xv = tabledivide32_noinline(xv, j);
yv = tabledivide32_noinline(yv, j);
int16_t sect = -1; int16_t sect = -1;
for (j=glassCnt; j>0; j--) for (bsize_t j = glassCnt; j > 0; --j)
{ {
x1 += xv; v1.x += v.x;
y1 += yv; v1.y += v.y;
updatesector(x1,y1,&sect); updatesector(v1.x,v1.y,&sect);
if (sect >= 0) if (sect >= 0)
{ {
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz))); int z = sector[sect].floorz - (krand() & (klabs(sector[sect].ceilingz - sector[sect].floorz)));
if (z < -ZOFFSET5 || z > ZOFFSET5) if (z < -ZOFFSET5 || z > ZOFFSET5)
z = SZ(spriteNum)-ZOFFSET5+(krand()&((64<<8)-1)); z = SZ(spriteNum) - ZOFFSET5 + (krand() & ((64 << 8) - 1));
a = SA(spriteNum)-1024;
A_InsertSprite(SECT(spriteNum),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),spriteNum,5); A_InsertSprite(SECT(spriteNum), v1.x, v1.y, z, GLASSPIECES + (j % 3), -32, 36, 36, SA(spriteNum) - 1024, 32 + (krand() & 63),
-(krand() & 1023), spriteNum, 5);
} }
} }
} }
void A_SpawnGlass(int32_t i,int32_t n) void A_SpawnGlass(int spriteNum, int glassCnt)
{ {
for (; n>0; n--) for (; glassCnt>0; glassCnt--)
{ {
int32_t k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-((krand()&16)<<8),GLASSPIECES+(n%3), int const k
krand()&15,36,36,krand()&2047,32+(krand()&63),-512-(krand()&2047),i,5); = A_InsertSprite(SECT(spriteNum), SX(spriteNum), SY(spriteNum), SZ(spriteNum) - ((krand() & 16) << 8), GLASSPIECES + (glassCnt % 3),
sprite[k].pal = sprite[i].pal; krand() & 15, 36, 36, krand() & 2047, 32 + (krand() & 63), -512 - (krand() & 2047), spriteNum, 5);
sprite[k].pal = sprite[spriteNum].pal;
} }
} }
void A_SpawnCeilingGlass(int32_t i,int32_t sectnum,int32_t n) void A_SpawnCeilingGlass(int spriteNum, int sectNum, int glassCnt)
{ {
int32_t j, xv, yv, z, x1, y1, a,s; int const startWall = sector[sectNum].wallptr;
int32_t startwall = sector[sectnum].wallptr; int const endWall = startWall+sector[sectNum].wallnum;
int32_t endwall = startwall+sector[sectnum].wallnum;
for (s=startwall; s<(endwall-1); s++) for (bssize_t wallNum = startWall; wallNum < (endWall - 1); wallNum++)
{ {
x1 = wall[s].x; vec2_t v1 = { wall[wallNum].x, wall[wallNum].y };
y1 = wall[s].y; vec2_t v = { tabledivide32_noinline(wall[wallNum + 1].x - v1.x, glassCnt + 1),
tabledivide32_noinline(wall[wallNum + 1].y - v1.y, glassCnt + 1) };
xv = tabledivide32_noinline(wall[s+1].x-x1, n+1); for (bsize_t j = glassCnt; j > 0; j--)
yv = tabledivide32_noinline(wall[s+1].y-y1, n+1);
for (j=n; j>0; j--)
{ {
x1 += xv; v1.x += v.x;
y1 += yv; v1.y += v.y;
a = krand()&2047; A_InsertSprite(sectNum, v1.x, v1.y, sector[sectNum].ceilingz + ((krand() & 15) << 8), GLASSPIECES + (j % 3), -32, 36, 36,
z = sector[sectnum].ceilingz+((krand()&15)<<8); krand() & 2047, (krand() & 31), 0, spriteNum, 5);
A_InsertSprite(sectnum,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,(krand()&31),0,i,5);
} }
} }
} }
void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n) void A_SpawnRandomGlass(int spriteNum, int wallNum, int glassCnt)
{ {
int32_t j, xv, yv, z, x1, y1; if (wallNum < 0)
int16_t sect = -1;
int32_t a, k;
if (wallnum < 0)
{ {
for (j=n-1; j >= 0 ; j--) for (bssize_t j = glassCnt - 1; j >= 0; j--)
{ {
a = krand()&2047; int const k
k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5); = A_InsertSprite(SECT(spriteNum), SX(spriteNum), SY(spriteNum), SZ(spriteNum) - (krand() & (63 << 8)), GLASSPIECES + (j % 3),
sprite[k].pal = krand()&15; -32, 36, 36, krand() & 2047, 32 + (krand() & 63), 1024 - (krand() & 2047), spriteNum, 5);
sprite[k].pal = krand() & 15;
} }
return; return;
} }
j = n+1; vec2_t v1 = { wall[wallNum].x, wall[wallNum].y };
x1 = wall[wallnum].x; vec2_t v = { tabledivide32_noinline(wall[wall[wallNum].point2].x - wall[wallNum].x, glassCnt + 1),
y1 = wall[wallnum].y; tabledivide32_noinline(wall[wall[wallNum].point2].y - wall[wallNum].y, glassCnt + 1) };
int16_t sectNum = sprite[spriteNum].sectnum;
xv = tabledivide32_noinline(wall[wall[wallnum].point2].x-wall[wallnum].x, j); for (bsize_t j = glassCnt; j > 0; j--)
yv = tabledivide32_noinline(wall[wall[wallnum].point2].y-wall[wallnum].y, j);
for (j=n; j>0; j--)
{ {
x1 += xv; v1.x += v.x;
y1 += yv; v1.y += v.y;
updatesector(v1.x, v1.y, &sectNum);
int z = sector[sectNum].floorz - (krand() & (klabs(sector[sectNum].ceilingz - sector[sectNum].floorz)));
updatesector(x1,y1,&sect);
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz)));
if (z < -ZOFFSET5 || z > ZOFFSET5) if (z < -ZOFFSET5 || z > ZOFFSET5)
z = SZ(i)-ZOFFSET5+(krand()&((64<<8)-1)); z = SZ(spriteNum) - ZOFFSET5 + (krand() & ((64 << 8) - 1));
a = SA(i)-1024;
k = A_InsertSprite(SECT(i),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5); int const k = A_InsertSprite(SECT(spriteNum), v1.x, v1.y, z, GLASSPIECES + (j % 3), -32, 36, 36, SA(spriteNum) - 1024,
sprite[k].pal = krand()&7; 32 + (krand() & 63), -(krand() & 2047), spriteNum, 5);
sprite[k].pal = krand() & 7;
} }
} }

View file

@ -306,9 +306,9 @@ void El_CreateGameState(void);
#endif #endif
void G_PostCreateGameState(void); void G_PostCreateGameState(void);
void A_SpawnCeilingGlass(int32_t i,int32_t sectnum,int32_t n); void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt);
void A_SpawnGlass(int32_t i,int32_t n); void A_SpawnGlass(int spriteNum,int glassCnt);
void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n); void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt);
void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n); void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n);
void G_AddUserQuote(const char *daquote); void G_AddUserQuote(const char *daquote);
void G_BackToMenu(void); void G_BackToMenu(void);

View file

@ -2483,18 +2483,18 @@ nullquote:
case CON_DRAGPOINT: case CON_DRAGPOINT:
insptr++; insptr++;
{ {
int const nWall = Gv_GetVarX(*insptr++); int const wallNum = Gv_GetVarX(*insptr++);
vec2_t n; vec2_t n;
Gv_GetManyVars(2, (int32_t *)&n); Gv_GetManyVars(2, (int32_t *)&n);
if (EDUKE32_PREDICT_FALSE((unsigned)nWall >= (unsigned)numwalls)) if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{ {
CON_ERRPRINTF("Invalid wall %d\n", nWall); CON_ERRPRINTF("Invalid wall %d\n", wallNum);
continue; continue;
} }
dragpoint(nWall, n.x, n.y, 0); dragpoint(wallNum, n.x, n.y, 0);
continue; continue;
} }
@ -2595,7 +2595,7 @@ nullquote:
case CON_QSPAWNVAR: case CON_QSPAWNVAR:
insptr++; insptr++;
{ {
int const nPicnum = Gv_GetVarX(*insptr++); int const tileNum = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{ {
@ -2603,7 +2603,7 @@ nullquote:
continue; continue;
} }
int const spriteNum = A_Spawn(vm.spriteNum, nPicnum); int const spriteNum = A_Spawn(vm.spriteNum, tileNum);
switch (tw) switch (tw)
{ {
@ -5772,10 +5772,10 @@ void A_LoadActor(int32_t spriteNum)
#endif #endif
// NORECURSE // NORECURSE
void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist) void A_Execute(int spriteNum, int playerNum, int32_t playerDist)
{ {
vmstate_t tempvm = { vmstate_t tempvm = {
spriteNum, playerNum, lDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps
}; };
vm = tempvm; vm = tempvm;
@ -5842,7 +5842,7 @@ void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist)
{ {
double t = gethiticks(); double t = gethiticks();
killit = (El_CallActor(&g_ElState, picnum, spriteNum, playerNum, lDist)==1); killit = (El_CallActor(&g_ElState, picnum, spriteNum, playerNum, playerDist)==1);
t = gethiticks()-t; t = gethiticks()-t;
g_actorTotalMs[picnum] += t; g_actorTotalMs[picnum] += t;

View file

@ -47,7 +47,7 @@ extern int32_t g_currentEventExec;
void A_LoadActor(int32_t spriteNum); void A_LoadActor(int32_t spriteNum);
#endif #endif
void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist); void A_Execute(int spriteNum, int playerNum, int32_t playerDist);
void A_Fall(int spriteNum); void A_Fall(int spriteNum);
int32_t A_FurthestVisiblePoint(int32_t spriteNum,uspritetype * const ts,int32_t *dax,int32_t *day); int32_t A_FurthestVisiblePoint(int32_t spriteNum,uspritetype * const ts,int32_t *dax,int32_t *day);
int32_t A_GetFurthestAngle(int spriteNum,int angDiv); int32_t A_GetFurthestAngle(int spriteNum,int angDiv);

View file

@ -1736,50 +1736,52 @@ void Gv_InitWeaponPointers(void)
for (bssize_t i=(MAX_WEAPONS-1); i>=0; i--) for (bssize_t i=(MAX_WEAPONS-1); i>=0; i--)
{ {
Bsprintf(aszBuf,"WEAPON%zd_CLIP",i); Bsprintf(aszBuf, "WEAPON%zd_CLIP", i);
aplWeaponClip[i]=Gv_GetVarDataPtr(aszBuf); aplWeaponClip[i] = Gv_GetVarDataPtr(aszBuf);
if (!aplWeaponClip[i]) if (!aplWeaponClip[i])
{ {
initprintf("ERROR: NULL weapon! WTF?!\n"); initprintf("ERROR: NULL weapon! WTF?! %s\n", aszBuf);
// Bexit(0); // Bexit(0);
G_Shutdown(); G_Shutdown();
} }
Bsprintf(aszBuf,"WEAPON%zd_RELOAD",i);
aplWeaponReload[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_RELOAD", i);
Bsprintf(aszBuf,"WEAPON%zd_FIREDELAY",i); aplWeaponReload[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponFireDelay[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_FIREDELAY", i);
Bsprintf(aszBuf,"WEAPON%zd_TOTALTIME",i); aplWeaponFireDelay[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponTotalTime[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_TOTALTIME", i);
Bsprintf(aszBuf,"WEAPON%zd_HOLDDELAY",i); aplWeaponTotalTime[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponHoldDelay[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_HOLDDELAY", i);
Bsprintf(aszBuf,"WEAPON%zd_FLAGS",i); aplWeaponHoldDelay[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponFlags[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_FLAGS", i);
Bsprintf(aszBuf,"WEAPON%zd_SHOOTS",i); aplWeaponFlags[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponShoots[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SHOOTS", i);
Bsprintf(aszBuf,"WEAPON%zd_SPAWNTIME",i); aplWeaponShoots[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponSpawnTime[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SPAWNTIME", i);
Bsprintf(aszBuf,"WEAPON%zd_SPAWN",i); aplWeaponSpawnTime[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponSpawn[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SPAWN", i);
Bsprintf(aszBuf,"WEAPON%zd_SHOTSPERBURST",i); aplWeaponSpawn[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponShotsPerBurst[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SHOTSPERBURST", i);
Bsprintf(aszBuf,"WEAPON%zd_WORKSLIKE",i); aplWeaponShotsPerBurst[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponWorksLike[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_WORKSLIKE", i);
Bsprintf(aszBuf,"WEAPON%zd_INITIALSOUND",i); aplWeaponWorksLike[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponInitialSound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_INITIALSOUND", i);
Bsprintf(aszBuf,"WEAPON%zd_FIRESOUND",i); aplWeaponInitialSound[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponFireSound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_FIRESOUND", i);
Bsprintf(aszBuf,"WEAPON%zd_SOUND2TIME",i); aplWeaponFireSound[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponSound2Time[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SOUND2TIME", i);
Bsprintf(aszBuf,"WEAPON%zd_SOUND2SOUND",i); aplWeaponSound2Time[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponSound2Sound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SOUND2SOUND", i);
Bsprintf(aszBuf,"WEAPON%zd_RELOADSOUND1",i); aplWeaponSound2Sound[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponReloadSound1[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_RELOADSOUND1", i);
Bsprintf(aszBuf,"WEAPON%zd_RELOADSOUND2",i); aplWeaponReloadSound1[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponReloadSound2[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_RELOADSOUND2", i);
Bsprintf(aszBuf,"WEAPON%zd_SELECTSOUND",i); aplWeaponReloadSound2[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponSelectSound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_SELECTSOUND", i);
Bsprintf(aszBuf,"WEAPON%zd_FLASHCOLOR",i); aplWeaponSelectSound[i] = Gv_GetVarDataPtr(aszBuf);
aplWeaponFlashColor[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf, "WEAPON%zd_FLASHCOLOR", i);
aplWeaponFlashColor[i] = Gv_GetVarDataPtr(aszBuf);
} }
} }
@ -1819,10 +1821,11 @@ void Gv_RefreshPointers(void)
aGameVars[Gv_GetVarIndex("current_menu")].global = (intptr_t)&g_currentMenu; aGameVars[Gv_GetVarIndex("current_menu")].global = (intptr_t)&g_currentMenu;
aGameVars[Gv_GetVarIndex("viewingrange")].global = (intptr_t)&viewingrange; aGameVars[Gv_GetVarIndex("viewingrange")].global = (intptr_t)&viewingrange;
aGameVars[Gv_GetVarIndex("yxaspect")].global = (intptr_t)&yxaspect; aGameVars[Gv_GetVarIndex("yxaspect")].global = (intptr_t)&yxaspect;
aGameVars[Gv_GetVarIndex("gravitationalconstant")].global = (intptr_t)&g_spriteGravity;
aGameVars[Gv_GetVarIndex("gametype_flags")].global = (intptr_t)&GametypeFlags[ud.coop]; aGameVars[Gv_GetVarIndex("gametype_flags")].global = (intptr_t)&GametypeFlags[ud.coop];
aGameVars[Gv_GetVarIndex("framerate")].global = (intptr_t)&g_currentFrameRate; aGameVars[Gv_GetVarIndex("framerate")].global = (intptr_t)&g_currentFrameRate;
aGameVars[Gv_GetVarIndex("gravitationalconstant")].global = (intptr_t)&g_spriteGravity;
aGameVars[Gv_GetVarIndex("camerax")].global = (intptr_t)&ud.camerapos.x; aGameVars[Gv_GetVarIndex("camerax")].global = (intptr_t)&ud.camerapos.x;
aGameVars[Gv_GetVarIndex("cameray")].global = (intptr_t)&ud.camerapos.y; aGameVars[Gv_GetVarIndex("cameray")].global = (intptr_t)&ud.camerapos.y;
aGameVars[Gv_GetVarIndex("cameraz")].global = (intptr_t)&ud.camerapos.z; aGameVars[Gv_GetVarIndex("cameraz")].global = (intptr_t)&ud.camerapos.z;

View file

@ -1321,48 +1321,48 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
} }
} }
for (bssize_t nWall=numwalls-1; nWall>=0; nWall--) for (bssize_t wallNum=numwalls-1; wallNum>=0; wallNum--)
{ {
if (lotag == wall[nWall].lotag) if (lotag == wall[wallNum].lotag)
{ {
if (wall[nWall].picnum >= MULTISWITCH && wall[nWall].picnum <= MULTISWITCH+3) if (wall[wallNum].picnum >= MULTISWITCH && wall[wallNum].picnum <= MULTISWITCH+3)
{ {
wall[nWall].picnum++; wall[wallNum].picnum++;
if (wall[nWall].picnum > MULTISWITCH+3) if (wall[wallNum].picnum > MULTISWITCH+3)
wall[nWall].picnum = MULTISWITCH; wall[wallNum].picnum = MULTISWITCH;
} }
switch (DYNAMICTILEMAP(wall[nWall].picnum)) switch (DYNAMICTILEMAP(wall[wallNum].picnum))
{ {
case DIPSWITCH_LIKE_CASES: case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_WALL && nWall == wallOrSprite) if (switchType == SWITCH_WALL && wallNum == wallOrSprite)
wall[nWall].picnum++; wall[wallNum].picnum++;
else if (wall[nWall].hitag == 0) else if (wall[wallNum].hitag == 0)
nCorrectDips++; nCorrectDips++;
nNumDips++; nNumDips++;
break; break;
case ACCESSSWITCH_CASES: case ACCESSSWITCH_CASES:
case REST_SWITCH_CASES: case REST_SWITCH_CASES:
wall[nWall].picnum++; wall[wallNum].picnum++;
break; break;
default: default:
if (wall[nWall].picnum <= 0) // oob safety if (wall[wallNum].picnum <= 0) // oob safety
break; break;
switch (DYNAMICTILEMAP(wall[nWall].picnum - 1)) switch (DYNAMICTILEMAP(wall[wallNum].picnum - 1))
{ {
case DIPSWITCH_LIKE_CASES: case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_WALL && nWall == wallOrSprite) if (switchType == SWITCH_WALL && wallNum == wallOrSprite)
wall[nWall].picnum--; wall[wallNum].picnum--;
else if (wall[nWall].hitag == 1) else if (wall[wallNum].hitag == 1)
nCorrectDips++; nCorrectDips++;
nNumDips++; nNumDips++;
break; break;
case REST_SWITCH_CASES: case REST_SWITCH_CASES:
wall[nWall].picnum--; wall[wallNum].picnum--;
break; break;
} }
break; break;
@ -1469,18 +1469,18 @@ void G_ActivateBySector(int sectNum, int spriteNum)
G_OperateSectors(sectNum, spriteNum); G_OperateSectors(sectNum, spriteNum);
} }
static void G_BreakWall(int nPicnum, int spriteNum, int nWall) static void G_BreakWall(int tileNum, int spriteNum, int wallNum)
{ {
wall[nWall].picnum = nPicnum; wall[wallNum].picnum = tileNum;
A_PlaySound(VENT_BUST,spriteNum); A_PlaySound(VENT_BUST,spriteNum);
A_PlaySound(GLASS_HEAVYBREAK,spriteNum); A_PlaySound(GLASS_HEAVYBREAK,spriteNum);
A_SpawnWallGlass(spriteNum,nWall,10); A_SpawnWallGlass(spriteNum,wallNum,10);
} }
void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum) void A_DamageWall(int spriteNum, int wallNum, const vec3_t *vPos, int weaponNum)
{ {
int16_t sectNum = -1; int16_t sectNum = -1;
walltype *pWall = &wall[nWall]; walltype *pWall = &wall[wallNum];
if (pWall->overpicnum == MIRROR && pWall->pal != 4 && if (pWall->overpicnum == MIRROR && pWall->pal != 4 &&
A_CheckSpriteFlags(spriteNum, SFLAG_PROJECTILE) && A_CheckSpriteFlags(spriteNum, SFLAG_PROJECTILE) &&
@ -1488,7 +1488,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
{ {
if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4) if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4)
{ {
A_SpawnWallGlass(spriteNum, nWall, 70); A_SpawnWallGlass(spriteNum, wallNum, 70);
pWall->cstat &= ~16; pWall->cstat &= ~16;
pWall->overpicnum = MIRRORBROKE; pWall->overpicnum = MIRRORBROKE;
A_PlaySound(GLASS_HEAVYBREAK, spriteNum); A_PlaySound(GLASS_HEAVYBREAK, spriteNum);
@ -1509,7 +1509,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
case EXPLODINGBARREL__STATIC: case EXPLODINGBARREL__STATIC:
if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4) if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4)
{ {
A_SpawnWallGlass(spriteNum, nWall, 70); A_SpawnWallGlass(spriteNum, wallNum, 70);
pWall->cstat &= ~16; pWall->cstat &= ~16;
pWall->overpicnum = MIRRORBROKE; pWall->overpicnum = MIRRORBROKE;
A_PlaySound(GLASS_HEAVYBREAK, spriteNum); A_PlaySound(GLASS_HEAVYBREAK, spriteNum);
@ -1522,7 +1522,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
(sector[pWall->nextsector].floorz > vPos->z) && (sector[pWall->nextsector].floorz > vPos->z) &&
(sector[pWall->nextsector].floorz != sector[pWall->nextsector].ceilingz)) (sector[pWall->nextsector].floorz != sector[pWall->nextsector].ceilingz))
{ {
int const nSwitchPicnum = G_GetForcefieldPicnum(nWall); int const nSwitchPicnum = G_GetForcefieldPicnum(wallNum);
switch (DYNAMICTILEMAP(nSwitchPicnum)) switch (DYNAMICTILEMAP(nSwitchPicnum))
{ {
@ -1573,7 +1573,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
if (sectNum < 0) if (sectNum < 0)
return; return;
pWall->overpicnum = GLASS2; pWall->overpicnum = GLASS2;
A_SpawnWallGlass(spriteNum, nWall, 10); A_SpawnWallGlass(spriteNum, wallNum, 10);
pWall->cstat = 0; pWall->cstat = 0;
if (pWall->nextwall >= 0) if (pWall->nextwall >= 0)
@ -1584,7 +1584,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
g_player[0].ps->ang, 0, 0, spriteNum, 3); g_player[0].ps->ang, 0, 0, spriteNum, 3);
SLT(i) = 128; SLT(i) = 128;
T2(i) = 5; T2(i) = 5;
T3(i) = nWall; T3(i) = wallNum;
A_PlaySound(GLASS_BREAKING, i); A_PlaySound(GLASS_BREAKING, i);
} }
return; return;
@ -1593,7 +1593,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
updatesector(vPos->x, vPos->y, &sectNum); updatesector(vPos->x, vPos->y, &sectNum);
if (sectNum < 0) if (sectNum < 0)
return; return;
A_SpawnRandomGlass(spriteNum, nWall, 80); A_SpawnRandomGlass(spriteNum, wallNum, 80);
pWall->cstat = 0; pWall->cstat = 0;
if (pWall->nextwall >= 0) if (pWall->nextwall >= 0)
wall[pWall->nextwall].cstat = 0; wall[pWall->nextwall].cstat = 0;
@ -1607,7 +1607,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
{ {
case COLAMACHINE__STATIC: case COLAMACHINE__STATIC:
case VENDMACHINE__STATIC: case VENDMACHINE__STATIC:
G_BreakWall(pWall->picnum + 2, spriteNum, nWall); G_BreakWall(pWall->picnum + 2, spriteNum, wallNum);
A_PlaySound(VENT_BUST, spriteNum); A_PlaySound(VENT_BUST, spriteNum);
return; return;
@ -1637,7 +1637,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
case SCREENBREAK18__STATIC: case SCREENBREAK18__STATIC:
case SCREENBREAK19__STATIC: case SCREENBREAK19__STATIC:
case BORNTOBEWILDSCREEN__STATIC: case BORNTOBEWILDSCREEN__STATIC:
A_SpawnWallGlass(spriteNum, nWall, 30); A_SpawnWallGlass(spriteNum, wallNum, 30);
pWall->picnum = W_SCREENBREAK + (krand() % 3); pWall->picnum = W_SCREENBREAK + (krand() % 3);
A_PlaySound(GLASS_HEAVYBREAK, spriteNum); A_PlaySound(GLASS_HEAVYBREAK, spriteNum);
return; return;
@ -1647,15 +1647,15 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
case W_TECHWALL7__STATIC: case W_TECHWALL7__STATIC:
case W_TECHWALL8__STATIC: case W_TECHWALL8__STATIC:
case W_TECHWALL9__STATIC: case W_TECHWALL9__STATIC:
G_BreakWall(pWall->picnum + 1, spriteNum, nWall); G_BreakWall(pWall->picnum + 1, spriteNum, wallNum);
return; return;
case W_MILKSHELF__STATIC: case W_MILKSHELF__STATIC:
G_BreakWall(W_MILKSHELFBROKE, spriteNum, nWall); G_BreakWall(W_MILKSHELFBROKE, spriteNum, wallNum);
return; return;
case W_TECHWALL10__STATIC: case W_TECHWALL10__STATIC:
G_BreakWall(W_HITTECHWALL10, spriteNum, nWall); G_BreakWall(W_HITTECHWALL10, spriteNum, wallNum);
return; return;
case W_TECHWALL1__STATIC: case W_TECHWALL1__STATIC:
@ -1663,27 +1663,27 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
case W_TECHWALL12__STATIC: case W_TECHWALL12__STATIC:
case W_TECHWALL13__STATIC: case W_TECHWALL13__STATIC:
case W_TECHWALL14__STATIC: case W_TECHWALL14__STATIC:
G_BreakWall(W_HITTECHWALL1, spriteNum, nWall); G_BreakWall(W_HITTECHWALL1, spriteNum, wallNum);
return; return;
case W_TECHWALL15__STATIC: case W_TECHWALL15__STATIC:
G_BreakWall(W_HITTECHWALL15, spriteNum, nWall); G_BreakWall(W_HITTECHWALL15, spriteNum, wallNum);
return; return;
case W_TECHWALL16__STATIC: case W_TECHWALL16__STATIC:
G_BreakWall(W_HITTECHWALL16, spriteNum, nWall); G_BreakWall(W_HITTECHWALL16, spriteNum, wallNum);
return; return;
case W_TECHWALL2__STATIC: case W_TECHWALL2__STATIC:
G_BreakWall(W_HITTECHWALL2, spriteNum, nWall); G_BreakWall(W_HITTECHWALL2, spriteNum, wallNum);
return; return;
case W_TECHWALL3__STATIC: case W_TECHWALL3__STATIC:
G_BreakWall(W_HITTECHWALL3, spriteNum, nWall); G_BreakWall(W_HITTECHWALL3, spriteNum, wallNum);
return; return;
case W_TECHWALL4__STATIC: case W_TECHWALL4__STATIC:
G_BreakWall(W_HITTECHWALL4, spriteNum, nWall); G_BreakWall(W_HITTECHWALL4, spriteNum, wallNum);
return; return;
case ATM__STATIC: case ATM__STATIC:
@ -1700,7 +1700,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
case TECHLIGHT4__STATIC: case TECHLIGHT4__STATIC:
{ {
A_PlaySound(rnd(128) ? GLASS_HEAVYBREAK : GLASS_BREAKING, spriteNum); A_PlaySound(rnd(128) ? GLASS_HEAVYBREAK : GLASS_BREAKING, spriteNum);
A_SpawnWallGlass(spriteNum, nWall, 30); A_SpawnWallGlass(spriteNum, wallNum, 30);
if (pWall->picnum == WALLLIGHT1) if (pWall->picnum == WALLLIGHT1)
pWall->picnum = WALLLIGHTBUST1; pWall->picnum = WALLLIGHTBUST1;
@ -1739,7 +1739,7 @@ void A_DamageWall(int spriteNum, int nWall, const vec3_t *vPos, int weaponNum)
int const nRand = krand() & 1; int const nRand = krand() & 1;
for (bssize_t SPRITES_OF(STAT_EFFECTOR, i)) for (bssize_t SPRITES_OF(STAT_EFFECTOR, i))
if (SHT(i) == wall[nWall].lotag && SLT(i) == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) if (SHT(i) == wall[wallNum].lotag && SLT(i) == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT)
{ {
T3(i) = nRand; T3(i) = nRand;
T4(i) = nDarkestWall; T4(i) = nDarkestWall;

View file

@ -774,7 +774,7 @@ void S_ChangeSoundPitch(int32_t num, int32_t i, int32_t pitchoffset)
if ((i == -1 && voice > FX_Ok) || (i != -1 && g_sounds[num].SoundOwner[j].ow == i)) if ((i == -1 && voice > FX_Ok) || (i != -1 && g_sounds[num].SoundOwner[j].ow == i))
{ {
if (EDUKE32_PREDICT_FALSE(i >= 0 && voice <= FX_Ok)) if (EDUKE32_PREDICT_FALSE(i >= 0 && voice <= FX_Ok))
initprintf(OSD_ERROR "S_ChangeSoundPitch(): bad voice %d for sound ID %d index %d!\n", voice, num, j); initprintf(OSD_ERROR "S_ChangeSoundPitch(): bad voice %d for sound ID %d index %zd!\n", voice, num, j);
else if (voice > FX_Ok && FX_SoundActive(voice)) else if (voice > FX_Ok && FX_SoundActive(voice))
FX_SetPitch(voice, pitchoffset); FX_SetPitch(voice, pitchoffset);
break; break;