From f0b946c3cf73266d1d849e424a37330c39707bd1 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Wed, 6 Nov 2013 13:37:34 -0500 Subject: [PATCH 1/3] - Allow use of system GME library. It defaults to forcing the use of the internal library at least for now though. --- CMakeLists.txt | 19 ++++++++++++++++++- src/CMakeLists.txt | 7 +++---- src/sound/music_gme.cpp | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4740603b0..3715cdac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(ZDoom) list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ) include( CreateLaunchers ) +include( FindPackageHandleStandardArgs ) # Generator expression are available some time in CMake 2.8. Due to # cmake_minimum_required, we can assume a minor version of > 7 implies major >= 2 @@ -72,6 +73,13 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") find_package( BZip2 ) find_package( JPEG ) find_package( ZLIB ) +# GME +find_path( GME_INCLUDE_DIR gme.h ) +find_library( GME_LIBRARIES gme ) +mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME + REQUIRED_VARS GME_LIBRARIES GME_INCLUDE_DIR +) if( MSVC ) # Eliminate unreferenced functions and data @@ -125,6 +133,7 @@ set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" ) option(FORCE_INTERNAL_ZLIB "Use internal zlib") option(FORCE_INTERNAL_JPEG "Use internal jpeg") option(FORCE_INTERNAL_BZIP2 "Use internal bzip2") +option(FORCE_INTERNAL_GME "Use internal gme" ON) if( ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB ) message( STATUS "Using system zlib" ) @@ -156,11 +165,19 @@ else( BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2 ) set( BZIP2_LIBRARY bz2 ) endif( BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2 ) +if( GME_FOUND AND NOT FORCE_INTERNAL_GME ) + message( STATUS "Using system gme library ${GME_INCLUDE_DIR}" ) +else( GME_FOUND AND NOT FORCE_INTERNAL_GME ) + message( STATUS "Using internal gme library" ) + add_subdirectory( game-music-emu ) + set( GME_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/game-music-emu" ) + set( GME_LIBRARIES gme ) +endif( GME_FOUND AND NOT FORCE_INTERNAL_GME ) + set( LZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lzma/C" ) add_subdirectory( lzma ) add_subdirectory( tools ) -add_subdirectory( game-music-emu ) add_subdirectory( dumb ) add_subdirectory( gdtoa ) add_subdirectory( wadsrc ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9506e6a59..268c1d705 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -503,8 +503,8 @@ add_custom_target( revision_check ALL # Libraries ZDoom needs message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" ) -set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${FMOD_LIBRARY}" ) -include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" ) +set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${FMOD_LIBRARY}" ) +include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" ) if( FLUIDSYNTH_FOUND ) if( NOT DYN_FLUIDSYNTH) @@ -1065,7 +1065,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") set( ZDOOM_LIBS ${ZDOOM_LIBS} nsl socket) endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") -target_link_libraries( zdoom ${ZDOOM_LIBS} gme gdtoa dumb lzma ) +target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) include_directories( . g_doom g_heretic @@ -1079,7 +1079,6 @@ include_directories( . thingdef timidity xlat - ../game-music-emu/gme ../gdtoa ../dumb/include ${CMAKE_BINARY_DIR}/gdtoa diff --git a/src/sound/music_gme.cpp b/src/sound/music_gme.cpp index 0c3d8c8c3..7f017b7d2 100644 --- a/src/sound/music_gme.cpp +++ b/src/sound/music_gme.cpp @@ -40,7 +40,7 @@ #include "i_musicinterns.h" #include "c_cvars.h" #include "critsec.h" -#include "gme.h" +#include #include "v_text.h" // MACROS ------------------------------------------------------------------ From 34457ce737ed2b67d7c928f27d853cc4a76a3de1 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Wed, 6 Nov 2013 13:42:05 -0500 Subject: [PATCH 2/3] - Applied VoidMage's patch to strip color codes from system console on SDL platforms. --- src/sdl/i_system.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ba126bf54..03cbd74bf 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -422,7 +422,27 @@ void I_SetIWADInfo () void I_PrintStr (const char *cp) { - fputs (cp, stdout); + // Strip out any color escape sequences before writing to the log file + char * copy = new char[strlen(cp)+1]; + const char * srcp = cp; + char * dstp = copy; + + while (*srcp != 0) + { + if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) + { + *dstp++=*srcp++; + } + else + { + if (srcp[1]!=0) srcp+=2; + else break; + } + } + *dstp=0; + + fputs (copy, stdout); + delete [] copy; fflush (stdout); } From a967b05290f324787358b751b06d145d463c6629 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Mon, 11 Nov 2013 20:42:54 +1300 Subject: [PATCH 3/3] Improvements to restoring stalled netgames - The waiting message is now always cleared, regardless if it needed to be in the first place. It's a rather simple for-loop so I doubt it matters. - Nodes are also cleared from the list if they catch up while other nodes are still behind. - "lastglobalrecvtime" is now bumped after the waiting loop if a tic was successful, rather then bumping it every time a packet was received. It appears that you can receive a packet before the game knows it stalled, thus stalling it anyway. - Instead of comparing the nettics to the local node, all nodes are tested against gametic+counts (the real reason why the game has stopped). - More then one node can be marked as late at any one time. - In a packet-server game, the arbitrator is now assumed slow, rather then testing it. There is no point, seeing as we already know the game has stalled because of it. --- src/d_net.cpp | 52 ++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 0ea8e58c5..9c4bf14dd 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -704,8 +704,6 @@ void GetPackets (void) } continue; // extra setup packet } - - lastglobalrecvtime = I_GetTime (false); //Update the last time a packet was recieved netnode = doomcom.remotenode; netconsole = playerfornode[netnode] & ~PL_DRONE; @@ -1827,30 +1825,39 @@ void TryRunTics (void) I_Error ("TryRunTics: lowtic < gametic"); // [Ed850] Check to see the last time a packet was recieved. - // If it's longer then 3 seconds, a node has likely stalled. Check which one and re-request its last packet. + // If it's longer then 3 seconds, a node has likely stalled. if(I_GetTime(false) - lastglobalrecvtime >= TICRATE*3) { - int latenode = 0; // Node 0 is the local player, and should always be the highest lastglobalrecvtime = I_GetTime(false); //Bump the count if(NetMode == NET_PeerToPeer || consoleplayer == Net_Arbitrator) { + //Keep the local node in the for loop so we can still log any cases where the local node is /somehow/ late. + //However, we don't send a resend request for sanity reasons. for (i = 0; i < doomcom.numnodes; i++) - if (nodeingame[i] && nettics[i] < nettics[latenode]) - latenode = i; + { + if (nodeingame[i] && nettics[i] < gametic + counts) + { + if (debugfile) + fprintf (debugfile, "%i is slow (%i to %i)\n", + i, nettics[i], gametic+counts); + //Send resend request to the late node. Also mark the node as waiting to display it in the hud. + if(i != 0) + remoteresend[i] = players[playerfornode[i]].waiting = hadlate = true; + } + else + players[playerfornode[i]].waiting = false; + } } - else if (nodeingame[nodeforplayer[Net_Arbitrator]] && - nettics[nodeforplayer[Net_Arbitrator]] < nettics[0]) - { // Likely a packet server game. Only check the packet host. - latenode = Net_Arbitrator; + else + { //Send a resend request to the Arbitrator, as it's obvious we are stuck here. + if (debugfile) + fprintf (debugfile, "Arbitrator is slow (%i to %i)\n", + Net_Arbitrator, nettics[Net_Arbitrator], gametic+counts); + //Send resend request to the Arbitrator. Also mark the Arbitrator as waiting to display it in the hud. + if(i != 0) + remoteresend[Net_Arbitrator] = players[playerfornode[Net_Arbitrator]].waiting = hadlate = true; } - - if (debugfile) - fprintf (debugfile, "lost tics from %i (%i to %i)\n", - latenode, nettics[latenode], gametic); - - if(latenode != 0) // Send resend request to late node (if not yourself... somehow). Also mark the node as waiting to display it in the hud. - remoteresend[latenode] = players[playerfornode[latenode]].waiting = hadlate = true; } // don't stay in here forever -- give the menu a chance to work @@ -1862,12 +1869,11 @@ void TryRunTics (void) } } - if (hadlate) - { - hadlate = false; - for (i = 0; i < MAXPLAYERS; i++) - players[i].waiting = false; - } + //Tic lowtic is high enough to process this gametic. Clear all possible waiting info + hadlate = false; + for (i = 0; i < MAXPLAYERS; i++) + players[i].waiting = false; + lastglobalrecvtime = I_GetTime (false); //Update the last time the game tic'd over // run the count tics if (counts > 0)