From b2c34906ff0ca7dee3fe7edc8c3e7c8aa3ddbed7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Apr 2024 19:24:44 +0200 Subject: [PATCH 01/10] try and fix some compile issues --- src/doomtype.h | 3 +-- src/hardware/hw_md2.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 5a04f77ba..3541e2cf6 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -17,7 +17,7 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ -#ifdef _WIN32 +#if defined (_WIN32) //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H #include @@ -48,7 +48,6 @@ typedef long ssize_t; #define PDWORD_PTR PDWORD #endif #endif - #else #define __STDC_LIMIT_MACROS #include diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 79ca9bf92..5818f01b2 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -70,7 +70,7 @@ #endif #ifndef errno -#include "errno.h" +#include #endif md2_t md2_models[NUMSPRITES]; -- 2.54.0 From bce914df6e760b5aea38f10455e4eb1c36b4b47e Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 6 Apr 2024 01:31:43 +0300 Subject: [PATCH 02/10] Don't call menu drawer in wipes on dedicated servers --- src/f_wipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index 9909de0f0..da5b9dac1 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -383,7 +383,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) I_OsPolling(); I_UpdateNoBlit(); - if (drawMenu) + if (rendermode != render_none && drawMenu) { #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); -- 2.54.0 From 6f293945fd56e75edb8926f13e0af6b3181e0ac4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Apr 2024 18:40:00 +0200 Subject: [PATCH 03/10] add qs22j to cmakelist --- src/CMakeLists.txt | 1084 ++++++++++++++++++++++---------------------- 1 file changed, 543 insertions(+), 541 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2fda45979..ca94f1b95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,541 +1,543 @@ -# SRB2 Core - -# Core sources -set(SRB2_CORE_SOURCES - am_map.c - b_bot.c - command.c - comptime.c - console.c - d_clisrv.c - d_main.c - d_net.c - d_netcmd.c - d_netfil.c - d_protocol.c - dehacked.c - f_finale.c - f_wipe.c - filesrch.c - g_game.c - g_input.c - hu_stuff.c - i_tcp.c - info.c - lzf.c - m_aatree.c - m_anigif.c - m_argv.c - m_bbox.c - m_cheat.c - m_cond.c - m_fixed.c - m_menu.c - m_misc.c - m_perfstats.c - m_queue.c - m_random.c - md5.c - mserv.c - http-mserv.c - s_sound.c - screen.c - sounds.c - st_stuff.c - #string.c - tables.c - v_video.c - w_wad.c - y_inter.c - z_zone.c -) - -set(SRB2_CORE_HEADERS - am_map.h - b_bot.h - byteptr.h - command.h - console.h - d_clisrv.h - d_event.h - d_main.h - d_net.h - d_netcmd.h - d_netfil.h - d_player.h - d_protocol.h - d_think.h - d_ticcmd.h - dehacked.h - doomdata.h - doomdef.h - doomstat.h - doomtype.h - endian.h - f_finale.h - fastcmp.h - filesrch.h - g_game.h - g_input.h - g_state.h - hu_stuff.h - i_joy.h - i_net.h - i_sound.h - i_system.h - i_tcp.h - i_time.h - i_video.h - info.h - keys.h - lzf.h - m_aatree.h - m_anigif.h - m_argv.h - m_bbox.h - m_cheat.h - m_cond.h - m_dllist.h - m_fixed.h - m_menu.h - m_misc.h - m_queue.h - m_perfstats.h - m_random.h - m_swap.h - md5.h - mserv.h - s_sound.h - screen.h - sounds.h - st_stuff.h - tables.h - v_video.h - w_wad.h - y_inter.h - z_zone.h - - config.h.in -) - -set(SRB2_CORE_RENDER_SOURCES - r_bsp.c - r_data.c - r_draw.c - r_fps.c - r_main.c - r_patch.c - r_plane.c - r_segs.c - r_sky.c - r_splats.c - r_things.c - - r_bsp.h - r_data.h - r_defs.h - r_draw.h - r_fps.h - r_local.h - r_main.h - r_patch - r_plane.h - r_segs.h - r_sky.h - r_splats.h - r_state.h - r_things.h -) - -set(SRB2_CORE_GAME_SOURCES - p_ceilng.c - p_enemy.c - p_floor.c - p_inter.c - p_lights.c - p_map.c - p_maputl.c - p_mobj.c - p_polyobj.c - p_saveg.c - p_setup.c - p_sight.c - p_slopes.c - p_spec.c - p_telept.c - p_tick.c - p_user.c - k_kart.c - i_time.c - - p_local.h - p_maputl.h - p_mobj.h - p_polyobj.h - p_pspr.h - p_saveg.h - p_setup.h - p_slopes.h - p_spec.h - p_tick.h - k_kart.h -) - -if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) -endif() - -prepend_sources(SRB2_CORE_SOURCES) -prepend_sources(SRB2_CORE_HEADERS) -prepend_sources(SRB2_CORE_RENDER_SOURCES) -prepend_sources(SRB2_CORE_GAME_SOURCES) - -set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h) -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}) - -### Configuration -set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL - "Enable Lua interpreter support") -set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL - "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") -set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL - "Enable zlib support.") -set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL - "Enable GME support.") -set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL - "Enable OpenMPT support.") -set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL - "Enable Discord rich presence support.") -set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL - "Enable curl support, used for downloading files via HTTP.") -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.") - -### use internal libraries? -if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only - set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL - "Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).") -endif() - -if(${SRB2_CONFIG_HAVE_BLUA}) - add_definitions(-DHAVE_BLUA) - set(SRB2_LUA_SOURCES - lua_baselib.c - lua_blockmaplib.c - lua_consolelib.c - lua_hooklib.c - lua_hudlib.c - lua_hudlib_drawlist.c - lua_infolib.c - lua_maplib.c - lua_mathlib.c - lua_mobjlib.c - lua_playerlib.c - lua_script.c - lua_skinlib.c - lua_thinkerlib.c - lua_udatalib.c - lua_glib.c - ) - set(SRB2_LUA_HEADERS - lua_hook.h - lua_hud.h - lua_hudlib_drawlist.h - lua_libs.h - lua_script.h - lua_udatalib.h - lua_glib.h - ) - - prepend_sources(SRB2_LUA_SOURCES) - prepend_sources(SRB2_LUA_HEADERS) - - source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) - - set(SRB2_BLUA_SOURCES - blua/lapi.c - blua/lauxlib.c - blua/lbaselib.c - blua/ldblib.c - blua/lcode.c - blua/ldebug.c - blua/ldo.c - blua/ldump.c - blua/lfunc.c - blua/lgc.c - blua/linit.c - blua/liolib.c - blua/llex.c - blua/lmem.c - blua/lobject.c - blua/lopcodes.c - blua/lparser.c - blua/lstate.c - blua/lstring.c - blua/lstrlib.c - blua/ltable.c - blua/ltablib.c - blua/ltm.c - blua/lundump.c - blua/lvm.c - blua/lzio.c - ) - set(SRB2_BLUA_HEADERS - blua/lapi.h - blua/lauxlib.h - blua/lcode.h - blua/ldebug.h - blua/ldo.h - blua/lfunc.h - blua/lgc.h - blua/llex.h - blua/llimits.h - blua/lmem.h - blua/lobject.h - blua/lopcodes.h - blua/lparser.h - blua/lstate.h - blua/lstring.h - blua/ltable.h - blua/ltm.h - blua/lua.h - blua/luaconf.h - blua/lualib.h - blua/lundump.h - blua/lvm.h - blua/lzio.h - ) - - prepend_sources(SRB2_BLUA_SOURCES) - prepend_sources(SRB2_BLUA_HEADERS) - - source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) -endif() - -if(${SRB2_CONFIG_HAVE_GME}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(GME_FOUND ON) - set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme") - else() # 32-bit - set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme") - endif() - else() - find_package(GME) - endif() - if(${GME_FOUND}) - set(SRB2_HAVE_GME ON) - add_definitions(-DHAVE_LIBGME) - else() - message(WARNING "You have specified that GME is available but it was not found.") - endif() -endif() - -if(${SRB2_CONFIG_HAVE_DISCORDRPC}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(DISCORDRPC_FOUND ON) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include) - set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc") - else() # 32-bit - set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include) - set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc") - endif() - else() - find_package(DiscordRPC) - endif() - if(${DISCORDRPC_FOUND}) - set(SRB2_HAVE_DISCORDRPC ON) - add_definitions(-DHAVE_DISCORDRPC) - add_definitions(-DUSE_STUN) - set(SRB2_DISCORDRPC_SOURCES discord.c stun.c) - set(SRB2_DISCORDRPC_HEADERS discord.h stun.h) - prepend_sources(SRB2_DISCORDRPC_SOURCES) - prepend_sources(SRB2_DISCORDRPC_HEADERS) - source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS}) - else() - message(WARNING "You have specified that Discord Rich Presence is available but it was not found.") - endif() -endif() - -if(${SRB2_CONFIG_HAVE_OPENMPT}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(OPENMPT_FOUND ON) - set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt") - else() # 32-bit - set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt") - endif() - else() - find_package(OPENMPT) - endif() - if(${OPENMPT_FOUND}) - set(SRB2_HAVE_OPENMPT ON) - add_definitions(-DHAVE_OPENMPT) - else() - message(WARNING "You have specified that OpenMPT is available but it was not found.") - endif() -endif() - -if(${SRB2_CONFIG_HAVE_ZLIB}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(ZLIB_FOUND ON) - set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64") - else() # 32-bit - set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz32") - endif() - else() - find_package(ZLIB) - endif() - if(${ZLIB_FOUND}) - set(SRB2_HAVE_ZLIB ON) - add_definitions(-DHAVE_ZLIB) - else() - message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.") - endif() -endif() - -if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) - if (${ZLIB_FOUND}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(PNG_FOUND ON) - set(PNG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libpng-src) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng64") - else() # 32-bit - set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng32") - endif() - else() - find_package(PNG) - endif() - if(${PNG_FOUND}) - set(SRB2_HAVE_PNG ON) - add_definitions(-DHAVE_PNG) - add_definitions(-D_LARGEFILE64_SOURCE) - set(SRB2_PNG_SOURCES apng.c) - set(SRB2_PNG_HEADERS apng.h) - prepend_sources(SRB2_PNG_SOURCES) - prepend_sources(SRB2_PNG_HEADERS) - source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} - ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) - else() - message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.") - endif() - endif() -endif() - -if(${SRB2_CONFIG_HAVE_CURL}) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(CURL_FOUND ON) - set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl") - else() # 32-bit - set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl") - endif() - else() - find_package(CURL) - endif() - if(${CURL_FOUND}) - set(SRB2_HAVE_CURL ON) - add_definitions(-DHAVE_CURL) - else() - message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.") - endif() -endif() - -if(${SRB2_CONFIG_HWRENDER}) - add_definitions(-DHWRENDER) - set(SRB2_HWRENDER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c - ) - - set (SRB2_HWRENDER_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h - ) - - set(SRB2_R_OPENGL_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c - ) - - 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}) - find_package(OpenGL) - if(${OPENGL_FOUND}) - add_definitions(-DHWRENDER) - add_definitions(-DSTATIC_OPENGL) - else() - message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") - endif() -endif() - - -# Targets - -# Compatibility flag with later versions of GCC -# We should really fix our code to not need this -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) -endif() - -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) -endif() - -add_definitions(-DCMAKECONFIG) - -#add_library(SRB2Core STATIC -# ${SRB2_CORE_SOURCES} -# ${SRB2_CORE_HEADERS} -# ${SRB2_CORE_RENDER_SOURCES} -# ${SRB2_CORE_GAME_SOURCES} -# ${SRB2_LUA_SOURCES} -# ${SRB2_LUA_HEADERS} -# ${SRB2_BLUA_SOURCES} -# ${SRB2_BLUA_HEADERS} -#) - -add_subdirectory(sdl) - -if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE}) - message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(") -endif() +# SRB2 Core + +# Core sources +set(SRB2_CORE_SOURCES + am_map.c + b_bot.c + command.c + comptime.c + console.c + d_clisrv.c + d_main.c + d_net.c + d_netcmd.c + d_netfil.c + d_protocol.c + dehacked.c + f_finale.c + f_wipe.c + filesrch.c + g_game.c + g_input.c + hu_stuff.c + i_tcp.c + info.c + lzf.c + m_aatree.c + m_anigif.c + m_argv.c + m_bbox.c + m_cheat.c + m_cond.c + m_fixed.c + m_menu.c + m_misc.c + m_perfstats.c + m_queue.c + m_random.c + md5.c + mserv.c + http-mserv.c + qs22j.c + s_sound.c + screen.c + sounds.c + st_stuff.c + #string.c + tables.c + v_video.c + w_wad.c + y_inter.c + z_zone.c +) + +set(SRB2_CORE_HEADERS + am_map.h + b_bot.h + byteptr.h + command.h + console.h + d_clisrv.h + d_event.h + d_main.h + d_net.h + d_netcmd.h + d_netfil.h + d_player.h + d_protocol.h + d_think.h + d_ticcmd.h + dehacked.h + doomdata.h + doomdef.h + doomstat.h + doomtype.h + endian.h + f_finale.h + fastcmp.h + filesrch.h + g_game.h + g_input.h + g_state.h + hu_stuff.h + i_joy.h + i_net.h + i_sound.h + i_system.h + i_tcp.h + i_time.h + i_video.h + info.h + keys.h + lzf.h + m_aatree.h + m_anigif.h + m_argv.h + m_bbox.h + m_cheat.h + m_cond.h + m_dllist.h + m_fixed.h + m_menu.h + m_misc.h + m_queue.h + m_perfstats.h + m_random.h + m_swap.h + md5.h + mserv.h + qs22j.h + s_sound.h + screen.h + sounds.h + st_stuff.h + tables.h + v_video.h + w_wad.h + y_inter.h + z_zone.h + + config.h.in +) + +set(SRB2_CORE_RENDER_SOURCES + r_bsp.c + r_data.c + r_draw.c + r_fps.c + r_main.c + r_patch.c + r_plane.c + r_segs.c + r_sky.c + r_splats.c + r_things.c + + r_bsp.h + r_data.h + r_defs.h + r_draw.h + r_fps.h + r_local.h + r_main.h + r_patch + r_plane.h + r_segs.h + r_sky.h + r_splats.h + r_state.h + r_things.h +) + +set(SRB2_CORE_GAME_SOURCES + p_ceilng.c + p_enemy.c + p_floor.c + p_inter.c + p_lights.c + p_map.c + p_maputl.c + p_mobj.c + p_polyobj.c + p_saveg.c + p_setup.c + p_sight.c + p_slopes.c + p_spec.c + p_telept.c + p_tick.c + p_user.c + k_kart.c + i_time.c + + p_local.h + p_maputl.h + p_mobj.h + p_polyobj.h + p_pspr.h + p_saveg.h + p_setup.h + p_slopes.h + p_spec.h + p_tick.h + k_kart.h +) + +if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) +endif() + +prepend_sources(SRB2_CORE_SOURCES) +prepend_sources(SRB2_CORE_HEADERS) +prepend_sources(SRB2_CORE_RENDER_SOURCES) +prepend_sources(SRB2_CORE_GAME_SOURCES) + +set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h) +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}) + +### Configuration +set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL + "Enable Lua interpreter support") +set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL + "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") +set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL + "Enable zlib support.") +set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL + "Enable GME support.") +set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL + "Enable OpenMPT support.") +set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL + "Enable Discord rich presence support.") +set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL + "Enable curl support, used for downloading files via HTTP.") +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.") + +### use internal libraries? +if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only + set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL + "Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).") +endif() + +if(${SRB2_CONFIG_HAVE_BLUA}) + add_definitions(-DHAVE_BLUA) + set(SRB2_LUA_SOURCES + lua_baselib.c + lua_blockmaplib.c + lua_consolelib.c + lua_hooklib.c + lua_hudlib.c + lua_hudlib_drawlist.c + lua_infolib.c + lua_maplib.c + lua_mathlib.c + lua_mobjlib.c + lua_playerlib.c + lua_script.c + lua_skinlib.c + lua_thinkerlib.c + lua_udatalib.c + lua_glib.c + ) + set(SRB2_LUA_HEADERS + lua_hook.h + lua_hud.h + lua_hudlib_drawlist.h + lua_libs.h + lua_script.h + lua_udatalib.h + lua_glib.h + ) + + prepend_sources(SRB2_LUA_SOURCES) + prepend_sources(SRB2_LUA_HEADERS) + + source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) + + set(SRB2_BLUA_SOURCES + blua/lapi.c + blua/lauxlib.c + blua/lbaselib.c + blua/ldblib.c + blua/lcode.c + blua/ldebug.c + blua/ldo.c + blua/ldump.c + blua/lfunc.c + blua/lgc.c + blua/linit.c + blua/liolib.c + blua/llex.c + blua/lmem.c + blua/lobject.c + blua/lopcodes.c + blua/lparser.c + blua/lstate.c + blua/lstring.c + blua/lstrlib.c + blua/ltable.c + blua/ltablib.c + blua/ltm.c + blua/lundump.c + blua/lvm.c + blua/lzio.c + ) + set(SRB2_BLUA_HEADERS + blua/lapi.h + blua/lauxlib.h + blua/lcode.h + blua/ldebug.h + blua/ldo.h + blua/lfunc.h + blua/lgc.h + blua/llex.h + blua/llimits.h + blua/lmem.h + blua/lobject.h + blua/lopcodes.h + blua/lparser.h + blua/lstate.h + blua/lstring.h + blua/ltable.h + blua/ltm.h + blua/lua.h + blua/luaconf.h + blua/lualib.h + blua/lundump.h + blua/lvm.h + blua/lzio.h + ) + + prepend_sources(SRB2_BLUA_SOURCES) + prepend_sources(SRB2_BLUA_HEADERS) + + source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) +endif() + +if(${SRB2_CONFIG_HAVE_GME}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(GME_FOUND ON) + set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme") + else() # 32-bit + set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme") + endif() + else() + find_package(GME) + endif() + if(${GME_FOUND}) + set(SRB2_HAVE_GME ON) + add_definitions(-DHAVE_LIBGME) + else() + message(WARNING "You have specified that GME is available but it was not found.") + endif() +endif() + +if(${SRB2_CONFIG_HAVE_DISCORDRPC}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(DISCORDRPC_FOUND ON) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include) + set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc") + else() # 32-bit + set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include) + set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc") + endif() + else() + find_package(DiscordRPC) + endif() + if(${DISCORDRPC_FOUND}) + set(SRB2_HAVE_DISCORDRPC ON) + add_definitions(-DHAVE_DISCORDRPC) + add_definitions(-DUSE_STUN) + set(SRB2_DISCORDRPC_SOURCES discord.c stun.c) + set(SRB2_DISCORDRPC_HEADERS discord.h stun.h) + prepend_sources(SRB2_DISCORDRPC_SOURCES) + prepend_sources(SRB2_DISCORDRPC_HEADERS) + source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS}) + else() + message(WARNING "You have specified that Discord Rich Presence is available but it was not found.") + endif() +endif() + +if(${SRB2_CONFIG_HAVE_OPENMPT}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(OPENMPT_FOUND ON) + set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt") + else() # 32-bit + set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt") + endif() + else() + find_package(OPENMPT) + endif() + if(${OPENMPT_FOUND}) + set(SRB2_HAVE_OPENMPT ON) + add_definitions(-DHAVE_OPENMPT) + else() + message(WARNING "You have specified that OpenMPT is available but it was not found.") + endif() +endif() + +if(${SRB2_CONFIG_HAVE_ZLIB}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(ZLIB_FOUND ON) + set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64") + else() # 32-bit + set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz32") + endif() + else() + find_package(ZLIB) + endif() + if(${ZLIB_FOUND}) + set(SRB2_HAVE_ZLIB ON) + add_definitions(-DHAVE_ZLIB) + else() + message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.") + endif() +endif() + +if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) + if (${ZLIB_FOUND}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(PNG_FOUND ON) + set(PNG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libpng-src) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng64") + else() # 32-bit + set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng32") + endif() + else() + find_package(PNG) + endif() + if(${PNG_FOUND}) + set(SRB2_HAVE_PNG ON) + add_definitions(-DHAVE_PNG) + add_definitions(-D_LARGEFILE64_SOURCE) + set(SRB2_PNG_SOURCES apng.c) + set(SRB2_PNG_HEADERS apng.h) + prepend_sources(SRB2_PNG_SOURCES) + prepend_sources(SRB2_PNG_HEADERS) + source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} + ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) + else() + message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.") + endif() + endif() +endif() + +if(${SRB2_CONFIG_HAVE_CURL}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(CURL_FOUND ON) + set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl") + else() # 32-bit + set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl") + endif() + else() + find_package(CURL) + endif() + if(${CURL_FOUND}) + set(SRB2_HAVE_CURL ON) + add_definitions(-DHAVE_CURL) + else() + message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.") + endif() +endif() + +if(${SRB2_CONFIG_HWRENDER}) + add_definitions(-DHWRENDER) + set(SRB2_HWRENDER_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c + ) + + set (SRB2_HWRENDER_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h + ) + + set(SRB2_R_OPENGL_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c + ) + + 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}) + find_package(OpenGL) + if(${OPENGL_FOUND}) + add_definitions(-DHWRENDER) + add_definitions(-DSTATIC_OPENGL) + else() + message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") + endif() +endif() + + +# Targets + +# Compatibility flag with later versions of GCC +# We should really fix our code to not need this +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) +endif() + +add_definitions(-DCMAKECONFIG) + +#add_library(SRB2Core STATIC +# ${SRB2_CORE_SOURCES} +# ${SRB2_CORE_HEADERS} +# ${SRB2_CORE_RENDER_SOURCES} +# ${SRB2_CORE_GAME_SOURCES} +# ${SRB2_LUA_SOURCES} +# ${SRB2_LUA_HEADERS} +# ${SRB2_BLUA_SOURCES} +# ${SRB2_BLUA_HEADERS} +#) + +add_subdirectory(sdl) + +if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE}) + message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(") +endif() -- 2.54.0 From 2147951a167b9b1e4c56069751c9224a4d2aedd8 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 20 Apr 2024 11:41:17 +0300 Subject: [PATCH 04/10] Add IT_CV_BIGFLOAT to use bigger increment for some CV_FLOAT cvars (added only to fov atm) --- src/m_menu.c | 12 ++++++++---- src/m_menu.h | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b672357a1..2dcab703f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1339,9 +1339,9 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, - {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, - {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75}, - {IT_STRING | IT_CVAR, NULL, "Field of View", &cv_fov, 95}, + {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, + {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View", &cv_fov, 95}, {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 105}, {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 115}, @@ -3305,7 +3305,11 @@ static void M_ChangeCvar(INT32 choice) else if (cv->flags & CV_FLOAT) { char s[20]; - sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f)); + float increment; + + increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5 : (1.f/16); + + sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); CV_Set(cv,s); } else diff --git a/src/m_menu.h b/src/m_menu.h index bb504642d..bba8d3db3 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -129,6 +129,10 @@ extern boolean menu_text_input; #define IT_CV_NOMOD 2048 #define IT_CV_INVISSLIDER 2560 +// For cv_float's, will use 1/2 as increment instead of 1/16 +// Not sure if i should add it to cvartype, since its more a flag than type +#define IT_CV_BIGFLOAT 4096 + //call/submenu specific // There used to be a lot more here but ... // A lot of them became redundant with the advent of the Pause menu, so they were removed -- 2.54.0 From 443905ffb3dd8904c395c9c50570ccc17b42dd27 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Apr 2024 11:42:21 +0200 Subject: [PATCH 05/10] Revert "Don't traverse the entire HOME directory to find wads" This reverts commit 1f019ed27772b65768abc2c1d87bdc786d2a0dd2. --- src/sdl/i_system.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 48e513afc..9574d6ec5 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -4039,16 +4039,12 @@ static const char *locateWad(void) #endif #ifndef NOHOME // find in $HOME - I_OutputMsg(",HOME/" DEFAULTDIR); + I_OutputMsg(",HOME"); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); - strcpy(tmp, envstr); - strcat(tmp, DEFAULTDIR); WadPath = searchWad(envstr); if (WadPath) return WadPath; - free(tmp); } #endif #ifdef DEFAULTSEARCHPATH1 -- 2.54.0 From d0c50006bc8cb1b6530791bba25439d8d0ff8021 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Apr 2024 22:36:23 +0200 Subject: [PATCH 06/10] some stuff from ceepeepeecheck --- src/d_net.c | 6 ++++++ src/d_netcmd.c | 6 +----- src/dehacked.c | 6 +++++- src/g_game.c | 2 +- src/hardware/hw_main.c | 10 +++++++--- src/hu_stuff.c | 11 +++++++++-- src/i_tcp.c | 3 +++ src/p_user.c | 17 +++++++---------- src/y_inter.c | 2 +- 9 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 1b4550d35..6b45e009d 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1445,6 +1445,12 @@ void Command_Ping_f(void) pingv[pingc].ms = ms; pingc++; } + else + { + pingv[pingc].num = 0; + pingv[pingc].f = 0; + pingv[pingc].ms = 0; + } } if (f_width < 10) f_width = 1; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b85e3a0ea..1e46da57f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2659,13 +2659,9 @@ void D_ModifyClientVote(SINT8 voted, UINT8 splitplayer) { char buf[2]; char *p = buf; - UINT8 player = consoleplayer; - - if (splitplayer > 0) - player = displayplayers[splitplayer]; WRITESINT8(p, voted); - WRITEUINT8(p, player); + WRITEUINT8(p, splitplayer); SendNetXCmd(XD_MODIFYVOTE, &buf, 2); } diff --git a/src/dehacked.c b/src/dehacked.c index 486584fa5..8b181a563 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8940,7 +8940,11 @@ static char *lua_enumlib_sprintf_upper(char **buf, int* size, const char *format if (length > *size) { void *ptr = realloc(*buf, length+1); - if (!ptr) return NULL; + if (!ptr) + { + va_end(va); + return NULL; + } *buf = ptr; *size = length+1; diff --git a/src/g_game.c b/src/g_game.c index 4161c6ca7..d692863e9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -8377,7 +8377,7 @@ void G_SaveDemo(void) size_t i, strindex = 0; boolean dash = true; - for (i = 0; demo.titlename[i] && i < 127; i++) + for (i = 0; i < 127 && demo.titlename[i]; i++) { if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || (demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dc2af869e..3ff6b1044 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4908,11 +4908,11 @@ void HWR_ProjectSprite(mobj_t *thing) size_t lumpoff; unsigned rot; UINT8 flip; - boolean mirrored = thing->mirrored; - boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + boolean mirrored; + boolean hflip; angle_t ang, camang; - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + boolean papersprite; INT32 heightsec, phs; INT32 dist = -1; @@ -4931,6 +4931,10 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; + mirrored = thing->mirrored; + hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + papersprite = (thing->frame & FF_PAPERSPRITE); + if (cv_grmaxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4224b992c..cd0f42a9c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -531,7 +531,8 @@ static void HU_removeChatText_Log(void) free(chat_log[0]); size_t i; - for(i=0;imo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) { - if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + if ((netgame || multiplayer) && player->spectator) + P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators + else { - if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators - else - { - K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. - } - - if (player->playerstate == PST_DEAD) - return; + K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. } + + if (player->playerstate == PST_DEAD) + return; } #ifdef HWRENDER diff --git a/src/y_inter.c b/src/y_inter.c index 0520b4730..807332c9d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1486,7 +1486,7 @@ void Y_VoteTicker(void) if ((InputDown(gc_accelerate, i+1) || JoyAxis(AXISMOVE, i+1) > 0) && !pressed) { - D_ModifyClientVote(voteclient.playerinfo[i].selection, i); + D_ModifyClientVote(voteclient.playerinfo[i].selection, p); pressed = true; } } -- 2.54.0 From 38d5ee5ae74d0a60dd60291d320ae4b0a16aab42 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Apr 2024 22:52:22 +0200 Subject: [PATCH 07/10] a --- src/i_tcp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 6d0cf8f71..81c221d27 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -896,10 +896,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen socklen_t len = sizeof(sin); if (s == (SOCKET_TYPE)ERRSOCKET) - { - close(s); return (SOCKET_TYPE)ERRSOCKET; - } #ifdef USE_WINSOCK { // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up #ifdef USE_WINSOCK2 -- 2.54.0 From b4dfebac582077b02228430238f56bc4a11cfd2f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Apr 2024 05:24:49 +0200 Subject: [PATCH 08/10] fix some visual issues with fofs --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3ff6b1044..1d77b76cb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3296,7 +3296,7 @@ static void HWR_Subsector(size_t num) centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) @@ -3340,7 +3340,7 @@ static void HWR_Subsector(size_t num) if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) -- 2.54.0 From 836890968c899f1034cae299f6b057ed7acd4006 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Apr 2024 09:06:51 +0200 Subject: [PATCH 09/10] Revert "Merge pull request #121 from Indev450/texload" This reverts commit b6a5c5b7205fb4353b7360eb3e14fa9c4d0d5d0d, reversing changes made to bcf2b3bab2f63ddbcad2179e4fba3a7a070d4ea2. --- src/doomdef.h | 16 --- src/p_setup.c | 4 +- src/r_data.c | 321 ++++++++++++++++++-------------------------------- src/r_data.h | 2 - src/w_wad.c | 25 ++-- src/w_wad.h | 1 - 6 files changed, 121 insertions(+), 248 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 1af046e24..d1bbe04e0 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -516,22 +516,6 @@ extern boolean capslock; // i_system.c, replace getchar() once the keyboard has been appropriated INT32 I_GetKey(void); -/* http://www.cse.yorku.ca/~oz/hash.html */ -static inline -UINT32 quickncasehash (const char *p, size_t n) -{ - size_t i = 0; - UINT32 x = 5381; - - while (i < n && p[i]) - { - x = (x * 33) ^ tolower(p[i]); - i++; - } - - return x; -} - #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) #endif diff --git a/src/p_setup.c b/src/p_setup.c index 2435390cb..9ae36afc9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3452,8 +3452,6 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) if (!devparm && digmreplaces) CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); - R_LoadTexturesPwad(wadnum); - // // search for sprite replacements // @@ -3550,7 +3548,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 1) { // Reload all textures, unconditionally for better or worse. - //R_LoadTextures(); + R_LoadTextures(); if (fullsetup) ++partadd_stage; diff --git a/src/r_data.c b/src/r_data.c index a65709d9a..69b0ce1ac 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -129,7 +129,6 @@ INT16 *hicolormaps; // test a 32k colormap remaps high -> high // Painfully simple texture id cacheing to make maps load faster. :3 static struct { char name[9]; - UINT32 hash; INT32 id; } *tidcache = NULL; static INT32 tidcachelen = 0; @@ -375,63 +374,144 @@ void R_FlushTextureCache(void) int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum); void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index); +// +// R_LoadTextures +// Initializes the texture list with the textures from the world map. +// #define TX_START "TX_START" #define TX_END "TX_END" - -static INT32 -Rloadtextures (INT32 i, INT32 w) +void R_LoadTextures(void) { + INT32 i, k, w; UINT16 j; - INT32 k; UINT16 texstart, texend, texturesLumpPos; - patch_t patchlump; + patch_t *patchlump; texpatch_t *patch; texture_t *texture; - // Get the lump numbers for the markers in the WAD, if they exist. - if (W_FileHasFolders(wadfiles[w])) + // Free previous memory before numtextures change. + if (numtextures) { - texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); - texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + for (i = 0; i < numtextures; i++) + { + Z_Free(textures[i]); + Z_Free(texturecache[i]); + } + Z_Free(texturetranslation); + Z_Free(textures); + } + + // Load patches and textures. + + // Get the number of textures to check. + // NOTE: Make SURE the system does not process + // the markers. + // This system will allocate memory for all duplicate/patched textures even if it never uses them, + // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. + for (w = 0, numtextures = 0; w < numwadfiles; w++) + { + if (wadfiles[w]->type == RET_PK3) + { + texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + } + else + { + texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; + texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); + } + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); while (texturesLumpPos != INT16_MAX) { - R_ParseTEXTURESLump(w, texturesLumpPos, &i); + numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos); texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); } - } - else - { - texstart = W_CheckNumForMarkerStartPwad(TX_START, (UINT16)w, 0); - texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); - if (texturesLumpPos != INT16_MAX) - R_ParseTEXTURESLump(w, texturesLumpPos, &i); + + // Add all the textures between TX_START and TX_END + if (texstart != INT16_MAX && texend != INT16_MAX) + { + // PK3s have subfolders, so we can't just make a simple sum + if (W_FileHasFolders(wadfiles[w])) + { + for (j = texstart; j < texend; j++) + { + if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it + numtextures++; + } + } + else + { + numtextures += (UINT32)(texend - texstart); + } + } } - if (!( texstart == INT16_MAX || texend == INT16_MAX )) + // If no textures found by this point, bomb out + if (!numtextures) + I_Error("No textures detected in any WADs!\n"); + + // Allocate memory and initialize to 0 for all the textures we are initialising. + // There are actually 5 buffers allocated in one for convenience. + textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL); + + // Allocate texture column offset table. + texturecolumnofs = (void *)((UINT8 *)textures + (numtextures * sizeof(void *))); + // Allocate texture referencing cache. + texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2)); + // Allocate texture width mask table. + texturewidthmask = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3)); + // Allocate texture height mask table. + textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); + // Create translation table for global animation. + texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL); + + for (i = 0; i < numtextures; i++) + texturetranslation[i] = i; + + for (i = 0, w = 0; w < numwadfiles; w++) { + // Get the lump numbers for the markers in the WAD, if they exist. + if (wadfiles[w]->type == RET_PK3) + { + texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); + while (texturesLumpPos != INT16_MAX) + { + R_ParseTEXTURESLump(w, texturesLumpPos, &i); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); + } + } + else + { + texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; + texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); + if (texturesLumpPos != INT16_MAX) + R_ParseTEXTURESLump(w, texturesLumpPos, &i); + } + + if (texstart == INT16_MAX || texend == INT16_MAX) + continue; + // Work through each lump between the markers in the WAD. for (j = 0; j < (texend - texstart); j++) { - UINT16 wadnum = (UINT16)w; - lumpnum_t lumpnum = texstart + j; - if (W_FileHasFolders(wadfiles[w])) { - if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder + if (W_IsLumpFolder(w, texstart + j)) // Check if lump is a folder continue; // If it is then SKIP IT } - W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, 8, 0); // #define PNG_HEADER_SIZE (8) + patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->hash = quickncasehash(texture->name, 8); - texture->width = SHORT(patchlump.width); - texture->height = SHORT(patchlump.height); + texture->width = SHORT(patchlump->width); + texture->height = SHORT(patchlump->height); texture->patchcount = 1; texture->holes = false; @@ -442,6 +522,8 @@ Rloadtextures (INT32 i, INT32 w) patch->wad = (UINT16)w; patch->lump = texstart + j; + Z_Unlock(patchlump); + k = 1; while (k << 1 <= texture->width) k <<= 1; @@ -452,186 +534,12 @@ Rloadtextures (INT32 i, INT32 w) } } - return i; -} - -static INT32 -count_range -( const char * marker_start, - const char * marker_end, - const char * folder, - UINT16 wadnum) -{ - UINT16 j; - UINT16 texstart, texend; - INT32 count = 0; - - // Count flats - if (W_FileHasFolders(wadfiles[wadnum])) - { - texstart = W_CheckNumForFolderStartPK3(folder, wadnum, 0); - texend = W_CheckNumForFolderEndPK3(folder, wadnum, texstart); - } - else - { - texstart = W_CheckNumForMarkerStartPwad(marker_start, wadnum, 0); - texend = W_CheckNumForNamePwad(marker_end, wadnum, texstart); - } - - if (texstart != INT16_MAX && texend != INT16_MAX) - { - // PK3s have subfolders, so we can't just make a simple sum - if (W_FileHasFolders(wadfiles[wadnum])) - { - for (j = texstart; j < texend; j++) - { - if (!W_IsLumpFolder(wadnum, j)) // Check if lump is a folder; if not, then count it - count++; - } - } - else // Add all the textures between markers - { - count += (texend - texstart); - } - } - - return count; -} - -static INT32 R_CountTextures(UINT16 wadnum) -{ - UINT16 texturesLumpPos; - INT32 count = 0; - - // Load patches and textures. - - // Get the number of textures to check. - // NOTE: Make SURE the system does not process - // the markers. - // This system will allocate memory for all duplicate/patched textures even if it never uses them, - // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. - - // Count the textures from TEXTURES lumps - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, 0); - - while (texturesLumpPos != INT16_MAX) - { - count += R_CountTexturesInTEXTURESLump(wadnum, texturesLumpPos); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, texturesLumpPos + 1); - } - - // Count single-patch textures - count += count_range(TX_START, TX_END, "textures/", wadnum); - - return count; -} - -static void -recallocuser -( void * user, - size_t old, - size_t new) -{ - char *p = Z_Realloc(*(void**)user, - new, PU_STATIC, user); - - if (new > old) - memset(&p[old], 0, (new - old)); -} - -static void R_AllocateTextures(INT32 add) -{ - const INT32 newtextures = (numtextures + add); - const size_t newsize = newtextures * sizeof (void*); - const size_t oldsize = numtextures * sizeof (void*); - - INT32 i; - - // Allocate memory and initialize to 0 for all the textures we are initialising. - recallocuser(&textures, oldsize, newsize); - - // Allocate texture column offset table. - recallocuser(&texturecolumnofs, oldsize, newsize); - // Allocate texture referencing cache. - recallocuser(&texturecache, oldsize, newsize); - // Allocate texture width table. - recallocuser(&texturewidthmask, oldsize, newsize); - // Allocate texture height table. - recallocuser(&textureheight, oldsize, newsize); - // Create translation table for global animation. - Z_Realloc(texturetranslation, (newtextures + 1) * sizeof(*texturetranslation), PU_STATIC, &texturetranslation); - - for (i = 0; i < numtextures; ++i) - { - // R_FlushTextureCache relies on the user for - // Z_Free, texturecache has been reallocated so the - // user is now garbage memory. - Z_SetUser(texturecache[i], - (void**)&texturecache[i]); - } - - while (i < newtextures) - { - texturetranslation[i] = i; - i++; - } -} - -static INT32 R_DefineTextures(INT32 i, UINT16 w) -{ - return Rloadtextures(i, w); -} - -static void R_FinishLoadingTextures(INT32 add) -{ - numtextures += add; - #ifdef HWRENDER if (rendermode == render_opengl) HWR_LoadTextures(numtextures); #endif } -// -// R_LoadTextures -// Initializes the texture list with the textures from the world map. -// -void R_LoadTextures(void) -{ - INT32 i, w; - INT32 newtextures = 0; - - for (w = 0; w < numwadfiles; w++) - { - newtextures += R_CountTextures((UINT16)w); - } - - // If no textures found by this point, bomb out - if (!newtextures) - I_Error("No textures detected in any WADs!\n"); - - R_AllocateTextures(newtextures); - - for (i = 0, w = 0; w < numwadfiles; w++) - { - i = R_DefineTextures(i, w); - } - - R_FinishLoadingTextures(newtextures); -} - -void R_LoadTexturesPwad(UINT16 wadnum) -{ - INT32 newtextures = R_CountTextures(wadnum); - - if (!newtextures) - return; - - R_AllocateTextures(newtextures); - R_DefineTextures(numtextures, wadnum); - R_FinishLoadingTextures(newtextures); -} - static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) { char *texturesToken; @@ -870,7 +778,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t),PU_STATIC,NULL); M_Memcpy(resultTexture->name, newTextureName, 8); - resultTexture->hash = quickncasehash(newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; } @@ -1658,22 +1565,19 @@ void R_ClearTextureNumCache(boolean btell) INT32 R_CheckTextureNumForName(const char *name) { INT32 i; - UINT32 hash; // "NoTexture" marker. if (name[0] == '-') return 0; - hash = quickncasehash(name, 8); - for (i = 0; i < tidcachelen; i++) - if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8)) + if (!strncasecmp(tidcache[i].name, name, 8)) return tidcache[i].id; // Need to parse the list backwards, so textures loaded more recently are used in lieu of ones loaded earlier //for (i = 0; i < numtextures; i++) <- old for (i = (numtextures - 1); i >= 0; i--) // <- new - if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8)) + if (!strncasecmp(textures[i]->name, name, 8)) { tidcachelen++; Z_Realloc(tidcache, tidcachelen * sizeof(*tidcache), PU_STATIC, &tidcache); @@ -1682,7 +1586,6 @@ INT32 R_CheckTextureNumForName(const char *name) #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "texture #%s: %s\n", sizeu1(tidcachelen), tidcache[tidcachelen-1].name); #endif - tidcache[tidcachelen-1].hash = hash; tidcache[tidcachelen-1].id = i; return i; } diff --git a/src/r_data.h b/src/r_data.h index 102bb5314..ec1146322 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -40,7 +40,6 @@ typedef struct { // Keep name for switch changing, etc. char name[8]; - UINT32 hash; INT16 width, height; boolean holes; @@ -64,7 +63,6 @@ extern CV_PossibleValue_t Color_cons_t[]; // Load TEXTURE1/TEXTURE2/PNAMES definitions, create lookup tables void R_LoadTextures(void); -void R_LoadTexturesPwad(UINT16 wadnum); void R_FlushTextureCache(void); INT32 R_GetTextureNum(INT32 texnum); diff --git a/src/w_wad.c b/src/w_wad.c index 486359d21..cd2968494 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -371,7 +371,6 @@ static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const lumpinfo->size = ftell(handle); fseek(handle, 0, SEEK_SET); strlcpy(lumpinfo->name, lumpname, 9); - lumpinfo->hash = quickncasehash(lumpname, 8); // Allocate the lump's full and long name. lumpinfo->fullname = Z_StrDup(lumpname); @@ -463,7 +462,6 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen lump_p->compression = CM_NOCOMPRESSION; memset(lump_p->name, 0x00, 9); strncpy(lump_p->name, fileinfo->name, 8); - lump_p->hash = quickncasehash(lump_p->name, 8); // Allocate the lump's long name. lump_p->longname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL); @@ -638,7 +636,6 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? strncpy(lump_p->name, trimname, min(8, dotpos - trimname)); - lump_p->hash = quickncasehash(lump_p->name, 8); lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); @@ -956,7 +953,6 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; static char uname[9]; - UINT32 hash; if (!TestValidLump(wad,0)) return INT16_MAX; @@ -964,7 +960,6 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) memset(uname, 0, sizeof uname); strncpy(uname, name, sizeof(uname)-1); strupr(uname); - hash = quickncasehash(uname, 8); // // scan forward @@ -975,7 +970,7 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) - if (lump_p->hash == hash && memcmp(lump_p->name, uname, sizeof(uname) - 1) == 0) + if (memcmp(lump_p->name, uname, sizeof(uname) - 1) == 0) return i; } @@ -1183,20 +1178,15 @@ lumpnum_t W_CheckNumForLongName(const char *name) // TODO: Make it search through cache first, maybe...? lumpnum_t W_CheckNumForMap(const char *name) { - UINT32 hash = quickncasehash(name, 8); UINT16 lumpNum, end; UINT32 i; - lumpinfo_t *p; for (i = numwadfiles - 1; i < numwadfiles; i--) { if (wadfiles[i]->type == RET_WAD) { for (lumpNum = 0; lumpNum < wadfiles[i]->numlumps; lumpNum++) - { - p = wadfiles[i]->lumpinfo + lumpNum; - if (p->hash == hash && !strncmp(name, p->name, 8)) + if (!strncmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) return (i<<16) + lumpNum; - } } else if (wadfiles[i]->type == RET_PK3) { @@ -1207,11 +1197,12 @@ lumpnum_t W_CheckNumForMap(const char *name) continue; // Now look for the specified map. for (; lumpNum < end; lumpNum++) - { - p = wadfiles[i]->lumpinfo + lumpNum; - if (p->hash == hash && !strnicmp(name, p->name, 8)) - return (i<<16) + lumpNum; - } + if (!strnicmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) + { + const char *extension = strrchr(wadfiles[i]->lumpinfo[lumpNum].fullname, '.'); + if (!(extension && stricmp(extension, ".wad"))) + return (i<<16) + lumpNum; + } } } return LUMPERROR; diff --git a/src/w_wad.h b/src/w_wad.h index c0f47708e..84ce9775e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -69,7 +69,6 @@ typedef struct unsigned long position; // filelump_t filepos unsigned long disksize; // filelump_t size char name[9]; // filelump_t name[] e.g. "LongEntr" - UINT32 hash; char *longname; // e.g. "LongEntryName" char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension" size_t size; // real (uncompressed) size -- 2.54.0 From 3acdcb09f194ad181ddc66d99f469145e80f5b3e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 24 Apr 2024 10:59:09 +0200 Subject: [PATCH 10/10] inline those --- src/qs22j.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qs22j.c b/src/qs22j.c index 53277521e..16dc217bd 100644 --- a/src/qs22j.c +++ b/src/qs22j.c @@ -41,33 +41,33 @@ typedef void *pref_typ; #define COMP(a, b) ((*compar)((void *)(a), (void *)(b))) -static void swapbytes(void *a0, void *b0, size_t n) +static inline void swapbytes(void *a0, void *b0, size_t n) { char *a = a0, *b = b0, t; do {ASWAP(*a, *b, t); a++; b++;} while (--n); } -static void swapdword(void *a0, void *b0, size_t n) +static inline void swapdword(void *a0, void *b0, size_t n) { DWORD *a = a0, *b = b0, t; ASWAP(*a, *b, t); (void)n; } -static void swapdwords(void *a0, void *b0, size_t n) +static inline void swapdwords(void *a0, void *b0, size_t n) { DWORD *a = a0, *b = b0, t; do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD)); } -static void swapword(void *a0, void *b0, size_t n) +static inline void swapword(void *a0, void *b0, size_t n) { WORD *a = a0, *b = b0, t; ASWAP(*a, *b, t); (void)n; } -static void swapwords(void *a0, void *b0, size_t n) +static inline void swapwords(void *a0, void *b0, size_t n) { WORD *a = a0, *b = b0, t; do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD)); @@ -75,7 +75,7 @@ static void swapwords(void *a0, void *b0, size_t n) typedef void (*swapf_typ)(void *, void *, size_t); -static char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *)) +static inline char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *)) { return COMP(a, b) < 0 ? (COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) : -- 2.54.0