Skip to content

Commit

Permalink
Textures are not drawn on some levels. fix #31
Browse files Browse the repository at this point in the history
  • Loading branch information
tx00100xt committed Oct 20, 2023
1 parent 70c4bbe commit 08a2a34
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 9 deletions.
5 changes: 3 additions & 2 deletions SamTFE/Sources/Entities/Common/LightFixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions SamTFE/Sources/Entities/MusicHolder.es
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion SamTFE/Sources/GameMP/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
55 changes: 53 additions & 2 deletions SamTSE/Sources/EntitiesMP/MusicHolder.es
Original file line number Diff line number Diff line change
Expand Up @@ -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"
%}


Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
56 changes: 56 additions & 0 deletions SamTSE/Sources/GameMP/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Base/Profiling.h>
#include <Engine/Base/Statistics.h>
#include <Engine/CurrentVersion.h>
#include <Engine/World/World.h>
#include "Camera.h"
#include "LCDDrawing.h"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08a2a34

Please sign in to comment.