Replace some constants with preprocessor macros.

git-svn-id: https://svn.eduke32.com/eduke32@4472 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2014-05-17 12:36:40 +00:00
parent 20bf310cba
commit a755e95c2c
12 changed files with 56 additions and 33 deletions

View file

@ -82,11 +82,12 @@ extern void setvsync(int32_t sync);
extern char inputdevices; extern char inputdevices;
// keys // keys
#define NUMKEYS 256
#define KEYSTATUSSIZ 256 #define KEYSTATUSSIZ 256
#define KEYFIFOSIZ 64 #define KEYFIFOSIZ 64
extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
extern char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; extern char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
extern char scantoasc[128], remap[KEYSTATUSSIZ], key_names[256][24]; extern char scantoasc[128], remap[KEYSTATUSSIZ], key_names[NUMKEYS][24];
extern int32_t remapinit; extern int32_t remapinit;
extern int32_t defaultres[][2]; extern int32_t defaultres[][2];

View file

@ -733,7 +733,11 @@ EXTERN intptr_t ylookup[MAXYDIM+1];
}; };
#endif #endif
#ifndef GEKKO
#define MAXVALIDMODES 256 #define MAXVALIDMODES 256
#else
#define MAXVALIDMODES 16
#endif
EXTERN int32_t validmodecnt; EXTERN int32_t validmodecnt;
struct validmode_t { struct validmode_t {
int32_t xdim,ydim; int32_t xdim,ydim;

View file

@ -14,7 +14,7 @@ char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
char remap[KEYSTATUSSIZ]; char remap[KEYSTATUSSIZ];
int32_t remapinit=0; int32_t remapinit=0;
char key_names[256][24]; char key_names[NUMKEYS][24];
volatile int32_t mousex=0,mousey=0,mouseb=0,mouseabsx=0,mouseabsy=0; volatile int32_t mousex=0,mousey=0,mouseb=0,mouseabsx=0,mouseabsy=0;
volatile uint8_t moustat = 0, mousegrab = 0; volatile uint8_t moustat = 0, mousegrab = 0;
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL; int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;

View file

@ -285,11 +285,11 @@ void CONFIG_SetDefaults(void)
Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); Bstrcpy(ud.ridecule[0], "An inspiration for birth control.");
Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); Bstrcpy(ud.ridecule[1], "You're gonna die for that!");
Bstrcpy(ud.ridecule[2], "It hurts to be you."); Bstrcpy(ud.ridecule[2], "It hurts to be you.");
Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch."); Bstrcpy(ud.ridecule[3], "Lucky son of a bitch.");
Bstrcpy(ud.ridecule[4], "Hmmm....Payback time."); Bstrcpy(ud.ridecule[4], "Hmmm... payback time.");
Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker."); Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker.");
Bstrcpy(ud.ridecule[6], "Damn, you're ugly."); Bstrcpy(ud.ridecule[6], "Damn, you're ugly.");
Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!"); Bstrcpy(ud.ridecule[7], "Ha ha ha... wasted!");
Bstrcpy(ud.ridecule[8], "You suck!"); Bstrcpy(ud.ridecule[8], "You suck!");
Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!");
@ -608,7 +608,7 @@ int32_t CONFIG_ReadSetup(void)
{ {
char dummybuf[64]; char dummybuf[64];
for (dummy = 0; dummy < 10; dummy++) for (dummy = 0; dummy < MAXRIDECULE; dummy++)
{ {
commmacro[13] = dummy+'0'; commmacro[13] = dummy+'0';
SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);
@ -970,7 +970,7 @@ void CONFIG_WriteSetup(uint32_t flags)
{ {
char commmacro[] = "CommbatMacro# "; char commmacro[] = "CommbatMacro# ";
for (dummy = 0; dummy < 10; dummy++) for (dummy = 0; dummy < MAXRIDECULE; dummy++)
{ {
commmacro[13] = dummy+'0'; commmacro[13] = dummy+'0';
SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]);

View file

@ -151,7 +151,6 @@ int32_t g_Shareware = 0;
int32_t quotebot, quotebotgoal; int32_t quotebot, quotebotgoal;
static int32_t user_quote_time[MAXUSERQUOTES]; static int32_t user_quote_time[MAXUSERQUOTES];
static char user_quote[MAXUSERQUOTES][178]; static char user_quote[MAXUSERQUOTES][178];
// char typebuflen,typebuf[41];
// This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo. // This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo.
// Ideally, we would look at our memory usage on our most cramped platform and figure out // Ideally, we would look at our memory usage on our most cramped platform and figure out

View file

@ -31,6 +31,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define USERQUOTE_LEFTOFFSET 5 #define USERQUOTE_LEFTOFFSET 5
#define USERQUOTE_RIGHTOFFSET 14 #define USERQUOTE_RIGHTOFFSET 14
#define MAXRIDECULE 10
#define MAXRIDECULELENGTH 40
#define MAXSAVEGAMES 10
#define MAXSAVEGAMENAME 22
#define MAXPWLOCKOUT 128
#define MAXRTSNAME 128
enum GametypeFlags_t { enum GametypeFlags_t {
GAMETYPE_COOP = 0x00000001, GAMETYPE_COOP = 0x00000001,
GAMETYPE_WEAPSTAY = 0x00000002, GAMETYPE_WEAPSTAY = 0x00000002,
@ -233,9 +240,9 @@ typedef struct {
char overhead_on,last_overhead,showweapons; char overhead_on,last_overhead,showweapons;
char god,warp_on,cashman,eog,showallmap; char god,warp_on,cashman,eog,showallmap;
char show_help,scrollmode,noclip; char show_help,scrollmode,noclip;
char ridecule[10][40]; char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
char savegame[10][22]; char savegame[MAXSAVEGAMES][MAXSAVEGAMENAME];
char pwlockout[128],rtsname[128]; char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
char display_bonus_screen; char display_bonus_screen;
char show_level_text; char show_level_text;
} user_defs; } user_defs;

View file

@ -3291,20 +3291,16 @@ nullquote:
{ {
g_lastSaveSlot = *insptr++; g_lastSaveSlot = *insptr++;
if ((unsigned)g_lastSaveSlot >= 10) if ((unsigned)g_lastSaveSlot >= MAXSAVEGAMES)
continue; continue;
if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0) if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0)
{ {
time_t curtime = time(NULL); time_t curtime = time(NULL);
Bstrcpy(tempbuf,asctime(localtime(&curtime))); struct tm *timeptr = localtime(&curtime);
clearbufbyte(ud.savegame[g_lastSaveSlot],sizeof(ud.savegame[g_lastSaveSlot]),0); Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]), "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n",
Bsprintf(ud.savegame[g_lastSaveSlot],"Auto"); timeptr->tm_year + 1900, timeptr->tm_mon, timeptr->tm_mday,
// for (j=0;j<13;j++) timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec);
// Bmemcpy(&ud.savegame[g_lastSaveSlot][j+4],&tempbuf[j+3],sizeof(tempbuf[j+3]));
// ud.savegame[g_lastSaveSlot][j+4] = '\0';
Bmemcpy(&ud.savegame[g_lastSaveSlot][4],&tempbuf[3],sizeof(tempbuf[0])*13);
ud.savegame[g_lastSaveSlot][17] = '\0';
} }
OSD_Printf("Saving to slot %d\n",g_lastSaveSlot); OSD_Printf("Saving to slot %d\n",g_lastSaveSlot);

View file

@ -65,10 +65,12 @@ G_EXTERN char g_numSkills;
G_EXTERN char myjumpingtoggle,myonground,myhardlanding,myreturntocenter; G_EXTERN char myjumpingtoggle,myonground,myhardlanding,myreturntocenter;
G_EXTERN char pus,pub; G_EXTERN char pus,pub;
G_EXTERN char ready2send; G_EXTERN char ready2send;
G_EXTERN char szPlayerName[32]; #define MAXPLAYERNAME 32
G_EXTERN char szPlayerName[MAXPLAYERNAME];
// XXX: menutextbuf overflow possible? // XXX: menutextbuf overflow possible?
G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[1024]; G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[1024];
G_EXTERN char typebuflen,typebuf[141]; #define TYPEBUFSIZE 141
G_EXTERN char typebuf[TYPEBUFSIZE];
G_EXTERN input_t avg; G_EXTERN input_t avg;
G_EXTERN input_t loc; G_EXTERN input_t loc;
G_EXTERN input_t recsync[RECSYNCBUFSIZ]; G_EXTERN input_t recsync[RECSYNCBUFSIZ];

View file

@ -481,6 +481,12 @@ enum
MAXJOYBUTTONS = (32+4), MAXJOYBUTTONS = (32+4),
MAXJOYAXES = 8, MAXJOYAXES = 8,
NUMGAMEFUNCTIONS = 56, NUMGAMEFUNCTIONS = 56,
MAXRIDECULE = 10,
MAXRIDECULELENGTH = 40,
MAXSAVEGAMES = 10,
MAXSAVEGAMENAME = 22,
MAXPWLOCKOUT = 128,
MAXRTSNAME = 128,
}; };
typedef struct { typedef struct {
@ -574,9 +580,9 @@ typedef struct {
char overhead_on,last_overhead,showweapons; char overhead_on,last_overhead,showweapons;
char god,warp_on,cashman,eog,showallmap; char god,warp_on,cashman,eog,showallmap;
char show_help,scrollmode,noclip; char show_help,scrollmode,noclip;
char ridecule[10][40]; char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
char savegame[10][22]; char savegame[MAXSAVEGAMES][MAXSAVEGAMENAME];
char pwlockout[128],rtsname[128]; char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
char display_bonus_screen; char display_bonus_screen;
char show_level_text; char show_level_text;
} user_defs; } user_defs;

View file

@ -572,7 +572,7 @@ static void M_DisplaySaveGameList(void)
rotatesprite_fs(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10); rotatesprite_fs(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10);
rotatesprite_fs(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10); rotatesprite_fs(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10);
for (x=0; x<=9; x++) for (x=0; x<MAXSAVEGAMES; x++)
{ {
if (ud.savegame[x][0]) if (ud.savegame[x][0])
{ {
@ -1173,7 +1173,7 @@ void M_DisplayMenus(void)
M_ChangeMenu(MENU_PLAYER); M_ChangeMenu(MENU_PLAYER);
probey = 7; probey = 7;
} }
else if (x >= 0 && x <= 9) else if (x >= 0 && x < MAXRIDECULE)
{ {
strcpy(buf, ud.ridecule[x]); strcpy(buf, ud.ridecule[x]);
inputloc = strlen(buf); inputloc = strlen(buf);
@ -1197,7 +1197,7 @@ void M_DisplayMenus(void)
probey = last_menu_pos; probey = last_menu_pos;
} }
} }
for (i=0; i<10; i++) for (i=0; i<MAXRIDECULE; i++)
{ {
if (g_currentMenu == MENU_MACROSTYPING && i == last_menu_pos) continue; if (g_currentMenu == MENU_MACROSTYPING && i == last_menu_pos) continue;
mgametextpal(26,40+(i<<3),ud.ridecule[i],MENUHIGHLIGHT(i),0); mgametextpal(26,40+(i<<3),ud.ridecule[i],MENUHIGHLIGHT(i),0);

View file

@ -33,7 +33,7 @@ const char *g_failedVarname;
extern char *bitptr; extern char *bitptr;
uint8_t g_oldverSavegame[10]; uint8_t g_oldverSavegame[MAXSAVEGAMES];
#define BITPTR_POINTER 1 #define BITPTR_POINTER 1
@ -143,7 +143,7 @@ void ReadSaveGameHeaders(void)
Bstrcpy(fn, "dukesav0.esv"); Bstrcpy(fn, "dukesav0.esv");
for (i=0; i<10; i++) for (i=0; i<MAXSAVEGAMES; i++)
{ {
int32_t k; int32_t k;
@ -176,6 +176,8 @@ int32_t G_LoadSaveHeaderNew(int32_t spot, savehead_t *saveh)
char fn[16]; char fn[16];
int32_t fil, screenshotofs, i; int32_t fil, screenshotofs, i;
Bassert(spot < MAXSAVEGAMES);
Bstrcpy(fn, "dukesav0.esv"); Bstrcpy(fn, "dukesav0.esv");
fn[7] = spot + '0'; fn[7] = spot + '0';
@ -228,6 +230,8 @@ int32_t G_LoadPlayer(int32_t spot)
savehead_t h; savehead_t h;
Bassert(spot < MAXSAVEGAMES);
Bstrcpy(fn, "dukesav0.esv"); Bstrcpy(fn, "dukesav0.esv");
fn[7] = spot + '0'; fn[7] = spot + '0';
@ -347,6 +351,8 @@ int32_t G_SavePlayer(int32_t spot)
// char mpfn[16]; // char mpfn[16];
FILE *fil; FILE *fil;
Bassert(spot < MAXSAVEGAMES);
G_SaveTimers(); G_SaveTimers();
Bstrcpy(fn, "dukesav0.esv"); Bstrcpy(fn, "dukesav0.esv");
@ -1232,7 +1238,7 @@ int32_t sv_saveandmakesnapshot(FILE *fil, int8_t spot, int8_t recdiffsp, int8_t
h.skill = ud.player_skill; h.skill = ud.player_skill;
Bstrncpy(h.boardfn, currentboardfilename, sizeof(h.boardfn)); Bstrncpy(h.boardfn, currentboardfilename, sizeof(h.boardfn));
if (spot >= 0) if ((unsigned)spot < MAXSAVEGAMES)
{ {
// savegame // savegame
Bstrncpyz(h.savename, ud.savegame[spot], sizeof(h.savename)); Bstrncpyz(h.savename, ud.savegame[spot], sizeof(h.savename));

View file

@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __savegame_h__ #ifndef __savegame_h__
#define __savegame_h__ #define __savegame_h__
#include "game.h"
#ifdef LUNATIC #ifdef LUNATIC
# define SV_MAJOR_VER 2 # define SV_MAJOR_VER 2
#else #else
@ -45,7 +47,7 @@ typedef struct
int32_t reccnt, snapsiz; int32_t reccnt, snapsiz;
// 8 bytes // 8 bytes
char savename[22]; // should be of the same length as ud.savegame[i] char savename[MAXSAVEGAMENAME];
uint8_t numplayers, volnum, levnum, skill; uint8_t numplayers, volnum, levnum, skill;
char boardfn[256]; // BMAX_PATH char boardfn[256]; // BMAX_PATH
// 282 bytes // 282 bytes
@ -76,7 +78,7 @@ extern void sv_postyaxload(void);
// XXX: The 'bitptr' decl really belongs into gamedef.h, but we don't want to // XXX: The 'bitptr' decl really belongs into gamedef.h, but we don't want to
// pull all of it in savegame.c? // pull all of it in savegame.c?
extern char *bitptr; extern char *bitptr;
extern uint8_t g_oldverSavegame[10]; extern uint8_t g_oldverSavegame[MAXSAVEGAMES];
enum enum
{ {