Remove unused globals and move others from control.cpp to needed source files

This commit is contained in:
Lwmte 2021-09-15 21:09:09 +03:00
parent 1195e2077c
commit 42bb372f63
23 changed files with 111 additions and 143 deletions

View file

@ -1448,7 +1448,7 @@ void BinocularCamera(ITEM_INFO* item)
{ {
GetTargetOnLOS(&Camera.pos, &Camera.target, 0, 0); GetTargetOnLOS(&Camera.pos, &Camera.target, 0, 0);
if (!(InputBusy & IN_ACTION) || Infrared) if (!(InputBusy & IN_ACTION))
{ {
// Reimplement this mode? // Reimplement this mode?
} }

View file

@ -6,6 +6,7 @@
#include "camera.h" #include "camera.h"
#include "Lara.h" #include "Lara.h"
#include "effects/hair.h" #include "effects/hair.h"
#include "effects/flmtorch.h"
#include "items.h" #include "items.h"
#include "flipeffect.h" #include "flipeffect.h"
#include "draw.h" #include "draw.h"
@ -60,58 +61,48 @@ using namespace TEN::Renderer;
using namespace TEN::Math::Random; using namespace TEN::Math::Random;
using namespace TEN::Floordata; using namespace TEN::Floordata;
int RumbleTimer = 0; int GameTimer = 0;
int InGameCnt = 0; int RumbleTimer = 0;
bool InItemControlLoop; int InGameCounter = 0;
short GlobalCounter = 0;
int Wibble = 0;
bool InitialiseGame;
bool DoTheGame;
bool JustLoaded;
bool ThreadEnded;
int RequiredStartPos;
int CurrentLevel;
int LevelComplete;
bool InItemControlLoop;
short ItemNewRoomNo; short ItemNewRoomNo;
short ItemNewRooms[512]; short ItemNewRooms[512];
short NextFxActive;
short NextFxFree;
short NextItemActive; short NextItemActive;
short NextItemFree; short NextItemFree;
short NextFxActive;
short NextFxFree;
bool DisableLaraControl = false;
bool OldLaraBusy;
int DisableLaraControl = 0;
int WeatherType; int WeatherType;
int LaraDrawType; int LaraDrawType;
int NumAnimatedTextures;
short *AnimTextureRanges;
int nAnimUVRanges;
int Wibble = 0;
int SetDebounce = 0;
std::string CurrentAtmosphere;
short CurrentRoom;
int GameTimer;
short GlobalCounter;
byte LevelComplete;
#ifndef NEW_INV #ifndef NEW_INV
int LastInventoryItem; int LastInventoryItem;
extern Inventory g_Inventory;
#endif #endif
int TrackCameraInit;
short TorchRoom;
int InitialiseGame;
int RequiredStartPos;
int WeaponDelay; int WeaponDelay;
int WeaponEnemyTimer; int WeaponEnemyTimer;
int CutSeqNum;
int CurrentLevel;
bool DoTheGame;
bool ThreadEnded;
int OnFloor;
int TriggerTimer;
int JustLoaded;
int OldLaraBusy;
int Infrared;
std::vector<short> OutsideRoomTable[OUTSIDE_SIZE][OUTSIDE_SIZE];
short IsRoomOutsideNo; short IsRoomOutsideNo;
std::vector<short> OutsideRoomTable[OUTSIDE_SIZE][OUTSIDE_SIZE];
extern GameFlow *g_GameFlow; extern GameFlow *g_GameFlow;
extern GameScript *g_GameScript; extern GameScript *g_GameScript;
#ifndef NEW_INV
extern Inventory g_Inventory;
#endif
extern int SplashCount;
// This might not be the exact amount of time that has passed, but giving it a // This might not be the exact amount of time that has passed, but giving it a
// value of 1/30 keeps it in lock-step with the rest of the game logic, // value of 1/30 keeps it in lock-step with the rest of the game logic,
@ -290,8 +281,6 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode)
DbInput = 0; DbInput = 0;
} }
} }
Infrared = false;
} }
else if (BinocularRange == 0) else if (BinocularRange == 0)
{ {
@ -304,20 +293,6 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode)
Lara.busy = true; Lara.busy = true;
LaserSight = true; LaserSight = true;
Infrared = true;
}
else
Infrared = false;
}
else
{
if (LaserSight)
{
Infrared = true;
}
else
{
Infrared = false;
} }
} }
} }
@ -599,12 +574,12 @@ GAME_STATUS DoTitle(int index)
InitSpotCamSequences(); InitSpotCamSequences();
InitialiseSpotCam(2); InitialiseSpotCam(2);
CurrentAtmosphere = "083_horus"; CurrentLoopedSoundTrack = "083_horus";
UseSpotCam = true; UseSpotCam = true;
// Play background music // Play background music
//CurrentAtmosphere = ambient; //CurrentLoopedSoundTrack = ambient;
S_CDPlay(CurrentAtmosphere, 1); S_CDPlay(CurrentLoopedSoundTrack, 1);
// Initialise ponytails // Initialise ponytails
InitialiseHair(); InitialiseHair();
@ -753,8 +728,8 @@ GAME_STATUS DoLevel(int index, std::string ambient, bool loadFromSavegame)
InitSpotCamSequences(); InitSpotCamSequences();
// Play background music // Play background music
CurrentAtmosphere = ambient; CurrentLoopedSoundTrack = ambient;
S_CDPlay(CurrentAtmosphere, 1); S_CDPlay(CurrentLoopedSoundTrack, 1);
// Initialise ponytails // Initialise ponytails
InitialiseHair(); InitialiseHair();
@ -1165,7 +1140,7 @@ void RumbleScreen()
{ {
if (!(GetRandomControl() & 0x1FF)) if (!(GetRandomControl() & 0x1FF))
{ {
InGameCnt = 0; InGameCounter = 0;
RumbleTimer = -32 - (GetRandomControl() & 0x1F); RumbleTimer = -32 - (GetRandomControl() & 0x1F);
return; return;
} }
@ -1173,15 +1148,15 @@ void RumbleScreen()
if (RumbleTimer < 0) if (RumbleTimer < 0)
{ {
if (InGameCnt >= abs(RumbleTimer)) if (InGameCounter >= abs(RumbleTimer))
{ {
Camera.bounce = -(GetRandomControl() % abs(RumbleTimer)); Camera.bounce = -(GetRandomControl() % abs(RumbleTimer));
RumbleTimer++; RumbleTimer++;
} }
else else
{ {
InGameCnt++; InGameCounter++;
Camera.bounce = -(GetRandomControl() % InGameCnt); Camera.bounce = -(GetRandomControl() % InGameCounter);
} }
} }
} }
@ -1404,6 +1379,9 @@ int IsRoomOutside(int x, int y, int z)
void ResetGlobals() void ResetGlobals()
{ {
// Reset oscillator seed
Wibble = 0;
// Needs to be cleared or otherwise controls will lockup if user will exit to title // Needs to be cleared or otherwise controls will lockup if user will exit to title
// while playing flyby with locked controls // while playing flyby with locked controls
DisableLaraControl = false; DisableLaraControl = false;

View file

@ -54,37 +54,25 @@ extern short NextFxActive;
extern short NextFxFree; extern short NextFxFree;
extern short NextItemActive; extern short NextItemActive;
extern short NextItemFree; extern short NextItemFree;
extern int DisableLaraControl; extern bool DisableLaraControl;
extern int WeatherType; extern int WeatherType;
extern int LaraDrawType; extern int LaraDrawType;
extern int NumAnimatedTextures;
extern short* AnimTextureRanges;
extern int nAnimUVRanges;
extern int Wibble; extern int Wibble;
extern int SetDebounce;
extern std::string CurrentAtmosphere;
extern short CurrentRoom;
extern int GameTimer; extern int GameTimer;
extern short GlobalCounter; extern short GlobalCounter;
extern byte LevelComplete; extern int LevelComplete;
#ifndef NEW_INV #ifndef NEW_INV
extern int LastInventoryItem; extern int LastInventoryItem;
#endif #endif
extern int TrackCameraInit; extern bool InitialiseGame;
extern short TorchRoom;
extern int InitialiseGame;
extern int RequiredStartPos; extern int RequiredStartPos;
extern int WeaponDelay; extern int WeaponDelay;
extern int WeaponEnemyTimer; extern int WeaponEnemyTimer;
extern int CutSeqNum;
extern int CurrentLevel; extern int CurrentLevel;
extern bool DoTheGame; extern bool DoTheGame;
extern bool ThreadEnded; extern bool ThreadEnded;
extern int OnFloor; extern bool JustLoaded;
extern int TriggerTimer; extern bool OldLaraBusy;
extern int JustLoaded;
extern int OldLaraBusy;
extern int Infrared;
extern std::vector<short> OutsideRoomTable[OUTSIDE_SIZE][OUTSIDE_SIZE]; extern std::vector<short> OutsideRoomTable[OUTSIDE_SIZE][OUTSIDE_SIZE];
extern short IsRoomOutsideNo; extern short IsRoomOutsideNo;

View file

@ -18,6 +18,7 @@
using namespace TEN::Entities::Switches; using namespace TEN::Entities::Switches;
int TriggerTimer;
int KeyTriggerActive; int KeyTriggerActive;
int TriggerActive(ITEM_INFO* item) int TriggerActive(ITEM_INFO* item)

View file

@ -57,6 +57,7 @@ enum TRIGOBJECTS_TYPES
TO_CUTSCENE TO_CUTSCENE
}; };
extern int TriggerTimer;
extern int KeyTriggerActive; extern int KeyTriggerActive;
bool GetKeyTrigger(ITEM_INFO* item); bool GetKeyTrigger(ITEM_INFO* item);

