From 81c920c96c7a29038aa811ce363759673e29bbcb Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 22 Jan 2020 12:42:33 +0100 Subject: [PATCH] review code changes, add or adapt comments where appropriate Fixes #41. --- Source/d_deh.c | 4 ++-- Source/d_main.c | 2 ++ Source/d_main.h | 2 +- Source/d_net.c | 5 +++-- Source/doomdata.h | 3 +++ Source/doomtype.h | 2 ++ Source/g_game.c | 28 ++++++++++++++++------------ Source/i_system.c | 14 +++++++++++--- Source/i_video.c | 16 +++++++--------- Source/i_video.h | 6 +++--- Source/m_cheat.c | 2 +- Source/m_cheat.h | 2 +- Source/m_fixed.h | 1 + Source/m_menu.c | 6 ++++-- Source/m_misc.c | 29 +++++++++++++++++++---------- Source/m_misc2.c | 2 +- Source/m_misc2.h | 2 +- Source/m_swap.h | 2 +- Source/mmus2mid.c | 2 ++ Source/p_enemy.c | 3 ++- Source/p_setup.c | 7 +++++-- Source/p_sight.c | 2 +- Source/p_spec.c | 1 + Source/r_data.c | 6 +++--- Source/r_defs.h | 5 ++++- Source/version.c | 1 + Source/w_wad.c | 4 +++- 27 files changed, 101 insertions(+), 58 deletions(-) diff --git a/Source/d_deh.c b/Source/d_deh.c index d15c78e2..4e914abd 100644 --- a/Source/d_deh.c +++ b/Source/d_deh.c @@ -1830,7 +1830,7 @@ void deh_procPointer(DEHFILE *fpin, FILE* fpout, char *line) // done states[indexnum].action = deh_codeptr[value]; if (fpout) fprintf(fpout," - applied %p from codeptr[%ld] to states[%d]\n",deh_codeptr[value],value,indexnum); // Write BEX-oriented line to match: - for (i=0;i 12) ? "..." : "", + lookfor ? lookfor : "", (lookfor && strlen(lookfor) > 12) ? "..." : "", // [FG] NULL dereference newstring, (strlen(newstring) > 12) ? "..." :"", deh_strlookup[i].lookup); diff --git a/Source/d_main.c b/Source/d_main.c index a5d271c2..2aa0439a 100644 --- a/Source/d_main.c +++ b/Source/d_main.c @@ -1103,6 +1103,7 @@ void FindResponseFile (void) size = ftell(handle); fseek(handle,0,SEEK_SET); file = malloc (size); + // [FG] check return value if (!fread(file,size,1,handle)) { fclose(handle); @@ -1809,6 +1810,7 @@ void D_DoomMain(void) idmusnum = -1; //jff 3/17/98 insure idmus number is blank // check for a driver that wants intermission stats + // [FG] replace with -statdump implementation from Chocolate Doom if ((p = M_CheckParm ("-statdump")) && ptype == ev_keydown && ev->data1 == key_escape) // phares @@ -716,7 +716,7 @@ void TryRunTics (void) // the key player does not adapt } else - if (i < MAXPLAYERS) + if (i < MAXPLAYERS) // [FG] avoid overflow { if (nettics[0] <= nettics[nodeforplayer[i]]) { @@ -752,6 +752,7 @@ void TryRunTics (void) M_Ticker (); return; } + // [FG] let the CPU sleep for 1 ms if there is no tic to proceed I_Sleep(1); } diff --git a/Source/doomdata.h b/Source/doomdata.h index 1f8a97fe..50892d8e 100644 --- a/Source/doomdata.h +++ b/Source/doomdata.h @@ -75,6 +75,7 @@ typedef struct { // A LineDef, as used for editing, and as input to the BSP builder. typedef struct { + // [FG] extended nodes unsigned short v1; unsigned short v2; unsigned short flags; @@ -140,6 +141,7 @@ typedef struct { // SubSector, as generated by BSP. typedef struct { + // [FG] extended nodes unsigned short numsegs; unsigned short firstseg; // Index of first one; segs are stored sequentially. } mapsubsector_t; @@ -147,6 +149,7 @@ typedef struct { // LineSeg, generated by splitting LineDefs // using partition lines selected by BSP builder. typedef struct { + // [FG] extended nodes unsigned short v1; unsigned short v2; short angle; diff --git a/Source/doomtype.h b/Source/doomtype.h index e3687f4f..fe4fb3f5 100644 --- a/Source/doomtype.h +++ b/Source/doomtype.h @@ -58,6 +58,8 @@ typedef int64_t Long64; #define D_MAXINT INT_MAX #define D_MININT INT_MIN +// [FG] common definitions from Chocolate Doom + #ifdef _WIN32 #define DIR_SEPARATOR '\\' diff --git a/Source/g_game.c b/Source/g_game.c index 0e6ccb10..447658e2 100644 --- a/Source/g_game.c +++ b/Source/g_game.c @@ -242,12 +242,10 @@ int defaultskill; //note 1-based // killough 2/8/98: make corpse queue variable in size int bodyqueslot, bodyquesize, default_bodyquesize; // killough 2/8/98, 10/98 -// Set to -1 or +1 to switch to the previous or next weapon. +// [FG] prev/next weapon handling from Chocolate Doom static int next_weapon = 0; -// Used for prev/next weapon keys. - static const struct { weapontype_t weapon; @@ -696,6 +694,7 @@ static void G_DoLoadLevel(void) joyxmove = joyymove = 0; mousex = mousey = 0; sendpause = sendsave = paused = false; + // [FG] array size! memset (mousearray, 0, sizeof(mousearray)); memset (joyarray, 0, sizeof(joyarray)); @@ -718,10 +717,7 @@ static void G_DoLoadLevel(void) } } -// -// G_Responder -// Get info needed to make ticcmd_ts for the players. -// +// [FG] mouse and joystick button handling adapted from Chocolate Doom static void SetJoyButtons(unsigned int buttons_mask) { @@ -775,6 +771,11 @@ static void SetMouseButtons(unsigned int buttons_mask) } } +// +// G_Responder +// Get info needed to make ticcmd_ts for the players. +// + boolean G_Responder(event_t* ev) { // allow spy mode changes even during the demo @@ -845,8 +846,7 @@ boolean G_Responder(event_t* ev) return true; // finale ate the event } - // If the next/previous weapon keys are pressed, set the next_weapon - // variable to change weapons when the next ticcmd is generated. + // [FG] prev/next weapon handling from Chocolate Doom if (ev->type == ev_keydown && ev->data1 == key_prevweapon) { @@ -873,8 +873,8 @@ boolean G_Responder(event_t* ev) return false; // always let key up events filter down case ev_mouse: + // [FG] mouse button and movement handling adapted from Chocolate Doom SetMouseButtons(ev->data1); - // [FG] mouse movement handling adapted from Chocolate Doom if (mouseSensitivity_horiz) mousex = ev->data2*(mouseSensitivity_horiz+5)/10; if (mouseSensitivity_vert) @@ -882,6 +882,7 @@ boolean G_Responder(event_t* ev) return true; // eat events case ev_joystick: + // [FG] joystick button and axis handling adapted from Chocolate Doom SetJoyButtons(ev->data1); joyxmove = ev->data2; joyymove = ev->data3; @@ -1087,6 +1088,7 @@ static void G_DoCompleted(void) viewactive = false; automapactive = false; + // [FG] -statdump implementation from Chocolate Doom if (gamemode == commercial || gamemap != 8) { StatCopy(&wminfo); @@ -1440,8 +1442,9 @@ static void G_DoSaveGame(void) save_p = G_WriteOptions(save_p); // killough 3/1/98: save game options + // [FG] fix copy size and pointer progression memcpy(save_p, &leveltime, sizeof leveltime); //killough 11/98: save entire word - save_p += sizeof leveltime; // [FG] fix copy size and pointer progression + save_p += sizeof leveltime; // killough 11/98: save revenant tracer state *save_p++ = (gametic-basetic) & 255; @@ -1546,8 +1549,9 @@ static void G_DoLoadGame(void) // get the times // killough 11/98: save entire word + // [FG] fix copy size and pointer progression memcpy(&leveltime, save_p, sizeof leveltime); - save_p += sizeof leveltime; // [FG] fix copy size and pointer progression + save_p += sizeof leveltime; // killough 11/98: load revenant tracer state basetic = gametic - (int) *save_p++; diff --git a/Source/i_system.c b/Source/i_system.c index f02f2264..751d99c9 100644 --- a/Source/i_system.c +++ b/Source/i_system.c @@ -31,7 +31,10 @@ #include #endif +#ifndef _WIN32 #include // [FG] isatty() +#endif + #include "SDL.h" #include "z_zone.h" @@ -56,6 +59,8 @@ void I_WaitVBL(int count) SDL_Delay((count*500)/TICRATE); } +// [FG] let the CPU sleep if there is no tic to proceed + void I_Sleep(int ms) { SDL_Delay(ms); @@ -282,9 +287,8 @@ void I_Quit (void) #endif } -// -// I_Error -// +// [FG] returns true if stdout is a real console, false if it is a file + static boolean I_ConsoleStdout(void) { #ifdef _WIN32 @@ -295,6 +299,10 @@ static boolean I_ConsoleStdout(void) #endif } +// +// I_Error +// + void I_Error(const char *error, ...) // killough 3/20/98: add const { boolean exit_gui_popup; diff --git a/Source/i_video.c b/Source/i_video.c index b2be09ae..3a2a409b 100644 --- a/Source/i_video.c +++ b/Source/i_video.c @@ -43,7 +43,7 @@ #include "i_video.h" #include "i_savepng.h" // [FG] SavePNG() -// Set the application icon +// [FG] set the application icon #include "icon.c" @@ -75,7 +75,7 @@ int joystickSens_y; extern SDL_Joystick *sdlJoystick; -// Get a bitmask of all currently-pressed buttons +// [FG] adapt joystick button and axis handling from Chocolate Doom 3.0 static int GetButtonsState(void) { @@ -95,8 +95,6 @@ static int GetButtonsState(void) return result; } -// Read the state of an axis - static int GetAxisState(int axis, int sens) { int result; @@ -300,7 +298,8 @@ int I_DoomCode2ScanCode (int a) return a; } -// Bit mask of mouse button state. +// [FG] mouse button and movement handling from Chocolate Doom 3.0 + static unsigned int mouse_button_state = 0; static void UpdateMouseButtonState(unsigned int button, boolean on) @@ -408,6 +407,8 @@ static void I_HandleMouseEvent(SDL_Event *sdlevent) } } +// [FG] keyboard event handling from Chocolate Doom 3.0 + static void I_HandleKeyboardEvent(SDL_Event *sdlevent) { // XXX: passing pointers to event for access after this function @@ -421,10 +422,7 @@ static void I_HandleKeyboardEvent(SDL_Event *sdlevent) event.data1 = TranslateKey(&sdlevent->key.keysym); event.data2 = 0; event.data3 = 0; -/* - event.data2 = GetLocalizedKey(&sdlevent->key.keysym); - event.data3 = GetTypedChar(&sdlevent->key.keysym); -*/ + if (event.data1 != 0) { D_PostEvent(&event); diff --git a/Source/i_video.h b/Source/i_video.h index 1ea48ff3..81c550b0 100644 --- a/Source/i_video.h +++ b/Source/i_video.h @@ -51,7 +51,7 @@ void I_FinishUpdate (void); // Wait for vertical retrace or pause a bit. void I_WaitVBL(int count); -void I_Sleep(int ms); +void I_Sleep(int ms); // [FG] let the CPU sleep void I_ReadScreen (byte* scr); @@ -59,14 +59,14 @@ int I_DoomCode2ScanCode(int); // killough int I_ScanCode2DoomCode(int); // killough void I_ResetScreen(void); // killough 10/98 -void I_ToggleToggleFullScreen(void); +void I_ToggleToggleFullScreen(void); // [FG] fullscreen mode menu toggle extern int use_vsync; // killough 2/8/98: controls whether vsync is called extern int page_flip; // killough 8/15/98: enables page flipping (320x200) extern int disk_icon; // killough 10/98 extern int hires; // killough 11/98 -boolean I_WritePNGfile(char *filename); +boolean I_WritePNGfile(char *filename); // [FG] screenshots in PNG format #endif diff --git a/Source/m_cheat.c b/Source/m_cheat.c index 417f9fc9..ab2e14ef 100644 --- a/Source/m_cheat.c +++ b/Source/m_cheat.c @@ -715,7 +715,7 @@ boolean M_FindCheats(int key) for (i=0;cheat[i].cheat;i++) { ULong64 c=0, m=0; - const char *p; + const char *p; // [FG] char! for (p=cheat[i].cheat; *p; p++) { unsigned key = tolower(*p)-'a'; // convert to 0-31 diff --git a/Source/m_cheat.h b/Source/m_cheat.h index ea32dee6..ae386d86 100644 --- a/Source/m_cheat.h +++ b/Source/m_cheat.h @@ -34,7 +34,7 @@ // killough 4/16/98: Cheat table structure extern struct cheat_s { - const char *cheat; + const char *cheat; // [FG] char! const char *const deh_cheat; enum { always = 0, diff --git a/Source/m_fixed.h b/Source/m_fixed.h index 9cfee42c..95864ffc 100644 --- a/Source/m_fixed.h +++ b/Source/m_fixed.h @@ -57,6 +57,7 @@ inline static fixed_t FixedMul(fixed_t a, fixed_t b) inline static fixed_t FixedDiv(fixed_t a, fixed_t b) { + // [FG] avoid 31-bit shift (from Chocolate Doom) return (abs(a)>>14) >= abs(b) ? ((a^b) < 0 ? D_MININT : D_MAXINT) : (fixed_t)(((Long64) a << FRACBITS) / b); } diff --git a/Source/m_menu.c b/Source/m_menu.c index c1a7d411..fca6170c 100644 --- a/Source/m_menu.c +++ b/Source/m_menu.c @@ -3729,7 +3729,7 @@ void M_ExtHelp(int choice) void M_DrawExtHelp(void) { - char namebfr[] = "HELPnn"; + char namebfr[] = "HELPnn"; // [FG] char array! inhelpscreens = true; // killough 5/1/98 namebfr[4] = extended_help_index/10 + 0x30; @@ -4199,7 +4199,7 @@ boolean M_Responder (event_t* ev) joywait = I_GetTime() + 5; } - // [FG] Menu joystick button + // [FG] main menu joystick button if (joybmainmenu > -1 && (ev->data1 & (1 << joybmainmenu))) { ch = menuactive ? key_menu_escape : key_escape; @@ -5632,12 +5632,14 @@ void M_Init(void) M_InitExtendedHelp(); // init extended help screens // phares 3/30/98 // [FG] support the BFG Edition IWADs + if (bfgedition) { strcpy(OptionsMenu[scrnsize].name, "M_DISP"); } // [FG] save screenshots in PNG format + if (SavePNG) { const char *bmp_text, *png_text; diff --git a/Source/m_misc.c b/Source/m_misc.c index c3e50eb3..7cda186f 100644 --- a/Source/m_misc.c +++ b/Source/m_misc.c @@ -91,7 +91,7 @@ extern int forceFlipPan; extern int grabmouse; extern int cfg_scalefactor; // haleyjd 05/11/09 extern int cfg_aspectratio; // haleyjd 05/11/09 -extern int fullscreen; +extern int fullscreen; // [FG] save fullscren mode extern char *chat_macros[], *wad_files[], *deh_files[]; // killough 10/98 @@ -663,7 +663,8 @@ default_t defaults[] = { "key to select from menu or review past messages" }, - { // [FG] clear key bindings with the DEL key + // [FG] clear key bindings with the DEL key + { "key_menu_clear", (config_t *) &key_menu_clear, NULL, {KEYD_DEL}, {0,255}, number, ss_keys, wad_no, @@ -964,7 +965,8 @@ default_t defaults[] = { "key to toggle between two most preferred weapons with ammo" }, - { // [FG] prev/next weapon keys and buttons + // [FG] prev/next weapon keys and buttons + { "key_prevweapon", (config_t *) &key_prevweapon, NULL, {0}, {0,255}, number, ss_keys, wad_no, @@ -1090,7 +1092,8 @@ default_t defaults[] = { "mouse button number to use for forward motion (-1 = disable)" }, //jff 3/8/98 end of lower range change for -1 allowed in mouse binding - { // [FG] prev/next weapon keys and buttons + // [FG] prev/next weapon keys and buttons + { "mouseb_prevweapon", (config_t *) &mousebprevweapon, NULL, {4}, {-1,MAX_MB-1}, number, ss_keys, wad_no, @@ -1139,7 +1142,8 @@ default_t defaults[] = { "joystick button number to use for use/open" }, - { // [FG] strafe left/right joystick buttons + // [FG] strafe left/right joystick buttons + { "joyb_strafeleft", (config_t *) &joybstrafeleft, NULL, {4}, {-1,MAX_JSB-1}, 0, ss_keys, wad_no, @@ -1153,7 +1157,8 @@ default_t defaults[] = { "joystick button number to strafe right (sideways right)" }, - { // [FG] prev/next weapon joystick buttons + // [FG] prev/next weapon joystick buttons + { "joyb_prevweapon", (config_t *) &joybprevweapon, NULL, {2}, {-1,MAX_JSB-1}, 0, ss_keys, wad_no, @@ -1167,14 +1172,16 @@ default_t defaults[] = { "joystick button number to cycle to the next weapon" }, - { // [FG] automap joystick button + // [FG] automap joystick button + { "joyb_automap", (config_t *) &joybautomap, NULL, {-1}, {-1,MAX_JSB-1}, 0, ss_keys, wad_no, "joystick button number to open the automap" }, - { // [FG] main menu joystick button + // [FG] main menu joystick button + { "joyb_mainmenu", (config_t *) &joybmainmenu, NULL, {-1}, {-1,MAX_JSB-1}, 0, ss_keys, wad_no, @@ -1751,6 +1758,7 @@ default_t defaults[] = { "1 to perform aspect ratio correction" }, + // [FG] save fullscren mode { "fullscreen", (config_t *) &fullscreen, NULL, @@ -2439,6 +2447,7 @@ boolean WriteBMPfile(char *filename, byte *data, int width, } // [FG] save screenshots in PNG format + boolean WritePNGfile(char *filename, byte *data, int width, int height, byte *palette) { @@ -2467,7 +2476,7 @@ void M_ScreenShot (void) do sprintf(lbmname, //jff 3/30/98 pcx or bmp? - screenshot_pcx ? "doom%02d.pcx" : (SavePNG ? "doom%02d.png" : "doom%02d.bmp"), shot++); + screenshot_pcx ? "doom%02d.pcx" : (SavePNG ? "doom%02d.png" : "doom%02d.bmp"), shot++); // [FG] PNG while (!access(lbmname,0) && --tries); if (tries) @@ -2485,7 +2494,7 @@ void M_ScreenShot (void) // killough 10/98: detect failure and remove file if error // killough 11/98: add hires support - if (!(success = (screenshot_pcx ? WritePCXfile : (SavePNG ? WritePNGfile : WriteBMPfile)) + if (!(success = (screenshot_pcx ? WritePCXfile : (SavePNG ? WritePNGfile : WriteBMPfile)) // [FG] PNG (lbmname,linear, SCREENWIDTH< diff --git a/Source/m_misc2.h b/Source/m_misc2.h index 1d84d4fc..adbeaf19 100644 --- a/Source/m_misc2.h +++ b/Source/m_misc2.h @@ -13,7 +13,7 @@ // GNU General Public License for more details. // // DESCRIPTION: -// Miscellaneous helper functions from Chocolate Doom. +// [FG] miscellaneous helper functions from Chocolate Doom. // #ifndef __M_MISC2__ diff --git a/Source/m_swap.h b/Source/m_swap.h index 9c42da3b..1c724870 100644 --- a/Source/m_swap.h +++ b/Source/m_swap.h @@ -29,7 +29,7 @@ #ifndef __M_SWAP__ #define __M_SWAP__ -#include "doomtype.h" +#include "doomtype.h" // [FG] inline // Endianess handling. // WAD files are stored little endian. diff --git a/Source/mmus2mid.c b/Source/mmus2mid.c index 2f9852a8..56f77409 100644 --- a/Source/mmus2mid.c +++ b/Source/mmus2mid.c @@ -601,6 +601,7 @@ int MidiToMIDI(UBYTE *mid,MIDI *mididata) return 0; } +// [FG] disable dead static code #if 0 //#ifdef STANDALONE /* this code unused by BOOM provided for future portability */ // /* it also provides a MUS to MID file converter*/ @@ -758,6 +759,7 @@ int main(int argc,char **argv) musst = fopen(musfile,"rb"); if (musst) { + // [FG] check return value if(!fread(&MUSh,sizeof(MUSheader),1,musst)) { printf("Error reading MUS file\n"); diff --git a/Source/p_enemy.c b/Source/p_enemy.c index b5209a7d..e33ee236 100644 --- a/Source/p_enemy.c +++ b/Source/p_enemy.c @@ -246,7 +246,7 @@ static boolean P_CheckMissileRange(mobj_t *actor) static boolean P_IsOnLift(const mobj_t *actor) { const sector_t *sec = actor->subsector->sector; - line_t line = {0}; + line_t line = {0}; // [FG] initialize int l; // Short-circuit: it's on a lift which is active. @@ -2577,6 +2577,7 @@ void A_LineEffect(mobj_t *mo) line_t junk = *lines; // Fake linedef set to 1st if ((junk.special = (short)mo->state->misc1)) // Linedef type { + // [FG] made static static player_t player; // Remember player status player_t *oldplayer = mo->player; // Remember player status mo->player = &player; // Fake player diff --git a/Source/p_setup.c b/Source/p_setup.c index 21dd92b9..4de22c88 100644 --- a/Source/p_setup.c +++ b/Source/p_setup.c @@ -164,12 +164,13 @@ void P_LoadSegs (int lump) int side, linedef; line_t *ldef; + // [FG] extended nodes li->v1 = &vertexes[(unsigned short)SHORT(ml->v1)]; li->v2 = &vertexes[(unsigned short)SHORT(ml->v2)]; li->angle = (SHORT(ml->angle))<<16; li->offset = (SHORT(ml->offset))<<16; - linedef = (unsigned short)SHORT(ml->linedef); + linedef = (unsigned short)SHORT(ml->linedef); // [FG] extended nodes ldef = &lines[linedef]; li->linedef = ldef; side = SHORT(ml->side); @@ -204,6 +205,7 @@ void P_LoadSubsectors (int lump) for (i=0; ichildren[j] = (unsigned short)SHORT(mn->children[j]); + no->children[j] = (unsigned short)SHORT(mn->children[j]); // [FG] extended nodes // [FG] extended nodes if (no->children[j] == 0xFFFF) @@ -407,6 +409,7 @@ void P_LoadLineDefs (int lump) line_t *ld = lines+i; vertex_t *v1, *v2; + // [FG] extended nodes ld->flags = (unsigned short)SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); diff --git a/Source/p_sight.c b/Source/p_sight.c index 48c0e8e3..ad78e455 100644 --- a/Source/p_sight.c +++ b/Source/p_sight.c @@ -54,7 +54,7 @@ typedef struct { int P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) { - fixed_t left = 0, right = 0; + fixed_t left = 0, right = 0; // [FG] initialize return !node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 : !node->dy ? x == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 : diff --git a/Source/p_spec.c b/Source/p_spec.c index a060e245..a24e25b9 100644 --- a/Source/p_spec.c +++ b/Source/p_spec.c @@ -71,6 +71,7 @@ typedef struct // typedef PACKED_STRUCT ( { + // [FG] signed char! signed char istexture; //jff 3/23/98 make char for comparison char endname[9]; // if false, it is a flat char startname[9]; diff --git a/Source/r_data.c b/Source/r_data.c index 49d023a2..d0369694 100644 --- a/Source/r_data.c +++ b/Source/r_data.c @@ -772,7 +772,7 @@ void R_InitTranMap(int progress) char fname[PATH_MAX+1], *D_DoomPrefDir(void); struct { unsigned char pct; - unsigned char playpal[256*3]; + unsigned char playpal[256*3]; // [FG] a palette has 256 colors saved as byte triples } cache; FILE *cachefp = fopen(strcat(strcpy(fname, D_DoomPrefDir()), "/tranmap.dat"),"r+b"); @@ -781,7 +781,7 @@ void R_InitTranMap(int progress) // Use cached translucency filter if it's available - if (!cachefp ? cachefp = fopen(fname,"w+b") , 1 : + if (!cachefp ? cachefp = fopen(fname,"w+b") , 1 : // [FG] open for writing and reading fread(&cache, 1, sizeof cache, cachefp) != sizeof cache || cache.pct != tran_filter_pct || memcmp(cache.playpal, playpal, sizeof cache.playpal) || @@ -853,7 +853,7 @@ void R_InitTranMap(int progress) if (cachefp) // write out the cached translucency map { cache.pct = tran_filter_pct; - memcpy(cache.playpal, playpal, sizeof cache.playpal); + memcpy(cache.playpal, playpal, sizeof cache.playpal); // [FG] a palette has 256 colors saved as byte triples fseek(cachefp, 0, SEEK_SET); fwrite(&cache, 1, sizeof cache, cachefp); fwrite(main_tranmap, 256, 256, cachefp); diff --git a/Source/r_defs.h b/Source/r_defs.h index dba94a4d..8b7273d7 100644 --- a/Source/r_defs.h +++ b/Source/r_defs.h @@ -181,9 +181,11 @@ typedef struct line_s { vertex_t *v1, *v2; // Vertices, from v1 to v2. fixed_t dx, dy; // Precalculated v2 - v1 for side checking. + // [FG] extended nodes unsigned short flags; // Animation related. short special; short tag; + // [FG] extended nodes unsigned short sidenum[2]; // Visual appearance: SideDefs. fixed_t bbox[4]; // A bounding box, for the linedef's extent slopetype_t slopetype; // To aid move clipping. @@ -206,7 +208,7 @@ typedef struct line_s typedef struct subsector_s { sector_t *sector; - int numlines, firstline; + int numlines, firstline; // [FG] extended nodes } subsector_t; // phares 3/14/98 @@ -262,6 +264,7 @@ typedef struct { fixed_t x, y, dx, dy; // Partition line. fixed_t bbox[2][4]; // Bounding box for each child. + // [FG] extended nodes int children[2]; // If NF_SUBSECTOR its a subsector. } node_t; diff --git a/Source/version.c b/Source/version.c index 321f770a..672de840 100644 --- a/Source/version.c +++ b/Source/version.c @@ -7,6 +7,7 @@ #include "version.h" +// [FG] allow to build reproducibly #ifndef BUILD_DATE #define BUILD_DATE __DATE__ #endif diff --git a/Source/w_wad.c b/Source/w_wad.c index 2dc04d60..8aba08fb 100644 --- a/Source/w_wad.c +++ b/Source/w_wad.c @@ -181,6 +181,7 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const else { // WAD file + // [FG] check return value if (!read(handle, &header, sizeof(header))) I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename); if (strncmp(header.identification,"IWAD",4) && @@ -191,6 +192,7 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const length = header.numlumps*sizeof(filelump_t); fileinfo2free = fileinfo = malloc(length); // killough lseek(handle, header.infotableofs, SEEK_SET); + // [FG] check return value if (!read(handle, fileinfo, length)) I_Error("Error reading lump directory from %s\n", filename); numlumps += header.numlumps; @@ -320,7 +322,7 @@ unsigned W_LumpNameHash(const char *s) // between different resources such as flats, sprites, colormaps // -int (W_CheckNumForName)(register const char *name, register int name_space) +int (W_CheckNumForName)(register const char *name, register int name_space) // [FG] namespace is reserved in C++ { // Hash function maps the name to one of possibly numlump chains. // It has been tuned so that the average chain length never exceeds 2.