diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 4519d9040..561a3c978 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -166,6 +166,9 @@ ifeq ($(PLATFORM),LINUX) NASMFLAGS += -f elf LIBS += -lvorbisfile -lvorbis -logg USE_OPENAL = 0 + ifeq ($(RELEASE),0) + OURCFLAGS += -D_FORTIFY_SOURCE=2 + endif endif ifeq ($(PLATFORM),DARWIN) diff --git a/polymer/eduke32/build/Makefile b/polymer/eduke32/build/Makefile index d00e36c22..df0e88ad5 100644 --- a/polymer/eduke32/build/Makefile +++ b/polymer/eduke32/build/Makefile @@ -145,6 +145,9 @@ EDITOROBJS=$(OBJ)/build.$o \ ifeq ($(PLATFORM),LINUX) ASFLAGS+= -f elf LIBS+= -lm + ifeq ($(RELEASE),0) + OURCFLAGS += -D_FORTIFY_SOURCE=2 + endif endif ifeq ($(PLATFORM),DARWIN) ENGINEOBJS += $(OBJ)/StartupWinController.editor.$o \ diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 4f934df66..5311e14d7 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -12167,7 +12167,20 @@ void HASH_free(struct HASH_table *t) t->items = 0; } -inline int HASH_getcode(const char *s) +#if 1 +// djb3 algorithm +inline unsigned int HASH_getcode(const char *s) +{ + unsigned int h = 5381; + int ch; + + while ((ch = *s++) != '\0') + h = ((h << 5) + h) ^ ch; + + return h; +} +#else +inline unsigned int HASH_getcode(const char *s) { int i=0, fact=1; while (*s) @@ -12178,6 +12191,7 @@ inline int HASH_getcode(const char *s) } return i; } +#endif void HASH_add(struct HASH_table *t, const char *s, int key) { @@ -12262,11 +12276,16 @@ int HASH_find(struct HASH_table *t, const char *s) { struct HASH_item *cur; - if (t->items==NULL) {initprintf("HASH_find: not initalized\n");return -1;} + if (t->items==NULL) + { + initprintf("HASH_find: not initalized\n"); + return -1; + } cur=t->items[HASH_getcode(s)%t->size]; while (cur) { - if (Bstrcmp(s,cur->string)==0)return cur->key; + if (Bstrcmp(s,cur->string) == 0) + return cur->key; cur=cur->next; } return -1; @@ -12276,11 +12295,16 @@ int HASH_findcase(struct HASH_table *t, const char *s) { struct HASH_item *cur; - if (t->items==NULL) {initprintf("HASH_findcase: not initalized\n");return -1;} + if (t->items==NULL) + { + initprintf("HASH_findcase: not initalized\n"); + return -1; + } cur=t->items[HASH_getcode(s)%t->size]; while (cur) { - if (Bstrcasecmp(s,cur->string)==0)return cur->key; + if (Bstrcasecmp(s,cur->string) == 0) + return cur->key; cur=cur->next; } return -1; diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 1ee5fada6..449c795e4 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -1855,7 +1855,7 @@ static symbol_t *findexactsymbol(const char *name) for (i=Bstrlen(lname);i>=0;i--) lname[i] = Btolower(lname[i]); - i = HASH_findcase(&osdsymbolsH,lname); + i = HASH_find(&osdsymbolsH,lname); if (i > -1) { // if ((symbol_t *)osdsymbptrs[i]->func == (void *)OSD_UNALIASED) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 0ddb02e10..f3e4a8758 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -896,7 +896,7 @@ extern intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine bei extern intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted extern intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound for weapon selection -extern short g_timerTicsPerSecond; +extern int g_timerTicsPerSecond; enum WeaponFlags_t { WEAPON_HOLSTER_CLEARS_CLIP = 1, // 'holstering' clears the current clip diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 5d651f3e9..2017665ea 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2576,8 +2576,10 @@ static void G_PrintFrameRate(void) int chars = Bsprintf(tempbuf, "%2u ms (%3u fps)", howlong, LastCount); printext256(windowx2-(chars<<(3-x))+1,windowy1+2,0,-1,tempbuf,x); - printext256(windowx2-(chars<<(3-x)),windowy1+1,(LastCount < LOW_FPS) ? COLOR_RED : COLOR_WHITE,-1,tempbuf,x); + printext256(windowx2-(chars<<(3-x)),windowy1+1, + (LastCount < LOW_FPS) ? COLOR_RED : COLOR_WHITE,-1,tempbuf,x); + // lag meter if (numplayers > 1 && (totalclock - lastpackettime) > 1) { for (howlong = (totalclock - lastpackettime);howlong>0 && howlong<(xdim>>2);howlong--) @@ -7562,7 +7564,7 @@ enum cheats CHEAT_SCREAMFORME, }; -void CheatGetInventory(void) +void G_CheatGetInv(void) { Gv_SetVar(g_iReturnVarID, 400, g_player[myconnectindex].ps->i, myconnectindex); X_OnEvent(EVENT_CHEATGETSTEROIDS, g_player[myconnectindex].ps->i, myconnectindex, -1); @@ -7631,7 +7633,7 @@ void CheatGetInventory(void) signed char cheatbuf[MAXCHEATLEN],cheatbuflen; -static void DoCheats(void) +static void G_DoCheats(void) { short ch, i, j, k=0, weapon; static int z=0; @@ -7722,7 +7724,7 @@ FOUNDCHEAT: case CHEAT_INVENTORY: KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - CheatGetInventory(); + G_CheatGetInv(); P_DoQuote(120,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; return; @@ -7824,7 +7826,7 @@ FOUNDCHEAT: sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].ps->palookup; Bstrcpy(ScriptQuotes[122],"Scream for me, Long Beach!"); P_DoQuote(122,g_player[myconnectindex].ps); - CheatGetInventory(); + G_CheatGetInv(); for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS;weapon++) g_player[myconnectindex].ps->gotweapon[weapon] = 1; @@ -7862,7 +7864,7 @@ FOUNDCHEAT: weapon < (MAX_WEAPONS-j); weapon++) P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); - CheatGetInventory(); + G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; P_DoQuote(5,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; @@ -7982,7 +7984,7 @@ FOUNDCHEAT: return; case CHEAT_ITEMS: - CheatGetInventory(); + G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; P_DoQuote(5,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; @@ -8099,7 +8101,7 @@ FOUNDCHEAT: } } -static void ShowScores(void) +static void G_ShowScores(void) { int t, i, y,xfragtotal,yfragtotal; @@ -8174,7 +8176,7 @@ static void ShowScores(void) } } -static void HandleLocalKeys(void) +static void G_HandleLocalKeys(void) { int i,ch; int j; @@ -11504,8 +11506,8 @@ MAIN_LOOP_RESTART: continue; } - DoCheats(); - HandleLocalKeys(); + G_DoCheats(); + G_HandleLocalKeys(); if ((ud.show_help == 0 && ud.multimode < 2 && !(g_player[myconnectindex].ps->gm&MODE_MENU)) || ud.multimode > 1 || ud.recstat == 2) i = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536); @@ -11543,7 +11545,7 @@ MAIN_LOOP_RESTART: gametext(160,70,"PRESS F1 TO ACCEPT, F2 TO DECLINE",0,2+8+16); } - if (BUTTON(gamefunc_Show_DukeMatch_Scores)) ShowScores(); + if (BUTTON(gamefunc_Show_DukeMatch_Scores)) G_ShowScores(); if (debug_on) G_ShowCacheLocks(); @@ -11860,7 +11862,7 @@ RECHECK: G_DrawBackground(); else { - HandleLocalKeys(); + G_HandleLocalKeys(); j = min(max((totalclock-lockclock)*(65536/TICSPERFRAME),0),65536); G_DrawRooms(screenpeek,j); diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 14388ddfd..1cef949c1 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -71,7 +71,7 @@ int g_currentFrameRate; char g_numVolumes = 3; -short g_timerTicsPerSecond=120; +int g_timerTicsPerSecond=120; //fx_device device; sound_t g_sounds[ MAXSOUNDS ];