Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
813ed67211 |
No files matched your search
+26
-28
@@ -1,9 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
|
||||
endif()
|
||||
|
||||
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
|
||||
# Version change is fine.
|
||||
project(SRB2
|
||||
@@ -16,31 +11,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.")
|
||||
|
||||
if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
set(SRB2_CPACK_GENERATOR "ZIP")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
set(SRB2_CPACK_GENERATOR "TGZ")
|
||||
endif()
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
|
||||
endif()
|
||||
|
||||
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
|
||||
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
|
||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
|
||||
include(CPack)
|
||||
|
||||
# Set up CMAKE path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
@@ -128,12 +102,14 @@ set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
# Set EXE names so the assets CMakeLists can refer to its target
|
||||
set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name")
|
||||
set(SRB2_WIN_EXE_NAME srb2kartdd CACHE STRING "Executable binary output name for DirectDraw build")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(assets)
|
||||
|
||||
|
||||
## config.h generation
|
||||
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||
include(GitUtilities)
|
||||
@@ -142,3 +118,25 @@ git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
|
||||
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
|
||||
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
set(CPACK_GENERATOR "TGZ")
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM} MATCHES "Darwin")
|
||||
set(CPACK_GENERATOR "DragNDrop")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes")
|
||||
set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes")
|
||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
|
||||
include(CPack)
|
||||
@@ -1,6 +1,6 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(GME_PKGCONF LIBGME)
|
||||
libfind_pkg_check_modules(GME_PKGCONF GME)
|
||||
|
||||
find_path(GME_INCLUDE_DIR
|
||||
NAMES gme.h
|
||||
@@ -8,7 +8,6 @@ find_path(GME_INCLUDE_DIR
|
||||
${GME_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include/gme"
|
||||
"/usr/local/include/gme"
|
||||
PATH_SUFFIXES gme
|
||||
)
|
||||
|
||||
find_library(GME_LIBRARY
|
||||
@@ -21,4 +20,4 @@ find_library(GME_LIBRARY
|
||||
|
||||
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
|
||||
set(GME_PROCESS_LIBS GME_LIBRARY)
|
||||
libfind_process(GME)
|
||||
libfind_process(GME)
|
||||
@@ -1,6 +1,6 @@
|
||||
include(LibFindMacros)
|
||||
|
||||
libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT)
|
||||
libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT)
|
||||
|
||||
find_path(OPENMPT_INCLUDE_DIR
|
||||
NAMES libopenmpt.h
|
||||
@@ -8,7 +8,6 @@ find_path(OPENMPT_INCLUDE_DIR
|
||||
${OPENMPT_PKGCONF_INCLUDE_DIRS}
|
||||
"/usr/include/libopenmpt"
|
||||
"/usr/local/include/libopenmpt"
|
||||
PATH_SUFFIXES libopenmpt
|
||||
)
|
||||
|
||||
find_library(OPENMPT_LIBRARY
|
||||
@@ -21,4 +20,4 @@ find_library(OPENMPT_LIBRARY
|
||||
|
||||
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
|
||||
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
|
||||
libfind_process(OPENMPT)
|
||||
libfind_process(OPENMPT)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Version 2.4
|
||||
# Version 2.2
|
||||
# Public Domain, originally written by Lasse Kärkkäinen <tronic>
|
||||
# Maintained at https://github.com/Tronic/cmake-modules
|
||||
# Please send your improvements as pull requests on Github.
|
||||
@@ -52,10 +52,6 @@ function (libfind_pkg_detect PREFIX)
|
||||
if (libraryargs)
|
||||
find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
|
||||
endif()
|
||||
# Read pkg-config version
|
||||
if (${PREFIX}_PKGCONF_VERSION)
|
||||
set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
|
||||
@@ -129,39 +125,24 @@ function (libfind_process PREFIX)
|
||||
|
||||
# Process deps to add to
|
||||
foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
|
||||
if (DEFINED ${i}_INCLUDE_OPTS)
|
||||
if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
|
||||
# The package seems to export option lists that we can use, woohoo!
|
||||
list(APPEND includeopts ${${i}_INCLUDE_OPTS})
|
||||
else()
|
||||
if (DEFINED ${i}_INCLUDE_DIR)
|
||||
# Singular forms can be used
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIR)
|
||||
else()
|
||||
if (DEFINED ${i}_INCLUDE_DIRS)
|
||||
# Plural forms can be used
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIRS)
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (DEFINED ${i}_LIBRARY_OPTS)
|
||||
# The package seems to export option lists that we can use, woohoo!
|
||||
list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
|
||||
else()
|
||||
if (DEFINED ${i}_LIBRARY)
|
||||
# If plural forms don't exist or they equal singular forms
|
||||
if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
|
||||
({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
|
||||
# Singular forms can be used
|
||||
list(APPEND libraryopts ${i}_LIBRARY)
|
||||
else()
|
||||
if (DEFINED ${i}_LIBRARIES)
|
||||
# Plural forms can be used
|
||||
list(APPEND libraryopts ${i}_LIBRARIES)
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!")
|
||||
if (DEFINED ${i}_INCLUDE_DIR)
|
||||
list(APPEND includeopts ${i}_INCLUDE_DIR)
|
||||
endif()
|
||||
if (DEFINED ${i}_LIBRARY)
|
||||
list(APPEND libraryopts ${i}_LIBRARY)
|
||||
endif()
|
||||
else()
|
||||
# Oh no, we don't know the option names
|
||||
message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -228,12 +209,12 @@ function (libfind_process PREFIX)
|
||||
message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
|
||||
message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
|
||||
endif()
|
||||
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
|
||||
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
|
||||
set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
|
||||
set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
|
||||
set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
+7
-19
@@ -191,7 +191,6 @@ set(SRB2_CORE_GAME_SOURCES
|
||||
k_kart.c
|
||||
k_stats.c
|
||||
i_time.c
|
||||
i_threads.c
|
||||
|
||||
p_local.h
|
||||
p_maputl.h
|
||||
@@ -237,23 +236,18 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
||||
"Enable hardware rendering through OpenGL.")
|
||||
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
||||
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
||||
set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
|
||||
"Enable hardware renderer (OpenGL) FBO downsampling support")
|
||||
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
|
||||
"Build a dedicated server.")
|
||||
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
|
||||
"Enable using libbacktrace for crashlogs.")
|
||||
set(SRB2_CONFIG_LTO ON CACHE BOOL
|
||||
"Enable link time optimizations, improves performance at the cost of longer link times.")
|
||||
set(SRB2_CONFIG_ASAN OFF CACHE BOOL
|
||||
"Compile with AddressSanitizer (libasan).")
|
||||
set(SRB2_CONFIG_UBSAN OFF CACHE BOOL
|
||||
"Compile with UndefinedBehaviorSanitizer (libubsan).")
|
||||
|
||||
set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
|
||||
"Enable Saturn specific special packet. Required for using the newer resynch system")
|
||||
set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL
|
||||
"Enable Saturn specific allowjoin toggle.")
|
||||
set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
|
||||
"Enable hardware renderer (OpenGL) FBO downsampling support")
|
||||
|
||||
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
|
||||
"Enable using libbacktrace for crashlogs")
|
||||
|
||||
if(${SRB2_CONFIG_DEDICATED})
|
||||
set(SRB2_CONFIG_HAVE_GME NO)
|
||||
@@ -508,6 +502,7 @@ if(${SRB2_CONFIG_LIBBACKTRACE})
|
||||
if(${LIBBACKTRACE_FOUND})
|
||||
set(SRB2_HAVE_LIBBACKTRACE ON)
|
||||
add_definitions(-DHAVE_LIBBACKTRACE)
|
||||
add_compile_options(-g)
|
||||
else()
|
||||
message(WARNING "You have specified that libbacktrace is available but it was not found.")
|
||||
endif()
|
||||
@@ -555,6 +550,7 @@ if(${SRB2_CONFIG_HWRENDER})
|
||||
set(SRB2_R_OPENGL_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
@@ -593,14 +589,6 @@ endif()
|
||||
# TODO: fix prng and P_CreateBlockmap overflow at some point
|
||||
add_compile_options(-fwrapv)
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
add_compile_options(-O0)
|
||||
else()
|
||||
add_compile_options(-O3)
|
||||
endif()
|
||||
|
||||
add_compile_options(-g)
|
||||
|
||||
add_definitions(-DCMAKECONFIG)
|
||||
|
||||
#add_library(SRB2Core STATIC
|
||||
|
||||
@@ -8,6 +8,11 @@ ifdef MINGW
|
||||
libs+=-mconsole
|
||||
endif
|
||||
|
||||
ifndef NOTHREADS
|
||||
opts+=-DHAVE_THREADS
|
||||
sources+=dedicated/i_threads.c
|
||||
endif
|
||||
|
||||
NOOPENMPT=1
|
||||
NOLIBGME=1
|
||||
NOHW=1
|
||||
|
||||
@@ -27,11 +27,6 @@ endif
|
||||
sources+=$(call List,hardware/Sourcefile)
|
||||
endif
|
||||
|
||||
ifndef NOTHREADS
|
||||
opts+=-DHAVE_THREADS
|
||||
sources+=i_threads.c
|
||||
endif
|
||||
|
||||
ifndef NOMD5
|
||||
sources+=md5.c
|
||||
endif
|
||||
|
||||
@@ -40,6 +40,11 @@ sources+=sdl/mixer_sound.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NOTHREADS
|
||||
opts+=-DHAVE_THREADS
|
||||
sources+=sdl/i_threads.c
|
||||
endif
|
||||
|
||||
ifdef SDL_PKGCONFIG
|
||||
$(eval $(call Use_pkg_config,SDL))
|
||||
else
|
||||
|
||||
+3
-3
@@ -44,14 +44,14 @@
|
||||
#define MAXHUDLINES 20
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_Mutex con_mutex;
|
||||
I_mutex con_mutex;
|
||||
|
||||
// g_in_exiting_signal_handler is an evil hack
|
||||
// to avoid infinite SIGABRT recursion in the signal handler
|
||||
// due to poisoned locks or mach-o kernel not supporting locks in signals
|
||||
// or something like that. idk
|
||||
# define Lock_state() if (!g_in_exiting_signal_handler) { I_LockMutex(&con_mutex); }
|
||||
# define Unlock_state() if (!g_in_exiting_signal_handler) { I_UnlockMutex(con_mutex); }
|
||||
# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); }
|
||||
# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); }
|
||||
#else/*HAVE_THREADS*/
|
||||
# define Lock_state()
|
||||
# define Unlock_state()
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ void CON_Init(void);
|
||||
boolean CON_Responder(event_t *ev);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
extern I_Mutex con_mutex;
|
||||
extern I_mutex con_mutex;
|
||||
#endif
|
||||
|
||||
// set true when screen size has changed, to adapt console
|
||||
|
||||
+4
-4
@@ -2830,11 +2830,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
||||
F_TitleScreenDrawer();
|
||||
CL_DrawConnectionStatus();
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); //Needed for drawing messageboxes on the connection screen
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
I_UpdateNoVsync(); // page flip or blit buffer
|
||||
if (moviemode)
|
||||
@@ -7187,12 +7187,12 @@ void NetUpdate(void)
|
||||
{
|
||||
resptime = nowtime;
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Ticker();
|
||||
refreshdirmenu = 0;
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
CON_Ticker();
|
||||
}
|
||||
|
||||
+6
-8
@@ -223,13 +223,13 @@ void D_ProcessEvents(void)
|
||||
|
||||
// Menu input
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
{
|
||||
eaten = M_Responder(ev);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
|
||||
if (eaten)
|
||||
@@ -244,13 +244,13 @@ void D_ProcessEvents(void)
|
||||
|
||||
// console input
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&con_mutex);
|
||||
I_lock_mutex(&con_mutex);
|
||||
#endif
|
||||
{
|
||||
eaten = CON_Responder(ev);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(con_mutex);
|
||||
I_unlock_mutex(con_mutex);
|
||||
#endif
|
||||
|
||||
if (eaten)
|
||||
@@ -577,11 +577,11 @@ static boolean D_Display(void)
|
||||
vid.recalc = false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); // menu is drawn even on top of everything...
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
// focus lost moved to M_Drawer
|
||||
|
||||
@@ -907,9 +907,7 @@ void D_ClearState(void)
|
||||
|
||||
// okay, stop now
|
||||
// (otherwise the game still thinks we're playing!)
|
||||
#ifdef HAVE_CURL
|
||||
CURLAbortFile();
|
||||
#endif
|
||||
SV_StopServer();
|
||||
SV_ResetServer();
|
||||
|
||||
|
||||
+1
-3
@@ -1009,9 +1009,6 @@ void D_RegisterClientCommands(void)
|
||||
CV_RegisterVar(&cv_gamepadled[i]);
|
||||
}
|
||||
|
||||
CV_RegisterVar(&cv_gamepadledifunfocused);
|
||||
CV_RegisterVar(&cv_rumbleifunfocused);
|
||||
|
||||
CV_RegisterVar(&cv_usemouse);
|
||||
CV_RegisterVar(&cv_invertmouse);
|
||||
CV_RegisterVar(&cv_mousexsens);
|
||||
@@ -2658,6 +2655,7 @@ static void Command_Map_f(void)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
last_map_cmd = I_GetTime();
|
||||
|
||||
size_t first_option;
|
||||
|
||||
+6
-6
@@ -112,7 +112,7 @@ static fileused_t transferFiles[UINT8_MAX + 1];
|
||||
INT32 fileneedednum = 0; // Number of files needed to join the server
|
||||
fileneeded_t fileneeded[MAX_WADFILES] = {}; // List of needed files
|
||||
#ifdef HAVE_THREADS
|
||||
static I_Mutex downloadmutex;
|
||||
static I_mutex downloadmutex;
|
||||
#endif
|
||||
char downloaddir[512] = "DOWNLOAD";
|
||||
|
||||
@@ -1427,7 +1427,7 @@ void CURLPrepareFile(const char* url, int dfilenum)
|
||||
filedownload.http_running = true;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
(void)!I_SpawnThread("http-download", (I_ThreadFn)CURLGetFile, NULL);
|
||||
I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -1440,15 +1440,15 @@ void CURLAbortFile(void)
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
// lock and unlock to wait for the download thread to exit
|
||||
I_LockMutex(&downloadmutex);
|
||||
I_UnlockMutex(downloadmutex);
|
||||
I_lock_mutex(&downloadmutex);
|
||||
I_unlock_mutex(downloadmutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CURLGetFile(void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&downloadmutex);
|
||||
I_lock_mutex(&downloadmutex);
|
||||
#endif
|
||||
CURLMcode mc; /* return code used by curl_multi_wait() */
|
||||
CURLcode easyres; /* Return from easy interface */
|
||||
@@ -1549,7 +1549,7 @@ static void CURLGetFile(void)
|
||||
|
||||
filedownload.http_running = false;
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(downloadmutex);
|
||||
I_unlock_mutex(downloadmutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +1,21 @@
|
||||
# Declare dedicated interface sources
|
||||
|
||||
set(SRB2_DEDICATED_SOURCES
|
||||
i_system.c
|
||||
i_main.c
|
||||
i_video.c
|
||||
i_sound.c
|
||||
i_threads.c
|
||||
dosstr.c
|
||||
endtxt.c
|
||||
)
|
||||
target_sourcefile(c)
|
||||
|
||||
set(SRB2_DEDICATED_HEADERS
|
||||
endtxt.h
|
||||
)
|
||||
|
||||
source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS})
|
||||
|
||||
set(SRB2_DEDICATED_TOTAL_SOURCES
|
||||
${SRB2_CORE_SOURCES}
|
||||
${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES}
|
||||
${SRB2_PNG_HEADERS}
|
||||
${SRB2_CORE_RENDER_SOURCES}
|
||||
${SRB2_CORE_GAME_SOURCES}
|
||||
${SRB2_LUA_SOURCES}
|
||||
${SRB2_LUA_HEADERS}
|
||||
${SRB2_BLUA_SOURCES}
|
||||
${SRB2_BLUA_HEADERS}
|
||||
${SRB2_DEDICATED_SOURCES}
|
||||
${SRB2_DEDICATED_HEADERS}
|
||||
)
|
||||
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||
target_sources(SRB2SDL2 PRIVATE)
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES}
|
||||
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
|
||||
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
|
||||
)
|
||||
target_sources(SRB2SDL2 PRIVATE
|
||||
../win32/win_dbg.c
|
||||
../win32/Srb2win.rc)
|
||||
endif()
|
||||
|
||||
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES})
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||
elseif(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy)
|
||||
else()
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
${CORE_FOUNDATION_LIBRARY}
|
||||
)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||
|
||||
# Configure the app bundle icon and plist properties
|
||||
target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
|
||||
set_target_properties(SRB2SDL2 PROPERTIES
|
||||
MACOSX_BUNDLE_ICON_FILE "Srb2mac"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
|
||||
|
||||
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
|
||||
)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
@@ -78,27 +24,25 @@ if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
${CORE_LIB}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||
else()
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
m
|
||||
rt
|
||||
pthread
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_HAVE_LIBBACKTRACE})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
|
||||
endif()
|
||||
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
|
||||
|
||||
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
@@ -116,34 +60,19 @@ target_include_directories(SRB2SDL2 PRIVATE
|
||||
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE
|
||||
-DDEDICATED
|
||||
-DHAVE_THREADS
|
||||
)
|
||||
|
||||
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_ASAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_UBSAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
## strip debug symbols into separate file when using gcc
|
||||
# if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
# message(STATUS "Will make separate debug symbols in *.debug")
|
||||
# add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||
# COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||
# COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
||||
# COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||
# )
|
||||
# endif()
|
||||
# endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
message(STATUS "Will make separate debug symbols in *.debug")
|
||||
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||
COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
||||
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#### Installation ####
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
|
||||
@@ -2,5 +2,6 @@ i_system.c
|
||||
i_main.c
|
||||
i_video.c
|
||||
i_sound.c
|
||||
i_threads.c
|
||||
dosstr.c
|
||||
endtxt.c
|
||||
@@ -1381,8 +1381,8 @@ INT32 I_StartupSystem(void)
|
||||
I_Fork();
|
||||
#endif
|
||||
#ifdef HAVE_THREADS
|
||||
I_StartThreads();
|
||||
I_AddExitFunc(I_StopThreads);
|
||||
I_start_threads();
|
||||
I_AddExitFunc(I_stop_threads);
|
||||
#endif
|
||||
I_RegisterSignals();
|
||||
#ifndef NOMUMBLE
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020-2023 by James R.
|
||||
//
|
||||
@@ -9,14 +9,12 @@
|
||||
/// \file i_threads.c
|
||||
/// \brief Multithreading abstraction
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#if defined (__unix__) || defined(UNIXCOMMON)
|
||||
#if defined (__unix__) || (!defined(__APPLE__) && defined (UNIXCOMMON))
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "i_threads.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomtype.h"
|
||||
#include "../i_threads.h"
|
||||
#include "../doomdef.h"
|
||||
|
||||
typedef struct thread_s thread_t;
|
||||
|
||||
@@ -24,7 +22,7 @@ struct thread_s
|
||||
{
|
||||
thread_t *next;
|
||||
void *userdata;
|
||||
I_ThreadFn func;
|
||||
I_thread_fn func;
|
||||
pthread_t thread;
|
||||
};
|
||||
|
||||
@@ -43,8 +41,12 @@ static void *HandleThread(void *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FUNCWARNRV
|
||||
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
|
||||
void
|
||||
I_spawn_thread (
|
||||
const char * name,
|
||||
I_thread_fn entry,
|
||||
void * userdata
|
||||
)
|
||||
{
|
||||
thread_t *thread;
|
||||
(void)name;
|
||||
@@ -64,20 +66,17 @@ int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
|
||||
if (thread == NULL)
|
||||
{
|
||||
thread = malloc(sizeof(thread_t));
|
||||
if (thread == NULL)
|
||||
return false;
|
||||
thread->next = thread_list;
|
||||
thread_list = thread;
|
||||
}
|
||||
|
||||
thread->func = entry;
|
||||
thread->userdata = userdata;
|
||||
int err = pthread_create(&thread->thread, NULL, HandleThread, thread);
|
||||
pthread_create(&thread->thread, NULL, HandleThread, thread);
|
||||
pthread_mutex_unlock(&thread_lock);
|
||||
return err == 0;
|
||||
}
|
||||
|
||||
int I_ThreadIsStopped(void)
|
||||
int I_thread_is_stopped(void)
|
||||
{
|
||||
thread_t *thread;
|
||||
pthread_mutex_lock(&thread_lock);
|
||||
@@ -95,11 +94,11 @@ int I_ThreadIsStopped(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void I_StartThreads(void)
|
||||
void I_start_threads(void)
|
||||
{
|
||||
}
|
||||
|
||||
void I_StopThreads(void)
|
||||
void I_stop_threads(void)
|
||||
{
|
||||
thread_t *thread = thread_list;
|
||||
while (thread != NULL)
|
||||
@@ -110,7 +109,7 @@ void I_StopThreads(void)
|
||||
}
|
||||
}
|
||||
|
||||
void I_LockMutex(I_Mutex *anchor)
|
||||
void I_lock_mutex(I_mutex *anchor)
|
||||
{
|
||||
pthread_mutex_lock(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -128,25 +127,25 @@ void I_LockMutex(I_Mutex *anchor)
|
||||
pthread_mutex_lock(*anchor);
|
||||
}
|
||||
|
||||
void I_UnlockMutex(I_Mutex id)
|
||||
void I_unlock_mutex(I_mutex id)
|
||||
{
|
||||
pthread_mutex_unlock(id);
|
||||
}
|
||||
|
||||
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
|
||||
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||
{
|
||||
I_Assert(mutexId != NULL);
|
||||
I_Assert(mutex_id != NULL);
|
||||
pthread_mutex_lock(&thread_lock);
|
||||
if (*condAnchor == NULL)
|
||||
if (*cond_anchor == NULL)
|
||||
{
|
||||
*condAnchor = malloc(sizeof(pthread_cond_t));
|
||||
pthread_cond_init(*condAnchor, NULL);
|
||||
*cond_anchor = malloc(sizeof(pthread_cond_t));
|
||||
pthread_cond_init(*cond_anchor, NULL);
|
||||
}
|
||||
pthread_mutex_unlock(&thread_lock);
|
||||
pthread_cond_wait(*condAnchor, mutexId);
|
||||
pthread_cond_wait(*cond_anchor, mutex_id);
|
||||
}
|
||||
|
||||
void I_WakeOneCond(I_Cond *anchor)
|
||||
void I_wake_one_cond(I_cond *anchor)
|
||||
{
|
||||
pthread_mutex_lock(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -158,7 +157,7 @@ void I_WakeOneCond(I_Cond *anchor)
|
||||
pthread_cond_signal(*anchor);
|
||||
}
|
||||
|
||||
void I_WakeAllCond(I_Cond *anchor)
|
||||
void I_wake_all_cond(I_cond *anchor)
|
||||
{
|
||||
pthread_mutex_lock(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -169,17 +168,12 @@ void I_WakeAllCond(I_Cond *anchor)
|
||||
pthread_mutex_unlock(&thread_lock);
|
||||
pthread_cond_broadcast(*anchor);
|
||||
}
|
||||
|
||||
thread_handle_t I_GetCurrentThread(void)
|
||||
{
|
||||
return pthread_self();
|
||||
}
|
||||
#elif defined (_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#include "i_threads.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomtype.h"
|
||||
#include "../i_threads.h"
|
||||
#include "../doomdef.h"
|
||||
#include "../doomtype.h"
|
||||
|
||||
typedef struct thread_s thread_t;
|
||||
|
||||
@@ -187,9 +181,9 @@ struct thread_s
|
||||
{
|
||||
thread_t *next;
|
||||
void *userdata;
|
||||
I_ThreadFn func;
|
||||
I_thread_fn func;
|
||||
HANDLE thread;
|
||||
DWORD threadId;
|
||||
DWORD thread_id;
|
||||
};
|
||||
|
||||
// we use a linked list to avoid moving memory blocks when allocating new threads.
|
||||
@@ -207,8 +201,7 @@ static DWORD __stdcall HandleThread(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FUNCWARNRV
|
||||
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
|
||||
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
|
||||
{
|
||||
thread_t *thread;
|
||||
(void)name;
|
||||
@@ -226,20 +219,17 @@ int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
|
||||
if (thread == NULL)
|
||||
{
|
||||
thread = malloc(sizeof(thread_t));
|
||||
if (thread == NULL)
|
||||
return false;
|
||||
thread->next = thread_list;
|
||||
thread_list = thread;
|
||||
}
|
||||
|
||||
thread->func = entry;
|
||||
thread->userdata = userdata;
|
||||
thread->thread = CreateThread(NULL, 0, HandleThread, thread, 0, &thread->threadId);
|
||||
thread->thread = CreateThread(NULL, 0, HandleThread, thread, 0, &thread->thread_id);
|
||||
LeaveCriticalSection(&thread_lock);
|
||||
return thread->thread != NULL;
|
||||
}
|
||||
|
||||
int I_ThreadIsStopped(void)
|
||||
int I_thread_is_stopped(void)
|
||||
{
|
||||
thread_t *thread;
|
||||
EnterCriticalSection(&thread_lock);
|
||||
@@ -257,12 +247,12 @@ int I_ThreadIsStopped(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void I_StartThreads(void)
|
||||
void I_start_threads(void)
|
||||
{
|
||||
InitializeCriticalSection(&thread_lock);
|
||||
}
|
||||
|
||||
void I_StopThreads(void)
|
||||
void I_stop_threads(void)
|
||||
{
|
||||
thread_t *thread = thread_list;
|
||||
while (thread != NULL)
|
||||
@@ -274,7 +264,7 @@ void I_StopThreads(void)
|
||||
DeleteCriticalSection(&thread_lock);
|
||||
}
|
||||
|
||||
void I_LockMutex(I_Mutex *anchor)
|
||||
void I_lock_mutex(I_mutex *anchor)
|
||||
{
|
||||
EnterCriticalSection(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -286,25 +276,25 @@ void I_LockMutex(I_Mutex *anchor)
|
||||
EnterCriticalSection(*anchor);
|
||||
}
|
||||
|
||||
void I_UnlockMutex(I_Mutex id)
|
||||
void I_unlock_mutex(I_mutex id)
|
||||
{
|
||||
LeaveCriticalSection(id);
|
||||
}
|
||||
|
||||
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
|
||||
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||
{
|
||||
I_Assert(mutexId != NULL);
|
||||
I_Assert(mutex_id != NULL);
|
||||
EnterCriticalSection(&thread_lock);
|
||||
if (*condAnchor == NULL)
|
||||
if (*cond_anchor == NULL)
|
||||
{
|
||||
*condAnchor = malloc(sizeof(CONDITION_VARIABLE));
|
||||
InitializeConditionVariable(*condAnchor);
|
||||
*cond_anchor = malloc(sizeof(CONDITION_VARIABLE));
|
||||
InitializeConditionVariable(*cond_anchor);
|
||||
}
|
||||
LeaveCriticalSection(&thread_lock);
|
||||
SleepConditionVariableCS(*condAnchor, mutexId, INFINITE);
|
||||
SleepConditionVariableCS(*cond_anchor, mutex_id, INFINITE);
|
||||
}
|
||||
|
||||
void I_WakeOneCond(I_Cond *anchor)
|
||||
void I_wake_one_cond(I_cond *anchor)
|
||||
{
|
||||
EnterCriticalSection(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -316,7 +306,7 @@ void I_WakeOneCond(I_Cond *anchor)
|
||||
WakeConditionVariable(*anchor);
|
||||
}
|
||||
|
||||
void I_WakeAllCond(I_Cond *anchor)
|
||||
void I_wake_all_cond(I_cond *anchor)
|
||||
{
|
||||
EnterCriticalSection(&thread_lock);
|
||||
if (*anchor == NULL)
|
||||
@@ -327,66 +317,48 @@ void I_WakeAllCond(I_Cond *anchor)
|
||||
LeaveCriticalSection(&thread_lock);
|
||||
WakeAllConditionVariable(*anchor);
|
||||
}
|
||||
|
||||
void *I_GetCurrentThread(void)
|
||||
{
|
||||
return GetCurrentThread();
|
||||
}
|
||||
#else
|
||||
#include "i_threads.h"
|
||||
|
||||
FUNCWARNRV
|
||||
int I_SpawnThread(const char *name, I_ThreadFn entry, void *userdata)
|
||||
void I_spawn_thread(const char *name, I_thread_fn entry, void *userdata)
|
||||
{
|
||||
(void)name;
|
||||
entry(userdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
int I_ThreadIsStopped(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void I_StartThreads(void)
|
||||
int I_thread_is_stopped(void)
|
||||
{
|
||||
}
|
||||
|
||||
void I_StopThreads(void)
|
||||
void I_start_threads(void)
|
||||
{
|
||||
}
|
||||
|
||||
void I_LockMutex(I_Mutex *anchor)
|
||||
void I_stop_threads(void)
|
||||
{
|
||||
}
|
||||
|
||||
void I_lock_mutex(I_mutex *anchor)
|
||||
{
|
||||
(void)anchor;
|
||||
}
|
||||
|
||||
void I_UnlockMutex(I_Mutex id)
|
||||
void I_unlock_mutex(I_mutex id)
|
||||
{
|
||||
(void)id;
|
||||
}
|
||||
|
||||
void I_HoldCond(I_Cond *condAnchor, I_Mutex mutexId)
|
||||
void I_hold_cond(I_cond *cond_anchor, I_mutex mutex_id)
|
||||
{
|
||||
(void)condAnchor;
|
||||
(void)mutexId;
|
||||
(void)cond_anchor;
|
||||
(void)mutex_id;
|
||||
}
|
||||
|
||||
void I_WakeOneCond(I_Cond *anchor)
|
||||
void I_wake_one_cond(I_cond *anchor)
|
||||
{
|
||||
(void)anchor;
|
||||
}
|
||||
|
||||
void I_WakeAllCond(I_Cond *anchor)
|
||||
void I_wake_all_cond(I_cond *anchor)
|
||||
{
|
||||
(void)anchor;
|
||||
}
|
||||
|
||||
void *I_GetCurrentThread(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // HAVE_THREADS
|
||||
@@ -223,8 +223,6 @@ typedef int32_t boolean;
|
||||
|
||||
#define FUNCNOINLINE __attribute__((noinline))
|
||||
|
||||
#define FUNCWARNRV __attribute__((warn_unused_result))
|
||||
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4
|
||||
#ifdef __i386__ // i386 only
|
||||
#define FUNCTARGET(X) __attribute__ ((__target__ (X)))
|
||||
@@ -270,9 +268,6 @@ typedef int32_t boolean;
|
||||
#ifndef FUNCTARGET
|
||||
#define FUNCTARGET(x)
|
||||
#endif
|
||||
#ifndef FUNCWARNRV
|
||||
#define FUNCWARNRV
|
||||
#endif
|
||||
#ifndef ATTRPACK
|
||||
#define ATTRPACK
|
||||
#endif
|
||||
|
||||
+3
-1
@@ -1172,7 +1172,9 @@ void F_StartWaitingPlayers(void)
|
||||
randskin = M_RandomKey(numskins);
|
||||
boolean waithires = skins[randskin].flags && SF_HIRES;
|
||||
|
||||
Z_Free(waitcolormap);
|
||||
if (waitcolormap)
|
||||
Z_Free(waitcolormap);
|
||||
|
||||
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
|
||||
|
||||
if (waithires)
|
||||
|
||||
+2
-2
@@ -388,11 +388,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
||||
if (rendermode != render_none && drawMenu)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_Drawer(); // menu is drawn even on top of wipes
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -317,7 +317,8 @@ void closefilemenu(boolean validsize)
|
||||
coredirmenu = NULL;
|
||||
}
|
||||
|
||||
Z_Free(refreshdirname);
|
||||
if (refreshdirname)
|
||||
Z_Free(refreshdirname);
|
||||
refreshdirname = NULL;
|
||||
}
|
||||
|
||||
@@ -345,7 +346,8 @@ void searchfilemenu(char *tempname)
|
||||
|
||||
if (!menusearch.length)
|
||||
{
|
||||
Z_Free(dirmenu);
|
||||
if (dirmenu)
|
||||
Z_Free(dirmenu);
|
||||
dirmenu = coredirmenu;
|
||||
sizedirmenu = sizecoredirmenu;
|
||||
|
||||
@@ -387,8 +389,8 @@ void searchfilemenu(char *tempname)
|
||||
I_Error("searchfilemenu(): could not create \"No results...\".");
|
||||
sizedirmenu = 1;
|
||||
dir_on[menudepthleft] = 0;
|
||||
Z_Free(tempname);
|
||||
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -503,8 +505,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
{
|
||||
closedir(dirhandle);
|
||||
closefilemenu(false);
|
||||
Z_Free(tempname);
|
||||
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -456,10 +456,10 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
|
||||
|
||||
//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}};
|
||||
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
|
||||
{"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
{"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
|
||||
@@ -523,8 +523,11 @@ void G_ClearRecords(void)
|
||||
INT16 i;
|
||||
for (i = 0; i < NUMMAPS; ++i)
|
||||
{
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
if (mainrecords[i])
|
||||
{
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -81,9 +81,6 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
|
||||
{"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void rumble_off_handle(void)
|
||||
{
|
||||
if (!cv_rumble[0].value)
|
||||
@@ -933,7 +930,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
|
||||
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
|
||||
if (cv_gamepadled[playernum].value == 0
|
||||
|| color >= MAXTRANSLATIONS)
|
||||
{
|
||||
return;
|
||||
@@ -1012,7 +1009,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
|
||||
{
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
|
||||
if (cv_rumble[playernum].value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,9 +116,6 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
extern consvar_t cv_gamepadledifunfocused;
|
||||
extern consvar_t cv_rumbleifunfocused;
|
||||
|
||||
extern INT32 mousex, mousey;
|
||||
|
||||
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
|
||||
|
||||
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
|
||||
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
|
||||
if (floatangle >= 180.0)
|
||||
return 0xffffffff;
|
||||
a1 = (angle_t)lrint(ANG1 * floatangle);
|
||||
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
|
||||
return a1;
|
||||
}
|
||||
|
||||
|
||||
@@ -5444,7 +5444,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
|
||||
fixed_t fixedaiming = AIMINGTODY(aimingangle);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming) * (static_cast<float>(vid.width) / static_cast<float>(vid.height)) / (static_cast<float>(BASEVIDWIDTH) / static_cast<float>(BASEVIDHEIGHT));
|
||||
if (splitscreen == 1) // only for 2 player splitscreen
|
||||
trans->viewaiming *= 2.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->shearing = true;
|
||||
gl_aimingangle = 0;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ md2found:
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
|
||||
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
|
||||
{
|
||||
FILE *f;
|
||||
char name[20], filename[32];
|
||||
|
||||
@@ -3591,30 +3591,22 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
1.0f, -1.0f, 1.0f
|
||||
};
|
||||
|
||||
xfix = 1/((float)screen_texsizew/(float)screen_width);
|
||||
yfix = 1/((float)screen_texsizeh/(float)screen_height);
|
||||
|
||||
const GLfloat scrwf = (float)screen_width;
|
||||
const GLfloat scrwh = (float)screen_height;
|
||||
|
||||
xfix = 1/((float)screen_texsizew/scrwf);
|
||||
yfix = 1/((float)screen_texsizeh/scrwh);
|
||||
|
||||
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
|
||||
// Slight fuzziness
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
uint32_t r = rand();
|
||||
const float stride = 2.f/scrwh;
|
||||
|
||||
const float ystep = 2.f/scrwh * (float)vid.udup/4.f;
|
||||
|
||||
for (i = 0; i < 1; i += ystep)
|
||||
for (i = 0; i < 1; i += stride)
|
||||
{
|
||||
// avoid calling rand thousands of times
|
||||
r ^= r >> 13;
|
||||
r ^= r >> 11;
|
||||
r ^= r << 21;
|
||||
|
||||
fix[2] = (float)(r & 127) / -22000.f * xfix;
|
||||
fix[2] = (float)(rand() % 128) / -22000.f * xfix;
|
||||
fix[0] = fix[2];
|
||||
fix[6] = fix[0] + xfix;
|
||||
fix[4] = fix[2] + xfix;
|
||||
@@ -3632,8 +3624,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
}
|
||||
|
||||
// Upward bar
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
color[0] = color[1] = color[2] = 190;
|
||||
color[3] = 250;
|
||||
@@ -3656,14 +3648,13 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
|
||||
fix[1] = fix[7] += (fix[3] - fix[7])*2;
|
||||
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
// Downward bar
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
//GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
//pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
|
||||
fix[0] = 0.0f;
|
||||
fix[6] = xfix;
|
||||
@@ -3682,7 +3673,6 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
|
||||
fix[1] = fix[7] += (fix[3] - fix[7])*2;
|
||||
screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2;
|
||||
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
@@ -3722,7 +3712,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
{
|
||||
float xfix, yfix;
|
||||
float origaspect, newaspect;
|
||||
float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen
|
||||
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
|
||||
|
||||
static float off[12] =
|
||||
{
|
||||
@@ -3745,19 +3735,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
if (origaspect < newaspect)
|
||||
{
|
||||
xoff = origaspect / newaspect;
|
||||
yoff = 1.0f;
|
||||
yoff = 1;
|
||||
}
|
||||
else if (origaspect > newaspect)
|
||||
{
|
||||
xoff = 1.0f;
|
||||
xoff = 1;
|
||||
yoff = newaspect / origaspect;
|
||||
}
|
||||
|
||||
// float off[12];
|
||||
off[0] = off[3] = -xoff;
|
||||
off[1] = off[10] = -yoff;
|
||||
off[4] = off[7] = yoff;
|
||||
off[6] = off[9] = xoff;
|
||||
off[4] = off[7] = yoff;
|
||||
off[6] = off[9] = xoff;
|
||||
|
||||
// float fix[8];
|
||||
fix[3] = fix[5] = yfix;
|
||||
|
||||
+9
-9
@@ -62,7 +62,7 @@ static int hms_started;
|
||||
|
||||
static char *hms_api;
|
||||
#ifdef HAVE_THREADS
|
||||
static I_Mutex hms_api_mutex;
|
||||
static I_mutex hms_api_mutex;
|
||||
#endif
|
||||
|
||||
static char *hms_server_token;
|
||||
@@ -90,9 +90,9 @@ Printf_url (const char *url)
|
||||
boolean startup;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&con_mutex);
|
||||
I_lock_mutex(&con_mutex);
|
||||
startup = con_startup;
|
||||
I_UnlockMutex(con_mutex);
|
||||
I_unlock_mutex(con_mutex);
|
||||
#else
|
||||
startup = con_startup;
|
||||
#endif
|
||||
@@ -183,7 +183,7 @@ HMS_connect (const char *format, ...)
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&hms_api_mutex);
|
||||
I_lock_mutex(&hms_api_mutex);
|
||||
#endif
|
||||
|
||||
seek = strlen(hms_api) + 1;/* + '/' */
|
||||
@@ -195,7 +195,7 @@ HMS_connect (const char *format, ...)
|
||||
sprintf(url, "%s/", hms_api);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(hms_api_mutex);
|
||||
I_unlock_mutex(hms_api_mutex);
|
||||
#endif
|
||||
|
||||
va_start (ap, format);
|
||||
@@ -477,12 +477,12 @@ HMS_fetch_servers (msg_server_t *list, int query_id)
|
||||
if (address && port)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&ms_QueryId_mutex);
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
{
|
||||
if (query_id != ms_QueryId)
|
||||
doing_shit = 0;
|
||||
}
|
||||
I_UnlockMutex(ms_QueryId_mutex);
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
|
||||
if (! doing_shit)
|
||||
break;
|
||||
@@ -611,14 +611,14 @@ void
|
||||
HMS_set_api (char *api)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&hms_api_mutex);
|
||||
I_lock_mutex(&hms_api_mutex);
|
||||
#endif
|
||||
{
|
||||
free(hms_api);
|
||||
hms_api = Strip_trailing_slashes(api);
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(hms_api_mutex);
|
||||
I_unlock_mutex(hms_api_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -1072,7 +1072,8 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
|
||||
|
||||
HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat
|
||||
|
||||
Z_Free(tempchar);
|
||||
if (tempchar)
|
||||
Z_Free(tempchar);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
// I just want to point out while I'm here that because the data is still
|
||||
@@ -1483,7 +1484,6 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return newstring;
|
||||
}
|
||||
|
||||
@@ -1522,7 +1522,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while (msg[j]) // iterate through msg
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1554,21 +1554,19 @@ static void HU_drawMiniChat(void)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
|
||||
prev_linereturn = false;
|
||||
dx += charwidth;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
linescount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
Z_Free(msg);
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
y = chaty - charheight*(msglines+1);
|
||||
@@ -1600,7 +1598,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while (msg[j]) // iterate through msg
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1645,17 +1643,16 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
dx += charwidth;
|
||||
prev_linereturn = false;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
Z_Free(msg);
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
// decrement addy and make that shit smooth:
|
||||
@@ -1707,7 +1704,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
|
||||
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
|
||||
|
||||
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog
|
||||
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
INT32 j = 0;
|
||||
@@ -1716,7 +1713,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while (msg[j]) // iterate through msg
|
||||
while(msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1761,10 +1758,10 @@ static void HU_drawChatLog(INT32 offset)
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
Z_Free(msg);
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling.
|
||||
|
||||
+10
-4
@@ -1510,8 +1510,11 @@ static boolean SOCK_SetBanUsername(const char *username)
|
||||
username = "Direct IP ban";
|
||||
}
|
||||
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
if (banned[numbans - 1].username)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
}
|
||||
|
||||
banned[numbans - 1].username = Z_StrDup(username);
|
||||
|
||||
@@ -1525,8 +1528,11 @@ static boolean SOCK_SetBanReason(const char *reason)
|
||||
reason = "No reason given";
|
||||
}
|
||||
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
if (banned[numbans - 1].reason)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
}
|
||||
|
||||
banned[numbans - 1].reason = Z_StrDup(reason);
|
||||
|
||||
|
||||
+13
-25
@@ -1,6 +1,6 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020-2023 by James R.
|
||||
// Copyright (C) 2020 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
@@ -14,46 +14,34 @@
|
||||
#ifndef I_THREADS_H
|
||||
#define I_THREADS_H
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*I_ThreadFn)(void *userdata);
|
||||
typedef void (*I_thread_fn)(void *userdata);
|
||||
|
||||
typedef void * I_Mutex;
|
||||
typedef void * I_Cond;
|
||||
typedef void * I_mutex;
|
||||
typedef void * I_cond;
|
||||
|
||||
#ifdef __linux__
|
||||
typedef long unsigned int thread_handle_t;
|
||||
#else
|
||||
typedef void *thread_handle_t;
|
||||
#endif
|
||||
void I_start_threads (void);
|
||||
void I_stop_threads (void);
|
||||
|
||||
void I_StartThreads (void);
|
||||
void I_StopThreads (void);
|
||||
|
||||
FUNCWARNRV
|
||||
int I_SpawnThread (const char *name, I_ThreadFn, void *userdata);
|
||||
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
|
||||
|
||||
/* check in your thread whether to return early */
|
||||
int I_ThreadIsStopped (void);
|
||||
int I_thread_is_stopped (void);
|
||||
|
||||
void I_LockMutex (I_Mutex *);
|
||||
void I_UnlockMutex (I_Mutex);
|
||||
void I_lock_mutex (I_mutex *);
|
||||
void I_unlock_mutex (I_mutex);
|
||||
|
||||
void I_HoldCond (I_Cond *, I_Mutex);
|
||||
void I_hold_cond (I_cond *, I_mutex);
|
||||
|
||||
void I_WakeOneCond (I_Cond *);
|
||||
void I_WakeAllCond (I_Cond *);
|
||||
|
||||
thread_handle_t I_GetCurrentThread(void);
|
||||
void I_wake_one_cond (I_cond *);
|
||||
void I_wake_all_cond (I_cond *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif/*I_THREADS_H*/
|
||||
|
||||
#endif/*HAVE_THREADS*/
|
||||
+2
-1
@@ -99,7 +99,8 @@ void K_EraseStats(void)
|
||||
// The only field we want to remember
|
||||
boolean vanilla = kartstats.vanilla;
|
||||
|
||||
Z_Free(kartstats.copy);
|
||||
if (kartstats.copy)
|
||||
Z_Free(kartstats.copy);
|
||||
|
||||
memset(&kartstats, 0, sizeof(kartstats_t));
|
||||
|
||||
|
||||
@@ -1293,7 +1293,6 @@ static int lib_pPlayRinglossSound(lua_State *L)
|
||||
player_t *player = NULL;
|
||||
mobj_t *damager = NULL;
|
||||
NOHUD
|
||||
LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround");
|
||||
if (!source)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
|
||||
@@ -136,9 +136,18 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
|
||||
{
|
||||
if (list == NULL) return;
|
||||
|
||||
Z_Free(list->items);
|
||||
Z_Free(list->olditems);
|
||||
Z_Free(list->strbuf);
|
||||
if (list->items)
|
||||
{
|
||||
Z_Free(list->items);
|
||||
}
|
||||
if (list->olditems)
|
||||
{
|
||||
Z_Free(list->olditems);
|
||||
}
|
||||
if (list->strbuf)
|
||||
{
|
||||
Z_Free(list->strbuf);
|
||||
}
|
||||
Z_Free(list);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include "lua_hook.h" // cmd errors
|
||||
|
||||
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
|
||||
state_t *astate = NULL;
|
||||
state_t *astate;
|
||||
|
||||
boolean actionsoverridden[NUMACTIONS] = {false};
|
||||
|
||||
|
||||
+21
-18
@@ -45,20 +45,20 @@ int hook_defrosting = 0;
|
||||
|
||||
// List of internal libraries to load from SRB2
|
||||
static lua_CFunction liblist[] = {
|
||||
LUA_EnumLib, // global metatable for enums
|
||||
LUA_SOCLib, // A_Action functions, freeslot
|
||||
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
|
||||
LUA_MathLib, // fixed_t and angle_t math functions
|
||||
LUA_HookLib, // hookAdd and hook-calling functions
|
||||
LUA_ConsoleLib, // console command/variable functions and structs
|
||||
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
|
||||
LUA_MobjLib, // mobj_t, mapthing_t
|
||||
LUA_PlayerLib, // player_t
|
||||
LUA_SkinLib, // skin_t, skins[]
|
||||
LUA_ThinkerLib, // thinker_t
|
||||
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
|
||||
LUA_BlockmapLib, // blockmap stuff
|
||||
LUA_HudLib, // HUD stuff
|
||||
LUA_EnumLib, // global metatable for enums
|
||||
LUA_SOCLib, // A_Action functions, freeslot
|
||||
LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc.
|
||||
LUA_MathLib, // fixed_t and angle_t math functions
|
||||
LUA_HookLib, // hookAdd and hook-calling functions
|
||||
LUA_ConsoleLib, // console command/variable functions and structs
|
||||
LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[]
|
||||
LUA_MobjLib, // mobj_t, mapthing_t
|
||||
LUA_PlayerLib, // player_t
|
||||
LUA_SkinLib, // skin_t, skins[]
|
||||
LUA_ThinkerLib, // thinker_t
|
||||
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
|
||||
LUA_BlockmapLib, // blockmap stuff
|
||||
LUA_HudLib, // HUD stuff
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -66,8 +66,12 @@ static lua_CFunction liblist[] = {
|
||||
static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
|
||||
{
|
||||
(void)ud;
|
||||
(void)osize;
|
||||
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
|
||||
if (nsize == 0) {
|
||||
if (osize != 0)
|
||||
Z_Free(ptr);
|
||||
return NULL;
|
||||
} else
|
||||
return Z_Realloc(ptr, nsize, PU_LUA, NULL);
|
||||
}
|
||||
|
||||
// Panic function Lua calls when there's an unprotected error.
|
||||
@@ -209,8 +213,7 @@ void LUA_ClearState(void)
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID);
|
||||
|
||||
// open srb2 libraries
|
||||
for (i = 0; liblist[i]; i++)
|
||||
{
|
||||
for(i = 0; liblist[i]; i++) {
|
||||
lua_pushcfunction(L, liblist[i]);
|
||||
lua_call(L, 0, 0);
|
||||
}
|
||||
|
||||
+6
-3
@@ -695,13 +695,16 @@ INT32 GIF_close(void)
|
||||
fclose(gif_out);
|
||||
gif_out = NULL;
|
||||
|
||||
Z_Free(gifbwr_buf);
|
||||
if (gifbwr_buf)
|
||||
Z_Free(gifbwr_buf);
|
||||
gifbwr_buf = gifbwr_cur = NULL;
|
||||
|
||||
Z_Free(gifframe_data);
|
||||
if (gifframe_data)
|
||||
Z_Free(gifframe_data);
|
||||
gifframe_data = NULL;
|
||||
|
||||
Z_Free(giflzw_hashTable);
|
||||
if (giflzw_hashTable)
|
||||
Z_Free(giflzw_hashTable);
|
||||
giflzw_hashTable = NULL;
|
||||
|
||||
Z_Free(scrbuf_screens);
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void)
|
||||
void Command_Scale_f(void)
|
||||
{
|
||||
const double scaled = atof(COM_Argv(1));
|
||||
fixed_t scale = DoubleToFixed(scaled);
|
||||
fixed_t scale = FLOAT_TO_FIXED(scaled);
|
||||
|
||||
REQUIRE_DEVMODE;
|
||||
REQUIRE_INLEVEL;
|
||||
|
||||
+6
-3
@@ -248,9 +248,12 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
|
||||
|
||||
void M_ClearConditionSet(UINT8 set)
|
||||
{
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
if (conditionSets[set - 1].numconditions)
|
||||
{
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
}
|
||||
conditionSets[set - 1].achieved = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,6 +265,35 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
|
||||
return INT32_MAX;
|
||||
}
|
||||
|
||||
/** \brief The xs_CRoundToInt function
|
||||
|
||||
\param val double number
|
||||
|
||||
\return Round toward nearest, but ties round toward even
|
||||
*/
|
||||
#if defined(SRB2_BIG_ENDIAN)
|
||||
#define _xs_iexp_ 0
|
||||
#define _xs_iman_ 1
|
||||
#else
|
||||
#define _xs_iexp_ 1 //intel is little endian
|
||||
#define _xs_iman_ 0
|
||||
#endif //BigEndian_
|
||||
|
||||
typedef double real64;
|
||||
|
||||
typedef union _xs_doubleints
|
||||
{
|
||||
real64 val;
|
||||
unsigned ival[2];
|
||||
} _xs_doubleints;
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
|
||||
{
|
||||
_xs_doubleints uval;
|
||||
uval.val = val + 6755399441055744.0;
|
||||
return uval.ival[_xs_iman_];
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fixed_t x;
|
||||
|
||||
+33
-43
@@ -142,7 +142,7 @@ typedef enum
|
||||
} text_enum;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_Mutex m_menu_mutex;
|
||||
I_mutex m_menu_mutex;
|
||||
#endif
|
||||
|
||||
M_waiting_mode_t m_waiting_mode = M_NOT_WAITING;
|
||||
@@ -1967,7 +1967,7 @@ void M_Ticker(void)
|
||||
}
|
||||
|
||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||
I_LockMutex(&ms_ServerList_mutex);
|
||||
I_lock_mutex(&ms_ServerList_mutex);
|
||||
{
|
||||
if (ms_ServerList)
|
||||
{
|
||||
@@ -1976,7 +1976,7 @@ void M_Ticker(void)
|
||||
ms_ServerList = NULL;
|
||||
}
|
||||
}
|
||||
I_UnlockMutex(ms_ServerList_mutex);
|
||||
I_unlock_mutex(ms_ServerList_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4014,14 +4014,14 @@ size_t demolist_all_size = 0;
|
||||
boolean replaynamesloaded = false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_Mutex replayquerymutex;
|
||||
I_mutex replayquerymutex;
|
||||
|
||||
// g_in_exiting_signal_handler is an evil hack
|
||||
// to avoid infinite SIGABRT recursion in the signal handler
|
||||
// due to poisoned locks or mach-o kernel not supporting locks in signals
|
||||
// or something like that. idk
|
||||
# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_LockMutex(&replayquerymutex); }
|
||||
# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_UnlockMutex(replayquerymutex); }
|
||||
# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&replayquerymutex); }
|
||||
# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(replayquerymutex); }
|
||||
#else/*HAVE_THREADS*/
|
||||
# define Lock_search_state()
|
||||
# define Unlock_search_state()
|
||||
@@ -4088,10 +4088,7 @@ static void LoadReplayNames(void)
|
||||
Unlock_search_state();
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
if (!I_SpawnThread("replay-names-load", ReplayNamesLoadThread, replaydirpath))
|
||||
{
|
||||
free(replaydirpath);
|
||||
}
|
||||
I_spawn_thread("replay-names-load", ReplayNamesLoadThread, replaydirpath);
|
||||
#else
|
||||
ReplayNamesLoadThread(replaydirpath);
|
||||
#endif
|
||||
@@ -4722,7 +4719,7 @@ static void M_DrawReplayHut(void)
|
||||
if (y > scaledviewheight-80)
|
||||
{
|
||||
V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
}
|
||||
|
||||
// Draw the cursor
|
||||
@@ -5359,7 +5356,7 @@ void M_PopupMasterServerRules(void)
|
||||
{
|
||||
firstDismissedRulesThisBoot = false;
|
||||
M_StartMessage(va("%s\n(press any key)", rules), NULL, MM_NOTHING);
|
||||
free(rules);
|
||||
Z_Free(rules);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -6563,22 +6560,17 @@ static void M_EraseGuest(INT32 choice)
|
||||
|
||||
static void M_OverwriteGuest(const char *which)
|
||||
{
|
||||
char *rguest;
|
||||
char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
UINT8 *buf;
|
||||
size_t len;
|
||||
len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf);
|
||||
|
||||
if (!len)
|
||||
if (!len) {
|
||||
return;
|
||||
|
||||
rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
|
||||
if (FIL_FileExists(rguest))
|
||||
{
|
||||
}
|
||||
if (FIL_FileExists(rguest)) {
|
||||
M_StopMessage(0);
|
||||
remove(rguest);
|
||||
}
|
||||
|
||||
FIL_WriteFile(rguest, buf, len);
|
||||
Z_Free(rguest);
|
||||
|
||||
@@ -6687,11 +6679,11 @@ static void M_EndGame(INT32 choice)
|
||||
void M_SetWaitingMode(int mode)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
m_waiting_mode = mode;
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6700,11 +6692,11 @@ int M_GetWaitingMode(void)
|
||||
int mode;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
mode = m_waiting_mode;
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
|
||||
return mode;
|
||||
@@ -6716,23 +6708,20 @@ static void Spawn_masterserver_thread(const char *name, void (*thread)(int*))
|
||||
{
|
||||
int *id = malloc(sizeof *id);
|
||||
|
||||
I_LockMutex(&ms_QueryId_mutex);
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
*id = ms_QueryId;
|
||||
I_UnlockMutex(ms_QueryId_mutex);
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
|
||||
if (!I_SpawnThread(name, (I_ThreadFn)thread, id))
|
||||
{
|
||||
free(id);
|
||||
}
|
||||
I_spawn_thread(name, (I_thread_fn)thread, id);
|
||||
}
|
||||
|
||||
static int Same_instance(int id)
|
||||
{
|
||||
int okay;
|
||||
|
||||
I_LockMutex(&ms_QueryId_mutex);
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
okay = ( id == ms_QueryId );
|
||||
I_UnlockMutex(ms_QueryId_mutex);
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
|
||||
return okay;
|
||||
}
|
||||
@@ -6761,9 +6750,9 @@ static void Fetch_servers_thread(int *id)
|
||||
M_SetWaitingMode(M_NOT_WAITING);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&ms_ServerList_mutex);
|
||||
I_lock_mutex(&ms_ServerList_mutex);
|
||||
ms_ServerList = server_list;
|
||||
I_UnlockMutex(ms_ServerList_mutex);
|
||||
I_unlock_mutex(ms_ServerList_mutex);
|
||||
#else
|
||||
CL_QueryServerList(server_list);
|
||||
free(server_list);
|
||||
@@ -6796,7 +6785,7 @@ static void M_SearchServerList(void)
|
||||
serverlistsearchedcount = 0;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&ms_ServerList_mutex);
|
||||
I_lock_mutex(&ms_ServerList_mutex);
|
||||
#endif
|
||||
|
||||
for (UINT32 i = 0; i < serverlistcount; ++i)
|
||||
@@ -6807,7 +6796,7 @@ static void M_SearchServerList(void)
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(ms_ServerList_mutex);
|
||||
I_unlock_mutex(ms_ServerList_mutex);
|
||||
#endif
|
||||
|
||||
if (menuinput.length > 0)
|
||||
@@ -7173,11 +7162,11 @@ static void M_CheckMODVersion(int id)
|
||||
{
|
||||
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_StartMessage(updatestring, NULL, MM_NOTHING);
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -7223,13 +7212,13 @@ static void M_ConnectMenu(INT32 choice)
|
||||
itemOn = 0;
|
||||
|
||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||
I_LockMutex(&ms_QueryId_mutex);
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
{
|
||||
ms_QueryId++;
|
||||
}
|
||||
I_UnlockMutex(ms_QueryId_mutex);
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
|
||||
I_LockMutex(&ms_ServerList_mutex);
|
||||
I_lock_mutex(&ms_ServerList_mutex);
|
||||
{
|
||||
if (ms_ServerList)
|
||||
{
|
||||
@@ -7237,7 +7226,7 @@ static void M_ConnectMenu(INT32 choice)
|
||||
ms_ServerList = NULL;
|
||||
}
|
||||
}
|
||||
I_UnlockMutex(ms_ServerList_mutex);
|
||||
I_unlock_mutex(ms_ServerList_mutex);
|
||||
|
||||
#ifdef UPDATE_ALERT
|
||||
Spawn_masterserver_thread("check-new-version", Check_new_version_thread);
|
||||
@@ -7598,6 +7587,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
||||
|
||||
static void M_DrawServerMenu(void)
|
||||
{
|
||||
|
||||
M_DrawLevelSelectOnly(false, false);
|
||||
#ifdef MASTERSERVER
|
||||
if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting.
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ void M_SetupNextMenu(menu_t *menudef);
|
||||
void M_ClearMenus(boolean callexitmenufunc);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
extern I_Mutex m_menu_mutex;
|
||||
extern I_mutex m_menu_mutex;
|
||||
#endif
|
||||
|
||||
extern menu_t *currentMenu;
|
||||
|
||||
@@ -1205,10 +1205,6 @@ static menuitem_t OP_FocusOptionsMenu[] =
|
||||
{IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140},
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150},
|
||||
|
||||
};
|
||||
|
||||
static const char* OP_FocusOptionsTooltips[] =
|
||||
@@ -1220,8 +1216,6 @@ static const char* OP_FocusOptionsTooltips[] =
|
||||
"Set manual framerate cap while the game is unfocused.",
|
||||
"Should the FOCUS LOST window appear\n while the game is unfocused?",
|
||||
"Displays the mouse cursor while the game is in focus.",
|
||||
"Should gamepad LED indicator change color when unfocused?",
|
||||
"Should gamepad rumble apply when unfocused?",
|
||||
};
|
||||
|
||||
static menuitem_t OP_DataOptionsMenu[] =
|
||||
|
||||
+2
-2
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
|
||||
void M_SaveConfig(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
CLEANUP(Z_Pfree) char *filepath = NULL;
|
||||
char *filepath;
|
||||
|
||||
// make sure not to write back the config until it's been correctly loaded
|
||||
if (!loaded_config)
|
||||
@@ -558,7 +558,7 @@ void M_SaveConfig(const char *filename)
|
||||
// append srb2home to beginning of filename
|
||||
// but check if srb2home isn't already there, first
|
||||
if (!strstr(filename, srb2home))
|
||||
filepath = Z_StrDup(va(pandf, srb2home, filename));
|
||||
filepath = va(pandf,srb2home, filename);
|
||||
else
|
||||
filepath = Z_StrDup(filename);
|
||||
|
||||
|
||||
+32
-37
@@ -41,11 +41,11 @@ static time_t MSLastPing;
|
||||
static char *MSRules;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
static I_Mutex MSMutex;
|
||||
static I_Cond MSCond;
|
||||
static I_mutex MSMutex;
|
||||
static I_cond MSCond;
|
||||
|
||||
# define Lock_state() I_LockMutex (&MSMutex)
|
||||
# define Unlock_state() I_UnlockMutex (MSMutex)
|
||||
# define Lock_state() I_lock_mutex (&MSMutex)
|
||||
# define Unlock_state() I_unlock_mutex (MSMutex)
|
||||
#else/*HAVE_THREADS*/
|
||||
# define Lock_state()
|
||||
# define Unlock_state()
|
||||
@@ -90,10 +90,10 @@ consvar_t cv_masterserver_nagattempts = {"masterserver_nagattempts", "5", CV_SAV
|
||||
|
||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||
int ms_QueryId = 0;
|
||||
I_Mutex ms_QueryId_mutex;
|
||||
I_mutex ms_QueryId_mutex;
|
||||
|
||||
msg_server_t *ms_ServerList = NULL;
|
||||
I_Mutex ms_ServerList_mutex;
|
||||
I_mutex ms_ServerList_mutex;
|
||||
#endif
|
||||
|
||||
UINT16 current_port = 0;
|
||||
@@ -129,11 +129,11 @@ void AddMServCommands(void)
|
||||
static void WarnGUI (void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&m_menu_mutex);
|
||||
I_lock_mutex(&m_menu_mutex);
|
||||
#endif
|
||||
M_PopupMasterServerConnectError();
|
||||
#ifdef HAVE_THREADS
|
||||
I_UnlockMutex(m_menu_mutex);
|
||||
I_unlock_mutex(m_menu_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -168,12 +168,12 @@ char *GetMODVersion(int id)
|
||||
c = HMS_compare_mod_version(buffer, 16);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_LockMutex(&ms_QueryId_mutex);
|
||||
I_lock_mutex(&ms_QueryId_mutex);
|
||||
{
|
||||
if (id != ms_QueryId)
|
||||
c = -1;
|
||||
}
|
||||
I_UnlockMutex(ms_QueryId_mutex);
|
||||
I_unlock_mutex(ms_QueryId_mutex);
|
||||
#endif
|
||||
|
||||
if (c > 0)
|
||||
@@ -219,9 +219,8 @@ static void Get_masterserver_rules(boolean checkfirst)
|
||||
if (HMS_fetch_rules(rules, sizeof rules))
|
||||
{
|
||||
Lock_state();
|
||||
if (MSRules)
|
||||
free(MSRules);
|
||||
MSRules = strdup(rules);
|
||||
Z_Free(MSRules);
|
||||
MSRules = Z_StrDup(rules);
|
||||
|
||||
if (MSRegistered == true)
|
||||
{
|
||||
@@ -341,7 +340,7 @@ Finish_unlist (void)
|
||||
Unlock_state();
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_WakeAllCond(&MSCond);
|
||||
I_wake_all_cond(&MSCond);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -377,7 +376,7 @@ New_server_id (void)
|
||||
Lock_state();
|
||||
{
|
||||
*id = ++MSId;
|
||||
I_WakeAllCond(&MSCond);
|
||||
I_wake_all_cond(&MSCond);
|
||||
}
|
||||
Unlock_state();
|
||||
return id;
|
||||
@@ -392,7 +391,7 @@ Register_server_thread (int *id)
|
||||
{
|
||||
/* wait for previous unlist to finish */
|
||||
while (*id == MSId && MSRegistered)
|
||||
I_HoldCond(&MSCond, MSMutex);
|
||||
I_hold_cond(&MSCond, MSMutex);
|
||||
|
||||
same = ( *id == MSId );/* it could have been a while */
|
||||
}
|
||||
@@ -444,7 +443,7 @@ Change_masterserver_thread (char *api)
|
||||
Lock_state();
|
||||
{
|
||||
while (MSRegistered)
|
||||
I_HoldCond(&MSCond, MSMutex);
|
||||
I_hold_cond(&MSCond, MSMutex);
|
||||
}
|
||||
Unlock_state();
|
||||
|
||||
@@ -464,9 +463,9 @@ void RegisterServer(void)
|
||||
{
|
||||
#ifdef MASTERSERVER
|
||||
#ifdef HAVE_THREADS
|
||||
(void)!I_SpawnThread(
|
||||
I_spawn_thread(
|
||||
"register-server",
|
||||
(I_ThreadFn)Register_server_thread,
|
||||
(I_thread_fn)Register_server_thread,
|
||||
New_server_id()
|
||||
);
|
||||
#else
|
||||
@@ -478,9 +477,9 @@ void RegisterServer(void)
|
||||
static void UpdateServer(void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
(void)!I_SpawnThread(
|
||||
I_spawn_thread(
|
||||
"update-server",
|
||||
(I_ThreadFn)Update_server_thread,
|
||||
(I_thread_fn)Update_server_thread,
|
||||
Server_id()
|
||||
);
|
||||
#else
|
||||
@@ -492,9 +491,9 @@ void UnregisterServer(void)
|
||||
{
|
||||
#ifdef MASTERSERVER
|
||||
#ifdef HAVE_THREADS
|
||||
(void)!I_SpawnThread(
|
||||
I_spawn_thread(
|
||||
"unlist-server",
|
||||
(I_ThreadFn)Unlist_server_thread,
|
||||
(I_thread_fn)Unlist_server_thread,
|
||||
Server_id()
|
||||
);
|
||||
#else
|
||||
@@ -508,7 +507,7 @@ char *GetMasterServerRules(void)
|
||||
char *rules;
|
||||
|
||||
Lock_state();
|
||||
rules = MSRules ? strdup(MSRules) : NULL;
|
||||
rules = MSRules ? Z_StrDup(MSRules) : NULL;
|
||||
Unlock_state();
|
||||
|
||||
return rules;
|
||||
@@ -557,18 +556,14 @@ void MasterClient_Ticker(void)
|
||||
static void
|
||||
Set_api (const char *api)
|
||||
{
|
||||
char *dapi = strdup(api);
|
||||
#ifdef HAVE_THREADS
|
||||
if (!I_SpawnThread(
|
||||
"change-masterserver",
|
||||
(I_ThreadFn)Change_masterserver_thread,
|
||||
dapi
|
||||
))
|
||||
{
|
||||
free(dapi);
|
||||
}
|
||||
I_spawn_thread(
|
||||
"change-masterserver",
|
||||
(I_thread_fn)Change_masterserver_thread,
|
||||
strdup(api)
|
||||
);
|
||||
#else
|
||||
Finish_masterserver_change(dapi);
|
||||
Finish_masterserver_change(strdup(api));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -576,9 +571,9 @@ void
|
||||
Get_rules (void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
(void)!I_SpawnThread(
|
||||
"get-masterserver-rules",
|
||||
(I_ThreadFn)Get_masterserver_rules_thread,
|
||||
I_spawn_thread(
|
||||
"get-masterserver-rules",
|
||||
(I_thread_fn)Get_masterserver_rules_thread,
|
||||
NULL
|
||||
);
|
||||
#else
|
||||
|
||||
+2
-2
@@ -69,10 +69,10 @@ extern consvar_t cv_rendezvousserver;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
extern int ms_QueryId;
|
||||
extern I_Mutex ms_QueryId_mutex;
|
||||
extern I_mutex ms_QueryId_mutex;
|
||||
|
||||
extern msg_server_t *ms_ServerList;
|
||||
extern I_Mutex ms_ServerList_mutex;
|
||||
extern I_mutex ms_ServerList_mutex;
|
||||
#endif
|
||||
#ifdef MASTERSERVER
|
||||
void RegisterServer(void);
|
||||
|
||||
+3
-1
@@ -320,7 +320,9 @@ void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext)
|
||||
*/
|
||||
void P_DeleteGrades(INT16 i)
|
||||
{
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
if (mapheaderinfo[i]->grades)
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
|
||||
mapheaderinfo[i]->grades = NULL;
|
||||
mapheaderinfo[i]->numGradedMares = 0;
|
||||
}
|
||||
|
||||
+2
-1
@@ -6221,7 +6221,8 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
|
||||
// Allocate each list
|
||||
for (i = 0; i < numsectors; i++)
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
if(secthinkers[i].thinkers)
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
|
||||
Z_Free(secthinkers);
|
||||
|
||||
|
||||
+2
-1
@@ -1720,7 +1720,8 @@ void R_InitData(void)
|
||||
|
||||
void R_ClearTextureNumCache(boolean btell)
|
||||
{
|
||||
Z_Free(tidcache);
|
||||
if (tidcache)
|
||||
Z_Free(tidcache);
|
||||
tidcache = NULL;
|
||||
if (btell)
|
||||
CONS_Debug(DBG_SETUP, "Fun Fact: There are %d textures used in this map.\n", tidcachelen);
|
||||
|
||||
+2
-8
@@ -289,14 +289,8 @@ void R_GenerateBlendTables(void)
|
||||
state->LocalPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pLocalPalette, palsize));
|
||||
state->gammaCorrectedPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pGammaCorrectedPalette, palsize));
|
||||
|
||||
if (!I_SpawnThread("blend-tables",
|
||||
R_GenerateBlendTables_Thread, state))
|
||||
{
|
||||
free(state->gammaCorrectedPalette);
|
||||
free(state->LocalPalette);
|
||||
free(state);
|
||||
I_Error("R_GenerateBlendTables: Failed to generate BlendTables\n"); // should we just retry on main thread instead?
|
||||
}
|
||||
I_spawn_thread("blend-tables",
|
||||
R_GenerateBlendTables_Thread, state);
|
||||
#else
|
||||
struct GenerateBlendTables_State state = {pLocalPalette, pGammaCorrectedPalette};
|
||||
R_GenerateBlendTables_Core(&state);
|
||||
|
||||
+12
-8
@@ -925,11 +925,11 @@ void R_ExecuteSetViewSize(void)
|
||||
viewheight = vid.height;
|
||||
|
||||
if (splitscreen)
|
||||
{
|
||||
viewheight >>= 1;
|
||||
|
||||
if (splitscreen > 1)
|
||||
viewwidth >>= 1;
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
viewwidth >>= 1;
|
||||
}
|
||||
|
||||
centerx = viewwidth/2;
|
||||
@@ -956,9 +956,13 @@ void R_ExecuteSetViewSize(void)
|
||||
screenheightarray[i] = (INT16)viewheight;
|
||||
}
|
||||
|
||||
Z_Free(ds_su);
|
||||
Z_Free(ds_sv);
|
||||
Z_Free(ds_sz);
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
|
||||
memset(scalelight, 0xFF, sizeof(scalelight));
|
||||
@@ -1014,8 +1018,8 @@ static void R_InitViewMapping(void)
|
||||
|
||||
for (INT32 i = 0; i < j; i++)
|
||||
{
|
||||
fixed_t dy = abs(i - viewheight*8) << FRACBITS;
|
||||
dy = FixedMul(dy, fovtan);
|
||||
fixed_t dy = (i - viewheight*8)<<FRACBITS;
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -405,8 +405,10 @@ static void Patch_FreeData(patch_t *patch)
|
||||
}*/
|
||||
#endif
|
||||
|
||||
Z_Free(patch->columnofs);
|
||||
Z_Free(patch->columns);
|
||||
if (patch->columnofs)
|
||||
Z_Free(patch->columnofs);
|
||||
if (patch->columns)
|
||||
Z_Free(patch->columns);
|
||||
}
|
||||
|
||||
void Patch_Free(patch_t *patch)
|
||||
|
||||
+9
-12
@@ -57,11 +57,8 @@ visffloor_t visffloor[MAXFFLOORS] = {};
|
||||
INT32 numffloors = 0;
|
||||
|
||||
//SoM: 3/23/2000: Boom visplane hashing routine.
|
||||
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
|
||||
const unsigned int height)
|
||||
{
|
||||
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
|
||||
}
|
||||
#define visplane_hash(picnum,lightlevel,height) \
|
||||
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
@@ -139,7 +136,7 @@ void R_AllocPlaneMemory(void)
|
||||
}
|
||||
|
||||
yslopetab = static_cast<fixed_t*>(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL));
|
||||
spanstart = static_cast<INT32*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
spanstart = static_cast<fixed_t*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -454,7 +451,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||
}
|
||||
}
|
||||
|
||||
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
|
||||
hash = visplane_hash(picnum, lightlevel, height);
|
||||
|
||||
for (check = visplanes[hash]; check; check = check->next)
|
||||
{
|
||||
@@ -565,7 +562,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS);
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||
new_pl = new_visplane(hash);
|
||||
}
|
||||
|
||||
@@ -923,12 +920,12 @@ static void R_SetSlopePlane(drawspandata_t* ds, pslope_t *slope, fixed_t xpos, f
|
||||
|
||||
// m is the v direction vector in view space
|
||||
ang = ANG2RAD(ANGLE_180 - (angle + plangle));
|
||||
m->x = cosf(ang);
|
||||
m->z = sinf(ang);
|
||||
m->x = cos(ang);
|
||||
m->z = sin(ang);
|
||||
|
||||
// n is the u direction vector in view space
|
||||
n->x = sinf(ang);
|
||||
n->z = -cosf(ang);
|
||||
n->x = sin(ang);
|
||||
n->z = -cos(ang);
|
||||
|
||||
plangle >>= ANGLETOFINESHIFT;
|
||||
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
|
||||
|
||||
@@ -246,6 +246,7 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16*
|
||||
if (!(*start < *end))
|
||||
return true;
|
||||
|
||||
|
||||
/** Trims a visplane's horizontal gap to match its render area.
|
||||
*
|
||||
* Visplanes' minx/maxx may sometimes exceed the area they're
|
||||
|
||||
+2
-2
@@ -2880,7 +2880,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markceiling)
|
||||
{
|
||||
if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes
|
||||
ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx-1);
|
||||
ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markceiling = false;
|
||||
|
||||
@@ -2894,7 +2894,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markfloor)
|
||||
{
|
||||
if (floorplane) //SoM: 3/29/2000: Check for null planes
|
||||
floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx-1);
|
||||
floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markfloor = false;
|
||||
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ INT16 *screenheightarray = NULL;
|
||||
|
||||
typedef struct drawseg_xrange_item_s
|
||||
{
|
||||
INT32 x1, x2;
|
||||
INT16 x1, x2;
|
||||
drawseg_t *user;
|
||||
} drawseg_xrange_item_t;
|
||||
|
||||
@@ -391,7 +391,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
||||
|
||||
// allocate space for the frames present and copy sprtemp to it
|
||||
if (spritedef->numframes && // has been allocated
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
{
|
||||
|
||||
Z_Free(spritedef->spriteframes);
|
||||
@@ -489,8 +489,8 @@ void R_InitSprites(void)
|
||||
for (angle = 1; angle < ROTANGLES; angle++)
|
||||
{
|
||||
fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<<FRACBITS));
|
||||
rollcosang[angle] = FLOAT_TO_FIXED(cosf(-fa));
|
||||
rollsinang[angle] = FLOAT_TO_FIXED(sinf(-fa));
|
||||
rollcosang[angle] = FLOAT_TO_FIXED(cos(-fa));
|
||||
rollsinang[angle] = FLOAT_TO_FIXED(sin(-fa));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ typedef struct viddef_s
|
||||
|
||||
INT32 dup; // scale 1, 2, 3 value for menus & overlays
|
||||
INT32 fdup; // same as dup, but exact value when aspect ratio isn't 320/200
|
||||
INT32 udup; // same as dup but does not account for highreshudscale
|
||||
UINT8 smalldup; // factor for a little bit of scaling
|
||||
UINT8 meddup; // factor for moderate, but not full, scaling
|
||||
|
||||
|
||||
+3
-15
@@ -35,6 +35,7 @@ set(SRB2_SDL2_SOURCES
|
||||
i_system.cpp
|
||||
i_ttf.c
|
||||
i_video.c
|
||||
i_threads.c
|
||||
#IMG_xpm.c
|
||||
ogl_sdl.c
|
||||
|
||||
@@ -168,6 +169,7 @@ if(${SDL2_FOUND})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE
|
||||
m
|
||||
@@ -228,20 +230,6 @@ if(${SDL2_FOUND})
|
||||
-DHAVE_THREADS
|
||||
)
|
||||
|
||||
if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_ASAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
||||
endif()
|
||||
|
||||
if(SRB2_CONFIG_UBSAN)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
## strip debug symbols into separate file when using gcc
|
||||
# if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
@@ -308,7 +296,7 @@ if(${SDL2_FOUND})
|
||||
else()
|
||||
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
|
||||
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
getwinlib(SDL2 "SDL2.dll")
|
||||
if(${SRB2_CONFIG_SDL2_USEMIXER})
|
||||
|
||||
+9
-29
@@ -726,9 +726,7 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
|
||||
|
||||
JoySet->dev = NULL;
|
||||
JoySet->oldjoy = -1;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoySet->id = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief SDL info about joystick
|
||||
@@ -785,11 +783,7 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
|
||||
///////////////////////////////////////////////
|
||||
if (JoyInfo[player].dev)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
cv_usejoystick[player].value = JoyInfo[player].id + 1;
|
||||
#else
|
||||
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -891,13 +885,13 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||
{
|
||||
CONS_Printf("Joystick subsystem not started\n");
|
||||
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||
{
|
||||
CONS_Printf("Game Controller subsystem not started\n");
|
||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -908,7 +902,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (num_joy == 0)
|
||||
{
|
||||
CONS_Printf("%s", "Found no joysticks on this system\n");
|
||||
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -931,7 +925,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
|
||||
// Else, we're changing devices, so send neutral joy events
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d device is changing; resetting events...\n", playerIndex+1);
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
|
||||
I_ShutdownJoystick(playerIndex);
|
||||
}
|
||||
|
||||
@@ -939,15 +933,13 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
|
||||
if (JoyInfo[playerIndex].dev == NULL)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: Couldn't open device - %s\n", playerIndex+1, SDL_GetError());
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev));
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
|
||||
#endif
|
||||
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
}
|
||||
@@ -993,9 +985,7 @@ void I_InitJoystick(UINT8 index)
|
||||
|
||||
JoyInfo[index].dev = NULL;
|
||||
JoyInfo[index].oldjoy = -1;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].id = -1;
|
||||
#endif
|
||||
|
||||
if (cv_usejoystick[index].value)
|
||||
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
||||
@@ -1009,27 +999,17 @@ void I_InitJoystick(UINT8 index)
|
||||
break;
|
||||
}
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev);
|
||||
#endif
|
||||
|
||||
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
cv_usejoystick[index].value = JoyInfo[index].id + 1;
|
||||
#else
|
||||
cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
#endif
|
||||
}
|
||||
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||
#else
|
||||
// SDL's device indexes are unstable, so cv_usejoystick may not match
|
||||
// the actual device index. So let's cheat a bit and find the device's current index.
|
||||
JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
#endif
|
||||
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1896,8 +1876,8 @@ INT32 I_StartupSystem(void)
|
||||
I_Fork();
|
||||
#endif
|
||||
#ifdef HAVE_THREADS
|
||||
I_StartThreads();
|
||||
I_AddExitFunc(I_StopThreads);
|
||||
I_start_threads();
|
||||
I_AddExitFunc(I_stop_threads);
|
||||
I_ThreadPoolInit();
|
||||
I_AddExitFunc(I_ThreadPoolShutdown);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_threads.c
|
||||
/// \brief Multithreading abstraction
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
||||
#include "../doomdef.h"
|
||||
#include "../i_threads.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
typedef void * (*Create_fn)(void);
|
||||
|
||||
struct Link;
|
||||
struct Thread;
|
||||
|
||||
typedef struct Link * Link;
|
||||
typedef struct Thread * Thread;
|
||||
|
||||
struct Link
|
||||
{
|
||||
void * data;
|
||||
Link next;
|
||||
Link prev;
|
||||
};
|
||||
|
||||
struct Thread
|
||||
{
|
||||
I_thread_fn entry;
|
||||
void * userdata;
|
||||
|
||||
SDL_Thread * thread;
|
||||
};
|
||||
|
||||
static Link i_thread_pool;
|
||||
static Link i_mutex_pool;
|
||||
static Link i_cond_pool;
|
||||
|
||||
static I_mutex i_thread_pool_mutex;
|
||||
static I_mutex i_mutex_pool_mutex;
|
||||
static I_mutex i_cond_pool_mutex;
|
||||
|
||||
static SDL_atomic_t i_threads_running = {1};
|
||||
|
||||
static Link
|
||||
Insert_link (
|
||||
Link * head,
|
||||
Link link
|
||||
){
|
||||
link->prev = NULL;
|
||||
link->next = (*head);
|
||||
if ((*head))
|
||||
(*head)->prev = link;
|
||||
(*head) = link;
|
||||
return link;
|
||||
}
|
||||
|
||||
static void
|
||||
Free_link (
|
||||
Link * head,
|
||||
Link link
|
||||
){
|
||||
if (link->prev)
|
||||
link->prev->next = link->next;
|
||||
else
|
||||
(*head) = link->next;
|
||||
|
||||
if (link->next)
|
||||
link->next->prev = link->prev;
|
||||
|
||||
free(link->data);
|
||||
free(link);
|
||||
}
|
||||
|
||||
static Link
|
||||
New_link (void *data)
|
||||
{
|
||||
Link link;
|
||||
|
||||
link = malloc(sizeof *link);
|
||||
|
||||
if (! link)
|
||||
abort();
|
||||
|
||||
link->data = data;
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
static void *
|
||||
Identity (
|
||||
Link * pool_anchor,
|
||||
I_mutex pool_mutex,
|
||||
|
||||
void ** anchor,
|
||||
|
||||
Create_fn create_fn
|
||||
){
|
||||
void * id;
|
||||
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
I_lock_mutex(&pool_mutex);
|
||||
{
|
||||
id = SDL_AtomicGetPtr(anchor);
|
||||
|
||||
if (! id)
|
||||
{
|
||||
id = (*create_fn)();
|
||||
|
||||
if (! id)
|
||||
abort();
|
||||
|
||||
Insert_link(pool_anchor, New_link(id));
|
||||
|
||||
SDL_AtomicSetPtr(anchor, id);
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(pool_mutex);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static int
|
||||
Worker (
|
||||
Link link
|
||||
){
|
||||
Thread th;
|
||||
|
||||
th = link->data;
|
||||
|
||||
(*th->entry)(th->userdata);
|
||||
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
SDL_DetachThread(th->thread);
|
||||
Free_link(&i_thread_pool, link);
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(i_thread_pool_mutex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
I_spawn_thread (
|
||||
const char * name,
|
||||
I_thread_fn entry,
|
||||
void * userdata
|
||||
){
|
||||
Link link;
|
||||
Thread th;
|
||||
|
||||
th = malloc(sizeof *th);
|
||||
|
||||
if (! th)
|
||||
abort();/* this is pretty GNU of me */
|
||||
|
||||
th->entry = entry;
|
||||
th->userdata = userdata;
|
||||
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
link = Insert_link(&i_thread_pool, New_link(th));
|
||||
|
||||
if (SDL_AtomicGet(&i_threads_running))
|
||||
{
|
||||
th->thread = SDL_CreateThread(
|
||||
(SDL_ThreadFunction)Worker,
|
||||
name,
|
||||
link
|
||||
);
|
||||
|
||||
if (! th->thread)
|
||||
abort();
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(i_thread_pool_mutex);
|
||||
}
|
||||
|
||||
int
|
||||
I_thread_is_stopped (void)
|
||||
{
|
||||
return ( ! SDL_AtomicGet(&i_threads_running) );
|
||||
}
|
||||
|
||||
void
|
||||
I_start_threads (void)
|
||||
{
|
||||
i_thread_pool_mutex = SDL_CreateMutex();
|
||||
i_mutex_pool_mutex = SDL_CreateMutex();
|
||||
i_cond_pool_mutex = SDL_CreateMutex();
|
||||
|
||||
if (!(
|
||||
i_thread_pool_mutex &&
|
||||
i_mutex_pool_mutex &&
|
||||
i_cond_pool_mutex
|
||||
)){
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
I_stop_threads (void)
|
||||
{
|
||||
Link link;
|
||||
Link next;
|
||||
|
||||
Thread th;
|
||||
SDL_mutex * mutex;
|
||||
SDL_cond * cond;
|
||||
|
||||
if (i_threads_running.value)
|
||||
{
|
||||
/* rely on the good will of thread-san */
|
||||
SDL_AtomicSet(&i_threads_running, 0);
|
||||
|
||||
I_lock_mutex(&i_thread_pool_mutex);
|
||||
{
|
||||
for (
|
||||
link = i_thread_pool;
|
||||
link;
|
||||
link = next
|
||||
){
|
||||
next = link->next;
|
||||
th = link->data;
|
||||
|
||||
SDL_WaitThread(th->thread, NULL);
|
||||
|
||||
free(th);
|
||||
free(link);
|
||||
}
|
||||
}
|
||||
I_unlock_mutex(i_thread_pool_mutex);
|
||||
|
||||
for (
|
||||
link = i_mutex_pool;
|
||||
link;
|
||||
link = next
|
||||
){
|
||||
next = link->next;
|
||||
mutex = link->data;
|
||||
|
||||
SDL_DestroyMutex(mutex);
|
||||
|
||||
free(link);
|
||||
}
|
||||
|
||||
for (
|
||||
link = i_cond_pool;
|
||||
link;
|
||||
link = next
|
||||
){
|
||||
next = link->next;
|
||||
cond = link->data;
|
||||
|
||||
SDL_DestroyCond(cond);
|
||||
|
||||
free(link);
|
||||
}
|
||||
|
||||
SDL_DestroyMutex(i_thread_pool_mutex);
|
||||
SDL_DestroyMutex(i_mutex_pool_mutex);
|
||||
SDL_DestroyMutex(i_cond_pool_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
I_lock_mutex (
|
||||
I_mutex * anchor
|
||||
){
|
||||
SDL_mutex * mutex;
|
||||
|
||||
mutex = Identity(
|
||||
&i_mutex_pool,
|
||||
i_mutex_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateMutex
|
||||
);
|
||||
|
||||
if (SDL_LockMutex(mutex) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_unlock_mutex (
|
||||
I_mutex id
|
||||
){
|
||||
if (SDL_UnlockMutex(id) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_hold_cond (
|
||||
I_cond * cond_anchor,
|
||||
I_mutex mutex_id
|
||||
){
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
cond_anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
if (SDL_CondWait(cond, mutex_id) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_one_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
if (SDL_CondSignal(cond) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
I_wake_all_cond (
|
||||
I_cond * anchor
|
||||
){
|
||||
SDL_cond * cond;
|
||||
|
||||
cond = Identity(
|
||||
&i_cond_pool,
|
||||
i_cond_pool_mutex,
|
||||
anchor,
|
||||
(Create_fn)SDL_CreateCond
|
||||
);
|
||||
|
||||
if (SDL_CondBroadcast(cond) == -1)
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif // HAVE_THREADS
|
||||
@@ -784,11 +784,7 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.type = ev_joystick + i;
|
||||
break;
|
||||
@@ -848,11 +844,7 @@ static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.data1 = hat_buttons_base[i];
|
||||
break;
|
||||
@@ -914,11 +906,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
if (evt.which == JoyInfo[i].id)
|
||||
#else
|
||||
if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)))
|
||||
#endif
|
||||
{
|
||||
event.data1 = buttons_base[i];
|
||||
break;
|
||||
|
||||
@@ -1107,7 +1107,7 @@ UINT32 I_GetSongPosition(void)
|
||||
|
||||
void I_UpdateSongLagThreshold(void)
|
||||
{
|
||||
stutter_threshold = (UINT32)(cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100)));
|
||||
stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100));
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "../m_fixed.h"
|
||||
|
||||
// SDL2 stub macro
|
||||
@@ -41,10 +39,8 @@ typedef struct SDLJoyInfo_s
|
||||
{
|
||||
/// Controller handle
|
||||
SDL_GameController *dev;
|
||||
#if (SDL_VERSION_ATLEAST(2,32,4))
|
||||
/// Controller index
|
||||
INT32 id;
|
||||
#endif
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
|
||||
+13
-11
@@ -465,7 +465,7 @@ void V_CubeApply(RGBA_t *input)
|
||||
if (!Cubeapply)
|
||||
return;
|
||||
|
||||
linear = ((*input).s.red/255.0f);
|
||||
linear = ((*input).s.red/255.0);
|
||||
#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2)
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
@@ -475,21 +475,21 @@ void V_CubeApply(RGBA_t *input)
|
||||
working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]);
|
||||
}
|
||||
|
||||
linear = ((*input).s.green/255.0f);
|
||||
linear = ((*input).s.green/255.0);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = dolerp(working[0][q], working[1][q]);
|
||||
working[1][q] = dolerp(working[2][q], working[3][q]);
|
||||
}
|
||||
|
||||
linear = ((*input).s.blue/255.0f);
|
||||
linear = ((*input).s.blue/255.0);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = 255*dolerp(working[0][q], working[1][q]);
|
||||
if (working[0][q] > 255.0f)
|
||||
working[0][q] = 255.0f;
|
||||
else if (working[0][q] < 0.0f)
|
||||
working[0][q] = 0.0f;
|
||||
working[0][q] = 0.0;
|
||||
}
|
||||
#undef dolerp
|
||||
|
||||
@@ -1760,15 +1760,17 @@ void V_DrawVhsEffect(boolean rewind)
|
||||
if (cv_reducevfx.value)
|
||||
return;
|
||||
|
||||
barsize = vid.udup << 5;
|
||||
updistort = vid.udup << (rewind ? 5 : 3);
|
||||
const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT);
|
||||
|
||||
barsize = dup << 5;
|
||||
updistort = dup << (rewind ? 5 : 3);
|
||||
downdistort = updistort >> 1;
|
||||
|
||||
if (rewind)
|
||||
V_DrawVhsEffect(false); // experimentation
|
||||
|
||||
upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
|
||||
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
|
||||
upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f));
|
||||
downbary += renderdeltatics * (dup * (rewind ? 2 : 1));
|
||||
|
||||
if (upbary < -barsize*FRACUNIT)
|
||||
upbary = vid.height << FRACBITS;
|
||||
@@ -3716,7 +3718,9 @@ void V_DoPostProcessor(INT32 view, INT32 param)
|
||||
// Make sure table is built
|
||||
if (heatshifter == NULL || lastheight != viewheight)
|
||||
{
|
||||
Z_Free(heatshifter);
|
||||
if (heatshifter)
|
||||
Z_Free(heatshifter);
|
||||
|
||||
heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL);
|
||||
|
||||
for (y = 0; y < viewheight; y++)
|
||||
@@ -3926,8 +3930,6 @@ void V_Recalc(void)
|
||||
vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT;
|
||||
}
|
||||
|
||||
vid.udup = vid.dup;
|
||||
|
||||
if (loaded_config // this could use a better name, since it is more and indicator that early startup is done and its safe to do sketchy shit now :chaosleep:
|
||||
&& (vid.width > 720) && (vid.height > 1280)) // ehhhh well this thing has so many issues, so ill lock it to higher resolutions instead
|
||||
{
|
||||
|
||||
+4
-3
@@ -122,9 +122,7 @@ void W_Shutdown(void)
|
||||
|
||||
if (wad->handle)
|
||||
fclose(wad->handle);
|
||||
|
||||
Z_Free(wad->filename);
|
||||
|
||||
while (wad->numlumps--)
|
||||
{
|
||||
Z_Free(wad->lumpinfo[wad->numlumps].longname);
|
||||
@@ -2732,7 +2730,10 @@ void vres_Free(virtres_t* vres)
|
||||
|
||||
while (vres->numlumps--)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
if (vres->vlumps[vres->numlumps].data)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
}
|
||||
|
||||
Z_Free(vres->vlumps);
|
||||
|
||||
@@ -75,8 +75,6 @@ typedef struct memblock_s
|
||||
#define MEMORY(x) (void *)((uintptr_t)(x) + sizeof(memblock_t) + ALIGNPAD)
|
||||
#define MEMBLOCK(x) (memblock_t *)((uintptr_t)(x) - ALIGNPAD - sizeof(memblock_t))
|
||||
|
||||
static thread_handle_t main_thread;
|
||||
|
||||
// both the head and tail of the zone memory block list
|
||||
static memblock_t head;
|
||||
|
||||
@@ -110,7 +108,6 @@ static void Command_Memdump_f(void);
|
||||
void Z_Init(void)
|
||||
{
|
||||
size_t total, memfree;
|
||||
main_thread = I_GetCurrentThread();
|
||||
|
||||
memset(&head, 0x00, sizeof(head));
|
||||
|
||||
@@ -146,8 +143,6 @@ void Z_Free(void *ptr)
|
||||
{
|
||||
memblock_t *block;
|
||||
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
@@ -242,8 +237,6 @@ void *Z_Malloc(size_t size, INT32 tag, void *user)
|
||||
memblock_t *block;
|
||||
void *ptr;
|
||||
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
#ifdef ZDEBUG2
|
||||
CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line);
|
||||
#endif
|
||||
@@ -307,8 +300,6 @@ void *Z_Calloc2(size_t size, INT32 tag, void *user, const char *file, INT32 line
|
||||
void *Z_Calloc(size_t size, INT32 tag, void *user)
|
||||
#endif
|
||||
{
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
#ifdef VALGRIND_MEMPOOL_ALLOC
|
||||
Z_calloc = true;
|
||||
#endif
|
||||
@@ -344,8 +335,6 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
|
||||
memblock_t *block;
|
||||
size_t copysize;
|
||||
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
#ifdef ZDEBUG2
|
||||
CONS_Debug(DBG_MEMORY, "Z_Realloc %s:%d\n", file, line);
|
||||
#endif
|
||||
@@ -425,8 +414,6 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag)
|
||||
{
|
||||
memblock_t *block, *next;
|
||||
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
#ifdef ZDEBUG
|
||||
Z_CheckHeap2(file, line);
|
||||
#else
|
||||
@@ -460,8 +447,6 @@ void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *))
|
||||
{
|
||||
memblock_t *block, *next;
|
||||
|
||||
I_Assert(I_GetCurrentThread() == main_thread);
|
||||
|
||||
if (!iterfunc)
|
||||
I_Error("Z_IterateTags: no iterator function was given");
|
||||
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ void Z_Init(void);
|
||||
|
||||
// Z_Free and alloc with alignment
|
||||
#ifdef ZDEBUG
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Realloc(p,s,t,u) Z_Realloc2(p,s, t, u, __FILE__, __LINE__)
|
||||
|
||||
Reference in new issue
Block a user