From 3dda2ec590a305bea7023f98bb0c6da30c02c7d6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Dec 2017 02:02:23 +0300 Subject: [PATCH 01/36] Fix compiling on MSVC2017 --- cl_dll/CMakeLists.txt | 17 ++++++++++++++--- dlls/CMakeLists.txt | 11 +++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2d247950..824acc52 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,11 +25,22 @@ project (CLDLL) set (CLDLL_LIBRARY client) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") + +add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) + +if(NOT WIN32) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-write-strings) # GCC/Clang flag + add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) +endif() + if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") + add_definitions(-DGOLDSOURCE_SUPPORT) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") + set (CLDLL_SOURCES ../dlls/crossbow.cpp diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 480b61d1..1564b90e 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,8 +25,15 @@ project (SVDLL) set (SVDLL_LIBRARY server) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -fno-exceptions -w") -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") +add_definitions(-DCLIENT_WEAPONS) + +if(NOT WIN32) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) +endif() set (SVDLL_SOURCES agrunt.cpp From 9a02d7116fc0d6dd89ab0f6f2e54e18eb6ecac8e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Dec 2017 02:05:47 +0300 Subject: [PATCH 02/36] It's better to use MSVC here instead of WIN32, so it wouldn't break MinGW builds --- cl_dll/CMakeLists.txt | 2 +- dlls/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 824acc52..05990913 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,7 +28,7 @@ set (CLDLL_LIBRARY client) add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) -if(NOT WIN32) +if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 1564b90e..bf65b00f 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -27,7 +27,7 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) -if(NOT WIN32) +if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) From c5aa3aa40e461042425a171b121df2e043d8d3d4 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 30 Dec 2017 22:22:14 +0700 Subject: [PATCH 03/36] Fix amd64 build --- dlls/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/util.h b/dlls/util.h index 7f9dea70..41e86a84 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -40,7 +40,7 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined XASH_64BIT || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((int)str - (int)STRING(0)) +#define MAKE_STRING(str) ((int)(long int)str - (int)(long int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) { From 8abffc937138ad9e84132259b81683f25f127286 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 13 Jan 2018 09:01:38 +0500 Subject: [PATCH 04/36] Fix typo. --- dlls/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index 94c8c68c..c7feab31 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -989,7 +989,7 @@ float UTIL_Approach( float target, float value, float speed ) float UTIL_ApproachAngle( float target, float value, float speed ) { target = UTIL_AngleMod( target ); - value = UTIL_AngleMod( target ); + value = UTIL_AngleMod( value ); float delta = target - value; From 31c1e121b5826245e1ec074f83d4e3636cef7891 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 13 Jan 2018 18:03:24 +0300 Subject: [PATCH 05/36] Fix some warnings. Disable warning about invalid offsetof as it produces billion warnings in save-restore code --- dlls/CMakeLists.txt | 4 ++-- dlls/playermonster.cpp | 4 ++-- utils/false_vgui/include/VGUI_Panel.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bf65b00f..bfd7d80b 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2015 Pavlo Lavrenenko # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,7 +28,7 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) - add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-fno-exceptions -Wno-invalid-offsetof) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index cd3484ab..a6e38389 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // @@ -82,7 +82,7 @@ void CPlayerMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CPlayerMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h index bec7ac25..351b2375 100644 --- a/utils/false_vgui/include/VGUI_Panel.h +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -219,7 +219,6 @@ private: bool _paintBorderEnabled; bool _paintBackgroundEnabled; bool _paintEnabled; -friend class Panel; friend class App; friend class SurfaceBase; friend class Image; From c13546377453d78c120d41d2b91326d3267e0a94 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 15 Jan 2018 02:43:57 +0300 Subject: [PATCH 06/36] add_compile_options for older cmake versions --- CMakeLists.txt | 10 ++++++++++ dlls/CMakeLists.txt | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d754eb5..e025342a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,16 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) endif() endif() +# add_compile_options for older cmake versions +if(${CMAKE_VERSION} VERSION_LESS "3.0.2") +macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() +endmacro() +endif() + if(BUILD_CLIENT) add_subdirectory(cl_dll) endif() diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bfd7d80b..bf7d3370 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2015 Pavlo Lavrenenko # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,7 +28,8 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) - add_compile_options(-fno-exceptions -Wno-invalid-offsetof) # GCC/Clang flag + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() From 8dc9245fe3eba4db5b8d44bc094b95b2273b462b Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 18 Jan 2018 22:36:32 +0300 Subject: [PATCH 07/36] Copyright symbol to utf-8 --- cl_dll/GameStudioModelRenderer.cpp | 2 +- cl_dll/GameStudioModelRenderer.h | 2 +- cl_dll/GameStudioModelRenderer_Sample.cpp | 2 +- cl_dll/GameStudioModelRenderer_Sample.h | 2 +- cl_dll/StudioModelRenderer.cpp | 2 +- cl_dll/StudioModelRenderer.h | 2 +- cl_dll/camera.h | 2 +- cl_dll/demo.h | 2 +- cl_dll/entity.cpp | 2 +- cl_dll/ev_hldm.h | 2 +- cl_dll/events.cpp | 2 +- cl_dll/eventscripts.h | 2 +- cl_dll/hud_iface.h | 2 +- cl_dll/hud_servers.cpp | 2 +- cl_dll/hud_servers.h | 2 +- cl_dll/hud_servers_priv.h | 2 +- cl_dll/hud_spectator.cpp | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_camera.cpp | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input.cpp | 2 +- cl_dll/kbutton.h | 2 +- cl_dll/overview.cpp | 2 +- cl_dll/overview.h | 2 +- cl_dll/studio_util.cpp | 2 +- cl_dll/studio_util.h | 2 +- cl_dll/tri.cpp | 2 +- cl_dll/view.cpp | 2 +- cl_dll/view.h | 2 +- dlls/squad.h | 2 +- dlls/stats.cpp | 2 +- pm_shared/pm_movevars.h | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index c7211752..f2953e96 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 881dd144..8b911db8 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index d697d927..5f1d2b69 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index 9c09374b..a9136880 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index b7c3c1c6..ffcf305b 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index cbfd0d3b..0f91122d 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 69a00216..99235ed6 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/demo.h b/cl_dll/demo.h index b7dbaff0..def3616a 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 303a9d25..344d1783 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 88b221df..ffb1190a 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/events.cpp b/cl_dll/events.cpp index a51dd72f..a6d21a69 100644 --- a/cl_dll/events.cpp +++ b/cl_dll/events.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index c11ee338..c4d831e0 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index 7993bd9d..ae73fc70 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 67973c75..9f940025 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 33fb72a5..59c60f4c 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index d26b3655..c5c9b18e 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index 5ffce74a..8f470c0a 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 7a9ec9d3..2993c3f2 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index 92051afe..cf5489c0 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index d5c352fa..5b6d7a41 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index fd1ef7da..10014082 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 54f1ea93..55fbeee6 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index 881812f7..ddfb3cd5 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 59535fb4..88a7a047 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index a5eb39f1..d3a031d4 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 7af94672..90c84fb4 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 517ef982..6bb4edbe 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index a4abe91c..bda8616d 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.h b/cl_dll/view.h index c0aa0e8f..7d8624c9 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/dlls/squad.h b/dlls/squad.h index f8f20aa0..607540cf 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 1df298b2..48804a16 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 61eb06fd..19b46b1d 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // From 48733fd1a1a5e10b1029b8099d118ee2d4ce63ec Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 19 Jan 2018 20:00:32 +0300 Subject: [PATCH 08/36] All copyright symbols to (c) --- cl_dll/GameStudioModelRenderer.cpp | 2 +- cl_dll/GameStudioModelRenderer.h | 2 +- cl_dll/GameStudioModelRenderer_Sample.cpp | 2 +- cl_dll/GameStudioModelRenderer_Sample.h | 2 +- cl_dll/StudioModelRenderer.cpp | 2 +- cl_dll/StudioModelRenderer.h | 2 +- cl_dll/camera.h | 2 +- cl_dll/demo.h | 2 +- cl_dll/entity.cpp | 2 +- cl_dll/ev_hldm.h | 2 +- cl_dll/events.cpp | 2 +- cl_dll/eventscripts.h | 2 +- cl_dll/hud_iface.h | 2 +- cl_dll/hud_servers.cpp | 2 +- cl_dll/hud_servers.h | 2 +- cl_dll/hud_servers_priv.h | 2 +- cl_dll/hud_spectator.cpp | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_camera.cpp | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input.cpp | 2 +- cl_dll/input_goldsource.cpp | 2 +- cl_dll/kbutton.h | 2 +- cl_dll/overview.cpp | 2 +- cl_dll/overview.h | 2 +- cl_dll/studio_util.cpp | 2 +- cl_dll/studio_util.h | 2 +- cl_dll/tri.cpp | 2 +- cl_dll/view.cpp | 2 +- cl_dll/view.h | 2 +- dlls/playermonster.cpp | 2 +- dlls/squad.h | 2 +- dlls/stats.cpp | 2 +- pm_shared/pm_movevars.h | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index f2953e96..570b3375 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 8b911db8..0e424576 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index 5f1d2b69..ee8e8f9c 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index a9136880..7a4d062d 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index ffcf305b..a9859244 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0f91122d..69d28a1e 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 99235ed6..1ecb9563 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/demo.h b/cl_dll/demo.h index def3616a..3aaa3f21 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 344d1783..40649fa7 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index ffb1190a..8a836762 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/events.cpp b/cl_dll/events.cpp index a6d21a69..f286d261 100644 --- a/cl_dll/events.cpp +++ b/cl_dll/events.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index c4d831e0..c61bf300 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index ae73fc70..73464c83 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 9f940025..fa6d5585 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 59c60f4c..5e886560 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index c5c9b18e..72590c2f 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index 8f470c0a..edb743ba 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 2993c3f2..9b3391e2 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index cf5489c0..12ad41f4 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 5b6d7a41..b4c51730 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index 10014082..0abd542b 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index f530bdbc..bd997784 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 55fbeee6..4c7c7ae8 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index ddfb3cd5..81f028e2 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 88a7a047..c1675e98 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index d3a031d4..6e488dcb 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 90c84fb4..83de704c 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 6bb4edbe..ab8f3730 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index bda8616d..daecc3af 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.h b/cl_dll/view.h index 7d8624c9..6ca818d5 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index a6e38389..092e7dca 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/squad.h b/dlls/squad.h index 607540cf..2c79ee90 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 48804a16..e37832c8 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 19b46b1d..53d8ee9c 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // From 53626b99652070e7e54767cb827afb3d96169aeb Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 20 Jan 2018 17:03:53 +0300 Subject: [PATCH 09/36] Add custom makefont from #46 --- utils/makefont/makefont.cpp | 845 ++++++++++++++++++++++++++++++++++++ utils/makefont/makefont.dsp | 138 ++++++ utils/makefont/winebuild.sh | 3 + 3 files changed, 986 insertions(+) create mode 100644 utils/makefont/makefont.cpp create mode 100644 utils/makefont/makefont.dsp create mode 100755 utils/makefont/winebuild.sh diff --git a/utils/makefont/makefont.cpp b/utils/makefont/makefont.cpp new file mode 100644 index 00000000..eb2eb3ff --- /dev/null +++ b/utils/makefont/makefont.cpp @@ -0,0 +1,845 @@ +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#define _NOENUMQBOOL + +#include + +extern "C" +{ + #include "cmdlib.h" + #include "wadlib.h" +} +#include "qfont.h" + +#define DEFAULT_FONT "Arial" + +#define FONT_TAG 6 // Font's are the 6th tag after the TYP_LUMPY base ( 64 )...i.e., type == 70 + +BOOL bItalic = FALSE; +BOOL bBold = FALSE; +BOOL bUnderline = FALSE; + +char fontname[ 256 ]; +int pointsize[3] = { 9, 11, 15 }; + +/* +================= +zeromalloc + +Allocates and zeroes memory +================= +*/ +void *zeromalloc( size_t size ) +{ + unsigned char *pbuffer; + pbuffer = ( unsigned char * )malloc( size ); + if ( !pbuffer ) + { + printf( "Failed on allocation of %i bytes", size ); + exit( -1 ); + } + + memset( pbuffer, 0, size ); + return ( void * )pbuffer; +} + +/* +================= +Draw_SetupConsolePalette + +Set's the palette to full brightness ( 192 ) and +set's up palette entry 0 -- black +================= +*/ +void Draw_SetupConsolePalette( unsigned char *pal ) +{ + unsigned char *pPalette; + int i; + + pPalette = pal; + + *(short *)pPalette = 3 * 256; + pPalette += sizeof( short ); + + for ( i = 0; i < 256; i++ ) + { + pPalette[3 * i + 0 ] = i; + pPalette[3 * i + 1 ] = i; + pPalette[3 * i + 2 ] = i; + } + + // Set palette zero correctly + pPalette[ 0 ] = 0; + pPalette[ 1 ] = 0; + pPalette[ 2 ] = 0; +} + +//DJXX added for debugging +BOOL WriteDIB(LPTSTR szFile, HANDLE hDIB) +{ + BITMAPFILEHEADER hdr; + LPBITMAPINFOHEADER lpbi; + + if (!hDIB) + return FALSE; + + FILE *file; + file = SafeOpenWrite(szFile); + + + lpbi = (LPBITMAPINFOHEADER)hDIB; + + int nColors = 1 << lpbi->biBitCount; + + // Fill in the fields of the file header + hdr.bfType = ((WORD)('M' << 8) | 'B'); // is always "BM" + hdr.bfSize = GlobalSize(hDIB) + sizeof(hdr); + printf("WriteDIB. Error code = %i\n",GetLastError()); + hdr.bfReserved1 = 0; + hdr.bfReserved2 = 0; + hdr.bfOffBits = (DWORD)(sizeof(hdr)+lpbi->biSize + + nColors * sizeof(RGBQUAD)); + + // Write the file header + SafeWrite(file, &hdr, sizeof(hdr)); + + // Write the DIB header and the bits + SafeWrite(file, lpbi, GlobalSize(hDIB)); + fclose(file); + return TRUE; +} + + +/* +================= +CreateProportionalConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: New version, draws chararacters closely to each other without spaces + +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateProportionalConsoleFont(char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + TEXTMETRIC tm; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128 - 32) / 16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16;//now used only for calculating width of wad texture + int fontcharwidth; + int edge = 1; + RECT rcChar; + boolean lShadow = true;//draw shadow instead of outline + + // Create the font + fnt = CreateFont(-nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont); + + bits = NULL; + + fullsize = sizeof(qfont_t)-4 + (/*128*/256 * w * charwidth) + sizeof(short)+768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = (qfont_t *)zeromalloc(fullsize); + pqdata = (unsigned char *)pqf + sizeof(qfont_t)-4; + + pPalette = pqdata + (/*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette(pPalette); + + hdc = GetDC(NULL); + hmemDC = CreateCompatibleDC(hdc); + + oldfnt = (HFONT)SelectObject(hmemDC, fnt); + + if (GetTextMetrics(hmemDC, &tm)) + { + fontcharwidth = tm.tmMaxCharWidth; + if (fontcharwidth % 2)//hack: on odd values of fontcharwidth, bitmaps pixel check gives false triggering + fontcharwidth++; + } + else { + fontcharwidth = charwidth; + } + + if (lShadow) + charheight += edge;//adding 1 pixel to bottom for shadowing + + rc.top = 0; + rc.left = 0; + rc.right = fontcharwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap(fontcharwidth * w, charheight * h, 1, 1, NULL); + oldbm = (HBITMAP)SelectObject(hmemDC, hbm); + + SetTextColor(hmemDC, 0x00ffffff); + SetBkMode(hmemDC, TRANSPARENT); + + // Paint black background + FillRect(hmemDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + + // Draw character set into memory DC + for (j = 0; j < h; j++) + { + for (i = 0; i < w; i++) + { + x = i * fontcharwidth; + y = j * charheight; + + c = (unsigned char)(startchar + j * w + i); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + fontcharwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText(hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT); + } + } + } + + // Now turn the qfont into raw format + memset(&tempbmi, 0, sizeof(BITMAPINFO)); + + pbmheader = (BITMAPINFOHEADER *)&tempbmi; + + pbmheader->biSize = sizeof(BITMAPINFOHEADER); + pbmheader->biWidth = w * fontcharwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS); + + // Allocate space for all bits + pbmi = (BITMAPINFO *)zeromalloc(sizeof (BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)+pbmheader->biSizeImage); + + memcpy(pbmi, &tempbmi, sizeof(BITMAPINFO)); + + bits = (unsigned char *)pbmi + sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD); + + // Now read in bits + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS); + + if (nScans > 0) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset(pCur, 0xFF, w * charwidth * pqf->height); + + int k = 0, dest_x = 0, dest_y = 0; + + for (j = 0; j < h; j++) + for (i = 0; i < w; i++) + { + int rightmost, leftmost, realcharwidth; + + x = i * fontcharwidth; + y = j * charheight; + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + rightmost = 0; + leftmost = fontcharwidth; + + //Calculate real width of the character + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < fontcharwidth; x1++) + { + int src_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7)))//on odd values of fontcharwidth this check gives false triggering + { + if (x1 > rightmost) + rightmost = x1; + + if (x1 < leftmost) + leftmost = x1; + } + } + if (leftmost > rightmost)//empty characters + { + leftmost = 0; + rightmost = 7; + } else { + rightmost += edge; + if (!lShadow) + leftmost -= edge; + } + + realcharwidth = rightmost - leftmost + 1; + pqf->fontinfo[c].charwidth = realcharwidth; + + if (dest_x + realcharwidth >= w * charwidth)//if it not fits on current line then carry it to the next line + { + dest_x = 0; + k++; + } + + dest_y = k * charheight; + pqf->fontinfo[c].startoffset = dest_y * w * charwidth + dest_x; + + if (lShadow) + { + int shift = edge; + //Draw shadow by shifting character to 1 pixel right and down + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + shift + y1) * w * charwidth + (dest_x + shift + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + //pCur[0] = 32; + pCur[0] = 0;//full black so shadow remains black even it's coloured text + } + } + } + else + { + // Put black pixels below and to the right of each pixel(outline) + for (y1 = edge; y1 < charheight - edge; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + int xx0, yy0; + + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + for (xx0 = -edge; xx0 <= edge; xx0++) + for (yy0 = -edge; yy0 <= edge; yy0++) + { + src_offset = (y + y1 + yy0) * w * fontcharwidth + x + x1 + xx0 + leftmost;//adding shift + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + pCur[0] = 32; + } + } + } + } + + // Now copy in the actual font pixels + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + pCur[0] = 192; + } + } + dest_x += realcharwidth; + } + } + // Free memory bits + free(pbmi); + SelectObject(hmemDC, oldfnt); + DeleteObject(fnt); + + SelectObject(hmemDC, oldbm); + + DeleteObject(hbm); + + DeleteDC(hmemDC); + ReleaseDC(NULL, hdc); + + return pqf; +} +#pragma optimize( "g", on ) + + +/* +================= +CreateConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: original version, just added drawing of locale characters and fixed memory bug. +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateConsoleFont( char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize ) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128-32)/16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16; + RECT rcChar; + + // Create the font + fnt = CreateFont( -nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont ); + + bits = NULL; + + fullsize = sizeof( qfont_t ) - 4 + ( /*128*/256 * w * charwidth ) + sizeof(short) + 768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = ( qfont_t * )zeromalloc( fullsize ); + pqdata = (unsigned char *)pqf + sizeof( qfont_t ) - 4; + + pPalette = pqdata + ( /*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette( pPalette ); + + hdc = GetDC( NULL ); + hmemDC = CreateCompatibleDC( hdc ); + + rc.top = 0; + rc.left = 0; + rc.right = charwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap( charwidth * w, charheight * h, 1, 1, NULL ); + oldbm = (HBITMAP)SelectObject( hmemDC, hbm ); + oldfnt = (HFONT)SelectObject( hmemDC, fnt ); + + SetTextColor( hmemDC, 0x00ffffff ); + SetBkMode( hmemDC, TRANSPARENT ); + + // Paint black background + FillRect( hmemDC, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); + + // Draw character set into memory DC + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + x = i * charwidth; + y = j * charheight; + + c = (unsigned char)( startchar + j * w + i ); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + charwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText( hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT ); + } + } + } + + // Now turn the qfont into raw format + memset( &tempbmi, 0, sizeof( BITMAPINFO ) ); + pbmheader = ( BITMAPINFOHEADER * )&tempbmi; + + pbmheader->biSize = sizeof( BITMAPINFOHEADER ); + pbmheader->biWidth = w * charwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS ); + + // Allocate space for all bits + pbmi = ( BITMAPINFO * )zeromalloc( sizeof ( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ) + pbmheader->biSizeImage ); + + memcpy( pbmi, &tempbmi, sizeof( BITMAPINFO ) ); + + bits = ( unsigned char * )pbmi + sizeof( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ); + + // Now read in bits + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS ); + + if ( nScans > 0 ) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset( pCur, 0xFF, w * charwidth * pqf->height ); + + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + int edge = 1; + int bestwidth; + x = i * charwidth; + y = j * charheight; + + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + pqf->fontinfo[ c ].charwidth = charwidth; + pqf->fontinfo[ c ].startoffset = y * w * charwidth + x; + + bestwidth = 0; + + // In this first pass, place the black drop shadow so characters draw ok in the engine against + // most backgrounds. + // YWB: FIXME, apply a box filter and enable blending? +#if 0//DJXX: we already did that for a whole image by memset + // Make it all transparent for starters + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + offset = ( y + y1 ) * w * charwidth + x + x1 ; + // Dest + pCur = pqdata + offset; + // Assume transparent + pCur[0] = 255; + } + } +#endif + // Put black pixels below and to the right of each pixel + for ( y1 = edge; y1 < charheight - edge; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + int srcoffset; + + int xx0, yy0; + + offset = ( y + y1 ) * w * charwidth + x + x1 ; + + // Dest + pCur = pqdata + offset; + + for ( xx0 = -edge; xx0 <= edge; xx0++ ) + { + for ( yy0 = -edge; yy0 <= edge; yy0++ ) + { + srcoffset = ( y + y1 + yy0 ) * w * charwidth + x + x1 + xx0; + + if ( bits[ srcoffset >> 3 ] & ( 1 << ( 7 - srcoffset & 7 ) ) ) + { + // Near Black + pCur[0] = 32; + } + } + } + } + } + + // Now copy in the actual font pixels + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + + // bestwidth += 1; + /* + // Now blend it + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + */ + + // Space character width + if ( c == 32 ) + { + bestwidth = 8; + } + else + { + // Small characters needs can be padded a bit so they don't run into each other + if ( bestwidth <= 14 ) + { + bestwidth += 2; + } + } + + // Store off width + pqf->fontinfo[ c ].charwidth = bestwidth; + } + } + } + + // Free memory bits + free ( pbmi ); + + SelectObject( hmemDC, oldfnt ); + DeleteObject( fnt ); + + SelectObject( hmemDC, oldbm ); + + DeleteObject( hbm ); + + DeleteDC( hmemDC ); + ReleaseDC( NULL, hdc ); + + return pqf; +} + +#pragma optimize( "g", on ) + +/* +================= +main + +================= +*/ +int main(int argc, char* argv[]) +{ + int i; + DWORD start, end; + char destfile[1024]; + char sz[ 32 ]; + int outsize[ 3 ]; + + qfont_t *fonts[ 3 ]; + + strcpy( fontname, DEFAULT_FONT ); + + printf("makefont.exe Version 2.0 by valve and DJXX (%s)\n", __DATE__ ); + + printf ("----- Creating Console Font ----\n"); + + for (i=1 ; i= argc ) + { + Error( "Makefont: Insufficient point sizes specified\n" ); + } + pointsize[0] = atoi( argv[i+1] ); + pointsize[1] = atoi( argv[i+2] ); + pointsize[2] = atoi( argv[i+3] ); + i += 3; + } + else if (!strcmp(argv[i],"-italic")) + { + bItalic = TRUE; + printf ( "italic set\n"); + } + else if (!strcmp(argv[i],"-bold")) + { + bBold = TRUE; + printf ( "bold set\n"); + } + else if (!strcmp(argv[i],"-underline")) + { + bUnderline = TRUE; + printf ( "underline set\n"); + } + else if ( argv[i][0] == '-' ) + { + Error ("Unknown option \"%s\"", argv[i]); + } + else + break; + } + + if ( i != argc - 1 ) + { + Error ("usage: makefont [-font \"fontname\"] [-italic] [-underline] [-bold] [-pointsizes sm med lg] outfile"); + } + + printf( "Creating %i, %i, and %i point %s fonts\n", pointsize[0], pointsize[1], pointsize[2], fontname ); + + start = timeGetTime(); + + // Create the fonts + for ( i = 0 ; i < 3; i++ ) + { + fonts[ i ] = CreateProportionalConsoleFont( fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[ i ] ); + //fonts[i] = CreateConsoleFont(fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[i]); + } + + // Create wad file + strcpy (destfile, argv[argc - 1]); + StripExtension (destfile); + DefaultExtension (destfile, ".wad"); + + NewWad( destfile, false ); + + // Add fonts as lumps + for ( i = 0; i < 3; i++ ) + { + sprintf( sz, "font%i", i ); + AddLump( sz, fonts[ i ], outsize[ i ], TYP_LUMPY + FONT_TAG, false ); + } + + // Store results as a WAD3 + // NOTE: ( should be named fonts.wad in the valve\ subdirectory ) + WriteWad( 3 ); + + // Clean up memory + for ( i = 0 ; i < 3; i++ ) + { + free( fonts[ i ] ); + } + + end = timeGetTime (); + + printf ( "%5.5f seconds elapsed\n", (float)( end - start )/1000.0 ); + + // Display for a second since it might not be running from command prompt + Sleep( 1000 ); + return 0; +} diff --git a/utils/makefont/makefont.dsp b/utils/makefont/makefont.dsp new file mode 100644 index 00000000..aece6e0c --- /dev/null +++ b/utils/makefont/makefont.dsp @@ -0,0 +1,138 @@ +# Microsoft Developer Studio Project File - Name="makefont" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=makefont - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makefont.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "makefont.mak" CFG="makefont - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makefont - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "makefont - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makefont - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /Zi /O2 /I "../../common" /I "../common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 +# Begin Special Build Tool +TargetPath=.\Release\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ELSEIF "$(CFG)" == "makefont - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../common" /I "../common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +TargetPath=.\Debug\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "makefont - Win32 Release" +# Name "makefont - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\common\cmdlib.c +# End Source File +# Begin Source File + +SOURCE=.\makefont.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\common\cmdlib.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/utils/makefont/winebuild.sh b/utils/makefont/winebuild.sh new file mode 100755 index 00000000..ec259577 --- /dev/null +++ b/utils/makefont/winebuild.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +winegcc -g -m32 makefont.cpp ../common/wadlib.c ../common/cmdlib.c -I../common/ -I../../common/ -mwindows -mno-cygwin -lwinmm -fno-stack-protector From 588065ab162693a30569d07089b46d7d17ca66d9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 17:27:02 +0500 Subject: [PATCH 10/36] Do not show long nicknames on low resolution. --- cl_dll/scoreboard.cpp | 65 ++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 908d00f3..0f26c6f2 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -92,17 +92,18 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // X positions // relative to the side of the scoreboard -#define NAME_RANGE_MIN -65 -#define NAME_RANGE_MAX 180 -#define KILLS_RANGE_MIN 165 -#define KILLS_RANGE_MAX 205 -#define DIVIDER_POS 215 -#define DEATHS_RANGE_MIN 220 -#define DEATHS_RANGE_MAX 245 -#define PING_RANGE_MIN 280 -#define PING_RANGE_MAX 330 -#define PL_RANGE_MIN 350 -#define PL_RANGE_MAX 410 +#define NAME_RANGE_MIN 20 +#define NAME_RANGE_MAX 145 +#define NAME_RANGE_MODIFIER 120 +#define KILLS_RANGE_MIN 130 +#define KILLS_RANGE_MAX 170 +#define DIVIDER_POS 180 +#define DEATHS_RANGE_MIN 185 +#define DEATHS_RANGE_MAX 210 +#define PING_RANGE_MIN 245 +#define PING_RANGE_MAX 295 +#define PL_RANGE_MIN 315 +#define PL_RANGE_MAX 375 int SCOREBOARD_WIDTH = 320; @@ -128,11 +129,11 @@ int CHudScoreboard::Draw( float fTime ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) { can_show_packetloss = 1; - SCOREBOARD_WIDTH = 400; + SCOREBOARD_WIDTH = ( ScreenWidth >= 520 ) ? ( 400 - NAME_RANGE_MODIFIER ) : 400; } else { - SCOREBOARD_WIDTH = 320; + SCOREBOARD_WIDTH = ( ScreenWidth >= 440 ) ? ( 320 - NAME_RANGE_MODIFIER ) : 320; } // just sort the list on the fly @@ -145,7 +146,14 @@ int CHudScoreboard::Draw( float fTime ) int xpos = NAME_RANGE_MIN + xpos_rel; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 125; + FAR_RIGHT += 5; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + FAR_RIGHT += NAME_RANGE_MODIFIER; + } + if( cl_scoreboard_bg && cl_scoreboard_bg->value ) gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) @@ -165,7 +173,7 @@ int CHudScoreboard::Draw( float fTime ) list_slot += 1.2; ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); - xpos = NAME_RANGE_MIN + xpos_rel; + // xpos = NAME_RANGE_MIN + xpos_rel; FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line list_slot += 0.8; @@ -266,12 +274,18 @@ int CHudScoreboard::Draw( float fTime ) break; xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish if( team_info->ownteam ) // if it is their team, draw the background different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) @@ -340,7 +354,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 125; + FAR_RIGHT += 5; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + FAR_RIGHT += NAME_RANGE_MODIFIER; + } // draw the players, in order, and restricted to team if set while( 1 ) @@ -380,6 +399,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, break; int xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 255, b = 255; float *colors = GetClientColor( best_player ); r *= colors[0], g *= colors[1], b *= colors[2]; @@ -388,18 +413,18 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( pl_info->thisplayer ) { // green is the suicide color? i wish this could do grey... - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); } else { // Highlight the killers name - overlay the background in red, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); } } else if( pl_info->thisplayer ) // if it is their name, draw it a different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) From f13adcfb8b7dc11d365389bc01ee3290f1d4ff26 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 17:52:07 +0500 Subject: [PATCH 11/36] Fix infinite slide in multiplayer. --- pm_shared/pm_shared.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 9aed8093..abe7b317 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -3312,8 +3312,8 @@ void PM_Move( struct playermove_s *ppmove, int server ) pmove->flags &= ~FL_ONGROUND; } - // In single player, reset friction after each movement to FrictionModifier Triggers work still. - if( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) + // Reset friction after each movement to FrictionModifier Triggers work still. + if( pmove->movetype == MOVETYPE_WALK ) { pmove->friction = 1.0f; } From 556e2647fe0ba801c75bf810e41ef58c5eb90c34 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 18:15:02 +0500 Subject: [PATCH 12/36] Do not show train controls after player death. --- dlls/player.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 52f5f546..99d4c7f6 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -782,6 +782,9 @@ void CBasePlayer::PackDeadPlayerItems( void ) void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { + int i; + CBasePlayerItem *pPendingItem; + if( m_pActiveItem ) { ResetAutoaim(); @@ -794,8 +797,8 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) if( m_pTank != 0 ) m_pTank->Use( this, this, USE_OFF, 0 ); - int i; - CBasePlayerItem *pPendingItem; + m_iTrain = TRAIN_NEW; // turn off train + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; From ccbc147c90bd530ef04af79a794fc6affb4c535e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 3 Mar 2018 23:58:19 +0300 Subject: [PATCH 13/36] Fix Battery message spam when armorvalue goes fractional --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 99d4c7f6..bbd668ba 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3935,7 +3935,7 @@ void CBasePlayer::UpdateClientData( void ) m_iClientHealth = (int)pev->health; } - if( pev->armorvalue != m_iClientBattery ) + if( (int)pev->armorvalue != m_iClientBattery ) { m_iClientBattery = (int)pev->armorvalue; From 4538ba1c19e0a3dd4898c3410ae751c821347b2e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:12:44 +0300 Subject: [PATCH 14/36] Force XP toolchain in newer Visual Studio --- CMakeLists.txt | 6 ++++++ cmake/VSForceXPToolchain.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 cmake/VSForceXPToolchain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e025342a..3403cfbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,12 @@ # cmake_minimum_required(VERSION 2.6.0) + +# Install custom module path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + +include(VSForceXPToolchain) # Force XP toolchain for Visual Studio + project (HLSDK-XASH3D) #-------------- diff --git a/cmake/VSForceXPToolchain.cmake b/cmake/VSForceXPToolchain.cmake new file mode 100644 index 00000000..e78fb0a2 --- /dev/null +++ b/cmake/VSForceXPToolchain.cmake @@ -0,0 +1,29 @@ +if(WIN32) + # Windows XP compatible platform toolset. Must be set before project(), + # otherwise change of CMAKE_*_TOOLSET will take no effect. + # We get VS version from the generator name because neither MSVC* nor other + # variables that describe the compiler aren't available before project(). + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") + if(${CMAKE_MATCH_1} LESS 11) + # Nothing. Older VS does support XP by default. + elseif(${CMAKE_MATCH_1} EQUAL 11) + # Visual Studio 11 2012 + set(CMAKE_GENERATOR_TOOLSET "v110_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAK_VS_PLATFORM_TOOLSET "v110_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 12) + # Visual Studio 12 2013 + set(CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v120_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 14) + # Visual Studio 14 2015 + set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v140_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 15) + # Visual Studio 15 2017 + set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v141_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + else() + message(WARNING "WARNING: You maybe building without Windows XP compability. See which toolchain version Visual Studio provides, and say cmake to use it: cmake -G \"Visual Studio XX\" -T \"vXXX_xp\"") + endif() + endif() +endif() From 81d31cdbd19c7fb744c8fb981321bfcdedb1006b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:13:52 +0300 Subject: [PATCH 15/36] Add appveyor --- appveyor.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..eb39ee2d --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +version: 1.0.{build} + +branches: + only: + - master + +environment: + matrix: + - os: Visual Studio 2013 + GENERATOR_NAME: "Visual Studio 12 2013" + - os: Visual Studio 2015 + GENERATOR_NAME: "Visual Studio 14 2015" +# TODO: Uncomment when AppVeyor will provide XP toolchain for VS2017 +# - os: Visual Studio 2017 +# GENERATOR_NAME: "Visual Studio 15 2017" + +clone_folder: c:\projects\xash\hlsdk-xash3d + +build: + project: INSTALL.vcxproj + verbosity: normal + +configuration: + - Debug + +before_build: + - git submodule update --init --recursive + - cmake -G "%GENERATOR_NAME%" From d52b03a9c465436dc78b012eca1677eeec8bad61 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:18:05 +0300 Subject: [PATCH 16/36] Add AppVeyor build status --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9261b1b3..a57d94b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) +# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-xash3d?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-xash3d) Half-Life SDK for Xash3D & GoldSource with some fixes. @@ -31,7 +31,7 @@ These scripts also can be ran via wine: The libraries built this way are always GoldSource compatible. -There're dsp projects for MVS 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer MVS versions. +There're dsp projects for Visual Studio 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer Visual Studio versions. #### Using mingw @@ -44,7 +44,7 @@ TODO ### OS X -TODO +Nothing here. ### FreeBSD From 6818ff091df1f4aae12ec784b5467bc4016e4f35 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:21:05 +0300 Subject: [PATCH 17/36] Remove cast pointer to size_t in cbase.h, it's useless here --- dlls/cbase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/cbase.h b/dlls/cbase.h index 4cf40abd..e200d7b0 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -283,7 +283,7 @@ public: #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if( pFunction && !NAME_FOR_FUNCTION( (size_t)( pFunction ) ) ) + if( pFunction && !NAME_FOR_FUNCTION( pFunction ) ) ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (size_t)pFunction ); } From 6161c6d4d834f1eac22b1e16aad86ab5ecf6971b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:24:54 +0300 Subject: [PATCH 18/36] Replace snprintf by _snprintf, for MSVC --- cl_dll/text_message.cpp | 8 ++++---- dlls/client.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index b959fc87..512623dd 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -181,20 +181,20 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf switch( msg_dest ) { case HUD_PRINTCENTER: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } diff --git a/dlls/client.cpp b/dlls/client.cpp index 578534e3..1e7dab72 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -108,7 +108,7 @@ void ClientDisconnect( edict_t *pEntity ) char text[256] = ""; if( pEntity->v.netname ) - snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -660,7 +660,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) if( gpGlobals->maxClients > 1 ) { char text[256]; - snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + _snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); From 4af903015604bbbbaf9b861fbd2e2b565520bcd1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 22 Mar 2018 15:23:34 +0300 Subject: [PATCH 19/36] Append 64 postfix on 64 bit --- CMakeLists.txt | 3 ++- cl_dll/CMakeLists.txt | 7 ++++++- dlls/CMakeLists.txt | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3403cfbd..705025bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ project (HLSDK-XASH3D) #-------------- # USER DEFINES \ ################\ +option(64BIT "Allow 64 Bit builds" OFF) option(USE_VGUI "Enable VGUI1. UNDONE" OFF) option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF) option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) @@ -50,7 +51,7 @@ set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows" set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") # Build 32-bit Xash on 64-bit, because Xash3D not support this -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") else() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 05990913..b848aa6c 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -125,8 +125,13 @@ set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(CLDLL_NAME "client") + if(64BIT) + set(CLDLL_NAME "client64") + endif() + set_target_properties(${CLDLL_LIBRARY} PROPERTIES - OUTPUT_NAME "client" + OUTPUT_NAME ${CLDLL_NAME} PREFIX "") endif() diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bf7d3370..55370eeb 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -157,8 +157,13 @@ set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(SVDLL_NAME "${SERVER_LIBRARY_NAME}") + if(64BIT) + set(SVDLL_NAME "${SERVER_LIBRARY_NAME}64") + endif() + set_target_properties(${SVDLL_LIBRARY} PROPERTIES - OUTPUT_NAME ${SERVER_LIBRARY_NAME} + OUTPUT_NAME ${SVDLL_NAME} PREFIX "") endif() From bc379e92343ae52d44c152baaf176e32f8ed9765 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 23 Mar 2018 23:08:38 +0300 Subject: [PATCH 20/36] Add 64/32 bit message and a dumb check when 32 bit isn't properly enabled --- CMakeLists.txt | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 705025bf..bd7fe664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +option(64BIT "Disable auto -m32 appending to compiler flags" OFF) set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") @@ -50,25 +51,35 @@ set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows" set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -# Build 32-bit Xash on 64-bit, because Xash3D not support this if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) - error("UNDONE: set 32 build flags") + error("UNDONE: set 32 build flags") else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() + set(CMAKE_SIZEOF_VOID_P 4) +endif() + +if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4) + message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!") +endif() + +if(64BIT) + message(STATUS "Building for 64 Bit") +else() + message(STATUS "Building for 32 Bit") endif() # add_compile_options for older cmake versions if(${CMAKE_VERSION} VERSION_LESS "3.0.2") -macro(add_compile_options) - set(list_var "${ARGV}") - foreach(arg IN LISTS list_var) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") - endforeach() -endmacro() + macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() + endmacro() endif() if(BUILD_CLIENT) From 3401f54148e4001b4aa893e92695b17d93b0b53e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 23 Mar 2018 23:46:05 +0300 Subject: [PATCH 21/36] Fix Android buil --- cl_dll/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 68917633..df6130ed 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -92,7 +92,7 @@ SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include -DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w +DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w -D_snprintf=snprintf LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../common \ From 9d7ab6acf46a8b71ef119d9c252767865522d21d Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 31 Mar 2018 17:09:13 +0500 Subject: [PATCH 22/36] Some fixes for FoV, HUD, egon flare and new compilers. (#52) * Fix warnings. * Merge some fixes from https://github.com/Fograin/hl-subs-mod. --- cl_dll/ev_hldm.cpp | 41 ++++++++++++++++++++++++++++++++++++- cl_dll/health.cpp | 3 ++- cl_dll/hl/hl_objects.cpp | 25 +++++++++++++++++++++- cl_dll/hl/hl_weapons.cpp | 2 ++ cl_dll/hud.cpp | 3 ++- cl_dll/hud.h | 2 +- cl_dll/hud_msg.cpp | 16 ++++++++++++++- cl_dll/input_goldsource.cpp | 2 +- cl_dll/scoreboard.cpp | 2 +- dlls/monsters.cpp | 3 ++- dlls/player.cpp | 18 +++++++++++++--- 11 files changed, 105 insertions(+), 12 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 628b5bfa..08127aa1 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1414,6 +1414,17 @@ enum EGON_FIREMODE BEAM *pBeam; BEAM *pBeam2; +TEMPENTITY *pFlare; // Vit_amiN: egon's beam flare + +void EV_EgonFlareCallback( struct tempent_s *ent, float frametime, float currenttime ) +{ + float delta = currenttime - ent->tentOffset.z; // time past since the last scale + if( delta >= ent->tentOffset.y ) + { + ent->entity.curstate.scale += ent->tentOffset.x * delta; + ent->tentOffset.z = currenttime; + } +} void EV_EgonFire( event_args_t *args ) { @@ -1451,7 +1462,7 @@ void EV_EgonFire( event_args_t *args ) if( EV_IsLocal( idx ) ) gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); - if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. + if( iStartup == 1 && EV_IsLocal( idx ) && !( pBeam || pBeam2 || pFlare ) && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. { vec3_t vecSrc, vecEnd, angles, forward, right, up; pmtrace_t tr; @@ -1499,8 +1510,16 @@ void EV_EgonFire( event_args_t *args ) pBeam->flags |= ( FBEAM_SINENOISE ); pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b ); + + // Vit_amiN: egon beam flare + pFlare = gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, gEngfuncs.pEventAPI->EV_FindModelIndex( EGON_FLARE_SPRITE ), kRenderGlow, kRenderFxNoDissipation, 1.0, 99999, FTENT_SPRCYCLE | FTENT_PERSIST ); } } + + if( pFlare ) // Vit_amiN: store the last mode for EV_EgonStop() + { + pFlare->tentOffset.x = ( iFireMode == FIRE_WIDE ) ? 1.0f : 0.0f; + } } void EV_EgonStop( event_args_t *args ) @@ -1529,6 +1548,26 @@ void EV_EgonStop( event_args_t *args ) pBeam2->die = 0.0; pBeam2 = NULL; } + + if( pFlare ) // Vit_amiN: egon beam flare + { + pFlare->die = gEngfuncs.GetClientTime(); + + if( gEngfuncs.GetMaxClients() == 1 || !(pFlare->flags & FTENT_NOMODEL) ) + { + if( pFlare->tentOffset.x != 0.0f ) // true for iFireMode == FIRE_WIDE + { + pFlare->callback = &EV_EgonFlareCallback; + pFlare->fadeSpeed = 2.0; // fade out will take 0.5 sec + pFlare->tentOffset.x = 10.0; // scaling speed per second + pFlare->tentOffset.y = 0.1; // min time between two scales + pFlare->tentOffset.z = pFlare->die; // the last callback run time + pFlare->flags = FTENT_FADEOUT | FTENT_CLIENTCUSTOM; + } + } + + pFlare = NULL; + } } } //====================== diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index d4979c35..eebf0eb0 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -231,7 +231,8 @@ int CHudHealth::Draw( float flTime ) int iHeight = gHUD.m_iFontHeight; int iWidth = HealthWidth / 10; - FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a ); + UnpackRGB( r, g, b, RGB_YELLOWISH ); + FillRGBA( x, y, iWidth, iHeight, r, g, b, a ); } DrawDamage( flTime ); diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index b51ee693..55822dcb 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -29,6 +29,7 @@ extern BEAM *pBeam; extern BEAM *pBeam2; +extern TEMPENTITY *pFlare; // Vit_amiN: egon's energy flare void HUD_GetLastOrg( float *org ); void UpdateBeams( void ) @@ -75,6 +76,28 @@ void UpdateBeams( void ) pBeam2->target = tr.endpos; pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. } + + if( pFlare ) // Vit_amiN: beam flare + { + pFlare->entity.origin = tr.endpos; + pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + + if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare + { + pFlare->flags |= FTENT_NOMODEL; + + if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0 ) ) // Beam hit some non-world entity + { + physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); + + // Not the world, let's assume that we hit something organic ( dog, cat, uncle joe, etc ) + if( pEntity && !( pEntity->solid == SOLID_BSP || pEntity->movetype == MOVETYPE_PUSHSTEP ) ) + { + pFlare->flags &= ~FTENT_NOMODEL; + } + } + } + } } /* @@ -86,6 +109,6 @@ Add game specific, client-side objects here */ void Game_AddObjects( void ) { - if( pBeam && pBeam2 ) + if( pBeam || pBeam2 || pFlare ) // Vit_amiN: egon flare added UpdateBeams(); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 75161a9e..b2c1d7b3 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -34,6 +34,7 @@ extern globalvars_t *gpGlobals; extern int g_iUser1; +extern bool g_hasPredictedFOV; // Vit_amiN: from HUD // Pool of client side entities/entvars_t static entvars_t ev[32]; @@ -881,6 +882,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm to->client.fuser2 = player.m_flNextAmmoBurn; to->client.fuser3 = player.m_flAmmoStartCharge; to->client.maxspeed = player.pev->maxspeed; + g_hasPredictedFOV = true; // Vit_amiN: ready //HL Weapons to->client.vuser1[0] = player.ammo_9mm; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 05bda284..195dfa5a 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -413,6 +413,7 @@ int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) } float g_lastFOV = 0.0; +bool g_hasPredictedFOV = false; // Vit_amiN: it'll became true after the first prediction /* ============ @@ -514,7 +515,7 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) int def_fov = CVAR_GET_FLOAT( "default_fov" ); //Weapon prediction already takes care of changing the fog. ( g_lastFOV ). - if( cl_lw && cl_lw->value ) + if( g_hasPredictedFOV ) return 1; g_lastFOV = newfov; diff --git a/cl_dll/hud.h b/cl_dll/hud.h index decfa917..f3e1ed85 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -230,7 +230,7 @@ public: void InitHUDData( void ); int VidInit( void ); int Draw( float flTime ); - int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing + int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, const char *team = NULL ); // returns the ypos where it finishes drawing void UserCmd_ShowScores( void ); void UserCmd_HideScores( void ); int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ); diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 47f8bc92..b435a85c 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -25,6 +25,10 @@ extern BEAM *pBeam; extern BEAM *pBeam2; +extern TEMPENTITY *pFlare; // Vit_amiN + +extern float g_lastFOV; // Vit_amiN +extern bool g_hasPredictedFOV; // Vit_amiN /// USER-DEFINED SERVER MESSAGE HANDLERS @@ -48,6 +52,11 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) // reset concussion effect m_iConcussionEffect = 0; + // Vit_amiN: reset the FOV + m_iFOV = 0; // default_fov + g_lastFOV = 0.0f; + g_hasPredictedFOV = false; + return 1; } @@ -72,6 +81,7 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) //Probably not a good place to put this. pBeam = pBeam2 = NULL; + pFlare = NULL; // Vit_amiN: clear egon's beam flare } int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) @@ -107,10 +117,14 @@ int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) { + int r, g, b; BEGIN_READ( pbuf, iSize ); m_iConcussionEffect = READ_BYTE(); if( m_iConcussionEffect ) - this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 ); + { + UnpackRGB( r, g, b, RGB_YELLOWISH ); // Vit_amiN: fixed + this->m_StatusIcons.EnableIcon( "dmg_concuss", r, g, b ); + } else this->m_StatusIcons.DisableIcon( "dmg_concuss" ); return 1; diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index bd997784..c45841cb 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -1368,7 +1368,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) // y=ax^b; where a = 300 and b = 1.3 // also x values are in increments of 800 (so this is factored out) // then bounds check result to level out excessively high spin rates - fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3); + fTemp = 300.0 * pow(fabs(fAxisValue) / 800.0, 1.3); if (fTemp > 14000.0) fTemp = 14000.0; // restore direction information diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 0f26c6f2..5d52787c 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -337,7 +337,7 @@ int CHudScoreboard::Draw( float fTime ) extern float *GetClientColor( int client ); // returns the ypos where it finishes drawing -int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team ) +int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, const char *team ) { int can_show_packetloss = 0; int FAR_RIGHT; diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 1e1d3de3..953d1a69 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -2118,7 +2118,8 @@ void CBaseMonster::StartMonster( void ) SetThink( &CBaseMonster::CallMonsterThink ); pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times. - if( !FStringNull( pev->targetname ) )// wait until triggered + // Vit_amiN: fixed -- now it doesn't touch any scripted_sequence target + if( !FStringNull( pev->targetname ) && !m_pCine )// wait until triggered { SetState( MONSTERSTATE_IDLE ); // UNDONE: Some scripted sequence monsters don't have an idle? diff --git a/dlls/player.cpp b/dlls/player.cpp index bbd668ba..b1d28e67 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1860,6 +1860,7 @@ void CBasePlayer::PreThink( void ) { CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity ); float vel; + int iGearId; // Vit_amiN: keeps the train control HUD in sync if( !pTrain ) { @@ -1900,10 +1901,12 @@ void CBasePlayer::PreThink( void ) pTrain->Use( this, this, USE_SET, (float)vel ); } - if( vel ) + iGearId = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + + if( iGearId != ( m_iTrain & 0x0F ) ) // Vit_amiN: speed changed { - m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); - m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; + m_iTrain = iGearId; + m_iTrain |= TRAIN_ACTIVE | TRAIN_NEW; } } else if( m_iTrain & TRAIN_ACTIVE ) @@ -2919,6 +2922,8 @@ void CBasePlayer::Precache( void ) if( gInitHUD ) m_fInitHUD = TRUE; + + pev->fov = m_iFOV; // Vit_amiN: restore the FOV on level change or map/saved game load } int CBasePlayer::Save( CSave &save ) @@ -3326,6 +3331,8 @@ void CBasePlayer::ForceClientDllUpdate( void ) { m_iClientHealth = -1; m_iClientBattery = -1; + m_iClientHideHUD = -1; // Vit_amiN: forcing to update + m_iClientFOV = -1; // Vit_amiN: force client weapons to be sent m_iTrain |= TRAIN_NEW; // Force new train message. m_fWeapon = FALSE; // Force weapon send m_fKnownItem = FALSE; // Force weaponinit messages. @@ -3890,6 +3897,11 @@ void CBasePlayer::UpdateClientData( void ) WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); + // Vit_amiN: the geiger state could run out of sync, too + MESSAGE_BEGIN( MSG_ONE, gmsgGeigerRange, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + InitStatusBar(); } From f6ffc92d5d17c0d52ddceacff08193bd320b60a0 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 1 Apr 2018 20:38:56 +0300 Subject: [PATCH 23/36] Always update gHUD.m_iFOV on SetFOV message. Fix #53 --- cl_dll/hl/hl_weapons.cpp | 2 -- cl_dll/hud.cpp | 5 ----- cl_dll/hud_msg.cpp | 2 -- 3 files changed, 9 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index b2c1d7b3..75161a9e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -34,7 +34,6 @@ extern globalvars_t *gpGlobals; extern int g_iUser1; -extern bool g_hasPredictedFOV; // Vit_amiN: from HUD // Pool of client side entities/entvars_t static entvars_t ev[32]; @@ -882,7 +881,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm to->client.fuser2 = player.m_flNextAmmoBurn; to->client.fuser3 = player.m_flAmmoStartCharge; to->client.maxspeed = player.pev->maxspeed; - g_hasPredictedFOV = true; // Vit_amiN: ready //HL Weapons to->client.vuser1[0] = player.ammo_9mm; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 195dfa5a..3ef72889 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -413,7 +413,6 @@ int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) } float g_lastFOV = 0.0; -bool g_hasPredictedFOV = false; // Vit_amiN: it'll became true after the first prediction /* ============ @@ -514,10 +513,6 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) int newfov = READ_BYTE(); int def_fov = CVAR_GET_FLOAT( "default_fov" ); - //Weapon prediction already takes care of changing the fog. ( g_lastFOV ). - if( g_hasPredictedFOV ) - return 1; - g_lastFOV = newfov; if( newfov == 0 ) diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index b435a85c..7cc2fbad 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -28,7 +28,6 @@ extern BEAM *pBeam2; extern TEMPENTITY *pFlare; // Vit_amiN extern float g_lastFOV; // Vit_amiN -extern bool g_hasPredictedFOV; // Vit_amiN /// USER-DEFINED SERVER MESSAGE HANDLERS @@ -55,7 +54,6 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) // Vit_amiN: reset the FOV m_iFOV = 0; // default_fov g_lastFOV = 0.0f; - g_hasPredictedFOV = false; return 1; } From 0c515e34649dc7ce9e5be5fabfd71c61b0db04f0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:54:10 +0300 Subject: [PATCH 24/36] Update mobility interface --- engine/mobility_int.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/engine/mobility_int.h b/engine/mobility_int.h index 88f63315..d8b6120a 100644 --- a/engine/mobility_int.h +++ b/engine/mobility_int.h @@ -34,7 +34,7 @@ extern "C" { #define TOUCH_FL_DEF_HIDE (1U << 6) #define TOUCH_FL_DRAW_ADDITIVE (1U << 7) #define TOUCH_FL_STROKE (1U << 8) -#define TOUCH_FL_PRECISION (1U << 9) +#define TOUCH_FL_PRECISION (1U << 9) typedef struct mobile_engfuncs_s { @@ -65,13 +65,21 @@ typedef struct mobile_engfuncs_s void (*pfnTouchSetClientOnly)( unsigned char state ); // Clean defaults list - void (*pfnTouchResetDefaultButtons)(); + void (*pfnTouchResetDefaultButtons)( void ); + // Draw scaled font for client + int (*pfnDrawScaledCharacter)( int x, int y, int number, int r, int g, int b, float scale ); + + void (*pfnSys_Warn)( const char *format, ... ); + + // Get native object for current platform. + // Pass NULL to arguments to receive an array of available objects or NULL if nothing + void *(*pfnGetNativeObject)( const char *obj ); + + void (*pfnSetCustomClientID)( const char *id ); // To be continued... } mobile_engfuncs_t; -extern mobile_engfuncs_t *gMobileEngfuncs; - // function exported from client // returns 0 on no error otherwise error typedef int (*pfnMobilityInterface)( mobile_engfuncs_t *gMobileEngfuncs ); From cec6d7a1bc6383a81cdbb7622e6e4a1ec9ec1b07 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:56:01 +0300 Subject: [PATCH 25/36] Add HUD_MessageBox. Rename isXashFWGS to IsXashFWGS --- cl_dll/cdll_int.cpp | 17 ++++++++++++++++- cl_dll/cl_util.h | 3 ++- cl_dll/hud_redraw.cpp | 2 +- cl_dll/input_mouse.cpp | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index fec09792..dc9199ba 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -376,7 +376,22 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) gMobileEngfuncs = gpMobileEngfuncs; } -bool isXashFWGS() +bool HUD_MessageBox( const char *msg ) +{ + gEngfuncs.Con_Printf( msg ); // just in case + + if( IsXashFWGS() ) + { + gMobileEngfuncs->pfnSys_Warn( msg ); + return true; + } + + // TODO: Load SDL2 and call ShowSimpleMessageBox + + return false; +} + +bool IsXashFWGS() { return gMobileEngfuncs != NULL; } diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 23f12230..0cb65f32 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -181,5 +181,6 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ HSPRITE LoadSprite( const char *pszName ); -bool isXashFWGS(); +bool HUD_MessageBox( const char *msg ); +bool IsXashFWGS(); #endif diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 06b25a33..4a46a519 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -235,7 +235,7 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { - if (isXashFWGS()) + if (IsXashFWGS()) { // xash3d: reset unicode state gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 8d57091b..3233d797 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -69,7 +69,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { #ifdef SUPPORT_GOLDSOURCE_INPUT - if (isXashFWGS()) { + if (IsXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; } else { From 6e5062b39e2118ccb967015265ce81df57dd1e08 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:56:26 +0300 Subject: [PATCH 26/36] Check for bad game data(missing or invalid hud.txt) --- cl_dll/hud.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 3ef72889..62c32b41 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -381,6 +381,18 @@ void CHud::VidInit( void ) // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); + if( m_HUD_number_0 == -1 ) + { + const char *msg = "There is something wrong with your game data! Please, reinstall\n"; + + if( HUD_MessageBox( msg ) ) + { + gEngfuncs.pfnClientCmd( "quit\n" ); + } + + return; + } + m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); From 71f55bb119c7ec4d0c5dd6dc0c29dee5aa9bcda7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 3 Apr 2018 21:39:07 +0300 Subject: [PATCH 27/36] Add mingw support to CMakeLists.txt. Add crosscompiling instructions to README.md --- CMakeLists.txt | 5 +++++ README.md | 8 ++++++++ cl_dll/CMakeLists.txt | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7fe664..64c48928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,11 @@ else() message(STATUS "Building for 32 Bit") endif() +if (MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias") +endif() + # add_compile_options for older cmake versions if(${CMAKE_VERSION} VERSION_LESS "3.0.2") macro(add_compile_options) diff --git a/README.md b/README.md index a57d94b5..be0a5fa8 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. cmake ../ make +Crosscompiling using mingw: + + mkdir build-mingw && cd build-mingw + TOOLCHAIN_PREFIX=i686-w64-mingw32 # check up the actual mingw prefix of your mingw installation + cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="$TOOLCHAIN_PREFIX-gcc" -DCMAKE_CXX_COMPILER="$TOOLCHAIN_PREFIX-g++" + You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory. See below if you want to build the GoldSource compatible libraries. @@ -68,6 +74,8 @@ or when using make without cmake: Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. +Note for **Windows**: it's not possible to create GoldSource compatible libraries using mingw, only msvc builds will work. + Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work). If your Linux distribution does not provide compatible g++ version you have several options. diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index b848aa6c..323d156f 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -32,7 +32,10 @@ if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems - add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp) + if(NOT MINGW) + add_definitions(-D_snprintf=snprintf -D_vsnprintf=vsnprintf) + endif() else() add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() From d112f720ad305db4266fc39ed89add34d575ec92 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 3 Apr 2018 23:17:56 +0300 Subject: [PATCH 28/36] Test building with mingw on travis --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e165b81..fecd6f5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,9 @@ os: sudo: true before_script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi script: - mkdir -p build && cd build - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * + - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++; make -j3; fi From ec6afbe86d311a4679c282611efd53b0aea53d5a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 4 Apr 2018 17:30:53 +0300 Subject: [PATCH 29/36] Fix addressing variables in travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fecd6f5b..01d2ba27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,9 @@ os: sudo: true before_script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi script: - mkdir -p build && cd build - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * - - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++; make -j3; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ && make -j3; fi From d17387c61ffe0a81b2ae6c6737bc7f08d7040ab3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 7 Apr 2018 04:21:16 +0300 Subject: [PATCH 30/36] Some fixes for PM_InitTextureTypes() from ReGameDLL_CS --- pm_shared/pm_shared.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index abe7b317..ace56595 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -168,24 +168,23 @@ void PM_InitTextureTypes() char buffer[512]; int i, j; byte *pMemFile; - int fileSize, filePos; + int fileSize, filePos = 0; static qboolean bTextureTypeInit = false; if( bTextureTypeInit ) return; - memset(&( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); + memset(&( grgszTextureName[0][0] ), 0, sizeof( grgszTextureName ) ); + memset( grgchTextureType, 0, sizeof( grgchTextureType ) ); gcTextures = 0; - fileSize = pmove->COM_FileSize( "sound/materials.txt" ); - pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); + pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, &fileSize ); if( !pMemFile ) return; - memset( buffer, 0, 512 ); - filePos = 0; + memset( buffer, 0, sizeof( buffer ) ); + // for each line in the file... while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) ) { From 3d7e2b0d933a5d27aed69f77e90f19e7c946728f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 8 Apr 2018 03:25:13 +0500 Subject: [PATCH 31/36] Do not show flashlight sprite in spectator mode. --- cl_dll/flashlight.cpp | 3 +++ dlls/player.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index c3514c7d..ee3d6d22 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -108,6 +108,9 @@ int CHudFlashlight::Draw( float flTime ) int r, g, b, x, y, a; wrect_t rc; + if( gEngfuncs.IsSpectateOnly() ) + return 1; + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return 1; diff --git a/dlls/player.cpp b/dlls/player.cpp index b1d28e67..926bf1e1 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1421,7 +1421,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) MESSAGE_END(); // Setup flags - m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_WEAPONS ); + m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_FLASHLIGHT | HIDEHUD_WEAPONS ); m_afPhysicsFlags |= PFLAG_OBSERVER; pev->effects = EF_NODRAW; pev->view_ofs = g_vecZero; From 75bc5105e786fef7ad865fee5226fbf88906541a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 8 Apr 2018 19:59:11 +0300 Subject: [PATCH 32/36] Remove old TEXTURETYPE code --- dlls/sound.cpp | 84 ++------------------------------------------------ dlls/world.cpp | 3 -- 2 files changed, 3 insertions(+), 84 deletions(-) diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 31d0b7aa..30c44326 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1454,14 +1454,6 @@ void EMIT_GROUPNAME_SUIT( edict_t *entity, const char *groupname ) // texture name to a material type. Play footstep sound based // on material type. -int fTextureTypeInit = FALSE; - -#define CTEXTURESMAX 512 // max number of textures loaded - -int gcTextures = 0; -char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; // texture names -char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types - // open materials.txt, get size, alloc space, // save in array. Only works first time called, // ignored on subsequent calls. @@ -1513,87 +1505,17 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer return NULL; } -void TEXTURETYPE_Init() -{ - char buffer[512]; - int i, j; - byte *pMemFile; - int fileSize, filePos = 0; - - if( fTextureTypeInit ) - return; - - memset( &( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); - - gcTextures = 0; - - pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); - if( !pMemFile ) - return; - - memset( buffer, 0, 512 ); - // for each line in the file... - while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) - { - // skip whitespace - i = 0; - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // skip comment lines - if( buffer[i] == '/' || !isalpha( buffer[i] ) ) - continue; - - // get texture type - grgchTextureType[gcTextures] = toupper( buffer[i++] ); - - // skip whitespace - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // get sentence name - j = i; - while( buffer[j] && !isspace( buffer[j] ) ) - j++; - - if( !buffer[j] ) - continue; - - // null-terminate name and save in sentences array - j = Q_min( j, CBTEXTURENAMEMAX - 1 + i ); - buffer[j] = 0; - strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); - } - - g_engfuncs.pfnFreeFile( pMemFile ); - - fTextureTypeInit = TRUE; -} - // given texture name, find texture type // if not found, return type 'concrete' // NOTE: this routine should ONLY be called if the // current texture under the player changes! +extern "C" char PM_FindTextureType( char *name ); + char TEXTURETYPE_Find( char *name ) { - // CONSIDER: pre-sort texture names and perform faster binary search here - - for( int i = 0; i < gcTextures; i++ ) - { - if( !strnicmp( name, &( grgszTextureName[i][0] ), CBTEXTURENAMEMAX - 1 ) ) - return grgchTextureType[i]; - } - - return CHAR_TEX_CONCRETE; + return PM_FindTextureType(name); } // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the diff --git a/dlls/world.cpp b/dlls/world.cpp index 3b9a1f1e..ae5a41bc 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -500,9 +500,6 @@ void CWorld::Precache( void ) // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); - // init texture type array from materials.txt - TEXTURETYPE_Init(); - // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache(); // get weapon precaches From b63c1753a142e98598a86deac9e64276997261c8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 11 Apr 2018 04:48:42 +0500 Subject: [PATCH 33/36] Do not break motd(Revert old changes). --- dlls/multiplay_gamerules.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 7922d413..de91ac6e 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1650,8 +1650,8 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) { // read from the MOTD.txt file int length, char_count = 0; - const char *pFileList; - const char *aFileList = pFileList = (const char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); + char *pFileList; + char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); @@ -1679,10 +1679,10 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) if( char_count < MAX_MOTD_LENGTH ) pFileList = aFileList + char_count; else - pFileList = 0; + *pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); - WRITE_BYTE( pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come + WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); } From 352e52eb0d7eeb3b65191543297d594706456a52 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 8 Jul 2018 15:49:23 +0300 Subject: [PATCH 34/36] Fix #62 ligthting issue. --- dlls/lights.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 1c39266b..13e6d3a9 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -155,10 +155,10 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } else if( j == 4 ) { - v /= 255; - r *= v; - g *= v; - b *= v; + float vf = v / 255.0f; + r *= vf; + g *= vf; + b *= vf; } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling From 65cb1f54f467b225949fab42b75a10a4bd202466 Mon Sep 17 00:00:00 2001 From: Jonathan Poncelet Date: Tue, 7 Aug 2018 08:24:04 +0100 Subject: [PATCH 35/36] Made library functions hidden by default on Mac/Linux This resolves an issue where the server library was calling client library functions in error. --- cl_dll/CMakeLists.txt | 1 + dlls/CMakeLists.txt | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 323d156f..1143eefe 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -31,6 +31,7 @@ add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp) if(NOT MINGW) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 55370eeb..ccaa0279 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -30,13 +30,14 @@ add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() -set (SVDLL_SOURCES +set (SVDLL_SOURCES agrunt.cpp airtank.cpp aflock.cpp @@ -140,7 +141,7 @@ set (SVDLL_SOURCES ../pm_shared/pm_math.c ../pm_shared/pm_shared.c ) - + include_directories (. wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) From b423cac3de4336e47c7379d04652275c5a0bd7c8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 12 Sep 2018 05:05:55 +0500 Subject: [PATCH 36/36] Use CMAKE_C_FLAGS value for C++ compilers. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c48928..918449e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,8 +55,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() set(CMAKE_SIZEOF_VOID_P 4)