Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions TombEngine/Game/spotcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ int LastSpotCamSequence;
int LaraHealth;
int LaraAir;
int CurrentSpotcamSequence;
SPOTCAM SpotCam[MAX_SPOTCAMS];
int SpotCamRemap[MAX_SPOTCAMS];
int CameraCnt[MAX_SPOTCAMS];
std::vector<SPOTCAM> SpotCam;
std::vector<int> SpotCamRemap;
std::vector<int> CameraCnt;
int NumberSpotcams;

bool CheckTrigger = false;
Expand All @@ -67,9 +67,9 @@ void ClearSpotCamSequences()
SpotcamDontDrawLara = false;
SpotcamOverlay = false;


for (int i = 0; i < MAX_SPOTCAMS; i++)
SpotCam[i] = {};
SpotCam.clear();
SpotCamRemap.clear();
CameraCnt.clear();
}

void InitializeSpotCamSequences(bool startFirstSequence)
Expand Down Expand Up @@ -848,7 +848,7 @@ Pose GetCameraTransform(int sequence, float alpha, bool loop)

alpha = std::clamp(alpha, 0.0f, 1.0f);

if (sequence < 0 || sequence >= MAX_SPOTCAMS)
if (sequence < 0 || sequence >= SPOTCAM_MAX_SEQUENCE_ID)
{
TENLog("Wrong flyby sequence number provided for getting camera coordinates.", LogLevel::Warning);
return Pose::Zero;
Expand Down
9 changes: 5 additions & 4 deletions TombEngine/Game/spotcam.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once
#include "Math/Math.h"
#include "Specific/clock.h"
#include <vector>

constexpr auto MAX_SPOTCAMS = 256;
constexpr auto SPOTCAM_MAX_SEQUENCE_ID = 256; // Max value for unsigned char sequence field
constexpr auto SPOTCAM_CINEMATIC_BARS_HEIGHT = 1.0f / 16;
constexpr auto SPOTCAM_CINEMATIC_BARS_SPEED = 1.0f / FPS;

Expand Down Expand Up @@ -47,9 +48,9 @@ enum SPOTCAM_FLAGS
SCF_CAMERA_ONE_SHOT = (1 << 15),
};

extern SPOTCAM SpotCam[MAX_SPOTCAMS];
extern int SpotCamRemap[MAX_SPOTCAMS];
extern int CameraCnt[MAX_SPOTCAMS];
extern std::vector<SPOTCAM> SpotCam;
extern std::vector<int> SpotCamRemap;
extern std::vector<int> CameraCnt;
extern int LastSpotCamSequence;
extern int NumberSpotcams;
extern bool UseSpotCam;
Expand Down
10 changes: 9 additions & 1 deletion TombEngine/Specific/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,17 @@ void LoadCameras()

NumberSpotcams = ReadCount();

// SpotCamRemap and CameraCnt are indexed by sequence number (unsigned char 0-255)
// Always initialize them to handle GetCameraTransform calls even when NumberSpotcams == 0
SpotCamRemap.assign(SPOTCAM_MAX_SEQUENCE_ID, 0);
CameraCnt.assign(SPOTCAM_MAX_SEQUENCE_ID, 0);

// TODO: Read properly!
if (NumberSpotcams != 0)
ReadBytes(SpotCam, NumberSpotcams * sizeof(SPOTCAM));
{
SpotCam.resize(NumberSpotcams);
ReadBytes(SpotCam.data(), NumberSpotcams * sizeof(SPOTCAM));
}

int sinkCount = ReadCount();
TENLog("Sink count: " + std::to_string(sinkCount), LogLevel::Info);
Expand Down