View file

@ -1,16 +1,14 @@
#include "framework.h" #include "framework.h"
#include "effects\flmtorch.h" #include "effects/flmtorch.h"
#include "effects\effects.h" #include "effects/effects.h"
#include "lara_flare.h" #include "lara_flare.h"
#include "lara.h" #include "lara.h"
#include "lara_fire.h"
#include "draw.h" #include "draw.h"
#include "items.h" #include "items.h"
#include "level.h" #include "level.h"
#include "setup.h" #include "setup.h"
#include "input.h" #include "input.h"
#include "Sound\sound.h" #include "Sound/sound.h"
#include "snowmobile.h"
extern OBJECT_COLLISION_BOUNDS FireBounds; extern OBJECT_COLLISION_BOUNDS FireBounds;
@ -163,8 +161,6 @@ void DoFlameTorch()
TriggerTorchFlame(LaraItem - g_Level.Items.data(), 0); TriggerTorchFlame(LaraItem - g_Level.Items.data(), 0);
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, (PHD_3DPOS*)&pos, 0); SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, (PHD_3DPOS*)&pos, 0);
TorchRoom = LaraItem->roomNumber;
} }
} }
@ -242,7 +238,6 @@ void TorchControl(short itemNumber)
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos, 12 - (GetRandomControl() & 1), (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 96, 0); TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos, 12 - (GetRandomControl() & 1), (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 96, 0);
if (!(Wibble & 7)) if (!(Wibble & 7))
TriggerTorchFlame(itemNumber, 1); TriggerTorchFlame(itemNumber, 1);
TorchRoom = item->roomNumber;
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0); SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
} }
} }

