Fixed release mode

- updated AlterFloorHeight()
- fixed chunkreader.h that used "ChunkReader::" in this own class.
- fixed ChunkId::FromString() not const for str.
- fixed some renderer wrong return value that caused error.
- fixed the debug mode not using the correct directx library !
- updated project include and libs required in release mode.
- fixed Sound_CheckBASSError() not const for message.
- fixed compileXXShader not const for the path.
- reverted GetFloor() change.
This commit is contained in:
TokyoSU 2019-12-14 22:41:38 +01:00
parent 3296db8dce
commit 4b6ffedf5e
9 changed files with 101 additions and 152 deletions

View file

@ -1240,9 +1240,9 @@ int CreatureVault(short itemNum, short angle, int vault, int shift)
void GetAITarget(CREATURE_INFO* creature) void GetAITarget(CREATURE_INFO* creature)
{ {
#define GET_REACHED_GOAL abs(enemy->pos.xPos - item->pos.xPos) < REACHED_GOAL_RADIUS &&\ #define GET_REACHED_GOAL abs(enemy->pos.xPos - item->pos.xPos) < REACHED_GOAL_RADIUS &&\
abs(enemy->pos.zPos - item->pos.zPos) < REACHED_GOAL_RADIUS &&\ abs(enemy->pos.zPos - item->pos.zPos) < REACHED_GOAL_RADIUS &&\
abs(enemy->pos.yPos - item->pos.yPos) < REACHED_GOAL_RADIUS abs(enemy->pos.yPos - item->pos.yPos) < REACHED_GOAL_RADIUS
ITEM_INFO* enemy; ITEM_INFO* enemy;
ITEM_INFO* item; ITEM_INFO* item;

View file

@ -1335,7 +1335,12 @@ int GetChange(ITEM_INFO* item, ANIM_STRUCT* anim)
void AlterFloorHeight(ITEM_INFO* item, int height) void AlterFloorHeight(ITEM_INFO* item, int height)
{ {
FLOOR_INFO* floor;
FLOOR_INFO* ceiling;
BOX_INFO* box;
short roomNumber;
int flag = 0; int flag = 0;
if (abs(height)) if (abs(height))
{ {
flag = 1; flag = 1;
@ -1345,42 +1350,42 @@ void AlterFloorHeight(ITEM_INFO* item, int height)
height--; height--;
} }
short roomNumber = item->roomNumber; roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber); floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
FLOOR_INFO* ceiling = GetFloor(item->pos.xPos, height + item->pos.yPos - 1024, item->pos.zPos, &roomNumber); ceiling = GetFloor(item->pos.xPos, height + item->pos.yPos - WALL_SIZE, item->pos.zPos, &roomNumber);
if (floor->floor == -127) if (floor->floor == NO_HEIGHT/STEP_SIZE)
{ {
floor->floor = ceiling->ceiling + (((height >> 31) + height) >> 8); floor->floor = ceiling->ceiling + height/STEP_SIZE;
} }
else else
{ {
floor->floor += (((height >> 31) + height) >> 8); floor->floor += height/STEP_SIZE;
if (floor->floor == ceiling->ceiling && !flag) if (floor->floor == ceiling->ceiling && !flag)
floor->floor = -127; floor->floor = NO_HEIGHT/STEP_SIZE;
} }
BOX_INFO* box = &Boxes[floor->box]; box = &Boxes[floor->box];
if (box->overlapIndex & 0x8000) if (box->overlapIndex & BLOCKABLE)
{ {
if (height >= 0) if (height >= 0)
box->overlapIndex &= ~0x4000; box->overlapIndex &= ~BLOCKED;
else else
box->overlapIndex |= 0x4000; box->overlapIndex |= BLOCKED;
} }
} }
FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber) FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
{ {
ROOM_INFO* r;
FLOOR_INFO* floor; FLOOR_INFO* floor;
short data;
int xFloor = 0; int xFloor = 0;
int yFloor = 0; int yFloor = 0;
short roomDoor = 0; short roomDoor = 0;
int retval; int retval;
ROOM_INFO* r = &Rooms[*roomNumber]; r = &Rooms[*roomNumber];
short data;
do do
{ {
xFloor = (z - r->z) >> WALL_SHIFT; xFloor = (z - r->z) >> WALL_SHIFT;
@ -1421,53 +1426,6 @@ FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
} }
} while (data != NO_ROOM); } while (data != NO_ROOM);
if (y >= (floor->floor * 256))
{
do
{
if (floor->pitRoom == NO_ROOM)
return floor;
retval = CheckNoColFloorTriangle(floor, x, z);
if (retval == 1)
break;
if (retval == -1)
{
if (y < r->minfloor)
break;
}
*roomNumber = floor->pitRoom;
r = &Rooms[floor->pitRoom];
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
}
while (y >= (floor->floor * 256));
}
else if (y < (floor->ceiling * 256))
{
do
{
if (floor->skyRoom == NO_ROOM)
return floor;
retval = CheckNoColCeilingTriangle(floor, x, z);
if (retval == 1)
break;
if (retval == -1)
{
if (y >= r->maxceiling)
break;
}
*roomNumber = floor->pitRoom;
r = &Rooms[floor->pitRoom];
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
}
while (y < (floor->ceiling * 256));
}
/*
if (y < floor->floor * 256) if (y < floor->floor * 256)
{ {
if (y < floor->ceiling * 256 && floor->skyRoom != NO_ROOM) if (y < floor->ceiling * 256 && floor->skyRoom != NO_ROOM)
@ -1496,12 +1454,12 @@ FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
*roomNumber = floor->pitRoom; *roomNumber = floor->pitRoom;
r = &Rooms[floor->pitRoom]; r = &Rooms[floor->pitRoom];
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
if (y < floor->floor * 256) if (y < floor->floor * 256)
break; break;
} while (floor->pitRoom != NO_ROOM); } while (floor->pitRoom != NO_ROOM);
} }
*/
return floor; return floor;
} }

