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

@ -1335,7 +1335,12 @@ int GetChange(ITEM_INFO* item, ANIM_STRUCT* anim)
void AlterFloorHeight(ITEM_INFO* item, int height)
{
FLOOR_INFO* floor;
FLOOR_INFO* ceiling;
BOX_INFO* box;
short roomNumber;
int flag = 0;
if (abs(height))
{
flag = 1;
@ -1345,42 +1350,42 @@ void AlterFloorHeight(ITEM_INFO* item, int height)
height--;
}
short roomNumber = item->roomNumber;
FLOOR_INFO* 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);
roomNumber = item->roomNumber;
floor = GetFloor(item->pos.xPos, item->pos.yPos, 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
{
floor->floor += (((height >> 31) + height) >> 8);
floor->floor += height/STEP_SIZE;
if (floor->floor == ceiling->ceiling && !flag)
floor->floor = -127;
floor->floor = NO_HEIGHT/STEP_SIZE;
}
BOX_INFO* box = &Boxes[floor->box];
if (box->overlapIndex & 0x8000)
box = &Boxes[floor->box];
if (box->overlapIndex & BLOCKABLE)
{
if (height >= 0)
box->overlapIndex &= ~0x4000;
box->overlapIndex &= ~BLOCKED;
else
box->overlapIndex |= 0x4000;
box->overlapIndex |= BLOCKED;
}
}
FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
{
ROOM_INFO* r;
FLOOR_INFO* floor;
short data;
int xFloor = 0;
int yFloor = 0;
short roomDoor = 0;
int retval;
ROOM_INFO* r = &Rooms[*roomNumber];
short data;
r = &Rooms[*roomNumber];
do
{
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);
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->ceiling * 256 && floor->skyRoom != NO_ROOM)
@ -1501,7 +1459,7 @@ FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
break;
} while (floor->pitRoom != NO_ROOM);
}
*/
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;
// Set 3D attributes
BASS_ChannelSet3DAttributes(channel, position ? BASS_3DMODE_NORMAL : BASS_3DMODE_OFF, SOUND_MAXVOL_RADIUS, radius, 360, 360, 0.0f);
Sound_UpdateEffectPosition(freeSlot, position, true);
@ -274,7 +273,7 @@ void S_CDPlay(short index, unsigned int mode)
mode = (mode >= NUM_SOUND_TRACK_TYPES) ? SOUND_TRACK_BGM : mode;
bool channelActive = BASS_ChannelIsActive(BASS_Soundtrack[mode].channel);
if (channelActive && (BASS_Soundtrack[mode].trackID == index))
if (channelActive && BASS_Soundtrack[mode].trackID == index)
return;
switch (mode)
@ -410,8 +409,7 @@ int Sound_GetFreeSlot()
{
for (int i = 0; i < SOUND_MAX_CHANNELS; i++)
{
if ((SoundSlot[i].channel == NULL) ||
!BASS_ChannelIsActive(SoundSlot[i].channel))
if (SoundSlot[i].channel == NULL || !BASS_ChannelIsActive(SoundSlot[i].channel))
return i;
}
@ -673,7 +671,7 @@ void Sound_DeInit()
BASS_Free();
}
bool Sound_CheckBASSError(char* message, bool verbose, ...)
bool Sound_CheckBASSError(const char* message, bool verbose, ...)
{
va_list argptr;
static char data[4096];
@ -682,7 +680,7 @@ bool Sound_CheckBASSError(char* message, bool verbose, ...)
if (verbose || bassError)
{
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);
snprintf(data + written, sizeof(data) - written, bassError ? ": error #%d \n" : ": success \n", bassError);
printf(data);

View file

@ -593,37 +593,28 @@ typedef enum sound_effects
};
#define PITCH_SHIFT 4
#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_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_CHANNELS 32 // Original was 24, reallocate original 36-byte struct with 24-byte SoundEffectSlot struct
#define SOUND_LEGACY_SOUNDMAP_SIZE 450
#define SOUND_LEGACY_TRACKTABLE_SIZE 136
#define SOUND_FLAG_NO_PAN (1<<12) // Unused flag
#define SOUND_FLAG_RND_PITCH (1<<13)
#define SOUND_FLAG_RND_GAIN (1<<14)
#define SOUND_MAX_PITCH_CHANGE 0.09f
#define SOUND_MAX_GAIN_CHANGE 0.0625f
#define SOUND_32BIT_SILENCE_LEVEL 4.9e-04f
#define SOUND_SAMPLE_FLAGS (BASS_SAMPLE_MONO | BASS_SAMPLE_FLOAT)
#define SOUND_XFADETIME_BGM 5000
#define SOUND_XFADETIME_BGM_START 1500
#define SOUND_XFADETIME_ONESHOT 200
#define SOUND_XFADETIME_CUTSOUND 100
#define SOUND_XFADETIME_HIJACKSOUND 50
#define SOUND_BGM_DAMP_COEFFICIENT 0.6f
typedef struct SoundEffectSlot
struct SoundEffectSlot
{
short state;
short effectID;
@ -632,7 +623,7 @@ typedef struct SoundEffectSlot
Vector3 origin;
};
typedef struct SoundTrackSlot
struct SoundTrackSlot
{
HSTREAM channel;
short trackID;
@ -706,7 +697,7 @@ static void CALLBACK Sound_FinishOneshotTrack(HSYNC handle, DWORD channel, DWORD
void Sound_Init();
void Sound_DeInit();
bool Sound_CheckBASSError(char* message, bool verbose, ...);
bool Sound_CheckBASSError(const char* message, bool verbose, ...);
void Sound_UpdateScene();
void Sound_FreeSample(int index);
int Sound_GetFreeSlot();

View file

@ -133,16 +133,12 @@ void Renderer11::FreeRendererData()
DX11_DELETE(m_animatedTextureSets[i]);
free(m_animatedTextureSets);
DX11_DELETE(m_textureAtlas);
DX11_DELETE(m_textureAtlas);
DX11_DELETE(m_skyTexture);
DX11_DELETE(m_roomsVertexBuffer);
DX11_DELETE(m_roomsIndexBuffer);
DX11_DELETE(m_moveablesVertexBuffer);
DX11_DELETE(m_moveablesIndexBuffer);
DX11_DELETE(m_staticsVertexBuffer);
DX11_DELETE(m_staticsIndexBuffer);
}
@ -151,9 +147,14 @@ bool Renderer11::Create()
{
D3D_FEATURE_LEVEL levels[1] = { D3D_FEATURE_LEVEL_10_0 };
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))
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);
// Load caustics
char* causticsNames[NUM_CAUSTICS_TEXTURES] = {
const char* causticsNames[NUM_CAUSTICS_TEXTURES] = {
"CausticsRender_001.bmp",
"CausticsRender_002.bmp",
"CausticsRender_003.bmp",
@ -1554,8 +1555,9 @@ bool Renderer11::drawScene(bool dump)
// Draw binoculars or lasersight
drawOverlays();
ROOM_INFO* r = &Rooms[LaraItem->roomNumber];
m_currentY = 60;
#ifdef _DEBUG
ROOM_INFO* r = &Rooms[LaraItem->roomNumber];
printDebugMessage("Update time: %d", m_timeUpdate);
printDebugMessage("Frame time: %d", m_timeFrame);
@ -1572,6 +1574,7 @@ bool Renderer11::drawScene(bool dump)
printDebugMessage("Lara.requiredAnimState: %d", LaraItem->requiredAnimState);
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);
#endif
}
drawAllStrings();
@ -2597,7 +2600,7 @@ bool Renderer11::PrepareDataForTheRenderer()
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;
@ -2621,7 +2624,7 @@ ID3D11VertexShader* Renderer11::compileVertexShader(char* fileName, char* functi
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;
@ -2645,7 +2648,7 @@ ID3D11PixelShader* Renderer11::compilePixelShader(char* fileName, char* function
return shader;
}
ID3D11GeometryShader* Renderer11::compileGeometryShader(char* fileName)
ID3D11GeometryShader* Renderer11::compileGeometryShader(const char* fileName)
{
HRESULT res;
@ -2664,7 +2667,7 @@ ID3D11GeometryShader* Renderer11::compileGeometryShader(char* fileName)
return shader;
}
ID3D11ComputeShader* Renderer11::compileComputeShader(char* fileName)
ID3D11ComputeShader* Renderer11::compileComputeShader(const char* fileName)
{
HRESULT res;
@ -4633,7 +4636,7 @@ bool Renderer11::printDebugMessage(int x, int y, int alpha, byte r, byte g, byte
return true;
}
void Renderer11::printDebugMessage(char* message, ...)
void Renderer11::printDebugMessage(LPCSTR message, ...)
{
char buffer[255];
ZeroMemory(buffer, 255);

View file

@ -264,7 +264,7 @@ public:
rt->DepthStencilTexture = NULL;
res = device->CreateTexture2D(&depthTexDesc, NULL, &rt->DepthStencilTexture);
if (FAILED(res))
return false;
return NULL;
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
@ -276,7 +276,7 @@ public:
rt->DepthStencilView = NULL;
res = device->CreateDepthStencilView(rt->DepthStencilTexture, &dsvDesc, &rt->DepthStencilView);
if (FAILED(res))
return false;
return NULL;
return rt;
}
@ -347,7 +347,7 @@ public:
return texture;
}
static Texture2D* LoadFromFile(ID3D11Device* device, char* fileName)
static Texture2D* LoadFromFile(ID3D11Device* device, const char* fileName)
{
Texture2D* texture = new Texture2D();
@ -926,10 +926,10 @@ private:
// Private functions
bool drawScene(bool dump);
bool drawAllStrings();
ID3D11VertexShader* compileVertexShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode);
ID3D11GeometryShader* compileGeometryShader(char* fileName);
ID3D11PixelShader* compilePixelShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode);
ID3D11ComputeShader* compileComputeShader(char* fileName);
ID3D11VertexShader* compileVertexShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode);
ID3D11GeometryShader* compileGeometryShader(const char* fileName);
ID3D11PixelShader* compilePixelShader(const char* fileName, const char* function, const char* model, ID3D10Blob** bytecode);
ID3D11ComputeShader* compileComputeShader(const char* fileName);
ID3D11Buffer* createConstantBuffer(int size);
int getAnimatedTextureInfo(short textureId);
void initialiseHairRemaps();
@ -966,7 +966,7 @@ private:
bool drawShadowMap();
bool drawObjectOn2DPosition(short x, short y, short objectNum, short rotX, short rotY, short rotZ);
bool drawLara(bool transparent, bool shadowMap);
void printDebugMessage(char* message, ...);
void printDebugMessage(LPCSTR message, ...);
void drawFires();
void drawSparks();
void drawSmokes();

