From 08a2a348914e4577547d28abb7e096b44becc889 Mon Sep 17 00:00:00 2001 From: tx00100xt Date: Fri, 20 Oct 2023 22:43:47 +0300 Subject: [PATCH] Textures are not drawn on some levels. fix #31 --- SamTFE/Sources/Entities/Common/LightFixes.h | 5 +- SamTFE/Sources/Entities/MusicHolder.es | 21 ++++++-- SamTFE/Sources/GameMP/Game.cpp | 7 ++- SamTSE/Sources/EntitiesMP/MusicHolder.es | 55 +++++++++++++++++++- SamTSE/Sources/GameMP/Game.cpp | 56 +++++++++++++++++++++ 5 files changed, 135 insertions(+), 9 deletions(-) diff --git a/SamTFE/Sources/Entities/Common/LightFixes.h b/SamTFE/Sources/Entities/Common/LightFixes.h index aa1059cc..4430d6c9 100644 --- a/SamTFE/Sources/Entities/Common/LightFixes.h +++ b/SamTFE/Sources/Entities/Common/LightFixes.h @@ -146,7 +146,7 @@ FLOAT _fKarnakCoordinates[42][3] { }; // Luxor -FLOAT _fLuxorCoordinates[51][3] { +FLOAT _fLuxorCoordinates[52][3] { -85.875f,14.4375f,6.6875f, -75.3125f,14.8125f,-5.0625f, -308.562f,116.312f,-7.8125f, @@ -197,7 +197,8 @@ FLOAT _fLuxorCoordinates[51][3] { 183.875f,113.75f,292.188f, 152.562f,112.5f,291.25f, 124.562f,119.312f,206.875f, -93.1875f,119.812f,206.562f +93.1875f,119.812f,206.562f, +15.0f,14.4375f,-77.1875f // grid texture }; // Sacred Yards diff --git a/SamTFE/Sources/Entities/MusicHolder.es b/SamTFE/Sources/Entities/MusicHolder.es index d45776e6..8a1c395e 100644 --- a/SamTFE/Sources/Entities/MusicHolder.es +++ b/SamTFE/Sources/Entities/MusicHolder.es @@ -108,7 +108,7 @@ properties: components: 1 model MODEL_MARKER "Models\\Editor\\MusicHolder.mdl", 2 texture TEXTURE_MARKER "Models\\Editor\\MusicHolder.tex", - 3 class CLASS_LIGHT "Classes\\Light.ecl", + 3 class CLASS_LIGHT "Classes\\Light.ecl" functions: @@ -264,7 +264,7 @@ functions: ((CLight&)*pen).m_colColor = C_GRAY; ((CLight&)*pen).m_ltType = LT_POINT; ((CLight&)*pen).m_bDarkLight = TRUE; - ((CLight&)*pen).m_rFallOffRange = 8.0f; + ((CLight&)*pen).m_rFallOffRange = 4.0f; ((CLight&)*pen).m_strName = "fix_texture"; pen->en_ulSpawnFlags =0xFFFFFFFF; pen->Reinitialize(); @@ -290,6 +290,19 @@ functions: pen->en_ulSpawnFlags =0xFFFFFFFF; pen->Reinitialize(); } + FLOAT m_fCoord1 = _fLuxorCoordinates[51][0]; + FLOAT m_fCoord2 = _fLuxorCoordinates[51][1]; + FLOAT m_fCoord3 = _fLuxorCoordinates[51][2]; + pl = CPlacement3D(FLOAT3D(m_fCoord1, m_fCoord2, m_fCoord3), ANGLE3D(0, 0, 0)); + pen = CreateEntity(pl, CLASS_LIGHT); + pen->Initialize(); + ((CLight&)*pen).m_colColor = C_GRAY; + ((CLight&)*pen).m_ltType = LT_POINT; + ((CLight&)*pen).m_bDarkLight = TRUE; + ((CLight&)*pen).m_rFallOffRange = 1.0f; + ((CLight&)*pen).m_strName = "fix_texture"; + pen->en_ulSpawnFlags =0xFFFFFFFF; + pen->Reinitialize(); } void FixTexturesSacredYards(void) @@ -343,7 +356,7 @@ functions: ((CLight&)*pen).m_colColor = C_GRAY; ((CLight&)*pen).m_ltType = LT_POINT; ((CLight&)*pen).m_bDarkLight = TRUE; - ((CLight&)*pen).m_rFallOffRange = 8.0f; + ((CLight&)*pen).m_rFallOffRange = 4.0f; ((CLight&)*pen).m_strName = "fix_texture"; pen->en_ulSpawnFlags =0xFFFFFFFF; pen->Reinitialize(); @@ -662,7 +675,7 @@ procedures: FixTexturesAlleyOfSphinxes(); } else if ( strModName=="" && strLevelName=="12_Karnak") { FixTexturesKarnak(); - } else if ( strModName=="" && strLevelName=="13_Luxor") { + } else if ( /* strModName=="" && */ strLevelName=="13_Luxor") { FixTexturesLuxor(); } else if ( strModName=="" && strLevelName=="14_SacredYards") { FixTexturesSacredYards(); diff --git a/SamTFE/Sources/GameMP/Game.cpp b/SamTFE/Sources/GameMP/Game.cpp index 36950216..19cc9e1d 100644 --- a/SamTFE/Sources/GameMP/Game.cpp +++ b/SamTFE/Sources/GameMP/Game.cpp @@ -298,6 +298,11 @@ void _FixTexturesLuxor(void) pl = CPlacement3D(FLOAT3D(m_fCoord1, m_fCoord2, m_fCoord3), ANGLE3D(0, 0, 0)); _CreateLights(pl, 8.0f); } + FLOAT m_fCoord1 = _fLuxorCoordinates[51][0]; + FLOAT m_fCoord2 = _fLuxorCoordinates[51][1]; + FLOAT m_fCoord3 = _fLuxorCoordinates[51][2]; + pl = CPlacement3D(FLOAT3D(m_fCoord1, m_fCoord2, m_fCoord3), ANGLE3D(0, 0, 0)); + _CreateLights(pl, 1.0f); } void _FixTexturesSacredYards(void) @@ -450,7 +455,7 @@ void MaybeDiscardLastLines(void) _FixTexturesAlleyOfSphinxes(); } else if ( strModName=="" && strLevelName=="12_Karnak") { _FixTexturesKarnak(); - } else if ( strModName=="" && strLevelName=="13_Luxor") { + } else if (/* strModName=="" && */ strLevelName=="13_Luxor") { _FixTexturesLuxor(); } else if ( strModName=="" && strLevelName=="14_SacredYards") { _FixTexturesSacredYards(); diff --git a/SamTSE/Sources/EntitiesMP/MusicHolder.es b/SamTSE/Sources/EntitiesMP/MusicHolder.es index 35f93801..77dc51aa 100644 --- a/SamTSE/Sources/EntitiesMP/MusicHolder.es +++ b/SamTSE/Sources/EntitiesMP/MusicHolder.es @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "EntitiesMP/EnemySpawner.h" #include "EntitiesMP/Trigger.h" #include "EntitiesMP/Woman.h" +#include "EntitiesMP/Light.h" %} @@ -122,10 +123,51 @@ properties: components: 1 model MODEL_MARKER "Models\\Editor\\MusicHolder.mdl", - 2 texture TEXTURE_MARKER "Models\\Editor\\MusicHolder.tex" - + 2 texture TEXTURE_MARKER "Models\\Editor\\MusicHolder.tex", + 3 class CLASS_LIGHT "Classes\\Light.ecl" functions: + + //*************************************************************** + //**************** Fix Textures on some levels **************** + //*************************************************************** + + // Clear Lights + void ClearLights(void) + { + {FOREACHINDYNAMICCONTAINER(_pNetwork->ga_World.wo_cenEntities, CEntity, pen) { + if(IsDerivedFromClass(pen, "Light")) { + if(((CLight&)*pen).m_strName == "fix_texture"){ + pen->Destroy(); + } + } + }} + } + + // Fix textures + void FixTexturesLandOfDamned(void) + { + ClearLights(); + CEntity *pen = NULL; + CPlacement3D pl; + for(int i = 0; i < 4; i++) { + pl = CPlacement3D(FLOAT3D(7.0f, 63.0f, -268.0f), ANGLE3D(0, 0, 0)); + pen = CreateEntity(pl, CLASS_LIGHT); + pen->Initialize(); + ((CLight&)*pen).m_colColor = C_GRAY; + ((CLight&)*pen).m_ltType = LT_POINT; + ((CLight&)*pen).m_bDarkLight = TRUE; + ((CLight&)*pen).m_rFallOffRange = 8.0f; + ((CLight&)*pen).m_strName = "fix_texture"; + pen->en_ulSpawnFlags =0xFFFFFFFF; + pen->Reinitialize(); + } + } + + //*************************************************************** + //*************************************************************** + //*************************************************************** + // count enemies in current world void CountEnemies(void) { @@ -321,6 +363,15 @@ procedures: // wait for game to start autowait(_pTimer->TickQuantum); + // Get Level Name and Mod Name + CTString strLevelName = _pNetwork->ga_fnmWorld.FileName(); + CTString strModName = _pShell->GetValue("sys_strModName"); + + // Fix textures + if ( /* strModName=="" && */ strLevelName=="3_2_LandOfDamned") { + FixTexturesLandOfDamned(); + } + // prepare initial music channel values ChangeMusicChannel(MT_LIGHT, m_fnMusic0, m_fVolume0); ChangeMusicChannel(MT_MEDIUM, m_fnMusic1, m_fVolume1); diff --git a/SamTSE/Sources/GameMP/Game.cpp b/SamTSE/Sources/GameMP/Game.cpp index bf8caf28..f5b0fcb6 100644 --- a/SamTSE/Sources/GameMP/Game.cpp +++ b/SamTSE/Sources/GameMP/Game.cpp @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include "Camera.h" #include "LCDDrawing.h" @@ -170,9 +171,64 @@ static FLOAT gam_fChatSoundVolume = 0.25f; BOOL map_bIsFirstEncounter = FALSE; BOOL _bUserBreakEnabled = FALSE; +//*************************************************************** +//**************** Fix Textures on some levels **************** +//*************************************************************** + +#ifndef DECL_DLL +#define DECL_DLL ENGINE_API +#endif +#include "EntitiesMP/Light.h" +#undef DECL_DLL + +void _ClearLights(void) +{ + {FOREACHINDYNAMICCONTAINER(_pNetwork->ga_World.wo_cenEntities, CEntity, pen) { + if(IsDerivedFromClass(pen, "Light")) { + if(((CLight&)*pen).m_strName == "fix_texture"){ + pen->Destroy(); + } + } + }} +} + +void _CreateLights(CPlacement3D pl, FLOAT _fFallOffRange) +{ + CEntity *pen = NULL; + pen = _pNetwork->ga_World.CreateEntity_t(pl, CTFILENAME("Classes\\Light.ecl")); + pen->Initialize(); + ((CLight&)*pen).m_colColor = C_GRAY; + ((CLight&)*pen).m_ltType = LT_POINT; + ((CLight&)*pen).m_bDarkLight = TRUE; + ((CLight&)*pen).m_rFallOffRange = _fFallOffRange; + ((CLight&)*pen).m_strName = "fix_texture"; + pen->en_ulSpawnFlags =0xFFFFFFFF; + pen->Reinitialize(); +} + +void _FixTexturesLandOfDamned(void) +{ + _ClearLights(); + CPlacement3D pl; + pl = CPlacement3D(FLOAT3D(7.0f, 63.0f, -268.0f), ANGLE3D(0, 0, 0)); + _CreateLights(pl, 8.0f); +} +//*************************************************************** +//*************************************************************** +//*************************************************************** + // make sure that console doesn't show last lines if not playing in network void MaybeDiscardLastLines(void) { + // Get Level Name and Mod Name + CTString strLevelName = _pNetwork->ga_fnmWorld.FileName(); + CTString strModName = _pShell->GetValue("sys_strModName"); + + // Fix textures + if ( /* strModName==" && */ strLevelName=="3_2_LandOfDamned") { + _FixTexturesLandOfDamned(); + } + // if not in network if (!_pNetwork->IsNetworkEnabled()) { // don't show last lines on screen after exiting console