View file

@ -1878,8 +1878,8 @@ int Inventory::DoTitleInventory()
UpdateSceneAndDrawInventory(); UpdateSceneAndDrawInventory();
} }
CurrentAtmosphere = CDA_XA11_FLYBY1; CurrentLoopedSoundTrack = CDA_XA11_FLYBY1;
S_CDPlay(CurrentAtmosphere, 1); S_CDPlay(CurrentLoopedSoundTrack, 1);
OpenRing(INV_RING_OPTIONS, true); OpenRing(INV_RING_OPTIONS, true);
@ -1888,7 +1888,6 @@ int Inventory::DoTitleInventory()
while (true /*!ResetFlag*/) while (true /*!ResetFlag*/)
{ {
SetDebounce = true; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = false; SetDebounce = false;
@ -2093,9 +2092,9 @@ int Inventory::DoPassport()
int selectedSavegame = 0; int selectedSavegame = 0;
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)
@ -2165,9 +2164,9 @@ int Inventory::DoPassport()
int selectedSavegame = 0; int selectedSavegame = 0;
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)
@ -2240,9 +2239,9 @@ int Inventory::DoPassport()
int selectedLevel = 0; int selectedLevel = 0;
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)
@ -2309,9 +2308,9 @@ int Inventory::DoPassport()
// New game // New game
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)
@ -2363,9 +2362,9 @@ int Inventory::DoPassport()
// Exit game // Exit game
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)
@ -2417,9 +2416,9 @@ int Inventory::DoPassport()
// Exit game // Exit game
while (true) while (true)
{ {
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
// Process input // Process input
if (DbInput & IN_DESELECT) if (DbInput & IN_DESELECT)

View file

@ -1232,9 +1232,9 @@ int DoPauseMenu()
} }
clear_input_vars(1); clear_input_vars(1);
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
SetDebounce = 0; SetDebounce = false;
do_debounced_input(); do_debounced_input();
if (pause_menu_to_display <= pause_options_menu) if (pause_menu_to_display <= pause_options_menu)
@ -3603,7 +3603,7 @@ int S_CallInventory2()
if (compassNeedleAngle != 1024) if (compassNeedleAngle != 1024)
compassNeedleAngle -= 32; compassNeedleAngle -= 32;
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
TrInput = InputBusy; TrInput = InputBusy;
GameTimer++; GameTimer++;
@ -3646,7 +3646,7 @@ int S_CallInventory2()
/* do /* do
{ {
S_InitialisePolyList(); S_InitialisePolyList();
SetDebounce = 1; SetDebounce = true;
S_UpdateInput(); S_UpdateInput();
input = inputBusy; input = inputBusy;
UpdatePulseColour(); UpdatePulseColour();

View file

@ -7,6 +7,7 @@
#include "spotcam.h" #include "spotcam.h"
#include "traps.h" #include "traps.h"
#include "control/flipmap.h" #include "control/flipmap.h"
#include "sound/sound.h"
#include "level.h" #include "level.h"
#include "setup.h" #include "setup.h"
#include "flipeffect.h" #include "flipeffect.h"
@ -69,7 +70,7 @@ std::unique_ptr<ChunkId> SaveGame::m_chunkExamineCombo;
std::unique_ptr<ChunkId> SaveGame::m_chunkWeaponItem; std::unique_ptr<ChunkId> SaveGame::m_chunkWeaponItem;
SAVEGAME_INFO Savegame; SAVEGAME_INFO Savegame;
//extern vector<AudioTrack> g_AudioTracks; //extern vector<AudioTrack> SoundTracks;
void SaveGame::saveItems() void SaveGame::saveItems()
{ {
@ -181,7 +182,7 @@ void SaveGame::saveGameStatus(int arg1, int arg2)
#endif #endif
LEB128::Write(m_stream, FlipEffect); LEB128::Write(m_stream, FlipEffect);
LEB128::Write(m_stream, FlipTimer); LEB128::Write(m_stream, FlipTimer);
//LEB128::Write(m_stream, CurrentAtmosphere); //LEB128::Write(m_stream, CurrentLoopedSoundTrack);
LEB128::Write(m_stream, CurrentSequence); LEB128::Write(m_stream, CurrentSequence);
// Now the sub-chunks // Now the sub-chunks
@ -195,8 +196,8 @@ void SaveGame::saveGameStatus(int arg1, int arg2)
for (int i = 0; i < NumberSpotcams; i++) for (int i = 0; i < NumberSpotcams; i++)
m_writer->WriteChunk(m_chunkFlybyFlags.get(), &saveFlybyFlags, i, SpotCam[i].flags); m_writer->WriteChunk(m_chunkFlybyFlags.get(), &saveFlybyFlags, i, SpotCam[i].flags);
for (int i = 0; i < g_AudioTracks.size(); i++) for (int i = 0; i < SoundTracks.size(); i++)
m_writer->WriteChunk(m_chunkCdFlags.get(), &saveCdFlags, i, g_AudioTracks[i].Mask); m_writer->WriteChunk(m_chunkCdFlags.get(), &saveCdFlags, i, SoundTracks[i].Mask);
for (int i = 0; i < NumberCameras; i++) for (int i = 0; i < NumberCameras; i++)
m_writer->WriteChunk(m_chunkCamera.get(), &saveCamera, i, FixedCameras[i].flags); m_writer->WriteChunk(m_chunkCamera.get(), &saveCamera, i, FixedCameras[i].flags);
@ -451,7 +452,7 @@ bool SaveGame::readGameStatus()
LastInventoryItem = LEB128::ReadInt32(m_stream); LastInventoryItem = LEB128::ReadInt32(m_stream);
#endif #endif
FlipEffect = LEB128::ReadInt32(m_stream); FlipEffect = LEB128::ReadInt32(m_stream);
CurrentAtmosphere = LEB128::ReadByte(m_stream); CurrentLoopedSoundTrack = LEB128::ReadByte(m_stream);
CurrentSequence = LEB128::ReadByte(m_stream); CurrentSequence = LEB128::ReadByte(m_stream);
m_reader->ReadChunks(&readGameStatusChunks, 0); m_reader->ReadChunks(&readGameStatusChunks, 0);
@ -839,8 +840,8 @@ bool SaveGame::readGameStatusChunks(ChunkId* chunkId, int maxSize, int arg)
short index = LEB128::ReadInt16(m_stream); short index = LEB128::ReadInt16(m_stream);
printf("Index: %d\n", index); printf("Index: %d\n", index);
short value = LEB128::ReadInt16(m_stream); short value = LEB128::ReadInt16(m_stream);
if (index < g_AudioTracks.size()) if (index < SoundTracks.size())
g_AudioTracks[index].Mask = value; SoundTracks[index].Mask = value;
return true; return true;
}*/ }*/
else if (chunkId->EqualsTo(m_chunkCamera.get())) else if (chunkId->EqualsTo(m_chunkCamera.get()))