View file

@ -220,7 +220,6 @@ long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags)
SoundSlot[freeSlot].origin = position ? Vector3(position->xPos, position->yPos, position->zPos) : SOUND_OMNIPRESENT_ORIGIN; SoundSlot[freeSlot].origin = position ? Vector3(position->xPos, position->yPos, position->zPos) : SOUND_OMNIPRESENT_ORIGIN;
// Set 3D attributes // Set 3D attributes
BASS_ChannelSet3DAttributes(channel, position ? BASS_3DMODE_NORMAL : BASS_3DMODE_OFF, SOUND_MAXVOL_RADIUS, radius, 360, 360, 0.0f); BASS_ChannelSet3DAttributes(channel, position ? BASS_3DMODE_NORMAL : BASS_3DMODE_OFF, SOUND_MAXVOL_RADIUS, radius, 360, 360, 0.0f);
Sound_UpdateEffectPosition(freeSlot, position, true); Sound_UpdateEffectPosition(freeSlot, position, true);
@ -264,7 +263,7 @@ void Sound_FreeSamples()
void S_CDPlay(short index, unsigned int mode) void S_CDPlay(short index, unsigned int mode)
{ {
bool crossfade = false; bool crossfade = false;
DWORD crossfadeTime; DWORD crossfadeTime;
DWORD flags = BASS_STREAM_AUTOFREE | BASS_SAMPLE_FLOAT | BASS_ASYNCFILE; DWORD flags = BASS_STREAM_AUTOFREE | BASS_SAMPLE_FLOAT | BASS_ASYNCFILE;
@ -274,7 +273,7 @@ void S_CDPlay(short index, unsigned int mode)
mode = (mode >= NUM_SOUND_TRACK_TYPES) ? SOUND_TRACK_BGM : mode; mode = (mode >= NUM_SOUND_TRACK_TYPES) ? SOUND_TRACK_BGM : mode;
bool channelActive = BASS_ChannelIsActive(BASS_Soundtrack[mode].channel); bool channelActive = BASS_ChannelIsActive(BASS_Soundtrack[mode].channel);
if (channelActive && (BASS_Soundtrack[mode].trackID == index)) if (channelActive && BASS_Soundtrack[mode].trackID == index)
return; return;
switch (mode) switch (mode)
@ -410,8 +409,7 @@ int Sound_GetFreeSlot()
{ {
for (int i = 0; i < SOUND_MAX_CHANNELS; i++) for (int i = 0; i < SOUND_MAX_CHANNELS; i++)
{ {
if ((SoundSlot[i].channel == NULL) || if (SoundSlot[i].channel == NULL || !BASS_ChannelIsActive(SoundSlot[i].channel))
!BASS_ChannelIsActive(SoundSlot[i].channel))
return i; return i;
} }
@ -673,7 +671,7 @@ void Sound_DeInit()
BASS_Free(); BASS_Free();
} }
bool Sound_CheckBASSError(char* message, bool verbose, ...) bool Sound_CheckBASSError(const char* message, bool verbose, ...)
{ {
va_list argptr; va_list argptr;
static char data[4096]; static char data[4096];
@ -682,7 +680,7 @@ bool Sound_CheckBASSError(char* message, bool verbose, ...)
if (verbose || bassError) if (verbose || bassError)
{ {
va_start(argptr, verbose); va_start(argptr, verbose);
int32_t written = vsprintf(data, message, argptr); // @TODO: replace with debug/console/message output later... int32_t written = vsprintf(data, (char*)message, argptr); // @TODO: replace with debug/console/message output later...
va_end(argptr); va_end(argptr);
snprintf(data + written, sizeof(data) - written, bassError ? ": error #%d \n" : ": success \n", bassError); snprintf(data + written, sizeof(data) - written, bassError ? ": error #%d \n" : ": success \n", bassError);
printf(data); printf(data);

View file

@ -593,37 +593,28 @@ typedef enum sound_effects
}; };
#define PITCH_SHIFT 4 #define PITCH_SHIFT 4
#define SOUND_BASS_UNITS 1.0f / 1024.0f // TR->BASS distance unit coefficient #define SOUND_BASS_UNITS 1.0f / 1024.0f // TR->BASS distance unit coefficient
#define SOUND_MAXVOL_RADIUS 1024.0f // Max. volume hearing distance #define SOUND_MAXVOL_RADIUS 1024.0f // Max. volume hearing distance
#define SOUND_OMNIPRESENT_ORIGIN Vector3(1.17549e-038f, 1.17549e-038f, 1.17549e-038f) #define SOUND_OMNIPRESENT_ORIGIN Vector3(1.17549e-038f, 1.17549e-038f, 1.17549e-038f)
#define SOUND_MAX_SAMPLES 3072 // Original was 1024, reallocate original 3-dword DX handle struct to just 1-dword memory pointer #define SOUND_MAX_SAMPLES 3072 // Original was 1024, reallocate original 3-dword DX handle struct to just 1-dword memory pointer
#define SOUND_MAX_CHANNELS 32 // Original was 24, reallocate original 36-byte struct with 24-byte SoundEffectSlot struct #define SOUND_MAX_CHANNELS 32 // Original was 24, reallocate original 36-byte struct with 24-byte SoundEffectSlot struct
#define SOUND_LEGACY_SOUNDMAP_SIZE 450 #define SOUND_LEGACY_SOUNDMAP_SIZE 450
#define SOUND_LEGACY_TRACKTABLE_SIZE 136 #define SOUND_LEGACY_TRACKTABLE_SIZE 136
#define SOUND_FLAG_NO_PAN (1<<12) // Unused flag #define SOUND_FLAG_NO_PAN (1<<12) // Unused flag
#define SOUND_FLAG_RND_PITCH (1<<13) #define SOUND_FLAG_RND_PITCH (1<<13)
#define SOUND_FLAG_RND_GAIN (1<<14) #define SOUND_FLAG_RND_GAIN (1<<14)
#define SOUND_MAX_PITCH_CHANGE 0.09f #define SOUND_MAX_PITCH_CHANGE 0.09f
#define SOUND_MAX_GAIN_CHANGE 0.0625f #define SOUND_MAX_GAIN_CHANGE 0.0625f
#define SOUND_32BIT_SILENCE_LEVEL 4.9e-04f #define SOUND_32BIT_SILENCE_LEVEL 4.9e-04f
#define SOUND_SAMPLE_FLAGS (BASS_SAMPLE_MONO | BASS_SAMPLE_FLOAT) #define SOUND_SAMPLE_FLAGS (BASS_SAMPLE_MONO | BASS_SAMPLE_FLOAT)
#define SOUND_XFADETIME_BGM 5000 #define SOUND_XFADETIME_BGM 5000
#define SOUND_XFADETIME_BGM_START 1500 #define SOUND_XFADETIME_BGM_START 1500
#define SOUND_XFADETIME_ONESHOT 200 #define SOUND_XFADETIME_ONESHOT 200
#define SOUND_XFADETIME_CUTSOUND 100 #define SOUND_XFADETIME_CUTSOUND 100
#define SOUND_XFADETIME_HIJACKSOUND 50 #define SOUND_XFADETIME_HIJACKSOUND 50
#define SOUND_BGM_DAMP_COEFFICIENT 0.6f #define SOUND_BGM_DAMP_COEFFICIENT 0.6f
typedef struct SoundEffectSlot struct SoundEffectSlot
{ {
short state; short state;
short effectID; short effectID;
@ -632,7 +623,7 @@ typedef struct SoundEffectSlot
Vector3 origin; Vector3 origin;
}; };
typedef struct SoundTrackSlot struct SoundTrackSlot
{ {
HSTREAM channel; HSTREAM channel;
short trackID; short trackID;
@ -706,7 +697,7 @@ static void CALLBACK Sound_FinishOneshotTrack(HSYNC handle, DWORD channel, DWORD
void Sound_Init(); void Sound_Init();
void Sound_DeInit(); void Sound_DeInit();
bool Sound_CheckBASSError(char* message, bool verbose, ...); bool Sound_CheckBASSError(const char* message, bool verbose, ...);
void Sound_UpdateScene(); void Sound_UpdateScene();
void Sound_FreeSample(int index); void Sound_FreeSample(int index);
int Sound_GetFreeSlot(); int Sound_GetFreeSlot();

View file

@ -133,16 +133,12 @@ void Renderer11::FreeRendererData()
DX11_DELETE(m_animatedTextureSets[i]); DX11_DELETE(m_animatedTextureSets[i]);
free(m_animatedTextureSets); free(m_animatedTextureSets);
DX11_DELETE(m_textureAtlas);
DX11_DELETE(m_textureAtlas); DX11_DELETE(m_textureAtlas);
DX11_DELETE(m_skyTexture); DX11_DELETE(m_skyTexture);
DX11_DELETE(m_roomsVertexBuffer); DX11_DELETE(m_roomsVertexBuffer);
DX11_DELETE(m_roomsIndexBuffer); DX11_DELETE(m_roomsIndexBuffer);
DX11_DELETE(m_moveablesVertexBuffer); DX11_DELETE(m_moveablesVertexBuffer);
DX11_DELETE(m_moveablesIndexBuffer); DX11_DELETE(m_moveablesIndexBuffer);
DX11_DELETE(m_staticsVertexBuffer); DX11_DELETE(m_staticsVertexBuffer);
DX11_DELETE(m_staticsIndexBuffer); DX11_DELETE(m_staticsIndexBuffer);
} }
@ -151,9 +147,14 @@ bool Renderer11::Create()
{ {
D3D_FEATURE_LEVEL levels[1] = { D3D_FEATURE_LEVEL_10_0 }; D3D_FEATURE_LEVEL levels[1] = { D3D_FEATURE_LEVEL_10_0 };
D3D_FEATURE_LEVEL featureLevel; D3D_FEATURE_LEVEL featureLevel;
HRESULT res;
#ifdef _RELEASE
res = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, levels, 1, D3D11_SDK_VERSION, &m_device, &featureLevel, &m_context);
#else
res = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, levels, 1, D3D11_SDK_VERSION, &m_device, &featureLevel, &m_context); // D3D11_CREATE_DEVICE_DEBUG
#endif
HRESULT res = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, levels, 1, D3D11_SDK_VERSION,
&m_device, &featureLevel, &m_context);
if (FAILED(res)) if (FAILED(res))
return false; return false;
@ -412,7 +413,7 @@ bool Renderer11::Initialise(int w, int h, int refreshRate, bool windowed, HWND h
m_states = new CommonStates(m_device); m_states = new CommonStates(m_device);
// Load caustics // Load caustics
char* causticsNames[NUM_CAUSTICS_TEXTURES] = { const char* causticsNames[NUM_CAUSTICS_TEXTURES] = {
"CausticsRender_001.bmp", "CausticsRender_001.bmp",
"CausticsRender_002.bmp", "CausticsRender_002.bmp",
"CausticsRender_003.bmp", "CausticsRender_003.bmp",
@ -1554,8 +1555,9 @@ bool Renderer11::drawScene(bool dump)
// Draw binoculars or lasersight // Draw binoculars or lasersight
drawOverlays(); drawOverlays();
ROOM_INFO* r = &Rooms[LaraItem->roomNumber];
m_currentY = 60; m_currentY = 60;
#ifdef _DEBUG
ROOM_INFO* r = &Rooms[LaraItem->roomNumber];
printDebugMessage("Update time: %d", m_timeUpdate); printDebugMessage("Update time: %d", m_timeUpdate);
printDebugMessage("Frame time: %d", m_timeFrame); printDebugMessage("Frame time: %d", m_timeFrame);
@ -1572,6 +1574,7 @@ bool Renderer11::drawScene(bool dump)
printDebugMessage("Lara.requiredAnimState: %d", LaraItem->requiredAnimState); printDebugMessage("Lara.requiredAnimState: %d", LaraItem->requiredAnimState);
printDebugMessage("Lara.goalAnimState: %d", LaraItem->goalAnimState); printDebugMessage("Lara.goalAnimState: %d", LaraItem->goalAnimState);
printDebugMessage("Room: %d %d %d %d", r->x, r->z, r->x + r->xSize * WALL_SIZE, r->z + r->ySize * WALL_SIZE); printDebugMessage("Room: %d %d %d %d", r->x, r->z, r->x + r->xSize * WALL_SIZE, r->z + r->ySize * WALL_SIZE);
#endif
} }
drawAllStrings(); drawAllStrings();
@ -2597,7 +2600,7 @@ bool Renderer11::PrepareDataForTheRenderer()
return true; return true;
} }
ID3D11VertexShader* Renderer11::compileVertexShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode) ID3D11VertexShader* Renderer11::compileVertexShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode)
{ {
HRESULT res; HRESULT res;
@ -2621,7 +2624,7 @@ ID3D11VertexShader* Renderer11::compileVertexShader(char* fileName, char* functi
return shader; return shader;
} }
ID3D11PixelShader* Renderer11::compilePixelShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode) ID3D11PixelShader* Renderer11::compilePixelShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode)
{ {
HRESULT res; HRESULT res;
@ -2645,7 +2648,7 @@ ID3D11PixelShader* Renderer11::compilePixelShader(char* fileName, char* function
return shader; return shader;
} }
ID3D11GeometryShader* Renderer11::compileGeometryShader(char* fileName) ID3D11GeometryShader* Renderer11::compileGeometryShader(const char* fileName)
{ {
HRESULT res; HRESULT res;
@ -2664,7 +2667,7 @@ ID3D11GeometryShader* Renderer11::compileGeometryShader(char* fileName)
return shader; return shader;
} }
ID3D11ComputeShader* Renderer11::compileComputeShader(char* fileName) ID3D11ComputeShader* Renderer11::compileComputeShader(const char* fileName)
{ {
HRESULT res; HRESULT res;
@ -4633,7 +4636,7 @@ bool Renderer11::printDebugMessage(int x, int y, int alpha, byte r, byte g, byte
return true; return true;
} }
void Renderer11::printDebugMessage(char* message, ...) void Renderer11::printDebugMessage(LPCSTR message, ...)
{ {
char buffer[255]; char buffer[255];
ZeroMemory(buffer, 255); ZeroMemory(buffer, 255);

View file

@ -264,7 +264,7 @@ public:
rt->DepthStencilTexture = NULL; rt->DepthStencilTexture = NULL;
res = device->CreateTexture2D(&depthTexDesc, NULL, &rt->DepthStencilTexture); res = device->CreateTexture2D(&depthTexDesc, NULL, &rt->DepthStencilTexture);
if (FAILED(res)) if (FAILED(res))
return false; return NULL;
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC)); ZeroMemory(&dsvDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
@ -276,7 +276,7 @@ public:
rt->DepthStencilView = NULL; rt->DepthStencilView = NULL;
res = device->CreateDepthStencilView(rt->DepthStencilTexture, &dsvDesc, &rt->DepthStencilView); res = device->CreateDepthStencilView(rt->DepthStencilTexture, &dsvDesc, &rt->DepthStencilView);
if (FAILED(res)) if (FAILED(res))
return false; return NULL;
return rt; return rt;
} }
@ -347,7 +347,7 @@ public:
return texture; return texture;
} }
static Texture2D* LoadFromFile(ID3D11Device* device, char* fileName) static Texture2D* LoadFromFile(ID3D11Device* device, const char* fileName)
{ {
Texture2D* texture = new Texture2D(); Texture2D* texture = new Texture2D();
@ -832,8 +832,8 @@ private:
SpriteFont* m_gameFont; SpriteFont* m_gameFont;
SpriteBatch* m_spriteBatch; SpriteBatch* m_spriteBatch;
vector<RendererStringToDraw> m_strings; vector<RendererStringToDraw> m_strings;
int m_blinkColorValue; int m_blinkColorValue;
int m_blinkColorDirection; int m_blinkColorDirection;
PrimitiveBatch<RendererVertex>* m_primitiveBatch; PrimitiveBatch<RendererVertex>* m_primitiveBatch;
// System resources // System resources
@ -873,31 +873,31 @@ private:
PreallocatedVector<RendererLine2D> m_lines2DToDraw; PreallocatedVector<RendererLine2D> m_lines2DToDraw;
PreallocatedVector<RendererLight> m_tempItemLights; PreallocatedVector<RendererLight> m_tempItemLights;
RendererSpriteToDraw* m_spritesBuffer; RendererSpriteToDraw* m_spritesBuffer;
int m_nextSprite; int m_nextSprite;
RendererLine3D* m_lines3DBuffer; RendererLine3D* m_lines3DBuffer;
int m_nextLine3D; int m_nextLine3D;
RendererLine2D* m_lines2DBuffer; RendererLine2D* m_lines2DBuffer;
int m_nextLine2D; int m_nextLine2D;
RendererLight* m_shadowLight; RendererLight* m_shadowLight;
RendererObject** m_moveableObjects; RendererObject** m_moveableObjects;
RendererObject** m_staticObjects; RendererObject** m_staticObjects;
RendererSprite** m_sprites; RendererSprite** m_sprites;
int m_numMoveables; int m_numMoveables;
int m_numStatics; int m_numStatics;
int m_numSprites; int m_numSprites;
int m_numSpritesSequences; int m_numSpritesSequences;
RendererSpriteSequence** m_spriteSequences; RendererSpriteSequence** m_spriteSequences;
unordered_map<unsigned int, RendererMesh*> m_meshPointersToMesh; unordered_map<unsigned int, RendererMesh*> m_meshPointersToMesh;
Matrix m_LaraWorldMatrix; Matrix m_LaraWorldMatrix;
RendererAnimatedTextureSet** m_animatedTextureSets; RendererAnimatedTextureSet** m_animatedTextureSets;
int m_numAnimatedTextureSets; int m_numAnimatedTextureSets;
int m_currentCausticsFrame; int m_currentCausticsFrame;
RendererUnderwaterDustParticle m_underwaterDustParticles[NUM_UNDERWATER_DUST_PARTICLES]; RendererUnderwaterDustParticle m_underwaterDustParticles[NUM_UNDERWATER_DUST_PARTICLES];
bool m_firstUnderwaterDustParticles = true; bool m_firstUnderwaterDustParticles = true;
vector<RendererMesh*> m_meshes; vector<RendererMesh*> m_meshes;
// Debug variables // Debug variables
int m_numDrawCalls = 0; int m_numDrawCalls = 0;
// Preallocated pools of objects for avoiding new/delete // Preallocated pools of objects for avoiding new/delete
// Items and effects are safe (can't be more than 1024 items in TR), // Items and effects are safe (can't be more than 1024 items in TR),
@ -905,13 +905,13 @@ private:
RendererItem m_items[NUM_ITEMS]; RendererItem m_items[NUM_ITEMS];
RendererEffect m_effects[NUM_ITEMS]; RendererEffect m_effects[NUM_ITEMS];
RendererLight m_lights[MAX_LIGHTS]; RendererLight m_lights[MAX_LIGHTS];
int m_nextLight; int m_nextLight;
int m_currentY; int m_currentY;
// Times for debug // Times for debug
int m_timeUpdate; int m_timeUpdate;
int m_timeDraw; int m_timeDraw;
int m_timeFrame; int m_timeFrame;
// Others // Others
bool m_firstWeather; bool m_firstWeather;
@ -919,19 +919,19 @@ private:
RendererWeatherParticle m_snow[NUM_SNOW_PARTICLES]; RendererWeatherParticle m_snow[NUM_SNOW_PARTICLES];
RENDERER_FADE_STATUS m_fadeStatus; RENDERER_FADE_STATUS m_fadeStatus;
float m_fadeFactor; float m_fadeFactor;
int m_progress; int m_progress;
bool m_enableCinematicBars = false; bool m_enableCinematicBars = false;
int m_pickupRotation; int m_pickupRotation;
// Private functions // Private functions
bool drawScene(bool dump); bool drawScene(bool dump);
bool drawAllStrings(); bool drawAllStrings();
ID3D11VertexShader* compileVertexShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode); ID3D11VertexShader* compileVertexShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode);
ID3D11GeometryShader* compileGeometryShader(char* fileName); ID3D11GeometryShader* compileGeometryShader(const char* fileName);
ID3D11PixelShader* compilePixelShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode); ID3D11PixelShader* compilePixelShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode);
ID3D11ComputeShader* compileComputeShader(char* fileName); ID3D11ComputeShader* compileComputeShader(const char* fileName);
ID3D11Buffer* createConstantBuffer(int size); ID3D11Buffer* createConstantBuffer(int size);
int getAnimatedTextureInfo(short textureId); int getAnimatedTextureInfo(short textureId);
void initialiseHairRemaps(); void initialiseHairRemaps();
RendererMesh* getRendererMeshFromTrMesh(RendererObject* obj, short* meshPtr, short* refMeshPtr, short boneIndex, int isJoints, int isHairs); RendererMesh* getRendererMeshFromTrMesh(RendererObject* obj, short* meshPtr, short* refMeshPtr, short boneIndex, int isJoints, int isHairs);
void fromTrAngle(Matrix* matrix, short* frameptr, int index); void fromTrAngle(Matrix* matrix, short* frameptr, int index);
@ -954,7 +954,7 @@ private:
void updateLaraAnimations(); void updateLaraAnimations();
void updateItemsAnimations(); void updateItemsAnimations();
void updateEffects(); void updateEffects();
int getFrame(short animation, short frame, short** framePtr, int* rate); int getFrame(short animation, short frame, short** framePtr, int* rate);
bool drawAmbientCubeMap(short roomNumber); bool drawAmbientCubeMap(short roomNumber);
bool sphereBoxIntersection(Vector3 boxMin, Vector3 boxMax, Vector3 sphereCentre, float sphereRadius); bool sphereBoxIntersection(Vector3 boxMin, Vector3 boxMax, Vector3 sphereCentre, float sphereRadius);
bool drawHorizonAndSky(); bool drawHorizonAndSky();
@ -966,7 +966,7 @@ private:
bool drawShadowMap(); bool drawShadowMap();
bool drawObjectOn2DPosition(short x, short y, short objectNum, short rotX, short rotY, short rotZ); bool drawObjectOn2DPosition(short x, short y, short objectNum, short rotX, short rotY, short rotZ);
bool drawLara(bool transparent, bool shadowMap); bool drawLara(bool transparent, bool shadowMap);
void printDebugMessage(char* message, ...); void printDebugMessage(LPCSTR message, ...);
void drawFires(); void drawFires();
void drawSparks(); void drawSparks();
void drawSmokes(); void drawSmokes();
@ -989,8 +989,8 @@ private:
bool drawBar(int x, int y, int w, int h, int percent, int color1, int color2); bool drawBar(int x, int y, int w, int h, int percent, int color1, int color2);
void insertLine2D(int x1, int y1, int x2, int y2, byte r, byte g, byte b, byte a); void insertLine2D(int x1, int y1, int x2, int y2, byte r, byte g, byte b, byte a);
bool drawDebris(bool transparent); bool drawDebris(bool transparent);
int drawInventoryScene(); int drawInventoryScene();
int drawFinalPass(); int drawFinalPass();
void updateAnimatedTextures(); void updateAnimatedTextures();
void createBillboardMatrix(Matrix* out, Vector3* particlePos, Vector3* cameraPos, float rotation); void createBillboardMatrix(Matrix* out, Vector3* particlePos, Vector3* cameraPos, float rotation);
void drawShockwaves(); void drawShockwaves();
@ -1013,10 +1013,10 @@ public:
Matrix Projection; Matrix Projection;
Matrix ViewProjection; Matrix ViewProjection;
float FieldOfView; float FieldOfView;
int ScreenWidth; int ScreenWidth;
int ScreenHeight; int ScreenHeight;
bool Windowed; bool Windowed;
int NumTexturePages; int NumTexturePages;
Renderer11(); Renderer11();
~Renderer11(); ~Renderer11();
@ -1024,13 +1024,13 @@ public:
bool Create(); bool Create();
bool EnumerateVideoModes(); bool EnumerateVideoModes();
bool Initialise(int w, int h, int refreshRate, bool windowed, HWND handle); bool Initialise(int w, int h, int refreshRate, bool windowed, HWND handle);
int Draw(); int Draw();
bool PrepareDataForTheRenderer(); bool PrepareDataForTheRenderer();
void UpdateCameraMatrices(float posX, float posY, float posZ, float targetX, float targetY, float targetZ, float roll, float fov); void UpdateCameraMatrices(float posX, float posY, float posZ, float targetX, float targetY, float targetZ, float roll, float fov);
int DumpGameScene(); int DumpGameScene();
int DrawInventory(); int DrawInventory();
int DrawPickup(short objectNum); int DrawPickup(short objectNum);
int SyncRenderer(); int SyncRenderer();
bool PrintString(int x, int y, char* string, D3DCOLOR color, int flags); bool PrintString(int x, int y, char* string, D3DCOLOR color, int flags);
void DrawDashBar(); void DrawDashBar();
void DrawHealthBar(int percentual); void DrawHealthBar(int percentual);

