diff --git a/TR5Main/Game/box.cpp b/TR5Main/Game/box.cpp index 39774d893..8259e064e 100644 --- a/TR5Main/Game/box.cpp +++ b/TR5Main/Game/box.cpp @@ -12,6 +12,7 @@ #include "camera.h" #include "control.h" #include "../Specific/setup.h" +#include "../Specific/level.h" int NumberBoxes; BOX_INFO* Boxes; diff --git a/TR5Main/Game/bubble.cpp b/TR5Main/Game/bubble.cpp index c162c8d93..32eccad03 100644 --- a/TR5Main/Game/bubble.cpp +++ b/TR5Main/Game/bubble.cpp @@ -1,5 +1,8 @@ #include "bubble.h" +#include "../Specific/level.h" + using namespace std; + extern vector Bubbles = vector(MAX_BUBBLES); void UpdateBubbles() diff --git a/TR5Main/Game/camera.cpp b/TR5Main/Game/camera.cpp index ad6bb08a9..970c1a878 100644 --- a/TR5Main/Game/camera.cpp +++ b/TR5Main/Game/camera.cpp @@ -10,6 +10,7 @@ #include "lara.h" #include "flmtorch.h" #include "sphere.h" +#include "../Specific/level.h" struct OLD_CAMERA { diff --git a/TR5Main/Game/collide.cpp b/TR5Main/Game/collide.cpp index 8572201da..39bc8f8bb 100644 --- a/TR5Main/Game/collide.cpp +++ b/TR5Main/Game/collide.cpp @@ -10,6 +10,7 @@ #include "sphere.h" #include "misc.h" #include "../Specific/setup.h" +#include "../Specific/level.h" char LM[] = { LJ_HIPS, diff --git a/TR5Main/Game/control.cpp b/TR5Main/Game/control.cpp index 1f12d107e..bba773ca4 100644 --- a/TR5Main/Game/control.cpp +++ b/TR5Main/Game/control.cpp @@ -32,7 +32,7 @@ #include "..\Objects\oldobjects.h" #include "footprint.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "..\Specific\input.h" #include "..\Specific\init.h" #include "..\Specific\winmain.h" @@ -65,6 +65,13 @@ short NextItemActive; short NextItemFree; short* TriggerIndex; int DisableLaraControl = 0; +int WeatherType; +int LaraDrawType; +int NumberSoundSources; +OBJECT_VECTOR* SoundSources; +int NumAnimatedTextures; +short* AnimTextureRanges; +int nAnimUVRanges; extern GameFlow* g_GameFlow; extern GameScript* g_GameScript; @@ -444,7 +451,7 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode) unsigned __stdcall GameMain(void*) { - DB_Log(2, "GameMain - DLL"); + //DB_Log(2, "GameMain - DLL"); printf("GameMain\n"); // We still need legacy matrices because control routines use them @@ -472,7 +479,7 @@ unsigned __stdcall GameMain(void*) GAME_STATUS DoTitle(int index) { - DB_Log(2, "DoTitle - DLL"); + //DB_Log(2, "DoTitle - DLL"); printf("DoTitle\n"); CreditsDone = false; @@ -3184,6 +3191,8 @@ void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift) int IsRoomOutside(int x, int y, int z) { + return 0; + short offset = OutsideRoomOffsets[((x >> 12) * 27) + (z >> 12)]; if (offset == -1) return -2; diff --git a/TR5Main/Game/control.h b/TR5Main/Game/control.h index f1a09f291..d8c265e04 100644 --- a/TR5Main/Game/control.h +++ b/TR5Main/Game/control.h @@ -20,6 +20,13 @@ extern short NextItemActive; extern short NextItemFree; extern short* TriggerIndex; extern int DisableLaraControl; +extern int WeatherType; +extern int LaraDrawType; +extern int NumberSoundSources; +extern OBJECT_VECTOR* SoundSources; +extern int NumAnimatedTextures; +extern short* AnimTextureRanges; +extern int nAnimUVRanges; GAME_STATUS DoTitle(int index); GAME_STATUS DoLevel(int index, int ambient, bool loadFromSavegame); diff --git a/TR5Main/Game/debris.cpp b/TR5Main/Game/debris.cpp index ed903c6db..a0c0306b9 100644 --- a/TR5Main/Game/debris.cpp +++ b/TR5Main/Game/debris.cpp @@ -1,5 +1,5 @@ #include "debris.h" -#include "../Specific/roomload.h" +#include "../Specific/level.h" #include "../Specific/setup.h" ShatterImpactInfo ShatterImpactData; diff --git a/TR5Main/Game/deltapak.cpp b/TR5Main/Game/deltapak.cpp index 6aae00f7e..4c2ee3882 100644 --- a/TR5Main/Game/deltapak.cpp +++ b/TR5Main/Game/deltapak.cpp @@ -1,6 +1,7 @@ #include "deltapak.h" #include "..\Global\global.h" #include +#include "../Specific/level.h" ITEM_INFO* FindItem(short objectNumber) { @@ -8,7 +9,7 @@ ITEM_INFO* FindItem(short objectNumber) printf("Called FindItem()\n"); #endif - DB_Log(0, "FindItem - DLL"); + //DB_Log(0, "FindItem - DLL"); if (LevelItems > 0) { diff --git a/TR5Main/Game/door.cpp b/TR5Main/Game/door.cpp index 48a9acc05..8afed884f 100644 --- a/TR5Main/Game/door.cpp +++ b/TR5Main/Game/door.cpp @@ -10,6 +10,7 @@ #include "switch.h" #include "misc.h" #include "Box.h" +#include "../Specific/level.h" PHD_VECTOR DoubleDoorPos = { 0, 0, 220 }; PHD_VECTOR PullDoorPos = { -201, 0, 322 }; diff --git a/TR5Main/Game/draw.cpp b/TR5Main/Game/draw.cpp index b01ef94c9..5721561ca 100644 --- a/TR5Main/Game/draw.cpp +++ b/TR5Main/Game/draw.cpp @@ -2,6 +2,7 @@ #include "Lara.h" #include "..\Renderer\Renderer11.h" #include "camera.h" +#include "../Specific/level.h" BITE_INFO EnemyBites[9] = { diff --git a/TR5Main/Game/effect2.cpp b/TR5Main/Game/effect2.cpp index 56108826e..033316715 100644 --- a/TR5Main/Game/effect2.cpp +++ b/TR5Main/Game/effect2.cpp @@ -5,6 +5,7 @@ #include "math.h" #include "..\Scripting\GameFlowScript.h" #include "../Specific/setup.h" +#include "../Specific/level.h" //long wibble; //long SplashCount; diff --git a/TR5Main/Game/effects.cpp b/TR5Main/Game/effects.cpp index 547ca513a..bdc722de6 100644 --- a/TR5Main/Game/effects.cpp +++ b/TR5Main/Game/effects.cpp @@ -10,7 +10,7 @@ #include "sphere.h" #include "footprint.h" #include "..\Objects\oldobjects.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "debris.h" #include "../Specific/setup.h" #include "camera.h" diff --git a/TR5Main/Game/flmtorch.cpp b/TR5Main/Game/flmtorch.cpp index 7a275edd3..4795818a9 100644 --- a/TR5Main/Game/flmtorch.cpp +++ b/TR5Main/Game/flmtorch.cpp @@ -9,7 +9,7 @@ #include "switch.h" #include "draw.h" #include "items.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" short FireBounds[12] = diff --git a/TR5Main/Game/footprint.cpp b/TR5Main/Game/footprint.cpp index 25758b01f..e03a583ff 100644 --- a/TR5Main/Game/footprint.cpp +++ b/TR5Main/Game/footprint.cpp @@ -3,8 +3,10 @@ #include "lara.h" #include "draw.h" #include "groundfx.h" +#include "../Specific/level.h" std::deque footprints = deque(); + bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition){ int x = item.pos.xPos; int y = item.pos.yPos; diff --git a/TR5Main/Game/gameflow.cpp b/TR5Main/Game/gameflow.cpp index ab47a45c4..3f02807dc 100644 --- a/TR5Main/Game/gameflow.cpp +++ b/TR5Main/Game/gameflow.cpp @@ -4,6 +4,7 @@ #include "..\Specific\input.h" #include "..\Global\global.h" +#include "../Specific/level.h" #include diff --git a/TR5Main/Game/hair.cpp b/TR5Main/Game/hair.cpp index 298b3e4be..3c3ae1208 100644 --- a/TR5Main/Game/hair.cpp +++ b/TR5Main/Game/hair.cpp @@ -5,6 +5,7 @@ #include "..\Scripting\GameFlowScript.h" #include "../Specific/setup.h" #include "sphere.h" +#include "../Specific/level.h" int FirstHair[2]; HAIR_STRUCT Hairs[2][7]; diff --git a/TR5Main/Game/healt.cpp b/TR5Main/Game/healt.cpp index 8ee8d3648..f880a5a96 100644 --- a/TR5Main/Game/healt.cpp +++ b/TR5Main/Game/healt.cpp @@ -3,6 +3,7 @@ #include "pickup.h" #include "lara.h" #include "camera.h" +#include "../Specific/level.h" short PickupX; short PickupY; diff --git a/TR5Main/Game/inventory.cpp b/TR5Main/Game/inventory.cpp index ecbcea366..ea45c3426 100644 --- a/TR5Main/Game/inventory.cpp +++ b/TR5Main/Game/inventory.cpp @@ -14,6 +14,7 @@ #include "..\Specific\configuration.h" #include "lara1gun.h" #include "lara2gun.h" +#include "../Specific/level.h" Inventory* g_Inventory; extern GameFlow* g_GameFlow; @@ -1793,19 +1794,10 @@ bool Inventory::UpdateSceneAndDrawInventory() if (CurrentLevel == 0 && g_GameFlow->TitleType == TITLE_FLYBY) { - // Control routines uses joints calculated here for getting Lara joint positions - CalcLaraMatrices(0); - phd_PushUnitMatrix(); - CalcLaraMatrices(1); - - // Calls my new rock & roll renderer :) g_Renderer->DumpGameScene(); g_Renderer->DrawInventory(); Camera.numberFrames = g_Renderer->SyncRenderer(); - // We need to pop the matrix stack or the game will crash - phd_PopMatrix(); - nframes = Camera.numberFrames; ControlPhase(nframes, 0); } diff --git a/TR5Main/Game/items.cpp b/TR5Main/Game/items.cpp index 5a3c9951f..ad8b4b641 100644 --- a/TR5Main/Game/items.cpp +++ b/TR5Main/Game/items.cpp @@ -3,6 +3,7 @@ #include "effect2.h" #include #include "../Specific/setup.h" +#include "../Specific/level.h" void ClearItem(short itemNum) { diff --git a/TR5Main/Game/lara.cpp b/TR5Main/Game/lara.cpp index ee2d48fa7..476871b41 100644 --- a/TR5Main/Game/lara.cpp +++ b/TR5Main/Game/lara.cpp @@ -21,6 +21,7 @@ #include "..\Objects\newobjects.h" #include "..\Global\global.h" +#include "../Specific/level.h" #include diff --git a/TR5Main/Game/lara1gun.cpp b/TR5Main/Game/lara1gun.cpp index 4d8558497..b49f180fe 100644 --- a/TR5Main/Game/lara1gun.cpp +++ b/TR5Main/Game/lara1gun.cpp @@ -20,7 +20,7 @@ #include "..\Global\global.h" #include "..\Scripting\GameFlowScript.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" #include "bubble.h" @@ -458,9 +458,19 @@ void ControlGrenade(short itemNumber) if (item->speed && aboveWater) { + Matrix world = Matrix::CreateFromYawPitchRoll( + TR_ANGLE_TO_RAD(item->pos.yRot - ANGLE(180)), + TR_ANGLE_TO_RAD(item->pos.xRot), + TR_ANGLE_TO_RAD(item->pos.zRot) + ) * Matrix::CreateTranslation(0, 0, -64); + + int wx = world.Translation().x; + int wy = world.Translation().y; + int wz = world.Translation().z; + // For now keep this legacy math // PHD_MATH - phd_PushUnitMatrix(); + /*phd_PushUnitMatrix(); MatrixPtr[M03] = 0; MatrixPtr[M13] = 0; @@ -473,15 +483,7 @@ void ControlGrenade(short itemNumber) int wy = (MatrixPtr[M13] >> W2V_SHIFT); int wz = (MatrixPtr[M23] >> W2V_SHIFT); - phd_PopMatrix(); - - /*Matrix matrix = Matrix::CreateFromYawPitchRoll( - TR_ANGLE_TO_RAD(item->pos.yRot), - TR_ANGLE_TO_RAD(item->pos.xRot), - TR_ANGLE_TO_RAD(item->pos.zRot) - ); */ - - + phd_PopMatrix();*/ TriggerRocketSmoke(wx + item->pos.xPos, wy + item->pos.yPos, wz + item->pos.zPos, -1); } diff --git a/TR5Main/Game/lara2gun.cpp b/TR5Main/Game/lara2gun.cpp index 98b8de33c..3ddf4f62f 100644 --- a/TR5Main/Game/lara2gun.cpp +++ b/TR5Main/Game/lara2gun.cpp @@ -5,7 +5,7 @@ #include "effect2.h" #include "draw.h" #include "tomb4fx.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "..\Specific\setup.h" #include "camera.h" diff --git a/TR5Main/Game/laraclmb.cpp b/TR5Main/Game/laraclmb.cpp index 1cb69f6e9..d841a99b3 100644 --- a/TR5Main/Game/laraclmb.cpp +++ b/TR5Main/Game/laraclmb.cpp @@ -6,6 +6,7 @@ #include "sphere.h" #include "laramisc.h" #include "camera.h" +#include "..\Specific\level.h" short LeftIntRightExtTab[4] = // offset 0xA0B7C { diff --git a/TR5Main/Game/larafire.cpp b/TR5Main/Game/larafire.cpp index e494a2ad3..a3653e880 100644 --- a/TR5Main/Game/larafire.cpp +++ b/TR5Main/Game/larafire.cpp @@ -14,7 +14,7 @@ #include "draw.h" #include "effect2.h" #include "flmtorch.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "lot.h" #include "../Specific/setup.h" diff --git a/TR5Main/Game/laraflar.cpp b/TR5Main/Game/laraflar.cpp index bec3d41d3..656a8956f 100644 --- a/TR5Main/Game/laraflar.cpp +++ b/TR5Main/Game/laraflar.cpp @@ -1,7 +1,7 @@ #include "laraflar.h" #include "..\Global\global.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "..\Specific\setup.h" #include "draw.h" diff --git a/TR5Main/Game/laramisc.cpp b/TR5Main/Game/laramisc.cpp index cb39f6427..34effafb8 100644 --- a/TR5Main/Game/laramisc.cpp +++ b/TR5Main/Game/laramisc.cpp @@ -1,6 +1,6 @@ #include "laramisc.h" #include "..\Global\global.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" #include "..\Scripting\GameFlowScript.h" #include "effects.h" diff --git a/TR5Main/Game/larasurf.cpp b/TR5Main/Game/larasurf.cpp index 3eedf1a8f..6afdca280 100644 --- a/TR5Main/Game/larasurf.cpp +++ b/TR5Main/Game/larasurf.cpp @@ -10,6 +10,7 @@ #include "laraswim.h" #include "larafire.h" #include "laramisc.h" +#include "..\Specific\level.h" extern void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll); extern void(*lara_collision_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/laraswim.cpp b/TR5Main/Game/laraswim.cpp index 4f385f5d5..b3b141143 100644 --- a/TR5Main/Game/laraswim.cpp +++ b/TR5Main/Game/laraswim.cpp @@ -15,6 +15,7 @@ #include "laramisc.h" #include "draw.h" #include "camera.h" +#include "..\Specific\level.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Game/lot.cpp b/TR5Main/Game/lot.cpp index 91573df96..2060e8a00 100644 --- a/TR5Main/Game/lot.cpp +++ b/TR5Main/Game/lot.cpp @@ -4,6 +4,7 @@ #include #include "../Specific/setup.h" #include "camera.h" +#include "..\Specific\level.h" #define DEFAULT_FLY_UPDOWN_SPEED 16 #define DEFAULT_SWIM_UPDOWN_SPEED 32 @@ -13,7 +14,7 @@ CREATURE_INFO* BaddieSlots; void InitialiseLOTarray(int allocMem) { - DB_Log(0, "InitialiseLOTarray - DLL"); + //DB_Log(0, "InitialiseLOTarray - DLL"); if (allocMem) BaddieSlots = (CREATURE_INFO*)GameMalloc(sizeof(CREATURE_INFO) * NUM_SLOTS); diff --git a/TR5Main/Game/misc.cpp b/TR5Main/Game/misc.cpp index fc92d8d9a..6d85b8824 100644 --- a/TR5Main/Game/misc.cpp +++ b/TR5Main/Game/misc.cpp @@ -1,5 +1,6 @@ #include "misc.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" #define CHK_ANY(var, flag) (var & flag) != 0 #define CHK_NOP(var, flag) !(var & flag) diff --git a/TR5Main/Game/missile.cpp b/TR5Main/Game/missile.cpp index 049dfbce4..5f5516e26 100644 --- a/TR5Main/Game/missile.cpp +++ b/TR5Main/Game/missile.cpp @@ -8,7 +8,7 @@ #include "..\Game\tomb4fx.h" #include #include "debris.h" -#include "../Specific/roomload.h" +#include "../Specific/level.h" #include "../Specific/setup.h" #define SHARD_DAMAGE 30 diff --git a/TR5Main/Game/objects.cpp b/TR5Main/Game/objects.cpp index dd80df6e9..170010cfe 100644 --- a/TR5Main/Game/objects.cpp +++ b/TR5Main/Game/objects.cpp @@ -13,6 +13,7 @@ #include "box.h" #include "../Specific/setup.h" #include "tomb4fx.h" +#include "..\Specific\level.h" int lastWaterfallY = 0; short TightRopeBounds[12] = diff --git a/TR5Main/Game/pickup.cpp b/TR5Main/Game/pickup.cpp index 9722bc004..c4dd959f3 100644 --- a/TR5Main/Game/pickup.cpp +++ b/TR5Main/Game/pickup.cpp @@ -19,6 +19,7 @@ #include "flmtorch.h" #include "../Specific/setup.h" #include "camera.h" +#include "..\Specific\level.h" #include "..\Global\global.h" diff --git a/TR5Main/Game/rope.cpp b/TR5Main/Game/rope.cpp index 99d59ce4a..07fa80408 100644 --- a/TR5Main/Game/rope.cpp +++ b/TR5Main/Game/rope.cpp @@ -2,6 +2,7 @@ #include "..\Global\global.h" #include "draw.h" #include "laramisc.h" +#include "..\Specific\level.h" PENDULUM CurrentPendulum; PENDULUM AlternatePendulum; diff --git a/TR5Main/Game/savegame.cpp b/TR5Main/Game/savegame.cpp index 41a3c8022..f595b817b 100644 --- a/TR5Main/Game/savegame.cpp +++ b/TR5Main/Game/savegame.cpp @@ -12,7 +12,7 @@ #include "..\Objects\newobjects.h" #include "..\Objects\oldobjects.h" #include "..\Game\sound.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" #include "camera.h" diff --git a/TR5Main/Game/sound.cpp b/TR5Main/Game/sound.cpp index c90c9ea93..dc37e2931 100644 --- a/TR5Main/Game/sound.cpp +++ b/TR5Main/Game/sound.cpp @@ -1,6 +1,7 @@ #include "sound.h" #include "camera.h" #include "..\Specific\configuration.h" +#include "..\Specific\level.h" HSTREAM BASS_3D_Mixdown; HFX BASS_FXHandler[NUM_SOUND_FILTERS]; diff --git a/TR5Main/Game/sphere.cpp b/TR5Main/Game/sphere.cpp index f34f435a2..f15115087 100644 --- a/TR5Main/Game/sphere.cpp +++ b/TR5Main/Game/sphere.cpp @@ -1,6 +1,6 @@ #include "sphere.h" #include "draw.h" -#include "../Specific/roomload.h" +#include "../Specific/level.h" #include "../Specific/setup.h" int NumLaraSpheres; diff --git a/TR5Main/Game/switch.cpp b/TR5Main/Game/switch.cpp index cc0223f78..66d24a0dc 100644 --- a/TR5Main/Game/switch.cpp +++ b/TR5Main/Game/switch.cpp @@ -11,6 +11,7 @@ #include "sphere.h" #include "camera.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" byte SequenceUsed[6]; byte SequenceResults[3][3][3]; diff --git a/TR5Main/Game/tomb4fx.cpp b/TR5Main/Game/tomb4fx.cpp index 3a1f4c0c2..b21e86d9e 100644 --- a/TR5Main/Game/tomb4fx.cpp +++ b/TR5Main/Game/tomb4fx.cpp @@ -5,6 +5,7 @@ #include "draw.h" #include "items.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" #include "bubble.h" char FlareTable[121] = @@ -1206,13 +1207,20 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage) short* frame = GetBestFrame(item); + Matrix world = Matrix::CreateFromYawPitchRoll( + TR_ANGLE_TO_RAD(item->pos.yRot), + TR_ANGLE_TO_RAD(item->pos.xRot), + TR_ANGLE_TO_RAD(item->pos.zRot) + ); + + // PHD_MATH: phd_PushUnitMatrix(); MatrixPtr[M03] = 0; MatrixPtr[M13] = 0; MatrixPtr[M23] = 0; - phd_RotYXZ(item->pos.yPos, item->pos.xRot, item->pos.zRot); + phd_RotYXZ(item->pos.yRot, item->pos.xRot, item->pos.zRot); phd_TranslateRel(frame[6], frame[7], frame[8]); short* rotation = &frame[9]; @@ -1227,13 +1235,15 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage) { if (damage & 0x100 || !(GetRandomControl() & 3)) { + Matrix boneMatrix = g_Renderer->GetBoneMatrix(item, 0); + int fxNumber = CreateNewEffect(item->roomNumber); if (fxNumber != NO_ITEM) { FX_INFO* fx = &Effects[fxNumber]; - fx->pos.xPos = item->pos.xPos + (MatrixPtr[M03] >> W2V_SHIFT); - fx->pos.yPos = item->pos.yPos + (MatrixPtr[M13] >> W2V_SHIFT); - fx->pos.zPos = item->pos.zPos + (MatrixPtr[M23] >> W2V_SHIFT); + fx->pos.xPos = item->pos.xPos + boneMatrix.Translation().x; // (MatrixPtr[M03] >> W2V_SHIFT); + fx->pos.yPos = item->pos.yPos + boneMatrix.Translation().y; // (MatrixPtr[M13] >> W2V_SHIFT); + fx->pos.zPos = item->pos.zPos + boneMatrix.Translation().z; // (MatrixPtr[M23] >> W2V_SHIFT); fx->roomNumber = item->roomNumber; fx->pos.yRot = 0; fx->pos.zRot = 0; @@ -1285,42 +1295,20 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage) for (int i = 1; i < obj->nmeshes; i++, bone += 3) { - short popPush = *(bone++); - - if (popPush & 1) - { - MatrixPtr -= 12; - DxMatrixPtr -= 12; - } - else if (popPush & 2) - { - phd_PushMatrix(); - } - - phd_TranslateRel(bone[0], bone[1], bone[2]); - gar_RotYXZsuperpack(&rotation, 0); - - if (popPush & (ROT_X | ROT_Y | ROT_Z)) - { - if (popPush & ROT_Y) - phd_RotY(*(extraRotation++)); - if (popPush & ROT_X) - phd_RotX(*(extraRotation++)); - if (popPush & ROT_Z) - phd_RotZ(*(extraRotation++)); - } - bits <<= 1; if (bits & meshBits && bits & item->meshBits && (damage & 0x100 || !(GetRandomControl() & 3))) { + Matrix boneMatrix = g_Renderer->GetBoneMatrix(item, i); + Matrix matrix = boneMatrix * world; + int fxNumber = CreateNewEffect(item->roomNumber); if (fxNumber != NO_ITEM) { FX_INFO* fx = &Effects[fxNumber]; - fx->pos.xPos = item->pos.xPos + (MatrixPtr[3] >> 14); - fx->pos.yPos = item->pos.yPos + (MatrixPtr[7] >> 14); - fx->pos.zPos = item->pos.zPos + (MatrixPtr[11] >> 14); + fx->pos.xPos = item->pos.xPos + matrix.Translation().x; // (MatrixPtr[3] >> 14); + fx->pos.yPos = item->pos.yPos + matrix.Translation().y; // (MatrixPtr[7] >> 14); + fx->pos.zPos = item->pos.zPos + matrix.Translation().z; // (MatrixPtr[11] >> 14); fx->roomNumber = item->roomNumber; fx->pos.yRot = 0; fx->pos.zRot = 0; @@ -1369,8 +1357,6 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage) } } - phd_PopMatrix(); - return (item->meshBits == 0); } diff --git a/TR5Main/Game/traps.cpp b/TR5Main/Game/traps.cpp index b88f29a37..2f26f4252 100644 --- a/TR5Main/Game/traps.cpp +++ b/TR5Main/Game/traps.cpp @@ -11,6 +11,7 @@ #include "camera.h" #include "objlight.h" #include "draw.h" +#include "..\Specific\level.h" static short CeilingTrapDoorBounds[12] = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820}; static PHD_VECTOR CeilingTrapDoorPos = {0, 1056, -480}; diff --git a/TR5Main/Global/global.h b/TR5Main/Global/global.h index c28ab8d0c..b366e87d0 100644 --- a/TR5Main/Global/global.h +++ b/TR5Main/Global/global.h @@ -22,7 +22,7 @@ using namespace DirectX::SimpleMath; #include "..\Renderer\Renderer11.h" -#define DB_Log ((HWND (__cdecl*)(short, const char*)) 0x004DEB10) +//#define DB_Log ((HWND (__cdecl*)(short, const char*)) 0x004DEB10) #pragma warning(disable:4996) diff --git a/TR5Main/Global/legacyfunctions.h b/TR5Main/Global/legacyfunctions.h index 3fb95745a..c006a4750 100644 --- a/TR5Main/Global/legacyfunctions.h +++ b/TR5Main/Global/legacyfunctions.h @@ -195,6 +195,31 @@ #define Legacy_InitialisePickup ((void (__cdecl*)(short)) 0x0043E260) #define Legacy_PickupControl ((void (__cdecl*)(short)) 0x004679D0) +// ROOMLOAD.CPP +#define Legacy_DoSomethingWithRooms ((void (__cdecl*)()) 0x004774D0) +#define Legacy_FreeItemsStuff ((void (__cdecl*)(int)) 0x00440590) +#define Legacy_InitialiseClosedDoors ((void (__cdecl*)()) 0x00473600) +#define Legacy_CreateSkinningData ((void (__cdecl*)()) 0x00456AE0) +#define Legacy_ProcessMeshData ((void (__cdecl*)(int)) 0x0049A3D0) +#define Legacy_ReadFileEx ((int (__cdecl*)(void*, int, int, FILE*)) 0x004E1D20) +#define Legacy_Decompress ((int (__cdecl*)(byte*, byte*, int, int)) 0x004A3EF0) +#define Legacy_ReadRoomOriginal ((int (__cdecl*)(ROOM_INFO*, ROOM_INFO*)) 0x004917D0) +#define Legacy_ReadRoomsOriginal ((int (__cdecl*)()) 0x004916C0) +#define Legacy_FileOpen ((FILE* (__cdecl*)(char*)) 0x004A3CD0) +#define Legacy_FileClose ((void (__cdecl*)(FILE*)) 0x004A3DA0) +#define Legacy_LoadSoundEffects ((void (__cdecl*)()) 0x004A5D90) +#define Legacy_LoadBoxes ((void (__cdecl*)()) 0x004A5E50) +#define Legacy_LoadAnimatedTextures ((void (__cdecl*)()) 0x004A6060) +#define Legacy_LoadTextureInfos ((void (__cdecl*)()) 0x004A60E0) +#define Legacy_LoadAIObjects ((void (__cdecl*)()) 0x004A67F0) +#define Legacy_LoadDemoData ((void (__cdecl*)()) 0x004A67D0) +#define Legacy_LoadSamples ((void (__cdecl*)()) 0x004A6880) +#define Legacy_InitialiseLaraLoad ((void (__cdecl*)(short)) 0x004568C0) +#define Legacy_LoadRooms ((void (__cdecl*)()) 0x004A4DA0) +#define Legacy_InitialiseGameStuff ((void (__cdecl*)()) 0x004778F0) +#define Legacy_InitialiseLaraMeshes ((void (__cdecl*)()) 0x00455680) +#define Legacy_InitialiseLaraAnims ((void (__cdecl*)(ITEM_INFO*)) 0x00456900) + // ROPE.CPP #define Legacy_CalculateRopePoints ((void (__cdecl*)(ROPE_STRUCT*)) 0x0046EC70) diff --git a/TR5Main/Global/malloc.cpp b/TR5Main/Global/malloc.cpp index d14c995a1..a8cc003ac 100644 --- a/TR5Main/Global/malloc.cpp +++ b/TR5Main/Global/malloc.cpp @@ -24,7 +24,7 @@ char* GameMalloc(int size) int memSize = (size + 3) & -4; if (memSize > MallocFree) { - DB_Log(0, "Out of memory"); + //DB_Log(0, "Out of memory"); return NULL; } else diff --git a/TR5Main/Global/vars.h b/TR5Main/Global/vars.h index c1a495290..3901a96dc 100644 --- a/TR5Main/Global/vars.h +++ b/TR5Main/Global/vars.h @@ -10,32 +10,32 @@ #define MallocPtr VAR_U_(0x00E4B0DC, char*) #define MallocFree VAR_U_(0x00E4B0F4, int) #define MallocUsed VAR_U_(0x00E4B0F0, int) -#define Items VAR_U_(0x00EEEFF0, ITEM_INFO*) +//#define Items VAR_U_(0x00EEEFF0, ITEM_INFO*) #define Effects VAR_U_(0x00E5C5E0, FX_INFO*) -#define nAIObjects VAR_U_(0x00E5B842, short) -#define LevelItems VAR_U_(0x0051CEB8, int) -#define AIObjects VAR_U_(0x00E5B844, AIOBJECT*) -#define Rooms VAR_U_(0x00875154, ROOM_INFO*) -#define Anims VAR_U_(0x00875158, ANIM_STRUCT*) -#define Bones VAR_U_(0x00875178, int*) -#define Changes VAR_U_(0x0087515C, CHANGE_STRUCT*) -#define Ranges VAR_U_(0x00875160, RANGE_STRUCT*) -#define Frames VAR_U_(0x00875174, short*) -#define Commands VAR_U_(0x0087517C, short*) -#define MeshesCount VAR_U_(0x00875140, int) -#define AnimationsCount VAR_U_(0x00875150, int) -#define FloorData VAR_U_(0x00875168, short*) -#define ObjectTextures VAR_U_(0x008751B0, OBJECT_TEXTURE*) -#define RoomLightsCount VAR_U_(0x0087B0EC, int) -#define NumberRooms VAR_U_(0x0087514C, short) -#define nAnimUVRanges VAR_U_(0x0087495C, int) -#define LevelFilePtr VAR_U_(0x00875164, FILE*) +//#define nAIObjects VAR_U_(0x00E5B842, short) +//#define LevelItems VAR_U_(0x0051CEB8, int) +//#define AIObjects VAR_U_(0x00E5B844, AIOBJECT*) +//#define Rooms VAR_U_(0x00875154, ROOM_INFO*) +//#define Anims VAR_U_(0x00875158, ANIM_STRUCT*) +//#define Bones VAR_U_(0x00875178, int*) +//#define Changes VAR_U_(0x0087515C, CHANGE_STRUCT*) +//#define Ranges VAR_U_(0x00875160, RANGE_STRUCT*) +//#define Frames VAR_U_(0x00875174, short*) +//#define Commands VAR_U_(0x0087517C, short*) +//#define MeshesCount VAR_U_(0x00875140, int) +//#define AnimationsCount VAR_U_(0x00875150, int) +//#define FloorData VAR_U_(0x00875168, short*) +//#define ObjectTextures VAR_U_(0x008751B0, OBJECT_TEXTURE*) +//#define RoomLightsCount VAR_U_(0x0087B0EC, int) +//#define NumberRooms VAR_U_(0x0087514C, short) +//#define nAnimUVRanges VAR_U_(0x0087495C, int) +//#define LevelFilePtr VAR_U_(0x00875164, FILE*) //#define NumberCameras VAR_U_(0x00EEFAC0, int) //#define Cameras VAR_U_(0x00EEF9A2, OBJECT_VECTOR*) #define LaraItem VAR_U_(0x00E5BF08, ITEM_INFO*) #define Lara VAR_U_(0x00E5BD60, LARA_INFO) -#define LaraDrawType VAR_U_(0x00EEEAD0, char) -#define Frames VAR_U_(0x00875174, short*) +//#define LaraDrawType VAR_U_(0x00EEEAD0, char) +//#define Frames VAR_U_(0x00875174, short*) #define SetDebounce VAR_U_(0x00EEEA38, int) #define WindowsHandle VAR_U_(0x00D9AB3C, HWND) #define SoundActive VAR_U_(0x0051D004, int) @@ -60,12 +60,12 @@ #define CurrentAtmosphere VAR_U_(0x00EEEB90, byte) #define GlobalMusicVolume VAR_U_(0x00517B68, unsigned int) #define GlobalFXVolume VAR_U_(0x00517B6C, unsigned int) -#define gfFilenameOffset VAR_U_(0x00E5C34C, short*) -#define gfFilenameWad VAR_U_(0x00E5C2CC, char*) -#define AllStrings VAR_U_(0x00E5C310, char*) -#define AllStringsOffsets VAR_U_(0x00E5C2B8, short*) +//#define gfFilenameOffset VAR_U_(0x00E5C34C, short*) +//#define gfFilenameWad VAR_U_(0x00E5C2CC, char*) +//#define AllStrings VAR_U_(0x00E5C310, char*) +//#define AllStringsOffsets VAR_U_(0x00E5C2B8, short*) #define RenderLoadBar VAR_U_(0x008FBDC0, int) -#define WeatherType VAR_U_(0x00EEF4A0, byte) +//#define WeatherType VAR_U_(0x00EEF4A0, byte) #define CreditsDone VAR_U_(0x00E6D838, byte) #define CanLoad VAR_U_(0x0051CE54, byte) #define Savegame VAR_U_(0x00E52EB3, SAVEGAME_INFO) diff --git a/TR5Main/Libs/zlib/dll16/zlib16.lib b/TR5Main/Libs/zlib/dll16/zlib16.lib new file mode 100644 index 000000000..f6982b5b5 Binary files /dev/null and b/TR5Main/Libs/zlib/dll16/zlib16.lib differ diff --git a/TR5Main/Libs/zlib/dll32/zlib.lib b/TR5Main/Libs/zlib/dll32/zlib.lib new file mode 100644 index 000000000..8d4557a6b Binary files /dev/null and b/TR5Main/Libs/zlib/dll32/zlib.lib differ diff --git a/TR5Main/Libs/zlib/dll32/zlib_bor.lib b/TR5Main/Libs/zlib/dll32/zlib_bor.lib new file mode 100644 index 000000000..312e34947 Binary files /dev/null and b/TR5Main/Libs/zlib/dll32/zlib_bor.lib differ diff --git a/TR5Main/Libs/zlib/ioapi.h b/TR5Main/Libs/zlib/ioapi.h new file mode 100644 index 000000000..19b301006 --- /dev/null +++ b/TR5Main/Libs/zlib/ioapi.h @@ -0,0 +1,64 @@ +/* ioapi.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 0.18 beta, Feb 26th, 2002 + + Copyright (C) 1998-2002 Gilles Vollant +*/ + +#ifndef _ZLIBIOAPI_H +#define _ZLIBIOAPI_H + + +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) +#define ZLIB_FILEFUNC_SEEK_SET (0) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + + +#ifndef ZCALLBACK + +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) +#define ZCALLBACK CALLBACK +#else +#define ZCALLBACK +#endif +#endif + +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); +typedef long (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +typedef struct zlib_filefunc_def_s +{ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc_def; + + + +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) +#endif diff --git a/TR5Main/Libs/zlib/readme.txt b/TR5Main/Libs/zlib/readme.txt new file mode 100644 index 000000000..226ee2136 --- /dev/null +++ b/TR5Main/Libs/zlib/readme.txt @@ -0,0 +1,11 @@ +dll16\zlib16.dll : The 16 bits DLL of ZLib 1.14 +dll16\zlib16.lib : The 16 bits import library for the DLL of ZLib 1.14 +dll32\zlib.dll : The 32 bits DLL of ZLib 1.14 +dll32\zlib.lib : The 32 bits import library for the DLL of ZLib 1.14 +static32\zlibstat.lib : The 32 bits statis library of zLib 1.14 for Visual C++ +dll32\zlib_bor.lib : The 32 bits import library for the DLL of ZLib 1.14 for Borland C++ + +I also include a version of zconf.h which must replace the version from zlib114.zip +The zlib.h included is the same version than in zlib114.zip + +I've also added unzip.h and zip.h (please visit http://www.winimage.com/zLibDll/unzip.html ) diff --git a/TR5Main/Libs/zlib/static32/zlibstat.lib b/TR5Main/Libs/zlib/static32/zlibstat.lib new file mode 100644 index 000000000..7fcf0fef0 Binary files /dev/null and b/TR5Main/Libs/zlib/static32/zlibstat.lib differ diff --git a/TR5Main/Libs/zlib/unzip.h b/TR5Main/Libs/zlib/unzip.h new file mode 100644 index 000000000..20ee2d55e --- /dev/null +++ b/TR5Main/Libs/zlib/unzip.h @@ -0,0 +1,300 @@ +/* unzip.h -- IO for uncompress .zip files using zlib + Version 0.18 beta, Feb 26th, 2002 + + Copyright (C) 1998-2002 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE + CAN CHANGE IN FUTURE VERSION !! + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef _unz_H +#define _unz_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info_s +{ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT unzOpen OF((const char *path)); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer + "zlib/zlib113.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ + +extern unzFile ZEXPORT unzOpen2 OF((const char *path, + zlib_filefunc_def* pzlib_filefunc_def)); +/* + Open a Zip file, like unzOpen, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + +extern int ZEXPORT unzClose OF((unzFile file)); +/* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, + int* method, + int* level, + int raw)); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + +extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT unztell OF((unzFile file)); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT unzeof OF((unzFile file)); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _unz_H */ diff --git a/TR5Main/Libs/zlib/zconf.h b/TR5Main/Libs/zlib/zconf.h new file mode 100644 index 000000000..3683a2c20 --- /dev/null +++ b/TR5Main/Libs/zlib/zconf.h @@ -0,0 +1,292 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x460) +# define NEED_DUMMY_RETURN +#endif +#if defined(__TURBOC__) && !defined(__BORLANDC__) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +#if defined(WIN32) && (!defined(ZLIB_WIN32_NODLL)) && (!defined(ZLIB_DLL)) +# define ZLIB_DLL +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) +# ifndef WINAPI +# ifdef FAR +# undef FAR +# endif +# include +# endif +# ifdef WIN32 +# define ZEXPORT WINAPI +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORT WINAPI _export +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/TR5Main/Libs/zlib/zip.h b/TR5Main/Libs/zlib/zip.h new file mode 100644 index 000000000..0e9d3dacc --- /dev/null +++ b/TR5Main/Libs/zlib/zip.h @@ -0,0 +1,188 @@ +/* zip.h -- IO for compress .zip files using zlib + Version 0.18 beta, Feb 26th, 2002 + + Copyright (C) 1998-2002 Gilles Vollant + + This unzip package allow creates .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + For uncompress .zip file, look at unzip.h + + THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE + CAN CHANGE IN FUTURE VERSION !! + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.html for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef _zip_H +#define _zip_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { int unused; } zipFile__; +typedef zipFile__ *zipFile; +#else +typedef voidp zipFile; +#endif + +#define ZIP_OK (0) +#define ZIP_ERRNO (Z_ERRNO) +#define ZIP_PARAMERROR (-102) +#define ZIP_INTERNALERROR (-104) + +/* tm_zip contain date/time info */ +typedef struct tm_zip_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_zip; + +typedef struct +{ + tm_zip tmz_date; /* date in understandable format */ + uLong dosDate; /* if dos_date == 0, tmu_date is used */ +/* uLong flag; */ /* general purpose bit flag 2 bytes */ + + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +typedef const char* zipcharpc; + + +extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); +/* + Create a zipfile. + pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on + an Unix computer "zlib/zlib113.zip". + if the file pathname exist and append=1, the zip will be created at the end + of the file. (useful if the file contain a self extractor code) + If the zipfile cannot be opened, the return value is NULL. + Else, the return value is a zipFile Handle, usable with other function + of this zip package. +*/ + +extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def)); + +extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level)); +/* + Open a file in the ZIP for writing. + filename : the filename in zip (if NULL, '-' without quote will be used + *zipfi contain supplemental information + if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local + contains the extrafield data the the local header + if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global + contains the extrafield data the the local header + if comment != NULL, comment contain the comment string + method contain the compression method (0 for store, Z_DEFLATED for deflate) + level contain the level of compression (can be Z_DEFAULT_COMPRESSION) +*/ + + +extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw)); + +/* + Same than zipOpenNewFileInZip, except if raw=1, we write raw file + */ + +extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, + const voidp buf, + unsigned len)); +/* + Write data in the zipfile +*/ + +extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); +/* + Close the current file in the zipfile +*/ + + +extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, + uLong uncompressed_size, + uLong crc32)); +/* + Close the current file in the zipfile, for fiel opened with + parameter raw=1 in zipOpenNewFileInZip2 + uncompressed_size and crc32 are value for the uncompressed size +*/ + +extern int ZEXPORT zipClose OF((zipFile file, + const char* global_comment)); +/* + Close the zipfile +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _zip_H */ diff --git a/TR5Main/Libs/zlib/zlib.h b/TR5Main/Libs/zlib/zlib.h new file mode 100644 index 000000000..52cb529f6 --- /dev/null +++ b/TR5Main/Libs/zlib/zlib.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.4" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/TR5Main/Objects/Effects/tr4_bubbles.cpp b/TR5Main/Objects/Effects/tr4_bubbles.cpp index 2fc9f4f90..5d9990ef0 100644 --- a/TR5Main/Objects/Effects/tr4_bubbles.cpp +++ b/TR5Main/Objects/Effects/tr4_bubbles.cpp @@ -6,7 +6,7 @@ #include "../../Game/draw.h" #include "../../Game/tomb4fx.h" #include "../../Game/effects.h" -#include "..\..\Specific\roomload.h" +#include "..\..\Specific\level.h" void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel) { diff --git a/TR5Main/Objects/TR1/tr1_ape.cpp b/TR5Main/Objects/TR1/tr1_ape.cpp index 70adbff3d..24f45c2c8 100644 --- a/TR5Main/Objects/TR1/tr1_ape.cpp +++ b/TR5Main/Objects/TR1/tr1_ape.cpp @@ -2,6 +2,7 @@ #include "../../Game/box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO apeBite = { 0, -19, 75, 15 }; diff --git a/TR5Main/Objects/TR1/tr1_bear.cpp b/TR5Main/Objects/TR1/tr1_bear.cpp index 9c64e214a..05844ad82 100644 --- a/TR5Main/Objects/TR1/tr1_bear.cpp +++ b/TR5Main/Objects/TR1/tr1_bear.cpp @@ -2,6 +2,7 @@ #include "../../Game/box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO bearBite = { 0, 96, 335, 14 }; diff --git a/TR5Main/Objects/TR1/tr1_lara_evil.cpp b/TR5Main/Objects/TR1/tr1_lara_evil.cpp index bdc2bb1c6..81ac802f7 100644 --- a/TR5Main/Objects/TR1/tr1_lara_evil.cpp +++ b/TR5Main/Objects/TR1/tr1_lara_evil.cpp @@ -3,6 +3,7 @@ #include "../../Game/items.h" #include "../../Game/larafire.h" #include "../../Game/misc.h" +#include "..\..\Specific\level.h" // TODO: Evil lara is not targetable and cant move like lara. diff --git a/TR5Main/Objects/TR1/tr1_larson.cpp b/TR5Main/Objects/TR1/tr1_larson.cpp index 481a93803..7b9b78693 100644 --- a/TR5Main/Objects/TR1/tr1_larson.cpp +++ b/TR5Main/Objects/TR1/tr1_larson.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/people.h" #include "../../Specific/setup.h" +#include "../../Specific/level.h" enum LARSON_STATE { PEOPLE_EMPTY, PEOPLE_STOP, PEOPLE_WALK, PEOPLE_RUN, PEOPLE_AIM, diff --git a/TR5Main/Objects/TR1/tr1_natla.cpp b/TR5Main/Objects/TR1/tr1_natla.cpp index abc3fe4c8..e78d9a604 100644 --- a/TR5Main/Objects/TR1/tr1_natla.cpp +++ b/TR5Main/Objects/TR1/tr1_natla.cpp @@ -3,6 +3,7 @@ #include "../../Game/people.h" #include "../../Game/items.h" #include "../../Game/missile.h" +#include "..\..\Specific\level.h" /* HIT POINTS for Natla when she enters her second stage */ #define NATLA_NEAR_DEATH 200 diff --git a/TR5Main/Objects/TR1/tr1_natla_evil.cpp b/TR5Main/Objects/TR1/tr1_natla_evil.cpp index 50ce06bce..19b3880c7 100644 --- a/TR5Main/Objects/TR1/tr1_natla_evil.cpp +++ b/TR5Main/Objects/TR1/tr1_natla_evil.cpp @@ -5,6 +5,7 @@ #include "../../Game/camera.h" #include "../../Specific/setup.h" #include "../../Game/tomb4fx.h" +#include "..\..\Specific\level.h" enum abortion_anims { ABORT_EMPTY, ABORT_STOP, ABORT_TURNL, ABORT_TURNR, ABORT_ATTACK1, ABORT_ATTACK2, diff --git a/TR5Main/Objects/TR1/tr1_pierre.cpp b/TR5Main/Objects/TR1/tr1_pierre.cpp index a50ed0eef..d1116293b 100644 --- a/TR5Main/Objects/TR1/tr1_pierre.cpp +++ b/TR5Main/Objects/TR1/tr1_pierre.cpp @@ -5,6 +5,7 @@ #include "../../Game/lot.h" #include "../../specific/setup.h" #include "..\..\Game\camera.h" +#include "..\..\Specific\level.h" enum PIERRE_STATE { PEOPLE_EMPTY, PEOPLE_STOP, PEOPLE_WALK, PEOPLE_RUN, PEOPLE_AIM, diff --git a/TR5Main/Objects/TR1/tr1_raptor.cpp b/TR5Main/Objects/TR1/tr1_raptor.cpp index 126669b16..4b6743046 100644 --- a/TR5Main/Objects/TR1/tr1_raptor.cpp +++ b/TR5Main/Objects/TR1/tr1_raptor.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" enum RAPTOR_STATE { diff --git a/TR5Main/Objects/TR1/tr1_wolf.cpp b/TR5Main/Objects/TR1/tr1_wolf.cpp index 0d7f554f2..43e8cbb82 100644 --- a/TR5Main/Objects/TR1/tr1_wolf.cpp +++ b/TR5Main/Objects/TR1/tr1_wolf.cpp @@ -3,6 +3,7 @@ #include "../../Game/box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO wolfBite = { 0, -14, 174, 6 }; diff --git a/TR5Main/Objects/TR2/tr2_barracuda.cpp b/TR5Main/Objects/TR2/tr2_barracuda.cpp index d631aa6f5..e5427e31d 100644 --- a/TR5Main/Objects/TR2/tr2_barracuda.cpp +++ b/TR5Main/Objects/TR2/tr2_barracuda.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO barracudaBite = { 2, -60, 121, 7 }; diff --git a/TR5Main/Objects/TR2/tr2_birdmonster.cpp b/TR5Main/Objects/TR2/tr2_birdmonster.cpp index c386214ff..69461e010 100644 --- a/TR5Main/Objects/TR2/tr2_birdmonster.cpp +++ b/TR5Main/Objects/TR2/tr2_birdmonster.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO birdyBiteL = { 0, 224, 0, 19 }; BITE_INFO birdyBiteR = { 0, 224, 0, 22 }; diff --git a/TR5Main/Objects/TR2/tr2_dragon.cpp b/TR5Main/Objects/TR2/tr2_dragon.cpp index 37a4b53bd..cb061445a 100644 --- a/TR5Main/Objects/TR2/tr2_dragon.cpp +++ b/TR5Main/Objects/TR2/tr2_dragon.cpp @@ -7,7 +7,7 @@ #include "../../Game/lot.h" #include "../../Game/sphere.h" #include "../../Game/camera.h" -#include "../../Specific/roomload.h" +#include "../../Specific/level.h" #include "../../specific/setup.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Objects/TR2/tr2_knifethrower.cpp b/TR5Main/Objects/TR2/tr2_knifethrower.cpp index d834ef69c..c246f9fb0 100644 --- a/TR5Main/Objects/TR2/tr2_knifethrower.cpp +++ b/TR5Main/Objects/TR2/tr2_knifethrower.cpp @@ -4,6 +4,7 @@ #include "../../Game/Box.h" #include "../../Game/people.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO knifeLeft = { 0, 0, 0, 5 }; BITE_INFO knifeRight = { 0, 0, 0, 8 }; diff --git a/TR5Main/Objects/TR2/tr2_mercenary.cpp b/TR5Main/Objects/TR2/tr2_mercenary.cpp index d73858009..ea6e0f795 100644 --- a/TR5Main/Objects/TR2/tr2_mercenary.cpp +++ b/TR5Main/Objects/TR2/tr2_mercenary.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/people.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO mercUziBite = { 0, 150, 19, 17 }; BITE_INFO mercAutoPistolBite = { 0, 230, 9, 17 }; diff --git a/TR5Main/Objects/TR2/tr2_monk.cpp b/TR5Main/Objects/TR2/tr2_monk.cpp index 1ff001aea..418c49179 100644 --- a/TR5Main/Objects/TR2/tr2_monk.cpp +++ b/TR5Main/Objects/TR2/tr2_monk.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO monkBite = { -23,16,265, 14 }; diff --git a/TR5Main/Objects/TR2/tr2_rat.cpp b/TR5Main/Objects/TR2/tr2_rat.cpp index 5b13955a1..e6d0cd5b6 100644 --- a/TR5Main/Objects/TR2/tr2_rat.cpp +++ b/TR5Main/Objects/TR2/tr2_rat.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO ratBite = { 0, 0, 57, 2 }; diff --git a/TR5Main/Objects/TR2/tr2_shark.cpp b/TR5Main/Objects/TR2/tr2_shark.cpp index 924bb8840..6d5e3df26 100644 --- a/TR5Main/Objects/TR2/tr2_shark.cpp +++ b/TR5Main/Objects/TR2/tr2_shark.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO sharkBite = { 17, -22, 344, 12 }; diff --git a/TR5Main/Objects/TR2/tr2_silencer.cpp b/TR5Main/Objects/TR2/tr2_silencer.cpp index 9b074c636..29c4a82c3 100644 --- a/TR5Main/Objects/TR2/tr2_silencer.cpp +++ b/TR5Main/Objects/TR2/tr2_silencer.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/people.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO silencerGun = { 3, 331, 56, 10 }; diff --git a/TR5Main/Objects/TR2/tr2_skidman.cpp b/TR5Main/Objects/TR2/tr2_skidman.cpp index 2d76bda97..3f9f507c9 100644 --- a/TR5Main/Objects/TR2/tr2_skidman.cpp +++ b/TR5Main/Objects/TR2/tr2_skidman.cpp @@ -7,6 +7,7 @@ #include "../../Game/people.h" #include "../../Game/sphere.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Objects/TR2/tr2_spear_guardian.cpp b/TR5Main/Objects/TR2/tr2_spear_guardian.cpp index e470cdc65..541f40b9b 100644 --- a/TR5Main/Objects/TR2/tr2_spear_guardian.cpp +++ b/TR5Main/Objects/TR2/tr2_spear_guardian.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO spearLeftBite = { 0, 0, 920, 11 }; BITE_INFO spearRightBite = { 0, 0, 920, 18 }; diff --git a/TR5Main/Objects/TR2/tr2_spider.cpp b/TR5Main/Objects/TR2/tr2_spider.cpp index 7b85325b8..7c4492abe 100644 --- a/TR5Main/Objects/TR2/tr2_spider.cpp +++ b/TR5Main/Objects/TR2/tr2_spider.cpp @@ -7,6 +7,7 @@ #include "../../Game/lot.h" #include "../../specific/setup.h" #include "../../Game/tomb4fx.h" +#include "..\..\Specific\level.h" BITE_INFO spiderBite = { 0, 0, 41, 1 }; diff --git a/TR5Main/Objects/TR2/tr2_sword_guardian.cpp b/TR5Main/Objects/TR2/tr2_sword_guardian.cpp index 3cfd2bff1..51eb2af84 100644 --- a/TR5Main/Objects/TR2/tr2_sword_guardian.cpp +++ b/TR5Main/Objects/TR2/tr2_sword_guardian.cpp @@ -5,6 +5,7 @@ #include "../../Game/effect2.h" #include "../../Game/items.h" #include "../../Game/tomb4fx.h" +#include "..\..\Specific\level.h" BITE_INFO swordBite = { 0, 37, 550, 15 }; diff --git a/TR5Main/Objects/TR2/tr2_worker_dualrevolver.cpp b/TR5Main/Objects/TR2/tr2_worker_dualrevolver.cpp index 624efeba1..a03e82519 100644 --- a/TR5Main/Objects/TR2/tr2_worker_dualrevolver.cpp +++ b/TR5Main/Objects/TR2/tr2_worker_dualrevolver.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/people.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO workerDualGunL = { -2, 275, 23, 6 }; BITE_INFO workerDualGunR = { 2, 275, 23, 10 }; diff --git a/TR5Main/Objects/TR2/tr2_worker_flamethrower.cpp b/TR5Main/Objects/TR2/tr2_worker_flamethrower.cpp index 6f9a60677..789cbbc87 100644 --- a/TR5Main/Objects/TR2/tr2_worker_flamethrower.cpp +++ b/TR5Main/Objects/TR2/tr2_worker_flamethrower.cpp @@ -7,6 +7,7 @@ #include "../../Game/missile.h" #include "../../Game/tomb4fx.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO workerFlameThrower = { 0, 250, 32, 9 }; diff --git a/TR5Main/Objects/TR2/tr2_worker_machinegun.cpp b/TR5Main/Objects/TR2/tr2_worker_machinegun.cpp index 03e14f426..f715bdff3 100644 --- a/TR5Main/Objects/TR2/tr2_worker_machinegun.cpp +++ b/TR5Main/Objects/TR2/tr2_worker_machinegun.cpp @@ -3,6 +3,7 @@ #include "../../Game/Box.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO workerMachineGun = { 0, 308, 32, 9 }; diff --git a/TR5Main/Objects/TR2/tr2_worker_shotgun.cpp b/TR5Main/Objects/TR2/tr2_worker_shotgun.cpp index 734573fbb..787f5fa55 100644 --- a/TR5Main/Objects/TR2/tr2_worker_shotgun.cpp +++ b/TR5Main/Objects/TR2/tr2_worker_shotgun.cpp @@ -3,6 +3,7 @@ #include "../../Game/people.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "../../specific/level.h" BITE_INFO workerShotgun = { 0, 281, 40, 9 }; diff --git a/TR5Main/Objects/TR2/tr2_yeti.cpp b/TR5Main/Objects/TR2/tr2_yeti.cpp index 133b0ad1d..beb6bc93c 100644 --- a/TR5Main/Objects/TR2/tr2_yeti.cpp +++ b/TR5Main/Objects/TR2/tr2_yeti.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO yetiBiteR = { 12, 101, 19, 10 }; BITE_INFO yetiBiteL = { 12, 101, 19, 13 }; diff --git a/TR5Main/Objects/TR3/tr3_civvy.cpp b/TR5Main/Objects/TR3/tr3_civvy.cpp index 81c8d8fce..631e060c5 100644 --- a/TR5Main/Objects/TR3/tr3_civvy.cpp +++ b/TR5Main/Objects/TR3/tr3_civvy.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/people.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO civvy_hit = { 0,0,0, 13 }; diff --git a/TR5Main/Objects/TR3/tr3_cobra.cpp b/TR5Main/Objects/TR3/tr3_cobra.cpp index 337d1f0f9..6d3ffb8a6 100644 --- a/TR5Main/Objects/TR3/tr3_cobra.cpp +++ b/TR5Main/Objects/TR3/tr3_cobra.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO cobraBite = { 0, 0, 0, 13 }; diff --git a/TR5Main/Objects/TR3/tr3_eagle_or_crow.cpp b/TR5Main/Objects/TR3/tr3_eagle_or_crow.cpp index 98a7b4e6a..5443a0a49 100644 --- a/TR5Main/Objects/TR3/tr3_eagle_or_crow.cpp +++ b/TR5Main/Objects/TR3/tr3_eagle_or_crow.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO eagleBite = { 15, 46, 21, 6 }; BITE_INFO crowBite = { 2, 10, 60, 14 }; diff --git a/TR5Main/Objects/TR3/tr3_fishemitter.cpp b/TR5Main/Objects/TR3/tr3_fishemitter.cpp index 78fc5eca5..dc595be0f 100644 --- a/TR5Main/Objects/TR3/tr3_fishemitter.cpp +++ b/TR5Main/Objects/TR3/tr3_fishemitter.cpp @@ -1,6 +1,7 @@ #include "../newobjects.h" #include "../../Game/effects.h" #include "../../Game/draw.h" +#include "..\..\Specific\level.h" #define PIRAHNA_DAMAGE 4 #define X 0 diff --git a/TR5Main/Objects/TR3/tr3_flamethrower.cpp b/TR5Main/Objects/TR3/tr3_flamethrower.cpp index accb6ce2c..b9d9798b1 100644 --- a/TR5Main/Objects/TR3/tr3_flamethrower.cpp +++ b/TR5Main/Objects/TR3/tr3_flamethrower.cpp @@ -7,6 +7,7 @@ #include "../../Game/draw.h" #include "../../specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO flamerBite = { 0, 340, 64, 7 }; diff --git a/TR5Main/Objects/TR3/tr3_monkey.cpp b/TR5Main/Objects/TR3/tr3_monkey.cpp index 37d05733e..19a273969 100644 --- a/TR5Main/Objects/TR3/tr3_monkey.cpp +++ b/TR5Main/Objects/TR3/tr3_monkey.cpp @@ -5,6 +5,7 @@ #include "../../Game/items.h" #include "../../specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO monkeyBite = { 10, 10, 11, 13 }; diff --git a/TR5Main/Objects/TR3/tr3_mpgun.cpp b/TR5Main/Objects/TR3/tr3_mpgun.cpp index ebbb3e54f..648170d1e 100644 --- a/TR5Main/Objects/TR3/tr3_mpgun.cpp +++ b/TR5Main/Objects/TR3/tr3_mpgun.cpp @@ -6,6 +6,7 @@ #include "../../Game/people.h" #include "../../specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" enum MPGUN_STATES { MPGUN_EMPTY, diff --git a/TR5Main/Objects/TR3/tr3_mpstick.cpp b/TR5Main/Objects/TR3/tr3_mpstick.cpp index 5280ef4d5..f58f87145 100644 --- a/TR5Main/Objects/TR3/tr3_mpstick.cpp +++ b/TR5Main/Objects/TR3/tr3_mpstick.cpp @@ -5,6 +5,7 @@ #include "../../Game/items.h" #include "../../specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO mpstickBite1 = { 247, 10, 11, 13 }; BITE_INFO mpstickBite2 = { 0, 0, 100, 6 }; diff --git a/TR5Main/Objects/TR3/tr3_raptor.cpp b/TR5Main/Objects/TR3/tr3_raptor.cpp index 4d2ffda2a..57e90040c 100644 --- a/TR5Main/Objects/TR3/tr3_raptor.cpp +++ b/TR5Main/Objects/TR3/tr3_raptor.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" extern BITE_INFO raptorBite; diff --git a/TR5Main/Objects/TR3/tr3_scuba.cpp b/TR5Main/Objects/TR3/tr3_scuba.cpp index 74b6d1d79..0a85ca5f0 100644 --- a/TR5Main/Objects/TR3/tr3_scuba.cpp +++ b/TR5Main/Objects/TR3/tr3_scuba.cpp @@ -3,6 +3,7 @@ #include "../../Game/effects.h" #include "../../Game/Box.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO scubaGun = { 17, 164, 44, 18 }; diff --git a/TR5Main/Objects/TR3/tr3_shiva.cpp b/TR5Main/Objects/TR3/tr3_shiva.cpp index b5bd686a6..f1b2e2108 100644 --- a/TR5Main/Objects/TR3/tr3_shiva.cpp +++ b/TR5Main/Objects/TR3/tr3_shiva.cpp @@ -5,6 +5,7 @@ #include "../../Game/sphere.h" #include "../../Game/items.h" #include "../../specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO shivaLeftBite = { 0, 0, 920, 13 }; BITE_INFO shivaRightBite = { 0, 0, 920, 22 }; diff --git a/TR5Main/Objects/TR3/tr3_sophia.cpp b/TR5Main/Objects/TR3/tr3_sophia.cpp index 8b9913dd3..ab1b6b8d0 100644 --- a/TR5Main/Objects/TR3/tr3_sophia.cpp +++ b/TR5Main/Objects/TR3/tr3_sophia.cpp @@ -9,6 +9,7 @@ #include "../../Game/effects.h" #include "../../Game/misc.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define MAX_TRIGGER_RANGE 0x4000 #define SMALL_FLASH 10 diff --git a/TR5Main/Objects/TR3/tr3_tiger.cpp b/TR5Main/Objects/TR3/tr3_tiger.cpp index 7b3a1c109..83a5aff89 100644 --- a/TR5Main/Objects/TR3/tr3_tiger.cpp +++ b/TR5Main/Objects/TR3/tr3_tiger.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO tigerBite = { 19, -13, 3, 26 }; diff --git a/TR5Main/Objects/TR3/tr3_tony.cpp b/TR5Main/Objects/TR3/tr3_tony.cpp index 9dbab4965..419c5747e 100644 --- a/TR5Main/Objects/TR3/tr3_tony.cpp +++ b/TR5Main/Objects/TR3/tr3_tony.cpp @@ -6,6 +6,7 @@ #include "../../Game/Box.h" #include "../../Game/draw.h" #include "../../Game/effects.h" +#include "..\..\Specific\level.h" #include "../../Specific/setup.h" // TODO: custom render for DrawExplosionRings() and DrawTonyBossShield() diff --git a/TR5Main/Objects/TR3/tr3_trex.cpp b/TR5Main/Objects/TR3/tr3_trex.cpp index e4d191f07..bb5bd7796 100644 --- a/TR5Main/Objects/TR3/tr3_trex.cpp +++ b/TR5Main/Objects/TR3/tr3_trex.cpp @@ -3,6 +3,7 @@ #include "../../Game/Box.h" #include "../../Game/camera.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" void LaraTyrannosaurDeath(ITEM_INFO* item) { diff --git a/TR5Main/Objects/TR3/tr3_tribesman.cpp b/TR5Main/Objects/TR3/tr3_tribesman.cpp index d02fbd3db..38624ccca 100644 --- a/TR5Main/Objects/TR3/tr3_tribesman.cpp +++ b/TR5Main/Objects/TR3/tr3_tribesman.cpp @@ -7,6 +7,7 @@ #include "../../Game/people.h" #include "../../Game/draw.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO tribesmanAxeBite = { 0, 16, 265, 13 }; BITE_INFO tribesmanDartsBite1 = { 0, 0, -200, 13 }; diff --git a/TR5Main/Objects/TR4/tr4_baddy.cpp b/TR5Main/Objects/TR4/tr4_baddy.cpp index dd6a7277c..38f12a9e8 100644 --- a/TR5Main/Objects/TR4/tr4_baddy.cpp +++ b/TR5Main/Objects/TR4/tr4_baddy.cpp @@ -7,6 +7,7 @@ #include "../../Game/people.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO baddyGun = { 0, -16, 200, 11 }; BITE_INFO baddySword = { 0, 0, 0, 15 }; diff --git a/TR5Main/Objects/TR4/tr4_bat.cpp b/TR5Main/Objects/TR4/tr4_bat.cpp index 8e80e5392..4cc9dffce 100644 --- a/TR5Main/Objects/TR4/tr4_bat.cpp +++ b/TR5Main/Objects/TR4/tr4_bat.cpp @@ -4,6 +4,7 @@ #include "../../Game/items.h" #include "../../Specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO batBite = { 0, 16, 45, 4 }; diff --git a/TR5Main/Objects/TR4/tr4_bigscorpion.cpp b/TR5Main/Objects/TR4/tr4_bigscorpion.cpp index ab3db1ff3..12b1019b4 100644 --- a/TR5Main/Objects/TR4/tr4_bigscorpion.cpp +++ b/TR5Main/Objects/TR4/tr4_bigscorpion.cpp @@ -4,6 +4,7 @@ #include "../../Game/items.h" #include "../../Specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO scorpionBite1 = { 0, 0, 0, 8 }; BITE_INFO scorpionBite2 = { 0, 0, 0, 23 }; diff --git a/TR5Main/Objects/TR4/tr4_crocodile.cpp b/TR5Main/Objects/TR4/tr4_crocodile.cpp index 37cf6d7f9..49714c5ef 100644 --- a/TR5Main/Objects/TR4/tr4_crocodile.cpp +++ b/TR5Main/Objects/TR4/tr4_crocodile.cpp @@ -4,6 +4,7 @@ #include "../../Game/people.h" #include "../../Game/items.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO crocodileBite = { 0, -156, 500, 9 }; diff --git a/TR5Main/Objects/TR4/tr4_demigod.cpp b/TR5Main/Objects/TR4/tr4_demigod.cpp index fa30ff39e..073a2b85c 100644 --- a/TR5Main/Objects/TR4/tr4_demigod.cpp +++ b/TR5Main/Objects/TR4/tr4_demigod.cpp @@ -8,6 +8,8 @@ #include "../../Game/tomb4fx.h" #include "../../Game/camera.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" + extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE]; void InitialiseDemigod(short itemNum) diff --git a/TR5Main/Objects/TR4/tr4_guide.cpp b/TR5Main/Objects/TR4/tr4_guide.cpp index aed8ac3b0..519c67d4a 100644 --- a/TR5Main/Objects/TR4/tr4_guide.cpp +++ b/TR5Main/Objects/TR4/tr4_guide.cpp @@ -7,6 +7,7 @@ #include "../../Game/effects.h" #include "../../Game/tomb4fx.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO guideBiteInfo1 = { 0, 20, 200, 18 }; BITE_INFO guideBiteInfo2 = { 30, 80, 50, 15 }; diff --git a/TR5Main/Objects/TR4/tr4_harpy.cpp b/TR5Main/Objects/TR4/tr4_harpy.cpp index 16f204a92..afc8f3123 100644 --- a/TR5Main/Objects/TR4/tr4_harpy.cpp +++ b/TR5Main/Objects/TR4/tr4_harpy.cpp @@ -8,6 +8,7 @@ #include "../../Game/draw.h" #include "../../Specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO harpyBite1 = { 0, 0, 0, 4 }; BITE_INFO harpyBite2 = { 0, 0, 0, 2 }; diff --git a/TR5Main/Objects/TR4/tr4_horseman.cpp b/TR5Main/Objects/TR4/tr4_horseman.cpp index 2aabefba5..43d3e4f1d 100644 --- a/TR5Main/Objects/TR4/tr4_horseman.cpp +++ b/TR5Main/Objects/TR4/tr4_horseman.cpp @@ -2,6 +2,7 @@ #include "../../Game/items.h" #include "../../Game/effect2.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO horseBite1 = { 0, 0, 0, 0x0D }; BITE_INFO horseBite2 = { 0, 0, 0, 0x11 }; diff --git a/TR5Main/Objects/TR4/tr4_jeanyves.cpp b/TR5Main/Objects/TR4/tr4_jeanyves.cpp index 763ec45bd..9b95d12b6 100644 --- a/TR5Main/Objects/TR4/tr4_jeanyves.cpp +++ b/TR5Main/Objects/TR4/tr4_jeanyves.cpp @@ -1,5 +1,6 @@ #include "../newobjects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" void InitialiseJeanYves(short itemNum) { diff --git a/TR5Main/Objects/TR4/tr4_knighttemplar.cpp b/TR5Main/Objects/TR4/tr4_knighttemplar.cpp index 57692b01e..055aaf276 100644 --- a/TR5Main/Objects/TR4/tr4_knighttemplar.cpp +++ b/TR5Main/Objects/TR4/tr4_knighttemplar.cpp @@ -6,6 +6,7 @@ #include "../../Game/debris.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO knightTemplarBite = { 0, 0, 0, 11 }; diff --git a/TR5Main/Objects/TR4/tr4_littlebeetle.cpp b/TR5Main/Objects/TR4/tr4_littlebeetle.cpp index f6afd5bd2..c09f34808 100644 --- a/TR5Main/Objects/TR4/tr4_littlebeetle.cpp +++ b/TR5Main/Objects/TR4/tr4_littlebeetle.cpp @@ -1,4 +1,5 @@ #include "../newobjects.h" +#include "..\..\Specific\level.h" void InitialiseLittleBeetle(short itemNum) { diff --git a/TR5Main/Objects/TR4/tr4_mummy.cpp b/TR5Main/Objects/TR4/tr4_mummy.cpp index f4debf247..a2ffd7bfc 100644 --- a/TR5Main/Objects/TR4/tr4_mummy.cpp +++ b/TR5Main/Objects/TR4/tr4_mummy.cpp @@ -3,6 +3,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO mummyBite1 = { 0, 0, 0, 11 }; BITE_INFO mummyBite2 = { 0, 0, 0, 14 }; diff --git a/TR5Main/Objects/TR4/tr4_sas.cpp b/TR5Main/Objects/TR4/tr4_sas.cpp index 5fdf01151..14f19c22e 100644 --- a/TR5Main/Objects/TR4/tr4_sas.cpp +++ b/TR5Main/Objects/TR4/tr4_sas.cpp @@ -6,6 +6,7 @@ #include "../../Game/people.h" #include "../../Game/lara.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO sasGun = { 0, 300, 64, 7 }; diff --git a/TR5Main/Objects/TR4/tr4_skeleton.cpp b/TR5Main/Objects/TR4/tr4_skeleton.cpp index 8e721bac0..29128e7e4 100644 --- a/TR5Main/Objects/TR4/tr4_skeleton.cpp +++ b/TR5Main/Objects/TR4/tr4_skeleton.cpp @@ -9,6 +9,7 @@ #include "../../Game/lot.h" #include "../../Specific/setup.h" #include "../../Game/tomb4fx.h" +#include "..\..\Specific\level.h" BITE_INFO skeletonBite = { 0, -16, 200, 11 }; diff --git a/TR5Main/Objects/TR4/tr4_smallscorpion.cpp b/TR5Main/Objects/TR4/tr4_smallscorpion.cpp index b832816bc..6ad4a7925 100644 --- a/TR5Main/Objects/TR4/tr4_smallscorpion.cpp +++ b/TR5Main/Objects/TR4/tr4_smallscorpion.cpp @@ -3,6 +3,7 @@ #include "../../Game/items.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO smallScorpionBiteInfo1 = { 0, 0, 0, 0 }; BITE_INFO smallScorpionBiteInfo2 = { 0, 0, 0, 23 }; diff --git a/TR5Main/Objects/TR4/tr4_sphinx.cpp b/TR5Main/Objects/TR4/tr4_sphinx.cpp index a9fe1a9a5..7053982f4 100644 --- a/TR5Main/Objects/TR4/tr4_sphinx.cpp +++ b/TR5Main/Objects/TR4/tr4_sphinx.cpp @@ -4,6 +4,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO sphinxBiteInfo = { 0, 0, 0, 6 }; diff --git a/TR5Main/Objects/TR4/tr4_troops.cpp b/TR5Main/Objects/TR4/tr4_troops.cpp index 5d365ca7a..b55da691a 100644 --- a/TR5Main/Objects/TR4/tr4_troops.cpp +++ b/TR5Main/Objects/TR4/tr4_troops.cpp @@ -7,6 +7,7 @@ #include "../../Game/people.h" #include "../../Specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO TroopsBite1 = { 0, 300, 64, 7 }; diff --git a/TR5Main/Objects/TR4/tr4_wildboard.cpp b/TR5Main/Objects/TR4/tr4_wildboard.cpp index 090ddd193..6055f064b 100644 --- a/TR5Main/Objects/TR4/tr4_wildboard.cpp +++ b/TR5Main/Objects/TR4/tr4_wildboard.cpp @@ -4,6 +4,7 @@ #include "../../Game/effects.h" #include "../../Specific/setup.h" #include "../../Game/lot.h" +#include "..\..\Specific\level.h" BITE_INFO wildboardBiteInfo = { 0, 0, 0, 14 }; diff --git a/TR5Main/Objects/TR5/tr5_autoguns.cpp b/TR5Main/Objects/TR5/tr5_autoguns.cpp index f0c8abacb..add542e70 100644 --- a/TR5Main/Objects/TR5/tr5_autoguns.cpp +++ b/TR5Main/Objects/TR5/tr5_autoguns.cpp @@ -5,6 +5,7 @@ #include "../../Game/effect2.h" #include "../../Game/effects.h" #include "../../Game/tomb4fx.h" +#include "..\..\Specific\level.h" void InitialiseAutoGuns(short itemNum) { diff --git a/TR5Main/Objects/TR5/tr5_brownbeast.cpp b/TR5Main/Objects/TR5/tr5_brownbeast.cpp index 95a3b854a..2cd3cc0e1 100644 --- a/TR5Main/Objects/TR5/tr5_brownbeast.cpp +++ b/TR5Main/Objects/TR5/tr5_brownbeast.cpp @@ -5,6 +5,7 @@ #include "../../Game/effect2.h" #include "../../Game/tomb4fx.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO BrownBeastBite1 = { 0, 0, 0, 16 }; BITE_INFO BrownBeastBite2 = { 0, 0, 0, 22 }; diff --git a/TR5Main/Objects/TR5/tr5_chef.cpp b/TR5Main/Objects/TR5/tr5_chef.cpp index 2de872632..56ae0da1d 100644 --- a/TR5Main/Objects/TR5/tr5_chef.cpp +++ b/TR5Main/Objects/TR5/tr5_chef.cpp @@ -8,6 +8,7 @@ #include "../../Game/tomb4fx.h" #include "../../Game/people.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_CHEF_COOKING 1 #define STATE_CHEF_TURN_180 2 diff --git a/TR5Main/Objects/TR5/tr5_cybord.cpp b/TR5Main/Objects/TR5/tr5_cybord.cpp index 65de5e996..cb055cfbb 100644 --- a/TR5Main/Objects/TR5/tr5_cybord.cpp +++ b/TR5Main/Objects/TR5/tr5_cybord.cpp @@ -9,6 +9,7 @@ #include "../../Game/lara.h" #include "../../Game/traps.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_HITMAN_STOP 1 #define STATE_HITMAN_WALK 2 diff --git a/TR5Main/Objects/TR5/tr5_doberman.cpp b/TR5Main/Objects/TR5/tr5_doberman.cpp index 408c1d7cd..5abaea4b1 100644 --- a/TR5Main/Objects/TR5/tr5_doberman.cpp +++ b/TR5Main/Objects/TR5/tr5_doberman.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO DobermanBite = { 0, 0x1E, 0x8D, 0x14 }; diff --git a/TR5Main/Objects/TR5/tr5_dog.cpp b/TR5Main/Objects/TR5/tr5_dog.cpp index a10d0d993..9bf79f47d 100644 --- a/TR5Main/Objects/TR5/tr5_dog.cpp +++ b/TR5Main/Objects/TR5/tr5_dog.cpp @@ -2,6 +2,7 @@ #include "../../Game/Box.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" byte DogAnims[] = { 20, 21, 22, 20 }; BITE_INFO DogBite = { 0, 0, 100, 3 }; diff --git a/TR5Main/Objects/TR5/tr5_ghost.cpp b/TR5Main/Objects/TR5/tr5_ghost.cpp index 7bd052b9d..5dd6bae84 100644 --- a/TR5Main/Objects/TR5/tr5_ghost.cpp +++ b/TR5Main/Objects/TR5/tr5_ghost.cpp @@ -4,6 +4,7 @@ #include "../../Game/effects.h" #include "../../Game/effect2.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO InvisibleGhostBite = { 0, 0, 0, 17 }; diff --git a/TR5Main/Objects/TR5/tr5_gladiator.cpp b/TR5Main/Objects/TR5/tr5_gladiator.cpp index 6c6eee089..e7dc1538a 100644 --- a/TR5Main/Objects/TR5/tr5_gladiator.cpp +++ b/TR5Main/Objects/TR5/tr5_gladiator.cpp @@ -7,6 +7,7 @@ #include "../../Game/effects.h" #include "../../Game/tomb4fx.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO GladiatorBite = { 0, 0, 0, 16 }; diff --git a/TR5Main/Objects/TR5/tr5_guard.cpp b/TR5Main/Objects/TR5/tr5_guard.cpp index 9b10101b0..635a012b3 100644 --- a/TR5Main/Objects/TR5/tr5_guard.cpp +++ b/TR5Main/Objects/TR5/tr5_guard.cpp @@ -7,6 +7,7 @@ #include "../../Game/tomb4fx.h" #include "../../Specific/setup.h" #include "../../Game/draw.h" +#include "..\..\Specific\level.h" BITE_INFO SwatGun = { 80, 200, 13, 0 }; BITE_INFO SniperGun = { 0, 480, 110, 13 }; diff --git a/TR5Main/Objects/TR5/tr5_hydra.cpp b/TR5Main/Objects/TR5/tr5_hydra.cpp index b43bfdac1..87bd25a78 100644 --- a/TR5Main/Objects/TR5/tr5_hydra.cpp +++ b/TR5Main/Objects/TR5/tr5_hydra.cpp @@ -7,6 +7,7 @@ #include "../../Game/effect2.h" #include "../../Game/people.h" #include "../../Game/draw.h" +#include "..\..\Specific\level.h" #define STATE_HYDRA_STOP 0 #define STATE_HYDRA_BITE_ATTACK1 1 diff --git a/TR5Main/Objects/TR5/tr5_imp.cpp b/TR5Main/Objects/TR5/tr5_imp.cpp index d55d49921..a2f78b05c 100644 --- a/TR5Main/Objects/TR5/tr5_imp.cpp +++ b/TR5Main/Objects/TR5/tr5_imp.cpp @@ -7,6 +7,7 @@ #include "../../Game/effect2.h" #include "../../Game/Box.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_IMP_WALK 0 #define STATE_IMP_STOP 1 diff --git a/TR5Main/Objects/TR5/tr5_lagoon_witch.cpp b/TR5Main/Objects/TR5/tr5_lagoon_witch.cpp index d0dea9f09..b8c234036 100644 --- a/TR5Main/Objects/TR5/tr5_lagoon_witch.cpp +++ b/TR5Main/Objects/TR5/tr5_lagoon_witch.cpp @@ -6,6 +6,7 @@ #include "../../Game/tomb4fx.h" #include "../../Game/inventory.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_LAGOON_WITCH_SWIM 1 #define STATE_LAGOON_WITCH_STOP 2 diff --git a/TR5Main/Objects/TR5/tr5_larson.cpp b/TR5Main/Objects/TR5/tr5_larson.cpp index 225feae3b..f6ffbfc28 100644 --- a/TR5Main/Objects/TR5/tr5_larson.cpp +++ b/TR5Main/Objects/TR5/tr5_larson.cpp @@ -6,6 +6,7 @@ #include "../../Game/people.h" #include "../../Game/lot.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_TR5_LARSON_STOP 1 #define STATE_TR5_LARSON_WALK 2 diff --git a/TR5Main/Objects/TR5/tr5_laser_head.cpp b/TR5Main/Objects/TR5/tr5_laser_head.cpp index 10c0cae39..4cc2693a9 100644 --- a/TR5Main/Objects/TR5/tr5_laser_head.cpp +++ b/TR5Main/Objects/TR5/tr5_laser_head.cpp @@ -13,6 +13,7 @@ #include "../../Game/laramisc.h" #include "../../Game/traps.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" struct LASER_HEAD_INFO { diff --git a/TR5Main/Objects/TR5/tr5_lion.cpp b/TR5Main/Objects/TR5/tr5_lion.cpp index 338c7b58d..2eba994af 100644 --- a/TR5Main/Objects/TR5/tr5_lion.cpp +++ b/TR5Main/Objects/TR5/tr5_lion.cpp @@ -7,6 +7,7 @@ #include "..\..\game\box.h" #include "..\..\game\tomb4fx.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" BITE_INFO LionBite1 = { 0xFFFFFFFE, 0xFFFFFFF6, 0xFA, 0x15 }; BITE_INFO LionBite2 = { 0xFFFFFFFE, 0xFFFFFFF6, 0x84, 0x15 }; diff --git a/TR5Main/Objects/TR5/tr5_misc_objects.cpp b/TR5Main/Objects/TR5/tr5_misc_objects.cpp index 2d2afee21..7e598075f 100644 --- a/TR5Main/Objects/TR5/tr5_misc_objects.cpp +++ b/TR5Main/Objects/TR5/tr5_misc_objects.cpp @@ -17,6 +17,7 @@ #include "../../Game/camera.h" #include "../../Game/missile.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" short DeathSlideBounds[12] = { -256, 256, -100, 100, 256, 512, 0, 0, -25 * ONE_DEGREE, 25 * ONE_DEGREE, 0, 0 }; PHD_VECTOR DeathSlidePosition = { 0, 0, 371 }; diff --git a/TR5Main/Objects/TR5/tr5_missile.cpp b/TR5Main/Objects/TR5/tr5_missile.cpp index 09d7d6274..1065b1168 100644 --- a/TR5Main/Objects/TR5/tr5_missile.cpp +++ b/TR5Main/Objects/TR5/tr5_missile.cpp @@ -8,7 +8,7 @@ #include "../../Game/draw.h" #include "../../Game/effects.h" #include "../../Game/traps.h" -#include "../../Specific/roomload.h" +#include "../../Specific/level.h" #include "../../Game/debris.h" void MissileControl(short itemNumber) diff --git a/TR5Main/Objects/TR5/tr5_moving_block.cpp b/TR5Main/Objects/TR5/tr5_moving_block.cpp index f074f65b9..6a8d4bd72 100644 --- a/TR5Main/Objects/TR5/tr5_moving_block.cpp +++ b/TR5Main/Objects/TR5/tr5_moving_block.cpp @@ -8,6 +8,7 @@ #include "../../Game/effects.h" #include "../../Game/laramisc.h" #include "../../Game/Box.h" +#include "..\..\Specific\level.h" short MovingBlockBounds[12] = { -300, 300, 0, 0, -692, -512, diff --git a/TR5Main/Objects/TR5/tr5_particle_enemies.cpp b/TR5Main/Objects/TR5/tr5_particle_enemies.cpp index e3d5e7389..fbae3840f 100644 --- a/TR5Main/Objects/TR5/tr5_particle_enemies.cpp +++ b/TR5Main/Objects/TR5/tr5_particle_enemies.cpp @@ -10,6 +10,7 @@ #include "../../Game/control.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" int NextBat; BAT_STRUCT* Bats; diff --git a/TR5Main/Objects/TR5/tr5_reaper.cpp b/TR5Main/Objects/TR5/tr5_reaper.cpp index 5884c4af3..9d1fc76e7 100644 --- a/TR5Main/Objects/TR5/tr5_reaper.cpp +++ b/TR5Main/Objects/TR5/tr5_reaper.cpp @@ -2,6 +2,7 @@ #include "../../Game/items.h" #include "../../Game/Box.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" void InitialiseReaper(short itemNum) { diff --git a/TR5Main/Objects/TR5/tr5_romanstatue.cpp b/TR5Main/Objects/TR5/tr5_romanstatue.cpp index fe4fba0c7..55acaee95 100644 --- a/TR5Main/Objects/TR5/tr5_romanstatue.cpp +++ b/TR5Main/Objects/TR5/tr5_romanstatue.cpp @@ -10,6 +10,7 @@ #include "../../Game/control.h" #include "../../Game/effects.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" #define STATE_ROMAN_STATUE_STOP 1 #define STATE_ROMAN_STATUE_SCREAMING 2 diff --git a/TR5Main/Objects/TR5/tr5_submarine.cpp b/TR5Main/Objects/TR5/tr5_submarine.cpp index a8c1cf70a..ab8403ba9 100644 --- a/TR5Main/Objects/TR5/tr5_submarine.cpp +++ b/TR5Main/Objects/TR5/tr5_submarine.cpp @@ -10,6 +10,7 @@ #include "../../Game/effects.h" #include "../../Game/lara1gun.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" void InitialiseSubmarine(short itemNum) { diff --git a/TR5Main/Objects/TR5/tr5_traps.cpp b/TR5Main/Objects/TR5/tr5_traps.cpp index 0aed608da..8cf05ad07 100644 --- a/TR5Main/Objects/TR5/tr5_traps.cpp +++ b/TR5Main/Objects/TR5/tr5_traps.cpp @@ -16,6 +16,7 @@ #include "../../Game/traps.h" #include "../../Game/camera.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" short SPyoffs[8] = { diff --git a/TR5Main/Objects/TR5/tr5_willowwisp.cpp b/TR5Main/Objects/TR5/tr5_willowwisp.cpp index 3b0652bae..6287a1d0f 100644 --- a/TR5Main/Objects/TR5/tr5_willowwisp.cpp +++ b/TR5Main/Objects/TR5/tr5_willowwisp.cpp @@ -1,6 +1,7 @@ #include "../newobjects.h" #include "../../Game/items.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" void InitialiseLightingGuide(short itemNum) { diff --git a/TR5Main/Objects/Vehicles/boat.cpp b/TR5Main/Objects/Vehicles/boat.cpp index dea5a35d1..06fc943cb 100644 --- a/TR5Main/Objects/Vehicles/boat.cpp +++ b/TR5Main/Objects/Vehicles/boat.cpp @@ -5,6 +5,7 @@ #include "../../Game/sphere.h" #include "../../Game/camera.h" #include "../../Specific/setup.h" +#include "../../Specific/level.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Objects/Vehicles/jeep.cpp b/TR5Main/Objects/Vehicles/jeep.cpp index d805681c0..0640402bd 100644 --- a/TR5Main/Objects/Vehicles/jeep.cpp +++ b/TR5Main/Objects/Vehicles/jeep.cpp @@ -13,6 +13,8 @@ #include #include "../../Specific/setup.h" +#include "../../Specific/level.h" + using namespace std; #define JF_FALLING 0x40 diff --git a/TR5Main/Objects/Vehicles/kayak.cpp b/TR5Main/Objects/Vehicles/kayak.cpp index 2c7603879..bf9d51ca7 100644 --- a/TR5Main/Objects/Vehicles/kayak.cpp +++ b/TR5Main/Objects/Vehicles/kayak.cpp @@ -7,8 +7,8 @@ #include "../../Game/collide.h" #include "../../Game/laraflar.h" #include "../../Game/items.h" -#include "..\..\Specific\roomload.h" -#include "..\..\Specific\roomload.h" +#include "..\..\Specific\level.h" +#include "..\..\Specific\level.h" #include "../../Specific/setup.h" extern LaraExtraInfo g_LaraExtra; @@ -354,6 +354,8 @@ int TestKayakHeight(ITEM_INFO* item, int x, int z, PHD_VECTOR* pos) FLOOR_INFO* floor; short roomNumber; + // PHD_MATH: + /* phd_PushUnitMatrix(); MatrixPtr[M03] = item->pos.xPos; MatrixPtr[M13] = item->pos.yPos; @@ -363,6 +365,7 @@ int TestKayakHeight(ITEM_INFO* item, int x, int z, PHD_VECTOR* pos) pos->x = (MatrixPtr[M03] >> W2V_SHIFT); pos->y = (MatrixPtr[M13] >> W2V_SHIFT); pos->z = (MatrixPtr[M23] >> W2V_SHIFT); + */ roomNumber = item->roomNumber; GetFloor(pos->x, pos->y, pos->z, &roomNumber); diff --git a/TR5Main/Objects/Vehicles/minecart.cpp b/TR5Main/Objects/Vehicles/minecart.cpp index ece07693d..047a6ebc0 100644 --- a/TR5Main/Objects/Vehicles/minecart.cpp +++ b/TR5Main/Objects/Vehicles/minecart.cpp @@ -8,7 +8,7 @@ #include "../../Game/draw.h" #include "../../Game/misc.h" #include "../../Game/camera.h" -#include "..\..\Specific\roomload.h" +#include "..\..\Specific\level.h" #include "../../Specific/setup.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Objects/Vehicles/quad.cpp b/TR5Main/Objects/Vehicles/quad.cpp index 212db9548..a312afaa7 100644 --- a/TR5Main/Objects/Vehicles/quad.cpp +++ b/TR5Main/Objects/Vehicles/quad.cpp @@ -12,6 +12,7 @@ #include "../../Game/lara1gun.h" #include "../../Game/misc.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" using namespace std; typedef enum QUAD_EFFECTS_POSITIONS { diff --git a/TR5Main/Objects/Vehicles/snowmobile.cpp b/TR5Main/Objects/Vehicles/snowmobile.cpp index 90256a621..7dbc74f89 100644 --- a/TR5Main/Objects/Vehicles/snowmobile.cpp +++ b/TR5Main/Objects/Vehicles/snowmobile.cpp @@ -11,6 +11,7 @@ #include "../../Game/tomb4fx.h" #include "../../Game/sphere.h" #include "../../Specific/setup.h" +#include "..\..\Specific\level.h" // TODO: recreate the DrawSkidoo for the snowmobile. diff --git a/TR5Main/Objects/Vehicles/upv.cpp b/TR5Main/Objects/Vehicles/upv.cpp index a89b52cd0..62e5d319c 100644 --- a/TR5Main/Objects/Vehicles/upv.cpp +++ b/TR5Main/Objects/Vehicles/upv.cpp @@ -13,6 +13,7 @@ #include "../../Game/camera.h" #include "../../Specific/setup.h" #include "../../Game/bubble.h" +#include "..\..\Specific\level.h" extern LaraExtraInfo g_LaraExtra; diff --git a/TR5Main/Objects/puzzles.cpp b/TR5Main/Objects/puzzles.cpp index ebab3dec2..32987dee1 100644 --- a/TR5Main/Objects/puzzles.cpp +++ b/TR5Main/Objects/puzzles.cpp @@ -14,6 +14,7 @@ #include "../Game/tomb4fx.h" #include "../Game/pickup.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" extern DRIP_STRUCT Drips[MAX_DRIPS]; short ScalesBounds[12] = { diff --git a/TR5Main/Objects/trap.cpp b/TR5Main/Objects/trap.cpp index 51a5787b8..a790e8734 100644 --- a/TR5Main/Objects/trap.cpp +++ b/TR5Main/Objects/trap.cpp @@ -14,6 +14,7 @@ #include "../Game/tomb4fx.h" #include "../Game/misc.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" short StargateBounds[24] = { diff --git a/TR5Main/Renderer/Render11Helper.cpp b/TR5Main/Renderer/Render11Helper.cpp index a4c081c19..02c9a32ea 100644 --- a/TR5Main/Renderer/Render11Helper.cpp +++ b/TR5Main/Renderer/Render11Helper.cpp @@ -4,6 +4,7 @@ #include "../Game/camera.h" #include "../Game/draw.h" #include "../Specific/setup.h" +#include "..\Specific\level.h" extern GameConfiguration g_Configuration; extern GameFlow* g_GameFlow; bool Renderer11::isRoomUnderwater(short roomNumber) diff --git a/TR5Main/Renderer/Renderer11.cpp b/TR5Main/Renderer/Renderer11.cpp index c2eb0cc02..3392cc047 100644 --- a/TR5Main/Renderer/Renderer11.cpp +++ b/TR5Main/Renderer/Renderer11.cpp @@ -2,7 +2,7 @@ #include "..\Specific\input.h" #include "..\Specific\winmain.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "..\Specific\configuration.h" #include "..\Game\draw.h" diff --git a/TR5Main/Renderer/Renderer11Compatibility.cpp b/TR5Main/Renderer/Renderer11Compatibility.cpp index b8fb72c5f..201d159ff 100644 --- a/TR5Main/Renderer/Renderer11Compatibility.cpp +++ b/TR5Main/Renderer/Renderer11Compatibility.cpp @@ -1,5 +1,5 @@ #include "Renderer11.h" -#include "../Specific/roomload.h" +#include "../Specific/level.h" #include #include "../Game/savegame.h" #include "../Specific/setup.h" @@ -19,8 +19,8 @@ bool Renderer11::PrepareDataForTheRenderer() m_meshes.clear(); // Step 0: prepare animated textures - short numSets = *AnimatedTextureRanges; - short* animatedPtr = AnimatedTextureRanges; + short numSets = *AnimTextureRanges; + short* animatedPtr = AnimTextureRanges; animatedPtr++; m_animatedTextureSets = vector(NUM_ANIMATED_SETS); diff --git a/TR5Main/Renderer/Renderer11Draw.cpp b/TR5Main/Renderer/Renderer11Draw.cpp index 70602dfd5..3e4d19fac 100644 --- a/TR5Main/Renderer/Renderer11Draw.cpp +++ b/TR5Main/Renderer/Renderer11Draw.cpp @@ -13,7 +13,7 @@ #include "../Game/tomb4fx.h" #include "../Game/door.h" #include "../Objects/oldobjects.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL]; diff --git a/TR5Main/Renderer/Renderer11DrawEffect.cpp b/TR5Main/Renderer/Renderer11DrawEffect.cpp index 2b4b7dc60..454b8b0a7 100644 --- a/TR5Main/Renderer/Renderer11DrawEffect.cpp +++ b/TR5Main/Renderer/Renderer11DrawEffect.cpp @@ -9,6 +9,7 @@ #include "../Game/debris.h" #include "../Specific/setup.h" #include "../Game/bubble.h" +#include "..\Specific\level.h" extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD]; extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE]; diff --git a/TR5Main/Renderer/Renderer11Frame.cpp b/TR5Main/Renderer/Renderer11Frame.cpp index bc7905f7a..404ec54c8 100644 --- a/TR5Main/Renderer/Renderer11Frame.cpp +++ b/TR5Main/Renderer/Renderer11Frame.cpp @@ -1,7 +1,7 @@ #include "Renderer11.h" #include "../Game/draw.h" #include "../Game/camera.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" #include "../Specific/setup.h" void Renderer11::collectRooms() { diff --git a/TR5Main/Renderer/Renderer11Init.cpp b/TR5Main/Renderer/Renderer11Init.cpp index 4d48b12fb..c325601e5 100644 --- a/TR5Main/Renderer/Renderer11Init.cpp +++ b/TR5Main/Renderer/Renderer11Init.cpp @@ -8,7 +8,7 @@ bool Renderer11::Initialise(int w, int h, int refreshRate, bool windowed, HWND h { HRESULT res; - DB_Log(2, "Renderer::Initialise - DLL"); + //DB_Log(2, "Renderer::Initialise - DLL"); printf("Initialising DX11\n"); CoInitialize(NULL); diff --git a/TR5Main/Renderer/Renderer11Lara.cpp b/TR5Main/Renderer/Renderer11Lara.cpp index debf4d2da..174631155 100644 --- a/TR5Main/Renderer/Renderer11Lara.cpp +++ b/TR5Main/Renderer/Renderer11Lara.cpp @@ -3,6 +3,7 @@ #include "../Game/hair.h" #include "../game/camera.h" #include "../Global/global.h" +#include "..\Specific\level.h" extern GameFlow* g_GameFlow; diff --git a/TR5Main/Scripting/GameLogicScript.cpp b/TR5Main/Scripting/GameLogicScript.cpp index 5efe06e7f..135c35993 100644 --- a/TR5Main/Scripting/GameLogicScript.cpp +++ b/TR5Main/Scripting/GameLogicScript.cpp @@ -4,6 +4,7 @@ #include "..\Game\lot.h" #include "..\Game\sound.h" #include "../Specific/setup.h" +#include "../Specific/level.h" extern GameFlow* g_GameFlow; diff --git a/TR5Main/Specific/configuration.cpp b/TR5Main/Specific/configuration.cpp index 1f7939229..9c27cdbd1 100644 --- a/TR5Main/Specific/configuration.cpp +++ b/TR5Main/Specific/configuration.cpp @@ -87,7 +87,7 @@ BOOL CALLBACK DialogProc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case WM_INITDIALOG: - DB_Log(6, "WM_INITDIALOG"); + //DB_Log(6, "WM_INITDIALOG"); SendMessageA(GetDlgItem(handle, IDC_GROUP_GFXADAPTER), WM_SETTEXT, 0, (LPARAM)g_GameFlow->GetString(STRING_DISPLAY_ADAPTER)); SendMessageA(GetDlgItem(handle, IDC_GROUP_OUTPUT_SETTINGS), WM_SETTEXT, 0, (LPARAM)g_GameFlow->GetString(STRING_OUTPUT_SETTINGS)); @@ -126,7 +126,7 @@ BOOL CALLBACK DialogProc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_COMMAND: - DB_Log(6, "WM_COMMAND"); + //DB_Log(6, "WM_COMMAND"); // Checkboxes if (HIWORD(wParam) == BN_CLICKED) diff --git a/TR5Main/Specific/roomload.cpp b/TR5Main/Specific/level.cpp similarity index 64% rename from TR5Main/Specific/roomload.cpp rename to TR5Main/Specific/level.cpp index f4f578272..9f46aa393 100644 --- a/TR5Main/Specific/roomload.cpp +++ b/TR5Main/Specific/level.cpp @@ -1,873 +1,1286 @@ -#include "roomload.h" -#include "..\Global\global.h" -#include "..\Game\items.h" -#include "..\Specific\setup.h" -#include "..\Game\draw.h" -#include "..\Game\lot.h" -#include "..\Game\Lara.h" -#include "..\Game\savegame.h" -#include "..\Game\spotcam.h" -#include "..\Game\camera.h" -#include "..\Scripting\GameFlowScript.h" -#include "..\Game\control.h" -#include "..\Game\pickup.h" -#include "../Game/door.h" -#include "../Game/box.h" - -#include "IO/ChunkId.h" -#include "IO/ChunkReader.h" -#include "IO/ChunkWriter.h" -#include "IO/LEB128.h" - -#include -#include -#include -#include -#include "IO/Streams.h" - -ChunkId* ChunkTriggersList = ChunkId::FromString("Tr5Triggers"); -ChunkId* ChunkTrigger = ChunkId::FromString("Tr5Trigger"); -ChunkId* ChunkLuaIds = ChunkId::FromString("Tr5LuaIds"); -ChunkId* ChunkLuaId = ChunkId::FromString("Tr5LuaId"); - -extern GameScript* g_GameScript; - -byte* Texture32; -byte* Texture16; -byte* MiscTextures; -short* RawMeshData; -int MeshDataSize; -int* MeshTrees; -int* RawMeshPointers; -int NumObjects; -int NumStaticObjects; -int NumMeshPointers; -int NumObjectTextures; -int NumTextureTiles; -short* MeshBase; -short** Meshes; -int NumItems; - -uintptr_t hLoadLevel; -unsigned int ThreadId; -int IsLevelLoading; -bool g_FirstLevel = true; - -using namespace std; - -vector MoveablesIds; -vector StaticObjectsIds; - -extern GameFlow* g_GameFlow; -extern LaraExtraInfo g_LaraExtra; -char* LevelDataPtr; - -int g_NumSprites; -int g_NumSpritesSequences; - -ChunkReader* g_levelChunkIO; - -short ReadInt8() -{ - byte value = *(byte*)LevelDataPtr; - LevelDataPtr += 1; - return value; -} - -short ReadInt16() -{ - short value = *(short*)LevelDataPtr; - LevelDataPtr += 2; - return value; -} - -int ReadInt32() -{ - int value = *(int*)LevelDataPtr; - LevelDataPtr += 4; - return value; -} - -void ReadBytes(void* dest, int count) -{ - memcpy(dest, LevelDataPtr, count); - LevelDataPtr += count; -} - -int LoadItems() -{ - DB_Log(2, "LoadItems - DLL"); - - NumItems = ReadInt32(); - if (NumItems == 0) - return false; - - Items = (ITEM_INFO*)GameMalloc(sizeof(ITEM_INFO) * NUM_ITEMS); - LevelItems = NumItems; - - InitialiseClosedDoors(); - FreeItemsStuff(NUM_ITEMS); - - if (NumItems > 0) - { - for (int i = 0; i < NumItems; i++) - { - ITEM_INFO* item = &Items[i]; - - item->objectNumber = ReadInt16(); - item->roomNumber = ReadInt16(); - item->pos.xPos = ReadInt32(); - item->pos.yPos = ReadInt32(); - item->pos.zPos = ReadInt32(); - item->pos.yRot = ReadInt16(); - item->shade = ReadInt16(); - item->triggerFlags = ReadInt16(); - item->flags = ReadInt16(); - - // DEBUG: set Lara position - /*if (item->objectNumber == ID_LARA) - { - item->pos.xPos = 33050; - item->pos.yPos = 10000; - item->pos.zPos = 21162; - item->roomNumber = 0; - }*/ - - // ANDREA2 - /*if (item->objectNumber == ID_LARA) - { - item->pos.xPos = 58*1024; - item->pos.yPos = 0; - item->pos.zPos = 39*1024; - item->roomNumber = 144; - }*/ - } - - for (int i = 0; i < NumItems; i++) - InitialiseItem(i); - } - - for (int r = 0; r < NumberRooms; r++) - { - MESH_INFO* mesh = Rooms[r].mesh; - - for (int m = 0; m < Rooms[r].numMeshes; m++) - { - FLOOR_INFO* floor = &Rooms[r].floor[((mesh->z - Rooms[r].z) >> 10) + Rooms[r].xSize * ((mesh->x - Rooms[r].x) >> 10)]; - - if (!(Boxes[floor->box].overlapIndex & 0x4000) - && !(CurrentLevel == 5 && (r == 19 || r == 23 || r == 16))) - { - int fl = floor->floor << 2; - STATIC_INFO* st = &StaticObjects[mesh->staticNumber]; - if (fl <= mesh->y - st->yMaxc + 512 && fl < mesh->y - st->yMinc) - { - if (st->xMaxc == 0 || st->xMinc == 0 || - st->zMaxc == 0 || st->zMinc == 0 || - (st->xMaxc ^ st->xMinc) & 0x8000 && - (st->xMaxc ^ st->zMinc) & 0x8000) - { - floor->box |= 8; - } - } - } - } - } - - return true; -} - -void LoadObjects() -{ - DB_Log(2, "LoadObjects - DLL"); - - memset(Objects, 0, sizeof(OBJECT_INFO) * ID_NUMBER_OBJECTS); - memset(StaticObjects, 0, sizeof(STATIC_INFO) * NUM_STATICS); - - int numMeshDataWords = ReadInt32(); - int numMeshDataBytes = 2 * numMeshDataWords; - - MeshBase = (short*)GameMalloc(numMeshDataBytes); - ReadBytes(MeshBase, numMeshDataBytes); - - MeshDataSize = numMeshDataBytes; - - int numMeshPointers = ReadInt32(); - Meshes = (short**)GameMalloc(4 * numMeshPointers); - ReadBytes(Meshes, 4 * numMeshPointers); - - for (int i = 0; i < numMeshPointers; i++) - { - Meshes[i] = &MeshBase[(int)Meshes[i] / 2]; - } - - int numMeshes = numMeshPointers; - NumMeshPointers = numMeshes; - - int numAnimations = ReadInt32(); - Anims = (ANIM_STRUCT*)GameMalloc(sizeof(ANIM_STRUCT) * numAnimations); - ReadBytes(Anims, sizeof(ANIM_STRUCT) * numAnimations); - - int numChanges = ReadInt32(); - Changes = (CHANGE_STRUCT*)GameMalloc(sizeof(CHANGE_STRUCT) * numChanges); - ReadBytes(Changes, sizeof(CHANGE_STRUCT) * numChanges); - - int numRanges = ReadInt32(); - Ranges = (RANGE_STRUCT*)GameMalloc(sizeof(RANGE_STRUCT) * numRanges); - ReadBytes(Ranges, sizeof(RANGE_STRUCT) * numRanges); - - int numCommands = ReadInt32(); - Commands = (short*)GameMalloc(2 * numCommands); - ReadBytes(Commands, 2 * numCommands); - - int numBones = ReadInt32(); - Bones = (int*)GameMalloc(4 * numBones); - ReadBytes(Bones, 4 * numBones); - - int* bone = Bones; - for (int i = 0; i < 15; i++) - { - int opcode = *(bone++); - int linkX = *(bone++); - int linkY = *(bone++); - int linkZ = *(bone++); - } - - MeshTrees = (int*)GameMalloc(4 * numBones); - - memcpy(MeshTrees, Bones, 4 * numBones); - - int numFrames = ReadInt32(); - Frames = (short*)GameMalloc(2 * numFrames); - ReadBytes(Frames, 2 * numFrames); - - AnimationsCount = numAnimations; - if (AnimationsCount > 0) - { - int i = 0; - for (int i = 0; i < AnimationsCount; i++) - ADD_PTR(Anims[i].framePtr, short, Frames); - } - - int numModels = ReadInt32(); - NumObjects = numModels; - for (int i = 0; i < numModels; i++) - { - int objNum = ReadInt32(); - MoveablesIds.push_back(objNum); - - Objects[objNum].loaded = true; - Objects[objNum].nmeshes = ReadInt16(); - Objects[objNum].meshIndex = ReadInt16(); - Objects[objNum].boneIndex = ReadInt32(); - Objects[objNum].frameBase = (short*)(ReadInt32() + (int)Frames); - Objects[objNum].animIndex = ReadInt16(); - - ReadInt16(); - - Objects[objNum].loaded = true; - } - - InitialiseObjects(); - InitialiseClosedDoors(); - - int numStatics = ReadInt32(); - NumStaticObjects = numStatics; - for (int i = 0; i < numStatics; i++) - { - int meshID = ReadInt32(); - StaticObjectsIds.push_back(meshID); - - StaticObjects[meshID].meshNumber = ReadInt16(); - - StaticObjects[meshID].yMinp = ReadInt16(); - StaticObjects[meshID].xMaxp = ReadInt16(); - StaticObjects[meshID].yMinp = ReadInt16(); - StaticObjects[meshID].yMaxp = ReadInt16(); - StaticObjects[meshID].zMinp = ReadInt16(); - StaticObjects[meshID].zMaxp = ReadInt16(); - - StaticObjects[meshID].xMinc = ReadInt16(); - StaticObjects[meshID].xMaxc = ReadInt16(); - StaticObjects[meshID].yMinc = ReadInt16(); - StaticObjects[meshID].yMaxc = ReadInt16(); - StaticObjects[meshID].zMinc = ReadInt16(); - StaticObjects[meshID].zMaxc = ReadInt16(); - - StaticObjects[meshID].flags = ReadInt16(); - } - - // HACK: to remove after decompiling LoadSprites - MoveablesIds.push_back(ID_DEFAULT_SPRITES); -} - -void LoadCameras() -{ - NumberCameras = ReadInt32(); - if (NumberCameras != 0) - { - Camera.fixed = (OBJECT_VECTOR*)GameMalloc(NumberCameras * sizeof(OBJECT_VECTOR)); - ReadBytes(Camera.fixed, NumberCameras * sizeof(OBJECT_VECTOR)); - } - - NumberSpotcams = ReadInt32(); - - if (NumberSpotcams != 0) - { - ReadBytes(SpotCam, NumberSpotcams * sizeof(SPOTCAM)); - } -} - -void LoadTextures() -{ - DB_Log(2, "LoadTextures - DLL"); - printf("LoadTextures\n"); - - int uncompressedSize = 0; - int compressedSize = 0; - - // Read 32 bit textures - ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); - ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); - - Texture32 = (byte*)malloc(uncompressedSize); - byte* buffer = (byte*)malloc(compressedSize); - - ReadFileEx(buffer, compressedSize, 1, LevelFilePtr); - Decompress(Texture32, buffer, compressedSize, uncompressedSize); - free(buffer); - - // Read 16 bit textures - ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); - ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); - - Texture16 = (byte*)malloc(uncompressedSize); - buffer = (byte*)malloc(compressedSize); - - ReadFileEx(buffer, compressedSize, 1u, LevelFilePtr); - Decompress(Texture16, buffer, compressedSize, uncompressedSize); - free(buffer); - - // Read misc textures - ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); - ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); - - printf("%d\n", uncompressedSize); - - MiscTextures = (byte*)malloc(uncompressedSize); - buffer = (byte*)malloc(compressedSize); - - ReadFileEx(buffer, compressedSize, 1u, LevelFilePtr); - Decompress(MiscTextures, buffer, compressedSize, uncompressedSize); - free(buffer); -} - -void ReadRoom(ROOM_INFO* room, ROOM_INFO* roomData) -{ - /*ADD_PTR(roomData->door, short, roomData + 1); - ADD_PTR(roomData->floor, FLOOR_INFO, roomData + 1); - ADD_PTR(roomData->light, LIGHTINFO, roomData + 1); - ADD_PTR(roomData->mesh, MESH_INFO, roomData + 1); - ADD_PTR(roomData->Separator4, void, roomData + 1); - ADD_PTR(roomData->LayerOffset, tr5_room_layer, roomData + 1); - ADD_PTR(roomData->PolyOffset, void, roomData + 1); - ADD_PTR(roomData->PolyOffset2, void, roomData + 1); - ADD_PTR(roomData->VerticesOffset, tr5_room_vertex, roomData + 1); - - roomData->LightDataSize += (int)(roomData + 1); - - if ((byte)roomData->door & 1) - { - //DB_Log(0, "%X", roomData->door); - roomData->door = 0; - } - - byte* polyOff = (byte*)roomData->PolyOffset; - byte* polyOff2 = (byte*)roomData->PolyOffset2; - byte* vertOff = (byte*)roomData->VerticesOffset; - - for (int i = 0; i < roomData->NumLayers; i++) - { - roomData->LayerOffset[i].PolyOffset = polyOff; - roomData->LayerOffset[i].PolyOffset2 = polyOff2; - roomData->LayerOffset[i].VerticesOffset = vertOff; - - polyOff += sizeof(tr4_mesh_face3) * roomData->LayerOffset[i].NumLayerTriangles + - sizeof(tr4_mesh_face4) * roomData->LayerOffset[i].NumLayerRectangles; - - polyOff2 += 4 * roomData->LayerOffset[i].NumLayerVertices; // todo find what struct this is - - vertOff += sizeof(tr5_room_vertex) * roomData->LayerOffset[i].NumLayerVertices; - } - - memcpy(room, roomData, sizeof(ROOM_INFO));*/ -} - -void ReadRooms() -{ - ReadInt32(); - - int numRooms = ReadInt32(); - NumberRooms = numRooms; - Rooms = (ROOM_INFO*)GameMalloc(NumberRooms * sizeof(ROOM_INFO)); - - printf("NumRooms: %d\n", numRooms); - - for (int i = 0; i < NumberRooms; i++) - { - // Ignore XELA - int xela = ReadInt32(); - - // Read room data - int roomDataSize = ReadInt32(); - byte* roomData = (byte*)GameMalloc(roomDataSize); - ReadBytes(roomData, roomDataSize); - - // Put the room data in the struct - ReadRoom(&Rooms[i], (ROOM_INFO*)roomData); - } -} - -int LoadRoomsNew() -{ - DB_Log(2, "LoadRooms - DLL"); - printf("LoadRooms\n"); - - Wibble = 0; - RoomLightsCount = 0; - Unk_007E7FE8 = 0; - - ReadRooms(); - DoSomethingWithRooms(); - - int numFloorData = ReadInt32(); - FloorData = (short*)GameMalloc(numFloorData * 2); - ReadBytes(FloorData, numFloorData * 2); - - return true; -} - -void FreeLevel() -{ - MallocPtr = MallocBuffer; - MallocFree = MallocSize; - g_Renderer->FreeRendererData(); - g_GameScript->FreeLevelScripts(); -} - -unsigned __stdcall LoadLevel(void* data) -{ - DB_Log(5, "LoadLevel - DLL"); - printf("LoadLevel\n"); - - char* filename = (char*)data; - - LevelDataPtr = NULL; - LevelFilePtr = NULL; - - g_Renderer->UpdateProgress(0); - - LevelFilePtr = FileOpen(filename); - if (LevelFilePtr) - { - int version; - short numRoomTextureTiles; - short numObjectsTextureTiles; - short numBumpTextureTiles; - - ReadFileEx(&version, 1, 4, LevelFilePtr); - ReadFileEx(&numRoomTextureTiles, 1, 2, LevelFilePtr); - ReadFileEx(&numObjectsTextureTiles, 1, 2, LevelFilePtr); - ReadFileEx(&numBumpTextureTiles, 1, 2, LevelFilePtr); - - g_Renderer->NumTexturePages = numRoomTextureTiles + numObjectsTextureTiles + numBumpTextureTiles; - - LoadTextures(); - - g_Renderer->UpdateProgress(20); - - short buffer[32]; - ReadFileEx(&buffer, 2, 16, LevelFilePtr); - WeatherType = buffer[0]; - LaraDrawType = buffer[1]; - - int uncompressedSize; - int compressedSize; - - ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); - ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); - - LevelDataPtr = (char*)malloc(uncompressedSize); - ReadFileEx(LevelDataPtr, uncompressedSize, 1, LevelFilePtr); - - LoadRooms(); - g_Renderer->UpdateProgress(40); - - LoadObjects(); - g_Renderer->UpdateProgress(50); - - InitialiseLOTarray(true); - LoadSprites(); - LoadCameras(); - LoadSoundEffects(); - g_Renderer->UpdateProgress(60); - - LoadBoxes(); - LoadAnimatedTextures(); - LoadTextureInfos(); - g_Renderer->UpdateProgress(70); - - LoadItems(); - LoadAIObjects(); - //LoadDemoData(); - LoadSamples(); - g_Renderer->UpdateProgress(80); - - int extraSize = 0; - ReadFileEx(&extraSize, 1, 4, LevelFilePtr); - if (extraSize > 0) - { - ReadFileEx(&extraSize, 1, 4, LevelFilePtr); - LevelDataPtr = (char*)malloc(extraSize); - ReadFileEx(LevelDataPtr, extraSize, 1, LevelFilePtr); - - LoadNewData(extraSize); - } - - LevelDataPtr = NULL; - FileClose(LevelFilePtr); - } - else - { - return false; - } - - g_Renderer->UpdateProgress(90); - g_Renderer->PrepareDataForTheRenderer(); - - // Initialise the game - GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel); - - SeedRandomDraw(0xD371F947); - SeedRandomControl(0xD371F947); - Wibble = 0; - TorchRoom = -1; - InitialiseGameFlags(); - InitialiseLara(!(InitialiseGame || CurrentLevel == 1 || level->ResetHub)); - GetCarriedItems(); - GetAIPickups(); - SeedRandomDraw(0xD371F947); - SeedRandomControl(0xD371F947); - g_LaraExtra.Vehicle = -1; - g_GameScript->AssignItemsAndLara(); - - // Level loaded - IsLevelLoading = false; - g_Renderer->UpdateProgress(100); - - _endthreadex(1); - - return true; -} - -void LoadSamples() -{ - // Legacy soundmap size was 450, for now let's store new soundmap size into NumDemoData field - SoundMapSize = ReadInt16(); - - if (SoundMapSize == 0) - SoundMapSize = SOUND_LEGACY_SOUNDMAP_SIZE; - - for (int i = 0; i < SoundMapSize; i++) - SampleLUT[i] = ReadInt16(); - - NumSamplesInfos = ReadInt32(); - if (NumSamplesInfos) - { - SampleInfo = (SAMPLE_INFO*)GameMalloc(NumSamplesInfos * sizeof(SAMPLE_INFO)); - ReadBytes(SampleInfo, NumSamplesInfos * sizeof(SAMPLE_INFO)); - - int numSampleIndices = ReadInt32(); - if (numSampleIndices) - { - int numSamples = 0; - ReadFileEx(&numSamples, 1, 4, LevelFilePtr); - //if (feof(LevelFilePtr)) - // return; - - if (numSamples <= 0) - return; - - int uncompressedSize; - int compressedSize; - char* buffer = (char*)malloc(1048576); - - for (int i = 0; i < numSamples; i++) - { - ReadFileEx(&uncompressedSize, 4, 1, LevelFilePtr); - ReadFileEx(&compressedSize, 4, 1, LevelFilePtr); - ReadFileEx(buffer, 1, compressedSize, LevelFilePtr); - Sound_LoadSample(buffer, compressedSize, uncompressedSize, i); - } - - free(buffer); - } - } - else - { - //Log(1, aNoSampleInfos); - } -} - -void LoadBoxes() -{ - // Read boxes - NumberBoxes = ReadInt32(); - Boxes = (BOX_INFO*)GameMalloc(NumberBoxes * sizeof(BOX_INFO)); - ReadBytes(Boxes, NumberBoxes * sizeof(BOX_INFO)); - - // Read overlaps - NumberOverlaps = ReadInt32(); - Overlaps = (short*)GameMalloc(NumberOverlaps * sizeof(short)); - ReadBytes(Overlaps, NumberOverlaps * sizeof(short)); - - // Read zones - for (int i = 0; i < 2; i++) - { - // Ground zones - for (int j = 0; j < 4; j++) - { - short* zone = (short*)GameMalloc(NumberBoxes * sizeof(short)); - ReadBytes(zone, NumberBoxes * sizeof(short)); - Zones[j][i] = zone; - } - - // Fly zone - short* zone = (short*)GameMalloc(NumberBoxes * sizeof(short)); - ReadBytes(zone, NumberBoxes * sizeof(short)); - Zones[4][i] = zone; - } - - // By default all blockable boxes are blocked - for (int i = 0; i < NumberBoxes; i++) - { - if (Boxes[i].overlapIndex & BLOCKABLE) - { - Boxes[i].overlapIndex |= BLOCKED; - } - } -} - -int S_LoadLevelFile(int levelIndex) -{ - DB_Log(2, "S_LoadLevelFile - DLL"); - printf("S_LoadLevelFile\n"); - - SOUND_Stop(); - Sound_FreeSamples(); - if (!g_FirstLevel) - FreeLevel(); - g_FirstLevel = false; - RenderLoadBar = false; - - char filename[80]; - GameScriptLevel* level = g_GameFlow->Levels[levelIndex]; - strcpy_s(filename, level->FileName.c_str()); - - // Loading level is done is two threads, one for loading level and one for drawing loading screen - IsLevelLoading = true; - hLoadLevel = _beginthreadex(0, 0, LoadLevel, filename, 0, &ThreadId); - - // This function loops until progress is 100%. Not very thread safe, but behaviour should be predictable. - g_Renderer->DrawLoadingScreen((char*)(level->LoadScreenFileName.c_str())); - - while (IsLevelLoading); - - return true; -} - -void AdjustUV(int num) -{ - // Dummy function - NumObjectTextures = num; -} - -bool ReadLuaIds(ChunkId* chunkId, int maxSize, int arg) -{ - if (chunkId->EqualsTo(ChunkLuaId)) - { - int luaId = 0; - g_levelChunkIO->GetRawStream()->ReadInt32(&luaId); - - int itemId = 0; - g_levelChunkIO->GetRawStream()->ReadInt32(&itemId); - - g_GameScript->AddLuaId(luaId, itemId); - - return true; - } - else - return false; -} - -bool ReadLuaTriggers(ChunkId* chunkId, int maxSize, int arg) -{ - if (chunkId->EqualsTo(ChunkTrigger)) - { - char* functionName = NULL; - g_levelChunkIO->GetRawStream()->ReadString(&functionName); - - char* functionCode = NULL; - g_levelChunkIO->GetRawStream()->ReadString(&functionCode); - - LuaFunction* function = new LuaFunction(); - function->Name = string(functionName); - function->Code = string(functionCode); - function->Executed = false; - - g_GameScript->AddTrigger(function); - - delete functionName; - delete functionCode; - - return true; - } - else - return false; -} - -bool ReadNewDataChunks(ChunkId* chunkId, int maxSize, int arg) -{ - if (chunkId->EqualsTo(ChunkTriggersList)) - return g_levelChunkIO->ReadChunks(ReadLuaTriggers, 0); - else if (chunkId->EqualsTo(ChunkLuaIds)) - return g_levelChunkIO->ReadChunks(ReadLuaIds, 0); - return false; -} - -void LoadNewData(int size) -{ - // Free old level scripts - MemoryStream stream(LevelDataPtr, size); - g_levelChunkIO = new ChunkReader(0x4D355254, &stream); - if (!g_levelChunkIO->IsValid()) - return; - - g_levelChunkIO->ReadChunks(ReadNewDataChunks, 0); -} - -void LoadSprites() -{ - DB_Log(2, "LoadSprites"); - - ReadInt32(); // SPR\0 - - g_NumSprites = ReadInt32(); - - Sprites = (SPRITE*)GameMalloc(g_NumSprites * sizeof(SPRITE)); - - for (int i = 0; i < g_NumSprites; i++) - { - Sprites[i].tile = ReadInt16() + 1; - Sprites[i].x = ReadInt8(); - Sprites[i].y = ReadInt8(); - Sprites[i].width = ReadInt16(); - Sprites[i].height = ReadInt16(); - Sprites[i].left = (ReadInt16() + 1) / 256.0; - Sprites[i].top = (ReadInt16() + 1) / 256.0; - Sprites[i].right = (ReadInt16() - 1) / 256.0; - Sprites[i].bottom = (ReadInt16() - 1) / 256.0; - } - - g_NumSpritesSequences = ReadInt32(); - - for (int i = 0; i < g_NumSpritesSequences; i++) - { - int spriteID = ReadInt32(); - short negLength = ReadInt16(); - short offset = ReadInt16(); - if (spriteID >= ID_NUMBER_OBJECTS) - { - StaticObjects[spriteID - ID_NUMBER_OBJECTS].meshNumber = offset; - } - else - { - Objects[spriteID].nmeshes = negLength; - Objects[spriteID].meshIndex = offset; - Objects[spriteID].loaded = true; - } - } -} - -void GetCarriedItems() -{ - int i; - ITEM_INFO* item, *item2; - short linknum; - - for (i = 0; i < LevelItems; ++i) - Items[i].carriedItem = NO_ITEM; - for (i = 0; i < LevelItems; ++i) - { - item = &Items[i]; - if (Objects[item->objectNumber].intelligent || item->objectNumber >= ID_SEARCH_OBJECT1 && item->objectNumber <= ID_SEARCH_OBJECT3) - { - for (linknum = Rooms[item->roomNumber].itemNumber; linknum != NO_ITEM; linknum = Items[linknum].nextItem) - { - item2 = &Items[linknum]; - if (abs(item2->pos.xPos - item->pos.xPos) < 512 - && abs(item2->pos.zPos - item->pos.zPos) < 512 - && abs(item2->pos.yPos - item->pos.yPos) < 256 - && Objects[item2->objectNumber].collision == PickupCollision) - { - item2->carriedItem = item->carriedItem; - item->carriedItem = linknum; - RemoveDrawnItem(linknum); - item2->roomNumber = NO_ROOM; - } - } - } - } -} - -void GetAIPickups() -{ - int i, num; - ITEM_INFO* item; - AIOBJECT* object; - - for (i = 0; i < LevelItems; ++i) - { - item = &Items[i]; - if (Objects[item->objectNumber].intelligent) - { - item->aiBits = 0; - for (num = 0; num < nAIObjects; ++num) - { - object = &AIObjects[num]; - if (abs(object->x - item->pos.xPos) < 512 - && abs(object->z - item->pos.zPos) < 512 - && object->roomNumber == item->roomNumber - && object->objectNumber < ID_AI_PATROL2) - { - item->aiBits = (1 << object->objectNumber - ID_AI_GUARD) & 0x1F; - item->itemFlags[3] = object->triggerFlags; - if (object->objectNumber != ID_AI_GUARD) - object->roomNumber = NO_ROOM; - } - } - item->TOSSPAD |= item->aiBits << 8 | (char) item->itemFlags[3]; - } - } -} - -void Inject_RoomLoad() -{ - INJECT(0x004A6380, LoadItems); - INJECT(0x004A4E60, LoadObjects); - INJECT(0x004A3FC0, LoadTextures); - INJECT(0x0040130C, S_LoadLevelFile); - INJECT(0x004A7130, FreeLevel); - INJECT(0x004A5430, AdjustUV); - INJECT(0x004A5CA0, LoadCameras); +#include "level.h" +#include "..\Global\global.h" +#include "..\Game\items.h" +#include "..\Specific\setup.h" +#include "..\Game\draw.h" +#include "..\Game\lot.h" +#include "..\Game\Lara.h" +#include "..\Game\savegame.h" +#include "..\Game\spotcam.h" +#include "..\Game\camera.h" +#include "..\Scripting\GameFlowScript.h" +#include "..\Game\control.h" +#include "..\Game\pickup.h" +#include "../Game/door.h" +#include "../Game/box.h" + +#include "IO/ChunkId.h" +#include "IO/ChunkReader.h" +#include "IO/ChunkWriter.h" +#include "IO/LEB128.h" + +#include +#include +#include +#include +#include "IO/Streams.h" +#include + +ChunkId* ChunkTriggersList = ChunkId::FromString("Tr5Triggers"); +ChunkId* ChunkTrigger = ChunkId::FromString("Tr5Trigger"); +ChunkId* ChunkLuaIds = ChunkId::FromString("Tr5LuaIds"); +ChunkId* ChunkLuaId = ChunkId::FromString("Tr5LuaId"); + +extern GameScript* g_GameScript; + +byte* Texture32; +byte* Texture16; +byte* MiscTextures; +short* RawMeshData; +int MeshDataSize; +int* MeshTrees; +int* RawMeshPointers; +int NumObjects; +int NumStaticObjects; +int NumMeshPointers; +int NumObjectTextures; +int NumTextureTiles; +short* MeshBase; +short** Meshes; +int NumItems; +FILE* LevelFilePtr; + +uintptr_t hLoadLevel; +unsigned int ThreadId; +int IsLevelLoading; +bool g_FirstLevel = true; + +using namespace std; + +vector MoveablesIds; +vector StaticObjectsIds; + +extern GameFlow* g_GameFlow; +extern LaraExtraInfo g_LaraExtra; +char* LevelDataPtr; +OBJECT_TEXTURE* ObjectTextures; +ITEM_INFO* Items; +int LevelItems; +int NumberRooms; +ROOM_INFO* Rooms; +ANIM_STRUCT* Anims; +CHANGE_STRUCT* Changes; +RANGE_STRUCT* Ranges; +short* Commands; +int* Bones; +short* Frames; +int AnimationsCount; +short* FloorData; +int nAIObjects; +AIOBJECT* AIObjects; + +int g_NumSprites; +int g_NumSpritesSequences; + +ChunkReader* g_levelChunkIO; + +short ReadInt8() +{ + byte value = *(byte*)LevelDataPtr; + LevelDataPtr += 1; + return value; +} + +short ReadInt16() +{ + short value = *(short*)LevelDataPtr; + LevelDataPtr += 2; + return value; +} + +int ReadInt32() +{ + int value = *(int*)LevelDataPtr; + LevelDataPtr += 4; + return value; +} + +void ReadBytes(void* dest, int count) +{ + memcpy(dest, LevelDataPtr, count); + LevelDataPtr += count; +} + +int LoadItems() +{ + //DB_Log(2, "LoadItems - DLL"); + + NumItems = ReadInt32(); + if (NumItems == 0) + return false; + + Items = (ITEM_INFO*)GameMalloc(sizeof(ITEM_INFO) * NUM_ITEMS); + LevelItems = NumItems; + + InitialiseClosedDoors(); + InitialiseItemArray(NUM_ITEMS); + + if (NumItems > 0) + { + for (int i = 0; i < NumItems; i++) + { + ITEM_INFO* item = &Items[i]; + + item->objectNumber = ReadInt16(); + item->roomNumber = ReadInt16(); + item->pos.xPos = ReadInt32(); + item->pos.yPos = ReadInt32(); + item->pos.zPos = ReadInt32(); + item->pos.yRot = ReadInt16(); + item->shade = ReadInt16(); + item->triggerFlags = ReadInt16(); + item->flags = ReadInt16(); + + // DEBUG: set Lara position + /*if (item->objectNumber == ID_LARA) + { + item->pos.xPos = 33050; + item->pos.yPos = 10000; + item->pos.zPos = 21162; + item->roomNumber = 0; + }*/ + + // ANDREA2 + /*if (item->objectNumber == ID_LARA) + { + item->pos.xPos = 58*1024; + item->pos.yPos = 0; + item->pos.zPos = 39*1024; + item->roomNumber = 144; + }*/ + } + + for (int i = 0; i < NumItems; i++) + InitialiseItem(i); + } + + for (int r = 0; r < NumberRooms; r++) + { + MESH_INFO* mesh = Rooms[r].mesh; + + for (int m = 0; m < Rooms[r].numMeshes; m++) + { + FLOOR_INFO* floor = &Rooms[r].floor[((mesh->z - Rooms[r].z) >> 10) + Rooms[r].xSize * ((mesh->x - Rooms[r].x) >> 10)]; + + if (!(Boxes[floor->box].overlapIndex & 0x4000) + && !(CurrentLevel == 5 && (r == 19 || r == 23 || r == 16))) + { + int fl = floor->floor << 2; + STATIC_INFO* st = &StaticObjects[mesh->staticNumber]; + if (fl <= mesh->y - st->yMaxc + 512 && fl < mesh->y - st->yMinc) + { + if (st->xMaxc == 0 || st->xMinc == 0 || + st->zMaxc == 0 || st->zMinc == 0 || + (st->xMaxc ^ st->xMinc) & 0x8000 && + (st->xMaxc ^ st->zMinc) & 0x8000) + { + floor->box |= 8; + } + } + } + } + } + + return true; +} + +void LoadObjects() +{ + //DB_Log(2, "LoadObjects - DLL"); + + memset(Objects, 0, sizeof(OBJECT_INFO) * ID_NUMBER_OBJECTS); + memset(StaticObjects, 0, sizeof(STATIC_INFO) * NUM_STATICS); + + int numMeshDataWords = ReadInt32(); + int numMeshDataBytes = 2 * numMeshDataWords; + + MeshBase = (short*)GameMalloc(numMeshDataBytes); + ReadBytes(MeshBase, numMeshDataBytes); + + MeshDataSize = numMeshDataBytes; + + int numMeshPointers = ReadInt32(); + Meshes = (short**)GameMalloc(4 * numMeshPointers); + ReadBytes(Meshes, 4 * numMeshPointers); + + for (int i = 0; i < numMeshPointers; i++) + { + Meshes[i] = &MeshBase[(int)Meshes[i] / 2]; + } + + int numMeshes = numMeshPointers; + NumMeshPointers = numMeshes; + + int numAnimations = ReadInt32(); + Anims = (ANIM_STRUCT*)GameMalloc(sizeof(ANIM_STRUCT) * numAnimations); + ReadBytes(Anims, sizeof(ANIM_STRUCT) * numAnimations); + + int numChanges = ReadInt32(); + Changes = (CHANGE_STRUCT*)GameMalloc(sizeof(CHANGE_STRUCT) * numChanges); + ReadBytes(Changes, sizeof(CHANGE_STRUCT) * numChanges); + + int numRanges = ReadInt32(); + Ranges = (RANGE_STRUCT*)GameMalloc(sizeof(RANGE_STRUCT) * numRanges); + ReadBytes(Ranges, sizeof(RANGE_STRUCT) * numRanges); + + int numCommands = ReadInt32(); + Commands = (short*)GameMalloc(2 * numCommands); + ReadBytes(Commands, 2 * numCommands); + + int numBones = ReadInt32(); + Bones = (int*)GameMalloc(4 * numBones); + ReadBytes(Bones, 4 * numBones); + + int* bone = Bones; + for (int i = 0; i < 15; i++) + { + int opcode = *(bone++); + int linkX = *(bone++); + int linkY = *(bone++); + int linkZ = *(bone++); + } + + MeshTrees = (int*)GameMalloc(4 * numBones); + + memcpy(MeshTrees, Bones, 4 * numBones); + + int numFrames = ReadInt32(); + Frames = (short*)GameMalloc(2 * numFrames); + ReadBytes(Frames, 2 * numFrames); + + AnimationsCount = numAnimations; + if (AnimationsCount > 0) + { + int i = 0; + for (int i = 0; i < AnimationsCount; i++) + ADD_PTR(Anims[i].framePtr, short, Frames); + } + + int numModels = ReadInt32(); + NumObjects = numModels; + for (int i = 0; i < numModels; i++) + { + int objNum = ReadInt32(); + MoveablesIds.push_back(objNum); + + Objects[objNum].loaded = true; + Objects[objNum].nmeshes = ReadInt16(); + Objects[objNum].meshIndex = ReadInt16(); + Objects[objNum].boneIndex = ReadInt32(); + Objects[objNum].frameBase = (short*)(ReadInt32() + (int)Frames); + Objects[objNum].animIndex = ReadInt16(); + + ReadInt16(); + + Objects[objNum].loaded = true; + } + + InitialiseObjects(); + InitialiseClosedDoors(); + + int numStatics = ReadInt32(); + NumStaticObjects = numStatics; + for (int i = 0; i < numStatics; i++) + { + int meshID = ReadInt32(); + StaticObjectsIds.push_back(meshID); + + StaticObjects[meshID].meshNumber = ReadInt16(); + + StaticObjects[meshID].yMinp = ReadInt16(); + StaticObjects[meshID].xMaxp = ReadInt16(); + StaticObjects[meshID].yMinp = ReadInt16(); + StaticObjects[meshID].yMaxp = ReadInt16(); + StaticObjects[meshID].zMinp = ReadInt16(); + StaticObjects[meshID].zMaxp = ReadInt16(); + + StaticObjects[meshID].xMinc = ReadInt16(); + StaticObjects[meshID].xMaxc = ReadInt16(); + StaticObjects[meshID].yMinc = ReadInt16(); + StaticObjects[meshID].yMaxc = ReadInt16(); + StaticObjects[meshID].zMinc = ReadInt16(); + StaticObjects[meshID].zMaxc = ReadInt16(); + + StaticObjects[meshID].flags = ReadInt16(); + } + + // HACK: to remove after decompiling LoadSprites + MoveablesIds.push_back(ID_DEFAULT_SPRITES); +} + +void LoadCameras() +{ + NumberCameras = ReadInt32(); + if (NumberCameras != 0) + { + Camera.fixed = (OBJECT_VECTOR*)GameMalloc(NumberCameras * sizeof(OBJECT_VECTOR)); + ReadBytes(Camera.fixed, NumberCameras * sizeof(OBJECT_VECTOR)); + } + + NumberSpotcams = ReadInt32(); + + if (NumberSpotcams != 0) + { + ReadBytes(SpotCam, NumberSpotcams * sizeof(SPOTCAM)); + } +} + +void LoadTextures() +{ + //DB_Log(2, "LoadTextures - DLL"); + printf("LoadTextures\n"); + + int uncompressedSize = 0; + int compressedSize = 0; + + // Read 32 bit textures + ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); + ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); + + Texture32 = (byte*)malloc(uncompressedSize); + byte* buffer = (byte*)malloc(compressedSize); + + ReadFileEx(buffer, compressedSize, 1, LevelFilePtr); + Decompress(Texture32, buffer, compressedSize, uncompressedSize); + free(buffer); + + // Read 16 bit textures + ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); + ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); + + Texture16 = (byte*)malloc(uncompressedSize); + buffer = (byte*)malloc(compressedSize); + + ReadFileEx(buffer, compressedSize, 1u, LevelFilePtr); + Decompress(Texture16, buffer, compressedSize, uncompressedSize); + free(buffer); + + // Read misc textures + ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); + ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); + + printf("%d\n", uncompressedSize); + + MiscTextures = (byte*)malloc(uncompressedSize); + buffer = (byte*)malloc(compressedSize); + + ReadFileEx(buffer, compressedSize, 1u, LevelFilePtr); + Decompress(MiscTextures, buffer, compressedSize, uncompressedSize); + free(buffer); +} + +void ReadRoom(ROOM_INFO* room, ROOM_INFO* roomData) +{ + /*ADD_PTR(roomData->door, short, roomData + 1); + ADD_PTR(roomData->floor, FLOOR_INFO, roomData + 1); + ADD_PTR(roomData->light, LIGHTINFO, roomData + 1); + ADD_PTR(roomData->mesh, MESH_INFO, roomData + 1); + ADD_PTR(roomData->Separator4, void, roomData + 1); + ADD_PTR(roomData->LayerOffset, tr5_room_layer, roomData + 1); + ADD_PTR(roomData->PolyOffset, void, roomData + 1); + ADD_PTR(roomData->PolyOffset2, void, roomData + 1); + ADD_PTR(roomData->VerticesOffset, tr5_room_vertex, roomData + 1); + + roomData->LightDataSize += (int)(roomData + 1); + + if ((byte)roomData->door & 1) + { + ////DB_Log(0, "%X", roomData->door); + roomData->door = 0; + } + + byte* polyOff = (byte*)roomData->PolyOffset; + byte* polyOff2 = (byte*)roomData->PolyOffset2; + byte* vertOff = (byte*)roomData->VerticesOffset; + + for (int i = 0; i < roomData->NumLayers; i++) + { + roomData->LayerOffset[i].PolyOffset = polyOff; + roomData->LayerOffset[i].PolyOffset2 = polyOff2; + roomData->LayerOffset[i].VerticesOffset = vertOff; + + polyOff += sizeof(tr4_mesh_face3) * roomData->LayerOffset[i].NumLayerTriangles + + sizeof(tr4_mesh_face4) * roomData->LayerOffset[i].NumLayerRectangles; + + polyOff2 += 4 * roomData->LayerOffset[i].NumLayerVertices; // todo find what struct this is + + vertOff += sizeof(tr5_room_vertex) * roomData->LayerOffset[i].NumLayerVertices; + } + + memcpy(room, roomData, sizeof(ROOM_INFO));*/ +} + +void FixUpRoom(ROOM_INFO* room, ROOM_INFO* roomData) +{ + AddPtr(roomData->door, short, roomData + 1); + AddPtr(roomData->floor, FLOOR_INFO, roomData + 1); + AddPtr(roomData->light, tr5_room_light, roomData + 1); + AddPtr(roomData->mesh, MESH_INFO, roomData + 1); + //AddPtr(roomData->RoomLights, tr5_room_light, roomData + 1); + AddPtr(roomData->LayerOffset, tr5_room_layer, roomData + 1); + AddPtr(roomData->PolyOffset, void, roomData + 1); + AddPtr(roomData->PolyOffset2, void, roomData + 1); + AddPtr(roomData->VerticesOffset, tr5_room_vertex, roomData + 1); + + roomData->LightDataSize += (uint32_t)(roomData + 1); + + if ((uint8_t)roomData->door & 1) + { + roomData->door = nullptr; + } + + auto* polyOff = (char*)roomData->PolyOffset; + auto* polyOff2 = (char*)roomData->PolyOffset2; + auto* vertOff = (char*)roomData->VerticesOffset; + + for (int i = 0; i < roomData->NumLayers; i++) + { + roomData->LayerOffset[i].PolyOffset = polyOff; + roomData->LayerOffset[i].PolyOffset2 = polyOff2; + roomData->LayerOffset[i].VerticesOffset = vertOff; + + polyOff += sizeof(struct tr4_mesh_face3) * roomData->LayerOffset[i].NumLayerTriangles + + sizeof(struct tr4_mesh_face4) * roomData->LayerOffset[i].NumLayerRectangles; + + polyOff2 += 4 * roomData->LayerOffset[i].NumLayerVertices; // todo find what struct this is + + vertOff += sizeof(tr5_room_vertex) * roomData->LayerOffset[i].NumLayerVertices; + } + + memcpy(room, roomData, sizeof(ROOM_INFO)); +} + +void ReadRooms() +{ + ReadInt32(); + + int numRooms = ReadInt32(); + NumberRooms = numRooms; + Rooms = (ROOM_INFO*)GameMalloc(NumberRooms * sizeof(ROOM_INFO)); + + printf("NumRooms: %d\n", numRooms); + + for (int i = 0; i < NumberRooms; i++) + { + // Ignore XELA + int xela = ReadInt32(); + + // Read room data + int roomDataSize = ReadInt32(); + byte* roomData = (byte*)GameMalloc(roomDataSize); + ReadBytes(roomData, roomDataSize); + + // Put the room data in the struct + FixUpRoom(&Rooms[i], (ROOM_INFO*)roomData); + } +} + +void BuildOutsideRoomsTable() +{ + /*long max_slots = 0; + AllocT(OutsideRoomOffsets, short, 27 * 27); + AllocT(OutsideRoomTable, char, 27 * 27 * OUTSIDE_Z); + memset(OutsideRoomTable, -1, 27 * 27 * OUTSIDE_Z); + + char flipped[256]; + memset(flipped, 0, 255); + + for (int i = 0; i < number_rooms; i++) + { + if (room[i].flipped_room != -1) + flipped[i] = true; + } + + for (int y = 0; y < 108; y += 4) + { + for (int x = 0; x < 108; x += 4) + { + for (int i = 0; i < number_rooms; i++) + { + const auto r = &room[i]; + + if (!flipped[i]) + { + const int rx = (r->z >> SECTOR(1)) + 1; + const int ry = (r->x >> SECTOR(1)) + 1; + + int j = 0; + + for (int yl = 0; yl < 4; yl++) + { + for (int xl = 0; xl < 4; xl++) + { + if ((x + xl) >= rx && (x + xl) < (rx + r->x_size - 2) && + (y + yl) >= ry && (y + yl) < (ry + r->y_size - 2)) + { + j = 1; + break; + } + } + } + + if (!j) + continue; + + if (i == 255) + { + S_Warn("ERROR : Room 255 fuckeroony - go tell Chris\n"); + } + + char* d = &OutsideRoomTable[OUTSIDE_Z * (x >> 2) + OUTSIDE_Z * (y >> 2) * 27]; + + for (int j = 0; j < OUTSIDE_Z; j++) + { + if (d[j] == -1) + { + d[j] = i; + + if (j > max_slots) + max_slots = j; + + break; + } + } + + if (j == OUTSIDE_Z) + { + S_Warn("ERROR : Buffer shittage - go tell Chris\n"); + } + } + } + } + } + // todo it's a bit incorrect + char* s = OutsideRoomTable; + + for (int y = 0; y < 27; y++) + { + for (int x = 0; x < 27; x++) + { + int z = 0; + + char* d = &OutsideRoomTable[OUTSIDE_Z * x + OUTSIDE_Z * y * 27]; + + const int i = 27 * y + x; + + while (d[z] != -1) + z++; + + if (z == 0) + { + OutsideRoomOffsets[i] = -1; + } + else if (z == 1) + { + OutsideRoomOffsets[i] = *d | 0x8000; + } + else + { + char* p = OutsideRoomTable; + + while (p < s) + { + if (memcmp(p, d, z) == 0) + { + OutsideRoomOffsets[i] = p - OutsideRoomTable; + break; + } + else + { + int z2 = 0; + + while (p[z2] != -1) + z2++; + + p += z2 + 1; + } + } + + if (p >= s) + { + OutsideRoomOffsets[i] = s - OutsideRoomTable; + + while (z-- > 0) + * s++ = *d++; + + *s++ = -1; + } + } + } + }*/ +} + +void LoadRooms() +{ + //DB_Log(2, "LoadRooms - DLL"); + printf("LoadRooms\n"); + + Wibble = 0; + //RoomLightsCount = 0; + Unk_007E7FE8 = 0; + + ReadRooms(); + BuildOutsideRoomsTable(); + + int numFloorData = ReadInt32(); + FloorData = (short*)GameMalloc(numFloorData * 2); + ReadBytes(FloorData, numFloorData * 2); +} + +void FreeLevel() +{ + MallocPtr = MallocBuffer; + MallocFree = MallocSize; + g_Renderer->FreeRendererData(); + g_GameScript->FreeLevelScripts(); +} + +size_t ReadFileEx(void* ptr, size_t size, size_t count, FILE* stream) +{ + _lock_file(stream); + size_t result = fread(ptr, size, count, stream); + _unlock_file(stream); + return result; +} + +void LoadSoundEffects() +{ + NumberSoundSources = ReadInt32(); + if (NumberSoundSources) + { + SoundSources = (OBJECT_VECTOR*)GameMalloc(NumberSoundSources * sizeof(OBJECT_VECTOR)); + ReadBytes(SoundSources, NumberSoundSources * sizeof(OBJECT_VECTOR)); + } +} + +void LoadAnimatedTextures() +{ + NumAnimatedTextures = ReadInt32(); + + AnimTextureRanges = (short*)GameMalloc(NumAnimatedTextures * sizeof(short)); + ReadBytes(AnimTextureRanges, NumAnimatedTextures * sizeof(short)); + + nAnimUVRanges = ReadInt8(); +} + +void LoadTextureInfos() +{ + ReadInt32(); // TEX/0 + + NumObjectTextures = ReadInt32(); + ObjectTextures = (OBJECT_TEXTURE*)GameMalloc(NumObjectTextures * sizeof(OBJECT_TEXTURE)); + + if (NumObjectTextures > 0) + { + for (int i = 0; i < NumObjectTextures; i++) + { + tr4_object_texture srctext; + ReadBytes(&srctext, sizeof(tr4_object_texture)); + + OBJECT_TEXTURE* texture = &ObjectTextures[i]; + + texture->attribute = srctext.Attribute; + texture->tileAndFlag = srctext.TileAndFlag; // &0x7FFF; + texture->newFlags = texture->newFlags; // srctext.TileAndFlag ^ (srctext.TileAndFlag ^ srctext.NewFlags) & 0x7FFF; + + for (int j = 0; j < 4; j++) + { + texture->vertices[j].x = srctext.Vertices[j].Xpixel / 256.0; + texture->vertices[j].y = srctext.Vertices[j].Ypixel / 256.0; + } + + // Adjust UV + float fx = 1.0f / 256.0f; + float fy = 1.0f / 256.0f; + + int correction = texture->newFlags & 7; + + if (texture->tileAndFlag & 0x8000) + { + if (correction == 1) + { + texture->vertices[0].x = texture->vertices[0].x - fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x + fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x + fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + texture->vertices[3].x = texture->vertices[3].x - fx; + texture->vertices[3].y = texture->vertices[3].y - fy; + } + else + { + texture->vertices[0].x = texture->vertices[0].x + fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x - fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + texture->vertices[3].x = texture->vertices[3].x + fx; + texture->vertices[3].y = texture->vertices[3].y - fy; + } + } + else + { + switch (correction) + { + case 0: + texture->vertices[0].x = texture->vertices[0].x + fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x - fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x + fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + break; + + case 1: + texture->vertices[0].x = texture->vertices[0].x - fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x - fx; + texture->vertices[1].y = texture->vertices[1].y - fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y + fy; + break; + + case 2: + texture->vertices[0].x = texture->vertices[0].x - fx; + texture->vertices[0].y = texture->vertices[0].y - fy; + texture->vertices[1].x = texture->vertices[1].x + fx; + texture->vertices[1].y = texture->vertices[1].y - fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y + fy; + break; + + case 3: + texture->vertices[0].x = texture->vertices[0].x + fx; + texture->vertices[0].y = texture->vertices[0].y - fy; + texture->vertices[1].x = texture->vertices[1].x + fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + break; + + case 4: + texture->vertices[0].x = texture->vertices[0].x - fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x + fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + break; + + case 5: + texture->vertices[0].x = texture->vertices[0].x + fx; + texture->vertices[0].y = texture->vertices[0].y + fy; + texture->vertices[1].x = texture->vertices[1].x + fx; + texture->vertices[1].y = texture->vertices[1].y - fy; + texture->vertices[2].x = texture->vertices[2].x - fx; + texture->vertices[2].y = texture->vertices[2].y + fy; + break; + + case 6: + texture->vertices[0].x = texture->vertices[0].x + fx; + texture->vertices[0].y = texture->vertices[0].y - fy; + texture->vertices[1].x = texture->vertices[1].x - fx; + texture->vertices[1].y = texture->vertices[1].y - fy; + texture->vertices[2].x = texture->vertices[2].x + fx; + texture->vertices[2].y = texture->vertices[2].y + fy; + break; + + case 7: + texture->vertices[0].x = texture->vertices[0].x - fx; + texture->vertices[0].y = texture->vertices[0].y - fy; + texture->vertices[1].x = texture->vertices[1].x - fx; + texture->vertices[1].y = texture->vertices[1].y + fy; + texture->vertices[2].x = texture->vertices[2].x + fx; + texture->vertices[2].y = texture->vertices[2].y - fy; + break; + + } + } + } + } +} + +void LoadAIObjects() +{ + nAIObjects = ReadInt32(); + + if (nAIObjects != 0) + { + AIObjects = (AIOBJECT*)GameMalloc(nAIObjects * sizeof(AIOBJECT)); + ReadBytes(&AIObjects, nAIObjects * sizeof(AIOBJECT)); + } +} + +FILE* FileOpen(const char* fileName) +{ + FILE* ptr = fopen(fileName, "rb"); + return ptr; +} + +void FileClose(FILE* ptr) +{ + fclose(ptr); +} + +void Decompress(byte* dest, byte* src, unsigned long compressedSize, unsigned long uncompressedSize) +{ + int z_result = uncompress( + + dest, // destination for the uncompressed + // data. This should be the size of + // the original data, which you should + // already know. + + &uncompressedSize, // length of destination (uncompressed) + // buffer + + src, // source buffer - the compressed data + + compressedSize); // length of compressed data in bytes + + switch (z_result) + { + case Z_OK: + printf("***** SUCCESS! *****\n"); + break; + + case Z_MEM_ERROR: + printf("out of memory\n"); + exit(1); // quit. + break; + + case Z_BUF_ERROR: + printf("output buffer wasn't large enough!\n"); + exit(1); // quit. + break; + } +} + +unsigned __stdcall LoadLevel(void* data) +{ + //DB_Log(5, "LoadLevel - DLL"); + printf("LoadLevel\n"); + + char* filename = (char*)data; + + LevelDataPtr = NULL; + LevelFilePtr = NULL; + + g_Renderer->UpdateProgress(0); + + LevelFilePtr = FileOpen(filename); + if (LevelFilePtr) + { + int version; + short numRoomTextureTiles; + short numObjectsTextureTiles; + short numBumpTextureTiles; + + ReadFileEx(&version, 1, 4, LevelFilePtr); + ReadFileEx(&numRoomTextureTiles, 1, 2, LevelFilePtr); + ReadFileEx(&numObjectsTextureTiles, 1, 2, LevelFilePtr); + ReadFileEx(&numBumpTextureTiles, 1, 2, LevelFilePtr); + + g_Renderer->NumTexturePages = numRoomTextureTiles + numObjectsTextureTiles + numBumpTextureTiles; + + LoadTextures(); + + g_Renderer->UpdateProgress(20); + + short buffer[32]; + ReadFileEx(&buffer, 2, 16, LevelFilePtr); + WeatherType = buffer[0]; + LaraDrawType = buffer[1]; + + int uncompressedSize; + int compressedSize; + + ReadFileEx(&uncompressedSize, 1, 4, LevelFilePtr); + ReadFileEx(&compressedSize, 1, 4, LevelFilePtr); + + LevelDataPtr = (char*)malloc(uncompressedSize); + ReadFileEx(LevelDataPtr, uncompressedSize, 1, LevelFilePtr); + + LoadRooms(); + g_Renderer->UpdateProgress(40); + + LoadObjects(); + g_Renderer->UpdateProgress(50); + + InitialiseLOTarray(true); + LoadSprites(); + LoadCameras(); + LoadSoundEffects(); + g_Renderer->UpdateProgress(60); + + LoadBoxes(); + LoadAnimatedTextures(); + LoadTextureInfos(); + g_Renderer->UpdateProgress(70); + + LoadItems(); + LoadAIObjects(); + //LoadDemoData(); + LoadSamples(); + g_Renderer->UpdateProgress(80); + + int extraSize = 0; + ReadFileEx(&extraSize, 1, 4, LevelFilePtr); + if (extraSize > 0) + { + ReadFileEx(&extraSize, 1, 4, LevelFilePtr); + LevelDataPtr = (char*)malloc(extraSize); + ReadFileEx(LevelDataPtr, extraSize, 1, LevelFilePtr); + + LoadNewData(extraSize); + } + + LevelDataPtr = NULL; + FileClose(LevelFilePtr); + } + else + { + return false; + } + + g_Renderer->UpdateProgress(90); + g_Renderer->PrepareDataForTheRenderer(); + + // Initialise the game + GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel); + + SeedRandomDraw(0xD371F947); + SeedRandomControl(0xD371F947); + Wibble = 0; + TorchRoom = -1; + InitialiseGameFlags(); + InitialiseLara(!(InitialiseGame || CurrentLevel == 1 || level->ResetHub)); + GetCarriedItems(); + GetAIPickups(); + SeedRandomDraw(0xD371F947); + SeedRandomControl(0xD371F947); + g_LaraExtra.Vehicle = -1; + g_GameScript->AssignItemsAndLara(); + + // Level loaded + IsLevelLoading = false; + g_Renderer->UpdateProgress(100); + + _endthreadex(1); + + return true; +} + +void LoadSamples() +{ + // Legacy soundmap size was 450, for now let's store new soundmap size into NumDemoData field + SoundMapSize = ReadInt16(); + + if (SoundMapSize == 0) + SoundMapSize = SOUND_LEGACY_SOUNDMAP_SIZE; + + for (int i = 0; i < SoundMapSize; i++) + SampleLUT[i] = ReadInt16(); + + NumSamplesInfos = ReadInt32(); + if (NumSamplesInfos) + { + SampleInfo = (SAMPLE_INFO*)GameMalloc(NumSamplesInfos * sizeof(SAMPLE_INFO)); + ReadBytes(SampleInfo, NumSamplesInfos * sizeof(SAMPLE_INFO)); + + int numSampleIndices = ReadInt32(); + if (numSampleIndices) + { + int numSamples = 0; + ReadFileEx(&numSamples, 1, 4, LevelFilePtr); + //if (feof(LevelFilePtr)) + // return; + + if (numSamples <= 0) + return; + + int uncompressedSize; + int compressedSize; + char* buffer = (char*)malloc(1048576); + + for (int i = 0; i < numSamples; i++) + { + ReadFileEx(&uncompressedSize, 4, 1, LevelFilePtr); + ReadFileEx(&compressedSize, 4, 1, LevelFilePtr); + ReadFileEx(buffer, 1, compressedSize, LevelFilePtr); + Sound_LoadSample(buffer, compressedSize, uncompressedSize, i); + } + + free(buffer); + } + } + else + { + //Log(1, aNoSampleInfos); + } +} + +void LoadBoxes() +{ + // Read boxes + NumberBoxes = ReadInt32(); + Boxes = (BOX_INFO*)GameMalloc(NumberBoxes * sizeof(BOX_INFO)); + ReadBytes(Boxes, NumberBoxes * sizeof(BOX_INFO)); + + // Read overlaps + NumberOverlaps = ReadInt32(); + Overlaps = (short*)GameMalloc(NumberOverlaps * sizeof(short)); + ReadBytes(Overlaps, NumberOverlaps * sizeof(short)); + + // Read zones + for (int i = 0; i < 2; i++) + { + // Ground zones + for (int j = 0; j < 4; j++) + { + short* zone = (short*)GameMalloc(NumberBoxes * sizeof(short)); + ReadBytes(zone, NumberBoxes * sizeof(short)); + Zones[j][i] = zone; + } + + // Fly zone + short* zone = (short*)GameMalloc(NumberBoxes * sizeof(short)); + ReadBytes(zone, NumberBoxes * sizeof(short)); + Zones[4][i] = zone; + } + + // By default all blockable boxes are blocked + for (int i = 0; i < NumberBoxes; i++) + { + if (Boxes[i].overlapIndex & BLOCKABLE) + { + Boxes[i].overlapIndex |= BLOCKED; + } + } +} + +int S_LoadLevelFile(int levelIndex) +{ + //DB_Log(2, "S_LoadLevelFile - DLL"); + printf("S_LoadLevelFile\n"); + + SOUND_Stop(); + Sound_FreeSamples(); + if (!g_FirstLevel) + FreeLevel(); + g_FirstLevel = false; + RenderLoadBar = false; + + char filename[80]; + GameScriptLevel* level = g_GameFlow->Levels[levelIndex]; + strcpy_s(filename, level->FileName.c_str()); + + // Loading level is done is two threads, one for loading level and one for drawing loading screen + IsLevelLoading = true; + hLoadLevel = _beginthreadex(0, 0, LoadLevel, filename, 0, &ThreadId); + + // This function loops until progress is 100%. Not very thread safe, but behaviour should be predictable. + g_Renderer->DrawLoadingScreen((char*)(level->LoadScreenFileName.c_str())); + + while (IsLevelLoading); + + return true; +} + +void AdjustUV(int num) +{ + // Dummy function + NumObjectTextures = num; +} + +bool ReadLuaIds(ChunkId* chunkId, int maxSize, int arg) +{ + if (chunkId->EqualsTo(ChunkLuaId)) + { + int luaId = 0; + g_levelChunkIO->GetRawStream()->ReadInt32(&luaId); + + int itemId = 0; + g_levelChunkIO->GetRawStream()->ReadInt32(&itemId); + + g_GameScript->AddLuaId(luaId, itemId); + + return true; + } + else + return false; +} + +bool ReadLuaTriggers(ChunkId* chunkId, int maxSize, int arg) +{ + if (chunkId->EqualsTo(ChunkTrigger)) + { + char* functionName = NULL; + g_levelChunkIO->GetRawStream()->ReadString(&functionName); + + char* functionCode = NULL; + g_levelChunkIO->GetRawStream()->ReadString(&functionCode); + + LuaFunction* function = new LuaFunction(); + function->Name = string(functionName); + function->Code = string(functionCode); + function->Executed = false; + + g_GameScript->AddTrigger(function); + + delete functionName; + delete functionCode; + + return true; + } + else + return false; +} + +bool ReadNewDataChunks(ChunkId* chunkId, int maxSize, int arg) +{ + if (chunkId->EqualsTo(ChunkTriggersList)) + return g_levelChunkIO->ReadChunks(ReadLuaTriggers, 0); + else if (chunkId->EqualsTo(ChunkLuaIds)) + return g_levelChunkIO->ReadChunks(ReadLuaIds, 0); + return false; +} + +void LoadNewData(int size) +{ + // Free old level scripts + MemoryStream stream(LevelDataPtr, size); + g_levelChunkIO = new ChunkReader(0x4D355254, &stream); + if (!g_levelChunkIO->IsValid()) + return; + + g_levelChunkIO->ReadChunks(ReadNewDataChunks, 0); +} + +void LoadSprites() +{ + //DB_Log(2, "LoadSprites"); + + ReadInt32(); // SPR\0 + + g_NumSprites = ReadInt32(); + + Sprites = (SPRITE*)GameMalloc(g_NumSprites * sizeof(SPRITE)); + + for (int i = 0; i < g_NumSprites; i++) + { + Sprites[i].tile = ReadInt16() + 1; + Sprites[i].x = ReadInt8(); + Sprites[i].y = ReadInt8(); + Sprites[i].width = ReadInt16(); + Sprites[i].height = ReadInt16(); + Sprites[i].left = (ReadInt16() + 1) / 256.0; + Sprites[i].top = (ReadInt16() + 1) / 256.0; + Sprites[i].right = (ReadInt16() - 1) / 256.0; + Sprites[i].bottom = (ReadInt16() - 1) / 256.0; + } + + g_NumSpritesSequences = ReadInt32(); + + for (int i = 0; i < g_NumSpritesSequences; i++) + { + int spriteID = ReadInt32(); + short negLength = ReadInt16(); + short offset = ReadInt16(); + if (spriteID >= ID_NUMBER_OBJECTS) + { + StaticObjects[spriteID - ID_NUMBER_OBJECTS].meshNumber = offset; + } + else + { + Objects[spriteID].nmeshes = negLength; + Objects[spriteID].meshIndex = offset; + Objects[spriteID].loaded = true; + } + } +} + +void GetCarriedItems() +{ + int i; + ITEM_INFO* item, *item2; + short linknum; + + for (i = 0; i < LevelItems; ++i) + Items[i].carriedItem = NO_ITEM; + for (i = 0; i < LevelItems; ++i) + { + item = &Items[i]; + if (Objects[item->objectNumber].intelligent || item->objectNumber >= ID_SEARCH_OBJECT1 && item->objectNumber <= ID_SEARCH_OBJECT3) + { + for (linknum = Rooms[item->roomNumber].itemNumber; linknum != NO_ITEM; linknum = Items[linknum].nextItem) + { + item2 = &Items[linknum]; + if (abs(item2->pos.xPos - item->pos.xPos) < 512 + && abs(item2->pos.zPos - item->pos.zPos) < 512 + && abs(item2->pos.yPos - item->pos.yPos) < 256 + && Objects[item2->objectNumber].collision == PickupCollision) + { + item2->carriedItem = item->carriedItem; + item->carriedItem = linknum; + RemoveDrawnItem(linknum); + item2->roomNumber = NO_ROOM; + } + } + } + } +} + +void GetAIPickups() +{ + int i, num; + ITEM_INFO* item; + AIOBJECT* object; + + for (i = 0; i < LevelItems; ++i) + { + item = &Items[i]; + if (Objects[item->objectNumber].intelligent) + { + item->aiBits = 0; + for (num = 0; num < nAIObjects; ++num) + { + object = &AIObjects[num]; + if (abs(object->x - item->pos.xPos) < 512 + && abs(object->z - item->pos.zPos) < 512 + && object->roomNumber == item->roomNumber + && object->objectNumber < ID_AI_PATROL2) + { + item->aiBits = (1 << object->objectNumber - ID_AI_GUARD) & 0x1F; + item->itemFlags[3] = object->triggerFlags; + if (object->objectNumber != ID_AI_GUARD) + object->roomNumber = NO_ROOM; + } + } + item->TOSSPAD |= item->aiBits << 8 | (char) item->itemFlags[3]; + } + } +} + +void Inject_level() +{ + INJECT(0x004A6380, LoadItems); + INJECT(0x004A4E60, LoadObjects); + INJECT(0x004A3FC0, LoadTextures); + INJECT(0x0040130C, S_LoadLevelFile); + INJECT(0x004A7130, FreeLevel); + INJECT(0x004A5430, AdjustUV); + INJECT(0x004A5CA0, LoadCameras); } \ No newline at end of file diff --git a/TR5Main/Specific/level.h b/TR5Main/Specific/level.h new file mode 100644 index 000000000..7cff95442 --- /dev/null +++ b/TR5Main/Specific/level.h @@ -0,0 +1,91 @@ +#pragma once + +#include "..\Global\global.h" + +#include +#include + +#include "IO/ChunkId.h" +#include "IO/ChunkReader.h" +#include "IO/LEB128.h" + +struct ChunkId; +struct LEB128; + +#define AddPtr(p, t, n) p = (t*)((char*)(p) + (ptrdiff_t)(n)); + +using namespace std; + +extern byte* Texture32; +extern byte* Texture16; +extern byte* MiscTextures; +extern short* MeshData; +extern int MeshDataSize; +extern OBJECT_TEXTURE* NewObjectTextures; +extern uintptr_t hLoadLevel; +extern int NumMeshPointers; +extern int* MeshTrees; +extern int NumObjects; +extern int NumStaticObjects; +extern vector MoveablesIds; +extern vector StaticObjectsIds; +extern int* RawMeshPointers; +extern short* RawMeshData; +extern int NumObjectTextures; +extern char* LevelDataPtr; +extern int IsLevelLoading; +extern int NumTextureTiles; +extern int g_NumSprites; +extern int g_NumSpritesSequences; +extern short* MeshBase; +extern short** Meshes; +extern int NumItems; +extern OBJECT_TEXTURE* ObjectTextures; +extern ITEM_INFO* Items; +extern int LevelItems; +extern int NumberRooms; +extern ROOM_INFO* Rooms; +extern ANIM_STRUCT* Anims; +extern CHANGE_STRUCT* Changes; +extern RANGE_STRUCT* Ranges; +extern short* Commands; +extern int* Bones; +extern short* Frames; +extern int AnimationsCount; +extern short* FloorData; +extern int nAIObjects; +extern AIOBJECT* AIObjects; + +void LoadTextures(); +void LoadRooms(); +int LoadItems(); +void LoadObjects(); +int S_LoadLevelFile(int levelIndex); +void FreeLevel(); +void AdjustUV(int num); +void LoadCameras(); +void InitialiseLara(int restore); +void LoadSprites(); +void GetCarriedItems(); +void GetAIPickups(); +void LoadBoxes(); +void LoadSamples(); +size_t ReadFileEx(void* ptr, size_t size, size_t count, FILE* stream); +void LoadSoundEffects(); +void LoadAnimatedTextures(); +void LoadTextureInfos(); +void LoadAIObjects(); +FILE* FileOpen(const char* fileName); +void FileClose(FILE* ptr); +void FixUpRoom(ROOM_INFO* room, ROOM_INFO* roomData); +void Decompress(byte* dest, byte* src, unsigned long compressedSize, unsigned long uncompressedSize); + +unsigned __stdcall LoadLevel(void* data); + +// New functions for loading data from TR5M footer +bool ReadLuaIds(ChunkId* chunkId, int maxSize, int arg); +bool ReadLuaTriggers(ChunkId* chunkId, int maxSize, int arg); +bool ReadNewDataChunks(ChunkId* chunkId, int maxSize, int arg); +void LoadNewData(int size); + +void Inject_level(); \ No newline at end of file diff --git a/TR5Main/Specific/roomload.h b/TR5Main/Specific/roomload.h deleted file mode 100644 index 143ae2a0d..000000000 --- a/TR5Main/Specific/roomload.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include "..\Global\global.h" - -#include -#include - -#include "IO/ChunkId.h" -#include "IO/ChunkReader.h" -#include "IO/LEB128.h" - -struct ChunkId; -struct LEB128; - -#define DoSomethingWithRooms ((void (__cdecl*)()) 0x004774D0) -#define FreeItemsStuff ((void (__cdecl*)(int)) 0x00440590) -//#define InitialiseClosedDoors ((void (__cdecl*)()) 0x00473600) -//#define CreateSkinningData ((void (__cdecl*)()) 0x00456AE0) -//#define ProcessMeshData ((void (__cdecl*)(int)) 0x0049A3D0) -#define ReadFileEx ((int (__cdecl*)(void*, int, int, FILE*)) 0x004E1D20) -#define Decompress ((int (__cdecl*)(byte*, byte*, int, int)) 0x004A3EF0) -#define ReadRoomOriginal ((int (__cdecl*)(ROOM_INFO*, ROOM_INFO*)) 0x004917D0) -#define ReadRoomsOriginal ((int (__cdecl*)()) 0x004916C0) -#define FileOpen ((FILE* (__cdecl*)(char*)) 0x004A3CD0) -#define FileClose ((void (__cdecl*)(FILE*)) 0x004A3DA0) -#define LoadSoundEffects ((void (__cdecl*)()) 0x004A5D90) -#define Legacy_LoadBoxes ((void (__cdecl*)()) 0x004A5E50) -#define LoadAnimatedTextures ((void (__cdecl*)()) 0x004A6060) -#define LoadTextureInfos ((void (__cdecl*)()) 0x004A60E0) -#define LoadAIObjects ((void (__cdecl*)()) 0x004A67F0) -#define LoadDemoData ((void (__cdecl*)()) 0x004A67D0) -//#define LoadSamples ((void (__cdecl*)()) 0x004A6880) -//#define InitialiseLaraLoad ((void (__cdecl*)(short)) 0x004568C0) -#define LoadRooms ((void (__cdecl*)()) 0x004A4DA0) -#define InitialiseGameStuff ((void (__cdecl*)()) 0x004778F0) -#define InitialiseLaraMeshes ((void (__cdecl*)()) 0x00455680) -//#define InitialiseLaraAnims ((void (__cdecl*)(ITEM_INFO*)) 0x00456900) - -using namespace std; - -extern byte* Texture32; -extern byte* Texture16; -extern byte* MiscTextures; -extern short* MeshData; -extern int MeshDataSize; -extern OBJECT_TEXTURE* NewObjectTextures; -extern uintptr_t hLoadLevel; -extern int NumMeshPointers; -extern int* MeshTrees; -extern int NumObjects; -extern int NumStaticObjects; -extern vector MoveablesIds; -extern vector StaticObjectsIds; -extern int* RawMeshPointers; -extern short* RawMeshData; -extern int NumObjectTextures; -extern char* LevelDataPtr; -extern int IsLevelLoading; -extern int NumTextureTiles; -extern int g_NumSprites; -extern int g_NumSpritesSequences; -extern short* MeshBase; -extern short** Meshes; -extern int NumItems; - -void LoadTextures(); -int LoadRoomsNew(); -int LoadItems(); -void LoadObjects(); -int S_LoadLevelFile(int levelIndex); -void FreeLevel(); -void AdjustUV(int num); -void LoadCameras(); -void InitialiseLara(int restore); -void LoadSprites(); -void GetCarriedItems(); -void GetAIPickups(); -void LoadBoxes(); -void LoadSamples(); - -unsigned __stdcall LoadLevel(void* data); - -// New functions for loading data from TR5M footer -bool ReadLuaIds(ChunkId* chunkId, int maxSize, int arg); -bool ReadLuaTriggers(ChunkId* chunkId, int maxSize, int arg); -bool ReadNewDataChunks(ChunkId* chunkId, int maxSize, int arg); -void LoadNewData(int size); - -void Inject_RoomLoad(); \ No newline at end of file diff --git a/TR5Main/Specific/setup.cpp b/TR5Main/Specific/setup.cpp index 4ba42ff24..cede1c7af 100644 --- a/TR5Main/Specific/setup.cpp +++ b/TR5Main/Specific/setup.cpp @@ -22,7 +22,7 @@ #include "..\Objects\oldobjects.h" #include "..\Objects\newobjects.h" -#include "roomload.h" +#include "level.h" #include #include diff --git a/TR5Main/Specific/winmain.cpp b/TR5Main/Specific/winmain.cpp index 910fe95bb..55f29034d 100644 --- a/TR5Main/Specific/winmain.cpp +++ b/TR5Main/Specific/winmain.cpp @@ -1,4 +1,3 @@ -#include "game.h" #include "init.h" #include "winmain.h" #include @@ -16,7 +15,8 @@ #include "..\Game\control.h" #include "..\Game\gameflow.h" #include "..\Game\savegame.h" -#include "..\Specific\roomload.h" +#include "..\Specific\level.h" +#include "..\Specific\level.h" #include "configuration.h" @@ -37,7 +37,7 @@ int WinProcMsg() int result; struct tagMSG Msg; - DB_Log(2, "WinProcMsg"); + //DB_Log(2, "WinProcMsg"); do { GetMessageA(&Msg, 0, 0, 0); @@ -56,17 +56,17 @@ void __stdcall HandleWmCommand(unsigned short wParam) { if (wParam == 8) { - DB_Log(5, "Pressed ALT + ENTER"); + //DB_Log(5, "Pressed ALT + ENTER"); if (!IsLevelLoading) { SuspendThread((HANDLE)hThread); - DB_Log(5, "Game thread suspended"); + //DB_Log(5, "Game thread suspended"); g_Renderer->ToggleFullScreen(); ResumeThread((HANDLE)hThread); - DB_Log(5, "Game thread resumed"); + //DB_Log(5, "Game thread resumed"); if (g_Renderer->IsFullsScreen()) { @@ -93,7 +93,7 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_COMMAND) { - DB_Log(6, "WM_COMMAND"); + //DB_Log(6, "WM_COMMAND"); HandleWmCommand((unsigned short)wParam); } @@ -102,7 +102,7 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) if (msg == WM_CLOSE) { - DB_Log(6, "WM_CLOSE"); + //DB_Log(6, "WM_CLOSE"); receivedWmClose = true; PostQuitMessage(0); @@ -116,7 +116,7 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return DefWindowProcA(hWnd, msg, wParam, (LPARAM)lParam); } - DB_Log(6, "WM_ACTIVATE"); + //DB_Log(6, "WM_ACTIVATE"); if (receivedWmClose) { @@ -130,29 +130,29 @@ LRESULT CALLBACK WinAppProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if ((signed int)(unsigned short)wParam > 0 && (signed int)(unsigned short)wParam <= 2) { - DB_Log(6, "WM_ACTIVE"); + //DB_Log(6, "WM_ACTIVE"); if (!Debug) ResumeThread((HANDLE)hThread); App_Unk00D9ABFD = 0; - DB_Log(5, "Game Thread Resumed"); + //DB_Log(5, "Game Thread Resumed"); return 0; } } else { - DB_Log(6, "WM_INACTIVE"); - DB_Log(5, "HangGameThread"); + //DB_Log(6, "WM_INACTIVE"); + //DB_Log(5, "HangGameThread"); App_Unk00D9ABFD = 1; if (!Debug) SuspendThread((HANDLE)hThread); - DB_Log(5, "Game Thread Suspended"); + //DB_Log(5, "Game Thread Suspended"); } return 0; @@ -316,7 +316,7 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL int WinClose() { - DB_Log(2, "WinClose - DLL"); + //DB_Log(2, "WinClose - DLL"); DestroyAcceleratorTable(hAccTable); diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj index 1170dc2bf..7950577b8 100644 --- a/TR5Main/TR5Main.vcxproj +++ b/TR5Main/TR5Main.vcxproj @@ -47,8 +47,8 @@ true $(ProjectDir)..\Build\ $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86 - $(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua - $(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua + F:\Software\TR5Main\TR5Main\Libs\zlib;F:\Software\TR5Main\TR5Main\Libs\zlib\include;$(IncludePath);$(DXSDK_DIR)Include;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)TR5Main\Libs\lua + F:\Software\TR5Main\TR5Main\Libs\zlib\dll32;$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua false @@ -76,7 +76,7 @@ true $(OutDir)$(TargetName)$(TargetExt) C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86;%(AdditionalLibraryDirectories) - comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;%(AdditionalDependencies) + comctl32.lib;lua53.lib;bass.lib;bassmix.lib;bass_fx.lib;D3DCompiler.lib;dxgi.lib;dxguid.lib;d3d11.lib;zlib.lib;%(AdditionalDependencies) false @@ -212,7 +212,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - + @@ -383,7 +383,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - + diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters index fc045f424..80f4e8550 100644 --- a/TR5Main/TR5Main.vcxproj.filters +++ b/TR5Main/TR5Main.vcxproj.filters @@ -186,9 +186,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -312,6 +309,9 @@ File di intestazione + + File di intestazione + @@ -446,9 +446,6 @@ File di origine - - File di origine - File di origine @@ -824,6 +821,9 @@ File di origine + + File di origine + diff --git a/TR5Main/dllmain.cpp b/TR5Main/dllmain.cpp index a049bc439..322b11302 100644 Binary files a/TR5Main/dllmain.cpp and b/TR5Main/dllmain.cpp differ