From fdc880671fd0b7225a332717fdaafc835f285878 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 12:29:43 +0300 Subject: [PATCH 1/7] Sanity: initialize renderer list in the main thread It turned out that it crashes sometimes on some systems. (two users with AMD CPU and Nvidia RTX GPU reported the same crash) This reverts commit 5673c5568b54c175371d83771a6bc2fdf86192e4 --- src/xrEngine/Engine.cpp | 1 + src/xrEngine/EngineAPI.h | 2 +- src/xrEngine/x_ray.cpp | 12 ------------ 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/xrEngine/Engine.cpp b/src/xrEngine/Engine.cpp index 277b90bba4c..85db38de84e 100644 --- a/src/xrEngine/Engine.cpp +++ b/src/xrEngine/Engine.cpp @@ -75,6 +75,7 @@ void CEngine::Initialize(GameModule* game) Device.seqFrame.Add(&g_sound_processor, REG_PRIORITY_NORMAL - 1000); // Place it after Level update Device.seqFrameMT.Add(&g_sound_renderer); + External.CreateRendererList(); CheckAndSetupRenderer(); External.Initialize(game); diff --git a/src/xrEngine/EngineAPI.h b/src/xrEngine/EngineAPI.h index d3e6416a9a5..09e79f5ae90 100644 --- a/src/xrEngine/EngineAPI.h +++ b/src/xrEngine/EngineAPI.h @@ -76,7 +76,7 @@ class ENGINE_API CEngineAPI CEngineAPI(); ~CEngineAPI(); - void CreateRendererList(); + void CreateRendererList(); // Better to call it in the main thread void Initialize(GameModule* game); void Destroy(); }; diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index 6234230f59b..0396687ee35 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -240,13 +240,6 @@ CApplication::CApplication(pcstr commandLine, GameModule* game) Engine.Sound.CreateDevicesList(); }); -#ifdef XR_PLATFORM_WINDOWS - const auto& createRendererList = TaskManager::AddTask([] - { - Engine.External.CreateRendererList(); - }); -#endif - pcstr fsltx = "-fsltx "; string_path fsgame = ""; if (strstr(commandLine, fsltx)) @@ -270,11 +263,6 @@ CApplication::CApplication(pcstr commandLine, GameModule* game) TaskScheduler->Wait(inputTask); InitConsole(); -#ifdef XR_PLATFORM_WINDOWS - TaskScheduler->Wait(createRendererList); -#else - Engine.External.CreateRendererList(); -#endif Engine.Initialize(game); Device.Initialize(); From 03d5924b42298d3266be06e2159024edf6c1eac6 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 19:01:00 +0300 Subject: [PATCH 2/7] xrGame/HudSound.cpp: don't crash when hud sound section doesn't exist in the config It wasn't crashing in vanilla. Related to #1678 --- src/xrGame/HudSound.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/xrGame/HudSound.cpp b/src/xrGame/HudSound.cpp index a3656c11e21..3015ce4d99a 100644 --- a/src/xrGame/HudSound.cpp +++ b/src/xrGame/HudSound.cpp @@ -236,12 +236,12 @@ void HUD_SOUND_COLLECTION_LAYERED::LoadSound(pcstr section, pcstr line, pcstr al { ZoneScoped; + if (!pSettings->line_exist(section, line)) + return; + pcstr str = pSettings->r_string(section, line); string256 buf_str; - int count = _GetItemCount(str); - R_ASSERT(count); - _GetItem(str, 0, buf_str); if (pSettings->section_exist(buf_str)) @@ -271,12 +271,12 @@ void HUD_SOUND_COLLECTION_LAYERED::LoadSound(CInifile const *ini, pcstr section, { ZoneScoped; + if (!pSettings->line_exist(section, line)) + return; + pcstr str = ini->r_string(section, line); string256 buf_str; - int count = _GetItemCount(str); - R_ASSERT(count); - _GetItem(str, 0, buf_str); if (ini->section_exist(buf_str)) From 61f71e8724bc03e119459737be870562991e90b1 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 19:45:33 +0300 Subject: [PATCH 3/7] Use snd_shoot when snd_silncer_shot doesn't exist in weapon config This is for compatibility with Clear Sky (#382), closes #1678. --- src/xrGame/WeaponMagazined.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/xrGame/WeaponMagazined.cpp b/src/xrGame/WeaponMagazined.cpp index 8686e63552e..61cfcf36730 100644 --- a/src/xrGame/WeaponMagazined.cpp +++ b/src/xrGame/WeaponMagazined.cpp @@ -86,8 +86,6 @@ void CWeaponMagazined::Load(LPCSTR section) if (WeaponSoundExist(section, "snd_reload_misfire")) m_sounds.LoadSound(section, "snd_reload_misfire", "sndReloadMisfire", true, m_eSoundReloadMisfire); - m_sSndShotCurrent = IsSilencerAttached() ? "sndSilencerShot" : "sndShot"; - //звуки и партиклы глушителя, если такой есть if (m_eSilencerStatus == ALife::eAddonAttachable || m_eSilencerStatus == ALife::eAddonPermanent) { @@ -101,6 +99,11 @@ void CWeaponMagazined::Load(LPCSTR section) //-Alundaio } + if (IsSilencerAttached() && m_layered_sounds.FindSoundItem("sndSilencerShot", false)) + m_sSndShotCurrent = "sndSilencerShot"; + else + m_sSndShotCurrent = "sndShot"; + m_iBaseDispersionedBulletsCount = READ_IF_EXISTS(pSettings, r_u8, section, "base_dispersioned_bullets_count", 0); m_fBaseDispersionedBulletsSpeed = READ_IF_EXISTS(pSettings, r_float, section, "base_dispersioned_bullets_speed", m_fStartBulletSpeed); @@ -1064,7 +1067,9 @@ void CWeaponMagazined::InitAddons() } } - if (IsSilencerAttached() /* && SilencerAttachable() */) + const bool silencer = IsSilencerAttached(); + + if (silencer && m_layered_sounds.FindSoundItem("sndSilencerShot", false)) { m_sFlameParticlesCurrent = m_sSilencerFlameParticles; m_sSmokeParticlesCurrent = m_sSilencerSmokeParticles; @@ -1072,7 +1077,6 @@ void CWeaponMagazined::InitAddons() //подсветка от выстрела LoadLights(*cNameSect(), "silencer_"); - ApplySilencerKoeffs(); } else { @@ -1082,9 +1086,13 @@ void CWeaponMagazined::InitAddons() //подсветка от выстрела LoadLights(*cNameSect(), ""); - ResetSilencerKoeffs(); } + if (silencer) + ApplySilencerKoeffs(); + else + ResetSilencerKoeffs(); + inherited::InitAddons(); } From f892cd9366f1bebe7121e340919a7c9b5f83f077 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 15:15:52 +0300 Subject: [PATCH 4/7] Fix some animations from scripts don't work properly in CS and SOC (#382, #392) Also returned VERIFY instead of message to the log. Logging is MUCH more annoying and drops FPS. --- src/xrGame/script_game_object3.cpp | 41 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/xrGame/script_game_object3.cpp b/src/xrGame/script_game_object3.cpp index 6f7c7904f26..8d55675619b 100644 --- a/src/xrGame/script_game_object3.cpp +++ b/src/xrGame/script_game_object3.cpp @@ -592,7 +592,7 @@ void CScriptGameObject::set_desired_direction(const Fvector* desired_direction) if (fsimilar(desired_direction->magnitude(), 0.f)) GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CAI_Stalker : [%s] set_desired_direction - you passed zero direction!", stalker->cName().c_str()); - else if (!ClearSkyMode && !ShadowOfChernobylMode) + else if (!ShadowOfChernobylMode) { if (!fsimilar(desired_direction->magnitude(), 1.f)) GEnv.ScriptEngine->script_log(LuaMessageType::Error, @@ -601,7 +601,7 @@ void CScriptGameObject::set_desired_direction(const Fvector* desired_direction) } Fvector direction = *desired_direction; - if (!ClearSkyMode && !ShadowOfChernobylMode) + if (!ShadowOfChernobylMode) direction.normalize_safe(); stalker->movement().set_desired_direction(&direction); } @@ -767,12 +767,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector* } else { - if ((sight_type == SightManager::eSightTypeDirection) && vector3d && (_abs(vector3d->magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && vector3d && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d)); -#endif - vector3d->normalize(); + if (_abs(vector3d->magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d))); + vector3d->normalize(); + } } stalker->sight().setup(sight_type, vector3d); @@ -798,12 +801,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector& } else { - if ((sight_type == SightManager::eSightTypeDirection) && (_abs(vector3d.magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d)); -#endif + if (_abs(vector3d.magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d))); vector3d.normalize(); + } } stalker->sight().setup(sight_type, vector3d, torso_look); @@ -819,12 +825,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector* } else { - if ((sight_type == SightManager::eSightTypeDirection) && vector3d && (_abs(vector3d->magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && vector3d && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d)); -#endif - vector3d->normalize(); + if (_abs(vector3d->magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d))); + vector3d->normalize(); + } } stalker->sight().setup(sight_type, vector3d); From 33cf4c958ee94139cfc268c5cdb22833e1734e8c Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 27 Dec 2024 21:29:34 +0300 Subject: [PATCH 5/7] Add keys and actions for PDA tab (CoC 1.5r7 support, #1529) (#1541) --- src/xrEngine/key_binding_registrator_script.cpp | 7 +++++++ src/xrEngine/xr_level_controller.cpp | 7 +++++++ src/xrEngine/xr_level_controller.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/src/xrEngine/key_binding_registrator_script.cpp b/src/xrEngine/key_binding_registrator_script.cpp index 7291cfdb9ff..fa04ac58c2d 100644 --- a/src/xrEngine/key_binding_registrator_script.cpp +++ b/src/xrEngine/key_binding_registrator_script.cpp @@ -146,6 +146,13 @@ SCRIPT_EXPORT(KeyBindings, (), value("kCUSTOM14", int(kCUSTOM14)), value("kCUSTOM15", int(kCUSTOM15)), + value("kPDA_TAB1", int(kPDA_TAB1)), + value("kPDA_TAB2", int(kPDA_TAB2)), + value("kPDA_TAB3", int(kPDA_TAB3)), + value("kPDA_TAB4", int(kPDA_TAB4)), + value("kPDA_TAB5", int(kPDA_TAB5)), + value("kPDA_TAB6", int(kPDA_TAB6)), + value("kKICK", int(kKICK)), value("kEDITOR", int(kEDITOR)), diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index ac5cb441f74..be4107d8341 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -143,6 +143,13 @@ game_action actions[] = { "custom14", kCUSTOM14, _sp }, { "custom15", kCUSTOM15, _sp }, + { "pda_tab1", kPDA_TAB1, _sp }, + { "pda_tab2", kPDA_TAB2, _sp }, + { "pda_tab3", kPDA_TAB3, _sp }, + { "pda_tab4", kPDA_TAB4, _sp }, + { "pda_tab5", kPDA_TAB5, _sp }, + { "pda_tab6", kPDA_TAB6, _sp }, + { "kick", kKICK, _sp }, { "editor", kEDITOR, _both }, diff --git a/src/xrEngine/xr_level_controller.h b/src/xrEngine/xr_level_controller.h index d0f291682b6..5d38037391e 100644 --- a/src/xrEngine/xr_level_controller.h +++ b/src/xrEngine/xr_level_controller.h @@ -124,6 +124,13 @@ enum EGameActions : u32 kCUSTOM14, kCUSTOM15, + kPDA_TAB1, + kPDA_TAB2, + kPDA_TAB3, + kPDA_TAB4, + kPDA_TAB5, + kPDA_TAB6, + kKICK, // alpet: kick dynamic objects kEDITOR, From 6adea8e1466b3409475cb9c500795833d8b65972 Mon Sep 17 00:00:00 2001 From: Syrotenko Igor Date: Fri, 27 Dec 2024 20:37:03 +0200 Subject: [PATCH 6/7] [FEATURE] Add gamedata as lua modules root. (#1610) --- src/xrScriptEngine/script_engine.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/xrScriptEngine/script_engine.cpp b/src/xrScriptEngine/script_engine.cpp index fdd90fc82d5..e5d725a0f0d 100644 --- a/src/xrScriptEngine/script_engine.cpp +++ b/src/xrScriptEngine/script_engine.cpp @@ -1004,6 +1004,21 @@ void CScriptEngine::init(ExporterFunc exporterFunc, bool loadGlobalNamespace) luaL_dostring(lua(), mathRandom); } + // Adds gamedata folder as module root for lua `require` and allows usage of built-in lua module system. + // Notes: + // - Does not resolve files inside archived game files + // Example: + // `local example = require("scripts.folder.file")` tries to import `gamedata\scripts\folder\file.script` + { + string_path gamedataPath; + string_path packagePath; + + FS.update_path(gamedataPath, "$game_data$", "?.script;"); + xr_sprintf(packagePath, "package.path = package.path .. [[%s]]", gamedataPath); + + luaL_dostring(lua(), packagePath); + } + // XXX nitrocaster: with vanilla scripts, '-nojit' option requires script profiler to be disabled. The reason // is that lua hooks somehow make 'super' global unavailable (is's used all over the vanilla scripts). // You can disable script profiler by commenting out the following lines in the beginning of _g.script: From 94b1f25a64725c64f5c603693922a879b18383c6 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 22:26:21 +0300 Subject: [PATCH 7/7] xrGame/quadtree.h: replace VERIFY with R_ASSERT1_CURE (#1440) --- src/xrGame/quadtree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xrGame/quadtree.h b/src/xrGame/quadtree.h index 5d899843b7d..bbf567c0fb9 100644 --- a/src/xrGame/quadtree.h +++ b/src/xrGame/quadtree.h @@ -49,7 +49,7 @@ class CQuadTree virtual ~CFixedStorage() { xr_free(m_objects); } IC T* get_object() { - VERIFY(m_free); + R_ASSERT1_CURE(m_free, { return nullptr; }); T* node = m_free; m_free = m_free->next(); ZeroMemory(node, sizeof(T));