From 57a9f56e2cba50249ee8a96533c8baed47814f92 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 10 Dec 2010 23:56:32 +0000 Subject: Fix memory leak when dynamically resizing window in true color video modes. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2215 --- src/i_video.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 488c08a0..ad4d7f39 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -97,7 +97,7 @@ static SDL_Surface *screen; // This is used when we are rendering in 32-bit screen mode. // When in a real 8-bit screen mode, screenbuffer == screen. -static SDL_Surface *screenbuffer; +static SDL_Surface *screenbuffer = NULL; // palette @@ -1646,6 +1646,14 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h) doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); + // If we are already running and in a true color mode, we need + // to free the screenbuffer surface before setting the new mode. + + if (screenbuffer != NULL && screen != screenbuffer) + { + SDL_FreeSurface(screenbuffer); + } + // Generate lookup tables before setting the video mode. if (mode != NULL && mode->InitMode != NULL) -- cgit v1.2.3 From 1ef81eb5f7c336972fe56f15285f389cafdc96f5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 14 Dec 2010 20:55:30 +0000 Subject: Check that an address is provided to the -query command line option (thanks Sander van Dijk). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2221 --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index 032c5caa..36382fb6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -868,7 +868,7 @@ void D_DoomMain (void) p = M_CheckParm("-query"); - if (p > 0) + if (p && p < myargc-1) { NET_QueryAddress(myargv[p+1]); exit(0); -- cgit v1.2.3 From 463bcf013ce355398974953508d232ac88a6b2d6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 18 Dec 2010 23:55:07 +0000 Subject: Add a M_CheckParmWithArgs function, that behaves like M_CheckParm but also checks that extra options were provided on the command line (thanks Sander van Dijk). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2223 --- src/d_iwad.c | 2 +- src/d_main.c | 62 ++++++++++++++++++++++++++++---------------------------- src/d_net.c | 2 +- src/g_game.c | 4 ++-- src/i_system.c | 2 +- src/i_video.c | 8 ++++---- src/m_argv.c | 13 ++++++++---- src/m_argv.h | 4 ++++ src/m_config.c | 8 ++++---- src/net_client.c | 4 ++-- src/net_sdl.c | 4 ++-- src/net_server.c | 4 ++-- src/p_map.c | 2 +- src/p_spec.c | 4 ++-- 14 files changed, 66 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/d_iwad.c b/src/d_iwad.c index 89a7fba3..c0d33707 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -658,7 +658,7 @@ char *D_FindIWAD(void) // @arg // - iwadparm = M_CheckParm("-iwad"); + iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { diff --git a/src/d_main.c b/src/d_main.c index 36382fb6..465ed45b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -672,9 +672,9 @@ static void InitGameVersion(void) // "ultimate" and "final". // - p = M_CheckParm("-gameversion"); + p = M_CheckParmWithArgs("-gameversion", 1); - if (p > 0) + if (p) { for (i=0; gameversions[i].description != NULL; ++i) { @@ -866,9 +866,9 @@ void D_DoomMain (void) // address. // - p = M_CheckParm("-query"); + p = M_CheckParmWithArgs("-query", 1); - if (p && p < myargc-1) + if (p) { NET_QueryAddress(myargv[p+1]); exit(0); @@ -1019,7 +1019,7 @@ void D_DoomMain (void) // into the main IWAD. Multiple files may be specified. // - p = M_CheckParm("-merge"); + p = M_CheckParmWithArgs("-merge", 1); if (p > 0) { @@ -1045,7 +1045,7 @@ void D_DoomMain (void) // Simulates the behavior of NWT's -merge option. Multiple files // may be specified. - p = M_CheckParm("-nwtmerge"); + p = M_CheckParmWithArgs("-nwtmerge", 1); if (p > 0) { @@ -1070,7 +1070,7 @@ void D_DoomMain (void) // the main IWAD directory. Multiple files may be specified. // - p = M_CheckParm("-af"); + p = M_CheckParmWithArgs("-af", 1); if (p > 0) { @@ -1093,7 +1093,7 @@ void D_DoomMain (void) // into the main IWAD directory. Multiple files may be specified. // - p = M_CheckParm("-as"); + p = M_CheckParmWithArgs("-as", 1); if (p > 0) { @@ -1115,7 +1115,7 @@ void D_DoomMain (void) // Equivalent to "-af -as ". // - p = M_CheckParm("-aa"); + p = M_CheckParmWithArgs("-aa", 1); if (p > 0) { @@ -1139,7 +1139,7 @@ void D_DoomMain (void) // Load the specified PWAD files. // - p = M_CheckParm ("-file"); + p = M_CheckParmWithArgs("-file", 1); if (p) { // the parms after p are wadfile/lump names, @@ -1163,7 +1163,7 @@ void D_DoomMain (void) // // convenience hack to allow -wart e m to add a wad file // prepend a tilde to the filename so wadfile will be reloadable - p = M_CheckParm ("-wart"); + p = M_CheckParmWithArgs("-wart", 1); if (p) { myargv[p][4] = 'p'; // big hack, change to -warp @@ -1200,7 +1200,7 @@ void D_DoomMain (void) // Play back the demo named demo.lmp. // - p = M_CheckParm ("-playdemo"); + p = M_CheckParmWithArgs ("-playdemo", 1); if (!p) { @@ -1212,11 +1212,11 @@ void D_DoomMain (void) // Play back the demo named demo.lmp, determining the framerate // of the screen. // - p = M_CheckParm ("-timedemo"); + p = M_CheckParmWithArgs("-timedemo", 1); } - if (p && p < myargc-1) + if (p) { if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp")) { @@ -1296,9 +1296,9 @@ void D_DoomMain (void) // 0 disables all monsters. // - p = M_CheckParm ("-skill"); + p = M_CheckParmWithArgs("-skill", 1); - if (p && p < myargc-1) + if (p) { startskill = myargv[p+1][0]-'1'; autostart = true; @@ -1311,9 +1311,9 @@ void D_DoomMain (void) // Start playing on episode n (1-4) // - p = M_CheckParm ("-episode"); + p = M_CheckParmWithArgs("-episode", 1); - if (p && p < myargc-1) + if (p) { startepisode = myargv[p+1][0]-'0'; startmap = 1; @@ -1330,9 +1330,9 @@ void D_DoomMain (void) // For multiplayer games: exit each level after n minutes. // - p = M_CheckParm ("-timer"); + p = M_CheckParmWithArgs("-timer", 1); - if (p && p < myargc-1) + if (p) { timelimit = atoi(myargv[p+1]); } @@ -1346,7 +1346,7 @@ void D_DoomMain (void) p = M_CheckParm ("-avg"); - if (p && p < myargc-1) + if (p) { timelimit = 20; } @@ -1359,9 +1359,9 @@ void D_DoomMain (void) // (Doom 2) // - p = M_CheckParm ("-warp"); + p = M_CheckParmWithArgs("-warp", 1); - if (p && p < myargc-1) + if (p) { if (gamemode == commercial) startmap = atoi (myargv[p+1]); @@ -1405,9 +1405,9 @@ void D_DoomMain (void) // Load the game in slot s. // - p = M_CheckParm ("-loadgame"); + p = M_CheckParmWithArgs("-loadgame", 1); - if (p && p < myargc-1) + if (p) { startloadgame = atoi(myargv[p+1]); } @@ -1507,24 +1507,24 @@ void D_DoomMain (void) // Record a demo named x.lmp. // - p = M_CheckParm ("-record"); + p = M_CheckParmWithArgs("-record", 1); - if (p && p < myargc-1) + if (p) { G_RecordDemo (myargv[p+1]); autostart = true; } - p = M_CheckParm ("-playdemo"); - if (p && p < myargc-1) + p = M_CheckParmWithArgs("-playdemo", 1); + if (p) { singledemo = true; // quit after one demo G_DeferedPlayDemo (demolumpname); D_DoomLoop (); // never returns } - p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) + p = M_CheckParmWithArgs("-timedemo", 1); + if (p) { G_TimeDemo (demolumpname); D_DoomLoop (); // never returns diff --git a/src/d_net.c b/src/d_net.c index ae5a6d62..57fe2399 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -317,7 +317,7 @@ void D_CheckNetGame (void) // address. // - i = M_CheckParm("-connect"); + i = M_CheckParmWithArgs("-connect", 1); if (i > 0) { diff --git a/src/g_game.c b/src/g_game.c index 59550513..7790b83e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2068,8 +2068,8 @@ void G_RecordDemo (char* name) // Specify the demo buffer size (KiB) // - i = M_CheckParm ("-maxdemo"); - if (i && i 0) { diff --git a/src/i_video.c b/src/i_video.c index ad4d7f39..55fd21e1 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1442,7 +1442,7 @@ static void CheckCommandLine(void) // Specify the screen width, in pixels. // - i = M_CheckParm("-width"); + i = M_CheckParmWithArgs("-width", 1); if (i > 0) { @@ -1456,7 +1456,7 @@ static void CheckCommandLine(void) // Specify the screen height, in pixels. // - i = M_CheckParm("-height"); + i = M_CheckParmWithArgs("-height", 1); if (i > 0) { @@ -1470,7 +1470,7 @@ static void CheckCommandLine(void) // Specify the color depth of the screen, in bits per pixel. // - i = M_CheckParm("-bpp"); + i = M_CheckParmWithArgs("-bpp", 1); if (i > 0) { @@ -1497,7 +1497,7 @@ static void CheckCommandLine(void) // Specify the screen mode (when running fullscreen) or the window // dimensions (when running in windowed mode). - i = M_CheckParm("-geometry"); + i = M_CheckParmWithArgs("-geometry", 1); if (i > 0) { diff --git a/src/m_argv.c b/src/m_argv.c index 99295c6d..4d321bbc 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -47,19 +47,24 @@ char** myargv; // or 0 if not present // -int M_CheckParm (char *check) +int M_CheckParmWithArgs(char *check, int num_args) { - int i; + int i; - for (i = 1;i 0) settings.extratics = atoi(myargv[i+1]); @@ -426,7 +426,7 @@ void NET_CL_StartGame(void) // the amount of network bandwidth needed. // - i = M_CheckParm("-dup"); + i = M_CheckParmWithArgs("-dup", 1); if (i > 0) settings.ticdup = atoi(myargv[i+1]); diff --git a/src/net_sdl.c b/src/net_sdl.c index 9c647cc9..2589540d 100644 --- a/src/net_sdl.c +++ b/src/net_sdl.c @@ -170,7 +170,7 @@ static boolean NET_SDL_InitClient(void) // the default (2342). // - p = M_CheckParm("-port"); + p = M_CheckParmWithArgs("-port", 1); if (p > 0) port = atoi(myargv[p+1]); @@ -196,7 +196,7 @@ static boolean NET_SDL_InitServer(void) { int p; - p = M_CheckParm("-port"); + p = M_CheckParmWithArgs("-port", 1); if (p > 0) port = atoi(myargv[p+1]); diff --git a/src/net_server.c b/src/net_server.c index 4307e2e2..b3a9ea92 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1121,9 +1121,9 @@ void NET_SV_SendQueryResponse(net_addr_t *addr) // When starting a network server, specify a name for the server. // - p = M_CheckParm("-servername"); + p = M_CheckParmWithArgs("-servername", 1); - if (p > 0 && p + 1 < myargc) + if (p > 0) { querydata.description = myargv[p + 1]; } diff --git a/src/p_map.c b/src/p_map.c index b50fff2c..1ac76349 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1426,7 +1426,7 @@ static void SpechitOverrun(line_t *ld) // Use the specified magic value when emulating spechit overruns. // - p = M_CheckParm("-spechit"); + p = M_CheckParmWithArgs("-spechit", 1); if (p > 0) { diff --git a/src/p_spec.c b/src/p_spec.c index fa3ec335..90d0bb7c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1213,9 +1213,9 @@ static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic, // system. The default (if this option is not specified) is to // emulate the behavior when running under Windows 98. - p = M_CheckParm("-donut"); + p = M_CheckParmWithArgs("-donut", 2); - if (p > 0 && p < myargc - 2) + if (p > 0) { // Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008 // -- cgit v1.2.3 From c67b4c15dc32f9824951f37c9b1fa665b7d1307f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 25 Dec 2010 20:55:30 +0000 Subject: Remove the 32 character limit on the lengths of filenames specified to -record (thanks AlexXav). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2225 --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index 7790b83e..f91e630e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -139,7 +139,7 @@ int gametic; int levelstarttic; // gametic at level start int totalkills, totalitems, totalsecret; // for intermission -char demoname[32]; +char *demoname; boolean demorecording; boolean longtics; // cph's doom 1.91 longtics hack boolean lowres_turn; // low resolution turning for longtics @@ -2050,14 +2050,14 @@ void G_WriteDemoTiccmd (ticcmd_t* cmd) // // G_RecordDemo // -void G_RecordDemo (char* name) +void G_RecordDemo (char *name) { int i; int maxsize; usergame = false; - strcpy (demoname, name); - strcat (demoname, ".lmp"); + demoname = Z_Malloc(strlen(name) + 5, PU_STATIC, NULL); + sprintf(demoname, "%s.lmp", name); maxsize = 0x20000; //! -- cgit v1.2.3 From a854f3e246be1373200a296413b31ece296c2914 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 25 Dec 2010 21:04:10 +0000 Subject: Remove the -wart parameter (thanks Sander van Dijk). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2226 --- src/d_main.c | 34 ---------------------------------- src/dstrings.h | 9 --------- 2 files changed, 43 deletions(-) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index 465ed45b..397062a9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1158,40 +1158,6 @@ void D_DoomMain (void) // Debug: // W_PrintDirectory(); - // add any files specified on the command line with -file wadfile - // to the wad list - // - // convenience hack to allow -wart e m to add a wad file - // prepend a tilde to the filename so wadfile will be reloadable - p = M_CheckParmWithArgs("-wart", 1); - if (p) - { - myargv[p][4] = 'p'; // big hack, change to -warp - - // Map name handling. - switch (gamemode ) - { - case shareware: - case retail: - case registered: - sprintf (file,"~"DEVMAPS"E%cM%c.wad", - myargv[p+1][0], myargv[p+2][0]); - printf("Warping to Episode %s, Map %s.\n", - myargv[p+1],myargv[p+2]); - break; - - case commercial: - default: - p = atoi (myargv[p+1]); - if (p<10) - sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p); - else - sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p); - break; - } - D_AddFile (file); - } - //! // @arg // @category demo diff --git a/src/dstrings.h b/src/dstrings.h index bdc6b2ce..d47fc1af 100644 --- a/src/dstrings.h +++ b/src/dstrings.h @@ -38,15 +38,6 @@ #define SAVEGAMENAME "doomsav" -// -// File locations, -// relative to current position. -// Path names are OS-sensitive. -// -#define DEVMAPS "devmaps" -#define DEVDATA "devdata" - - // QuitDOOM messages // 8 per each game type #define NUM_QUITMESSAGES 8 -- cgit v1.2.3 From fc09dbdf6703e62146a74a164be475ba965d00ab Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 28 Dec 2010 16:43:41 +0000 Subject: Make demo loop handling of DEMO4 case depend on the executable version being emulated: the Vanilla versions did not have any conditional behavior based on gamemode/gamemission. This has the side effect of causing the game to exit with an error when playing with Final Doom, but this is Vanilla behavior. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2230 --- src/d_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index 397062a9..73978c2f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -494,7 +494,13 @@ void D_DoAdvanceDemo (void) paused = false; gameaction = ga_nothing; - if (gamemode == retail && gameversion != exe_chex) + // The Ultimate Doom executable changed the demo sequence to add + // a DEMO4 demo. Final Doom was based on Ultimate, so also + // includes this change; however, the Final Doom IWADs do not + // include a DEMO4 lump, so the game bombs out with an error + // when it reaches this point in the demo sequence. + + if (gameversion == exe_ultimate || gameversion == exe_final) demosequence = (demosequence+1)%7; else demosequence = (demosequence+1)%6; -- cgit v1.2.3 From e63839de20c56649ce16adfe7e849735223ad130 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 2 Jan 2011 02:31:20 +0000 Subject: Turn off dynamic window resizing feature on OS X, as it adds an ugly resize handle to the corner of the window that overlaps the view of the game. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2231 --- src/i_video.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 55fd21e1..cd5d2ace 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1676,7 +1676,13 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h) } else { + // In windowed mode, the window can be resized while the game is + // running. This feature is disabled on OS X, as it adds an ugly + // scroll handle to the corner of the screen. + +#ifndef __MACOSX__ flags |= SDL_RESIZABLE; +#endif } screen = SDL_SetVideoMode(w, h, screen_bpp, flags); -- cgit v1.2.3 From 5130b54658ab03f3fc18727615b529d6e241566c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 12 Jan 2011 23:22:20 +0000 Subject: Fix menu navigation when using joystick / joypad (thanks AlexXav). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2237 --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/m_menu.c b/src/m_menu.c index 7b1c5a6e..efc4fefe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1450,23 +1450,23 @@ boolean M_Responder (event_t* ev) if (ev->type == ev_joystick && joywait < I_GetTime()) { - if (ev->data3 == -1) + if (ev->data3 < 0) { key = key_menu_up; joywait = I_GetTime() + 5; } - else if (ev->data3 == 1) + else if (ev->data3 > 0) { key = key_menu_down; joywait = I_GetTime() + 5; } - if (ev->data2 == -1) + if (ev->data2 < 0) { key = key_menu_left; joywait = I_GetTime() + 2; } - else if (ev->data2 == 1) + else if (ev->data2 > 0) { key = key_menu_right; joywait = I_GetTime() + 2; -- cgit v1.2.3 From ec169fd1c28b2ba3b6b6fc7e7123e9d27516dd5f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 13 Jan 2011 20:34:55 +0000 Subject: In configuration files, use the scan code for right shift, not left shift, to match Vanilla (thanks AlexXav). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2238 --- src/m_config.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index 332b8b95..04d0a963 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -1217,8 +1217,18 @@ static void SaveDefaultCollection(default_collection_t *collection) v = * (int *) defaults[i].location; - if (defaults[i].untranslated - && v == defaults[i].original_translated) + if (v == KEY_RSHIFT) + { + // Special case: for shift, force scan code for + // right shift, as this is what Vanilla uses. + // This overrides the change check below, to fix + // configuration files made by old versions that + // mistakenly used the scan code for left shift. + + v = 54; + } + else if (defaults[i].untranslated + && v == defaults[i].original_translated) { // Has not been changed since the last time we // read the config file. -- cgit v1.2.3