View file

@ -11,7 +11,7 @@
using namespace TEN::Renderer; using namespace TEN::Renderer;
using namespace TEN::Control::Volumes; using namespace TEN::Control::Volumes;
int TrackCameraInit;
int LastSequence; int LastSequence;
int SpotcamTimer; int SpotcamTimer;
int SpotcamPaused; int SpotcamPaused;
@ -135,7 +135,7 @@ void InitialiseSpotCam(short Sequence)
SpotcamTimer = 0; SpotcamTimer = 0;
SpotcamPaused = 0; SpotcamPaused = 0;
SpotcamLoopCnt = 0; SpotcamLoopCnt = 0;
DisableLaraControl = 0; DisableLaraControl = false;
LastFOV = CurrentFOV; LastFOV = CurrentFOV;
LaraAir = Lara.air; LaraAir = Lara.air;
@ -175,7 +175,7 @@ void InitialiseSpotCam(short Sequence)
if ((s->flags & SCF_DISABLE_LARA_CONTROLS)) if ((s->flags & SCF_DISABLE_LARA_CONTROLS))
{ {
DisableLaraControl = 1; DisableLaraControl = true;
g_Renderer.enableCinematicBars(true); g_Renderer.enableCinematicBars(true);
//SetFadeClip(16, 1); //SetFadeClip(16, 1);
} }
@ -774,7 +774,7 @@ void CalculateSpotCameras()
g_Renderer.enableCinematicBars(false); g_Renderer.enableCinematicBars(false);
UseSpotCam = 0; UseSpotCam = 0;
DisableLaraControl = 0; DisableLaraControl = false;
CheckTrigger = 0; CheckTrigger = 0;
Camera.oldType = FIXED_CAMERA; Camera.oldType = FIXED_CAMERA;
Camera.type = CHASE_CAMERA; Camera.type = CHASE_CAMERA;