View file

@ -38,9 +38,9 @@ public:
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)

View file

@ -45,9 +45,7 @@ public:
// TODO: future use for compression
m_stream->Seek(4, SEEK_ORIGIN::CURRENT);
m_emptyChunk = new ChunkId(NULL, 0);
m_isValid = true;
}
@ -56,12 +54,12 @@ public:
delete m_emptyChunk;
}
bool ChunkReader::IsValid()
bool 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
{

View file

@ -47,14 +47,15 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\Build\</OutDir>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(ProjectDir)Libs\bass;$(ProjectDir)Libs\sol2;$(ProjectDir)Libs\lua</IncludePath>
<LibraryPath>$(LibraryPath);$(ProjectDir)Libs\lua;$(DXSDK_DIR)Lib\x86;$(ProjectDir)Libs\bass</LibraryPath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(ProjectDir)Libs\bass</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(ProjectDir)Libs\bass</LibraryPath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
<OutDir>$(ProjectDir)..\Build\Release\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -64,7 +65,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)TR5Main\Libs\sol2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
</ClCompile>
@ -73,7 +74,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<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>
<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>
<PostBuildEvent>
<Command>md "$(TargetDir)\Shaders"
@ -90,7 +91,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<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>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@ -98,9 +99,9 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<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>
<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>
<PostBuildEvent>
<Command>md "$(TargetDir)\Shaders"