This commit is contained in:
Montagna Marco 2020-06-26 07:06:51 +02:00
commit d6f45db5ec
55 changed files with 26453 additions and 22588 deletions

View file

@ -262,7 +262,7 @@ void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraKillSt
*/ */
} }
short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, function<CreatureEffectFunction> func) short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, std::function<CreatureEffectFunction> func)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
pos.x = bite->x; pos.x = bite->x;
@ -272,7 +272,7 @@ short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angl
return func(pos.x, pos.y, pos.z, damage, angle, item->roomNumber); return func(pos.x, pos.y, pos.z, damage, angle, item->roomNumber);
} }
short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, function<CreatureEffectFunction> func) short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, std::function<CreatureEffectFunction> func)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
pos.x = bite->x; pos.x = bite->x;

View file

@ -4,7 +4,7 @@
#include "control.h" #include "control.h"
#include "trmath.h" #include "trmath.h"
#include "objectslist.h" #include "objectslist.h"
using std::vector;
extern vector<BUBBLE_STRUCT> Bubbles = vector<BUBBLE_STRUCT>(MAX_BUBBLES); extern vector<BUBBLE_STRUCT> Bubbles = vector<BUBBLE_STRUCT>(MAX_BUBBLES);
void UpdateBubbles() void UpdateBubbles()

View file

@ -9,7 +9,7 @@
#include "setup.h" #include "setup.h"
#include "sound.h" #include "sound.h"
#include "trmath.h" #include "trmath.h"
using std::vector;
char LM[] = char LM[] =
{ {
LM_HIPS, LM_HIPS,

View file

@ -43,6 +43,7 @@
#include "spark.h" #include "spark.h"
#include "explosion.h" #include "explosion.h"
#include "drip.h" #include "drip.h"
using std::vector;
using namespace T5M::Effects::Explosion; using namespace T5M::Effects::Explosion;
using namespace T5M::Effects::Spark; using namespace T5M::Effects::Spark;
using namespace T5M::Effects::Smoke; using namespace T5M::Effects::Smoke;

View file

@ -18,7 +18,7 @@
#include "tr5_bats_emitter.h" #include "tr5_bats_emitter.h"
#include "tr5_spider_emitter.h" #include "tr5_spider_emitter.h"
#include "pickup.h" #include "pickup.h"
using std::function;
constexpr auto ITEM_RADIUS_YMAX = SECTOR(3); constexpr auto ITEM_RADIUS_YMAX = SECTOR(3);
int wf = 256; int wf = 256;
using namespace T5M::Effects::Footprints; using namespace T5M::Effects::Footprints;

View file

@ -9,6 +9,7 @@
namespace T5M { namespace T5M {
namespace Effects { namespace Effects {
namespace Footprints { namespace Footprints {
using std::deque;
std::deque<FOOTPRINT_STRUCT> footprints = deque<FOOTPRINT_STRUCT>(); std::deque<FOOTPRINT_STRUCT> footprints = deque<FOOTPRINT_STRUCT>();
bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition) { bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition) {

View file

@ -5,7 +5,8 @@
#include "input.h" #include "input.h"
#include "level.h" #include "level.h"
using std::string;
using std::vector;
SavegameInfo g_SavegameInfos[MAX_SAVEGAMES]; SavegameInfo g_SavegameInfos[MAX_SAVEGAMES];
SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES]; SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES];
vector<string> g_NewStrings; vector<string> g_NewStrings;

View file

@ -34,7 +34,7 @@ struct GAMEFLOW
}; };
extern SavegameInfo g_SavegameInfos[MAX_SAVEGAMES]; extern SavegameInfo g_SavegameInfos[MAX_SAVEGAMES];
extern vector<string> g_NewStrings; extern std::vector<std::string> g_NewStrings;
extern SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES]; extern SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES];
int LoadSavegameInfos(); int LoadSavegameInfos();

View file

@ -16,7 +16,7 @@
#include "lara2gun.h" #include "lara2gun.h"
#include "level.h" #include "level.h"
#include "input.h" #include "input.h"
using std::vector;
Inventory g_Inventory; Inventory g_Inventory;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;

View file

@ -31,7 +31,7 @@
#include "upv.h" #include "upv.h"
#include "kayak.h" #include "kayak.h"
#include "minecart.h" #include "minecart.h"
using std::function;
static short LeftClimbTab[4] = // offset 0xA0638 static short LeftClimbTab[4] = // offset 0xA0638
{ {
0x0200, 0x0400, 0x0800, 0x0100 0x0200, 0x0400, 0x0800, 0x0100
@ -691,13 +691,13 @@ void lara_as_stop(ITEM_INFO* item, COLL_INFO* coll)
return; return;
} }
if (height >= -STEP_SIZE || fheight >= -STEP_SIZE) // if (height >= -STEP_SIZE || fheight >= -STEP_SIZE)
{ // {
if (TrInput & IN_WALK) if (TrInput & IN_WALK)
lara_as_walk(item, coll); lara_as_walk(item, coll);
else else
lara_as_run(item, coll); lara_as_run(item, coll);
} /* }
else else
{ {
Lara.moveAngle = item->pos.yRot; Lara.moveAngle = item->pos.yRot;
@ -715,7 +715,7 @@ void lara_as_stop(ITEM_INFO* item, COLL_INFO* coll)
coll->radius = LARA_RAD; coll->radius = LARA_RAD;
item->goalAnimState = STATE_LARA_STOP; item->goalAnimState = STATE_LARA_STOP;
} }
} }*/
} }
else if (TrInput & IN_BACK) else if (TrInput & IN_BACK)
{ {

View file

@ -4,7 +4,7 @@
#include "level.h" #include "level.h"
#include "lara.h" #include "lara.h"
#include "draw.h" #include "draw.h"
using std::vector;
short GF(short animIndex, short frameToStart) short GF(short animIndex, short frameToStart)
{ {
return Anims[animIndex].frameBase + frameToStart; return Anims[animIndex].frameBase + frameToStart;

View file

@ -24,4 +24,4 @@ CREATURE_INFO* GetCreatureInfo(ITEM_INFO* item);
void TargetNearestEntity(ITEM_INFO* item, CREATURE_INFO* creature); void TargetNearestEntity(ITEM_INFO* item, CREATURE_INFO* creature);
void GetRoomList(short roomNumber, short* roomArray, short* numRooms); // return the value via roomArray and numRooms void GetRoomList(short roomNumber, short* roomArray, short* numRooms); // return the value via roomArray and numRooms
void GetRoomList(short roomNumber, vector<short>* DestRoomList); // return the value via DestRoomList void GetRoomList(short roomNumber, std::vector<short>* DestRoomList); // return the value via DestRoomList

View file

@ -943,9 +943,9 @@ void PickupCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
}*/ }*/
} }
/* item->pos.xRot = oldXrot; item->pos.xRot = oldXrot;
item->pos.yRot = oldYrot; item->pos.yRot = oldYrot;
item->pos.zRot = oldZrot;*/ item->pos.zRot = oldZrot;
return; return;
} }

View file

@ -17,7 +17,8 @@
#include "tr5_rats_emitter.h" #include "tr5_rats_emitter.h"
#include "tr5_bats_emitter.h" #include "tr5_bats_emitter.h"
#include "tr5_spider_emitter.h" #include "tr5_spider_emitter.h"
using std::string;
using std::vector;
FileStream* SaveGame::m_stream; FileStream* SaveGame::m_stream;
ChunkReader* SaveGame::m_reader; ChunkReader* SaveGame::m_reader;
ChunkWriter* SaveGame::m_writer; ChunkWriter* SaveGame::m_writer;