View file

@ -56,6 +56,7 @@ extern int NumberSpotcams;
extern int UseSpotCam; extern int UseSpotCam;
extern int SpotcamDontDrawLara; extern int SpotcamDontDrawLara;
extern int SpotcamOverlay; extern int SpotcamOverlay;
extern int TrackCameraInit;
void ClearSpotCamSequences(); void ClearSpotCamSequences();
void InitSpotCamSequences(); void InitSpotCamSequences();

View file

@ -422,7 +422,6 @@ void FallingBlockControl(short itemNumber)
// { // {
// *height = item->pos.yPos; // *height = item->pos.yPos;
// HeightType = WALL; // HeightType = WALL;
// OnFloor = 1;
// } // }
// } // }
//} //}

View file

@ -5,6 +5,7 @@
#include "camera.h" #include "camera.h"
#include "control.h" #include "control.h"
#include "level.h" #include "level.h"
OBJECT_COLLISION_BOUNDS CeilingTrapDoorBounds = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820}; OBJECT_COLLISION_BOUNDS CeilingTrapDoorBounds = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820};
static PHD_VECTOR CeilingTrapDoorPos = {0, 1056, -480}; static PHD_VECTOR CeilingTrapDoorPos = {0, 1056, -480};
OBJECT_COLLISION_BOUNDS FloorTrapDoorBounds = {-256, 256, 0, 0, -1024, -256, -1820, 1820, -5460, 5460, -1820, 1820}; OBJECT_COLLISION_BOUNDS FloorTrapDoorBounds = {-256, 256, 0, 0, -1024, -256, -1820, 1820, -5460, 5460, -1820, 1820};

View file

@ -10,6 +10,8 @@
#include "creature_info.h" #include "creature_info.h"
#include "control.h" #include "control.h"
int CutSeqNum;
BITE_INFO scorpionBite1 = { 0, 0, 0, 8 }; BITE_INFO scorpionBite1 = { 0, 0, 0, 8 };
BITE_INFO scorpionBite2 = { 0, 0, 0, 23 }; BITE_INFO scorpionBite2 = { 0, 0, 0, 23 };

View file

@ -418,7 +418,7 @@ static int JeepCheckGetOff()
LaraItem->pos.zRot = 0; LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
CurrentAtmosphere = 110; CurrentLoopedSoundTrack = 110;
S_CDPlay(110, 1); S_CDPlay(110, 1);
return false; return false;
} }
@ -1606,7 +1606,7 @@ void JeepCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
item->flags |= 0x20; item->flags |= 0x20;
CurrentAtmosphere = 98; CurrentLoopedSoundTrack = 98;
S_CDPlay(98, 1); S_CDPlay(98, 1);
} }
else else

View file

@ -5,6 +5,7 @@
#include "lara.h" #include "lara.h"
#include "draw.h" #include "draw.h"
#include "effects\effects.h" #include "effects\effects.h"
#include "effects\flmtorch.h"
#include "box.h" #include "box.h"
#include "setup.h" #include "setup.h"
#include "level.h" #include "level.h"
@ -251,8 +252,6 @@ void ImpControl(short itemNumber)
case STATE_IMP_SCARED: case STATE_IMP_SCARED:
creature->maximumTurn = ANGLE(7); creature->maximumTurn = ANGLE(7);
if (TorchRoom != 11)
item->goalAnimState = STATE_IMP_STOP;
break; break;
case STATE_IMP_START_CLIMB: case STATE_IMP_START_CLIMB:
@ -298,9 +297,6 @@ void ImpControl(short itemNumber)
} }
} }
if (TorchRoom == 11)
item->goalAnimState = STATE_IMP_SCARED;
CreatureTilt(item, 0); CreatureTilt(item, 0);
CreatureJoint(item, 1, joint1); CreatureJoint(item, 1, joint1);
CreatureJoint(item, 0, joint0); CreatureJoint(item, 0, joint0);

View file

@ -22,7 +22,7 @@ using std::string;
using std::vector; using std::vector;
using std::unordered_map; using std::unordered_map;
extern unordered_map<string, AudioTrack> g_AudioTracks; extern unordered_map<string, AudioTrack> SoundTracks;
GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua } GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
{ {
@ -182,7 +182,7 @@ void GameFlow::SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>
track.Name = t.trackName; track.Name = t.trackName;
track.Mask = 0; track.Mask = 0;
track.looped = t.looped; track.looped = t.looped;
g_AudioTracks.insert_or_assign(track.Name, track); SoundTracks.insert_or_assign(track.Name, track);
} }
} }
@ -238,7 +238,7 @@ bool GameFlow::DoGameflow()
// First we need to fill some legacy variables in PCTomb5.exe // First we need to fill some legacy variables in PCTomb5.exe
GameScriptLevel* level = Levels[CurrentLevel]; GameScriptLevel* level = Levels[CurrentLevel];
CurrentAtmosphere = level->AmbientTrack; CurrentLoopedSoundTrack = level->AmbientTrack;
GAME_STATUS status; GAME_STATUS status;
@ -268,7 +268,7 @@ bool GameFlow::DoGameflow()
} }
} }
status = DoLevel(CurrentLevel, CurrentAtmosphere, loadFromSavegame); status = DoLevel(CurrentLevel, CurrentLoopedSoundTrack, loadFromSavegame);
loadFromSavegame = false; loadFromSavegame = false;
} }

View file

@ -53,8 +53,8 @@ static void PlaySoundEffect(int id, int flags)
static void SetAmbientTrack(std::string const & trackName) static void SetAmbientTrack(std::string const & trackName)
{ {
CurrentAtmosphere = trackName; CurrentLoopedSoundTrack = trackName;
S_CDPlay(CurrentAtmosphere, 1); S_CDPlay(CurrentLoopedSoundTrack, 1);
} }
static int FindRoomNumber(GameScriptPosition pos) static int FindRoomNumber(GameScriptPosition pos)

View file

@ -28,8 +28,8 @@ const BASS_BFX_FREEVERB BASS_ReverbTypes[NUM_REVERB_TYPES] = // Reverb preset
{ 1.0f, 0.25f, 0.90f, 1.00f, 1.0f, 0, -1 } // 4 = Pipe { 1.0f, 0.25f, 0.90f, 1.00f, 1.0f, 0, -1 } // 4 = Pipe
}; };
unordered_map<string, AudioTrack> g_AudioTracks; unordered_map<string, AudioTrack> SoundTracks;
char TrackNamePrefix; std::string CurrentLoopedSoundTrack;
static int GlobalMusicVolume; static int GlobalMusicVolume;
static int GlobalFXVolume; static int GlobalFXVolume;
@ -393,28 +393,28 @@ void S_CDPlayEx(std::string track, DWORD mask, DWORD unknown)
{ {
// Check and modify soundtrack map mask, if needed. // Check and modify soundtrack map mask, if needed.
// If existing mask is unmodified (same activation mask setup), track won't play. // If existing mask is unmodified (same activation mask setup), track won't play.
if (!g_AudioTracks[track].looped) if (!SoundTracks[track].looped)
{ {
byte filteredMask = (mask >> 8) & 0x3F; byte filteredMask = (mask >> 8) & 0x3F;
if ((g_AudioTracks[track].Mask & filteredMask) == filteredMask) if ((SoundTracks[track].Mask & filteredMask) == filteredMask)
return; // Mask is the same, don't play it. return; // Mask is the same, don't play it.
g_AudioTracks[track].Mask |= filteredMask; SoundTracks[track].Mask |= filteredMask;
} }
S_CDPlay(track, g_AudioTracks[track].looped); S_CDPlay(track, SoundTracks[track].looped);
} }
// Legacy! // Legacy!
void S_CDPlay(int index, unsigned int mode) void S_CDPlay(int index, unsigned int mode)
{ {
std::pair<const std::string, AudioTrack>& track = *std::next(g_AudioTracks.begin(), index); std::pair<const std::string, AudioTrack>& track = *std::next(SoundTracks.begin(), index);
S_CDPlay(track.first, mode); S_CDPlay(track.first, mode);
} }
void S_CDPlayEx(int index, DWORD mask, DWORD unknown) void S_CDPlayEx(int index, DWORD mask, DWORD unknown)
{ {
std::pair<const std::string, AudioTrack>& track = *std::next(g_AudioTracks.begin(), index); std::pair<const std::string, AudioTrack>& track = *std::next(SoundTracks.begin(), index);
S_CDPlayEx(track.first, mask, unknown); S_CDPlayEx(track.first, mask, unknown);
} }

View file

@ -114,7 +114,8 @@ struct AudioTrack
bool looped; bool looped;
}; };
extern std::unordered_map<std::string, AudioTrack> g_AudioTracks; extern std::unordered_map<std::string, AudioTrack> SoundTracks;
extern std::string CurrentLoopedSoundTrack;
long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags); long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags);
void StopSoundEffect(short effectID); void StopSoundEffect(short effectID);

View file

@ -53,10 +53,12 @@ const char* g_KeyNames[] = {
int TrInput; int TrInput;
int DbInput; int DbInput;
int InputBusy; int InputBusy;
bool SetDebounce = false;
short MouseX; short MouseX;
short MouseY; short MouseY;
int MouseKeys; int MouseKeys;
byte KeyMap[256]; byte KeyMap[256];
int ConflictingKeys[18]; int ConflictingKeys[18];
short KeyboardLayout[2][18] = short KeyboardLayout[2][18] =
@ -64,6 +66,7 @@ short KeyboardLayout[2][18] =
{ DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT, DIK_PERIOD, DIK_SLASH, DIK_RSHIFT, DIK_RMENU, DIK_RCONTROL, DIK_SPACE, DIK_COMMA, DIK_NUMPAD0, DIK_END, DIK_ESCAPE, DIK_DELETE, DIK_NEXT, DIK_P, DIK_RETURN }, { DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT, DIK_PERIOD, DIK_SLASH, DIK_RSHIFT, DIK_RMENU, DIK_RCONTROL, DIK_SPACE, DIK_COMMA, DIK_NUMPAD0, DIK_END, DIK_ESCAPE, DIK_DELETE, DIK_NEXT, DIK_P, DIK_RETURN },
{ DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT, DIK_PERIOD, DIK_SLASH, DIK_RSHIFT, DIK_RMENU, DIK_RCONTROL, DIK_SPACE, DIK_COMMA, DIK_NUMPAD0, DIK_END, DIK_ESCAPE, DIK_DELETE, DIK_NEXT, DIK_P, DIK_RETURN } { DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT, DIK_PERIOD, DIK_SLASH, DIK_RSHIFT, DIK_RMENU, DIK_RCONTROL, DIK_SPACE, DIK_COMMA, DIK_NUMPAD0, DIK_END, DIK_ESCAPE, DIK_DELETE, DIK_NEXT, DIK_P, DIK_RETURN }
}; };
int joy_x; int joy_x;
int joy_y; int joy_y;
int joy_fire; int joy_fire;

View file

@ -214,6 +214,8 @@ extern const char* g_KeyNames[];
extern int TrInput; extern int TrInput;
extern int DbInput; extern int DbInput;
extern int InputBusy; extern int InputBusy;
extern bool SetDebounce;
extern short KeyboardLayout[2][18]; extern short KeyboardLayout[2][18];
extern byte KeyMap[256]; extern byte KeyMap[256];

View file

@ -883,8 +883,8 @@ void LoadSoundEffects()
void LoadAnimatedTextures() void LoadAnimatedTextures()
{ {
NumAnimatedTextures = ReadInt32(); int numAnimatedTextures = ReadInt32();
for (int i = 0; i < NumAnimatedTextures; i++) for (int i = 0; i < numAnimatedTextures; i++)
{ {
ANIMATED_TEXTURES_SEQUENCE sequence; ANIMATED_TEXTURES_SEQUENCE sequence;
sequence.atlas = ReadInt32(); sequence.atlas = ReadInt32();
@ -904,7 +904,9 @@ void LoadAnimatedTextures()
} }
g_Level.AnimatedTexturesSequences.push_back(sequence); g_Level.AnimatedTexturesSequences.push_back(sequence);
} }
nAnimUVRanges = ReadInt8();
// Unused for now
int nAnimUVRanges = ReadInt8();
} }
void LoadTextureInfos() void LoadTextureInfos()
@ -1079,8 +1081,6 @@ unsigned CALLBACK LoadLevel(void* data)
// Initialise the game // Initialise the game
GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel); GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel);
Wibble = 0;
TorchRoom = -1;
InitialiseGameFlags(); InitialiseGameFlags();
InitialiseLara(!(InitialiseGame || CurrentLevel == 1)); InitialiseLara(!(InitialiseGame || CurrentLevel == 1));
GetCarriedItems(); GetCarriedItems();