diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index f1345718c..c9ec9176c 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -82,11 +82,12 @@ extern void setvsync(int32_t sync); extern char inputdevices; // keys +#define NUMKEYS 256 #define KEYSTATUSSIZ 256 #define KEYFIFOSIZ 64 extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; 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 defaultres[][2]; diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 5ce873596..a265b0683 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -733,7 +733,11 @@ EXTERN intptr_t ylookup[MAXYDIM+1]; }; #endif +#ifndef GEKKO #define MAXVALIDMODES 256 +#else +#define MAXVALIDMODES 16 +#endif EXTERN int32_t validmodecnt; struct validmode_t { int32_t xdim,ydim; diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index a5cceb139..494753903 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -14,7 +14,7 @@ char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; char remap[KEYSTATUSSIZ]; 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 uint8_t moustat = 0, mousegrab = 0; int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 178497d78..edf0e4f70 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -285,11 +285,11 @@ void CONFIG_SetDefaults(void) Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); Bstrcpy(ud.ridecule[2], "It hurts to be you."); - Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch."); - Bstrcpy(ud.ridecule[4], "Hmmm....Payback time."); + Bstrcpy(ud.ridecule[3], "Lucky son of a bitch."); + Bstrcpy(ud.ridecule[4], "Hmmm... payback time."); Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker."); 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[9], "AARRRGHHHHH!!!"); @@ -608,7 +608,7 @@ int32_t CONFIG_ReadSetup(void) { char dummybuf[64]; - for (dummy = 0; dummy < 10; dummy++) + for (dummy = 0; dummy < MAXRIDECULE; dummy++) { commmacro[13] = 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# "; - for (dummy = 0; dummy < 10; dummy++) + for (dummy = 0; dummy < MAXRIDECULE; dummy++) { commmacro[13] = dummy+'0'; SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 27870811c..3dc266586 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -151,7 +151,6 @@ int32_t g_Shareware = 0; int32_t quotebot, quotebotgoal; static int32_t user_quote_time[MAXUSERQUOTES]; 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. // Ideally, we would look at our memory usage on our most cramped platform and figure out diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index 27ad32a18..bff508156 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -31,6 +31,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define USERQUOTE_LEFTOFFSET 5 #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 { GAMETYPE_COOP = 0x00000001, GAMETYPE_WEAPSTAY = 0x00000002, @@ -233,9 +240,9 @@ typedef struct { char overhead_on,last_overhead,showweapons; char god,warp_on,cashman,eog,showallmap; char show_help,scrollmode,noclip; - char ridecule[10][40]; - char savegame[10][22]; - char pwlockout[128],rtsname[128]; + char ridecule[MAXRIDECULE][MAXRIDECULELENGTH]; + char savegame[MAXSAVEGAMES][MAXSAVEGAMENAME]; + char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME]; char display_bonus_screen; char show_level_text; } user_defs; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index a91217c08..1e468834e 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3291,20 +3291,16 @@ nullquote: { g_lastSaveSlot = *insptr++; - if ((unsigned)g_lastSaveSlot >= 10) + if ((unsigned)g_lastSaveSlot >= MAXSAVEGAMES) continue; if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0) { time_t curtime = time(NULL); - Bstrcpy(tempbuf,asctime(localtime(&curtime))); - clearbufbyte(ud.savegame[g_lastSaveSlot],sizeof(ud.savegame[g_lastSaveSlot]),0); - Bsprintf(ud.savegame[g_lastSaveSlot],"Auto"); - // for (j=0;j<13;j++) - // 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'; + struct tm *timeptr = localtime(&curtime); + Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]), "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", + timeptr->tm_year + 1900, timeptr->tm_mon, timeptr->tm_mday, + timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); } OSD_Printf("Saving to slot %d\n",g_lastSaveSlot); diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index 7f29f6036..c481c3f97 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -65,10 +65,12 @@ G_EXTERN char g_numSkills; G_EXTERN char myjumpingtoggle,myonground,myhardlanding,myreturntocenter; G_EXTERN char pus,pub; G_EXTERN char ready2send; -G_EXTERN char szPlayerName[32]; +#define MAXPLAYERNAME 32 +G_EXTERN char szPlayerName[MAXPLAYERNAME]; // XXX: menutextbuf overflow possible? 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 loc; G_EXTERN input_t recsync[RECSYNCBUFSIZ]; diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index cf0706481..7352b715b 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -481,6 +481,12 @@ enum MAXJOYBUTTONS = (32+4), MAXJOYAXES = 8, NUMGAMEFUNCTIONS = 56, + MAXRIDECULE = 10, + MAXRIDECULELENGTH = 40, + MAXSAVEGAMES = 10, + MAXSAVEGAMENAME = 22, + MAXPWLOCKOUT = 128, + MAXRTSNAME = 128, }; typedef struct { @@ -574,9 +580,9 @@ typedef struct { char overhead_on,last_overhead,showweapons; char god,warp_on,cashman,eog,showallmap; char show_help,scrollmode,noclip; - char ridecule[10][40]; - char savegame[10][22]; - char pwlockout[128],rtsname[128]; + char ridecule[MAXRIDECULE][MAXRIDECULELENGTH]; + char savegame[MAXSAVEGAMES][MAXSAVEGAMENAME]; + char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME]; char display_bonus_screen; char show_level_text; } user_defs; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index bf793b153..c669f9753 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -572,7 +572,7 @@ static void M_DisplaySaveGameList(void) 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); - for (x=0; x<=9; x++) + for (x=0; x= 0 && x <= 9) + else if (x >= 0 && x < MAXRIDECULE) { strcpy(buf, ud.ridecule[x]); inputloc = strlen(buf); @@ -1197,7 +1197,7 @@ void M_DisplayMenus(void) probey = last_menu_pos; } } - for (i=0; i<10; i++) + for (i=0; i= 0) + if ((unsigned)spot < MAXSAVEGAMES) { // savegame Bstrncpyz(h.savename, ud.savegame[spot], sizeof(h.savename)); diff --git a/polymer/eduke32/source/savegame.h b/polymer/eduke32/source/savegame.h index ed2a80d65..2fc580fb0 100644 --- a/polymer/eduke32/source/savegame.h +++ b/polymer/eduke32/source/savegame.h @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __savegame_h__ #define __savegame_h__ +#include "game.h" + #ifdef LUNATIC # define SV_MAJOR_VER 2 #else @@ -45,7 +47,7 @@ typedef struct int32_t reccnt, snapsiz; // 8 bytes - char savename[22]; // should be of the same length as ud.savegame[i] + char savename[MAXSAVEGAMENAME]; uint8_t numplayers, volnum, levnum, skill; char boardfn[256]; // BMAX_PATH // 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 // pull all of it in savegame.c? extern char *bitptr; -extern uint8_t g_oldverSavegame[10]; +extern uint8_t g_oldverSavegame[MAXSAVEGAMES]; enum {