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() diff --git a/src/Makefile.cfg b/src/Makefile.cfg index c97b4d5a9..77779f7d5 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -12,6 +12,7 @@ # to avoid a false positive with the version detection... SUPPORTED_GCC_VERSIONS:=\ + 141 14\ 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ @@ -23,7 +24,7 @@ SUPPORTED_GCC_VERSIONS:=\ 55 54 53 52 51 50\ 49 48 47 46 45 44 43 42 41 40 -LATEST_GCC_VERSION=13.2 +LATEST_GCC_VERSION=14.1 # gcc or g++ ifdef PREFIX @@ -77,6 +78,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) endif endif +ifdef GCC141 +GCC141=1 +endif + +ifdef GCC14 +GCC14=1 +endif + ifdef GCC132 GCC131=1 endif diff --git a/src/apng.c b/src/apng.c index 694b3d1e8..711024ee3 100644 --- a/src/apng.c +++ b/src/apng.c @@ -71,7 +71,7 @@ apng_create_info_struct (png_structp pngp) { apng_infop ainfop; (void)pngp; - if (( ainfop = calloc(sizeof (apng_info),1) )) + if (( ainfop = calloc(1, sizeof (apng_info)) )) { apng_set_write_fn(pngp, ainfop, 0, 0, 0, 0, 0); apng_set_set_acTL_fn(pngp, ainfop, 0); diff --git a/src/command.c b/src/command.c index 37e120d52..b7e1e01de 100644 --- a/src/command.c +++ b/src/command.c @@ -2132,7 +2132,12 @@ void CV_SaveVariables(FILE *f) // Silly hack for Min/Max vars if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN")) - sprintf(stringtowrite, "%d", cvar->value); + { + if (cvar->flags & CV_FLOAT) + sprintf(stringtowrite, "%f", FixedToFloat(cvar->value)); + else + sprintf(stringtowrite, "%d", cvar->value); + } else strcpy(stringtowrite, cvar->string); 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 8c1ba8e4d..8b181a563 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -334,7 +334,7 @@ static void readPlayer(MYFILE *f, INT32 num) // It works down here, though. { INT32 numline = 0; - for (i = 0; i < MAXLINELEN-1; i++) + for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++) { if (numline < 20 && description[num].notes[i] == '\n') numline++; @@ -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/doomdef.h b/src/doomdef.h index d1bbe04e0..d71aaeb8a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -127,8 +127,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v6.1 " -#define VERSIONSTRINGW L"Saturn v6.1" +#define VERSIONSTRING "Saturn v6.2 " +#define VERSIONSTRINGW L"Saturn v6.2" // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! // AND appveyor.yml, for the build bots! diff --git a/src/g_game.c b/src/g_game.c index d7ac0e8ff..8352d0b98 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2117,6 +2117,8 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) { camerap = &camera[viewnum-1]; P_ResetCamera(&players[(*displayplayerp)], camerap); + + R_ResetViewInterpolation(viewnum); } if (viewnum > splits) @@ -6221,7 +6223,10 @@ void G_ReadMetalTic(mobj_t *metal) // Read changes from the tic if (ziptic & GZT_XYZ) { - P_MoveOrigin(metal, READFIXED(metal_p), READFIXED(metal_p), READFIXED(metal_p)); + oldmetal.x = READFIXED(metal_p); + oldmetal.y = READFIXED(metal_p); + oldmetal.z = READFIXED(metal_p); + P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z); oldmetal.x = metal->x; oldmetal.y = metal->y; oldmetal.z = metal->z; @@ -8374,7 +8379,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 b1a960870..0e4b22499 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -180,6 +180,8 @@ static void CV_anisotropic_ONChange(void) static void CV_screentextures_ONChange(void) { ONLY_IF_GL_LOADED + if (cv_grscreentextures.value != 3) + CV_Set(&cv_grpaletterendering, "Off"); HWD.pfnSetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_grscreentextures.value); } @@ -274,6 +276,8 @@ ps_metric_t ps_hw_numcolors = {0}; ps_metric_t ps_hw_batchsorttime = {0}; ps_metric_t ps_hw_batchdrawtime = {0}; +static void HWR_AddPrecipitationSprites(void); + // ========================================================================== // View position // ========================================================================== @@ -505,6 +509,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } + light_level = SOFTLIGHT(light_level); + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations light_level = min(max(light_level, cv_secbright.value), 255); @@ -1120,7 +1126,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = SOFTLIGHT(pfloor->master->frontsector->lightlevel); + lightnum = pfloor->master->frontsector->lightlevel; colormap = pfloor->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1132,7 +1138,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = SOFTLIGHT(*list[i].lightlevel); + lightnum = *list[i].lightlevel; colormap = list[i].extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1507,7 +1513,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = SOFTLIGHT(gr_frontsector->lightlevel); + lightnum = gr_frontsector->lightlevel; colormap = gr_frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); } @@ -2238,7 +2244,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); + lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2246,7 +2252,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom colormap = rover->master->frontsector->extra_colormap; } - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); @@ -2377,7 +2383,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); + lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2385,7 +2391,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom colormap = rover->master->frontsector->extra_colormap; } - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_backsector->numlights) HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); @@ -3062,13 +3068,13 @@ void HWR_AddPolyObjectPlanes(void) FSurfaceInfo Surf; FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); } else { HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->floorpic].lumpnum, + polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, polyobjsector, 255, NULL); } } @@ -3084,13 +3090,13 @@ void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); } else { HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum, + polyobjsector->lightlevel, levelflats[polyobjsector->ceilingpic].lumpnum, polyobjsector, 255, NULL); } } @@ -3232,12 +3238,12 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) - floorlightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); + floorlightlevel = *gr_frontsector->lightlist[light].lightlevel; floorcolormap = gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) - ceilinglightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); + ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel; ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; } @@ -3305,7 +3311,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) @@ -3314,13 +3320,13 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); - alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); + alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], false, *rover->bottomheight, - SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), + *gr_frontsector->lightlist[light].lightlevel, alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3331,7 +3337,7 @@ static void HWR_Subsector(size_t num) &extrasubsectors[num], false, *rover->bottomheight, - SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), + *gr_frontsector->lightlist[light].lightlevel, max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3339,7 +3345,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -3349,7 +3355,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) @@ -3358,13 +3364,13 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); - alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); + alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], true, *rover->topheight, - SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), + *gr_frontsector->lightlist[light].lightlevel, alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3375,7 +3381,7 @@ static void HWR_Subsector(size_t num) &extrasubsectors[num], true, *rover->topheight, - SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), + *gr_frontsector->lightlist[light].lightlevel, max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3383,7 +3389,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -4007,7 +4013,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) alpha = Surf.PolyColor.s.alpha; // Start with the lightlevel and colormap from the top of the sprite - lightlevel = SOFTLIGHT(*list[sector->numlights - 1].lightlevel); + lightlevel = *list[sector->numlights - 1].lightlevel; colormap = list[sector->numlights - 1].extra_colormap; i = 0; @@ -4022,7 +4028,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i-1].lightlevel); + lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; colormap = list[i-1].extra_colormap; break; } @@ -4037,7 +4043,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); + lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; colormap = list[i].extra_colormap; } @@ -4256,7 +4262,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); + lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; HWR_Lighting(&Surf, lightlevel, colormap); } @@ -4357,7 +4363,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : SOFTLIGHT(*sector->lightlist[light].lightlevel); + lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; @@ -4365,7 +4371,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) else { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); + lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (sector->extra_colormap) colormap = sector->extra_colormap; @@ -4413,8 +4419,9 @@ static int CompareVisSprites(const void *p1, const void *p2) // make transparent sprites last // "boolean to int" - int transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); - int transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + int transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK); + int transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK); + idiff = transparency1 - transparency2; if (idiff != 0) return idiff; @@ -4427,8 +4434,6 @@ static int CompareVisSprites(const void *p1, const void *p2) return -1; } -#undef SOFTLIGHT - static void HWR_SortVisSprites(void) { UINT32 i; @@ -4757,8 +4762,7 @@ void HWR_DrawSprites(void) void HWR_AddSprites(sector_t *sec) { mobj_t *thing; - precipmobj_t *precipthing; - fixed_t approx_dist, limit_dist, precip_limit_dist; + fixed_t approx_dist, limit_dist; INT32 splitflags; boolean split_drawsprite; // drawing with splitscreen flags @@ -4780,13 +4784,9 @@ void HWR_AddSprites(sector_t *sec) limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS); else limit_dist = current_bsp_culling_distance; - precip_limit_dist = min(current_bsp_culling_distance, cv_drawdist_precip.value << FRACBITS); } else - { limit_dist = cv_drawdist.value << FRACBITS; - precip_limit_dist = cv_drawdist_precip.value << FRACBITS; - } // Handle all things in sector. // If a limit exists, handle things a tiny bit different. @@ -4794,7 +4794,6 @@ void HWR_AddSprites(sector_t *sec) { for (thing = sec->thinglist; thing; thing = thing->snext) { - split_drawsprite = false; if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) @@ -4839,7 +4838,6 @@ void HWR_AddSprites(sector_t *sec) // Draw everything in sector, no checks for (thing = sec->thinglist; thing; thing = thing->snext) { - split_drawsprite = false; if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) @@ -4874,21 +4872,46 @@ void HWR_AddSprites(sector_t *sec) HWR_ProjectSprite(thing); } } +} + +// -------------------------------------------------------------------------- +// HWR_AddPrecipitationSprites +// This renders through the blockmap instead of BSP to avoid +// iterating a huge amount of precipitation sprites in sectors +// that are beyond drawdist. +// -------------------------------------------------------------------------- +static void HWR_AddPrecipitationSprites(void) +{ + //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; + fixed_t drawdist; + + INT32 xl, xh, yl, yh, bx, by; + precipmobj_t *th; + + if (current_bsp_culling_distance) + drawdist = min(current_bsp_culling_distance, cv_drawdist_precip.value * mapobjectscale); + else + drawdist = cv_drawdist_precip.value * mapobjectscale; // No to infinite precipitation draw distance. - if (precip_limit_dist) + if (drawdist == 0) { - for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) + return; + } + + R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); + + for (bx = xl; bx <= xh; bx++) + { + for (by = yl; by <= yh; by++) { - if (precipthing->precipflags & PCF_INVISIBLE) - continue; + for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = th->bnext) + { + if (th->precipflags & PCF_INVISIBLE) + continue; - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - - if (approx_dist > precip_limit_dist) - continue; - - HWR_ProjectPrecipitationSprite(precipthing); + HWR_ProjectPrecipitationSprite(th); + } } } } @@ -4917,11 +4940,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; @@ -4940,6 +4963,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); @@ -5712,6 +5739,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe if (cv_grbatching.value) HWR_StartBatching(); + HWR_AddPrecipitationSprites(); + ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); @@ -5731,7 +5760,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe gr_portal = oldgl_portal_state; PS_STOP_TIMING(ps_bsptime); - + if (cv_grbatching.value) HWR_RenderBatches(); 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;i= y) - x -= y; - if (n) - return -x; - else - return x; + return x % y; } /** \brief The FixedSqrt function diff --git a/src/m_menu.c b/src/m_menu.c index b672357a1..f4ce5cf38 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}, @@ -2351,7 +2351,7 @@ static menuitem_t OP_DriftGaugeMenu[] = {IT_HEADER, NULL, "Driftgauge", NULL, 0}, {IT_STRING | IT_CVAR, NULL, "Driftgauge", &cv_driftgauge, 20}, {IT_STRING | IT_CVAR, NULL, "Driftgauge Transparency", &cv_driftgaugetrans, 30}, - {IT_STRING | IT_CVAR, NULL, "Driftgauge Offset", &cv_driftgaugeofs, 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Driftgauge Offset", &cv_driftgaugeofs, 40}, {IT_STRING | IT_CVAR, NULL, "Driftgauge Style", &cv_driftgaugestyle, 50}, }; @@ -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 diff --git a/src/m_misc.c b/src/m_misc.c index 97dcbed84..7d0ce6bfc 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1589,7 +1589,7 @@ char *va(const char *format, ...) static char string[1024]; va_start(argptr, format); - vsprintf(string, format, argptr); + vsnprintf(string, 1024, format, argptr); va_end(argptr); return string; diff --git a/src/p_local.h b/src/p_local.h index dc473b648..e1a07526a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -387,6 +387,7 @@ extern INT32 bmapheight; // in mapblocks extern fixed_t bmaporgx; extern fixed_t bmaporgy; // origin of block map extern mobj_t **blocklinks; // for thing chains +extern precipmobj_t **precipblocklinks; // special blockmap for precip rendering // // P_INTER diff --git a/src/p_maputl.c b/src/p_maputl.c index c680931d0..3c91dc922 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -754,15 +754,45 @@ void P_UnsetThingPosition(mobj_t *thing) void P_UnsetPrecipThingPosition(precipmobj_t *thing) { - precipmobj_t **sprev = thing->sprev; - precipmobj_t *snext = thing->snext; - if ((*sprev = snext) != NULL) // unlink from sector list - snext->sprev = sprev; + precipmobj_t **bprev = thing->bprev; + precipmobj_t *bnext = thing->bnext; + + if (bprev && (*bprev = bnext) != NULL) // unlink from block map + bnext->bprev = bprev; precipsector_list = thing->touching_sectorlist; thing->touching_sectorlist = NULL; //to be restored by P_SetPrecipThingPosition } +static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap) +{ + const INT32 blockx = (unsigned)(thing->x - bmaporgx) >> MAPBLOCKSHIFT; + const INT32 blocky = (unsigned)(thing->y - bmaporgy) >> MAPBLOCKSHIFT; + + if (blockx >= 0 && blockx < bmapwidth + && blocky >= 0 && blocky < bmapheight) + { + // killough 8/11/98: simpler scheme using + // pointer-to-pointer prev pointers -- + // allows head nodes to be treated like everything else + + mobj_t **link = &bmap[(blocky * bmapwidth) + blockx]; + mobj_t *bnext = *link; + + thing->bnext = bnext; + + if (bnext != NULL) + bnext->bprev = &thing->bnext; + + thing->bprev = link; + *link = thing; + } + else // thing is off the map + { + thing->bnext = NULL, thing->bprev = NULL; + } +} + // // P_SetThingPosition // Links a thing into both a block and a subsector @@ -819,24 +849,7 @@ void P_SetThingPosition(mobj_t *thing) if (!(thing->flags & MF_NOBLOCKMAP)) { // inert things don't need to be in blockmap - const INT32 blockx = (unsigned)(thing->x - bmaporgx)>>MAPBLOCKSHIFT; - const INT32 blocky = (unsigned)(thing->y - bmaporgy)>>MAPBLOCKSHIFT; - if (blockx >= 0 && blockx < bmapwidth - && blocky >= 0 && blocky < bmapheight) - { - // killough 8/11/98: simpler scheme using - // pointer-to-pointer prev pointers -- - // allows head nodes to be treated like everything else - - mobj_t **link = &blocklinks[blocky*bmapwidth + blockx]; - mobj_t *bnext = *link; - if ((thing->bnext = bnext) != NULL) - bnext->bprev = &thing->bnext; - thing->bprev = link; - *link = thing; - } - else // thing is off the map - thing->bnext = NULL, thing->bprev = NULL; + P_LinkToBlockMap(thing, blocklinks); } // Allows you to 'step' on a new linedef exec when the previous @@ -891,18 +904,15 @@ void P_SetUnderlayPosition(mobj_t *thing) void P_SetPrecipitationThingPosition(precipmobj_t *thing) { - subsector_t *ss = thing->subsector = R_PointInSubsector(thing->x, thing->y); - - precipmobj_t **link = &ss->sector->preciplist; - precipmobj_t *snext = *link; - if ((thing->snext = snext) != NULL) - snext->sprev = &thing->snext; - thing->sprev = link; - *link = thing; + thing->subsector = R_PointInSubsector(thing->x, thing->y); P_CreatePrecipSecNodeList(thing, thing->x, thing->y); thing->touching_sectorlist = precipsector_list; // Attach to Thing's precipmobj_t precipsector_list = NULL; // clear for next time + + // NOTE: this works because bnext/bprev are at the same + // offsets in precipmobj_t and mobj_t + P_LinkToBlockMap((mobj_t*)thing, (mobj_t**)precipblocklinks); } // diff --git a/src/p_mobj.c b/src/p_mobj.c index cbc08c02c..608d9e821 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1329,7 +1329,7 @@ void P_XYMovement(mobj_t *mo) fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls boolean moved; pslope_t *oldslope = NULL; - vector3_t slopemom; + vector3_t slopemom = {0,0,0}; fixed_t predictedz = 0; I_Assert(mo != NULL); @@ -4978,18 +4978,17 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->angle -= InvAngle(angle)/8; // Spawn energy particles - for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) { + for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) + { dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y); if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1) break; } - if (spawner) { + if (spawner && dist) + { mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER); missile->momz = FixedDiv(missile->momz, 7*FRACUNIT/4); - if (dist == 0) - missile->fuse = 0; - else - missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); + missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); if (missile->fuse > mobj->fuse) P_RemoveMobj(missile); } @@ -10147,6 +10146,9 @@ void P_SpawnPrecipitation(void) //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always { + INT32 floorz; + INT32 ceilingz; + x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); @@ -10180,8 +10182,19 @@ void P_SpawnPrecipitation(void) else // everything else. rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); - // Randomly assign a height, now that floorz is set. - rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<floorz >> FRACBITS; + ceilingz = rainmo->ceilingz >> FRACBITS; + + if (floorz < ceilingz) + { + // Randomly assign a height, now that floorz is set. + rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; + } + else + { + // ...except if the floor is above the ceiling. + rainmo->z = ceilingz << FRACBITS; + } } } @@ -10270,7 +10283,8 @@ void P_PrecipitationEffects(void) volume = 255; // Sky above? We get it full blast. else { - fixed_t x, y, yl, yh, xl, xh; + /* GCC is optimizing away y >= yl, FUCK YOU */ + volatile fixed_t x, y, yl, yh, xl, xh; fixed_t closedist, newdist; // Essentially check in a 1024 unit radius of the player for an outdoor area. @@ -10279,8 +10293,8 @@ void P_PrecipitationEffects(void) xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT; xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT; closedist = 2048*FRACUNIT; - for (y = yl; y <= yh; y += FRACUNIT*64) - for (x = xl; x <= xh; x += FRACUNIT*64) + for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64) + for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64) { if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors! { diff --git a/src/p_mobj.h b/src/p_mobj.h index 5d26f9b44..a824edc6a 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -279,8 +279,8 @@ typedef struct mobj_s fixed_t old_x2, old_y2, old_z2; // More list: links in sector (if needed) - struct mobj_s *snext; - struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr + struct mobj_s *bnext; + struct mobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation @@ -338,8 +338,8 @@ typedef struct mobj_s // Interaction info, by BLOCKMAP. // Links in blocks (if needed). - struct mobj_s *bnext; - struct mobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr + struct mobj_s *snext; + struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr // Additional pointers for NiGHTS hoops struct mobj_s *hnext; @@ -432,8 +432,8 @@ typedef struct precipmobj_s fixed_t old_x2, old_y2, old_z2; // More list: links in sector (if needed) - struct precipmobj_s *snext; - struct precipmobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr + struct precipmobj_s *bnext; + struct precipmobj_s **bprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fa98ad9a5..9a3376595 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1206,7 +1206,7 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y) // http://www.inversereality.org/tutorials/graphics%20programming/2dtransformations.html // It is, of course, just a vector-matrix multiplication. // -static inline void Polyobj_rotatePoint(vertex_t *v, const vertex_t *c, angle_t ang) +static inline void Polyobj_rotatePoint(vertex_t *v, const vector2_t *c, angle_t ang) { vertex_t tmp = *v; @@ -1267,7 +1267,7 @@ static void Polyobj_rotateLine(line_t *ld) // // Causes objects resting on top of the rotating polyobject to 'ride' with its movement. // -static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, UINT8 turnthings) +static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, UINT8 turnthings) { static INT32 pomovecount = 10000; INT32 x, y; @@ -1367,7 +1367,7 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings) { size_t i; angle_t angle; - vertex_t origin; + vector2_t origin; INT32 hitflags = 0; // don't move bad polyobjects diff --git a/src/p_setup.c b/src/p_setup.c index 9ae36afc9..c99326116 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -127,6 +127,7 @@ INT32 *blockmaplump; // Big blockmap fixed_t bmaporgx, bmaporgy; // for thing chains mobj_t **blocklinks; +precipmobj_t **precipblocklinks; // REJECT // For fast sight rejection. @@ -714,7 +715,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->thinglist = NULL; ss->touching_thinglist = NULL; - ss->preciplist = NULL; + ss->touching_preciplist = NULL; ss->floordata = NULL; @@ -1948,6 +1949,9 @@ static void P_CreateBlockMap(void) // haleyjd 2/22/06: setup polyobject blockmap count = sizeof(*polyblocklinks) * bmapwidth * bmapheight; polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL); + + count = sizeof (*precipblocklinks)* bmapwidth*bmapheight; + precipblocklinks = Z_Calloc(count, PU_LEVEL, NULL); } } @@ -1982,10 +1986,6 @@ static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) // this should return false. static boolean P_LoadBlockMap(lumpnum_t lumpnum) { -#if 0 - (void)lumpnum; - return false; -#else size_t count; const char *lumpname = W_CheckNameForNum(lumpnum); @@ -2023,27 +2023,11 @@ static boolean P_LoadBlockMap(lumpnum_t lumpnum) // haleyjd 2/22/06: setup polyobject blockmap count = sizeof(*polyblocklinks) * bmapwidth * bmapheight; polyblocklinks = Z_Calloc(count, PU_LEVEL, NULL); + + count = sizeof (*precipblocklinks)* bmapwidth*bmapheight; + precipblocklinks = Z_Calloc(count, PU_LEVEL, NULL); + return true; -/* Original - blockmaplump = W_CacheLumpNum(lump, PU_LEVEL); - blockmap = blockmaplump+4; - count = W_LumpLength (lump)/2; - - for (i = 0; i < count; i++) - blockmaplump[i] = SHORT(blockmaplump[i]); - - bmaporgx = blockmaplump[0]<player == &players[displayplayers[i]] && camera[i].chase) + if (thing->player != &players[displayplayers[i]]) + continue; + if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); + R_ResetViewInterpolation(i + 1); + break; } // don't run in place after a teleport diff --git a/src/p_tick.c b/src/p_tick.c index 183c42a4b..6416142ce 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -581,6 +581,13 @@ void P_Ticker(boolean run) if (playeringame[i]) ++players[i].jointime; + if (run) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + } + if (objectplacing) { if (OP_FreezeObjectplace()) @@ -827,7 +834,6 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); - R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index 5d97e9ac6..6b076a132 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2510,18 +2510,15 @@ static void P_MovePlayer(player_t *player) if ((player->mo->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 @@ -3962,7 +3959,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); - R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); 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) : diff --git a/src/r_data.c b/src/r_data.c index 772d76925..69b0ce1ac 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1088,6 +1088,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) { char colormap[9] = "COLORMAP"; lumpnum_t lump; + const lumpnum_t basecolormaplump = W_GetNumForName(colormap); if (num > 0 && num <= 10000) snprintf(colormap, 8, "CLM%04u", num-1); @@ -1095,8 +1096,16 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) // Load in the light tables, now 64k aligned for smokie... lump = W_GetNumForName(colormap); if (lump == LUMPERROR) - lump = W_GetNumForName("COLORMAP"); - W_ReadLump(lump, colormaps); + lump = basecolormaplump; + else + { + if (W_LumpLength(lump) != W_LumpLength(basecolormaplump)) + { + CONS_Alert(CONS_WARNING, "%s lump size does not match COLORMAP, results may be unexpected.\n", colormap); + } + } + + W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U); // Encore mode. if (newencoremap != LUMPERROR) diff --git a/src/r_defs.h b/src/r_defs.h index 5a78a362b..81e3f0c3a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -350,7 +350,6 @@ typedef struct sector_s fixed_t floorspeed, ceilspeed; // list of precipitation mobjs in sector - precipmobj_t *preciplist; struct mprecipsecnode_s *touching_preciplist; // Eternity engine slope diff --git a/src/r_fps.c b/src/r_fps.c index 44518ea4d..91044b42e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -23,6 +23,8 @@ #include "r_state.h" #include "z_zone.h" #include "console.h" // con_startup_loadprogress +#include "i_time.h" + #ifdef HWRENDER #include "hardware/hw_main.h" // for cv_grshearing #endif @@ -80,6 +82,7 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS]; static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS]; static viewvars_t *oldview = &pview_old[0]; +static tic_t last_view_update; static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; viewvars_t *newview = &pview_new[0]; @@ -200,21 +203,27 @@ void R_UpdateViewInterpolation(void) if (oldview_invalid[i]) oldview_invalid[i]--; } + + last_view_update = I_GetTime(); } void R_ResetViewInterpolation(UINT8 p) { + // Wait an extra tic if the interpolation state hasn't + // updated yet. + int t = last_view_update == I_GetTime() ? 1 : 2; + if (p == 0) { UINT8 i; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - oldview_invalid[i]++; + oldview_invalid[i] = t; } } else { - oldview_invalid[p - 1]++; + oldview_invalid[p - 1] = t; } } diff --git a/src/r_main.c b/src/r_main.c index 3b7a8b063..a15258c48 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -32,6 +32,7 @@ #include "m_random.h" // quake camera shake #include "doomstat.h" // MAXSPLITSCREENPLAYERS #include "r_fps.h" // Frame interpolation/uncapped +#include "tables.h" #ifdef HWRENDER #include "hardware/hw_main.h" @@ -594,6 +595,33 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe return false; } +// Returns search dimensions within a blockmap, in the direction of viewangle and out to a certain distance. +void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh) +{ + const angle_t left = viewangle - clipangle; + const angle_t right = viewangle + clipangle; + + const fixed_t vxleft = viewx + FixedMul(drawdist, FCOS(left)); + const fixed_t vyleft = viewy + FixedMul(drawdist, FSIN(left)); + + const fixed_t vxright = viewx + FixedMul(drawdist, FCOS(right)); + const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right)); + + // Try to narrow the search to within only the field of view + *xl = (unsigned)(min(viewx, min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; + *xh = (unsigned)(max(viewx, max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT; + *yl = (unsigned)(min(viewy, min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; + *yh = (unsigned)(max(viewy, max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT; + + if (*xh >= bmapwidth) + *xh = bmapwidth - 1; + + if (*yh >= bmapheight) + *yh = bmapheight - 1; + + BMBOUNDFIX(*xl, *xh, *yl, *yh); +} + // // R_InitTextureMapping // @@ -1728,6 +1756,7 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_bsptime); R_RenderBSPNode((INT32)numnodes - 1); PS_STOP_TIMING(ps_bsptime); + R_AddPrecipitationSprites(); PS_START_TIMING(ps_sw_spritecliptime); R_ClipSprites(); PS_STOP_TIMING(ps_sw_spritecliptime); diff --git a/src/r_main.h b/src/r_main.h index b3f38e156..56e351138 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -80,6 +80,7 @@ subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); +void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh); // Performance stats extern precise_t ps_prevframetime;// time when previous frame was rendered diff --git a/src/r_things.c b/src/r_things.c index c66ca9f58..dfe05dbdf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1897,7 +1897,6 @@ weatherthink: void R_AddSprites(sector_t *sec, INT32 lightlevel) { mobj_t *thing; - precipmobj_t *precipthing; // Tails 08-25-2002 INT32 lightnum; fixed_t approx_dist, limit_dist; @@ -2016,21 +2015,42 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) R_ProjectSprite(thing); } } +} + +// R_AddPrecipitationSprites +// This renders through the blockmap instead of BSP to avoid +// iterating a huge amount of precipitation sprites in sectors +// that are beyond drawdist. +// +void R_AddPrecipitationSprites(void) +{ + const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; + + INT32 xl, xh, yl, yh, bx, by; + precipmobj_t *th, *next; + + if (drawdist == 0) + { + return; + } + + R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off - if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) + for (bx = xl; bx <= xh; bx++) { - for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) + for (by = yl; by <= yh; by++) { - if (precipthing->precipflags & PCF_INVISIBLE) - continue; + for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next) + { + // Store this beforehand because R_ProjectPrecipitionSprite may free th (see P_PrecipThinker) + next = th->bnext; - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); + if (th->precipflags & PCF_INVISIBLE) + continue; - if (approx_dist > limit_dist) - continue; - - R_ProjectPrecipitationSprite(precipthing); + R_ProjectPrecipitationSprite(th); + } } } } diff --git a/src/r_things.h b/src/r_things.h index b9e05022e..88e1abdab 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -67,6 +67,7 @@ void R_AddSpriteDefs(UINT16 wadnum); //SoM: 6/5/2000: Light sprites correctly! void R_AddSprites(sector_t *sec, INT32 lightlevel); +void R_AddPrecipitationSprites(void); void R_InitSprites(void); void R_ClearSprites(void); void R_DrawMasked(void); 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 diff --git a/src/tables.h b/src/tables.h index 353bf591f..761a6499e 100644 --- a/src/tables.h +++ b/src/tables.h @@ -24,6 +24,7 @@ #define FINEMASK (FINEANGLES - 1) #define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000 #define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK +#define ANGLETOFINE(x) (((x)>>ANGLETOFINESHIFT) & FINEMASK) // Effective size is 10240. extern fixed_t finesine[5*FINEANGLES/4]; @@ -121,4 +122,8 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z); #define FINECOSINE(n) (finecosine[n]>>(FINE_FRACBITS-FRACBITS)) #define FINETANGENT(n) (finetangent[n]>>(FINE_FRACBITS-FRACBITS)) +// FSIN(ANGLE_90) = FRACUNIT +#define FSIN(n) FINESINE(ANGLETOFINE(n)) +#define FCOS(n) FINECOSINE(ANGLETOFINE(n)) + #endif diff --git a/src/v_video.c b/src/v_video.c index c56711f20..4ea028cc3 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2944,6 +2944,9 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 continue; + if (c < HU_FONTSTART) + continue; + if (!lowercase || !tny_font[c-HU_FONTSTART]) c = toupper(c); c -= HU_FONTSTART; @@ -3367,7 +3370,7 @@ void V_Init(void) #ifdef DEBUG CONS_Debug(DBG_RENDER, "V_Init done:\n"); - for (i = 0; i < NUMSCREENS+1; i++) + for (i = 0; i < NUMSCREENS; i++) CONS_Debug(DBG_RENDER, " screens[%d] = %x\n", i, screens[i]); #endif } diff --git a/src/w_wad.c b/src/w_wad.c index 86536c03f..cd2968494 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -186,9 +186,9 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) if (filenamebuf != *filename) { // avoid overlap strncpy(filenamebuf, *filename, MAX_WADPATH); + filenamebuf[MAX_WADPATH - 1] = '\0'; + *filename = filenamebuf; } - filenamebuf[MAX_WADPATH - 1] = '\0'; - *filename = filenamebuf; // open wad file if ((handle = fopen_utf8(*filename, "rb")) == NULL) 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; } }