View file

@ -38,9 +38,9 @@ public:
delete m_chunkBytes; delete m_chunkBytes;
} }
static ChunkId* FromString(char* str) static ChunkId* FromString(const char* str)
{ {
return new ChunkId(str, strlen(str)); return new ChunkId((char*)str, strlen(str));
} }
static ChunkId* FromString(string* str) static ChunkId* FromString(string* str)

View file

@ -45,9 +45,7 @@ public:
// TODO: future use for compression // TODO: future use for compression
m_stream->Seek(4, SEEK_ORIGIN::CURRENT); m_stream->Seek(4, SEEK_ORIGIN::CURRENT);
m_emptyChunk = new ChunkId(NULL, 0); m_emptyChunk = new ChunkId(NULL, 0);
m_isValid = true; m_isValid = true;
} }
@ -56,12 +54,12 @@ public:
delete m_emptyChunk; delete m_emptyChunk;
} }
bool ChunkReader::IsValid() bool IsValid()
{ {
return m_isValid; return m_isValid;
} }
bool ChunkReader::ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg) bool ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg)
{ {
do do
{ {

View file

@ -47,14 +47,15 @@
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\Build\</OutDir> <OutDir>$(ProjectDir)..\Build\</OutDir>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath> <ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(ProjectDir)Libs\bass;$(ProjectDir)Libs\sol2;$(ProjectDir)Libs\lua</IncludePath> <IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua</IncludePath>
<LibraryPath>$(LibraryPath);$(ProjectDir)Libs\lua;$(DXSDK_DIR)Lib\x86;$(ProjectDir)Libs\bass</LibraryPath> <LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath> <ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(ProjectDir)Libs\bass</IncludePath> <IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(ProjectDir)Libs\bass</LibraryPath> <LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
<OutDir>$(ProjectDir)..\Build\Release\</OutDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -64,7 +65,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode> <ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)TR5Main\Libs\sol2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath> <IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
</ClCompile> </ClCompile>
@ -73,7 +74,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;dxerr.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;dxerr.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;d3dx11.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>md "$(TargetDir)\Shaders" <Command>md "$(TargetDir)\Shaders"
@ -90,7 +91,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_RELEASE;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
@ -98,9 +99,9 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>bass.lib;bassmix.lib;bass_fx.lib;d3d9.lib;dinput8.lib;d3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;dxerr.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>md "$(TargetDir)\Shaders" <Command>md "$(TargetDir)\Shaders"