View file

@ -67,7 +67,7 @@ private:
static FileStream* m_stream; static FileStream* m_stream;
static ChunkReader* m_reader; static ChunkReader* m_reader;
static ChunkWriter* m_writer; static ChunkWriter* m_writer;
static vector<LuaVariable> m_luaVariables; static std::vector<LuaVariable> m_luaVariables;
static ChunkId* m_chunkGameStatus; static ChunkId* m_chunkGameStatus;
static ChunkId* m_chunkItems; static ChunkId* m_chunkItems;

View file

@ -5,7 +5,7 @@
#include "configuration.h" #include "configuration.h"
#include "level.h" #include "level.h"
#include "winmain.h" #include "winmain.h"
using std::vector;
HSTREAM BASS_3D_Mixdown; HSTREAM BASS_3D_Mixdown;
HFX BASS_FXHandler[NUM_SOUND_FILTERS]; HFX BASS_FXHandler[NUM_SOUND_FILTERS];
SoundTrackSlot BASS_Soundtrack[NUM_SOUND_TRACK_TYPES]; SoundTrackSlot BASS_Soundtrack[NUM_SOUND_TRACK_TYPES];

View file

@ -2041,9 +2041,7 @@ typedef struct AudioTrack
byte Mask; byte Mask;
}; };
using namespace std; extern std::vector<AudioTrack> g_AudioTracks;
extern vector<AudioTrack> g_AudioTracks;
extern short SampleLUT[SOUND_NEW_SOUNDMAP_MAX_SIZE]; extern short SampleLUT[SOUND_NEW_SOUNDMAP_MAX_SIZE];
extern short SoundMapSize; extern short SoundMapSize;
extern int NumSamplesInfos; extern int NumSamplesInfos;

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp $ ** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -218,7 +218,7 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
** =================================================================== ** ===================================================================
*/ */
/* print a std::string */ /* print a string */
#if !defined(lua_writestring) #if !defined(lua_writestring)
#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
#endif #endif

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.332 2016/12/22 15:51:20 roberto Exp $ ** $Id: lua.h,v 1.332.1.2 2018/06/13 16:58:17 roberto Exp $
** Lua - A Scripting Language ** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file ** See Copyright Notice at the end of this file
@ -19,11 +19,11 @@
#define LUA_VERSION_MAJOR "5" #define LUA_VERSION_MAJOR "5"
#define LUA_VERSION_MINOR "3" #define LUA_VERSION_MINOR "3"
#define LUA_VERSION_NUM 503 #define LUA_VERSION_NUM 503
#define LUA_VERSION_RELEASE "4" #define LUA_VERSION_RELEASE "5"
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2017 Lua.org, PUC-Rio" #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2018 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
@ -460,7 +460,7 @@ struct lua_Debug {
/****************************************************************************** /******************************************************************************
* Copyright (C) 1994-2017 Lua.org, PUC-Rio. * Copyright (C) 1994-2018 Lua.org, PUC-Rio.
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the

Binary file not shown.

View file

@ -1,5 +1,5 @@
/* /*
** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $ ** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $
** Configuration file for Lua ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -160,7 +160,7 @@
/* /*
** LUA_PATH_SEP is the character that separates templates in a path. ** LUA_PATH_SEP is the character that separates templates in a path.
** LUA_PATH_MARK is the std::string that marks the substitution points in a ** LUA_PATH_MARK is the string that marks the substitution points in a
** template. ** template.
** LUA_EXEC_DIR in a Windows path is replaced by the executable's ** LUA_EXEC_DIR in a Windows path is replaced by the executable's
** directory. ** directory.
@ -427,7 +427,7 @@
@@ lua_number2str converts a float to a string. @@ lua_number2str converts a float to a string.
@@ l_mathop allows the addition of an 'l' or 'f' to all math operations. @@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
@@ l_floor takes the floor of a float. @@ l_floor takes the floor of a float.
@@ lua_str2number converts a decimal numeric std::string to a number. @@ lua_str2number converts a decimal numeric string to a number.
*/ */
@ -612,7 +612,7 @@
/* /*
@@ lua_strx2number converts an hexadecimal numeric std::string to a number. @@ lua_strx2number converts an hexadecimal numeric string to a number.
** In C99, 'strtod' does that conversion. Otherwise, you can ** In C99, 'strtod' does that conversion. Otherwise, you can
** leave 'lua_strx2number' undefined and Lua will provide its own ** leave 'lua_strx2number' undefined and Lua will provide its own
** implementation. ** implementation.
@ -622,6 +622,13 @@
#endif #endif
/*
@@ lua_pointer2str converts a pointer to a readable string in a
** non-specified way.
*/
#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)
/* /*
@@ lua_number2strx converts a float to an hexadecimal numeric string. @@ lua_number2strx converts a float to an hexadecimal numeric string.
** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.

View file

@ -1,5 +1,5 @@
/* /*
** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $ ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $
** Lua standard libraries ** Lua standard libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */

25838
TR5Main/Libs/sol/sol.hpp Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@
#include "level.h" #include "level.h"
#include "input.h" #include "input.h"
#include "sound.h" #include "sound.h"
using std::vector;
// TODO: recreate the DrawSkidoo for the snowmobile. // TODO: recreate the DrawSkidoo for the snowmobile.
enum SKIDOO_STATE { SKID_SIT, SKID_GETON, SKID_LEFT, SKID_RIGHT, SKID_FALL, SKID_HIT, SKID_GETONL, SKID_GETOFFL, SKID_STILL, SKID_GETOFF, SKID_LETGO, SKID_DEATH, SKID_FALLOFF }; enum SKIDOO_STATE { SKID_SIT, SKID_GETON, SKID_LEFT, SKID_RIGHT, SKID_FALL, SKID_HIT, SKID_GETONL, SKID_GETOFFL, SKID_STILL, SKID_GETOFF, SKID_LETGO, SKID_DEATH, SKID_FALLOFF };

View file

@ -11,7 +11,7 @@
#include "level.h" #include "level.h"
#include "setup.h" #include "setup.h"
#include "input.h" #include "input.h"
using std::vector;
#define MAX_SPEED 0x380000 #define MAX_SPEED 0x380000
#define KAYAK_COLLIDE 64 #define KAYAK_COLLIDE 64
#define GETOFF_DIST CLICK(3) // minimum collision distance #define GETOFF_DIST CLICK(3) // minimum collision distance

View file

@ -13,7 +13,7 @@
#include "setup.h" #include "setup.h"
#include "input.h" #include "input.h"
#include "sound.h" #include "sound.h"
using std::vector;
typedef enum MINECART_STATE { typedef enum MINECART_STATE {
CART_GETIN, CART_GETIN,
CART_GETOUT, CART_GETOUT,

View file

@ -15,7 +15,7 @@
#include "level.h" #include "level.h"
#include "input.h" #include "input.h"
#include "sound.h" #include "sound.h"
using std::vector;
typedef enum QUAD_EFFECTS_POSITIONS { typedef enum QUAD_EFFECTS_POSITIONS {
EXHAUST_LEFT = 0, EXHAUST_LEFT = 0,
EXHAUST_RIGHT, EXHAUST_RIGHT,

View file

@ -15,7 +15,7 @@
#include "sound.h" #include "sound.h"
#include "setup.h" #include "setup.h"
#include "level.h" #include "level.h"
using std::vector;
typedef struct JEEP_INFO typedef struct JEEP_INFO
{ {
short rot1; short rot1;

View file

@ -6,7 +6,7 @@
#include "level.h" #include "level.h"
#include "tr5_smashobject.h" #include "tr5_smashobject.h"
#include "tr5_pushableblock.h" #include "tr5_pushableblock.h"
using std::function;
void InitSmashObject(ObjectInfo* obj, int objectNumber) void InitSmashObject(ObjectInfo* obj, int objectNumber)
{ {
obj = &Objects[objectNumber]; obj = &Objects[objectNumber];

View file

@ -9,7 +9,7 @@ void InitPuzzleHole(ObjectInfo* obj, int objectNumber);
void InitPuzzleDone(ObjectInfo* obj, int objectNumber); void InitPuzzleDone(ObjectInfo* obj, int objectNumber);
void InitAnimating(ObjectInfo* obj, int objectNumber); void InitAnimating(ObjectInfo* obj, int objectNumber);
void InitPickup(ObjectInfo* obj, int objectNumber); void InitPickup(ObjectInfo* obj, int objectNumber);
void InitPickupItem(ObjectInfo* obj, function<InitFunction> func, int objectNumber, bool useDrawAnimItem = false); void InitPickupItem(ObjectInfo* obj, std::function<InitFunction> func, int objectNumber, bool useDrawAnimItem = false);
void InitProjectile(ObjectInfo* obj, function<InitFunction> func, int objectNumber, bool noLoad = false); void InitProjectile(ObjectInfo* obj, std::function<InitFunction> func, int objectNumber, bool noLoad = false);
void InitSearchObject(ObjectInfo* obj, int objectNumber); void InitSearchObject(ObjectInfo* obj, int objectNumber);
void InitPushableObject(ObjectInfo* obj, int objectNumber); void InitPushableObject(ObjectInfo* obj, int objectNumber);

View file

@ -9,7 +9,8 @@
#include "lara.h" #include "lara.h"
#include "sphere.h" #include "sphere.h"
#include "GameFlowScript.h" #include "GameFlowScript.h"
using std::vector;
using std::pair;
extern GameConfiguration g_Configuration; extern GameConfiguration g_Configuration;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;

View file

@ -21,6 +21,7 @@
#include "Utils.h" #include "Utils.h"
#include "VertexBuffer.h" #include "VertexBuffer.h"
using namespace T5M::Renderer::Utils; using namespace T5M::Renderer::Utils;
using std::array;
Renderer11* g_Renderer; Renderer11* g_Renderer;
Renderer11::Renderer11() Renderer11::Renderer11()
{ {

View file

@ -5,7 +5,8 @@
#include "setup.h" #include "setup.h"
#include "control.h" #include "control.h"
#include "objects.h" #include "objects.h"
using std::vector;
using std::stack;
bool Renderer11::PrepareDataForTheRenderer() bool Renderer11::PrepareDataForTheRenderer()
{ {
m_moveableObjects = (RendererObject * *)malloc(sizeof(RendererObject*) * ID_NUMBER_OBJECTS); m_moveableObjects = (RendererObject * *)malloc(sizeof(RendererObject*) * ID_NUMBER_OBJECTS);

View file

@ -20,7 +20,7 @@
#include "tr5_spider_emitter.h" #include "tr5_spider_emitter.h"
#include "CameraMatrixBuffer.h" #include "CameraMatrixBuffer.h"
using namespace T5M::Renderer; using namespace T5M::Renderer;
using namespace std::chrono;
extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL]; extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL];
extern RendererHUDBar* g_DashBar; extern RendererHUDBar* g_DashBar;
extern RendererHUDBar* g_SFXVolumeBar; extern RendererHUDBar* g_SFXVolumeBar;
@ -1903,8 +1903,8 @@ int Renderer11::DrawInventory()
bool Renderer11::drawScene(bool dump) bool Renderer11::drawScene(bool dump)
{ {
using ns = chrono::nanoseconds; using ns = std::chrono::nanoseconds;
using get_time = chrono::steady_clock; using get_time = std::chrono::steady_clock;
m_timeUpdate = 0; m_timeUpdate = 0;
m_timeDraw = 0; m_timeDraw = 0;
m_timeFrame = 0; m_timeFrame = 0;
@ -1925,7 +1925,7 @@ bool Renderer11::drawScene(bool dump)
m_stLights.CameraPosition = Vector3(Camera.pos.x, Camera.pos.y, Camera.pos.z); m_stLights.CameraPosition = Vector3(Camera.pos.x, Camera.pos.y, Camera.pos.z);
// Prepare the scene to draw // Prepare the scene to draw
auto time1 = chrono::high_resolution_clock::now(); auto time1 = std::chrono::high_resolution_clock::now();
prepareCameraForFrame(); prepareCameraForFrame();
ProcessClosedDoors(); ProcessClosedDoors();
@ -1948,8 +1948,8 @@ bool Renderer11::drawScene(bool dump)
if (GnFrameCounter % 2 == 0) if (GnFrameCounter % 2 == 0)
updateAnimatedTextures(); updateAnimatedTextures();
auto time2 = chrono::high_resolution_clock::now(); auto time2 = std::chrono::high_resolution_clock::now();
m_timeUpdate = (chrono::duration_cast<ns>(time2 - time1)).count() / 1000000; m_timeUpdate = (std::chrono::duration_cast<ns>(time2 - time1)).count() / 1000000;
time1 = time2; time1 = time2;
// Draw shadow map // Draw shadow map
@ -2040,8 +2040,8 @@ bool Renderer11::drawScene(bool dump)
drawSprites(); drawSprites();
drawLines3D(); drawLines3D();
time2 = chrono::high_resolution_clock::now(); time2 = std::chrono::high_resolution_clock::now();
m_timeFrame = (chrono::duration_cast<ns>(time2 - time1)).count() / 1000000; m_timeFrame = (std::chrono::duration_cast<ns>(time2 - time1)).count() / 1000000;
time1 = time2; time1 = time2;
// Bars // Bars

View file

@ -18,6 +18,7 @@
#include "explosion.h" #include "explosion.h"
using namespace T5M::Renderer; using namespace T5M::Renderer;
using namespace T5M::Effects::Footprints; using namespace T5M::Effects::Footprints;
using std::vector;
extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD]; extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE]; extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE];
extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE]; extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE];

View file

@ -4,7 +4,7 @@
#include "winmain.h" #include "winmain.h"
#include "GameFlowScript.h" #include "GameFlowScript.h"
using namespace T5M::Renderer; using namespace T5M::Renderer;
using std::vector;
extern GameConfiguration g_Configuration; extern GameConfiguration g_Configuration;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;

View file

@ -6,7 +6,8 @@
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
#include "draw.h" #include "draw.h"
using std::string;
using std::vector;
ChunkId* ChunkGameFlowFlags = ChunkId::FromString("Tr5MainFlags"); ChunkId* ChunkGameFlowFlags = ChunkId::FromString("Tr5MainFlags");
ChunkId* ChunkGameFlowLevel = ChunkId::FromString("Tr5MainLevel"); ChunkId* ChunkGameFlowLevel = ChunkId::FromString("Tr5MainLevel");
ChunkId* ChunkGameFlowLevelFlags = ChunkId::FromString("Tr5MainLevelFlags"); ChunkId* ChunkGameFlowLevelFlags = ChunkId::FromString("Tr5MainLevelFlags");
@ -328,6 +329,8 @@ bool __cdecl LoadScript()
string GameFlow::loadScriptFromFile(char* luaFilename) string GameFlow::loadScriptFromFile(char* luaFilename)
{ {
using std::ifstream;
using std::ios;
ifstream ifs(luaFilename, ios::in | ios::binary | ios::ate); ifstream ifs(luaFilename, ios::in | ios::binary | ios::ate);
ifstream::pos_type fileSize = ifs.tellg(); ifstream::pos_type fileSize = ifs.tellg();

View file

@ -163,8 +163,8 @@ private:
sol::state* m_lua; sol::state* m_lua;
GameScriptSettings m_settings; GameScriptSettings m_settings;
string loadScriptFromFile(char* luaFilename); std::string loadScriptFromFile(char* luaFilename);
map<short, short> m_itemsMap; std::map<short, short> m_itemsMap;
public: public:
Vector3 SkyColorLayer1; Vector3 SkyColorLayer1;
@ -188,8 +188,8 @@ public:
// Selected language set // Selected language set
LanguageScript* CurrentStrings; LanguageScript* CurrentStrings;
vector<LanguageScript*> Strings; std::vector<LanguageScript*> Strings;
vector<GameScriptLevel*> Levels; std::vector<GameScriptLevel*> Levels;
GameFlow(sol::state* lua); GameFlow(sol::state* lua);
~GameFlow(); ~GameFlow();

View file

@ -8,7 +8,7 @@
#include "sound.h" #include "sound.h"
#include "setup.h" #include "setup.h"
#include "level.h" #include "level.h"
using namespace std;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;
GameScript* g_GameScript; GameScript* g_GameScript;
bool WarningsAsErrors = false; bool WarningsAsErrors = false;

View file

@ -34,16 +34,16 @@ private:
float xPos; float xPos;
float yPos; float yPos;
float zPos; float zPos;
function<float()> readXPos; std::function<float()> readXPos;
function<void(float)> writeXPos; std::function<void(float)> writeXPos;
function<float()> readYPos; std::function<float()> readYPos;
function<void(float)> writeYPos; std::function<void(float)> writeYPos;
function<float()> readZPos; std::function<float()> readZPos;
function<void(float)> writeZPos; std::function<void(float)> writeZPos;
public: public:
GameScriptPosition(float x, float y, float z); GameScriptPosition(float x, float y, float z);
GameScriptPosition(function<float()> readX, function<void(float)> writeX, function<float()> readY, function<void(float)> writeY, function<float()> readZ, function<void(float)> writeZ); GameScriptPosition(std::function<float()> readX, std::function<void(float)> writeX, std::function<float()> readY, std::function<void(float)> writeY, std::function<float()> readZ, std::function<void(float)> writeZ);
float GetXPos(); float GetXPos();
void SetXPos(float x); void SetXPos(float x);
@ -58,16 +58,16 @@ private:
float xRot; float xRot;
float yRot; float yRot;
float zRot; float zRot;
function<float()> readXRot; std::function<float()> readXRot;
function<void(float)> writeXRot; std::function<void(float)> writeXRot;
function<float()> readYRot; std::function<float()> readYRot;
function<void(float)> writeYRot; std::function<void(float)> writeYRot;
function<float()> readZRot; std::function<float()> readZRot;
function<void(float)> writeZRot; std::function<void(float)> writeZRot;
public: public:
GameScriptRotation(float x, float y, float z); GameScriptRotation(float x, float y, float z);
GameScriptRotation(function<float()> readX, function<void(float)> writeX, function<float()> readY, function<void(float)> writeY, function<float()> readZ, function<void(float)> writeZ); GameScriptRotation(std::function<float()> readX, std::function<void(float)> writeX, std::function<float()> readY, std::function<void(float)> writeY, std::function<float()> readZ, std::function<void(float)> writeZ);
float GetXRot(); float GetXRot();
void SetXRot(float x); void SetXRot(float x);
@ -104,7 +104,7 @@ public:
class LuaVariables class LuaVariables
{ {
public: public:
map<string, sol::object> variables; std::map<std::string, sol::object> variables;
sol::object GetVariable(std::string key); sol::object GetVariable(std::string key);
void SetVariable(std::string key, sol::object value); void SetVariable(std::string key, sol::object value);
@ -127,15 +127,15 @@ private:
sol::state* m_lua; sol::state* m_lua;
LuaVariables m_globals; LuaVariables m_globals;
LuaVariables m_locals; LuaVariables m_locals;
map<int, short> m_itemsMapId; std::map<int, short> m_itemsMapId;
map<string, short> m_itemsMapName; std::map<std::string, short> m_itemsMapName;
vector<LuaFunction*> m_triggers; std::vector<LuaFunction*> m_triggers;
public: public:
GameScript(sol::state* lua); GameScript(sol::state* lua);
bool ExecuteScript(const string& luaFilename, string& message); bool ExecuteScript(const std::string& luaFilename, std::string& message);
bool ExecuteString(const string& command, string& message); bool ExecuteString(const std::string& command, std::string& message);
void FreeLevelScripts(); void FreeLevelScripts();
void AddTrigger(LuaFunction* function); void AddTrigger(LuaFunction* function);
void AddLuaId(int luaId, short itemNumber); void AddLuaId(int luaId, short itemNumber);
@ -144,9 +144,9 @@ public:
void ResetVariables(); void ResetVariables();
template <typename T> template <typename T>
void GetVariables(map<string, T>& locals, map<string, T>& globals); void GetVariables(std::map<std::string, T>& locals, std::map<std::string, T>& globals);
template <typename T> template <typename T>
void SetVariables(map<string, T>& locals, map<string, T>& globals); void SetVariables(std::map<std::string, T>& locals, std::map<std::string, T>& globals);
void PlayAudioTrack(short track); void PlayAudioTrack(short track);
void ChangeAmbientSoundTrack(short track); void ChangeAmbientSoundTrack(short track);
bool ExecuteTrigger(short index); bool ExecuteTrigger(short index);
@ -155,8 +155,8 @@ public:
void SetSecretsCount(int secretsNum); void SetSecretsCount(int secretsNum);
void AddOneSecret(); void AddOneSecret();
void MakeItemInvisible(short id); void MakeItemInvisible(short id);
unique_ptr<GameScriptItem> GetItemById(int id); std::unique_ptr<GameScriptItem> GetItemById(int id);
unique_ptr<GameScriptItem> GetItemByName(std::string name); std::unique_ptr<GameScriptItem> GetItemByName(std::string name);
void PlaySoundEffectAtPosition(short id, int x, int y, int z, int flags); void PlaySoundEffectAtPosition(short id, int x, int y, int z, int flags);
void PlaySoundEffect(short id, int flags); void PlaySoundEffect(short id, int flags);
GameScriptPosition CreatePosition(float x, float y, float z); GameScriptPosition CreatePosition(float x, float y, float z);

View file

@ -0,0 +1,54 @@
#include "framework.h"
#include "ChunkId.h"
using std::string;
ChunkId::ChunkId(char* bytes, int length) {
if (length == 0) {
m_chunkBytes = NULL;
m_length = 0;
} else {
m_chunkBytes = (byte*)malloc(length);
memcpy(m_chunkBytes, bytes, length);
m_length = length;
}
}
ChunkId::~ChunkId() {
if (m_chunkBytes != NULL)
delete m_chunkBytes;
}
ChunkId* ChunkId::FromString(const char* str) {
return new ChunkId((char*)str, strlen(str));
}
ChunkId* ChunkId::FromString(string* str) {
return new ChunkId((char*)str->c_str(), str->length());
}
ChunkId* ChunkId::FromStream(BaseStream* stream) {
int idLength = LEB128::ReadInt32(stream);
char* buffer = (char*)malloc(idLength);
stream->Read(buffer, idLength);
ChunkId* chunk = new ChunkId(buffer, idLength);
free(buffer);
return chunk;
}
void ChunkId::ToStream(BaseStream* stream) {
LEB128::Write(stream, m_length);
stream->WriteBytes(m_chunkBytes, m_length);
}
byte* ChunkId::GetBytes() {
return m_chunkBytes;
}
int ChunkId::GetLength() {
return m_length;
}
bool ChunkId::EqualsTo(ChunkId* other) {
if (m_length != other->GetLength())
return false;
return (strncmp((const char*)m_chunkBytes, (const char*)other->GetBytes(), m_length) == 0);
}

View file

@ -2,7 +2,6 @@
#include "LEB128.h" #include "LEB128.h"
#include "Streams.h" #include "Streams.h"
using namespace std;
typedef struct ChunkId typedef struct ChunkId
{ {
@ -11,67 +10,21 @@ private:
int m_length; int m_length;
public: public:
ChunkId(char* bytes, int length) ChunkId(char* bytes, int length);
{
if (length == 0)
{
m_chunkBytes = NULL;
m_length = 0;
}
else
{
m_chunkBytes = (byte*)malloc(length);
memcpy(m_chunkBytes, bytes, length);
m_length = length;
}
}
~ChunkId() ~ChunkId();
{
if (m_chunkBytes != NULL)
delete m_chunkBytes;
}
static ChunkId* FromString(const char* str) static ChunkId* FromString(const char* str);
{
return new ChunkId((char*)str, strlen(str));
}
static ChunkId* FromString(string* str) static ChunkId* FromString(std::string* str);
{
return new ChunkId((char*)str->c_str(), str->length());
}
static ChunkId* FromStream(BaseStream* stream) static ChunkId* FromStream(BaseStream* stream);
{
int idLength = LEB128::ReadInt32(stream);
char* buffer = (char*)malloc(idLength);
stream->Read(buffer, idLength);
ChunkId* chunk = new ChunkId(buffer, idLength);
free(buffer);
return chunk;
}
void ToStream(BaseStream* stream) void ToStream(BaseStream* stream);
{
LEB128::Write(stream, m_length);
stream->WriteBytes(m_chunkBytes, m_length);
}
byte* GetBytes() byte* GetBytes();
{
return m_chunkBytes;
}
int GetLength() int GetLength();
{
return m_length;
}
bool EqualsTo(ChunkId* other) bool EqualsTo(ChunkId* other);
{
if (m_length != other->GetLength())
return false;
return (strncmp((const char*)m_chunkBytes, (const char*)other->GetBytes(), m_length) == 0);
}
}; };

View file

@ -0,0 +1,133 @@
#include "framework.h"
#include "ChunkReader.h"
int ChunkReader::readInt32() {
int value = 0;
m_stream->Read(reinterpret_cast<char*>(&value), 4);
return value;
}
short ChunkReader::readInt16() {
short value = 0;
m_stream->Read(reinterpret_cast<char*>(&value), 2);
return value;
}
ChunkReader::ChunkReader(int expectedMagicNumber, BaseStream* stream) {
m_isValid = false;
if (stream == NULL)
return;
m_stream = stream;
// Check the magic number
int magicNumber = readInt32();
if (magicNumber != expectedMagicNumber)
return;
// TODO: future use for compression
m_stream->Seek(4, SeekOrigin::CURRENT);
m_emptyChunk = new ChunkId(NULL, 0);
m_isValid = true;
}
ChunkReader::~ChunkReader() {
delete m_emptyChunk;
}
bool ChunkReader::IsValid() {
return m_isValid;
}
bool ChunkReader::ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg) {
do {
ChunkId* chunkId = ChunkId::FromStream(m_stream);
if (chunkId->EqualsTo(m_emptyChunk)) // End reached
break;
// Read up to a 64 bit number for the chunk size
__int64 chunkSize = LEB128::ReadLong(m_stream);
// Try loading chunk content
bool chunkRecognized = false;
int startPos = m_stream->GetCurrentPosition();
chunkRecognized = func(chunkId, chunkSize, arg);
int readDataCount = m_stream->GetCurrentPosition() - startPos;
// Adjust _stream position if necessary
if (readDataCount != chunkSize)
m_stream->Seek(chunkSize - readDataCount, SeekOrigin::CURRENT);
} while (true);
return true;
}
bool ChunkReader::ReadChunks(std::function<bool(ChunkId*, long, int)> func, int arg) {
do {
ChunkId* chunkId = ChunkId::FromStream(m_stream);
if (chunkId->EqualsTo(m_emptyChunk)) // End reached
break;
// Read up to a 64 bit number for the chunk size
__int64 chunkSize = LEB128::ReadLong(m_stream);
// Try loading chunk content
bool chunkRecognized = false;
int startPos = m_stream->GetCurrentPosition();
chunkRecognized = func(chunkId, chunkSize, arg);
int readDataCount = m_stream->GetCurrentPosition() - startPos;
// Adjust _stream position if necessary
if (readDataCount != chunkSize)
m_stream->Seek(chunkSize - readDataCount, SeekOrigin::CURRENT);
} while (true);
return true;
}
char* ChunkReader::ReadChunkArrayOfBytes(__int64 length) {
char* value = (char*)malloc(length);
m_stream->Read(value, length);
return value;
}
bool ChunkReader::ReadChunkBool(__int64 length) {
return (LEB128::ReadByte(m_stream) != 0);
}
__int64 ChunkReader::ReadChunkLong(__int64 length) {
return LEB128::ReadLong(m_stream);
}
int ChunkReader::ReadChunkInt32(__int64 length) {
return LEB128::ReadInt32(m_stream);
}
unsigned int ChunkReader::ReadChunkUInt32(__int64 length) {
return LEB128::ReadUInt32(m_stream);
}
short ChunkReader::ReadChunkInt16(__int64 length) {
return LEB128::ReadInt16(m_stream);
}
unsigned short ChunkReader::ReadChunkUInt16(__int64 length) {
return LEB128::ReadUInt16(m_stream);
}
byte ChunkReader::ReadChunkByte(__int64 length) {
return LEB128::ReadByte(m_stream);
}
char* ChunkReader::ReadChunkString(long length) {
char* value = (char*)malloc(length);
memcpy(value, LevelDataPtr, length);
return value;
}
BaseStream* ChunkReader::GetRawStream() {
return m_stream;
}

View file

@ -3,7 +3,6 @@
#include "LEB128.h" #include "LEB128.h"
#include "Streams.h" #include "Streams.h"
using namespace std;
class ChunkReader class ChunkReader
{ {
@ -12,154 +11,38 @@ private:
ChunkId* m_emptyChunk = nullptr; ChunkId* m_emptyChunk = nullptr;
BaseStream* m_stream = nullptr; BaseStream* m_stream = nullptr;
int readInt32() int readInt32();
{
int value = 0;
m_stream->Read(reinterpret_cast<char *>(&value), 4);
return value;
}
short readInt16() short readInt16();
{
short value = 0;
m_stream->Read(reinterpret_cast<char *>(&value), 2);
return value;
}
public: public:
ChunkReader(int expectedMagicNumber, BaseStream* stream) ChunkReader(int expectedMagicNumber, BaseStream* stream);
{
m_isValid = false;
if (stream == NULL) ~ChunkReader();
return;
m_stream = stream; bool IsValid();
// Check the magic number bool ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg);
int magicNumber = readInt32();
if (magicNumber != expectedMagicNumber)
return;
// TODO: future use for compression bool ReadChunks(std::function<bool(ChunkId*, long, int)> func, int arg);
m_stream->Seek(4, SeekOrigin::CURRENT);
m_emptyChunk = new ChunkId(NULL, 0);
m_isValid = true;
}
~ChunkReader() char* ReadChunkArrayOfBytes(__int64 length);
{
delete m_emptyChunk;
}
bool IsValid() bool ReadChunkBool(__int64 length);
{
return m_isValid;
}
bool ReadChunks(bool(*func)(ChunkId* parentChunkId, int maxSize, int arg), int arg) __int64 ReadChunkLong(__int64 length);
{
do
{
ChunkId* chunkId = ChunkId::FromStream(m_stream);
if (chunkId->EqualsTo(m_emptyChunk)) // End reached
break;
// Read up to a 64 bit number for the chunk size int ReadChunkInt32(__int64 length);
__int64 chunkSize = LEB128::ReadLong(m_stream);
// Try loading chunk content unsigned int ReadChunkUInt32(__int64 length);
bool chunkRecognized = false;
int startPos = m_stream->GetCurrentPosition();
chunkRecognized = func(chunkId, chunkSize, arg); short ReadChunkInt16(__int64 length);
int readDataCount = m_stream->GetCurrentPosition() - startPos;
// Adjust _stream position if necessary unsigned short ReadChunkUInt16(__int64 length);
if (readDataCount != chunkSize)
m_stream->Seek(chunkSize - readDataCount, SeekOrigin::CURRENT);
} while (true);
return true; byte ReadChunkByte(__int64 length);
}
bool ReadChunks(std::function<bool(ChunkId*, long, int)> func, int arg) char* ReadChunkString(long length);
{
do
{
ChunkId* chunkId = ChunkId::FromStream(m_stream);
if (chunkId->EqualsTo(m_emptyChunk)) // End reached
break;
// Read up to a 64 bit number for the chunk size BaseStream* GetRawStream();
__int64 chunkSize = LEB128::ReadLong(m_stream);
// Try loading chunk content
bool chunkRecognized = false;
int startPos = m_stream->GetCurrentPosition();
chunkRecognized = func(chunkId, chunkSize, arg);
int readDataCount = m_stream->GetCurrentPosition() - startPos;
// Adjust _stream position if necessary
if (readDataCount != chunkSize)
m_stream->Seek(chunkSize - readDataCount, SeekOrigin::CURRENT);
} while (true);
return true;
}
char* ReadChunkArrayOfBytes(__int64 length)
{
char* value = (char*)malloc(length);
m_stream->Read(value, length);
return value;
}
bool ReadChunkBool(__int64 length)
{
return (LEB128::ReadByte(m_stream) != 0);
}
__int64 ReadChunkLong(__int64 length)
{
return LEB128::ReadLong(m_stream);
}
int ReadChunkInt32(__int64 length)
{
return LEB128::ReadInt32(m_stream);
}
unsigned int ReadChunkUInt32(__int64 length)
{
return LEB128::ReadUInt32(m_stream);
}
short ReadChunkInt16(__int64 length)
{
return LEB128::ReadInt16(m_stream);
}
unsigned short ReadChunkUInt16(__int64 length)
{
return LEB128::ReadUInt16(m_stream);
}
byte ReadChunkByte(__int64 length)
{
return LEB128::ReadByte(m_stream);
}
char* ReadChunkString(long length)
{
char* value = (char*)malloc(length);
memcpy(value, LevelDataPtr, length);
return value;
}
BaseStream* GetRawStream()
{
return m_stream;
}
}; };

View file

@ -0,0 +1,234 @@
#include "framework.h"
#include "Streams.h"
using std::ios;
using std::string;
using std::ifstream;
using std::fstream;
using std::ofstream;
bool BaseStream::ReadBytes(byte* value, int length) {
return Read(reinterpret_cast<char*>(value), length);
}
bool BaseStream::ReadByte(byte* value) {
return Read(reinterpret_cast<char*>(value), 1);
}
bool BaseStream::ReadBool(bool* value) {
return Read(reinterpret_cast<char*>(value), 1);
}
bool BaseStream::ReadInt16(short* value) {
return Read(reinterpret_cast<char*>(value), 2);
}
bool BaseStream::ReadInt32(int* value) {
return Read(reinterpret_cast<char*>(value), 4);
}
bool BaseStream::ReadFloat(float* value) {
return Read(reinterpret_cast<char*>(value), 4);
}
bool BaseStream::ReadString(char** value) {
int length;
ReadInt32(&length);
*value = (char*)malloc(length + 1);
Read(*value, length);
(*value)[length] = NULL;
return true;
}
bool BaseStream::ReadString(string* value) {
int length;
ReadInt32(&length);
char* buffer = (char*)malloc(length + 1);
Read(buffer, length);
buffer[length] = NULL;
*value = string(buffer);
free(buffer);
return true;
}
bool BaseStream::ReadVector2(Vector2* value) {
ReadFloat(&value->x);
ReadFloat(&value->y);
return true;
}
bool BaseStream::ReadVector3(Vector3* value) {
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
return true;
}
bool BaseStream::ReadVector4(Vector4* value) {
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
ReadFloat(&value->w);
return true;
}
bool BaseStream::ReadQuaternion(Quaternion* value) {
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
ReadFloat(&value->w);
return true;
}
bool BaseStream::ReadBoundingBox(BoundingBox* value) {
Vector3 minPos;
Vector3 maxPos;
ReadVector3(&minPos);
ReadVector3(&maxPos);
BoundingBox::CreateFromPoints(*value, minPos, maxPos);
return true;
}
bool BaseStream::ReadBoundingSphere(BoundingSphere* sphere) {
Vector3 center;
float radius;
ReadVector3(&center);
ReadFloat(&radius);
sphere->Center = center;
sphere->Radius = radius;
return true;
}
bool BaseStream::WriteBytes(byte* value, int length) {
return Write(reinterpret_cast<char*>(value), length);
}
bool BaseStream::WriteByte(byte value) {
return Write(reinterpret_cast<char*>(&value), 1);
}
bool BaseStream::WriteInt16(short value) {
return Write(reinterpret_cast<char*>(&value), 2);
}
bool BaseStream::WriteInt32(int value) {
return Write(reinterpret_cast<char*>(&value), 4);
}
bool BaseStream::WriteBool(bool value) {
return Write(reinterpret_cast<char*>(&value), 1);
}
bool BaseStream::WriteFloat(float value) {
return Write(reinterpret_cast<char*>(&value), 4);
}
bool BaseStream::WriteString(char* str) {
int length = (int)strlen(str);
WriteInt32(length);
Write(str, length);
return true;
}
MemoryStream::MemoryStream(char* buffer, int size) {
m_buffer = (char*)malloc(size);
m_startBuffer = m_buffer;
memcpy(m_buffer, buffer, size);
m_size = size;
}
MemoryStream::MemoryStream(int size) {
m_buffer = (char*)malloc(size);
m_startBuffer = m_buffer;
m_size = size;
}
MemoryStream::~MemoryStream() {
free(m_startBuffer);
}
bool MemoryStream::Read(char* buffer, int length) {
memcpy(buffer, m_buffer, length);
m_buffer += length;
return true;
}
bool MemoryStream::Write(char* buffer, int length) {
memcpy(m_buffer, buffer, length);
m_buffer += length;
return true;
}
int MemoryStream::GetCurrentPosition() {
return (m_buffer - m_startBuffer);
}
bool MemoryStream::Seek(int seek, SeekOrigin origin) {
if (origin == SeekOrigin::BEGIN)
m_buffer = m_startBuffer + seek;
else
m_buffer += seek;
return true;
}
bool MemoryStream::IsEOF() {
return (GetCurrentPosition() > m_size);
}
bool MemoryStream::Close() {
return true;
}
FileStream::FileStream(char* fileName, bool read, bool write) {
int mode = 0;
if (read)
mode |= ifstream::binary | fstream::in;
if (write)
mode |= ofstream::binary | fstream::out | fstream::trunc;
m_stream.open(fileName, mode);
bool opened = m_stream.is_open();
}
FileStream::~FileStream() {
m_stream.close();
}
bool FileStream::Read(char* buffer, int length) {
m_stream.read(buffer, length);
return true;
}
bool FileStream::Write(char* buffer, int length) {
m_stream.write(buffer, length);
return true;
}
int FileStream::GetCurrentPosition() {
return (int)(m_stream.tellg());
}
bool FileStream::Seek(int seek, SeekOrigin origin) {
m_stream.seekg(seek, (origin == SeekOrigin::BEGIN ? m_stream.beg : m_stream.cur));
return true;
}
bool FileStream::IsEOF() {
return (m_stream.eof());
}
bool FileStream::Close() {
m_stream.flush();
m_stream.close();
return true;
}

View file

@ -10,7 +10,6 @@
using namespace DirectX; using namespace DirectX;
using namespace DirectX::SimpleMath; using namespace DirectX::SimpleMath;
using namespace std;
enum SeekOrigin { enum SeekOrigin {
BEGIN, BEGIN,
@ -26,161 +25,47 @@ public:
virtual bool IsEOF() = 0; virtual bool IsEOF() = 0;
virtual bool Close() = 0; virtual bool Close() = 0;
bool ReadBytes(byte* value, int length) bool ReadBytes(byte* value, int length);
{
return Read(reinterpret_cast<char*>(value), length);
}
bool ReadByte(byte* value) bool ReadByte(byte* value);
{
return Read(reinterpret_cast<char*>(value), 1);
}
bool ReadBool(bool* value) bool ReadBool(bool* value);
{
return Read(reinterpret_cast<char*>(value), 1);
}
bool ReadInt16(short* value) bool ReadInt16(short* value);
{
return Read(reinterpret_cast<char*>(value), 2);
}
bool ReadInt32(int* value) bool ReadInt32(int* value);
{
return Read(reinterpret_cast<char*>(value), 4);
}
bool ReadFloat(float* value) bool ReadFloat(float* value);
{
return Read(reinterpret_cast<char*>(value), 4);
}
bool ReadString(char** value) bool ReadString(char** value);
{
int length;
ReadInt32(&length);
*value = (char*)malloc(length + 1);
Read(*value, length);
(*value)[length] = NULL;
return true; bool ReadString(std::string* value);
}
bool ReadString(string* value) bool ReadVector2(Vector2* value);
{
int length;
ReadInt32(&length);
char* buffer = (char*)malloc(length + 1);
Read(buffer, length);
buffer[length] = NULL;
*value = string(buffer);
free(buffer);
return true; bool ReadVector3(Vector3* value);
}
bool ReadVector2(Vector2* value) bool ReadVector4(Vector4* value);
{
ReadFloat(&value->x);
ReadFloat(&value->y);
return true; bool ReadQuaternion(Quaternion* value);
}
bool ReadVector3(Vector3* value) bool ReadBoundingBox(BoundingBox* value);
{
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
return true; bool ReadBoundingSphere(BoundingSphere* sphere);
}
bool ReadVector4(Vector4* value) bool WriteBytes(byte* value, int length);
{
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
ReadFloat(&value->w);
return true; bool WriteByte(byte value);
}
bool ReadQuaternion(Quaternion* value) bool WriteInt16(short value);
{
ReadFloat(&value->x);
ReadFloat(&value->y);
ReadFloat(&value->z);
ReadFloat(&value->w);
return true; bool WriteInt32(int value);
}
bool ReadBoundingBox(BoundingBox* value) bool WriteBool(bool value);
{
Vector3 minPos;
Vector3 maxPos;
ReadVector3(&minPos); bool WriteFloat(float value);
ReadVector3(&maxPos);
BoundingBox::CreateFromPoints(*value, minPos, maxPos); bool WriteString(char* str);
return true;
}
bool ReadBoundingSphere(BoundingSphere* sphere)
{
Vector3 center;
float radius;
ReadVector3(&center);
ReadFloat(&radius);
sphere->Center = center;
sphere->Radius = radius;
return true;
}
bool WriteBytes(byte* value, int length)
{
return Write(reinterpret_cast<char*>(value), length);
}
bool WriteByte(byte value)
{
return Write(reinterpret_cast<char*>(&value), 1);
}
bool WriteInt16(short value)
{
return Write(reinterpret_cast<char*>(&value), 2);
}
bool WriteInt32(int value)
{
return Write(reinterpret_cast<char*>(&value), 4);
}
bool WriteBool(bool value)
{
return Write(reinterpret_cast<char*>(&value), 1);
}
bool WriteFloat(float value)
{
return Write(reinterpret_cast<char*>(&value), 4);
}
bool WriteString(char* str)
{
int length = (int)strlen(str);
WriteInt32(length);
Write(str, length);
return true;
}
}; };
class MemoryStream : public BaseStream { class MemoryStream : public BaseStream {
@ -190,119 +75,43 @@ private:
int m_size; int m_size;
public: public:
MemoryStream(char* buffer, int size) MemoryStream(char* buffer, int size);
{
m_buffer = (char*)malloc(size);
m_startBuffer = m_buffer;
memcpy(m_buffer, buffer, size);
m_size = size;
}
MemoryStream(int size) MemoryStream(int size);
{
m_buffer = (char*)malloc(size);
m_startBuffer = m_buffer;
m_size = size;
}
~MemoryStream() ~MemoryStream();
{
free(m_startBuffer);
}
bool Read(char* buffer, int length) bool Read(char* buffer, int length);
{
memcpy(buffer, m_buffer, length);
m_buffer += length;
return true;
}
bool Write(char* buffer, int length) bool Write(char* buffer, int length);
{
memcpy(m_buffer, buffer, length);
m_buffer += length;
return true;
}
int GetCurrentPosition() int GetCurrentPosition();
{
return (m_buffer - m_startBuffer);
}
bool Seek(int seek, SeekOrigin origin) bool Seek(int seek, SeekOrigin origin);
{
if (origin == SeekOrigin::BEGIN)
m_buffer = m_startBuffer + seek;
else
m_buffer += seek;
return true;
}
bool IsEOF() bool IsEOF();
{
return (GetCurrentPosition() > m_size);
}
bool Close() bool Close();
{
return true;
}
}; };
class FileStream : public BaseStream { class FileStream : public BaseStream {
private: private:
fstream m_stream; std::fstream m_stream;
public: public:
FileStream(char* fileName, bool read, bool write) FileStream(char* fileName, bool read, bool write);
{
int mode = 0;
if (read)
mode |= ifstream::binary | fstream::in;
if (write)
mode |= ofstream::binary | fstream::out | fstream::trunc;
m_stream.open(fileName, mode); ~FileStream();
bool opened = m_stream.is_open();
}
~FileStream() bool Read(char* buffer, int length);
{
m_stream.close();
}
bool Read(char* buffer, int length) bool Write(char* buffer, int length);
{
m_stream.read(buffer, length);
return true;
}
bool Write(char* buffer, int length) int GetCurrentPosition();
{
m_stream.write(buffer, length);
return true;
}
int GetCurrentPosition() bool Seek(int seek, SeekOrigin origin);
{
return (int)(m_stream.tellg());
}
bool Seek(int seek, SeekOrigin origin) bool IsEOF();
{
m_stream.seekg(seek, (origin == SeekOrigin::BEGIN ? m_stream.beg : m_stream.cur));
return true;
}
bool IsEOF() bool Close();
{
return (m_stream.eof());
}
bool Close()
{
m_stream.flush();
m_stream.close();
return true;
}
}; };

View file

@ -7,7 +7,7 @@
#include "GameFlowScript.h" #include "GameFlowScript.h"
#include "configuration.h" #include "configuration.h"
#include "sound.h" #include "sound.h"
using std::vector;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;
GameConfiguration g_Configuration; GameConfiguration g_Configuration;

View file

@ -14,7 +14,8 @@
#include "sound.h" #include "sound.h"
#include "levelloader.h" #include "levelloader.h"
#include "GameFlowScript.h" #include "GameFlowScript.h"
using std::vector;
using std::string;
ChunkId* ChunkTriggersList = ChunkId::FromString("Tr5Triggers"); ChunkId* ChunkTriggersList = ChunkId::FromString("Tr5Triggers");
ChunkId* ChunkTrigger = ChunkId::FromString("Tr5Trigger"); ChunkId* ChunkTrigger = ChunkId::FromString("Tr5Trigger");
ChunkId* ChunkLuaIds = ChunkId::FromString("Tr5LuaIds"); ChunkId* ChunkLuaIds = ChunkId::FromString("Tr5LuaIds");

View file

@ -113,7 +113,7 @@ extern int g_NumSpritesSequences;
extern short* MeshBase; extern short* MeshBase;
extern short** Meshes; extern short** Meshes;
extern int NumItems; extern int NumItems;
extern vector<OBJECT_TEXTURE> ObjectTextures; extern std::vector<OBJECT_TEXTURE> ObjectTextures;
extern ITEM_INFO* Items; extern ITEM_INFO* Items;
extern int LevelItems; extern int LevelItems;
extern std::vector<ROOM_INFO> Rooms; extern std::vector<ROOM_INFO> Rooms;
@ -129,10 +129,10 @@ extern int nAIObjects;
extern AIOBJECT* AIObjects; extern AIOBJECT* AIObjects;
extern SPRITE* Sprites; extern SPRITE* Sprites;
extern vector<TEXTURE> RoomTextures; extern std::vector<TEXTURE> RoomTextures;
extern vector<TEXTURE> MoveablesTextures; extern std::vector<TEXTURE> MoveablesTextures;
extern vector<TEXTURE> StaticsTextures; extern std::vector<TEXTURE> StaticsTextures;
extern vector<TEXTURE> SpritesTextures; extern std::vector<TEXTURE> SpritesTextures;
extern TEXTURE MiscTextures; extern TEXTURE MiscTextures;
extern TrLevel g_Level; extern TrLevel g_Level;

View file

@ -4,7 +4,7 @@
#include "ChunkReader.h" #include "ChunkReader.h"
#include "level.h" #include "level.h"
#include <Specific\setup.h> #include <Specific\setup.h>
using std::string;
LevelLoader::LevelLoader(string filename) LevelLoader::LevelLoader(string filename)
{ {
m_filename = filename; m_filename = filename;

View file

@ -6,7 +6,7 @@ struct TEXTURE
int width; int width;
int height; int height;
int size; int size;
vector<byte> data; std::vector<byte> data;
}; };
struct TrTexturePage struct TrTexturePage

View file

@ -11,7 +11,10 @@
#include "level.h" #include "level.h"
#include "configuration.h" #include "configuration.h"
#include "Renderer11.h" #include "Renderer11.h"
using std::exception;
using std::string;
using std::cout;
using std::endl;
WINAPP App; WINAPP App;
unsigned int ThreadID; unsigned int ThreadID;
uintptr_t ThreadHandle; uintptr_t ThreadHandle;

View file

@ -47,14 +47,14 @@
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)..\Build\</OutDir> <OutDir>$(ProjectDir)..\Build\</OutDir>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath> <ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)\TR5Main\Libs\zlib;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua;$(SolutionDir)TR5Main\Libs\sol;$(SolutionDir)\TR5Main\Libs\zlib;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)TR5Main\Libs\zlib\dll32;$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath> <LibraryPath>$(SolutionDir)TR5Main\Libs\zlib\dll32;$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
<TargetExt>.exe</TargetExt> <TargetExt>.exe</TargetExt>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath> <ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua;$(SolutionDir)TR5Main\Libs\sol2;$(SolutionDir)\TR5Main\Libs\zlib;$(IncludePath)</IncludePath> <IncludePath>$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua;$(SolutionDir)TR5Main\Libs\sol;$(SolutionDir)\TR5Main\Libs\zlib;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)TR5Main\Libs\zlib\dll32;$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath> <LibraryPath>$(SolutionDir)TR5Main\Libs\zlib\dll32;$(LibraryPath);$(DXSDK_DIR)Lib\x86;$(SolutionDir)TR5Main\Libs\bass;$(SolutionDir)TR5Main\Libs\lua</LibraryPath>
<OutDir>$(ProjectDir)..\Build\</OutDir> <OutDir>$(ProjectDir)..\Build\</OutDir>
</PropertyGroup> </PropertyGroup>
@ -71,7 +71,7 @@
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath> <IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp14</LanguageStandard> <LanguageStandard>stdcpplatest</LanguageStandard>
<PrecompiledHeaderFile>framework.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>framework.h</PrecompiledHeaderFile>
</ClCompile> </ClCompile>
<Link> <Link>
@ -105,7 +105,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<LanguageStandard>stdcpp14</LanguageStandard> <LanguageStandard>stdcpplatest</LanguageStandard>
<PrecompiledHeaderFile>framework.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>framework.h</PrecompiledHeaderFile>
</ClCompile> </ClCompile>
<Link> <Link>
@ -617,6 +617,9 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClCompile Include="Specific\configuration.cpp" /> <ClCompile Include="Specific\configuration.cpp" />
<ClCompile Include="Specific\Init.cpp" /> <ClCompile Include="Specific\Init.cpp" />
<ClCompile Include="Specific\input.cpp" /> <ClCompile Include="Specific\input.cpp" />
<ClCompile Include="Specific\IO\ChunkId.cpp" />
<ClCompile Include="Specific\IO\ChunkReader.cpp" />
<ClCompile Include="Specific\IO\Streams.cpp" />
<ClCompile Include="Specific\level.cpp" /> <ClCompile Include="Specific\level.cpp" />
<ClCompile Include="Specific\levelloader.cpp" /> <ClCompile Include="Specific\levelloader.cpp" />
<ClCompile Include="Specific\setup.cpp" /> <ClCompile Include="Specific\setup.cpp" />

View file

@ -1493,6 +1493,15 @@
<ClCompile Include="Renderer\RenderTarget2D.cpp"> <ClCompile Include="Renderer\RenderTarget2D.cpp">
<Filter>File di origine</Filter> <Filter>File di origine</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Specific\IO\Streams.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Specific\IO\ChunkId.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Specific\IO\ChunkReader.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />