From f1596273a3e991448ca7e04415a74f916b2c9810 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 20 Jul 2009 00:37:41 +0000 Subject: Save and display the loading disk icon as a fixed 16x16 square, from an image drawn at the bottom right corner of the screen. This seems to be the same as how Vanilla behaves, and fixes chook3.wad, that uses an STDISK replacement with an offset that pushes the image to the left. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1629 --- src/i_video.c | 65 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 3412051b..582a7fa7 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -50,6 +50,9 @@ #include "w_wad.h" #include "z_zone.h" +#define LOADING_DISK_W 16 +#define LOADING_DISK_H 16 + // Non aspect ratio-corrected modes (direct multiples of 320x200) static screen_mode_t *screen_modes[] = { @@ -145,7 +148,6 @@ boolean screenvisible; // restored by EndRead static byte *disk_image = NULL; -static int disk_image_w, disk_image_h; static byte *saved_background; static boolean window_focused; @@ -258,6 +260,8 @@ static void LoadDiskImage(void) patch_t *disk; char *disk_name; int y; + int xoffset = SCREENWIDTH - LOADING_DISK_W; + int yoffset = SCREENHEIGHT - LOADING_DISK_H; char buf[20]; SDL_VideoDriverName(buf, 15); @@ -278,19 +282,20 @@ static void LoadDiskImage(void) disk = W_CacheLumpName(disk_name, PU_STATIC); - V_DrawPatch(0, 0, 0, disk); - disk_image_w = SHORT(disk->width); - disk_image_h = SHORT(disk->height); + // Draw the disk to the screen: + + V_DrawPatch(SCREENWIDTH - LOADING_DISK_W, + SCREENHEIGHT - LOADING_DISK_H, + 0, disk); - disk_image = Z_Malloc(disk_image_w * disk_image_h, PU_STATIC, NULL); - saved_background = Z_Malloc(disk_image_w * disk_image_h, PU_STATIC, NULL); + disk_image = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); + saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL); - for (y=0; y -typedef BOOL WINAPI (*SetAffinityFunc)(HANDLE hProcess, DWORD_PTR mask); +typedef BOOL (WINAPI *SetAffinityFunc)(HANDLE hProcess, DWORD mask); // This is a bit more complicated than it really needs to be. We really // just need to call the SetProcessAffinityMask function, but that @@ -74,7 +74,7 @@ static void LockCPUAffinity(void) // Find the SetProcessAffinityMask function. - SetAffinity = GetProcAddress(kernel32_dll, "SetProcessAffinityMask"); + SetAffinity = (SetAffinityFunc)GetProcAddress(kernel32_dll, "SetProcessAffinityMask"); // If the function was not found, we are on an old (Win9x) system // that doesn't have this function. That's no problem, because diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index bb8229e4..ea5c92a5 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -275,12 +275,15 @@ static boolean LoadSoundLump(int sound, uint32_t *length, byte **data_ref) { + int lumplen; + byte *data; + // Load the sound *lumpnum = S_sfx[sound].lumpnum; *data_ref = W_CacheLumpNum(*lumpnum, PU_STATIC); - int lumplen = W_LumpLength(*lumpnum); - byte *data = *data_ref; + lumplen = W_LumpLength(*lumpnum); + data = *data_ref; // Ensure this is a valid sound -- cgit v1.2.3 From 410579ec66f7df8757cb980c0a78e3161b7f20d5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 30 Sep 2009 23:07:03 +0000 Subject: Change British English spellings to American English, for consistency. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1699 --- src/d_iwad.c | 2 +- src/d_iwad.h | 2 +- src/d_main.c | 4 ++-- src/d_net.h | 2 +- src/deh_defs.h | 2 +- src/deh_main.c | 4 ++-- src/deh_ptr.c | 2 +- src/deh_text.c | 2 +- src/doomdef.h | 2 +- src/i_joystick.c | 2 +- src/i_pcsound.c | 18 +++++++++--------- src/i_sdlmusic.c | 44 ++++++++++++++++++++++---------------------- src/i_sdlsound.c | 18 +++++++++--------- src/i_timer.c | 2 +- src/i_timer.h | 2 +- src/i_video.c | 22 ++++++++++++---------- src/net_client.c | 4 ++-- src/net_common.c | 4 ++-- src/net_defs.h | 4 ++-- src/net_gui.c | 2 +- src/net_loop.c | 4 ++-- src/net_sdl.c | 2 +- src/net_server.c | 14 +++++++------- src/net_server.h | 2 +- src/s_sound.c | 10 +++++----- src/s_sound.h | 6 +++--- src/w_merge.c | 2 +- 27 files changed, 93 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/d_iwad.c b/src/d_iwad.c index d1c2f0bf..0e48420d 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -19,7 +19,7 @@ // 02111-1307, USA. // // DESCRIPTION: -// Search for and locate an IWAD file, and initialise according +// Search for and locate an IWAD file, and initialize according // to the IWAD type. // //----------------------------------------------------------------------------- diff --git a/src/d_iwad.h b/src/d_iwad.h index 281d3467..cb101305 100644 --- a/src/d_iwad.h +++ b/src/d_iwad.h @@ -19,7 +19,7 @@ // 02111-1307, USA. // // DESCRIPTION: -// Find IWAD and initialise according to IWAD type. +// Find IWAD and initialize according to IWAD type. // //----------------------------------------------------------------------------- diff --git a/src/d_main.c b/src/d_main.c index c59a8fb7..3580c346 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -666,7 +666,7 @@ static struct { NULL, NULL, 0}, }; -// Initialise the game version +// Initialize the game version static void InitGameVersion(void) { @@ -1450,7 +1450,7 @@ void D_DoomMain (void) I_Init (); #ifdef FEATURE_MULTIPLAYER - printf ("NET_Init: Initialise network subsystem.\n"); + printf ("NET_Init: Init network subsystem.\n"); NET_Init (); #endif diff --git a/src/d_net.h b/src/d_net.h index df3d2d4b..e5980a9b 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -47,7 +47,7 @@ void D_QuitNetGame (void); //? how many ticks to run? void TryRunTics (void); -// Called at start of game loop to initialise timers +// Called at start of game loop to initialize timers void D_StartGameLoop(void); extern boolean drone; diff --git a/src/deh_defs.h b/src/deh_defs.h index a6650544..e7b76182 100644 --- a/src/deh_defs.h +++ b/src/deh_defs.h @@ -41,7 +41,7 @@ struct deh_section_s { char *name; - // Called on startup to initialise code + // Called on startup to initialize code deh_section_init_t init; diff --git a/src/deh_main.c b/src/deh_main.c index 616b30e0..dcdfb00d 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -108,7 +108,7 @@ void DEH_Checksum(md5_digest_t digest) // Called on startup to call the Init functions -static void InitialiseSections(void) +static void InitializeSections(void) { unsigned int i; @@ -383,7 +383,7 @@ void DEH_Init(void) char *filename; int p; - InitialiseSections(); + InitializeSections(); //! // @category mod diff --git a/src/deh_ptr.c b/src/deh_ptr.c index a819ddc0..9841e38c 100644 --- a/src/deh_ptr.c +++ b/src/deh_ptr.c @@ -56,7 +56,7 @@ static void DEH_PointerInit(void) { int i; - // Initialise list of dehacked pointers + // Initialize list of dehacked pointers for (i=0; iabuf = Z_Malloc(expanded_length, PU_STATIC, &destination->abuf); - // If we can, use the standard / optimised SDL conversion routines. + // If we can, use the standard / optimized SDL conversion routines. if (samplerate <= mixer_freq && ConvertibleRatio(samplerate, mixer_freq) @@ -548,7 +548,7 @@ static void I_SDL_UpdateSoundParams(int handle, int vol, int sep) { int left, right; - if (!sound_initialised) + if (!sound_initialized) { return; } @@ -577,7 +577,7 @@ static int I_SDL_StartSound(int id, int channel, int vol, int sep) { Mix_Chunk *chunk; - if (!sound_initialised) + if (!sound_initialized) { return -1; } @@ -611,7 +611,7 @@ static int I_SDL_StartSound(int id, int channel, int vol, int sep) static void I_SDL_StopSound (int handle) { - if (!sound_initialised) + if (!sound_initialized) { return; } @@ -659,7 +659,7 @@ static void I_SDL_UpdateSound(void) static void I_SDL_ShutdownSound(void) { - if (!sound_initialised) + if (!sound_initialized) { return; } @@ -667,7 +667,7 @@ static void I_SDL_ShutdownSound(void) Mix_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); - sound_initialised = false; + sound_initialized = false; } // Calculate slice size, based on MAX_SOUND_SLICE_TIME. @@ -721,7 +721,7 @@ static boolean I_SDL_InitSound(void) if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { - fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError()); + fprintf(stderr, "Error initializing SDL_mixer: %s\n", Mix_GetError()); return false; } @@ -751,7 +751,7 @@ static boolean I_SDL_InitSound(void) SDL_PauseAudio(0); - sound_initialised = true; + sound_initialized = true; return true; } diff --git a/src/i_timer.c b/src/i_timer.c index 5fd7fba9..48be83be 100644 --- a/src/i_timer.c +++ b/src/i_timer.c @@ -76,7 +76,7 @@ void I_Sleep(int ms) void I_InitTimer(void) { - // initialise timer + // initialize timer SDL_Init(SDL_INIT_TIMER); } diff --git a/src/i_timer.h b/src/i_timer.h index 83ccecc9..d90094c8 100644 --- a/src/i_timer.h +++ b/src/i_timer.h @@ -38,7 +38,7 @@ int I_GetTimeMS (void); // Pause for a specified number of ms void I_Sleep(int ms); -// Initialise timer +// Initialize timer void I_InitTimer(void); #endif diff --git a/src/i_video.c b/src/i_video.c index 582a7fa7..5f5979d2 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -101,7 +101,7 @@ static int windowwidth, windowheight; // display has been set up? -static boolean initialised = false; +static boolean initialized = false; // disable mouse? @@ -246,7 +246,7 @@ static void UpdateFocus(void) state = SDL_GetAppState(); // We should have input (keyboard) focus and be visible - // (not minimised) + // (not minimized) window_focused = (state & SDL_APPINPUTFOCUS) && (state & SDL_APPACTIVE); @@ -396,14 +396,14 @@ static int TranslateKey(SDL_keysym *sym) void I_ShutdownGraphics(void) { - if (initialised) + if (initialized) { SDL_ShowCursor(1); SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_QuitSubSystem(SDL_INIT_VIDEO); - initialised = false; + initialized = false; } } @@ -622,7 +622,7 @@ static void I_ReadMouse(void) // void I_StartTic (void) { - if (!initialised) + if (!initialized) { return; } @@ -741,7 +741,7 @@ void I_BeginRead(void) + (SCREENWIDTH - LOADING_DISK_W); int y; - if (!initialised || disk_image == NULL) + if (!initialized || disk_image == NULL) return; // save background and copy the disk image in @@ -769,7 +769,7 @@ void I_EndRead(void) + (SCREENWIDTH - LOADING_DISK_W); int y; - if (!initialised || disk_image == NULL) + if (!initialized || disk_image == NULL) return; // save background and copy the disk image in @@ -797,7 +797,7 @@ void I_FinishUpdate (void) int i; // UNUSED static unsigned char *bigscreen=0; - if (!initialised) + if (!initialized) return; if (noblit) @@ -1500,7 +1500,7 @@ void I_InitGraphics(void) if (SDL_Init(SDL_INIT_VIDEO) < 0) { - I_Error("Failed to initialise video: %s", SDL_GetError()); + I_Error("Failed to initialize video: %s", SDL_GetError()); } // Check for command-line video-related parameters. @@ -1564,6 +1564,8 @@ void I_InitGraphics(void) flags |= SDL_FULLSCREEN; } + flags |= SDL_NOFRAME; + screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags); if (screen == NULL) @@ -1679,6 +1681,6 @@ void I_InitGraphics(void) CenterMouse(); } - initialised = true; + initialized = true; } diff --git a/src/net_client.c b/src/net_client.c index 36dafe7a..0d6dd2fc 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1152,7 +1152,7 @@ boolean NET_CL_Connect(net_addr_t *addr) client_context = NET_NewContext(); - // initialise module for client mode + // initialize module for client mode if (!addr->module->InitClient()) { @@ -1164,7 +1164,7 @@ boolean NET_CL_Connect(net_addr_t *addr) net_client_connected = true; net_client_received_wait_data = false; - // Initialise connection + // Initialize connection NET_Conn_InitClient(&client_connection, addr); diff --git a/src/net_common.c b/src/net_common.c index 5af6aaa7..da3d7fd5 100644 --- a/src/net_common.c +++ b/src/net_common.c @@ -59,7 +59,7 @@ static void NET_Conn_Init(net_connection_t *conn, net_addr_t *addr) conn->reliable_recv_seq = 0; } -// Initialise as a client connection +// Initialize as a client connection void NET_Conn_InitClient(net_connection_t *conn, net_addr_t *addr) { @@ -67,7 +67,7 @@ void NET_Conn_InitClient(net_connection_t *conn, net_addr_t *addr) conn->state = NET_CONN_STATE_CONNECTING; } -// Initialise as a server connection +// Initialize as a server connection void NET_Conn_InitServer(net_connection_t *conn, net_addr_t *addr) { diff --git a/src/net_defs.h b/src/net_defs.h index c575020f..66b17c77 100644 --- a/src/net_defs.h +++ b/src/net_defs.h @@ -45,11 +45,11 @@ struct _net_packet_s struct _net_module_s { - // Initialise this module for use as a client + // Initialize this module for use as a client boolean (*InitClient)(void); - // Initialise this module for use as a server + // Initialize this module for use as a server boolean (*InitServer)(void); diff --git a/src/net_gui.c b/src/net_gui.c index 9816346b..ed9a58e9 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -262,7 +262,7 @@ void NET_WaitForStart(void) { if (!TXT_Init()) { - fprintf(stderr, "Failed to initialise GUI\n"); + fprintf(stderr, "Failed to initialize GUI\n"); exit(-1); } diff --git a/src/net_loop.c b/src/net_loop.c index 890dcbf2..abba96e0 100644 --- a/src/net_loop.c +++ b/src/net_loop.c @@ -99,7 +99,7 @@ static boolean NET_CL_InitClient(void) static boolean NET_CL_InitServer(void) { - I_Error("NET_CL_InitServer: attempted to initialise client pipe end as a server!"); + I_Error("NET_CL_InitServer: attempted to initialize client pipe end as a server!"); return false; } @@ -161,7 +161,7 @@ net_module_t net_loop_client_module = static boolean NET_SV_InitClient(void) { - I_Error("NET_SV_InitClient: attempted to initialise server pipe end as a client!"); + I_Error("NET_SV_InitClient: attempted to initialize server pipe end as a client!"); return false; } diff --git a/src/net_sdl.c b/src/net_sdl.c index 92606fac..9c647cc9 100644 --- a/src/net_sdl.c +++ b/src/net_sdl.c @@ -57,7 +57,7 @@ typedef struct static addrpair_t **addr_table; static int addr_table_size = -1; -// Initialises the address table +// Initializes the address table static void NET_SDL_InitAddrTable(void) { diff --git a/src/net_server.c b/src/net_server.c index a90ed4fd..383608be 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -119,7 +119,7 @@ typedef struct } net_client_recv_t; static net_server_state_t server_state; -static boolean server_initialised = false; +static boolean server_initialized = false; static net_client_t clients[MAXNETNODES]; static net_client_t *sv_players[MAXPLAYERS]; static net_context_t *server_context; @@ -612,7 +612,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, return; } - // Activate, initialise connection + // Activate, initialize connection NET_SV_InitNewClient(client, addr, player_name); @@ -1489,13 +1489,13 @@ void NET_SV_AddModule(net_module_t *module) NET_AddModule(server_context, module); } -// Initialise server and wait for connections +// Initialize server and wait for connections void NET_SV_Init(void) { int i; - // initialise send/receive context + // initialize send/receive context server_context = NET_NewContext(); @@ -1510,7 +1510,7 @@ void NET_SV_Init(void) server_state = SERVER_WAITING_START; sv_gamemode = indetermined; - server_initialised = true; + server_initialized = true; } // Run server code to check for new packets/send packets as the server @@ -1522,7 +1522,7 @@ void NET_SV_Run(void) net_packet_t *packet; int i; - if (!server_initialised) + if (!server_initialized) { return; } @@ -1564,7 +1564,7 @@ void NET_SV_Shutdown(void) boolean running; int start_time; - if (!server_initialised) + if (!server_initialized) { return; } diff --git a/src/net_server.h b/src/net_server.h index 3d0cf6e4..93b22fc3 100644 --- a/src/net_server.h +++ b/src/net_server.h @@ -24,7 +24,7 @@ #ifndef NET_SERVER_H #define NET_SERVER_H -// initialise server and wait for connections +// initialize server and wait for connections void NET_SV_Init(void); diff --git a/src/s_sound.c b/src/s_sound.c index 70fa75f3..9b4f71aa 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -176,7 +176,7 @@ static boolean SndDeviceInList(snddevice_t device, snddevice_t *list, return false; } -// Find and initialise a sound_module_t appropriate for the setting +// Find and initialize a sound_module_t appropriate for the setting // in snd_sfxdevice. static void InitSfxModule(void) @@ -194,7 +194,7 @@ static void InitSfxModule(void) sound_modules[i]->sound_devices, sound_modules[i]->num_sound_devices)) { - // Initialise the module + // Initialize the module if (sound_modules[i]->Init()) { @@ -205,7 +205,7 @@ static void InitSfxModule(void) } } -// Initialise music according to snd_musicdevice. +// Initialize music according to snd_musicdevice. static void InitMusicModule(void) { @@ -222,7 +222,7 @@ static void InitMusicModule(void) music_modules[i]->sound_devices, music_modules[i]->num_sound_devices)) { - // Initialise the module + // Initialize the module if (music_modules[i]->Init()) { @@ -268,7 +268,7 @@ void S_Init(int sfxVolume, int musicVolume) nomusic = M_CheckParm("-nomusic") > 0; - // Initialise the sound and music subsystems. + // Initialize the sound and music subsystems. if (!nosound && !screensaver_mode) { diff --git a/src/s_sound.h b/src/s_sound.h index 67071338..b8d0e766 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -54,8 +54,8 @@ typedef struct snddevice_t *sound_devices; int num_sound_devices; - // Initialise sound module - // Returns true if successfully initialised + // Initialize sound module + // Returns true if successfully initialized boolean (*Init)(void); @@ -99,7 +99,7 @@ typedef struct snddevice_t *sound_devices; int num_sound_devices; - // Initialise the music subsystem + // Initialize the music subsystem boolean (*Init)(void); diff --git a/src/w_merge.c b/src/w_merge.c index 372b3583..6b6ae659 100644 --- a/src/w_merge.c +++ b/src/w_merge.c @@ -143,7 +143,7 @@ static void SetupLists(void) SetupList(&pwad_sprites, &pwad, "S_START", "S_END", "SS_START", "SS_END"); } -// Initialise the replace list +// Initialize the replace list static void InitSpriteList(void) { -- cgit v1.2.3 From 508c3fd3fa5b3149d329e15ea3e072ad2a7aa2f2 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 1 Oct 2009 01:04:00 +0000 Subject: Oops. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1701 --- src/i_sdlmusic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 29f00a97..81f492b5 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -304,7 +304,7 @@ static void *I_SDL_RegisterSong(void *data, int len) // remove file now -// remove(filename); + remove(filename); Z_Free(filename); -- cgit v1.2.3 From a034c665c088904d9061e13cf73f5de33ef2268b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 1 Oct 2009 19:08:21 +0000 Subject: Oops. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1703 --- src/i_video.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 5f5979d2..062c9c9c 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1564,8 +1564,6 @@ void I_InitGraphics(void) flags |= SDL_FULLSCREEN; } - flags |= SDL_NOFRAME; - screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags); if (screen == NULL) -- cgit v1.2.3 From a91a40f18eb3a353025b21bf22599c30f65a1cd3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 5 Oct 2009 20:25:53 +0000 Subject: Fix desync in ep1-0500.lmp on 64-bit (thanks exp(x)). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1710 --- src/p_doors.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/p_doors.c b/src/p_doors.c index b681a8d0..89b65328 100644 --- a/src/p_doors.c +++ b/src/p_doors.c @@ -420,8 +420,41 @@ EV_VerticalDoor { if (!thing->player) return; // JDC: bad guys never close doors - - door->direction = -1; // start going down immediately + + // When is a door not a door? + // In Vanilla, door->direction is set, even though + // "specialdata" might not actually point at a door. + + if (door->thinker.function.acp1 == (actionf_p1) T_VerticalDoor) + { + door->direction = -1; // start going down immediately + } + else if (door->thinker.function.acp1 == (actionf_p1) T_PlatRaise) + { + // Erm, this is a plat, not a door. + // This notably causes a problem in ep1-0500.lmp where + // a plat and a door are cross-referenced; the door + // doesn't open on 64-bit. + // The direction field in vldoor_t corresponds to the wait + // field in plat_t. Let's set that to -1 instead. + + plat_t *plat; + + plat = (plat_t *) door; + plat->wait = -1; + } + else + { + // This isn't a door OR a plat. Now we're in trouble. + + fprintf(stderr, "EV_VerticalDoor: Tried to close " + "something that wasn't a door.\n"); + + // Try closing it anyway. At least it will work on 32-bit + // machines. + + door->direction = -1; + } } return; } -- cgit v1.2.3 From cc92d31eeaa40ae966196cfa5402474ffda0bbc7 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 10 Oct 2009 01:02:58 +0000 Subject: Don't crash when using the donut special type and the joining linedef is one sided (thanks Alexander Waldmann). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1711 --- src/p_spec.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/p_spec.c b/src/p_spec.c index 27042b5d..5bb6f19d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1199,6 +1199,24 @@ int EV_DoDonut(line_t* line) rtn = 1; s2 = getNextSector(s1->lines[0],s1); + + // Vanilla Doom does not check if the linedef is one sided. The + // game does not crash, but reads invalid memory and causes the + // sector floor to move "down" to some unknown height. + // DOSbox prints a warning about an invalid memory access. + // + // I'm not sure exactly what invalid memory is being read. This + // isn't something that should be done, anyway. + // Just print a warning and return. + + if (s2 == NULL) + { + fprintf(stderr, + "EV_DoDonut: linedef had no second sidedef! " + "Unexpected behavior may occur in Vanilla Doom. \n"); + break; + } + for (i = 0;i < s2->linecount;i++) { if ((!s2->lines[i]->flags & ML_TWOSIDED) || -- cgit v1.2.3 From 35f753d9e4b9d85cc712262a751729688e32aad6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 16 Oct 2009 18:35:19 +0000 Subject: Fix compile under MSVC (thanks entryway). Subversion-branch: /branches/raven-branch Subversion-revision: 1718 --- src/doomtype.h | 2 ++ src/heretic/am_data.h | 12 ++++++------ src/heretic/am_map.c | 2 +- src/heretic/p_enemy.c | 8 ++++---- src/heretic/p_mobj.c | 6 +++--- src/heretic/p_pspr.c | 12 ++++++------ src/heretic/r_data.c | 20 +++++++++++++++----- src/hexen/am_data.h | 6 +++--- src/hexen/p_mobj.c | 4 ++-- src/hexen/r_data.c | 20 +++++++++++++++----- src/i_cdmus.c | 2 ++ src/i_main.c | 6 ++++-- src/i_system.h | 1 + 13 files changed, 64 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/doomtype.h b/src/doomtype.h index b79bd687..e38d921f 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -36,7 +36,9 @@ #ifdef _WIN32 #define snprintf _snprintf +#if _MSC_VER < 1400 /* not needed for Visual Studio 2008 */ #define vsnprintf _vsnprintf +#endif #define strcasecmp stricmp #define strncasecmp strnicmp diff --git a/src/heretic/am_data.h b/src/heretic/am_data.h index 1f83d876..342f06a9 100644 --- a/src/heretic/am_data.h +++ b/src/heretic/am_data.h @@ -92,18 +92,18 @@ mline_t cheat_player_arrow[] = { #define R (FRACUNIT) mline_t triangle_guy[] = { - { { -.867*R, -.5*R }, { .867*R, -.5*R } }, - { { .867*R, -.5*R } , { 0, R } }, - { { 0, R }, { -.867*R, -.5*R } } + { { (fixed_t)(-.867*R), (fixed_t)(-.5*R) }, { (fixed_t)(.867*R ), (fixed_t)(-.5*R) } }, + { { (fixed_t)(.867*R ), (fixed_t)(-.5*R) }, { (fixed_t)(0 ), (fixed_t)(R ) } }, + { { (fixed_t)(0 ), (fixed_t)(R ) }, { (fixed_t)(-.867*R), (fixed_t)(-.5*R) } } }; #undef R #define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) #define R (FRACUNIT) mline_t thintriangle_guy[] = { - { { -.5*R, -.7*R }, { R, 0 } }, - { { R, 0 }, { -.5*R, .7*R } }, - { { -.5*R, .7*R }, { -.5*R, -.7*R } } + { { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)(R ), (fixed_t)(0 ) } }, + { { (fixed_t)(R ), (fixed_t)(0 ) }, { (fixed_t)(-.5*R), (fixed_t)(.7*R ) } }, + { { (fixed_t)(-.5*R), (fixed_t)(.7*R ) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } } }; #undef R #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) diff --git a/src/heretic/am_map.c b/src/heretic/am_map.c index aa1b273b..99a8e206 100644 --- a/src/heretic/am_map.c +++ b/src/heretic/am_map.c @@ -131,7 +131,7 @@ static fixed_t old_m_x, old_m_y; static mpoint_t f_oldloc; // used by MTOF to scale from map-to-frame-buffer coords -static fixed_t scale_mtof = INITSCALEMTOF; +static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF; // used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof) static fixed_t scale_ftom; diff --git a/src/heretic/p_enemy.c b/src/heretic/p_enemy.c index 05566a07..6ad8cff0 100644 --- a/src/heretic/p_enemy.c +++ b/src/heretic/p_enemy.c @@ -1917,7 +1917,7 @@ void A_HeadIceImpact(mobj_t * ice) angle >>= ANGLETOFINESHIFT; shard->momx = FixedMul(shard->info->speed, finecosine[angle]); shard->momy = FixedMul(shard->info->speed, finesine[angle]); - shard->momz = -.6 * FRACUNIT; + shard->momz = (fixed_t)(-.6 * FRACUNIT); P_CheckMissileSpawn(shard); } } @@ -2507,7 +2507,7 @@ void A_VolcanoBlast(mobj_t * volcano) angle >>= ANGLETOFINESHIFT; blast->momx = FixedMul(1 * FRACUNIT, finecosine[angle]); blast->momy = FixedMul(1 * FRACUNIT, finesine[angle]); - blast->momz = (2.5 * FRACUNIT) + (P_Random() << 10); + blast->momz = (fixed_t)(2.5 * FRACUNIT) + (P_Random() << 10); S_StartSound(blast, sfx_volsht); P_CheckMissileSpawn(blast); } @@ -2540,8 +2540,8 @@ void A_VolcBallImpact(mobj_t * ball) angle = i * ANG90; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; - tiny->momx = FixedMul(FRACUNIT * .7, finecosine[angle]); - tiny->momy = FixedMul(FRACUNIT * .7, finesine[angle]); + tiny->momx = FixedMul((fixed_t)(FRACUNIT * .7), finecosine[angle]); + tiny->momy = FixedMul((fixed_t)(FRACUNIT * .7), finesine[angle]); tiny->momz = FRACUNIT + (P_Random() << 9); P_CheckMissileSpawn(tiny); } diff --git a/src/heretic/p_mobj.c b/src/heretic/p_mobj.c index b5366501..e07ecf45 100644 --- a/src/heretic/p_mobj.c +++ b/src/heretic/p_mobj.c @@ -70,7 +70,7 @@ boolean P_SetMobjState(mobj_t * mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - mobj->state = S_NULL; + mobj->state = (state_t *) S_NULL; P_RemoveMobj(mobj); return (false); } @@ -100,7 +100,7 @@ boolean P_SetMobjStateNF(mobj_t * mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - mobj->state = S_NULL; + mobj->state = (state_t *) S_NULL; P_RemoveMobj(mobj); return (false); } @@ -1214,7 +1214,7 @@ void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z) break; case MT_GAUNTLETPUFF1: case MT_GAUNTLETPUFF2: - puff->momz = .8 * FRACUNIT; + puff->momz = (fixed_t)(.8 * FRACUNIT); default: break; } diff --git a/src/heretic/p_pspr.c b/src/heretic/p_pspr.c index 07a04ac7..7f9660ac 100644 --- a/src/heretic/p_pspr.c +++ b/src/heretic/p_pspr.c @@ -1639,14 +1639,14 @@ void A_PhoenixPuff(mobj_t * actor) puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF); angle = actor->angle + ANG90; angle >>= ANGLETOFINESHIFT; - puff->momx = FixedMul(FRACUNIT * 1.3, finecosine[angle]); - puff->momy = FixedMul(FRACUNIT * 1.3, finesine[angle]); + puff->momx = FixedMul((fixed_t)(FRACUNIT * 1.3), finecosine[angle]); + puff->momy = FixedMul((fixed_t)(FRACUNIT * 1.3), finesine[angle]); puff->momz = 0; puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF); angle = actor->angle - ANG90; angle >>= ANGLETOFINESHIFT; - puff->momx = FixedMul(FRACUNIT * 1.3, finecosine[angle]); - puff->momy = FixedMul(FRACUNIT * 1.3, finesine[angle]); + puff->momx = FixedMul((fixed_t)(FRACUNIT * 1.3), finecosine[angle]); + puff->momy = FixedMul((fixed_t)(FRACUNIT * 1.3), finesine[angle]); puff->momz = 0; } @@ -1727,7 +1727,7 @@ void A_ShutdownPhoenixPL2(player_t * player, pspdef_t * psp) void A_FlameEnd(mobj_t * actor) { - actor->momz += 1.5 * FRACUNIT; + actor->momz += (fixed_t)(1.5 * FRACUNIT); } //---------------------------------------------------------------------------- @@ -1738,7 +1738,7 @@ void A_FlameEnd(mobj_t * actor) void A_FloatPuff(mobj_t * puff) { - puff->momz += 1.8 * FRACUNIT; + puff->momz += (fixed_t)(1.8 * FRACUNIT); } //--------------------------------------------------------------------------- diff --git a/src/heretic/r_data.c b/src/heretic/r_data.c index 9846196a..ee005248 100644 --- a/src/heretic/r_data.c +++ b/src/heretic/r_data.c @@ -221,7 +221,7 @@ void R_GenerateLookup(int texnum) // fill in the lump / offset, so columns with only a single patch are // all done // - patchcount = (byte *) alloca(texture->width); + patchcount = (byte *) Z_Malloc(texture->width, PU_STATIC, &patchcount); memset(patchcount, 0, texture->width); patch = texture->patches; @@ -263,6 +263,8 @@ void R_GenerateLookup(int texnum) texturecompositesize[texnum] += texture->height; } } + + Z_Free(patchcount); } @@ -322,7 +324,7 @@ void R_InitTextures(void) names = W_CacheLumpName("PNAMES", PU_STATIC); nummappatches = LONG(*((int *) names)); name_p = names + 4; - patchlookup = alloca(nummappatches * sizeof(*patchlookup)); + patchlookup = Z_Malloc(nummappatches * sizeof(*patchlookup), PU_STATIC, NULL); for (i = 0; i < nummappatches; i++) { strncpy(name, name_p + i * 8, 8); @@ -423,6 +425,8 @@ void R_InitTextures(void) totalwidth += texture->width; } + Z_Free(patchlookup); + W_ReleaseLumpName("TEXTURE1"); if (maptex2) { @@ -654,7 +658,7 @@ void R_PrecacheLevel(void) // // precache flats // - flatpresent = alloca(numflats); + flatpresent = Z_Malloc(numflats, PU_STATIC, NULL); memset(flatpresent, 0, numflats); for (i = 0; i < numsectors; i++) { @@ -671,10 +675,12 @@ void R_PrecacheLevel(void) W_CacheLumpNum(lump, PU_CACHE); } + Z_Free(flatpresent); + // // precache textures // - texturepresent = alloca(numtextures); + texturepresent = Z_Malloc(numtextures, PU_STATIC, NULL); memset(texturepresent, 0, numtextures); for (i = 0; i < numsides; i++) @@ -700,10 +706,12 @@ void R_PrecacheLevel(void) } } + Z_Free(texturepresent); + // // precache sprites // - spritepresent = alloca(numsprites); + spritepresent = Z_Malloc(numsprites, PU_STATIC, NULL); memset(spritepresent, 0, numsprites); for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -728,4 +736,6 @@ void R_PrecacheLevel(void) } } } + + Z_Free(spritepresent); } diff --git a/src/hexen/am_data.h b/src/hexen/am_data.h index db964598..e20e34ce 100644 --- a/src/hexen/am_data.h +++ b/src/hexen/am_data.h @@ -108,9 +108,9 @@ mline_t triangle_guy[] = { #define R (FRACUNIT) mline_t thintriangle_guy[] = { - { { -.5*R, -.7*R }, { R, 0 } }, - { { R, 0 }, { -.5*R, .7*R } }, - { { -.5*R, .7*R }, { -.5*R, -.7*R } } + { { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)(R ), (fixed_t)(0 ) } }, + { { (fixed_t)(R ), (fixed_t)(0 ) }, { (fixed_t)(-.5*R), (fixed_t)(.7*R ) } }, + { { (fixed_t)(-.5*R), (fixed_t)(.7*R ) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } } }; #undef R #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) diff --git a/src/hexen/p_mobj.c b/src/hexen/p_mobj.c index 5d6f7097..ee8f8fd4 100644 --- a/src/hexen/p_mobj.c +++ b/src/hexen/p_mobj.c @@ -100,7 +100,7 @@ boolean P_SetMobjState(mobj_t * mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - mobj->state = S_NULL; + mobj->state = (state_t *) S_NULL; P_RemoveMobj(mobj); return (false); } @@ -130,7 +130,7 @@ boolean P_SetMobjStateNF(mobj_t * mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - mobj->state = S_NULL; + mobj->state = (state_t *) S_NULL; P_RemoveMobj(mobj); return (false); } diff --git a/src/hexen/r_data.c b/src/hexen/r_data.c index bd020073..b82c0ff6 100644 --- a/src/hexen/r_data.c +++ b/src/hexen/r_data.c @@ -218,7 +218,7 @@ void R_GenerateLookup(int texnum) // fill in the lump / offset, so columns with only a single patch are // all done // - patchcount = (byte *) alloca(texture->width); + patchcount = (byte *) Z_Malloc(texture->width, PU_STATIC, &patchcount); memset(patchcount, 0, texture->width); patch = texture->patches; @@ -260,6 +260,8 @@ void R_GenerateLookup(int texnum) texturecompositesize[texnum] += texture->height; } } + + Z_Free(patchcount); } @@ -319,7 +321,7 @@ void R_InitTextures(void) names = W_CacheLumpName("PNAMES", PU_STATIC); nummappatches = LONG(*((int *) names)); name_p = names + 4; - patchlookup = alloca(nummappatches * sizeof(*patchlookup)); + patchlookup = Z_Malloc(nummappatches * sizeof(*patchlookup), PU_STATIC, NULL); for (i = 0; i < nummappatches; i++) { strncpy(name, name_p + i * 8, 8); @@ -403,6 +405,8 @@ void R_InitTextures(void) totalwidth += texture->width; } + Z_Free(patchlookup); + W_ReleaseLumpName("TEXTURE1"); if (maptex2) W_ReleaseLumpName("TEXTURE2"); @@ -620,7 +624,7 @@ void R_PrecacheLevel(void) // // precache flats // - flatpresent = alloca(numflats); + flatpresent = Z_Malloc(numflats, PU_STATIC, NULL); memset(flatpresent, 0, numflats); for (i = 0; i < numsectors; i++) { @@ -637,10 +641,12 @@ void R_PrecacheLevel(void) W_CacheLumpNum(lump, PU_CACHE); } + Z_Free(flatpresent); + // // precache textures // - texturepresent = alloca(numtextures); + texturepresent = Z_Malloc(numtextures, PU_STATIC, NULL); memset(texturepresent, 0, numtextures); for (i = 0; i < numsides; i++) @@ -667,10 +673,12 @@ void R_PrecacheLevel(void) } } + Z_Free(texturepresent); + // // precache sprites // - spritepresent = alloca(numsprites); + spritepresent = Z_Malloc(numsprites, PU_STATIC, NULL); memset(spritepresent, 0, numsprites); for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -695,4 +703,6 @@ void R_PrecacheLevel(void) } } } + + Z_Free(spritepresent); } diff --git a/src/i_cdmus.c b/src/i_cdmus.c index 5a52b143..94ac47c6 100644 --- a/src/i_cdmus.c +++ b/src/i_cdmus.c @@ -25,6 +25,8 @@ // //----------------------------------------------------------------------------- +#include + #include "SDL.h" #include "SDL_cdrom.h" diff --git a/src/i_main.c b/src/i_main.c index a17d56b9..1ccc52c0 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -26,6 +26,8 @@ #include "config.h" +#include + #include "SDL.h" #include "doomtype.h" @@ -53,7 +55,7 @@ static void LockCPUAffinity(void) #define WIN32_LEAN_AND_MEAN #include -typedef BOOL WINAPI (*SetAffinityFunc)(HANDLE hProcess, DWORD_PTR mask); +typedef BOOL (WINAPI *SetAffinityFunc)(HANDLE hProcess, DWORD mask); // This is a bit more complicated than it really needs to be. We really // just need to call the SetProcessAffinityMask function, but that @@ -79,7 +81,7 @@ static void LockCPUAffinity(void) } // Find the SetProcessAffinityMask function. - SetAffinity = GetProcAddress(kernel32_dll, "SetProcessAffinityMask"); + SetAffinity = (SetAffinityFunc)GetProcAddress(kernel32_dll, "SetProcessAffinityMask"); // If the function was not found, we are on an old (Win9x) system // that doesn't have this function. That's no problem, because diff --git a/src/i_system.h b/src/i_system.h index b34f61e4..0697f7db 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -60,6 +60,7 @@ ticcmd_t* I_BaseTiccmd (void); // Clean exit, displays sell blurb. void I_Quit (void); +void I_Error (char *error, ...); // Allocates from low memory under dos, // just mallocs under unix -- cgit v1.2.3 From 095bc1110b3c11fbf2e17bfd51bf78909fe34662 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 16 Oct 2009 18:43:39 +0000 Subject: Remove CR characters from code. Minor formatting cleanups to heretic/doomdef.h. Subversion-branch: /branches/raven-branch Subversion-revision: 1719 --- src/heretic/doomdef.h | 122 +++++++++++++++++++++---------------------- src/hexen/am_data.h | 141 +++++++++++++++++++++++++------------------------- src/hexen/m_random.h | 84 +++++++++++++++--------------- 3 files changed, 173 insertions(+), 174 deletions(-) (limited to 'src') diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h index 0580f9b0..3f976c3d 100644 --- a/src/heretic/doomdef.h +++ b/src/heretic/doomdef.h @@ -205,74 +205,74 @@ typedef struct // --- mobj.flags --- -#define MF_SPECIAL 1 // call P_SpecialThing when touched -#define MF_SOLID 2 +#define MF_SPECIAL 1 // call P_SpecialThing when touched +#define MF_SOLID 2 #define MF_SHOOTABLE 4 -#define MF_NOSECTOR 8 // don't use the sector links - // (invisible but touchable) -#define MF_NOBLOCKMAP 16 // don't use the blocklinks - // (inert but displayable) -#define MF_AMBUSH 32 -#define MF_JUSTHIT 64 // try to attack right back -#define MF_JUSTATTACKED 128 // take at least one step before attacking -#define MF_SPAWNCEILING 256 // hang from ceiling instead of floor -#define MF_NOGRAVITY 512 // don't apply gravity every tic +#define MF_NOSECTOR 8 // don't use the sector links + // (invisible but touchable) +#define MF_NOBLOCKMAP 16 // don't use the blocklinks + // (inert but displayable) +#define MF_AMBUSH 32 +#define MF_JUSTHIT 64 // try to attack right back +#define MF_JUSTATTACKED 128 // take at least one step before attacking +#define MF_SPAWNCEILING 256 // hang from ceiling instead of floor +#define MF_NOGRAVITY 512 // don't apply gravity every tic // movement flags -#define MF_DROPOFF 0x400 // allow jumps from high places -#define MF_PICKUP 0x800 // for players to pick up items -#define MF_NOCLIP 0x1000 // player cheat -#define MF_SLIDE 0x2000 // keep info about sliding along walls -#define MF_FLOAT 0x4000 // allow moves to any height, no gravity -#define MF_TELEPORT 0x8000 // don't cross lines or look at heights -#define MF_MISSILE 0x10000 // don't hit same species, explode on block - -#define MF_DROPPED 0x20000 // dropped by a demon, not level spawned -#define MF_SHADOW 0x40000 // use translucent draw (shadow demons / invis) -#define MF_NOBLOOD 0x80000 // don't bleed when shot (use puff) -#define MF_CORPSE 0x100000 // don't stop moving halfway off a step -#define MF_INFLOAT 0x200000 // floating to a height for a move, don't - // auto float to target's height - -#define MF_COUNTKILL 0x400000 // count towards intermission kill total -#define MF_COUNTITEM 0x800000 // count towards intermission item total - -#define MF_SKULLFLY 0x1000000 // skull in flight -#define MF_NOTDMATCH 0x2000000 // don't spawn in death match (key cards) - -#define MF_TRANSLATION 0xc000000 // if 0x4 0x8 or 0xc, use a translation +#define MF_DROPOFF 0x400 // allow jumps from high places +#define MF_PICKUP 0x800 // for players to pick up items +#define MF_NOCLIP 0x1000 // player cheat +#define MF_SLIDE 0x2000 // keep info about sliding along walls +#define MF_FLOAT 0x4000 // allow moves to any height, no gravity +#define MF_TELEPORT 0x8000 // don't cross lines or look at heights +#define MF_MISSILE 0x10000 // don't hit same species, explode on block + +#define MF_DROPPED 0x20000 // dropped by a demon, not level spawned +#define MF_SHADOW 0x40000 // use translucent draw (shadow demons / invis) +#define MF_NOBLOOD 0x80000 // don't bleed when shot (use puff) +#define MF_CORPSE 0x100000 // don't stop moving halfway off a step +#define MF_INFLOAT 0x200000 // floating to a height for a move, don't + // auto float to target's height + +#define MF_COUNTKILL 0x400000 // count towards intermission kill total +#define MF_COUNTITEM 0x800000 // count towards intermission item total + +#define MF_SKULLFLY 0x1000000 // skull in flight +#define MF_NOTDMATCH 0x2000000 // don't spawn in death match (key cards) + +#define MF_TRANSLATION 0xc000000 // if 0x4 0x8 or 0xc, use a translation #define MF_TRANSSHIFT 26 // table for player colormaps // --- mobj.flags2 --- -#define MF2_LOGRAV 0x00000001 // alternate gravity setting -#define MF2_WINDTHRUST 0x00000002 // gets pushed around by the wind - // specials -#define MF2_FLOORBOUNCE 0x00000004 // bounces off the floor -#define MF2_THRUGHOST 0x00000008 // missile will pass through ghosts -#define MF2_FLY 0x00000010 // fly mode is active -#define MF2_FOOTCLIP 0x00000020 // if feet are allowed to be clipped -#define MF2_SPAWNFLOAT 0x00000040 // spawn random float z -#define MF2_NOTELEPORT 0x00000080 // does not teleport -#define MF2_RIP 0x00000100 // missile rips through solid - // targets -#define MF2_PUSHABLE 0x00000200 // can be pushed by other moving - // mobjs -#define MF2_SLIDE 0x00000400 // slides against walls -#define MF2_ONMOBJ 0x00000800 // mobj is resting on top of another - // mobj -#define MF2_PASSMOBJ 0x00001000 // Enable z block checking. If on, - // this flag will allow the mobj to - // pass over/under other mobjs. -#define MF2_CANNOTPUSH 0x00002000 // cannot push other pushable mobjs -#define MF2_FEETARECLIPPED 0x00004000 // a mobj's feet are now being cut -#define MF2_BOSS 0x00008000 // mobj is a major boss -#define MF2_FIREDAMAGE 0x00010000 // does fire damage -#define MF2_NODMGTHRUST 0x00020000 // does not thrust target when - // damaging -#define MF2_TELESTOMP 0x00040000 // mobj can stomp another -#define MF2_FLOATBOB 0x00080000 // use float bobbing z movement -#define MF2_DONTDRAW 0X00100000 // don't generate a vissprite +#define MF2_LOGRAV 0x00000001 // alternate gravity setting +#define MF2_WINDTHRUST 0x00000002 // gets pushed around by the wind + // specials +#define MF2_FLOORBOUNCE 0x00000004 // bounces off the floor +#define MF2_THRUGHOST 0x00000008 // missile will pass through ghosts +#define MF2_FLY 0x00000010 // fly mode is active +#define MF2_FOOTCLIP 0x00000020 // if feet are allowed to be clipped +#define MF2_SPAWNFLOAT 0x00000040 // spawn random float z +#define MF2_NOTELEPORT 0x00000080 // does not teleport +#define MF2_RIP 0x00000100 // missile rips through solid + // targets +#define MF2_PUSHABLE 0x00000200 // can be pushed by other moving + // mobjs +#define MF2_SLIDE 0x00000400 // slides against walls +#define MF2_ONMOBJ 0x00000800 // mobj is resting on top of another + // mobj +#define MF2_PASSMOBJ 0x00001000 // Enable z block checking. If on, + // this flag will allow the mobj to + // pass over/under other mobjs. +#define MF2_CANNOTPUSH 0x00002000 // cannot push other pushable mobjs +#define MF2_FEETARECLIPPED 0x00004000 // a mobj's feet are now being cut +#define MF2_BOSS 0x00008000 // mobj is a major boss +#define MF2_FIREDAMAGE 0x00010000 // does fire damage +#define MF2_NODMGTHRUST 0x00020000 // does not thrust target when + // damaging +#define MF2_TELESTOMP 0x00040000 // mobj can stomp another +#define MF2_FLOATBOB 0x00080000 // use float bobbing z movement +#define MF2_DONTDRAW 0X00100000 // don't generate a vissprite //============================================================================= typedef enum diff --git a/src/hexen/am_data.h b/src/hexen/am_data.h index e20e34ce..a4cb47f3 100644 --- a/src/hexen/am_data.h +++ b/src/hexen/am_data.h @@ -22,26 +22,25 @@ // //----------------------------------------------------------------------------- +#ifndef __AMDATA_H__ +#define __AMDATA_H__ -#ifndef __AMDATA_H__ -#define __AMDATA_H__ - -// a line drawing of the player pointing right, starting from the middle. - -#define R ((8*PLAYERRADIUS)/7) - -mline_t player_arrow[] = { - { { -R+R/4, 0 }, { 0, 0} }, // center line. - { { -R+R/4, R/8 }, { R, 0} }, // blade - { { -R+R/4, -R/8 }, { R, 0 } }, - { { -R+R/4, -R/4 }, { -R+R/4, R/4 } }, // crosspiece - { { -R+R/8, -R/4 }, { -R+R/8, R/4 } }, - { { -R+R/8, -R/4 }, { -R+R/4, -R/4} }, //crosspiece connectors - { { -R+R/8, R/4 }, { -R+R/4, R/4} }, - { { -R-R/4, R/8 }, { -R-R/4, -R/8 } }, //pommel - { { -R-R/4, R/8 }, { -R+R/8, R/8 } }, - { { -R-R/4, -R/8}, { -R+R/8, -R/8 } } - }; +// a line drawing of the player pointing right, starting from the middle. + +#define R ((8*PLAYERRADIUS)/7) + +mline_t player_arrow[] = { + { { -R+R/4, 0 }, { 0, 0} }, // center line. + { { -R+R/4, R/8 }, { R, 0} }, // blade + { { -R+R/4, -R/8 }, { R, 0 } }, + { { -R+R/4, -R/4 }, { -R+R/4, R/4 } }, // crosspiece + { { -R+R/8, -R/4 }, { -R+R/8, R/4 } }, + { { -R+R/8, -R/4 }, { -R+R/4, -R/4} }, //crosspiece connectors + { { -R+R/8, R/4 }, { -R+R/4, R/4} }, + { { -R-R/4, R/8 }, { -R-R/4, -R/8 } }, //pommel + { { -R-R/4, R/8 }, { -R+R/8, R/8 } }, + { { -R-R/4, -R/8}, { -R+R/8, -R/8 } } + }; /* mline_t keysquare[] = { @@ -55,64 +54,64 @@ mline_t keysquare[] = { { { -3*R/4, 0 }, { -3*R/4, -R/4 } } }; */ - -/*mline_t player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, // ----- - { { R, 0 }, { R-R/2, R/4 } }, // -----> - { { R, 0 }, { R-R/2, -R/4 } }, - { { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >----> - { { -R+R/8, 0 }, { -R-R/8, -R/4 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>---> - { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } - }; -*/ -#undef R -#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) + +/*mline_t player_arrow[] = { + { { -R+R/8, 0 }, { R, 0 } }, // ----- + { { R, 0 }, { R-R/2, R/4 } }, // -----> + { { R, 0 }, { R-R/2, -R/4 } }, + { { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >----> + { { -R+R/8, 0 }, { -R-R/8, -R/4 } }, + { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>---> + { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } + }; +*/ +#undef R +#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) #define NUMKEYSQUARELINES (sizeof(keysquare)/sizeof(mline_t)) /* -#define R ((8*PLAYERRADIUS)/7) -mline_t cheat_player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, // ----- - { { R, 0 }, { R-R/2, R/6 } }, // -----> - { { R, 0 }, { R-R/2, -R/6 } }, - { { -R+R/8, 0 }, { -R-R/8, R/6 } }, // >-----> - { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, // >>-----> - { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, - { { -R/2, 0 }, { -R/2, -R/6 } }, // >>-d---> - { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, - { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, - { { -R/6, 0 }, { -R/6, -R/6 } }, // >>-dd--> - { { -R/6, -R/6 }, { 0, -R/6 } }, - { { 0, -R/6 }, { 0, R/4 } }, - { { R/6, R/4 }, { R/6, -R/7 } }, // >>-ddt-> - { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, - { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } - }; -#undef R -#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) +#define R ((8*PLAYERRADIUS)/7) +mline_t cheat_player_arrow[] = { + { { -R+R/8, 0 }, { R, 0 } }, // ----- + { { R, 0 }, { R-R/2, R/6 } }, // -----> + { { R, 0 }, { R-R/2, -R/6 } }, + { { -R+R/8, 0 }, { -R-R/8, R/6 } }, // >-----> + { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, + { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, // >>-----> + { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, + { { -R/2, 0 }, { -R/2, -R/6 } }, // >>-d---> + { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, + { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, + { { -R/6, 0 }, { -R/6, -R/6 } }, // >>-dd--> + { { -R/6, -R/6 }, { 0, -R/6 } }, + { { 0, -R/6 }, { 0, R/4 } }, + { { R/6, R/4 }, { R/6, -R/7 } }, // >>-ddt-> + { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, + { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } + }; +#undef R +#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) */ /* -#define R (FRACUNIT) -mline_t triangle_guy[] = { - { { -.867*R, -.5*R }, { .867*R, -.5*R } }, - { { .867*R, -.5*R } , { 0, R } }, - { { 0, R }, { -.867*R, -.5*R } } - }; -#undef R -#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) +#define R (FRACUNIT) +mline_t triangle_guy[] = { + { { -.867*R, -.5*R }, { .867*R, -.5*R } }, + { { .867*R, -.5*R } , { 0, R } }, + { { 0, R }, { -.867*R, -.5*R } } + }; +#undef R +#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) */ -#define R (FRACUNIT) -mline_t thintriangle_guy[] = { - { { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)(R ), (fixed_t)(0 ) } }, - { { (fixed_t)(R ), (fixed_t)(0 ) }, { (fixed_t)(-.5*R), (fixed_t)(.7*R ) } }, - { { (fixed_t)(-.5*R), (fixed_t)(.7*R ) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } } - }; -#undef R -#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) - -#endif +#define R (FRACUNIT) +mline_t thintriangle_guy[] = { + { { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)(R ), (fixed_t)(0 ) } }, + { { (fixed_t)(R ), (fixed_t)(0 ) }, { (fixed_t)(-.5*R), (fixed_t)(.7*R ) } }, + { { (fixed_t)(-.5*R), (fixed_t)(.7*R ) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } } + }; +#undef R +#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) + +#endif diff --git a/src/hexen/m_random.h b/src/hexen/m_random.h index 44e4643d..582bcfa7 100644 --- a/src/hexen/m_random.h +++ b/src/hexen/m_random.h @@ -1,42 +1,42 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2008 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -//----------------------------------------------------------------------------- - -#ifndef HEXEN_M_RANDOM_H -#define HEXEN_M_RANDOM_H - -// Most damage defined using HITDICE -#define HITDICE(a) ((1+(P_Random()&7))*a) - -int M_Random(void); -// returns a number from 0 to 255 -int P_Random(void); -// as M_Random, but used only by the play simulation - -void M_ClearRandom(void); -// fix randoms for demos - -extern int rndindex; - -#endif // HEXEN_M_RANDOM_H - +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 1993-2008 Raven Software +// Copyright(C) 2008 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +//----------------------------------------------------------------------------- + +#ifndef HEXEN_M_RANDOM_H +#define HEXEN_M_RANDOM_H + +// Most damage defined using HITDICE +#define HITDICE(a) ((1+(P_Random()&7))*a) + +int M_Random(void); +// returns a number from 0 to 255 +int P_Random(void); +// as M_Random, but used only by the play simulation + +void M_ClearRandom(void); +// fix randoms for demos + +extern int rndindex; + +#endif // HEXEN_M_RANDOM_H + -- cgit v1.2.3 From a3ab0a6910f55c6f45a3f4eaf48b4a99c4e16e22 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Oct 2009 19:29:46 +0000 Subject: Import donut overrun emulation code from PrBoom+ (Thanks entryway). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1720 --- src/m_misc.c | 8 ++++ src/m_misc.h | 1 + src/p_spec.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 129 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/m_misc.c b/src/m_misc.c index acab0a5b..9a5fb84a 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -198,3 +198,11 @@ char *M_TempFile(char *s) return result; } +boolean M_StrToInt(const char *str, int *result) +{ + return sscanf(str, " 0x%x", result) == 1 + || sscanf(str, " 0X%x", result) == 1 + || sscanf(str, " 0%o", result) == 1 + || sscanf(str, " %d", result) == 1; +} + diff --git a/src/m_misc.h b/src/m_misc.h index 0fea7e92..0fe8e62e 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -39,6 +39,7 @@ void M_MakeDirectory(char *dir); char *M_TempFile(char *s); boolean M_FileExists(char *file); long M_FileLength(FILE *handle); +boolean M_StrToInt(const char *str, int *result); #endif diff --git a/src/p_spec.c b/src/p_spec.c index 5bb6f19d..37beb850 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -38,6 +38,7 @@ #include "i_system.h" #include "z_zone.h" #include "m_argv.h" +#include "m_misc.h" #include "m_random.h" #include "w_wad.h" @@ -1169,10 +1170,94 @@ void P_UpdateSpecials (void) memset(&buttonlist[i],0,sizeof(button_t)); } } - } +// +// Donut overrun emulation +// +// Derived from the code from PrBoom+. Thanks go to Andrey Budko (entryway) +// as usual :-) +// + +#define DONUT_FLOORHEIGHT_DEFAULT 0x00000000 +#define DONUT_FLOORPIC_DEFAULT 0x16 + +static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic, + line_t *line, sector_t *pillar_sector) +{ + static int first = 1; + static int tmp_s3_floorheight; + static int tmp_s3_floorpic; + + extern int numflats; + + if (first) + { + int p; + + // This is the first time we have had an overrun. + first = 0; + + // Default values + tmp_s3_floorheight = DONUT_FLOORHEIGHT_DEFAULT; + tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT; + + //! + // @category compat + // @arg + // + // Use the specified magic values when emulating behavior caused + // by memory overruns from improperly constructed donuts. + // In Vanilla Doom this can differ depending on the operating + // system. The default (if this option is not specified) is to + // emulate the behavior when running under Windows 98. + + p = M_CheckParm("-donut"); + + if (p > 0 && p < myargc - 2) + { + // Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008 + // + // C:\>debug + // -d 0:0 + // + // DOS 6.22: + // 0000:0000 (57 92 19 00) F4 06 70 00-(16 00) + // DOS 7.1: + // 0000:0000 (9E 0F C9 00) 65 04 70 00-(16 00) + // Win98: + // 0000:0000 (00 00 00 00) 65 04 70 00-(16 00) + // DOSBox under XP: + // 0000:0000 (00 00 00 F1) ?? ?? ?? 00-(07 00) + + M_StrToInt(myargv[p + 1], &tmp_s3_floorheight); + M_StrToInt(myargv[p + 2], &tmp_s3_floorpic); + + if (tmp_s3_floorpic >= numflats) + { + fprintf(stderr, + "DonutOverrun: The second parameter for \"-donut\" " + "switch should be greater than 0 and less than number " + "of flats (%d). Using default value (%d) instead. \n", + numflats, DONUT_FLOORPIC_DEFAULT); + tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT; + } + } + } + + /* + fprintf(stderr, + "Linedef: %d; Sector: %d; " + "New floor height: %d; New floor pic: %d\n", + line->iLineID, pillar_sector->iSectorID, + tmp_s3_floorheight >> 16, tmp_s3_floorpic); + */ + + *s3_floorheight = (fixed_t) tmp_s3_floorheight; + *s3_floorpic = (short) tmp_s3_floorpic; +} + // // Special Stuff that can not be categorized @@ -1186,17 +1271,19 @@ int EV_DoDonut(line_t* line) int rtn; int i; floormove_t* floor; - + fixed_t s3_floorheight; + short s3_floorpic; + secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { s1 = §ors[secnum]; - + // ALREADY MOVING? IF SO, KEEP GOING... if (s1->specialdata) continue; - + rtn = 1; s2 = getNextSector(s1->lines[0],s1); @@ -1217,13 +1304,34 @@ int EV_DoDonut(line_t* line) break; } - for (i = 0;i < s2->linecount;i++) + for (i = 0; i < s2->linecount; i++) { - if ((!s2->lines[i]->flags & ML_TWOSIDED) || - (s2->lines[i]->backsector == s1)) - continue; s3 = s2->lines[i]->backsector; - + + if (s3 == s1) + continue; + + if (s3 == NULL) + { + // e6y + // s3 is NULL, so + // s3->floorheight is an int at 0000:0000 + // s3->floorpic is a short at 0000:0008 + // Trying to emulate + + fprintf(stderr, + "EV_DoDonut: WARNING: emulating buffer overrun due to " + "NULL back sector. " + "Unexpected behavior may occur in Vanilla Doom.\n"); + + DonutOverrun(&s3_floorheight, &s3_floorpic, line, s1); + } + else + { + s3_floorheight = s3->floorheight; + s3_floorpic = s3->floorpic; + } + // Spawn rising slime floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); @@ -1234,9 +1342,9 @@ int EV_DoDonut(line_t* line) floor->direction = 1; floor->sector = s2; floor->speed = FLOORSPEED / 2; - floor->texture = s3->floorpic; + floor->texture = s3_floorpic; floor->newspecial = 0; - floor->floordestheight = s3->floorheight; + floor->floordestheight = s3_floorheight; // Spawn lowering donut-hole floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); @@ -1248,7 +1356,7 @@ int EV_DoDonut(line_t* line) floor->direction = -1; floor->sector = s1; floor->speed = FLOORSPEED / 2; - floor->floordestheight = s3->floorheight; + floor->floordestheight = s3_floorheight; break; } } -- cgit v1.2.3 From 1290c2496e85105871ab457b91e159d43c4cc7b4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Oct 2009 19:39:37 +0000 Subject: Use M_StrToInt() when processing values passed with -spechit, so that hex values can be specified. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1721 --- src/p_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/p_map.c b/src/p_map.c index 42f2a60f..db512673 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -36,6 +36,7 @@ #include "doomdef.h" #include "m_argv.h" +#include "m_misc.h" #include "p_local.h" #include "s_sound.h" @@ -1412,7 +1413,7 @@ static void SpechitOverrun(line_t *ld) if (p > 0) { - baseaddr = atoi(myargv[p+1]); + M_StrToInt(atoi(myargv[p+1]), &baseaddr); } else { -- cgit v1.2.3 From 42454af827d204444874558ccb340fc6e65f9ac1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Oct 2009 20:13:54 +0000 Subject: Fix error in last change. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1722 --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/p_map.c b/src/p_map.c index db512673..89f8f3f8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1413,7 +1413,7 @@ static void SpechitOverrun(line_t *ld) if (p > 0) { - M_StrToInt(atoi(myargv[p+1]), &baseaddr); + M_StrToInt(myargv[p+1], (int *) &baseaddr); } else { -- cgit v1.2.3 From 3771126689527293eb4ad658b338d7910bf79012 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 26 Oct 2009 19:28:12 +0000 Subject: Initial hacks for compiling under SDL 1.3. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1726 --- src/i_video.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 062c9c9c..481ee0ea 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -334,7 +334,9 @@ static int TranslateKey(SDL_keysym *sym) case SDLK_PAUSE: return KEY_PAUSE; +#if !SDL_VERSION_ATLEAST(1, 3, 0) case SDLK_EQUALS: return KEY_EQUALS; +#endif case SDLK_MINUS: return KEY_MINUS; @@ -347,9 +349,11 @@ static int TranslateKey(SDL_keysym *sym) return KEY_RCTRL; case SDLK_LALT: - case SDLK_LMETA: case SDLK_RALT: +#if !SDL_VERSION_ATLEAST(1, 3, 0) + case SDLK_LMETA: case SDLK_RMETA: +#endif return KEY_RALT; case SDLK_CAPSLOCK: return KEY_CAPSLOCK; @@ -420,9 +424,15 @@ void I_StartFrame (void) static int MouseButtonState(void) { - Uint8 state = SDL_GetMouseState(NULL, NULL); + Uint8 state; int result = 0; +#if SDL_VERSION_ATLEAST(1, 3, 0) + state = SDL_GetMouseState(0, NULL, NULL); +#else + state = SDL_GetMouseState(NULL, NULL); +#endif + // Note: button "0" is left, button "1" is right, // button "2" is middle for Doom. This is different // to how SDL sees things. @@ -585,7 +595,11 @@ static void CenterMouse(void) // Clear any relative movement caused by warping SDL_PumpEvents(); +#if SDL_VERSION_ATLEAST(1, 3, 0) + SDL_GetRelativeMouseState(0, NULL, NULL); +#else SDL_GetRelativeMouseState(NULL, NULL); +#endif } // @@ -599,7 +613,11 @@ static void I_ReadMouse(void) int x, y; event_t ev; +#if SDL_VERSION_ATLEAST(1, 3, 0) + SDL_GetRelativeMouseState(0, &x, &y); +#else SDL_GetRelativeMouseState(&x, &y); +#endif if (x != 0 || y != 0) { @@ -1553,7 +1571,9 @@ void I_InitGraphics(void) // has to be done before the call to SDL_SetVideoMode. I_SetWindowCaption(); +#if !SDL_VERSION_ATLEAST(1, 3, 0) I_SetWindowIcon(); +#endif // Set the video mode. -- cgit v1.2.3 From 43b0dbd272da1d590797d2974e94413971131129 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 19 Nov 2009 21:49:13 +0000 Subject: Rework the OS X MIDI disabling code, as SDL_mixer 1.2.11 fixes the crash. Check and disable MIDI by default if using an older version of SDL on OS X. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1730 --- src/i_sdlmusic.c | 32 +++++++++++++++++++++----------- src/m_config.c | 19 +++++++++++++++++++ src/s_sound.c | 10 +--------- 3 files changed, 41 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 81f492b5..7f9bd8ec 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -81,18 +81,28 @@ static boolean SDLIsInitialized(void) // Initialize music subsystem static boolean I_SDL_InitMusic(void) -{ - // When trying to run with music enabled on OSX, display - // a warning message. - -#ifdef __APPLE__ - printf("\n" - " *** WARNING ***\n" - " Music playback on OSX may cause crashes and\n" - " is disabled by default.\n" - "\n"); +{ + // SDL_mixer prior to v1.2.11 has a bug that causes crashes + // with MIDI playback. Print a warning message if we are + // using an old version. + +#ifdef __MACOSX__ + { + const SDL_version *v = Mix_Linked_Version(); + + if (SDL_VERSIONNUM(v->major, v->minor, v->patch) + < SDL_VERSIONNUM(1, 2, 11)) + { + printf("\n" + " *** WARNING ***\n" + " You are using an old version of SDL_mixer.\n" + " Music playback on this version may cause crashes\n" + " under OS X and is disabled by default.\n" + "\n"); + } + } #endif - + // If SDL_mixer is not initialized, we have to initialize it // and have the responsibility to shut it down later on. diff --git a/src/m_config.c b/src/m_config.c index 4f789845..73f0da2c 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -36,6 +36,8 @@ #include #endif +#include "SDL_mixer.h" + #include "config.h" #include "deh_main.h" #include "doomdef.h" @@ -53,6 +55,7 @@ #include "i_swap.h" #include "i_system.h" #include "i_video.h" +#include "s_sound.h" #include "v_video.h" #include "hu_stuff.h" @@ -1456,5 +1459,21 @@ void M_ApplyPlatformDefaults(void) #ifdef _WIN32_WCE M_ApplyWindowsCEDefaults(); #endif + + // Before SDL_mixer version 1.2.11, MIDI music caused the game + // to crash when it looped. If this is an old SDL_mixer version, + // disable MIDI. + +#ifdef __MACOSX__ + { + const SDL_version *v = Mix_Linked_Version(); + + if (SDL_VERSIONNUM(v->major, v->minor, v->patch) + < SDL_VERSIONNUM(1, 2, 11)) + { + snd_musicdevice = SNDDEVICE_NONE; + } + } +#endif } diff --git a/src/s_sound.c b/src/s_sound.c index 9b4f71aa..1c56efb2 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -69,14 +69,6 @@ #define NORM_PRIORITY 64 #define NORM_SEP 128 -// Disable music on OSX by default; there are problems with SDL_mixer. - -#ifndef __APPLE__ -#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB -#else -#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE -#endif - typedef struct { // sound information (if null, channel avail.) @@ -128,7 +120,7 @@ static musicinfo_t *mus_playing = NULL; int numChannels = 8; -int snd_musicdevice = DEFAULT_MUSIC_DEVICE; +int snd_musicdevice = SNDDEVICE_SB; int snd_sfxdevice = SNDDEVICE_SB; // Sound modules -- cgit v1.2.3 From 1dfad75870fa6b8e0a3aa41b3f9bb6ea260c9d9f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 21 Nov 2009 00:38:16 +0000 Subject: Don't crash if key settings are set in a configuration file that are out of range (thanks entryway). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1732 --- src/m_config.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index 73f0da2c..a2f3ac58 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -1237,7 +1237,14 @@ static void LoadDefaultCollection(default_collection_t *collection) intparm = ParseIntParameter(strparm); defaults[i].untranslated = intparm; - intparm = scantokey[intparm]; + if (intparm >= 0 && intparm < 128) + { + intparm = scantokey[intparm]; + } + else + { + intparm = 0; + } defaults[i].original_translated = intparm; * (int *) def->location = intparm; -- cgit v1.2.3 From 3d577f70fb8a41a6609db76bdabae30f064a95bc Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 21 Nov 2009 16:46:17 +0000 Subject: Fix launch of game from setup tool. Subversion-branch: /branches/raven-branch Subversion-revision: 1738 --- src/setup/mode.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/setup/mode.c b/src/setup/mode.c index ea90c76f..702db67d 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -162,16 +162,18 @@ void InitBindings(void) static void SetExecutable(mission_config_t *config) { + char *extension; + free(executable); #ifdef _WIN32 - executable = malloc(strlen(config->executable) + 5); - sprintf(executable, "%s.exe", config->executable); + extension = ".exe"; #else - executable = malloc(strlen(INSTALL_DIR) + strlen(config->executable) + 2); - sprintf(executable, "%s%c%s", INSTALL_DIR, DIR_SEPARATOR, - config->executable); + extension = ""; #endif + + executable = malloc(strlen(config->executable) + 5); + sprintf(executable, "%s%s", config->executable, extension); } static void SetMission(mission_config_t *config) -- cgit v1.2.3 From 372ad50b2260e5e03c251ae8442a65bd32334cf6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 21 Nov 2009 16:54:05 +0000 Subject: Auto-select SDL slice size based on sample rate. Subversion-branch: /branches/raven-branch Subversion-revision: 1739 --- src/i_sdlsound.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index 3273907e..0b3f8aa3 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -49,6 +49,7 @@ #include "doomtype.h" #define LOW_PASS_FILTER +#define MAX_SOUND_SLICE_TIME 70 /* ms */ #define NUM_CHANNELS 16 static boolean sound_initialized = false; @@ -681,11 +682,37 @@ static void I_SDL_ShutdownSound(void) sound_initialized = false; } +// Calculate slice size, based on MAX_SOUND_SLICE_TIME. +// The result must be a power of two. + +static int GetSliceSize(void) +{ + int limit; + int n; + + limit = (snd_samplerate * MAX_SOUND_SLICE_TIME) / 1000; + + // Try all powers of two, not exceeding the limit. + + for (n=0;; ++n) + { + // 2^n <= limit < 2^n+1 ? + + if ((1 << (n + 1)) > limit) + { + return (1 << n); + } + } + + // Should never happen? + + return 1024; +} static boolean I_SDL_InitSound(boolean _use_sfx_prefix) -{ +{ int i; - + use_sfx_prefix = _use_sfx_prefix; // No sounds yet @@ -701,7 +728,7 @@ static boolean I_SDL_InitSound(boolean _use_sfx_prefix) return false; } - if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, 1024) < 0) + if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError()); return false; -- cgit v1.2.3 From d0f41d4163fc96168f56155e6f5b36025eea79e4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 21 Nov 2009 17:07:37 +0000 Subject: Make assembly name in setup-manifest.xml use PROGRAM_PREFIX. Remove INSTALL_DIR #define when building setup. Subversion-branch: /branches/raven-branch Subversion-revision: 1740 --- src/setup/Makefile.am | 3 +-- src/setup/setup-manifest.xml.in | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am index 58561b62..07d7c936 100644 --- a/src/setup/Makefile.am +++ b/src/setup/Makefile.am @@ -3,8 +3,7 @@ gamesdir = $(prefix)/games AM_CFLAGS = @SDL_CFLAGS@ \ @SDLMIXER_CFLAGS@ \ - -I$(top_builddir)/textscreen -I.. \ - -DINSTALL_DIR="\"$(gamesdir)\"" + -I$(top_builddir)/textscreen -I.. noinst_LIBRARIES = libsetup.a diff --git a/src/setup/setup-manifest.xml.in b/src/setup/setup-manifest.xml.in index 70ae915e..bac9a05e 100644 --- a/src/setup/setup-manifest.xml.in +++ b/src/setup/setup-manifest.xml.in @@ -3,7 +3,7 @@ + name="@PROGRAM_PREFIX@setup" type="win32"/> -- cgit v1.2.3