diff --git a/TR5Main/Game/Box.h b/TR5Main/Game/Box.h index a873adc21..0412e9830 100644 --- a/TR5Main/Game/Box.h +++ b/TR5Main/Game/Box.h @@ -1,16 +1,10 @@ #pragma once #include "Specific\phd_global.h" -#include "items.h" #include "level.h" - -enum MOOD_TYPE -{ - BORED_MOOD, - ATTACK_MOOD, - ESCAPE_MOOD, - STALK_MOOD -}; - +struct ITEM_INFO; +struct BITE_INFO; +struct CREATURE_INFO; +struct LOT_INFO; enum TARGET_TYPE { NO_TARGET, @@ -18,25 +12,7 @@ enum TARGET_TYPE SECONDARY_TARGET }; -enum ZoneType -{ - ZONE_NULL = -1, // default zone - ZONE_SKELLY = 0, - ZONE_BASIC, - ZONE_FLYER, - ZONE_HUMAN_CLASSIC, - ZONE_VON_CROY, - ZONE_WATER, - ZONE_MAX, - /// custom zone (using zone above for LOT.zone): - ZONE_HUMAN_JUMP_AND_MONKEY, - ZONE_HUMAN_JUMP, - ZONE_SPIDER, - ZONE_BLOCKABLE, // for trex, shiva, etc.. - ZONE_SOPHIALEE, // dont want sophia to go down again ! - ZONE_APE, // only 2 click climb - ZONE_HUMAN_LONGJUMP_AND_MONKEY, -}; + struct OBJECT_BONES { @@ -86,13 +62,7 @@ struct OBJECT_BONES } }; -struct BOX_NODE -{ - int exitBox; - int searchNumber; - int nextExpansion; - int boxNumber; -}; + struct AI_INFO { @@ -147,49 +117,7 @@ struct BITE_INFO } }; -struct LOT_INFO -{ - std::vector node; - int head; - int tail; - int searchNumber; - int blockMask; - short step; - short drop; - short zoneCount; - int targetBox; - int requiredBox; - short fly; - bool canJump; - bool canMonkey; - bool isAmphibious; - bool isJumping; - bool isMonkeying; - PHD_VECTOR target; - ZoneType zone; -}; -struct CREATURE_INFO -{ - short jointRotation[4]; - short maximumTurn; - short flags; - bool alerted; - bool headLeft; - bool headRight; - bool reachedGoal; - bool hurtByLara; - bool patrol2; - bool jumpAhead; - bool monkeyAhead; - MOOD_TYPE mood; - ITEM_INFO* enemy; - ITEM_INFO aiTarget; - short pad; - short itemNum; - PHD_VECTOR target; - LOT_INFO LOT; -}; struct EntityStoringInfo { @@ -231,7 +159,7 @@ struct EntityStoringInfo }; #define CreatureEffectFunction short(int x, int y, int z, short speed, short yRot, short roomNumber) -#define XZ_GET_SECTOR(room, x, z) (room->floor[(z) / SECTOR(1) + (x) / SECTOR(1) * room->xSize]) +//#define XZ_GET_SECTOR(room, x, z) (room->floor[(z) / SECTOR(1) + (x) / SECTOR(1) * room->xSize]) constexpr auto UNIT_SHADOW = 256; constexpr auto NO_SHADOW = 0; @@ -314,5 +242,6 @@ void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info); TARGET_TYPE CalculateTarget(PHD_VECTOR* target, ITEM_INFO* item, LOT_INFO* LOT); int CreatureAnimation(short itemNumber, short angle, short tilt); void AdjustStopperFlag(ITEM_INFO* item, int dir, int set); - +//(room->floor[ + * room->xSize]) +FLOOR_INFO* XZ_GET_SECTOR(ROOM_INFO* r, int x, int z); diff --git a/TR5Main/Game/Lara/lara.cpp b/TR5Main/Game/Lara/lara.cpp index 31bcbf402..7ead10667 100644 --- a/TR5Main/Game/Lara/lara.cpp +++ b/TR5Main/Game/Lara/lara.cpp @@ -37,6 +37,8 @@ #include "rubberboat.h" #include #include +#include "Renderer11.h" +#include "camera.h" #ifdef NEW_INV #include "newinv2.h" diff --git a/TR5Main/Game/Lara/lara.h b/TR5Main/Game/Lara/lara.h index 26d677a6c..0646ad4b7 100644 --- a/TR5Main/Game/Lara/lara.h +++ b/TR5Main/Game/Lara/lara.h @@ -1,6 +1,7 @@ #pragma once #include "lara_struct.h" - +struct ITEM_INFO; +struct COLL_INFO; #define FRONT_ARC ANGLE(90.0f) #define LARA_LEAN_RATE ANGLE(1.5f) #define LARA_LEAN_MAX ANGLE(11.0f) diff --git a/TR5Main/Game/Lara/lara_basic.cpp b/TR5Main/Game/Lara/lara_basic.cpp index dc9cfbeda..38a7b5139 100644 --- a/TR5Main/Game/Lara/lara_basic.cpp +++ b/TR5Main/Game/Lara/lara_basic.cpp @@ -10,6 +10,9 @@ #include "Sound\sound.h" #include "draw.h" #include "pickup\pickup.h" +#include "collide.h" +#include "item.h" +#include "camera.h" bool DoJump = false; diff --git a/TR5Main/Game/Lara/lara_basic.h b/TR5Main/Game/Lara/lara_basic.h index c395cbcf6..45ec06e33 100644 --- a/TR5Main/Game/Lara/lara_basic.h +++ b/TR5Main/Game/Lara/lara_basic.h @@ -1,6 +1,6 @@ #pragma once -#include "lara_struct.h" - +struct ITEM_INFO; +struct COLL_INFO; /*generic functions*/ void lara_void_func(ITEM_INFO* item, COLL_INFO* coll); void lara_default_col(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/Lara/lara_cheat.cpp b/TR5Main/Game/Lara/lara_cheat.cpp index 70b962a86..75768e5eb 100644 --- a/TR5Main/Game/Lara/lara_cheat.cpp +++ b/TR5Main/Game/Lara/lara_cheat.cpp @@ -8,7 +8,10 @@ #endif #include "effects\effects.h" #include "Sound\sound.h" - +#include "collide.h" +#include "item.h" +#include "setup.h" +#include "level.h" extern GameFlow* g_GameFlow; int NoCheatCounter; diff --git a/TR5Main/Game/Lara/lara_cheat.h b/TR5Main/Game/Lara/lara_cheat.h index 845228de8..af986b6a3 100644 --- a/TR5Main/Game/Lara/lara_cheat.h +++ b/TR5Main/Game/Lara/lara_cheat.h @@ -1,5 +1,6 @@ #pragma once - +struct ITEM_INFO; +struct COLL_INFO; void lara_as_swimcheat(ITEM_INFO* item, COLL_INFO* coll); void LaraCheatyBits(); diff --git a/TR5Main/Game/Lara/lara_collide.cpp b/TR5Main/Game/Lara/lara_collide.cpp index 3a35d84d2..0057cb1f7 100644 --- a/TR5Main/Game/Lara/lara_collide.cpp +++ b/TR5Main/Game/Lara/lara_collide.cpp @@ -3,8 +3,8 @@ #include "input.h" #include "draw.h" #include "effects\effects.h" +#include "collide.h" #include "control.h" - /*this file has all the generic **collision** test functions called in lara's state code*/ int LaraDeflectEdge(ITEM_INFO* item, COLL_INFO* coll) diff --git a/TR5Main/Game/Lara/lara_collide.h b/TR5Main/Game/Lara/lara_collide.h index 0ffacb25f..4d82223dd 100644 --- a/TR5Main/Game/Lara/lara_collide.h +++ b/TR5Main/Game/Lara/lara_collide.h @@ -1,6 +1,6 @@ #pragma once -#include "lara_struct.h" - +struct ITEM_INFO; +struct COLL_INFO; int LaraDeflectEdge(ITEM_INFO* item, COLL_INFO* coll); void LaraDeflectEdgeJump(ITEM_INFO* item, COLL_INFO* coll); int LaraDeflectEdgeDuck(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/Lara/lara_crawl.cpp b/TR5Main/Game/Lara/lara_crawl.cpp index b151a6c17..5e20be639 100644 --- a/TR5Main/Game/Lara/lara_crawl.cpp +++ b/TR5Main/Game/Lara/lara_crawl.cpp @@ -7,7 +7,10 @@ #include "draw.h" #include "control.h" #include - +#include "collide.h" +#include "item.h" +#include "camera.h" +#include "control.h" /*this file has all the related functions to ducking and crawling*/ /*crouch/duck start*/ diff --git a/TR5Main/Game/Lara/lara_fire.cpp b/TR5Main/Game/Lara/lara_fire.cpp index 605258ad4..96a65bfd5 100644 --- a/TR5Main/Game/Lara/lara_fire.cpp +++ b/TR5Main/Game/Lara/lara_fire.cpp @@ -18,7 +18,7 @@ #include "savegame.h" #include "GameFlowScript.h" #include "lara_struct.h" - +#include "creature_info.h" WEAPON_INFO Weapons[NUM_WEAPONS] = { /* No weapons */ @@ -1006,11 +1006,11 @@ void LaraGetNewTarget(WEAPON_INFO* weapon) maxDistance = weapon->targetDist; targets = 0; - for (slot = 0; slot < NUM_SLOTS; ++slot) + for (slot = 0; slot < ActiveCreatures.size(); ++slot) { - if (BaddieSlots[slot].itemNum != NO_ITEM) + if (ActiveCreatures[slot]->itemNum != NO_ITEM) { - item = &g_Level.Items[BaddieSlots[slot].itemNum]; + item = &g_Level.Items[ActiveCreatures[slot]->itemNum]; if (item->hitPoints > 0) { x = item->pos.xPos - src.x; diff --git a/TR5Main/Game/Lara/lara_fire.h b/TR5Main/Game/Lara/lara_fire.h index 27d29bbe0..6c91c6014 100644 --- a/TR5Main/Game/Lara/lara_fire.h +++ b/TR5Main/Game/Lara/lara_fire.h @@ -1,6 +1,7 @@ #pragma once #include "lara.h" - +struct ITEM_INFO; +struct COLL_INFO; enum FireWeaponType { FW_MISS = -1, diff --git a/TR5Main/Game/Lara/lara_flare.cpp b/TR5Main/Game/Lara/lara_flare.cpp index a343c53f6..9e14ceeb1 100644 --- a/TR5Main/Game/Lara/lara_flare.cpp +++ b/TR5Main/Game/Lara/lara_flare.cpp @@ -63,7 +63,8 @@ void FlareControl(short itemNumber) DoProjectileDynamics(itemNumber, oldX, oldY, oldZ, xv, item->fallspeed, zv); - short age = (short)(item->data) & 0x7FFF; + short& age = item->data; + age &= 0x7FFF; if (age >= FLARE_AGE) { if (!item->fallspeed && !item->speed) @@ -84,8 +85,6 @@ void FlareControl(short itemNumber) age |= 0x8000; } - - item->data = (void*)age; } void ready_flare() @@ -362,10 +361,12 @@ void CreateFlare(GAME_OBJECT_ID objectNum, int thrown) if (objectNum == ID_FLARE_ITEM) { + item->data = (short)0; + short& age = item->data; if (DoFlareLight((PHD_VECTOR*)&item->pos, Lara.flareAge)) - item->data = (void*)(Lara.flareAge | 0x8000); + age = (Lara.flareAge | 0x8000); else - item->data = (void*)(Lara.flareAge & 0x7FFF); + age = (Lara.flareAge & 0x7FFF); } else { diff --git a/TR5Main/Game/Lara/lara_flare.h b/TR5Main/Game/Lara/lara_flare.h index 4a3d86491..f84828fbb 100644 --- a/TR5Main/Game/Lara/lara_flare.h +++ b/TR5Main/Game/Lara/lara_flare.h @@ -1,6 +1,8 @@ #pragma once -#include "items.h" +struct ITEM_INFO; +struct COLL_INFO; +struct PHD_VECTOR; enum GAME_OBJECT_ID : short; #define FLARE_AGE 30*30 //30 seconds * 30 frames diff --git a/TR5Main/Game/Lara/lara_hang.cpp b/TR5Main/Game/Lara/lara_hang.cpp index 681b39537..2357a16ef 100644 --- a/TR5Main/Game/Lara/lara_hang.cpp +++ b/TR5Main/Game/Lara/lara_hang.cpp @@ -2,7 +2,10 @@ #include "lara.h" #include "input.h" #include "lara_tests.h" - +#include "item.h" +#include "collide.h" +#include "camera.h" +#include "level.h" /*this file has all the lara_as/lara_col functions related to hanging*/ /*normal hanging and shimmying*/ diff --git a/TR5Main/Game/Lara/lara_info.h b/TR5Main/Game/Lara/lara_info.h new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/TR5Main/Game/Lara/lara_info.h @@ -0,0 +1 @@ +#pragma once diff --git a/TR5Main/Game/Lara/lara_initialise.cpp b/TR5Main/Game/Lara/lara_initialise.cpp index 9bf1d7ed9..739ca75e9 100644 --- a/TR5Main/Game/Lara/lara_initialise.cpp +++ b/TR5Main/Game/Lara/lara_initialise.cpp @@ -2,7 +2,10 @@ #include "lara.h" #include "lara_initialise.h" #include "health.h" - +#include "item.h" +#include "items.h" +#include "setup.h" +#include "level.h" void InitialiseLara(int restore) { if (Lara.itemNumber == NO_ITEM) @@ -10,7 +13,7 @@ void InitialiseLara(int restore) short itemNumber = Lara.itemNumber; - LaraItem->data = &Lara; + //LaraItem->data = &Lara; LaraItem->collidable = false; LaraItem->location.roomNumber = LaraItem->roomNumber; LaraItem->location.yNumber = LaraItem->pos.yPos; diff --git a/TR5Main/Game/Lara/lara_monkey.cpp b/TR5Main/Game/Lara/lara_monkey.cpp index 0a219c5fb..a5ec5b8a6 100644 --- a/TR5Main/Game/Lara/lara_monkey.cpp +++ b/TR5Main/Game/Lara/lara_monkey.cpp @@ -5,7 +5,12 @@ #include "lara_collide.h" #include "lara_tests.h" #include "lara_monkey.h" - +#include "floordata.h" +#include "collide.h" +#include "item.h" +#include "camera.h" +#include "control.h" +#include "level.h" using namespace TEN::Floordata; /*this file has all the related functions to monkeyswinging*/ diff --git a/TR5Main/Game/Lara/lara_monkey.h b/TR5Main/Game/Lara/lara_monkey.h index b8153972a..620cf1656 100644 --- a/TR5Main/Game/Lara/lara_monkey.h +++ b/TR5Main/Game/Lara/lara_monkey.h @@ -1,6 +1,6 @@ #pragma once -#include "lara_struct.h" - +struct ITEM_INFO; +struct COLL_INFO; /*monkeyswing state handling functions*/ void lara_as_hang2(ITEM_INFO* item, COLL_INFO* coll); void lara_col_hang2(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/Lara/lara_objects.cpp b/TR5Main/Game/Lara/lara_objects.cpp index 6f9ba0dbf..060923ed8 100644 --- a/TR5Main/Game/Lara/lara_objects.cpp +++ b/TR5Main/Game/Lara/lara_objects.cpp @@ -7,8 +7,9 @@ #include "lara_tests.h" #include "camera.h" #include "collide.h" +#include "item.h" #include "control.h" -#include "Specific\prng.h" + /*This file has "all" lara_as/lara_col functions where Lara is interacting with an object.*/ /*pickups*/ diff --git a/TR5Main/Game/Lara/lara_one_gun.h b/TR5Main/Game/Lara/lara_one_gun.h index a41f331cd..1909c5572 100644 --- a/TR5Main/Game/Lara/lara_one_gun.h +++ b/TR5Main/Game/Lara/lara_one_gun.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" #include "Specific\trmath.h" +struct ITEM_INFO; enum GRENADE_TYPE { GRENADE_NORMAL, diff --git a/TR5Main/Game/Lara/lara_slide.cpp b/TR5Main/Game/Lara/lara_slide.cpp index 8854d95db..ee98d42fb 100644 --- a/TR5Main/Game/Lara/lara_slide.cpp +++ b/TR5Main/Game/Lara/lara_slide.cpp @@ -3,6 +3,9 @@ #include "lara_collide.h" #include "input.h" #include "Sound\sound.h" +#include "collide.h" +#include "camera.h" +#include "level.h" short OldAngle = 1; diff --git a/TR5Main/Game/Lara/lara_slide.h b/TR5Main/Game/Lara/lara_slide.h index 26621a51f..c6d81a12b 100644 --- a/TR5Main/Game/Lara/lara_slide.h +++ b/TR5Main/Game/Lara/lara_slide.h @@ -1,5 +1,7 @@ #pragma once -#include "lara_struct.h" + +struct ITEM_INFO; +struct COLL_INFO; /*Tests and others*/ int TestLaraSlide(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/Lara/lara_struct.h b/TR5Main/Game/Lara/lara_struct.h index a938df9a4..1ec0fce9b 100644 --- a/TR5Main/Game/Lara/lara_struct.h +++ b/TR5Main/Game/Lara/lara_struct.h @@ -1,10 +1,6 @@ #pragma once -#include "box.h" -#include "collide.h" -#include "effects\effects.h" #include "objectslist.h" #include "Specific\trmath.h" -#include "Renderer11.h" #define NUM_PUZZLES (ID_PUZZLE_ITEM16 - ID_PUZZLE_ITEM1 + 1) #define NUM_PUZZLE_PIECES (ID_PUZZLE_ITEM16_COMBO2 - ID_PUZZLE_ITEM1_COMBO1 + 1) @@ -15,6 +11,15 @@ #define NUM_EXAMINES (ID_EXAMINE8 - ID_EXAMINE1 + 1) #define NUM_EXAMINES_PIECES (ID_EXAMINE8_COMBO2 - ID_EXAMINE1_COMBO1 + 1) +struct CREATURE_INFO; +struct ITEM_INFO; +struct FX_INFO; + +namespace TEN::Renderer { + struct RendererMesh; +} + + #pragma region state_and_animation enum LARA_STATE { @@ -965,7 +970,7 @@ struct LARA_ARM struct AnimsNew { bool CrouchRoll; //crouch roll - bool Monkey180Roll; //the 180° roll on monkeybars + bool Monkey180Roll; //the 180� roll on monkeybars bool Crawl1clickup; //going 1 click up in crawlspaces bool Crawl1clickdown; //going 1 click down in crawlspaces bool CrawlExit1click; //crawlspace exit at 1 click @@ -1110,4 +1115,4 @@ struct LaraInfo int NumSmallMedipacks; int NumLargeMedipacks; int NumFlares; -}; \ No newline at end of file +}; diff --git a/TR5Main/Game/Lara/lara_surface.h b/TR5Main/Game/Lara/lara_surface.h index eb8ccaf7a..cbe600662 100644 --- a/TR5Main/Game/Lara/lara_surface.h +++ b/TR5Main/Game/Lara/lara_surface.h @@ -1,8 +1,8 @@ #pragma once -#include "Lara.h" - +struct ITEM_INFO; +struct COLL_INFO; void _cdecl lara_col_surftread(ITEM_INFO* item, COLL_INFO* coll); void _cdecl lara_col_surfright(ITEM_INFO* item, COLL_INFO* coll); void _cdecl lara_col_surfleft(ITEM_INFO* item, COLL_INFO* coll); diff --git a/TR5Main/Game/Lara/lara_swim.cpp b/TR5Main/Game/Lara/lara_swim.cpp index 2a4835b6a..71ddb5f4f 100644 --- a/TR5Main/Game/Lara/lara_swim.cpp +++ b/TR5Main/Game/Lara/lara_swim.cpp @@ -160,7 +160,7 @@ int GetWaterDepth(int x, int y, int z, short roomNumber) floor = GetFloor(x, y, z, &roomNumber); return (GetFloorHeight(floor, x, y, z) - wh); } - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); } return 0x7FFF; } @@ -175,7 +175,7 @@ int GetWaterDepth(int x, int y, int z, short roomNumber) floor = GetFloor(x, y, z, &roomNumber); return (GetFloorHeight(floor, x, y, z) - wh); } - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); } return NO_HEIGHT; } diff --git a/TR5Main/Game/Lara/lara_tests.cpp b/TR5Main/Game/Lara/lara_tests.cpp index b0babed76..f8d3986bb 100644 --- a/TR5Main/Game/Lara/lara_tests.cpp +++ b/TR5Main/Game/Lara/lara_tests.cpp @@ -6,6 +6,7 @@ #include "control.h" #include "lara_climb.h" #include "lara_collide.h" +#include "control.h" using namespace TEN::Floordata; diff --git a/TR5Main/Game/Lara/lara_tests.h b/TR5Main/Game/Lara/lara_tests.h index ceca52455..e9c151d97 100644 --- a/TR5Main/Game/Lara/lara_tests.h +++ b/TR5Main/Game/Lara/lara_tests.h @@ -1,6 +1,8 @@ #pragma once -#include "lara_struct.h" +#include "collide.h" +struct ITEM_INFO; +struct COLL_INFO; int TestLaraVault(ITEM_INFO* item, COLL_INFO* coll); bool TestLaraStandUp(COLL_INFO* coll); int TestWall(ITEM_INFO* item, int front, int right, int down); diff --git a/TR5Main/Game/box.cpp b/TR5Main/Game/box.cpp index 2c433b860..a1a8f6a05 100644 --- a/TR5Main/Game/box.cpp +++ b/TR5Main/Game/box.cpp @@ -11,7 +11,7 @@ #include "setup.h" #include "Specific\trmath.h" #include "objectslist.h" - +#include "creature_info.h" #define CHECK_CLICK(x) CLICK(x) / 2 #define ESCAPE_DIST SECTOR(5) #define STALK_DIST SECTOR(3) @@ -22,7 +22,15 @@ #define BIFF_AVOID_TURN 1536 #define FEELER_DISTANCE 512 #define FEELER_ANGLE ANGLE(45.0f) +#ifdef CREATURE_AI_PRIORITY_OPTIMIZATION +constexpr int HIGH_PRIO_RANGE = 8; +constexpr int MEDIUM_PRIO_RANGE = HIGH_PRIO_RANGE + HIGH_PRIO_RANGE * (HIGH_PRIO_RANGE / 6.0f); +constexpr int LOW_PRIO_RANGE = MEDIUM_PRIO_RANGE + MEDIUM_PRIO_RANGE * (MEDIUM_PRIO_RANGE / 24.0f); +constexpr int NONE_PRIO_RANGE = LOW_PRIO_RANGE + LOW_PRIO_RANGE * (LOW_PRIO_RANGE / 32.0f); +constexpr auto FRAME_PRIO_BASE = 4; +constexpr auto FRAME_PRIO_EXP = 1.5; +#endif // CREATURE_AI_PRIORITY_OPTIMIZATION void DropBaddyPickups(ITEM_INFO* item) { ITEM_INFO* pickup = NULL; @@ -109,13 +117,13 @@ bool SameZone(CREATURE_INFO* creature, ITEM_INFO* target) int* zone = g_Level.Zones[creature->LOT.zone][FlipStatus].data(); ITEM_INFO* item = &g_Level.Items[creature->itemNum]; ROOM_INFO* room = &g_Level.Rooms[item->roomNumber]; - FLOOR_INFO* floor = &XZ_GET_SECTOR(room, item->pos.xPos - room->x, item->pos.zPos - room->z); + FLOOR_INFO* floor = XZ_GET_SECTOR(room, item->pos.xPos - room->x, item->pos.zPos - room->z); if (floor->box == NO_BOX) return false; item->boxNumber = floor->box; room = &g_Level.Rooms[target->roomNumber]; - floor = &XZ_GET_SECTOR(room, target->pos.xPos - room->x, target->pos.zPos - room->z); + floor = XZ_GET_SECTOR(room, target->pos.xPos - room->x, target->pos.zPos - room->z); if (floor->box == NO_BOX) return false; target->boxNumber = floor->box; @@ -166,9 +174,9 @@ void AlertNearbyGuards(ITEM_INFO* item) int x, y, z; int distance; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - creature = &BaddieSlots[i]; + creature = ActiveCreatures[i]; if (creature->itemNum == NO_ITEM) continue; @@ -195,9 +203,9 @@ void AlertAllGuards(short itemNumber) CREATURE_INFO* creature; short objNumber; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - creature = &BaddieSlots[i]; + creature = ActiveCreatures[i]; if (creature->itemNum == NO_ITEM) continue; @@ -364,7 +372,7 @@ void CreatureFloat(short itemNumber) void CreatureJoint(ITEM_INFO* item, short joint, short required) { - if (item->data == NULL) + if (!item->data) return; CREATURE_INFO* creature = (CREATURE_INFO*)item->data; @@ -403,7 +411,7 @@ void CreatureTilt(ITEM_INFO* item, short angle) short CreatureTurn(ITEM_INFO* item, short maximumTurn) { - if (item->data == NULL || maximumTurn == 0) + if (!item->data || maximumTurn == 0) return 0; CREATURE_INFO* creature; @@ -446,7 +454,7 @@ int CreatureAnimation(short itemNumber, short angle, short tilt) int boxHeight, height, nextHeight, nextBox; item = &g_Level.Items[itemNumber]; - if (item->data == NULL) + if (!item->data) return false; creature = (CREATURE_INFO*)item->data; @@ -1074,7 +1082,23 @@ int SearchLOT(LOT_INFO* LOT, int depth) return true; } -int CreatureActive(short itemNumber) + +#if CREATURE_AI_PRIORITY_OPTIMIZATION +CREATURE_AI_PRIORITY GetCreatureLOTPriority(ITEM_INFO* item) { + Vector3 itemPos = Vector3(item->pos.xPos, item->pos.yPos, item->pos.zPos); + Vector3 cameraPos = Vector3(Camera.pos.x, Camera.pos.y, Camera.pos.z); + float distance = Vector3::Distance(itemPos, cameraPos); + distance /= SECTOR(1); + if(distance <= HIGH_PRIO_RANGE) + return CREATURE_AI_PRIORITY::HIGH; + if(distance <= MEDIUM_PRIO_RANGE) + return CREATURE_AI_PRIORITY::MEDIUM; + if(distance <= LOW_PRIO_RANGE) + return CREATURE_AI_PRIORITY::LOW; + return CREATURE_AI_PRIORITY::NONE; +} +#endif +int CreatureActive(short itemNumber) { ITEM_INFO* item = &g_Level.Items[itemNumber]; @@ -1091,6 +1115,10 @@ int CreatureActive(short itemNumber) } item->status = ITEM_ACTIVE; } +#ifdef CREATURE_AI_PRIORITY_OPTIMIZATION + CREATURE_INFO* creature = (CREATURE_INFO*)item->data; + creature->priority = GetCreatureLOTPriority(item); +#endif // CREATURE_AI_PRIORITY_OPTIMIZATION return true; } @@ -1395,10 +1423,10 @@ void FindAITargetObject(CREATURE_INFO* creature, short objectNumber) int* zone = g_Level.Zones[creature->LOT.zone][FlipStatus].data(); ROOM_INFO* r = &g_Level.Rooms[item->roomNumber]; - item->boxNumber = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z).box; + item->boxNumber = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z)->box; r = &g_Level.Rooms[aiObject->roomNumber]; - aiObject->boxNumber = XZ_GET_SECTOR(r, aiObject->x - r->x, aiObject->z - r->z).box; + aiObject->boxNumber = XZ_GET_SECTOR(r, aiObject->x - r->x, aiObject->z - r->z)->box; if (item->boxNumber == NO_BOX || aiObject->boxNumber == NO_BOX) { @@ -1415,9 +1443,9 @@ void FindAITargetObject(CREATURE_INFO* creature, short objectNumber) if (foundObject != NULL) { - ITEM_INFO* aiItem = &creature->aiTarget; + CREATURE_TARGET* aiItem = &creature->aiTarget; - creature->enemy = aiItem; + creature->enemy = nullptr; aiItem->objectNumber = foundObject->objectNumber; aiItem->roomNumber = foundObject->roomNumber; @@ -1440,7 +1468,7 @@ void FindAITargetObject(CREATURE_INFO* creature, short objectNumber) void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info) { - if (item->data == NULL) + if (!item->data) return; CREATURE_INFO * creature; @@ -1464,14 +1492,20 @@ void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info) zone = g_Level.Zones[creature->LOT.zone][FlipStatus].data(); r = &g_Level.Rooms[item->roomNumber]; - item->boxNumber = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z).box; + item->boxNumber = NO_BOX; + FLOOR_INFO* floor = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z); + if(floor) + item->boxNumber = floor->box; if (item->boxNumber != NO_BOX) info->zoneNumber = zone[item->boxNumber]; else info->zoneNumber = NO_ZONE; r = &g_Level.Rooms[enemy->roomNumber]; - enemy->boxNumber = XZ_GET_SECTOR(r, enemy->pos.xPos - r->x, enemy->pos.zPos - r->z).box; + enemy->boxNumber = NO_BOX; + floor = XZ_GET_SECTOR(r, enemy->pos.xPos - r->x, enemy->pos.zPos - r->z); + if(floor) + enemy->boxNumber = floor->box; if (enemy->boxNumber != NO_BOX) info->enemyZone = zone[enemy->boxNumber]; else @@ -1543,7 +1577,7 @@ void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info) void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent) { - if (item->data == NULL) + if (!item->data) return; CREATURE_INFO* creature; @@ -1627,8 +1661,37 @@ void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent) if (LOT->targetBox == NO_BOX) TargetBox(LOT, item->boxNumber); +#ifdef CREATURE_AI_PRIORITY_OPTIMIZATION + bool shouldUpdateTarget = false; + switch(creature->priority) { + case CREATURE_AI_PRIORITY::HIGH: + shouldUpdateTarget = true; + break; + case CREATURE_AI_PRIORITY::MEDIUM: + { + if(creature->framesSinceLOTUpdate > std::pow(FRAME_PRIO_BASE, FRAME_PRIO_EXP)) + shouldUpdateTarget = true; + } + break; + case CREATURE_AI_PRIORITY::LOW: + { + if(creature->framesSinceLOTUpdate > std::pow(FRAME_PRIO_BASE,FRAME_PRIO_EXP*2)) + shouldUpdateTarget = true; + } + break; + default: + break; + } + if(shouldUpdateTarget) { + CalculateTarget(&creature->target, item, &creature->LOT); + creature->framesSinceLOTUpdate = 0; + } else { + creature->framesSinceLOTUpdate++; + } +#else CalculateTarget(&creature->target, item, &creature->LOT); +#endif // CREATURE_AI_PRIORITY_OPTIMIZATION creature->jumpAhead = false; creature->monkeyAhead = false; @@ -1663,7 +1726,7 @@ void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent) void GetCreatureMood(ITEM_INFO* item, AI_INFO* info, int isViolent) { - if (item->data == NULL) + if (!item->data) return; CREATURE_INFO* creature; @@ -2009,7 +2072,7 @@ void AdjustStopperFlag(ITEM_INFO* item, int dir, int set) ROOM_INFO* r = &g_Level.Rooms[item->roomNumber]; - FLOOR_INFO* floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + FLOOR_INFO* floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); floor->stopper = set; x = item->pos.xPos + 1024 * phd_sin(dir); @@ -2019,6 +2082,16 @@ void AdjustStopperFlag(ITEM_INFO* item, int dir, int set) GetFloor(x, item->pos.yPos, z, &roomNumber); r = &g_Level.Rooms[roomNumber]; - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); floor->stopper = set; -} \ No newline at end of file +} + +FLOOR_INFO* XZ_GET_SECTOR(ROOM_INFO* r, int x, int z) { + int sectorX = (x) / SECTOR(1); + int sectorZ = (z) / SECTOR(1); + int index = sectorZ + sectorX * r->xSize; + if(index > r->floor.size()) { + return nullptr; + } + return &r->floor[index]; +} diff --git a/TR5Main/Game/collide.cpp b/TR5Main/Game/collide.cpp index 913924d33..024d147ad 100644 --- a/TR5Main/Game/collide.cpp +++ b/TR5Main/Game/collide.cpp @@ -12,6 +12,7 @@ #include "Specific\trmath.h" #include "Specific\prng.h" #include "room.h" +#include "Renderer11.h"" using std::vector; using namespace TEN::Math::Random; @@ -1251,7 +1252,7 @@ COLL_RESULT GetCollisionResult(FLOOR_INFO* floor, int x, int y, int z) if (CheckNoColFloorTriangle(floor, x, z) == 1) break; r = &g_Level.Rooms[floor->pitRoom]; - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); } // Return probed bottom block into result. diff --git a/TR5Main/Game/collide.h b/TR5Main/Game/collide.h index b77f33127..a9f4a76d4 100644 --- a/TR5Main/Game/collide.h +++ b/TR5Main/Game/collide.h @@ -1,6 +1,10 @@ #pragma once #include "Specific\phd_global.h" -#include "level.h" +#include "trmath.h" +struct ITEM_INFO; +struct COLL_INFO; +struct FLOOR_INFO; +struct MESH_INFO; // used by coll->Setup.BadHeightUp #define NO_BAD_POS (-NO_HEIGHT) diff --git a/TR5Main/Game/control.cpp b/TR5Main/Game/control.cpp index dd4111b72..6915e651c 100644 --- a/TR5Main/Game/control.cpp +++ b/TR5Main/Game/control.cpp @@ -52,7 +52,7 @@ #include #include #include "generic_switch.h" - +#include "creature_info.h" using namespace TEN::Entities::Switches; using std::vector; @@ -562,9 +562,6 @@ unsigned CALLBACK GameMain(void *) { try { printf("GameMain\n"); - - // Initialise legacy memory buffer and game timer - init_game_malloc(); TIME_Init(); if (g_GameFlow->IntroImagePath.empty()) { @@ -906,7 +903,7 @@ void TranslateItem(ITEM_INFO *item, int x, int y, int z) int GetWaterSurface(int x, int y, int z, short roomNumber) { ROOM_INFO *room = &g_Level.Rooms[roomNumber]; - FLOOR_INFO *floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z); + FLOOR_INFO *floor = XZ_GET_SECTOR(room, x - room->x, z - room->z); if (room->flags & ENV_FLAG_WATER) { @@ -915,7 +912,7 @@ int GetWaterSurface(int x, int y, int z, short roomNumber) room = &g_Level.Rooms[floor->skyRoom]; if (!(room->flags & ENV_FLAG_WATER)) return (floor->ceiling << 8); - floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z); + floor = XZ_GET_SECTOR(room, x - room->x, z - room->z); } return NO_HEIGHT; } @@ -926,7 +923,7 @@ int GetWaterSurface(int x, int y, int z, short roomNumber) room = &g_Level.Rooms[floor->pitRoom]; if (room->flags & ENV_FLAG_WATER) return (floor->floor << 8); - floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z); + floor = XZ_GET_SECTOR(room, x - room->x, z - room->z); } } @@ -2406,9 +2403,9 @@ void DoFlipMap(short group) FlipStats[group] = status; FlipStatus = status; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - BaddieSlots[i].LOT.targetBox = NO_BOX; + ActiveCreatures[i]->LOT.targetBox = NO_BOX; } } @@ -2613,7 +2610,7 @@ int GetWaterHeight(int x, int y, int z, short roomNumber) r = &g_Level.Rooms[floor->skyRoom]; if (!(r->flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP))) return r->minfloor; - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); if (floor->skyRoom == NO_ROOM) break; } @@ -2629,7 +2626,7 @@ int GetWaterHeight(int x, int y, int z, short roomNumber) r = &g_Level.Rooms[floor->pitRoom]; if (r->flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP)) return r->maxceiling; - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); if (floor->pitRoom == NO_ROOM) break; } diff --git a/TR5Main/Game/control.h b/TR5Main/Game/control.h index 73eda55ff..48e5ed96b 100644 --- a/TR5Main/Game/control.h +++ b/TR5Main/Game/control.h @@ -6,7 +6,12 @@ #include "control\trigger.h" struct BOUNDING_BOX; - +struct ITEM_INFO; +struct COLL_INFO; +class FLOOR_INFO; +struct ANIM_STRUCT; +struct MESH_INFO; +struct ROOM_INFO; enum GAME_STATUS { GAME_STATUS_NONE, @@ -144,4 +149,4 @@ void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift); int IsRoomOutside(int x, int y, int z); void ResetGlobals(); -unsigned CALLBACK GameMain(void*); \ No newline at end of file +unsigned CALLBACK GameMain(void*); diff --git a/TR5Main/Game/control/trigger.cpp b/TR5Main/Game/control/trigger.cpp index 25559d8f3..29e39c846 100644 --- a/TR5Main/Game/control/trigger.cpp +++ b/TR5Main/Game/control/trigger.cpp @@ -163,7 +163,7 @@ short* GetTriggerIndex(FLOOR_INFO* floor, int x, int y, int z) if (CheckNoColFloorTriangle(floor, x, z) == 1) break; r = &g_Level.Rooms[floor->pitRoom]; - floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z); + floor = XZ_GET_SECTOR(r, x - r->x, z - r->z); } if ((floor->floor * 256) == NO_HEIGHT || floor->index == 0) diff --git a/TR5Main/Game/control/trigger.h b/TR5Main/Game/control/trigger.h index a23b0e131..3b5c57690 100644 --- a/TR5Main/Game/control/trigger.h +++ b/TR5Main/Game/control/trigger.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include "control.h" +struct ITEM_INFO; +struct FLOOR_INFO; int GetKeyTrigger(ITEM_INFO* item); int GetSwitchTrigger(ITEM_INFO* item, short* itemNos, int AttatchedToSwitch); diff --git a/TR5Main/Game/creature_info.h b/TR5Main/Game/creature_info.h new file mode 100644 index 000000000..f90684097 --- /dev/null +++ b/TR5Main/Game/creature_info.h @@ -0,0 +1,98 @@ +#pragma once +#include "phd_global.h" +#include +struct BOX_NODE { + int exitBox; + int searchNumber; + int nextExpansion; + int boxNumber; +}; + +enum ZoneType : char { + ZONE_NULL = -1, // default zone + ZONE_SKELLY = 0, + ZONE_BASIC, + ZONE_FLYER, + ZONE_HUMAN_CLASSIC, + ZONE_VON_CROY, + ZONE_WATER, + ZONE_MAX, + /// custom zone (using zone above for LOT.zone): + ZONE_HUMAN_JUMP_AND_MONKEY, + ZONE_HUMAN_JUMP, + ZONE_SPIDER, + ZONE_BLOCKABLE, // for trex, shiva, etc.. + ZONE_SOPHIALEE, // dont want sophia to go down again ! + ZONE_APE, // only 2 click climb + ZONE_HUMAN_LONGJUMP_AND_MONKEY, +}; + +struct LOT_INFO { + std::vector node; + int head; + int tail; + int searchNumber; + int blockMask; + short step; + short drop; + short zoneCount; + int targetBox; + int requiredBox; + short fly; + bool canJump; + bool canMonkey; + bool isAmphibious; + bool isJumping; + bool isMonkeying; + PHD_VECTOR target; + ZoneType zone; + bool initialised; +}; +enum MOOD_TYPE { + BORED_MOOD, + ATTACK_MOOD, + ESCAPE_MOOD, + STALK_MOOD +}; + +struct CREATURE_TARGET { + GAME_OBJECT_ID objectNumber; + int boxNumber; + PHD_3DPOS pos; + uint16_t flags; // ItemFlags enum + uint16_t triggerFlags; + short roomNumber; + +}; + +enum class CREATURE_AI_PRIORITY { + HIGH, + MEDIUM, + LOW, + NONE +}; + +struct CREATURE_INFO { + short jointRotation[4]; + short maximumTurn; + short flags; + bool alerted; + bool headLeft; + bool headRight; + bool reachedGoal; + bool hurtByLara; + bool patrol2; + bool jumpAhead; + bool monkeyAhead; + MOOD_TYPE mood; + ITEM_INFO* enemy; + CREATURE_TARGET aiTarget; + short pad; + short itemNum; + PHD_VECTOR target; + LOT_INFO LOT; +#ifdef CREATURE_AI_PRIORITY_OPTIMIZATION + CREATURE_AI_PRIORITY priority; + size_t framesSinceLOTUpdate; +#endif +}; \ No newline at end of file diff --git a/TR5Main/Game/door.cpp b/TR5Main/Game/door.cpp index af33ba5cc..3c8bbdab9 100644 --- a/TR5Main/Game/door.cpp +++ b/TR5Main/Game/door.cpp @@ -21,7 +21,8 @@ #include "generic_switch.h" #include "pickup\pickup.h" #include "fullblock_switch.h" - +#include "creature_info.h" +#include "door_data.h" using namespace TEN::Entities::Switches; PHD_VECTOR DoubleDoorPos(0, 0, 220); @@ -583,7 +584,7 @@ void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) if (floor != NULL) { - memcpy(doorPos->floor, &doorPos->data, sizeof(FLOOR_INFO)); + *doorPos->floor = doorPos->data; short boxIndex = doorPos->block; if (boxIndex != NO_BOX) @@ -591,9 +592,9 @@ void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) if (!DontUnlockBox) g_Level.Boxes[boxIndex].flags &= ~BLOCKED; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - BaddieSlots[i].LOT.targetBox = NO_BOX; + ActiveCreatures[i]->LOT.targetBox = NO_BOX; } } } @@ -681,9 +682,9 @@ void ShutThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) if (boxIndex != NO_BOX) { g_Level.Boxes[boxIndex].flags |= BLOCKED; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - BaddieSlots[i].LOT.targetBox = NO_BOX; + ActiveCreatures[i]->LOT.targetBox = NO_BOX; } } } @@ -723,15 +724,14 @@ void InitialiseDoor(short itemNumber) if (item->objectNumber == ID_LIFT_DOORS1 || item->objectNumber == ID_LIFT_DOORS2) item->itemFlags[0] = 4096; + item->data = DOOR_DATA(); + DOOR_DATA* door = item->data; - DOOR_DATA * door = game_malloc(); - - item->data = door; door->opened = false; - door->dptr1 = NULL; - door->dptr2 = NULL; - door->dptr3 = NULL; - door->dptr4 = NULL; + door->dptr1 = nullptr; + door->dptr2 = nullptr; + door->dptr3 = nullptr; + door->dptr4 = nullptr; int dz, dx; ROOM_INFO* r; @@ -761,8 +761,7 @@ void InitialiseDoor(short itemNumber) boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + dz + ((item->pos.xPos - b->x) / SECTOR(1) + dx) * b->xSize].box; } door->d1.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - - memcpy(&door->d1.data, door->d1.floor, sizeof(FLOOR_INFO)); + door->d1.data = *door->d1.floor; if (r->flippedRoom != -1) { @@ -779,7 +778,7 @@ void InitialiseDoor(short itemNumber) } door->d1flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - memcpy(&door->d1flip.data, door->d1flip.floor, sizeof(FLOOR_INFO)); + door->d1flip.data = *door->d1flip.floor; } else door->d1flip.floor = NULL; @@ -809,7 +808,7 @@ void InitialiseDoor(short itemNumber) } door->d2.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - memcpy(&door->d2.data, door->d2.floor, sizeof(FLOOR_INFO)); + door->d2.data = *door->d2.floor; if (r->flippedRoom != -1) { @@ -826,7 +825,7 @@ void InitialiseDoor(short itemNumber) } door->d2flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - memcpy(&door->d2flip.data, door->d2flip.floor, sizeof(FLOOR_INFO)); + door->d2flip.data = *door->d2flip.floor; } else door->d2flip.floor = NULL; diff --git a/TR5Main/Game/door.h b/TR5Main/Game/door.h index a9552d1fe..e7195d651 100644 --- a/TR5Main/Game/door.h +++ b/TR5Main/Game/door.h @@ -1,32 +1,10 @@ #pragma once -#include "items.h" -#include "collide.h" -#include "room.h" +struct COLL_INFO; +struct ITEM_INFO; +struct ROOM_INFO; +struct DOORPOS_DATA; +struct DOOR_DATA; -struct DOORPOS_DATA -{ - FLOOR_INFO* floor; - FLOOR_INFO data; - short block; -}; - -struct DOOR_DATA -{ - DOORPOS_DATA d1; - DOORPOS_DATA d1flip; - DOORPOS_DATA d2; - DOORPOS_DATA d2flip; - short opened; - short* dptr1; - short* dptr2; - short* dptr3; - short* dptr4; - byte dn1; - byte dn2; - byte dn3; - byte dn4; - ITEM_INFO* item; -}; void SequenceDoorControl(short itemNumber); void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); diff --git a/TR5Main/Game/door_data.h b/TR5Main/Game/door_data.h new file mode 100644 index 000000000..f2c589e03 --- /dev/null +++ b/TR5Main/Game/door_data.h @@ -0,0 +1,25 @@ +#pragma once +#include "floordata.h" +struct ITEM_INFO; +struct DOORPOS_DATA { + FLOOR_INFO* floor; + FLOOR_INFO data; + short block; +}; + +struct DOOR_DATA { + DOORPOS_DATA d1; + DOORPOS_DATA d1flip; + DOORPOS_DATA d2; + DOORPOS_DATA d2flip; + short opened; + short* dptr1; + short* dptr2; + short* dptr3; + short* dptr4; + unsigned char dn1; + unsigned char dn2; + unsigned char dn3; + unsigned char dn4; + ITEM_INFO* item; +}; \ No newline at end of file diff --git a/TR5Main/Game/draw.h b/TR5Main/Game/draw.h index 24e32c429..dde8c91a5 100644 --- a/TR5Main/Game/draw.h +++ b/TR5Main/Game/draw.h @@ -1,5 +1,9 @@ #pragma once -#include "box.h" +#include "Box.h" +struct PHD_3DPOS; +struct PHD_VECTOR; +struct ANIM_FRAME; +struct ITEM_INFO; extern BITE_INFO EnemyBites[9]; extern int LightningCount; diff --git a/TR5Main/Game/effects/effects.cpp b/TR5Main/Game/effects/effects.cpp index 2799e5d3c..38748361d 100644 --- a/TR5Main/Game/effects/effects.cpp +++ b/TR5Main/Game/effects/effects.cpp @@ -16,6 +16,7 @@ #include #include "smoke.h" #include "Specific\prng.h" +#include "Renderer11.h" using TEN::Renderer::g_Renderer; using TEN::Effects::Explosion::TriggerExplosion; @@ -23,7 +24,7 @@ using namespace TEN::Effects::Spark; using namespace TEN::Math::Random; short FXType; -FX_INFO* EffectList; +FX_INFO EffectList[NUM_EFFECTS]; int NextSpark; int DeadlyBounds[6]; @@ -1869,4 +1870,4 @@ void TriggerMetalSparks(int x, int y, int z, int xv, int yv, int zv, int additio spark->dSize = ((r >> 8) & 0xF) + 24; } } -} \ No newline at end of file +} diff --git a/TR5Main/Game/effects/effects.h b/TR5Main/Game/effects/effects.h index 3d1c9cb9b..b713065d6 100644 --- a/TR5Main/Game/effects/effects.h +++ b/TR5Main/Game/effects/effects.h @@ -1,6 +1,7 @@ #pragma once #include "Specific\phd_global.h" -#include "items.h" +struct ITEM_INFO; +struct COLL_INFO; enum RIPPLE_TYPE { @@ -180,7 +181,7 @@ constexpr auto SD_UWEXPLOSION = 2; #define MAX_RIPPLES 256 #define MAX_SPLASHES 8 #define MAX_SPARKS_DYNAMICS 8 - +#define NUM_EFFECTS 256 extern int NextSpark; extern int DeadlyBounds[6]; extern SPLASH_SETUP SplashSetup; @@ -195,7 +196,7 @@ extern int SplashCount; extern PHD_VECTOR NodeVectors[MAX_NODE]; extern NODEOFFSET_INFO NodeOffsets[MAX_NODE]; -extern FX_INFO* EffectList; +extern FX_INFO EffectList[NUM_EFFECTS]; void DetatchSpark(int num, SpriteEnumFlag type); int GetFreeSpark(); diff --git a/TR5Main/Game/effects/hair.cpp b/TR5Main/Game/effects/hair.cpp index 08e199e4d..3e54b682e 100644 --- a/TR5Main/Game/effects/hair.cpp +++ b/TR5Main/Game/effects/hair.cpp @@ -8,6 +8,7 @@ #include "setup.h" #include "sphere.h" #include "level.h" +#include "Renderer11.h" using TEN::Renderer::g_Renderer; int FirstHair[HAIR_MAX]; HAIR_STRUCT Hairs[HAIR_MAX][HAIR_SEGMENTS + 1]; diff --git a/TR5Main/Game/effects/tomb4fx.h b/TR5Main/Game/effects/tomb4fx.h index 915adfece..bf9f1ce35 100644 --- a/TR5Main/Game/effects/tomb4fx.h +++ b/TR5Main/Game/effects/tomb4fx.h @@ -1,7 +1,7 @@ #pragma once #include "Specific\phd_global.h" -#include "items.h" #include "lara_struct.h" +struct ITEM_INFO; struct ENERGY_ARC { diff --git a/TR5Main/Game/floordata.cpp b/TR5Main/Game/floordata.cpp index 92ea2bb13..18fa52c28 100644 --- a/TR5Main/Game/floordata.cpp +++ b/TR5Main/Game/floordata.cpp @@ -1,6 +1,6 @@ #include "framework.h" -#include "Specific\trmath.h" #include "floordata.h" +#include "Specific\trmath.h" #include "room.h" #include "level.h" #include "setup.h" diff --git a/TR5Main/Game/floordata.h b/TR5Main/Game/floordata.h index a506a98eb..2222b0e17 100644 --- a/TR5Main/Game/floordata.h +++ b/TR5Main/Game/floordata.h @@ -1,6 +1,7 @@ #pragma once #include "Specific\trmath.h" -#include "items.h" +#include +#include "roomvector.h" struct SECTOR_COLLISION_INFO { @@ -25,7 +26,7 @@ struct SECTOR_FLAGS class FLOOR_INFO { -public: + public: int index; int box; int fx; diff --git a/TR5Main/Game/health.cpp b/TR5Main/Game/health.cpp index 310b853fc..131eed58f 100644 --- a/TR5Main/Game/health.cpp +++ b/TR5Main/Game/health.cpp @@ -6,7 +6,7 @@ #include "camera.h" #include "level.h" #include "control.h" - +#include "Renderer11.h" using namespace TEN::Renderer; short PickupX; short PickupY; diff --git a/TR5Main/Game/item.h b/TR5Main/Game/item.h new file mode 100644 index 000000000..69d1a3536 --- /dev/null +++ b/TR5Main/Game/item.h @@ -0,0 +1,57 @@ +#pragma once +#include +#include "phd_global.h" +#include +#include "itemdata.h" +#include "roomvector.h" +enum GAME_OBJECT_ID : short; + + + +struct ITEM_INFO { + int floor; + uint32_t touchBits; + uint32_t meshBits; + GAME_OBJECT_ID objectNumber; + short currentAnimState; + short goalAnimState; + short requiredAnimState; + short animNumber; + short frameNumber; + short roomNumber; + ROOM_VECTOR location; + short nextItem; + short nextActive; + short speed; + short fallspeed; + short hitPoints; + int boxNumber; + short timer; + uint16_t flags; // ItemFlags enum + short shade; + uint16_t triggerFlags; + short carriedItem; + short afterDeath; + short firedWeapon; + short itemFlags[8]; + ITEM_DATA data; + PHD_3DPOS pos; + bool active; + short status; // ItemStatus enum + bool gravityStatus; + bool hitStatus; + bool collidable; + bool lookedAt; + bool dynamicLight; + bool poisoned; + uint8_t aiBits; // AIObjectType enum + bool reallyActive; + bool inDrawRoom; + bool friendly; + uint32_t swapMeshFlags; + short drawRoom; + short TOSSPAD; + PHD_3DPOS startPos; + short locationAI; + std::string luaName; +}; \ No newline at end of file diff --git a/TR5Main/Game/itemdata/itemdata.cpp b/TR5Main/Game/itemdata/itemdata.cpp new file mode 100644 index 000000000..bfce307fb --- /dev/null +++ b/TR5Main/Game/itemdata/itemdata.cpp @@ -0,0 +1,4 @@ +#include "framework.h" +#include "itemdata.h" + +ITEM_DATA::ITEM_DATA() : data(nullptr) {} diff --git a/TR5Main/Game/itemdata/itemdata.h b/TR5Main/Game/itemdata/itemdata.h new file mode 100644 index 000000000..be2a2df8f --- /dev/null +++ b/TR5Main/Game/itemdata/itemdata.h @@ -0,0 +1,131 @@ +#pragma once +#include +#include +#include +#include "upv_info.h" +#include "skidoo_info.h" +#include "door_data.h" +#include "kayak_info.h" +#include "lara_struct.h" +#include "jeep_info.h" +#include "motorbike_info.h" +#include "minecart_info.h" +#include "biggun_info.h" +#include "quad_info.h" +#include "tr5_laserhead_info.h" +#include "creature_info.h" +#include "boat_info.h" +#include "rubberboat_info.h" +#include +#include "phd_global.h" +#include "tr4_wraith_info.h" +#include "tr5_pushableblock_info.h" + +template struct visitor : Ts... { using Ts::operator()...; }; +template visitor(Ts...)->visitor; // line not needed in C++20... + +struct ITEM_INFO; + +class ITEM_DATA { + std::variant, + ITEM_INFO*, + CREATURE_INFO, + LASER_HEAD_INFO, + QUAD_INFO, + BIGGUNINFO, + MOTORBIKE_INFO, + JEEP_INFO, + LaraInfo, + KAYAK_INFO, + DOOR_DATA, + SKIDOO_INFO, + SUB_INFO, + BOAT_INFO, + GAME_VECTOR, + WRAITH_INFO, + RUBBER_BOAT_INFO, + PUSHABLE_INFO, + CART_INFO + > data; + public: + ITEM_DATA(); + + template + ITEM_DATA(D&& type) : data(std::move(type)) {} + + + // conversion operators to keep original syntax! + // TODO: should be removed later and + template + operator T* () { + if(std::holds_alternative(data)) { + auto& ref = std::get(data); + return &ref; + } + throw std::runtime_error("ITEM_DATA does not hold the requested type!\n The code set the ITEM_DATA to a different type than the type that was attempted to read"); + } + + template + operator T& () { + if(std::holds_alternative(data)) { + auto& ref = std::get(data); + return ref; + } + throw std::runtime_error("ITEM_DATA does not hold the requested type!\n The code set the ITEM_DATA to a different type than the type that was attempted to read"); + } + + template + ITEM_DATA& operator=(T* newData) { + data = *newData; + return *this; + } + + ITEM_DATA& operator=(std::nullptr_t null) { + data = nullptr; + return *this; + } + + template + ITEM_DATA& operator=(T& newData) { + data = newData; + return *this; + } + + template + ITEM_DATA& operator=(T&& newData) { + data = std::move(newData); + return *this; + } + + operator bool() const { + return !std::holds_alternative(data); + } + + template + void apply(Funcs&&... funcs) { + std::visit( + visitor{ + [](auto const&) {}, + std::forward(funcs)... + }, + data); + } + template + bool is() const { + return std::holds_alternative(data); + } +}; diff --git a/TR5Main/Game/items.cpp b/TR5Main/Game/items.cpp index 7fe97bae0..faf3d2214 100644 --- a/TR5Main/Game/items.cpp +++ b/TR5Main/Game/items.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "control.h" #include "effects\effects.h" +#include "Game\box.h" void ClearItem(short itemNum) { @@ -12,7 +13,7 @@ void ClearItem(short itemNum) ROOM_INFO* room = &g_Level.Rooms[item->roomNumber]; item->collidable = true; - item->data = NULL; + item->data = nullptr; item->startPos = item->pos; } @@ -270,8 +271,6 @@ short CreateNewEffect(short roomNum) void InitialiseFXArray(int allocmem) { - if (allocmem) - EffectList = game_malloc(NUM_EFFECTS); FX_INFO* fx; @@ -382,7 +381,6 @@ void InitialiseItem(short itemNum) item->touchBits = 0; item->afterDeath = false; item->firedWeapon = 0; - item->data = NULL; item->swapMeshFlags = 0; if (item->flags & IFLAG_INVISIBLE) @@ -408,7 +406,7 @@ void InitialiseItem(short itemNum) item->nextItem = r->itemNumber; r->itemNumber = itemNum; - FLOOR_INFO* floor = &XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z); + FLOOR_INFO* floor = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z); item->floor = floor->floor * 256; item->boxNumber = floor->box; diff --git a/TR5Main/Game/items.h b/TR5Main/Game/items.h index 3a0e72c1a..09bc594c9 100644 --- a/TR5Main/Game/items.h +++ b/TR5Main/Game/items.h @@ -1,7 +1,7 @@ #pragma once #include "Specific\phd_global.h" - -enum GAME_OBJECT_ID : short; +#include "item.h" +#include enum AIObjectType { @@ -32,60 +32,8 @@ enum ItemFlags IFLAG_ACTIVATION_MASK = 0x3E00 // bits 9-13 }; -struct ROOM_VECTOR -{ - int roomNumber; - int yNumber; -}; -struct ITEM_INFO -{ - int floor; - DWORD touchBits; - DWORD meshBits; - GAME_OBJECT_ID objectNumber; - short currentAnimState; - short goalAnimState; - short requiredAnimState; - short animNumber; - short frameNumber; - short roomNumber; - ROOM_VECTOR location; - short nextItem; - short nextActive; - short speed; - short fallspeed; - short hitPoints; - int boxNumber; - short timer; - unsigned short flags; // ItemFlags enum - short shade; - short triggerFlags; - short carriedItem; - short afterDeath; - short firedWeapon; - short itemFlags[8]; - void* data; - PHD_3DPOS pos; - bool active; - short status; // ItemStatus enum - bool gravityStatus; - bool hitStatus; - bool collidable; - bool lookedAt; - bool dynamicLight; - bool poisoned; - byte aiBits; // AIObjectType enum - bool reallyActive; - bool inDrawRoom; - bool friendly; - int swapMeshFlags; - short drawRoom; - short TOSSPAD; - PHD_3DPOS startPos; - short locationAI; - std::string luaName; -}; + // used by fx->shade ! #define RGB555(r, g, b) ((r << 7) & 0x7C00 | (g << 2) & 0x3E0 | (b >> 3) & 0x1F) @@ -97,7 +45,6 @@ constexpr auto NO_ITEM = -1; constexpr auto ALL_MESHBITS = -1; constexpr auto NOT_TARGETABLE = -16384; #define NUM_ITEMS 1024 -#define NUM_EFFECTS 1024 void EffectNewRoom(short fxNumber, short roomNumber); void ItemNewRoom(short itemNum, short roomNumber); diff --git a/TR5Main/Game/lot.cpp b/TR5Main/Game/lot.cpp index 440c264b8..59a829f33 100644 --- a/TR5Main/Game/lot.cpp +++ b/TR5Main/Game/lot.cpp @@ -5,46 +5,35 @@ #include "camera.h" #include "lara.h" #include "level.h" - +#include "creature_info.h" #define DEFAULT_FLY_UPDOWN_SPEED 16 #define DEFAULT_SWIM_UPDOWN_SPEED 32 int SlotsUsed; -std::vector BaddieSlots; +std::vector ActiveCreatures; -void InitialiseLOTarray(int allocMem) +void InitialiseLOTarray(int itemNum) { - if (allocMem) - { - BaddieSlots.clear(); - BaddieSlots.resize(NUM_SLOTS); + ITEM_INFO* item = &g_Level.Items[itemNum]; + + CREATURE_INFO* creature = item->data; + if(!creature->LOT.initialised) { + creature->LOT.node = std::vector(g_Level.Boxes.size(), BOX_NODE{}); + creature->LOT.initialised = true; } - - CREATURE_INFO* creature = BaddieSlots.data(); - for (int i = 0; i < NUM_SLOTS; i++, creature++) - { - creature->itemNum = NO_ITEM; - if (allocMem) - { - creature->LOT.node.clear(); - creature->LOT.node.resize(g_Level.Boxes.size()); - for (int j = 0; j < g_Level.Boxes.size(); j++) - { - creature->LOT.node.emplace_back(BOX_NODE()); - } - } - } - - SlotsUsed = 0; + } int EnableBaddieAI(short itemNum, int always) { ITEM_INFO* item = &g_Level.Items[itemNum]; - if (item->data != NULL) + if (item->data.is()) return true; + + + /* if (SlotsUsed >= NUM_SLOTS) { int cameraDistance = 0; @@ -57,9 +46,11 @@ int EnableBaddieAI(short itemNum, int always) } int slotToDisable = -1; - CREATURE_INFO* creature = BaddieSlots.data(); - for (int slot = 0; slot < NUM_SLOTS; slot++, creature++) + + + for (int slot = 0; slot < ActiveCreatures.size(); slot++) { + CREATURE_INFO* creature = ActiveCreatures[slot]; item = &g_Level.Items[creature->itemNum]; int deltaX = (item->pos.xPos - Camera.pos.x) >> 8; @@ -77,17 +68,18 @@ int EnableBaddieAI(short itemNum, int always) if (slotToDisable < 0 || slotToDisable > NUM_SLOTS) return false; - ITEM_INFO* itemToDisable = &g_Level.Items[BaddieSlots[slotToDisable].itemNum]; - CREATURE_INFO* creatureToDisable = &BaddieSlots[slotToDisable]; + ITEM_INFO* itemToDisable = &g_Level.Items[ActiveCreatures[slotToDisable].itemNum]; + CREATURE_INFO* creatureToDisable = &ActiveCreatures[slotToDisable]; itemToDisable->status = ITEM_INVISIBLE; DisableBaddieAI(creatureToDisable->itemNum); InitialiseSlot(itemNum, slotToDisable); return true; } - else + else*/ { - CREATURE_INFO* creature = BaddieSlots.data(); + /* + CREATURE_INFO* creature = ActiveCreatures.data(); for (int slot = 0; slot < NUM_SLOTS; slot++, creature++) { if (creature->itemNum == NO_ITEM) @@ -96,9 +88,12 @@ int EnableBaddieAI(short itemNum, int always) return true; } } + */ + InitialiseSlot(itemNum, 0); + ActiveCreatures.push_back(item->data); } - return false; + return true; } void DisableBaddieAI(short itemNumber) @@ -106,11 +101,13 @@ void DisableBaddieAI(short itemNumber) ITEM_INFO* item = &g_Level.Items[itemNumber]; CREATURE_INFO* creature = (CREATURE_INFO*)item->data; - item->data = NULL; + if (creature) { creature->itemNum = NO_ITEM; - SlotsUsed--; + ActiveCreatures.erase(std::find(ActiveCreatures.begin(), ActiveCreatures.end(), creature)); + item->data = nullptr; + } } @@ -118,9 +115,10 @@ void InitialiseSlot(short itemNum, short slot) { ITEM_INFO* item = &g_Level.Items[itemNum]; OBJECT_INFO* obj = &Objects[item->objectNumber]; - CREATURE_INFO* creature = &BaddieSlots[slot]; - item->data = creature; + item->data = CREATURE_INFO(); + CREATURE_INFO* creature = item->data; + InitialiseLOTarray(itemNum); creature->itemNum = itemNum; creature->mood = BORED_MOOD; creature->jointRotation[0] = 0; @@ -283,12 +281,11 @@ void ClearLOT(LOT_INFO* LOT) LOT->requiredBox = NO_BOX; BOX_NODE* node = LOT->node.data(); - for (int i = 0; i < g_Level.Boxes.size(); i++) + for(auto& node : LOT->node) { - node->exitBox = NO_BOX; - node->nextExpansion = NO_BOX; - node->searchNumber = 0; - node++; + node.exitBox = NO_BOX; + node.nextExpansion = NO_BOX; + node.searchNumber = 0; } } @@ -297,7 +294,7 @@ void CreateZone(ITEM_INFO* item) CREATURE_INFO* creature = (CREATURE_INFO*)item->data; ROOM_INFO* r = &g_Level.Rooms[item->roomNumber]; - item->boxNumber = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z).box; + item->boxNumber = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z)->box; if (creature->LOT.fly) { diff --git a/TR5Main/Game/lot.h b/TR5Main/Game/lot.h index 1c1fd7e8d..e828e2a3b 100644 --- a/TR5Main/Game/lot.h +++ b/TR5Main/Game/lot.h @@ -1,9 +1,7 @@ #pragma once #include "box.h" -constexpr auto NUM_SLOTS = 32; -extern int SlotsUsed; -extern std::vector BaddieSlots; +extern std::vector ActiveCreatures; void InitialiseLOTarray(int allocMem); int EnableBaddieAI(short itemNum, int always); diff --git a/TR5Main/Game/memory/malloc.cpp b/TR5Main/Game/memory/malloc.cpp deleted file mode 100644 index 9acc0c4c2..000000000 --- a/TR5Main/Game/memory/malloc.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "framework.h" -#include "malloc.h" -#include "door.h" -char* malloc_buffer; -int malloc_size; -char* malloc_ptr; -int malloc_free; -int malloc_used; -void init_game_malloc() noexcept -{ -} - -void game_free(void* ptr) noexcept -{ - - delete[] ptr; -} \ No newline at end of file diff --git a/TR5Main/Game/memory/malloc.h b/TR5Main/Game/memory/malloc.h deleted file mode 100644 index 51c64e42f..000000000 --- a/TR5Main/Game/memory/malloc.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -extern char* malloc_buffer; -extern int malloc_size; -extern char* malloc_ptr; -extern int malloc_free; -extern int malloc_used; - -template -T* game_malloc(size_t count = 1,Args&&...args) noexcept { - - return new T[count]{std::forward(args)...}; -} -void init_game_malloc() noexcept; -void game_free(void* ptr) noexcept; \ No newline at end of file diff --git a/TR5Main/Game/misc.cpp b/TR5Main/Game/misc.cpp index e8fc614ad..e48842473 100644 --- a/TR5Main/Game/misc.cpp +++ b/TR5Main/Game/misc.cpp @@ -4,6 +4,7 @@ #include "level.h" #include "lara.h" #include "draw.h" +#include "creature_info.h" using std::vector; short GF(short animIndex, short frameToStart) { diff --git a/TR5Main/Game/missile.cpp b/TR5Main/Game/missile.cpp index 1a9b4ff00..18b028cb4 100644 --- a/TR5Main/Game/missile.cpp +++ b/TR5Main/Game/missile.cpp @@ -8,7 +8,7 @@ #include "level.h" #include "setup.h" #include "lara.h" - +#include "collide.h" #define SHARD_DAMAGE 30 #define ROCKET_DAMAGE 100 #define DIVER_HARPOON_DAMAGE 50 diff --git a/TR5Main/Game/newinv2.cpp b/TR5Main/Game/newinv2.cpp index 709028809..8a733245e 100644 --- a/TR5Main/Game/newinv2.cpp +++ b/TR5Main/Game/newinv2.cpp @@ -17,6 +17,7 @@ #include "level.h" #include "input.h" #include "pickup\pickup.h" +#include "Renderer11.h" using namespace TEN::Renderer; bool goUp, goDown, goRight, goLeft, goSelect, goDeselect; @@ -4258,4 +4259,4 @@ int do_special_waterskin_combine_bullshit(int flag) return 0; } -#endif \ No newline at end of file +#endif diff --git a/TR5Main/Game/objects.cpp b/TR5Main/Game/objects.cpp index 0ac223c3c..79aecf933 100644 --- a/TR5Main/Game/objects.cpp +++ b/TR5Main/Game/objects.cpp @@ -14,6 +14,7 @@ #include "level.h" #include "input.h" #include "Sound\sound.h" +#include "collide.h" OBJECT_TEXTURE* WaterfallTextures[6]; float WaterfallY[6]; diff --git a/TR5Main/Game/objects.h b/TR5Main/Game/objects.h index c07c1d797..ecd0ba953 100644 --- a/TR5Main/Game/objects.h +++ b/TR5Main/Game/objects.h @@ -1,7 +1,8 @@ #pragma once -#include "collide.h" - +struct ITEM_INFO; +struct COLL_INFO; +struct OBJECT_TEXTURE; extern OBJECT_TEXTURE* WaterfallTextures[6]; extern float WaterfallY[6]; diff --git a/TR5Main/Game/people.cpp b/TR5Main/Game/people.cpp index 5686a529a..13f22e9ab 100644 --- a/TR5Main/Game/people.cpp +++ b/TR5Main/Game/people.cpp @@ -7,6 +7,7 @@ #include "effects\debris.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotation, int damage) { diff --git a/TR5Main/Game/pickup/pickup.h b/TR5Main/Game/pickup/pickup.h index d594d8eb3..ec873fae9 100644 --- a/TR5Main/Game/pickup/pickup.h +++ b/TR5Main/Game/pickup/pickup.h @@ -1,7 +1,9 @@ #pragma once -#include "collide.h" - +struct ITEM_INFO; +struct COLL_INFO; +struct PHD_VECTOR; +struct BOUNDING_BOX; enum GAME_OBJECT_ID : short; extern int NumRPickups; diff --git a/TR5Main/Game/puzzles_keys.cpp b/TR5Main/Game/puzzles_keys.cpp index 24ce4c0fa..dd9f2d856 100644 --- a/TR5Main/Game/puzzles_keys.cpp +++ b/TR5Main/Game/puzzles_keys.cpp @@ -13,7 +13,8 @@ #include "control.h" #include "puzzles_keys.h" #include "generic_switch.h" - +#include "camera.h" +#include "control.h" using namespace TEN::Entities::Switches; enum PuzzleType { diff --git a/TR5Main/Game/puzzles_keys.h b/TR5Main/Game/puzzles_keys.h index 96ca20098..f94a754f0 100644 --- a/TR5Main/Game/puzzles_keys.h +++ b/TR5Main/Game/puzzles_keys.h @@ -1,6 +1,7 @@ #pragma once -#include "collide.h" +struct ITEM_INFO; +struct COLL_INFO; /*puzzles*/ void PuzzleHoleCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); void PuzzleDoneCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); diff --git a/TR5Main/Game/roomvector.h b/TR5Main/Game/roomvector.h new file mode 100644 index 000000000..ca9026480 --- /dev/null +++ b/TR5Main/Game/roomvector.h @@ -0,0 +1,5 @@ +#pragma once +struct ROOM_VECTOR { + int roomNumber; + int yNumber; +}; \ No newline at end of file diff --git a/TR5Main/Game/rope.cpp b/TR5Main/Game/rope.cpp index 24e9e5ebd..cafa21e8e 100644 --- a/TR5Main/Game/rope.cpp +++ b/TR5Main/Game/rope.cpp @@ -6,6 +6,7 @@ #include "input.h" #include "control.h" #include "Sound\sound.h" +#include "camera.h" PENDULUM CurrentPendulum; PENDULUM AlternatePendulum; diff --git a/TR5Main/Game/savegame.cpp b/TR5Main/Game/savegame.cpp index 98905fdeb..1aa0d54fb 100644 --- a/TR5Main/Game/savegame.cpp +++ b/TR5Main/Game/savegame.cpp @@ -18,7 +18,8 @@ #include "tr5_spider_emitter.h" #include "generic_switch.h" #include "fullblock_switch.h" - +#include "creature_info.h" +#include "quad_info.h" using namespace TEN::Entities::Switches; using std::string; @@ -996,7 +997,7 @@ bool SaveGame::readItemChunks(ChunkId* chunkId, int maxSize, int itemNumber) creature->mood = (MOOD_TYPE)LEB128::ReadInt32(m_stream); ITEM_INFO* enemy = (ITEM_INFO*)LEB128::ReadLong(m_stream); - creature->enemy = AddPtr(enemy, ITEM_INFO, malloc_buffer); + //creature->enemy = AddPtr(enemy, ITEM_INFO, malloc_buffer); creature->aiTarget.objectNumber = from_underlying(LEB128::ReadInt16(m_stream)); creature->aiTarget.roomNumber = LEB128::ReadInt16(m_stream); @@ -1019,10 +1020,10 @@ bool SaveGame::readItemChunks(ChunkId* chunkId, int maxSize, int itemNumber) } else if (chunkId->EqualsTo(m_chunkItemQuadInfo.get())) { - QUAD_INFO* quadInfo = game_malloc(); - m_stream->ReadBytes(reinterpret_cast(quadInfo), sizeof(QUAD_INFO)); - if (item->objectNumber == ID_QUAD) - item->data = (void*)quadInfo; + //QUAD_INFO* quadInfo = game_malloc(); + //m_stream->ReadBytes(reinterpret_cast(quadInfo), sizeof(QUAD_INFO)); + //if (item->objectNumber == ID_QUAD) + // item->data = quadInfo; return true; } @@ -1107,7 +1108,7 @@ void SaveGame::saveItemIntelligentData(int arg1, int arg2) OBJECT_INFO* obj = &Objects[item->objectNumber]; CREATURE_INFO* creature = (CREATURE_INFO*)item->data; - ITEM_INFO* enemy = (ITEM_INFO*)((char*)creature->enemy - (ptrdiff_t)malloc_buffer); + ITEM_INFO* enemy = (ITEM_INFO*)((char*)creature->enemy); LEB128::Write(m_stream, creature->jointRotation[0]); LEB128::Write(m_stream, creature->jointRotation[1]); @@ -1418,7 +1419,7 @@ bool SaveGame::readFlare() AddActiveItem(itemNumber); // Flare age - item->data = (void*)LEB128::ReadInt32(m_stream); + item->data = LEB128::ReadInt32(m_stream); return true; } @@ -1465,7 +1466,8 @@ bool SaveGame::readTorpedo() void SaveGame::saveItemQuadInfo(int itemNumber, int arg2) { - m_stream->WriteBytes(reinterpret_cast(g_Level.Items[itemNumber].data), sizeof(QUAD_INFO)); + + //m_stream->WriteBytes(reinterpret_cast(g_Level.Items[itemNumber].data), sizeof(QUAD_INFO)); } void SaveGame::saveRats(int arg1, int arg2) diff --git a/TR5Main/Game/switch.h b/TR5Main/Game/switch.h index 3a796fb48..15b5677c9 100644 --- a/TR5Main/Game/switch.h +++ b/TR5Main/Game/switch.h @@ -1,7 +1,7 @@ #pragma once -#include "collide.h" - +struct COLL_INFO; +struct ITEM_INFO; void ProcessExplodingSwitchType8(ITEM_INFO* item); void InitialiseShootSwitch(short itemNumber); void ShootSwitchCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); diff --git a/TR5Main/Game/traps.h b/TR5Main/Game/traps.h index 97a1a2ea8..1a9914109 100644 --- a/TR5Main/Game/traps.h +++ b/TR5Main/Game/traps.h @@ -1,10 +1,10 @@ #pragma once -#include "collide.h" +struct COLL_INFO; +struct ITEM_INFO; extern ITEM_INFO* WBItem; extern short WBRoom; - void LaraBurn(); void LavaBurn(ITEM_INFO* item); void FlameControl(short fxNumber); diff --git a/TR5Main/Objects/Effects/tr4_bubbles.cpp b/TR5Main/Objects/Effects/tr4_bubbles.cpp index e5229683c..4ed26dd4a 100644 --- a/TR5Main/Objects/Effects/tr4_bubbles.cpp +++ b/TR5Main/Objects/Effects/tr4_bubbles.cpp @@ -10,6 +10,7 @@ #include "lara.h" #include "control.h" #include "tr4_mutant.h" +#include "collide.h" namespace TEN::entities::all { diff --git a/TR5Main/Objects/Effects/tr4_locusts.cpp b/TR5Main/Objects/Effects/tr4_locusts.cpp index 91d580c43..0858907b3 100644 --- a/TR5Main/Objects/Effects/tr4_locusts.cpp +++ b/TR5Main/Objects/Effects/tr4_locusts.cpp @@ -6,6 +6,7 @@ #include "misc.h" #include "lara.h" #include "effects\tomb4fx.h" +#include "collide.h" namespace TEN::Entities::TR4 { LOCUST_INFO Locusts[MAX_LOCUSTS]; diff --git a/TR5Main/Objects/Generic/Object/generic_bridge.h b/TR5Main/Objects/Generic/Object/generic_bridge.h index 6b94a17de..1d113fc8e 100644 --- a/TR5Main/Objects/Generic/Object/generic_bridge.h +++ b/TR5Main/Objects/Generic/Object/generic_bridge.h @@ -1,5 +1,6 @@ #pragma once #include "Specific\phd_global.h" +#include "level.h" void InitialiseBridge(short itemNumber); int GetOffset(short angle, int x, int z); diff --git a/TR5Main/Objects/Generic/Object/generic_trapdoor.cpp b/TR5Main/Objects/Generic/Object/generic_trapdoor.cpp index 86b35d962..feca0895c 100644 --- a/TR5Main/Objects/Generic/Object/generic_trapdoor.cpp +++ b/TR5Main/Objects/Generic/Object/generic_trapdoor.cpp @@ -2,7 +2,9 @@ #include "generic_trapdoor.h" #include "lara.h" #include "input.h" - +#include "camera.h" +#include "control.h" +#include "level.h" OBJECT_COLLISION_BOUNDS CeilingTrapDoorBounds = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820}; static PHD_VECTOR CeilingTrapDoorPos = {0, 1056, -480}; OBJECT_COLLISION_BOUNDS FloorTrapDoorBounds = {-256, 256, 0, 0, -1024, -256, -1820, 1820, -5460, 5460, -1820, 1820}; diff --git a/TR5Main/Objects/Generic/Switches/cog_switch.cpp b/TR5Main/Objects/Generic/Switches/cog_switch.cpp index dbb5b8bde..b116cbd45 100644 --- a/TR5Main/Objects/Generic/Switches/cog_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/cog_switch.cpp @@ -4,8 +4,8 @@ #include "input.h" #include "lara.h" #include "generic_switch.h" -#include "door.h" - +#include "door_data.h" +#include "Box.h" namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS CogSwitchBounds = diff --git a/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp b/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp index 390de7a8e..f27d38c00 100644 --- a/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp @@ -7,6 +7,7 @@ #include "newinv2.h" #include "Sound\sound.h" #include "pickup\pickup.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp b/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp index 3c2156179..fdd0ef9d5 100644 --- a/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp @@ -4,7 +4,9 @@ #include "input.h" #include "lara.h" #include "generic_switch.h" - +#include "setup.h" +#include "collide.h" +#include "level.h" namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS FullBlockSwitchBounds = diff --git a/TR5Main/Objects/Generic/Switches/fullblock_switch.h b/TR5Main/Objects/Generic/Switches/fullblock_switch.h index 6dcc4d9b8..1836fa211 100644 --- a/TR5Main/Objects/Generic/Switches/fullblock_switch.h +++ b/TR5Main/Objects/Generic/Switches/fullblock_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/generic_switch.cpp b/TR5Main/Objects/Generic/Switches/generic_switch.cpp index a80d1e897..31a4fa0ab 100644 --- a/TR5Main/Objects/Generic/Switches/generic_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/generic_switch.cpp @@ -5,7 +5,8 @@ #include "generic_switch.h" #include "sphere.h" #include "draw.h" - +#include "collide.h" +#include "floordata.h" namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS SwitchBounds = diff --git a/TR5Main/Objects/Generic/Switches/generic_switch.h b/TR5Main/Objects/Generic/Switches/generic_switch.h index 57d701b1b..c68696d92 100644 --- a/TR5Main/Objects/Generic/Switches/generic_switch.h +++ b/TR5Main/Objects/Generic/Switches/generic_switch.h @@ -1,8 +1,8 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { enum SwitchStatus diff --git a/TR5Main/Objects/Generic/Switches/jump_switch.cpp b/TR5Main/Objects/Generic/Switches/jump_switch.cpp index 0b4d83008..9e5e8fefe 100644 --- a/TR5Main/Objects/Generic/Switches/jump_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/jump_switch.cpp @@ -4,6 +4,7 @@ #include "input.h" #include "lara.h" #include "generic_switch.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/pulley_switch.cpp b/TR5Main/Objects/Generic/Switches/pulley_switch.cpp index 393d01efa..e9b2c42bd 100644 --- a/TR5Main/Objects/Generic/Switches/pulley_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/pulley_switch.cpp @@ -6,6 +6,7 @@ #include "generic_switch.h" #include "Sound\sound.h" #include "pickup\pickup.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/rail_switch.cpp b/TR5Main/Objects/Generic/Switches/rail_switch.cpp index fd43a56ba..43cd81846 100644 --- a/TR5Main/Objects/Generic/Switches/rail_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/rail_switch.cpp @@ -4,6 +4,7 @@ #include "input.h" #include "lara.h" #include "generic_switch.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/turn_switch.cpp b/TR5Main/Objects/Generic/Switches/turn_switch.cpp index 82a5f36de..4723f0069 100644 --- a/TR5Main/Objects/Generic/Switches/turn_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/turn_switch.cpp @@ -7,6 +7,9 @@ #include "door.h" #include "Sound\sound.h" #include "switch.h" +#include "setup.h" +#include "camera.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/underwater_switch.cpp b/TR5Main/Objects/Generic/Switches/underwater_switch.cpp index 4397f8838..9e246db4e 100644 --- a/TR5Main/Objects/Generic/Switches/underwater_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/underwater_switch.cpp @@ -6,6 +6,9 @@ #include "newinv2.h" #include "Sound\sound.h" #include "generic_switch.h" +#include "camera.h" +#include "collide.h" +#include "level.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/TR1/Entity/tr1_bear.cpp b/TR5Main/Objects/TR1/Entity/tr1_bear.cpp index f92306319..0a5aa6120 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_bear.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_bear.cpp @@ -6,6 +6,8 @@ #include "level.h" #include "control.h" #include "lara.h" +#include "creature_info.h" +#include "control.h" BITE_INFO bearBite = { 0, 96, 335, 14 }; diff --git a/TR5Main/Objects/TR1/Entity/tr1_centaur.cpp b/TR5Main/Objects/TR1/Entity/tr1_centaur.cpp index 90c853fd4..ab6ecdcb5 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_centaur.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_centaur.cpp @@ -11,6 +11,9 @@ #include "lara_one_gun.h" #include "effects\effects.h" #include "draw.h" +#include "collide.h" +#include "item.h" +#include "setup.h" enum centaur_anims { CENTAUR_EMPTY, diff --git a/TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp b/TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp index dd6bb7fe7..d61404098 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp @@ -107,7 +107,7 @@ void DoppelgangerControl(short itemNum) item->gravityStatus = true; item->fallspeed = 0; item->speed = 0; - item->data = (void*)-1; + item->data = -1; item->pos.yPos += 50; } } diff --git a/TR5Main/Objects/TR1/Entity/tr1_giant_mutant.cpp b/TR5Main/Objects/TR1/Entity/tr1_giant_mutant.cpp index 135a2890e..fdf1515e7 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_giant_mutant.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_giant_mutant.cpp @@ -8,6 +8,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" enum abortion_anims { ABORT_EMPTY, ABORT_STOP, ABORT_TURNL, ABORT_TURNR, ABORT_ATTACK1, ABORT_ATTACK2, diff --git a/TR5Main/Objects/TR1/Entity/tr1_natla.cpp b/TR5Main/Objects/TR1/Entity/tr1_natla.cpp index 9cd38b2bc..5bd44d594 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_natla.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_natla.cpp @@ -8,6 +8,7 @@ #include "Sound\sound.h" #include "effects\effects.h" #include "Specific\trmath.h" +#include "creature_info.h" #define NATLA_NEAR_DEATH 200 diff --git a/TR5Main/Objects/TR1/Entity/tr1_wolf.cpp b/TR5Main/Objects/TR1/Entity/tr1_wolf.cpp index 56df8d415..2ab0bdd14 100644 --- a/TR5Main/Objects/TR1/Entity/tr1_wolf.cpp +++ b/TR5Main/Objects/TR1/Entity/tr1_wolf.cpp @@ -7,7 +7,8 @@ #include "setup.h" #include "control.h" #include "level.h" - +#include "creature_info.h" +#include "control.h" BITE_INFO wolfBite = { 0, -14, 174, 6 }; enum wolfStates { diff --git a/TR5Main/Objects/TR1/tr1_objects.cpp b/TR5Main/Objects/TR1/tr1_objects.cpp index 6b5179338..6a80fda68 100644 --- a/TR5Main/Objects/TR1/tr1_objects.cpp +++ b/TR5Main/Objects/TR1/tr1_objects.cpp @@ -19,6 +19,7 @@ #include "setup.h" #include "level.h" #include "object_helper.h" +#include "creature_info.h" static void StartBaddy(OBJECT_INFO* obj) { diff --git a/TR5Main/Objects/TR2/Entity/tr2_barracuda.cpp b/TR5Main/Objects/TR2/Entity/tr2_barracuda.cpp index bd799d2b5..8ad5e2806 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_barracuda.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_barracuda.cpp @@ -5,7 +5,7 @@ #include "lara.h" #include "setup.h" #include "level.h" - +#include "creature_info.h" BITE_INFO barracudaBite = { 2, -60, 121, 7 }; void BarracudaControl(short itemNum) diff --git a/TR5Main/Objects/TR2/Entity/tr2_dragon.cpp b/TR5Main/Objects/TR2/Entity/tr2_dragon.cpp index 674ca80b6..e6ed7b9d4 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_dragon.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_dragon.cpp @@ -12,7 +12,7 @@ #include "setup.h" #include "input.h" #include "Sound\sound.h" - +#include "creature_info.h" #define DRAGON_SWIPE_DAMAGE 250 #define DRAGON_TOUCH_DAMAGE 10 @@ -478,7 +478,7 @@ void InitialiseBartoli(short itemNum) InitialiseItem(back_item); back->meshBits = 0x1FFFFF; - item->data = (void*)back_item; + item->data = back_item; front = &g_Level.Items[front_item]; front->objectNumber = ID_DRAGON_FRONT; @@ -492,7 +492,7 @@ void InitialiseBartoli(short itemNum) InitialiseItem(front_item); - back->data = (void*)front_item; + back->data = front_item; g_Level.NumItems += 2; } diff --git a/TR5Main/Objects/TR2/Entity/tr2_eagle_or_crow.cpp b/TR5Main/Objects/TR2/Entity/tr2_eagle_or_crow.cpp index efdc28234..e8f05f7ed 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_eagle_or_crow.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_eagle_or_crow.cpp @@ -6,6 +6,7 @@ #include "items.h" #include "setup.h" #include "level.h" +#include "creature_info.h" BITE_INFO eagleBite = { 15, 46, 21, 6 }; BITE_INFO crowBite = { 2, 10, 60, 14 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_knifethrower.cpp b/TR5Main/Objects/TR2/Entity/tr2_knifethrower.cpp index 3c2446ea5..bfb2b2dbf 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_knifethrower.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_knifethrower.cpp @@ -8,6 +8,9 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" +#include "floordata.h" +#include "collide.h" BITE_INFO knifeLeft = { 0, 0, 0, 5 }; BITE_INFO knifeRight = { 0, 0, 0, 8 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_mercenary.cpp b/TR5Main/Objects/TR2/Entity/tr2_mercenary.cpp index 5935704e5..b1ce381a2 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_mercenary.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_mercenary.cpp @@ -6,6 +6,7 @@ #include "level.h" #include "control.h" #include "Specific\trmath.h" +#include "creature_info.h" BITE_INFO mercUziBite = { 0, 150, 19, 17 }; BITE_INFO mercAutoPistolBite = { 0, 230, 9, 17 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_monk.cpp b/TR5Main/Objects/TR2/Entity/tr2_monk.cpp index 9c44e96a3..21c6d52e3 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_monk.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_monk.cpp @@ -6,7 +6,7 @@ #include "Sound\sound.h" #include "setup.h" #include "level.h" - +#include "creature_info.h" BITE_INFO monkBite = { -23,16,265, 14 }; extern bool MonksAttackLara; diff --git a/TR5Main/Objects/TR2/Entity/tr2_rat.cpp b/TR5Main/Objects/TR2/Entity/tr2_rat.cpp index 16b717c29..11fd2ad7c 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_rat.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_rat.cpp @@ -6,6 +6,8 @@ #include "setup.h" #include "control.h" #include "level.h" +#include "creature_info.h" +#include "control.h" BITE_INFO ratBite = { 0, 0, 57, 2 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_silencer.cpp b/TR5Main/Objects/TR2/Entity/tr2_silencer.cpp index 60199758e..02faf671e 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_silencer.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_silencer.cpp @@ -5,7 +5,7 @@ #include "setup.h" #include "level.h" #include "control.h" - +#include "creature_info.h" BITE_INFO silencerGun = { 3, 331, 56, 10 }; void SilencerControl(short itemNum) diff --git a/TR5Main/Objects/TR2/Entity/tr2_skidman.cpp b/TR5Main/Objects/TR2/Entity/tr2_skidman.cpp index cc2702216..101c8438b 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_skidman.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_skidman.cpp @@ -11,7 +11,8 @@ #include "level.h" #include "Sound\sound.h" #include "snowmobile.h" - +#include "creature_info.h" +#include "skidoo_info.h" enum SKIDMAN_STATE { SMAN_EMPTY, SMAN_WAIT, SMAN_MOVING, SMAN_STARTLEFT, SMAN_STARTRIGHT, SMAN_LEFT, SMAN_RIGHT, SMAN_DEATH }; #define SMAN_MIN_TURN (ANGLE(6.0f)/3) @@ -44,7 +45,7 @@ void InitialiseSkidman(short itemNum) InitialiseItem(skidoo_item); // The skidman remembers his skidoo - item->data = (void*)skidoo_item; + item->data = skidoo_item; g_Level.NumItems++; } diff --git a/TR5Main/Objects/TR2/Entity/tr2_spear_guardian.cpp b/TR5Main/Objects/TR2/Entity/tr2_spear_guardian.cpp index e357dae18..eb2381b8d 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_spear_guardian.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_spear_guardian.cpp @@ -7,6 +7,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO spearLeftBite = { 0, 0, 920, 11 }; BITE_INFO spearRightBite = { 0, 0, 920, 18 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_spider.cpp b/TR5Main/Objects/TR2/Entity/tr2_spider.cpp index 4f817c791..5b515a899 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_spider.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_spider.cpp @@ -9,6 +9,7 @@ #include "setup.h" #include "effects\tomb4fx.h" #include "level.h" +#include "creature_info.h" #include "control.h" BITE_INFO spiderBite = { 0, 0, 41, 1 }; @@ -249,4 +250,4 @@ void BigSpiderControl(short itemNum) } CreatureAnimation(itemNum, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR2/Entity/tr2_sword_guardian.cpp b/TR5Main/Objects/TR2/Entity/tr2_sword_guardian.cpp index 46377fc06..e767758c0 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_sword_guardian.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_sword_guardian.cpp @@ -8,6 +8,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO swordBite = { 0, 37, 550, 15 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_worker_dualrevolver.cpp b/TR5Main/Objects/TR2/Entity/tr2_worker_dualrevolver.cpp index ce7e60b97..ad8213387 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_worker_dualrevolver.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_worker_dualrevolver.cpp @@ -5,6 +5,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" BITE_INFO workerDualGunL = { -2, 275, 23, 6 }; BITE_INFO workerDualGunR = { 2, 275, 23, 10 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_worker_flamethrower.cpp b/TR5Main/Objects/TR2/Entity/tr2_worker_flamethrower.cpp index 4792d4390..6da1be912 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_worker_flamethrower.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_worker_flamethrower.cpp @@ -11,6 +11,8 @@ #include "control.h" #include "effects\effects.h" #include "Specific\trmath.h" +#include "creature_info.h" +#include "control.h" BITE_INFO workerFlameThrower = { 0, 250, 32, 9 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_worker_machinegun.cpp b/TR5Main/Objects/TR2/Entity/tr2_worker_machinegun.cpp index 6edec8f66..155924edd 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_worker_machinegun.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_worker_machinegun.cpp @@ -6,6 +6,7 @@ #include "setup.h" #include "level.h" #include "control.h" +#include "creature_info.h" BITE_INFO workerMachineGun = { 0, 308, 32, 9 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_worker_shotgun.cpp b/TR5Main/Objects/TR2/Entity/tr2_worker_shotgun.cpp index 0e9bba209..85cd62af8 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_worker_shotgun.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_worker_shotgun.cpp @@ -6,6 +6,7 @@ #include "setup.h" #include "level.h" #include "control.h" +#include "creature_info.h" BITE_INFO workerShotgun = { 0, 281, 40, 9 }; diff --git a/TR5Main/Objects/TR2/Entity/tr2_yeti.cpp b/TR5Main/Objects/TR2/Entity/tr2_yeti.cpp index e8bf6bade..a0867aa6b 100644 --- a/TR5Main/Objects/TR2/Entity/tr2_yeti.cpp +++ b/TR5Main/Objects/TR2/Entity/tr2_yeti.cpp @@ -6,6 +6,7 @@ #include "lara.h" #include "setup.h" #include "level.h" +#include "creature_info.h" #include "control.h" BITE_INFO yetiBiteR = { 12, 101, 19, 10 }; @@ -317,4 +318,4 @@ void YetiControl(short itemNum) { CreatureAnimation(itemNum, angle, tilt); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR2/Vehicles/boat.cpp b/TR5Main/Objects/TR2/Vehicles/boat.cpp index befdfea23..d24e1e51b 100644 --- a/TR5Main/Objects/TR2/Vehicles/boat.cpp +++ b/TR5Main/Objects/TR2/Vehicles/boat.cpp @@ -9,22 +9,9 @@ #include "level.h" #include "input.h" #include "Sound\sound.h" -#include -#include - - - -struct BOAT_INFO -{ - int boatTurn; - int leftFallspeed; - int rightFallspeed; - int water; - int pitch; - short tiltAngle; - short extraRotation; - short propRot; -}; +#include "effects\effects.h" +#include "particle\SimpleParticle.h" +#include "boat_info.h" enum BOAT_STATE { @@ -506,7 +493,7 @@ int SpeedBoatDynamics(short itemNum) int newspeed; boat = &g_Level.Items[itemNum]; - binfo = (BOAT_INFO*)boat->data; + binfo = boat->data; boat->pos.zRot -= binfo->tiltAngle; @@ -826,8 +813,8 @@ void InitialiseSpeedBoat(short itemNum) BOAT_INFO* binfo; boat = &g_Level.Items[itemNum]; - binfo = game_malloc(); - boat->data = (void*)binfo; + boat->data = BOAT_INFO(); + binfo = boat->data; binfo->boatTurn = 0; binfo->leftFallspeed = 0; binfo->rightFallspeed = 0; diff --git a/TR5Main/Objects/TR2/Vehicles/boat_info.h b/TR5Main/Objects/TR2/Vehicles/boat_info.h new file mode 100644 index 000000000..432aba12f --- /dev/null +++ b/TR5Main/Objects/TR2/Vehicles/boat_info.h @@ -0,0 +1,11 @@ +#pragma once +struct BOAT_INFO { + int boatTurn; + int leftFallspeed; + int rightFallspeed; + int water; + int pitch; + short tiltAngle; + short extraRotation; + short propRot; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR2/Vehicles/skidoo_info.h b/TR5Main/Objects/TR2/Vehicles/skidoo_info.h new file mode 100644 index 000000000..0f4c94b90 --- /dev/null +++ b/TR5Main/Objects/TR2/Vehicles/skidoo_info.h @@ -0,0 +1,13 @@ +#pragma once +struct SKIDOO_INFO { + short trackMesh; + int skidooTurn; + int leftFallspeed; + int rightFallspeed; + short momentumAngle; + short extraRotation; + int pitch; + bool alreadyCdPlayed; + bool armed; + int flashTimer; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR2/Vehicles/snowmobile.cpp b/TR5Main/Objects/TR2/Vehicles/snowmobile.cpp index fcafa9bc9..64e1f3ccd 100644 --- a/TR5Main/Objects/TR2/Vehicles/snowmobile.cpp +++ b/TR5Main/Objects/TR2/Vehicles/snowmobile.cpp @@ -14,8 +14,10 @@ #include "level.h" #include "input.h" #include "Sound\sound.h" -#include +#include "particle\SimpleParticle.h" #include "Specific\prng.h" +#include "camera.h" +#include "skidoo_info.h" using std::vector; using namespace TEN::Math::Random; @@ -77,9 +79,8 @@ enum SKIDOO_STATE void InitialiseSkidoo(short itemNum) { ITEM_INFO* skidoo = &g_Level.Items[itemNum]; - - SKIDOO_INFO* skinfo = game_malloc(); - skidoo->data = (void*)skinfo; + skidoo->data = SKIDOO_INFO(); + SKIDOO_INFO* skinfo = skidoo->data; skinfo->alreadyCdPlayed = false; diff --git a/TR5Main/Objects/TR2/Vehicles/snowmobile.h b/TR5Main/Objects/TR2/Vehicles/snowmobile.h index 28c7c7ddb..9d1cc704d 100644 --- a/TR5Main/Objects/TR2/Vehicles/snowmobile.h +++ b/TR5Main/Objects/TR2/Vehicles/snowmobile.h @@ -2,19 +2,7 @@ #include "items.h" #include "collide.h" -struct SKIDOO_INFO -{ - short trackMesh; - int skidooTurn; - int leftFallspeed; - int rightFallspeed; - short momentumAngle; - short extraRotation; - int pitch; - bool alreadyCdPlayed; - bool armed; - int flashTimer; -}; + void InitialiseSkidoo(short itemNum); void SkidooCollision(short itemNum, ITEM_INFO* litem, COLL_INFO* coll); diff --git a/TR5Main/Objects/TR2/tr2_objects.cpp b/TR5Main/Objects/TR2/tr2_objects.cpp index d02b0a7e5..9462a15a0 100644 --- a/TR5Main/Objects/TR2/tr2_objects.cpp +++ b/TR5Main/Objects/TR2/tr2_objects.cpp @@ -34,6 +34,7 @@ #include "box.h" #include "setup.h" #include "level.h" +#include "creature_info.h" static void StartBaddy(OBJECT_INFO* obj) { diff --git a/TR5Main/Objects/TR3/Entity/tr3_civvy.cpp b/TR5Main/Objects/TR3/Entity/tr3_civvy.cpp index 086cbc62e..c08edaaff 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_civvy.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_civvy.cpp @@ -7,6 +7,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO civvy_hit = { 0,0,0, 13 }; diff --git a/TR5Main/Objects/TR3/Entity/tr3_cobra.cpp b/TR5Main/Objects/TR3/Entity/tr3_cobra.cpp index aa61c6311..c9eaafb4b 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_cobra.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_cobra.cpp @@ -6,6 +6,7 @@ #include "lara.h" #include "setup.h" #include "level.h" +#include "creature_info.h" BITE_INFO cobraBite = { 0, 0, 0, 13 }; diff --git a/TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp b/TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp index f6188b73b..a9aeaf339 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp @@ -1,11 +1,11 @@ #include "framework.h" #include "tr3_fishemitter.h" -#include "effects\effects.h" #include "draw.h" #include "level.h" #include "lara.h" #include "fish.h" #include "control.h" +#include "effects\effects.h" #define PIRAHNA_DAMAGE 4 #define X 0 diff --git a/TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp b/TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp index 842a9d252..f1d2d6e7c 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp @@ -11,6 +11,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO flamerBite = { 0, 340, 64, 7 }; @@ -256,11 +257,11 @@ void FlameThrowerControl(short itemNumber) creature->enemy = NULL; int minDistance = 0x7FFFFFFF; - CREATURE_INFO* currentCreature = BaddieSlots.data(); ITEM_INFO* target = NULL; - for (int i = 0; i < NUM_SLOTS; i++, currentCreature++) + for (int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* currentCreature = ActiveCreatures[i]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNumber) continue; diff --git a/TR5Main/Objects/TR3/Entity/tr3_monkey.cpp b/TR5Main/Objects/TR3/Entity/tr3_monkey.cpp index 0e635aa2c..528ae105a 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_monkey.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_monkey.cpp @@ -7,6 +7,7 @@ #include "setup.h" #include "lot.h" #include "level.h" +#include "creature_info.h" #include "control.h" BITE_INFO monkeyBite = { 10, 10, 11, 13 }; @@ -62,10 +63,11 @@ void MonkeyControl(short itemNumber) { int minDistance = 0x7FFFFFFF; creature->enemy = NULL; - CREATURE_INFO* currentCreature = BaddieSlots.data(); + - for (int i = 0; i < NUM_SLOTS; i++, currentCreature++) + for (int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* currentCreature = ActiveCreatures[i]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNumber) continue; @@ -291,9 +293,10 @@ void MonkeyControl(short itemNumber) creature->enemy->roomNumber = NO_ROOM; creature->enemy->carriedItem = NO_ITEM; - CREATURE_INFO* currentCreature = BaddieSlots.data(); - for (int i = 0; i < NUM_SLOTS; i++, currentCreature++) + + for (int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* currentCreature = ActiveCreatures[i]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNumber) continue; @@ -581,4 +584,4 @@ void MonkeyControl(short itemNumber) creature->maximumTurn = 0; CreatureAnimation(itemNumber, angle, tilt); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR3/Entity/tr3_mpgun.cpp b/TR5Main/Objects/TR3/Entity/tr3_mpgun.cpp index 559fe1ec4..4852ee07d 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_mpgun.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_mpgun.cpp @@ -9,6 +9,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" enum MPGUN_STATES { @@ -115,9 +116,9 @@ void MPGunControl(short itemNumber) laraInfo.distance = SQUARE(dx) + SQUARE(dx); - CREATURE_INFO* currentCreature = BaddieSlots.data(); - for (int slot = 0; slot < NUM_SLOTS; slot++, currentCreature++) + for (int slot = 0; slot < ActiveCreatures.size(); slot++) { + CREATURE_INFO* currentCreature = ActiveCreatures[slot]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNumber) continue; diff --git a/TR5Main/Objects/TR3/Entity/tr3_mpstick.cpp b/TR5Main/Objects/TR3/Entity/tr3_mpstick.cpp index 2b31ffdcf..5daf15312 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_mpstick.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_mpstick.cpp @@ -9,6 +9,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO mpstickBite1 = { 247, 10, 11, 13 }; BITE_INFO mpstickBite2 = { 0, 0, 100, 6 }; @@ -96,9 +97,9 @@ void MPStickControl(short itemNumber) laraInfo.distance = SQUARE(dx) + SQUARE(dx); int bestDistance = 0x7fffffff; - CREATURE_INFO* currentCreature = BaddieSlots.data(); - for (int slot = 0; slot < NUM_SLOTS; slot++, currentCreature++) + for (int slot = 0; slot < ActiveCreatures.size(); slot++) { + CREATURE_INFO* currentCreature = ActiveCreatures[slot]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNumber) continue; diff --git a/TR5Main/Objects/TR3/Entity/tr3_raptor.cpp b/TR5Main/Objects/TR3/Entity/tr3_raptor.cpp index 45ab7ee0a..13e9aa5b4 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_raptor.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_raptor.cpp @@ -6,6 +6,7 @@ #include "lot.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" static BITE_INFO raptorBite = { 0, 66, 318, 22 }; @@ -40,10 +41,10 @@ void RaptorControl(short itemNum) { if (creature->enemy == NULL || !(GetRandomControl() & 0x7F)) { - CREATURE_INFO* currentCreature = BaddieSlots.data(); ITEM_INFO* target = NULL; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* currentCreature = ActiveCreatures[i]; if (currentCreature->itemNum == NO_ITEM || currentCreature->itemNum == itemNum) { currentCreature++; @@ -286,4 +287,4 @@ void RaptorControl(short itemNum) CreatureJoint(item, 2, neck); CreatureJoint(item, 3, neck); CreatureAnimation(itemNum, angle, tilt); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR3/Entity/tr3_scuba.cpp b/TR5Main/Objects/TR3/Entity/tr3_scuba.cpp index 46250c278..18512cff7 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_scuba.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_scuba.cpp @@ -1,12 +1,13 @@ #include "framework.h" #include "tr3_scuba.h" #include "items.h" -#include "effects\effects.h" #include "box.h" #include "lara.h" #include "setup.h" #include "level.h" +#include "creature_info.h" #include "control.h" +#include "effects\effects.h" BITE_INFO scubaGun = { 17, 164, 44, 18 }; diff --git a/TR5Main/Objects/TR3/Entity/tr3_shiva.cpp b/TR5Main/Objects/TR3/Entity/tr3_shiva.cpp index 8fe6eeba4..af657f987 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_shiva.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_shiva.cpp @@ -8,6 +8,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO shivaLeftBite = { 0, 0, 920, 13 }; BITE_INFO shivaRightBite = { 0, 0, 920, 22 }; diff --git a/TR5Main/Objects/TR3/Entity/tr3_tiger.cpp b/TR5Main/Objects/TR3/Entity/tr3_tiger.cpp index 90676e58a..ab56daa6f 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_tiger.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_tiger.cpp @@ -6,6 +6,8 @@ #include "level.h" #include "control.h" #include "lara.h" +#include "creature_info.h" +#include "control.h" BITE_INFO tigerBite = { 19, -13, 3, 26 }; diff --git a/TR5Main/Objects/TR3/Entity/tr3_tony.cpp b/TR5Main/Objects/TR3/Entity/tr3_tony.cpp index 46dc4b473..38af4719d 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_tony.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_tony.cpp @@ -12,6 +12,8 @@ #include "lara.h" #include "traps.h" #include "Sound\sound.h" +#include "creature_info.h" +#include "collide.h" enum TonyFlameType { diff --git a/TR5Main/Objects/TR3/Entity/tr3_trex.cpp b/TR5Main/Objects/TR3/Entity/tr3_trex.cpp index 9bffe93a2..e8ee2a853 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_trex.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_trex.cpp @@ -6,8 +6,8 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" - void LaraTyrannosaurDeath(ITEM_INFO* item) { item->goalAnimState = 8; diff --git a/TR5Main/Objects/TR3/Entity/tr3_tribesman.cpp b/TR5Main/Objects/TR3/Entity/tr3_tribesman.cpp index a46b0af2f..ef924b167 100644 --- a/TR5Main/Objects/TR3/Entity/tr3_tribesman.cpp +++ b/TR5Main/Objects/TR3/Entity/tr3_tribesman.cpp @@ -10,6 +10,7 @@ #include "draw.h" #include "setup.h" #include "level.h" +#include "creature_info.h" BITE_INFO tribesmanAxeBite = { 0, 16, 265, 13 }; BITE_INFO tribesmanDartsBite1 = { 0, 0, -200, 13 }; diff --git a/TR5Main/Objects/TR3/Trap/train.cpp b/TR5Main/Objects/TR3/Trap/train.cpp index c1f4f7a07..e8ac6c80b 100644 --- a/TR5Main/Objects/TR3/Trap/train.cpp +++ b/TR5Main/Objects/TR3/Trap/train.cpp @@ -8,6 +8,7 @@ #include "camera.h" #include "sphere.h" #include "lara.h" +#include "collide.h" #define TRAIN_VEL 260 #define LARA_TRAIN_DEATH_ANIM 3; diff --git a/TR5Main/Objects/TR3/Vehicles/biggun.cpp b/TR5Main/Objects/TR3/Vehicles/biggun.cpp index b90f65c16..744844dce 100644 --- a/TR5Main/Objects/TR3/Vehicles/biggun.cpp +++ b/TR5Main/Objects/TR3/Vehicles/biggun.cpp @@ -12,7 +12,9 @@ #include "lara_struct.h" #include "effects\tomb4fx.h" #include "draw.h" - +#include "setup.h" +#include "camera.h" +#include "biggun_info.h" static long GunRotYAdd = 0; bool barrelRotating; @@ -119,10 +121,9 @@ void BigGunInitialise(short itemNum) BIGGUNINFO *gun; obj = &g_Level.Items[itemNum]; + obj->data = BIGGUNINFO(); - gun = (BIGGUNINFO*)malloc(sizeof(BIGGUNINFO)); - obj->data = malloc(sizeof(BIGGUNINFO)); - + gun = obj->data; gun->flags = 0; gun->fireCount = 0; gun->xRot = GETOFF_FRAME; diff --git a/TR5Main/Objects/TR3/Vehicles/biggun.h b/TR5Main/Objects/TR3/Vehicles/biggun.h index e74d92e83..c55c7336d 100644 --- a/TR5Main/Objects/TR3/Vehicles/biggun.h +++ b/TR5Main/Objects/TR3/Vehicles/biggun.h @@ -1,14 +1,7 @@ #pragma once -#include "lara_struct.h" +struct COLL_INFO; +struct ITEM_INFO; -typedef struct { - short xRot; - short yRot; - short startYRot; - char flags; - int fireCount; - short barrelZ; -}BIGGUNINFO; void FireBigGun(ITEM_INFO *obj); void BigGunInitialise(short itemNum); static int CanUseGun(ITEM_INFO *obj, ITEM_INFO *lara); diff --git a/TR5Main/Objects/TR3/Vehicles/biggun_info.h b/TR5Main/Objects/TR3/Vehicles/biggun_info.h new file mode 100644 index 000000000..5cc42d5c9 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/biggun_info.h @@ -0,0 +1,9 @@ +#pragma once +struct BIGGUNINFO { + short xRot; + short yRot; + short startYRot; + char flags; + int fireCount; + short barrelZ; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/Vehicles/kayak.cpp b/TR5Main/Objects/TR3/Vehicles/kayak.cpp index c7c675415..ec53b579f 100644 --- a/TR5Main/Objects/TR3/Vehicles/kayak.cpp +++ b/TR5Main/Objects/TR3/Vehicles/kayak.cpp @@ -11,7 +11,7 @@ #include "setup.h" #include "input.h" #include "control.h" - +#include "kayak_info.h" using std::vector; #define KAYAK_COLLIDE 64 @@ -1168,9 +1168,9 @@ void KayakLaraRapidsDrown() void InitialiseKayak(short itemNumber) { ITEM_INFO* v = &g_Level.Items[itemNumber]; - - KAYAK_INFO* kayak = game_malloc(); - v->data = kayak; + KAYAK_INFO* kayak; + v->data = KAYAK_INFO(); + kayak = v->data; kayak->Vel = kayak->Rot = kayak->Flags = 0; kayak->FallSpeedF = kayak->FallSpeedL = kayak->FallSpeedR = 0; diff --git a/TR5Main/Objects/TR3/Vehicles/kayak.h b/TR5Main/Objects/TR3/Vehicles/kayak.h index e8bb8c666..669be1045 100644 --- a/TR5Main/Objects/TR3/Vehicles/kayak.h +++ b/TR5Main/Objects/TR3/Vehicles/kayak.h @@ -1,21 +1,9 @@ #pragma once -#include "items.h" -#include "collide.h" +struct ITEM_INFO; +struct COLL_INFO; +struct PHD_VECTOR; +struct KAYAK_INFO; -struct KAYAK_INFO -{ - int Vel; - int Rot; - int FallSpeedF; - int FallSpeedL; - int FallSpeedR; - int Water; - PHD_3DPOS OldPos; - char Turn; - char Forward; - char TrueWater; - char Flags; -}; void KayakDoWake(ITEM_INFO* v, short xoff, short zoff, short rotate); void KayakDoRipple(ITEM_INFO* v, short xoff, short zoff); diff --git a/TR5Main/Objects/TR3/Vehicles/kayak_info.h b/TR5Main/Objects/TR3/Vehicles/kayak_info.h new file mode 100644 index 000000000..bfa2d2861 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/kayak_info.h @@ -0,0 +1,15 @@ +#pragma once +#include "phd_global.h" +struct KAYAK_INFO { + int Vel; + int Rot; + int FallSpeedF; + int FallSpeedL; + int FallSpeedR; + int Water; + PHD_3DPOS OldPos; + char Turn; + char Forward; + char TrueWater; + char Flags; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/Vehicles/minecart.cpp b/TR5Main/Objects/TR3/Vehicles/minecart.cpp index b22ff6d8f..ec0a8bce1 100644 --- a/TR5Main/Objects/TR3/Vehicles/minecart.cpp +++ b/TR5Main/Objects/TR3/Vehicles/minecart.cpp @@ -13,6 +13,7 @@ #include "setup.h" #include "input.h" #include "Sound\sound.h" +#include "minecart_info.h" using std::vector; @@ -764,8 +765,8 @@ void InitialiseMineCart(short itemNum) CART_INFO* cart; v = &g_Level.Items[itemNum]; - cart = game_malloc(); - v->data = (void*)cart; + v->data = CART_INFO(); + cart = v->data; cart->Flags = NULL; cart->Speed = 0; cart->YVel = 0; @@ -831,8 +832,8 @@ int MineCartControl(void) short roomNumber; v = &g_Level.Items[Lara.Vehicle]; - if (v->data == NULL) { printf("v->data is nullptr !"); return 0; } - cart = (CART_INFO*)v->data; + if (!v->data) { printf("v->data is nullptr !"); return 0; } + cart = v->data; DoUserInput(v, LaraItem, cart); @@ -867,4 +868,4 @@ int MineCartControl(void) } return (Lara.Vehicle == NO_ITEM) ? 0 : 1; -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR3/Vehicles/minecart.h b/TR5Main/Objects/TR3/Vehicles/minecart.h index 12d4ce20d..702e0f61b 100644 --- a/TR5Main/Objects/TR3/Vehicles/minecart.h +++ b/TR5Main/Objects/TR3/Vehicles/minecart.h @@ -2,20 +2,7 @@ #include "items.h" #include "collide.h" -struct CART_INFO -{ - int Speed; - int MidPos; - int FrontPos; - int TurnX; - int TurnZ; - short TurnLen; - short TurnRot; - short YVel; - short Gradient; - char Flags; - char StopDelay; -}; + void InitialiseMineCart(short itemNum); void MineCartCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); diff --git a/TR5Main/Objects/TR3/Vehicles/minecart_info.h b/TR5Main/Objects/TR3/Vehicles/minecart_info.h new file mode 100644 index 000000000..c4f4df2af --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/minecart_info.h @@ -0,0 +1,14 @@ +#pragma once +struct CART_INFO { + int Speed; + int MidPos; + int FrontPos; + int TurnX; + int TurnZ; + short TurnLen; + short TurnRot; + short YVel; + short Gradient; + char Flags; + char StopDelay; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/Vehicles/quad.cpp b/TR5Main/Objects/TR3/Vehicles/quad.cpp index 310bd356b..536dce8c3 100644 --- a/TR5Main/Objects/TR3/Vehicles/quad.cpp +++ b/TR5Main/Objects/TR3/Vehicles/quad.cpp @@ -15,6 +15,8 @@ #include "input.h" #include "Sound\sound.h" #include "Specific\prng.h" +#include "quad_info.h" + using std::vector; using namespace TEN::Math::Random; enum QUAD_EFFECTS_POSITIONS { @@ -1123,8 +1125,8 @@ void InitialiseQuadBike(short itemNumber) { ITEM_INFO* item = &g_Level.Items[itemNumber]; - item->data = game_malloc(); - QUAD_INFO* quad = (QUAD_INFO *)item->data; + item->data = QUAD_INFO(); + QUAD_INFO* quad = item->data; quad->velocity = 0; diff --git a/TR5Main/Objects/TR3/Vehicles/quad.h b/TR5Main/Objects/TR3/Vehicles/quad.h index cb77aebb3..2a3944d44 100644 --- a/TR5Main/Objects/TR3/Vehicles/quad.h +++ b/TR5Main/Objects/TR3/Vehicles/quad.h @@ -1,23 +1,7 @@ #pragma once -#include "items.h" -#include "collide.h" -struct QUAD_INFO -{ - int velocity; - short frontRot; - short rearRot; - int revs; - int engineRevs; - short trackMesh; - int skidooTurn; - int leftFallspeed; - int rightFallspeed; - short momentumAngle; - short extraRotation; - int pitch; - char flags; -}; +struct ITEM_INFO; +struct COLL_INFO; void InitialiseQuadBike(short itemNumber); void QuadBikeCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); diff --git a/TR5Main/Objects/TR3/Vehicles/quad_info.h b/TR5Main/Objects/TR3/Vehicles/quad_info.h new file mode 100644 index 000000000..bd05eefa3 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/quad_info.h @@ -0,0 +1,16 @@ +#pragma once +struct QUAD_INFO { + int velocity; + short frontRot; + short rearRot; + int revs; + int engineRevs; + short trackMesh; + int skidooTurn; + int leftFallspeed; + int rightFallspeed; + short momentumAngle; + short extraRotation; + int pitch; + char flags; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/Vehicles/rubberboat.cpp b/TR5Main/Objects/TR3/Vehicles/rubberboat.cpp index 558023819..5ea110e37 100644 --- a/TR5Main/Objects/TR3/Vehicles/rubberboat.cpp +++ b/TR5Main/Objects/TR3/Vehicles/rubberboat.cpp @@ -9,8 +9,9 @@ #include "Sound\sound.h" #include "effects\bubble.h" #include "draw.h" - - +#include "camera.h" +#include "setup.h" +#include "rubberboat_info.h" #define RUBBER_BOAT_FRONT 750 #define RUBBER_BOAT_SIDE 300 @@ -48,10 +49,10 @@ void DrawRubberBoat(ITEM_INFO *item) { RUBBER_BOAT_INFO *b; - b = (RUBBER_BOAT_INFO*)item->data; + b = item->data; item->data = &b->propRot; DrawAnimatingItem(item); - item->data = (void *)b; + item->data = b; } int RubberBoatCheckGeton(short itemNum, COLL_INFO *coll) @@ -578,10 +579,9 @@ void InitialiseRubberBoat(short itemNum) RUBBER_BOAT_INFO* binfo; boat = &g_Level.Items[itemNum]; - - binfo = game_malloc(); - boat->data = binfo; - + boat->data = RUBBER_BOAT_INFO(); + + binfo = boat->data; binfo->boatTurn = 0; binfo->tiltAngle = 0; binfo->rightFallspeed = 0; diff --git a/TR5Main/Objects/TR3/Vehicles/rubberboat.h b/TR5Main/Objects/TR3/Vehicles/rubberboat.h index ddb94553b..bc98a43a5 100644 --- a/TR5Main/Objects/TR3/Vehicles/rubberboat.h +++ b/TR5Main/Objects/TR3/Vehicles/rubberboat.h @@ -2,17 +2,6 @@ #include "items.h" #include "collide.h" -typedef struct { - int boatTurn; - int leftFallspeed; - int rightFallspeed; - short tiltAngle; - short extraRotation; - int water; - int pitch; - short propRot; -}RUBBER_BOAT_INFO; - void InitialiseRubberBoat(short itemNum); void RubberBoatCollision(short itemNum, ITEM_INFO *lara, COLL_INFO *coll); void RubberBoatControl(short itemNum); diff --git a/TR5Main/Objects/TR3/Vehicles/rubberboat_info.h b/TR5Main/Objects/TR3/Vehicles/rubberboat_info.h new file mode 100644 index 000000000..a4e53ae85 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/rubberboat_info.h @@ -0,0 +1,11 @@ +#pragma once +struct RUBBER_BOAT_INFO { + int boatTurn; + int leftFallspeed; + int rightFallspeed; + short tiltAngle; + short extraRotation; + int water; + int pitch; + short propRot; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/Vehicles/upv.cpp b/TR5Main/Objects/TR3/Vehicles/upv.cpp index ec861620b..a0b0584f7 100644 --- a/TR5Main/Objects/TR3/Vehicles/upv.cpp +++ b/TR5Main/Objects/TR3/Vehicles/upv.cpp @@ -17,6 +17,7 @@ #include "input.h" #include "savegame.h" #include "Sound\sound.h" +#include "upv_info.h" #define UPV_CONTROL 1 #define UPV_SURFACE 2 @@ -830,11 +831,10 @@ static void UserInput(ITEM_INFO* v, ITEM_INFO* l, SUB_INFO* sub) void SubInitialise(short itemNum) { ITEM_INFO* v; - SUB_INFO* sub; v = &g_Level.Items[itemNum]; - sub = game_malloc(); - v->data = (void*)sub; + v->data = SUB_INFO(); + SUB_INFO* sub = v->data; sub->Vel = sub->Rot = 0; sub->Flags = UPV_SURFACE; sub->WeaponTimer = 0; diff --git a/TR5Main/Objects/TR3/Vehicles/upv.h b/TR5Main/Objects/TR3/Vehicles/upv.h index 24bb9621c..c8feafb9b 100644 --- a/TR5Main/Objects/TR3/Vehicles/upv.h +++ b/TR5Main/Objects/TR3/Vehicles/upv.h @@ -2,16 +2,6 @@ #include "items.h" #include "collide.h" -struct SUB_INFO -{ - int Vel; - int Rot; - int RotX; - short FanRot; - char Flags; - char WeaponTimer; -}; - void SubInitialise(short itemNum); void SubCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); int SubControl(void); diff --git a/TR5Main/Objects/TR3/Vehicles/upv_info.h b/TR5Main/Objects/TR3/Vehicles/upv_info.h new file mode 100644 index 000000000..b4c1d2582 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/upv_info.h @@ -0,0 +1,9 @@ +#pragma once +struct SUB_INFO { + int Vel; + int Rot; + int RotX; + short FanRot; + char Flags; + char WeaponTimer; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR3/tr3_objects.cpp b/TR5Main/Objects/TR3/tr3_objects.cpp index 28eb0e404..39878c8ce 100644 --- a/TR5Main/Objects/TR3/tr3_objects.cpp +++ b/TR5Main/Objects/TR3/tr3_objects.cpp @@ -33,7 +33,8 @@ #include "collide.h" #include "setup.h" #include "level.h" - +#include "creature_info.h" +#include "Box.h" static void StartBaddy(OBJECT_INFO* obj) { obj = &Objects[ID_TONY_BOSS]; diff --git a/TR5Main/Objects/TR4/Entity/tr4_ahmet.cpp b/TR5Main/Objects/TR4/Entity/tr4_ahmet.cpp index 1c76f4ffd..6e3fe4f9a 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_ahmet.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_ahmet.cpp @@ -12,6 +12,7 @@ #include "people.h" #include "items.h" #include "lot.h" +#include "creature_info.h" namespace TEN::Entities::TR4 { diff --git a/TR5Main/Objects/TR4/Entity/tr4_baboon.cpp b/TR5Main/Objects/TR4/Entity/tr4_baboon.cpp index ad550c550..98ed86d7c 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_baboon.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_baboon.cpp @@ -6,8 +6,12 @@ #include "control.h" #include "misc.h" #include "Lara.h" +#include "effects\effects.h" #include "effects\tomb4fx.h" +#include "creature_info.h" + using std::vector; + BaboonRespawnClass BaboonRespawn; static BITE_INFO baboonBite = { 10, 10, 11, 4 }; diff --git a/TR5Main/Objects/TR4/Entity/tr4_baddy.cpp b/TR5Main/Objects/TR4/Entity/tr4_baddy.cpp index 47ee22703..7ec100c25 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_baddy.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_baddy.cpp @@ -11,6 +11,8 @@ #include "control.h" #include #include +#include "creature_info.h" +#include "control.h" /* ID_BADDY_1 @@ -1136,11 +1138,11 @@ namespace TEN::Entities::TR4 KillItem(currentCreature->enemy - g_Level.Items.data()); // cancel enemy pointer for other active baddies - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - if (BaddieSlots[i].itemNum != NO_ITEM && BaddieSlots[i].itemNum != itemNum && BaddieSlots[i].enemy == creature->enemy) + if (ActiveCreatures[i]->itemNum != NO_ITEM && ActiveCreatures[i]->itemNum != itemNum && ActiveCreatures[i]->enemy == creature->enemy) { - BaddieSlots[i].enemy = NULL; + ActiveCreatures[i]->enemy = NULL; } } creature->enemy = NULL; diff --git a/TR5Main/Objects/TR4/Entity/tr4_bat.cpp b/TR5Main/Objects/TR4/Entity/tr4_bat.cpp index c554cff72..491d3eac9 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_bat.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_bat.cpp @@ -8,6 +8,7 @@ #include "lot.h" #include "setup.h" #include "Specific\trmath.h" +#include "creature_info.h" namespace TEN::Entities::TR4 { @@ -195,4 +196,4 @@ namespace TEN::Entities::TR4 CreatureAnimation(itemNumber, angle, 0); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp index f1ecc7060..c94d79ad1 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp @@ -10,6 +10,7 @@ #include "Sound\sound.h" #include #include +#include "creature_info.h" namespace TEN::Entities::TR4 { @@ -205,4 +206,4 @@ namespace TEN::Entities::TR4 CreatureTilt(item, 2 * angle); CreatureAnimation(itemNumber, angle, angle); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp b/TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp index 8befd4ceb..20f1a3abf 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp @@ -7,6 +7,7 @@ #include "lot.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO scorpionBite1 = { 0, 0, 0, 8 }; @@ -164,12 +165,11 @@ void ScorpionControl(short itemNumber) else { creature->enemy = NULL; - CREATURE_INFO* baddy = &BaddieSlots[0]; int minDistance = 0x7FFFFFFF; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - baddy = &BaddieSlots[i]; + CREATURE_INFO* baddy = ActiveCreatures[i]; if (baddy->itemNum != NO_ITEM && baddy->itemNum != itemNumber) { @@ -391,4 +391,4 @@ void ScorpionControl(short itemNumber) if (!CutSeqNum) CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_crocodile.cpp b/TR5Main/Objects/TR4/Entity/tr4_crocodile.cpp index 250e231a2..71abff157 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_crocodile.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_crocodile.cpp @@ -10,6 +10,9 @@ #include "lara.h" #include "draw.h" #include "misc.h" +#include "creature_info.h" +#include "collide.h" +#include "control.h" enum CROCODILE_STATE { diff --git a/TR5Main/Objects/TR4/Entity/tr4_demigod.cpp b/TR5Main/Objects/TR4/Entity/tr4_demigod.cpp index 2a2254c3d..65bbbc40b 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_demigod.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_demigod.cpp @@ -12,6 +12,7 @@ #include "level.h" #include "lara.h" #include "control.h" +#include "creature_info.h" extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE]; @@ -718,4 +719,4 @@ void DemigodControl(short itemNumber) CreatureJoint(item, 3, joint3); CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_dog.cpp b/TR5Main/Objects/TR4/Entity/tr4_dog.cpp index 65623c4d9..9b554ceb6 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_dog.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_dog.cpp @@ -5,6 +5,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" namespace TEN::Entities::TR4 @@ -340,4 +341,4 @@ namespace TEN::Entities::TR4 CreatureJoint(item, 2, joint2); CreatureAnimation(itemNumber, angle, 0); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_enemy_jeep.cpp b/TR5Main/Objects/TR4/Entity/tr4_enemy_jeep.cpp index c2456cfc4..a705cdd6c 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_enemy_jeep.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_enemy_jeep.cpp @@ -10,8 +10,13 @@ #include #include "Sound\sound.h" #include -#include -#include +#include "creature_info.h" +#include "setup.h" +#include "control/trigger.h" +#include "effects/effects.h" +#include "effects/tomb4fx.h" + +ITEM_INFO jeepDummyTarget; void EnemyJeepLaunchGrenade(ITEM_INFO* item) { @@ -144,16 +149,10 @@ void EnemyJeepControl(short itemNumber) AI_INFO info; CreatureAIInfo(item, &info); - ITEM_INFO* target = &creature->aiTarget; - creature->enemy = target; + creature->enemy = &jeepDummyTarget; + CREATURE_TARGET* target = &creature->aiTarget; short angle; int distance; - if (target == LaraItem) - { - angle = info.angle; - distance = info.distance; - } - else { dx = LaraItem->pos.xPos - item->pos.xPos; dz = LaraItem->pos.zPos - item->pos.zPos; @@ -268,7 +267,7 @@ void EnemyJeepControl(short itemNumber) if (creature->reachedGoal) { - TestTriggers(target, true, NULL); + TestTriggers(target->pos.xPos,target->pos.yPos,target->pos.zPos,target->roomNumber, true, 0x0); if (Lara.location < item->itemFlags[3] && item->currentAnimState != 2 && item->goalAnimState != 2) { @@ -309,8 +308,8 @@ void EnemyJeepControl(short itemNumber) creature->reachedGoal = false; item->itemFlags[3]++; - creature->enemy = NULL; - AI_OBJECT* aiObject = NULL; + creature->enemy = nullptr; + AI_OBJECT* aiObject = nullptr; for (int i = 0; i < g_Level.AIObjects.size(); i++) { @@ -323,9 +322,9 @@ void EnemyJeepControl(short itemNumber) } } - if (aiObject != NULL) + if (aiObject != nullptr) { - creature->enemy = target; + creature->enemy = nullptr; target->objectNumber = aiObject->objectNumber; target->roomNumber = aiObject->roomNumber; target->pos.xPos = aiObject->x; diff --git a/TR5Main/Objects/TR4/Entity/tr4_guide.cpp b/TR5Main/Objects/TR4/Entity/tr4_guide.cpp index 9e867f220..da36c0eb7 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_guide.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_guide.cpp @@ -10,6 +10,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" #define STATE_GUIDE_STOP 1 #define STATE_GUIDE_WALK 2 @@ -133,11 +134,10 @@ void GuideControl(short itemNumber) || item->currentAnimState == STATE_GUIDE_TORCH_ATTACK) { int minDistance = 0x7FFFFFFF; - CREATURE_INFO* baddie = &BaddieSlots[0]; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - baddie = &BaddieSlots[i]; + CREATURE_INFO* baddie = ActiveCreatures[i]; if (baddie->itemNum == NO_ITEM || baddie->itemNum == itemNumber) continue; diff --git a/TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp b/TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp index 3879709ab..1c47bba58 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp @@ -9,6 +9,7 @@ #include "lara.h" #include "draw.h" #include "misc.h" +#include "creature_info.h" #include "control.h" #define STATE_HAMMERHEAD_STOP 0 @@ -137,4 +138,4 @@ void HammerheadControl(short itemNumber) CreatureFloat(itemNumber); } } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_harpy.cpp b/TR5Main/Objects/TR4/Entity/tr4_harpy.cpp index 32d90194c..526f89f7d 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_harpy.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_harpy.cpp @@ -10,6 +10,7 @@ #include "lot.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO harpyBite1 = { 0, 0, 0, 4 }; @@ -334,13 +335,12 @@ void HarpyControl(short itemNumber) GetAITarget(creature); } - CREATURE_INFO* baddie = &BaddieSlots[0]; int minDistance = 0x7FFFFFFF; creature->enemy = NULL; - for (int i = 0; i < NUM_SLOTS; i++, baddie++) - { + for(int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* baddie = ActiveCreatures[i]; if (baddie->itemNum == NO_ITEM || baddie->itemNum == itemNumber) continue; @@ -619,4 +619,4 @@ void HarpyControl(short itemNumber) CreatureJoint(item, 1, joint1); CreatureJoint(item, 2, joint2); CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_horseman.cpp b/TR5Main/Objects/TR4/Entity/tr4_horseman.cpp index 50f3776d8..1991b9a4e 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_horseman.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_horseman.cpp @@ -9,6 +9,7 @@ #include #include "Sound\sound.h" #include +#include "box.h" namespace TEN::Entities::TR4 { diff --git a/TR5Main/Objects/TR4/Entity/tr4_knighttemplar.cpp b/TR5Main/Objects/TR4/Entity/tr4_knighttemplar.cpp index 4b259e6de..b0b9fdccd 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_knighttemplar.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_knighttemplar.cpp @@ -9,6 +9,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO knightTemplarBite = { 0, 0, 0, 11 }; diff --git a/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.cpp b/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.cpp index 94fa51890..a86f1331b 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.cpp @@ -4,10 +4,10 @@ #include "control.h" #include "Specific\trmath.h" #include "lara.h" - +#include "setup.h" namespace TEN::Entities::TR4 { - SCARAB_INFO* Scarabs; + SCARAB_INFO Scarabs[NUM_LITTLE_BETTLES]; int NextScarab; void InitialiseScarabs(short itemNumber) diff --git a/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.h b/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.h index 8cda22e83..203192475 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.h +++ b/TR5Main/Objects/TR4/Entity/tr4_littlebeetle.h @@ -15,7 +15,7 @@ namespace TEN::Entities::TR4 { constexpr auto NUM_LITTLE_BETTLES = 256; - extern SCARAB_INFO* Scarabs; + extern SCARAB_INFO Scarabs[NUM_LITTLE_BETTLES]; extern int NextScarab; void InitialiseScarabs(short itemNumber); diff --git a/TR5Main/Objects/TR4/Entity/tr4_mummy.cpp b/TR5Main/Objects/TR4/Entity/tr4_mummy.cpp index f3c0c82b5..f948fbcf9 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_mummy.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_mummy.cpp @@ -8,6 +8,8 @@ #include "setup.h" #include "control.h" #include "level.h" +#include "creature_info.h" +#include "control.h" enum MUMMY_STATES { STATE_MUMMY_ARMS_CROSSED = 0, diff --git a/TR5Main/Objects/TR4/Entity/tr4_mutant.cpp b/TR5Main/Objects/TR4/Entity/tr4_mutant.cpp index 46d0d1755..86bfce518 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_mutant.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_mutant.cpp @@ -8,6 +8,7 @@ #include "sphere.h" #include "objectslist.h" #include "Specific\trmath.h" +#include "creature_info.h" #include "control.h" namespace TEN::Entities::TR4 @@ -330,4 +331,4 @@ namespace TEN::Entities::TR4 CreatureJoint(item, 3, mutant_joint.bone3); CreatureAnimation(itemNumber, angle, 0); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_sas.cpp b/TR5Main/Objects/TR4/Entity/tr4_sas.cpp index 9a24eff9f..727ef16ca 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_sas.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_sas.cpp @@ -12,7 +12,8 @@ #include "effects\tomb4fx.h" #include #include - +#include "creature_info.h" +#include "control.h" namespace TEN::Entities::TR4 { enum SAS_STATES @@ -739,4 +740,4 @@ namespace TEN::Entities::TR4 } } } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_sentrygun.cpp b/TR5Main/Objects/TR4/Entity/tr4_sentrygun.cpp index 3e13392fc..58e858133 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_sentrygun.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_sentrygun.cpp @@ -16,6 +16,7 @@ #include "Sound\sound.h" #include "Specific\trmath.h" #include "objectslist.h" +#include "creature_info.h" #ifndef NEW_INV extern Inventory g_Inventory; diff --git a/TR5Main/Objects/TR4/Entity/tr4_setha.cpp b/TR5Main/Objects/TR4/Entity/tr4_setha.cpp index 9907f2012..130acbb8a 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_setha.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_setha.cpp @@ -10,6 +10,7 @@ #include "Sound\sound.h" #include #include +#include "creature_info.h" BITE_INFO SethaBite1 = { 0,220,50,17 }; BITE_INFO SethaBite2 = { 0,220,50,13 }; diff --git a/TR5Main/Objects/TR4/Entity/tr4_skeleton.cpp b/TR5Main/Objects/TR4/Entity/tr4_skeleton.cpp index 2c44b0f5a..c8ccaa7e3 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_skeleton.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_skeleton.cpp @@ -12,6 +12,9 @@ #include "setup.h" #include "effects\tomb4fx.h" #include "level.h" +#include "creature_info.h" +#include "floordata.h" +#include "collide.h" namespace TEN::Entities::TR4 { diff --git a/TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp b/TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp index 914c2f1b0..e6098aa29 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp @@ -6,6 +6,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO smallScorpionBiteInfo1 = { 0, 0, 0, 0 }; @@ -181,4 +182,4 @@ void SmallScorpionControl(short itemNumber) } CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_sphinx.cpp b/TR5Main/Objects/TR4/Entity/tr4_sphinx.cpp index 13d740856..95f4c87d8 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_sphinx.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_sphinx.cpp @@ -8,6 +8,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" enum SPHIX_STATES { SPHINX_EMPTY, diff --git a/TR5Main/Objects/TR4/Entity/tr4_troops.cpp b/TR5Main/Objects/TR4/Entity/tr4_troops.cpp index e8c42f437..1df410212 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_troops.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_troops.cpp @@ -9,8 +9,8 @@ #include "setup.h" #include "lot.h" #include "level.h" +#include "creature_info.h" #include "control.h" - BITE_INFO TroopsBite1 = { 0, 300, 64, 7 }; #define STATE_TROOPS_STOP 1 @@ -141,12 +141,12 @@ void TroopsControl(short itemNumber) { // Search for active troops creature->enemy = NULL; - CREATURE_INFO* baddy = &BaddieSlots[0]; + CREATURE_INFO* baddy = ActiveCreatures[0]; int minDistance = 0x7FFFFFFF; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - baddy = &BaddieSlots[i]; + baddy = ActiveCreatures[i]; if (baddy->itemNum != NO_ITEM && baddy->itemNum != itemNumber) { @@ -526,4 +526,4 @@ void TroopsControl(short itemNumber) CreatureJoint(item, 1, joint1); CreatureJoint(item, 2, joint2); CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_von_croy.cpp b/TR5Main/Objects/TR4/Entity/tr4_von_croy.cpp index ef3d8e55f..b93d94ee2 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_von_croy.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_von_croy.cpp @@ -11,6 +11,7 @@ #include "lara.h" #include "Sound\sound.h" #include +#include "creature_info.h" #define STATE_VON_CROY_STOP 1 #define STATE_VON_CROY_WALK 2 @@ -156,11 +157,11 @@ void VonCroyControl(short itemNumber) { int minDistance = 0x7FFFFFFF; int distance; - CREATURE_INFO* baddie = &BaddieSlots[0]; + CREATURE_INFO* baddie = ActiveCreatures[0]; - for (int i = 0; i < NUM_SLOTS; i++) + for (int i = 0; i < ActiveCreatures.size(); i++) { - baddie = &BaddieSlots[i]; + baddie = ActiveCreatures[i]; if (baddie->itemNum == NO_ITEM || baddie->itemNum == itemNumber diff --git a/TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp b/TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp index 22b893d58..7e2405204 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp @@ -7,6 +7,7 @@ #include "lot.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO wildboardBiteInfo = { 0, 0, 0, 14 }; @@ -53,12 +54,12 @@ void WildBoarControl(short itemNumber) { creature->enemy = LaraItem; - CREATURE_INFO* baddie = &BaddieSlots[0]; - CREATURE_INFO* found = &BaddieSlots[0]; int minDistance = 0x7FFFFFFF; - for (int i = 0; i < NUM_SLOTS; i++, baddie++) + for (int i = 0; i < ActiveCreatures.size(); i++) { + CREATURE_INFO* baddie = ActiveCreatures[i]; + if (baddie->itemNum == NO_ITEM || baddie->itemNum == itemNumber) continue; @@ -173,4 +174,4 @@ void WildBoarControl(short itemNumber) CreatureJoint(item, 2, joint2); CreatureJoint(item, 3, joint3); CreatureAnimation(itemNumber, angle, 0); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Entity/tr4_wraith.cpp b/TR5Main/Objects/TR4/Entity/tr4_wraith.cpp index ba3fdc57c..c775ff388 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_wraith.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_wraith.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "tr4_wraith_info.h" constexpr auto WRAITH_COUNT = 8; @@ -19,10 +20,10 @@ void InitialiseWraith(short itemNumber) ITEM_INFO* item; item = &g_Level.Items[itemNumber]; - WRAITH_INFO* wraithData; - wraithData = game_malloc(WRAITH_COUNT); - item->data = wraithData; + item->data = WRAITH_INFO(); + WRAITH_INFO* wraithData = item->data; + item->itemFlags[0] = 0; item->itemFlags[6] = 0; item->speed = WraithSpeed; diff --git a/TR5Main/Objects/TR4/Entity/tr4_wraith.h b/TR5Main/Objects/TR4/Entity/tr4_wraith.h index 33b931895..323539a0e 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_wraith.h +++ b/TR5Main/Objects/TR4/Entity/tr4_wraith.h @@ -1,18 +1,7 @@ #pragma once -#include "items.h" +struct ITEM_INFO; + -struct WRAITH_INFO -{ - int xPos; - int yPos; - int zPos; - short xRot; - short yRot; - short zRot; - byte r; - byte g; - byte b; -}; void InitialiseWraith(short itemNumber); void WraithControl(short itemNumber); diff --git a/TR5Main/Objects/TR4/Entity/tr4_wraith_info.h b/TR5Main/Objects/TR4/Entity/tr4_wraith_info.h new file mode 100644 index 000000000..1a3328e1d --- /dev/null +++ b/TR5Main/Objects/TR4/Entity/tr4_wraith_info.h @@ -0,0 +1,12 @@ +#pragma once +struct WRAITH_INFO { + int xPos; + int yPos; + int zPos; + short xRot; + short yRot; + short zRot; + unsigned char r; + unsigned char g; + unsigned char b; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Object/tr4_clockwork_beetle.cpp b/TR5Main/Objects/TR4/Object/tr4_clockwork_beetle.cpp index 18061edc7..010285290 100644 --- a/TR5Main/Objects/TR4/Object/tr4_clockwork_beetle.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_clockwork_beetle.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "draw.h" #include "Sound\sound.h" +#include "collide.h" void ClockworkBeetleControl(short item_number) { diff --git a/TR5Main/Objects/TR4/Object/tr4_element_puzzle.cpp b/TR5Main/Objects/TR4/Object/tr4_element_puzzle.cpp index 9baf5ae05..f4fba4325 100644 --- a/TR5Main/Objects/TR4/Object/tr4_element_puzzle.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_element_puzzle.cpp @@ -11,7 +11,7 @@ #include #include #include "generic_switch.h" - +#include "collide.h" using namespace TEN::Entities::Switches; OBJECT_COLLISION_BOUNDS ElementPuzzleBounds = { diff --git a/TR5Main/Objects/TR4/Object/tr4_senet.cpp b/TR5Main/Objects/TR4/Object/tr4_senet.cpp index 3959a49c5..c15ab5fa7 100644 --- a/TR5Main/Objects/TR4/Object/tr4_senet.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_senet.cpp @@ -8,7 +8,8 @@ #include "lara.h" #include "lara_struct.h" #include "input.h" - +#include "level.h" +#include "collide.h" short SenetPiecesNumber[6]; char SenetDisplacement, ActiveSenetPieces[6], SenetBoard[17]; int SenetTargetX, SenetTargetZ; @@ -27,7 +28,8 @@ void InitialiseGameStix(short itemNumber) item = &g_Level.Items[itemNumber]; item->itemFlags[7] = -1; - item->data = &item->itemFlags; + //not needed + //item->data = &item->itemFlags; ActivePiece = -1; SenetDisplacement = 0; } diff --git a/TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp b/TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp index 463548c1c..4d4145ba2 100644 --- a/TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp +++ b/TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp @@ -2,10 +2,10 @@ #include "tr4_joby_spikes.h" #include "level.h" #include "control.h" -#include "effects\effects.h" #include "Sound\sound.h" -#include -#include +#include "draw.h" +#include "lara.h" +#include "effects\effects.h" void InitialiseJobySpikes(short itemNumber) { @@ -72,4 +72,4 @@ void JobySpikesControl(short itemNumber) item->itemFlags[1] += 3; item->pos.yRot += item->itemFlags[0]; -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Vehicles/jeep.cpp b/TR5Main/Objects/TR4/Vehicles/jeep.cpp index 6230dc77b..0791c12f3 100644 --- a/TR5Main/Objects/TR4/Vehicles/jeep.cpp +++ b/TR5Main/Objects/TR4/Vehicles/jeep.cpp @@ -18,7 +18,8 @@ #include "Sound\sound.h" #include "setup.h" #include "level.h" - +#include "Box.h" +#include "jeep_info.h" using std::vector; @@ -379,8 +380,9 @@ void InitialiseJeep(short itemNum) { ITEM_INFO* item = &g_Level.Items[itemNum]; - JEEP_INFO* jeep = game_malloc(); - item->data = jeep; + JEEP_INFO* jeep; + item->data = JEEP_INFO(); + jeep = item->data; jeep->velocity = 0; jeep->revs = 0; diff --git a/TR5Main/Objects/TR4/Vehicles/jeep.h b/TR5Main/Objects/TR4/Vehicles/jeep.h index 69490f9f2..6af38ddb6 100644 --- a/TR5Main/Objects/TR4/Vehicles/jeep.h +++ b/TR5Main/Objects/TR4/Vehicles/jeep.h @@ -1,25 +1,7 @@ #pragma once #include "items.h" #include "collide.h" -struct JEEP_INFO { - short rot1; - short rot2; - short rot3; - short rot4; - int velocity; - int revs; - short engineRevs; - short trackMesh; - int jeepTurn; - int fallSpeed; - short momentumAngle; - short extraRotation; - short unknown0; - int pitch; - short flags; - short unknown1; - short unknown2; -}; + void InitialiseJeep(short itemNumber); void JeepCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); int JeepControl(void); \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Vehicles/jeep_info.h b/TR5Main/Objects/TR4/Vehicles/jeep_info.h new file mode 100644 index 000000000..ff0332594 --- /dev/null +++ b/TR5Main/Objects/TR4/Vehicles/jeep_info.h @@ -0,0 +1,20 @@ +#pragma once +struct JEEP_INFO { + short rot1; + short rot2; + short rot3; + short rot4; + int velocity; + int revs; + short engineRevs; + short trackMesh; + int jeepTurn; + int fallSpeed; + short momentumAngle; + short extraRotation; + short unknown0; + int pitch; + short flags; + short unknown1; + short unknown2; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Vehicles/motorbike.cpp b/TR5Main/Objects/TR4/Vehicles/motorbike.cpp index c90f168d2..0e07a3fc7 100644 --- a/TR5Main/Objects/TR4/Vehicles/motorbike.cpp +++ b/TR5Main/Objects/TR4/Vehicles/motorbike.cpp @@ -20,6 +20,8 @@ #include "health.h" #include "camera.h" #include "Specific\prng.h" +#include "Box.h" +#include "motorbike_info.h" using namespace TEN::Math::Random; @@ -138,8 +140,8 @@ void InitialiseMotorbike(short itemNumber) MOTORBIKE_INFO* motorbike; item = &g_Level.Items[itemNumber]; - motorbike = game_malloc(); - item->data = (void*)motorbike; + item->data = ITEM_DATA(MOTORBIKE_INFO()); + motorbike = item->data; motorbike->velocity = 0; motorbike->bikeTurn = 0; motorbike->pitch = 0; @@ -1564,4 +1566,4 @@ void DrawMotorbikeEffect(ITEM_INFO* item) //if (Lara.Vehicle != NO_ITEM) //DrawMotorBikeSpeedoMeter(phd_winwidth - 64, phd_winheight - 16, motorbike->velocity, ANGLE(180), ANGLE(270), 32); // angle are 2D angle... DrawMotorBikeSmoke(item); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR4/Vehicles/motorbike.h b/TR5Main/Objects/TR4/Vehicles/motorbike.h index 0cd21b771..df033c501 100644 --- a/TR5Main/Objects/TR4/Vehicles/motorbike.h +++ b/TR5Main/Objects/TR4/Vehicles/motorbike.h @@ -2,21 +2,7 @@ #include "items.h" #include "collide.h" -struct MOTORBIKE_INFO -{ - int wheelRight; // (two wheel: front and back) - int wheelLeft; // (one wheel: left) - int velocity; - int revs; - int engineRevs; - short momentumAngle; - short extraRotation; - short wallShiftRotation; - int bikeTurn; - int pitch; - short flags; - short lightPower; -}; + void InitialiseMotorbike(short itemNumber); void MotorbikeCollision(short itemNumber, ITEM_INFO* laraitem, COLL_INFO* coll); diff --git a/TR5Main/Objects/TR4/Vehicles/motorbike_info.h b/TR5Main/Objects/TR4/Vehicles/motorbike_info.h new file mode 100644 index 000000000..4622e03da --- /dev/null +++ b/TR5Main/Objects/TR4/Vehicles/motorbike_info.h @@ -0,0 +1,15 @@ +#pragma once +struct MOTORBIKE_INFO { + int wheelRight; // (two wheel: front and back) + int wheelLeft; // (one wheel: left) + int velocity; + int revs; + int engineRevs; + short momentumAngle; + short extraRotation; + short wallShiftRotation; + int bikeTurn; + int pitch; + short flags; + short lightPower; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR4/tr4_objects.cpp b/TR5Main/Objects/TR4/tr4_objects.cpp index a14aa09ec..657199c4e 100644 --- a/TR5Main/Objects/TR4/tr4_objects.cpp +++ b/TR5Main/Objects/TR4/tr4_objects.cpp @@ -69,6 +69,8 @@ #include "setup.h" #include "level.h" #include "tr4_enemy_jeep.h" +#include "creature_info.h" +#include "Box.h" using namespace TEN::Entities::TR4; @@ -1217,6 +1219,5 @@ void InitialiseTR4Objects() void AllocTR4Objects() { - TEN::Entities::TR4::Scarabs = game_malloc(TEN::Entities::TR4::NUM_LITTLE_BETTLES); ZeroMemory(TEN::Entities::TR4::Scarabs, TEN::Entities::TR4::NUM_LITTLE_BETTLES * sizeof(SCARAB_INFO)); -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.cpp b/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.cpp index 2aa4d1f95..12055ba3e 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.cpp +++ b/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.cpp @@ -11,7 +11,7 @@ #include int NextBat; -BAT_STRUCT* Bats; +BAT_STRUCT Bats[NUM_BATS]; void InitialiseLittleBats(short itemNumber) { diff --git a/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.h b/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.h index 8f230a2e8..bf77d0260 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.h +++ b/TR5Main/Objects/TR5/Emitter/tr5_bats_emitter.h @@ -17,7 +17,7 @@ struct BAT_STRUCT }; extern int NextBat; -extern BAT_STRUCT* Bats; +extern BAT_STRUCT Bats[NUM_BATS]; short GetNextBat(); diff --git a/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.cpp b/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.cpp index 52c3979ab..f586244a8 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.cpp +++ b/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.cpp @@ -9,7 +9,7 @@ #include "lara.h" int NextRat; -RAT_STRUCT* Rats; +RAT_STRUCT Rats[NUM_RATS]; short GetNextRat() { diff --git a/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.h b/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.h index 2234738e0..512ac492e 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.h +++ b/TR5Main/Objects/TR5/Emitter/tr5_rats_emitter.h @@ -14,7 +14,7 @@ struct RAT_STRUCT }; extern int NextRat; -extern RAT_STRUCT* Rats; +extern RAT_STRUCT Rats[NUM_RATS]; void ClearRats(); short GetNextRat(); diff --git a/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.cpp b/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.cpp index c54442979..7882d5840 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.cpp +++ b/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.cpp @@ -9,7 +9,7 @@ #include "lara.h" int NextSpider; -SPIDER_STRUCT* Spiders; +SPIDER_STRUCT Spiders[NUM_SPIDERS]; short GetNextSpider() { diff --git a/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.h b/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.h index b628235ca..ec9e3f383 100644 --- a/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.h +++ b/TR5Main/Objects/TR5/Emitter/tr5_spider_emitter.h @@ -14,7 +14,7 @@ struct SPIDER_STRUCT }; extern int NextSpider; -extern SPIDER_STRUCT* Spiders; +extern SPIDER_STRUCT Spiders[NUM_SPIDERS]; short GetNextSpider(); void ClearSpiders(); diff --git a/TR5Main/Objects/TR5/Entity/tr5_autoguns.cpp b/TR5Main/Objects/TR5/Entity/tr5_autoguns.cpp index ef5c38d17..3f0fd4612 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_autoguns.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_autoguns.cpp @@ -14,7 +14,10 @@ void InitialiseAutoGuns(short itemNumber) item = &g_Level.Items[itemNumber]; item->meshBits = 1024; - item->data = game_malloc(5702); + //5702 bytes!? + //item->data = game_malloc(5702); + item->data = std::array(); + } static void TriggerAutoGunSmoke(PHD_VECTOR* pos, char shade) @@ -54,7 +57,7 @@ void AutoGunsControl(short itemNumber) { if (item->frameNumber >= g_Level.Anims[item->animNumber].frameEnd) { - short* data = (short*)item->data; + std::array& data = item->data; item->meshBits = 1664; diff --git a/TR5Main/Objects/TR5/Entity/tr5_brownbeast.cpp b/TR5Main/Objects/TR5/Entity/tr5_brownbeast.cpp index c3d5cea5b..02e49edd0 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_brownbeast.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_brownbeast.cpp @@ -8,6 +8,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO BrownBeastBite1 = { 0, 0, 0, 16 }; BITE_INFO BrownBeastBite2 = { 0, 0, 0, 22 }; diff --git a/TR5Main/Objects/TR5/Entity/tr5_chef.cpp b/TR5Main/Objects/TR5/Entity/tr5_chef.cpp index 93863a67d..17a2a5d18 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_chef.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_chef.cpp @@ -11,6 +11,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" #define STATE_CHEF_COOKING 1 #define STATE_CHEF_TURN_180 2 diff --git a/TR5Main/Objects/TR5/Entity/tr5_cyborg.cpp b/TR5Main/Objects/TR5/Entity/tr5_cyborg.cpp index 1614f8df9..8337745db 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_cyborg.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_cyborg.cpp @@ -12,6 +12,7 @@ #include "setup.h" #include "level.h" #include "Sound\sound.h" +#include "creature_info.h" #define STATE_HITMAN_STOP 1 #define STATE_HITMAN_WALK 2 diff --git a/TR5Main/Objects/TR5/Entity/tr5_doberman.cpp b/TR5Main/Objects/TR5/Entity/tr5_doberman.cpp index 715bc3f48..162fadb2f 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_doberman.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_doberman.cpp @@ -5,6 +5,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO DobermanBite = { 0, 0x1E, 0x8D, 0x14 }; @@ -224,4 +225,4 @@ void DobermanControl(short itemNumber) CreatureJoint(item, 2, 0); CreatureAnimation(itemNumber, angle, tilt); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Entity/tr5_dog.cpp b/TR5Main/Objects/TR5/Entity/tr5_dog.cpp index c86399c16..836b1c4d9 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_dog.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_dog.cpp @@ -6,6 +6,8 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" +#include "control.h" static BYTE DogAnims[] = { 20, 21, 22, 20 }; static BITE_INFO DogBite = { 0, 0, 100, 3 }; diff --git a/TR5Main/Objects/TR5/Entity/tr5_ghost.cpp b/TR5Main/Objects/TR5/Entity/tr5_ghost.cpp index fd695f9c8..6209643dc 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_ghost.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_ghost.cpp @@ -7,6 +7,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO InvisibleGhostBite = { 0, 0, 0, 17 }; diff --git a/TR5Main/Objects/TR5/Entity/tr5_gladiator.cpp b/TR5Main/Objects/TR5/Entity/tr5_gladiator.cpp index 79ec37e00..1d6f31ed7 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_gladiator.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_gladiator.cpp @@ -10,6 +10,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO GladiatorBite = { 0, 0, 0, 16 }; @@ -313,7 +314,7 @@ void ControlGladiator(short itemNumber) pos.z = 0; GetJointAbsPosition(item, &pos, 16); - floor = &XZ_GET_SECTOR(r, pos.x - r->x, pos.z - r->z); + floor = XZ_GET_SECTOR(r, pos.x - r->x, pos.z - r->z); if (floor->stopper) { for (i = 0; i < r->mesh.size(); i++) diff --git a/TR5Main/Objects/TR5/Entity/tr5_guard.cpp b/TR5Main/Objects/TR5/Entity/tr5_guard.cpp index e69620cf6..d1fe86888 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_guard.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_guard.cpp @@ -11,6 +11,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" BITE_INFO SwatGun = { 80, 200, 13, 0 }; BITE_INFO SniperGun = { 0, 480, 110, 13 }; diff --git a/TR5Main/Objects/TR5/Entity/tr5_hydra.cpp b/TR5Main/Objects/TR5/Entity/tr5_hydra.cpp index 361f0c24d..028268d88 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_hydra.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_hydra.cpp @@ -10,6 +10,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" #define STATE_HYDRA_STOP 0 #define STATE_HYDRA_BITE_ATTACK1 1 diff --git a/TR5Main/Objects/TR5/Entity/tr5_imp.cpp b/TR5Main/Objects/TR5/Entity/tr5_imp.cpp index c3b9f2e91..e3b4d9f8a 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_imp.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_imp.cpp @@ -8,6 +8,7 @@ #include "box.h" #include "setup.h" #include "level.h" +#include "creature_info.h" #include "control.h" #define STATE_IMP_WALK 0 @@ -307,4 +308,4 @@ void ImpControl(short itemNumber) CreatureJoint(item, 2, joint2); CreatureAnimation(itemNumber, angle, 0); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Entity/tr5_lagoon_witch.cpp b/TR5Main/Objects/TR5/Entity/tr5_lagoon_witch.cpp index 2492499bb..40e387477 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_lagoon_witch.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_lagoon_witch.cpp @@ -12,6 +12,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #define STATE_LAGOON_WITCH_SWIM 1 #define STATE_LAGOON_WITCH_STOP 2 diff --git a/TR5Main/Objects/TR5/Entity/tr5_larson.cpp b/TR5Main/Objects/TR5/Entity/tr5_larson.cpp index 3425034ac..8ec3f9e49 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_larson.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_larson.cpp @@ -9,8 +9,8 @@ #include "lara.h" #include "setup.h" #include "level.h" +#include "creature_info.h" #include "control.h" - #define STATE_TR5_LARSON_STOP 1 #define STATE_TR5_LARSON_WALK 2 #define STATE_TR5_LARSON_RUN 3 @@ -417,4 +417,4 @@ void LarsonControl(short itemNumber) KillItem(itemNumber); } }*/ -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Entity/tr5_laser_head.cpp b/TR5Main/Objects/TR5/Entity/tr5_laser_head.cpp index ee0415a03..83b2ac6bf 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_laser_head.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_laser_head.cpp @@ -14,13 +14,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" - -struct LASER_HEAD_INFO -{ - short baseItem; - short tentacles[8]; - short puzzleItem; -}; +#include "tr5_laserhead_info.h" struct LASER_HEAD_STRUCT { @@ -152,8 +146,8 @@ void InitialiseLaserHead(short itemNumber) { ITEM_INFO* item = &g_Level.Items[itemNumber]; - item->data = game_malloc(); - LASER_HEAD_INFO* info = (LASER_HEAD_INFO*)item->data; + item->data = LASER_HEAD_INFO(); + LASER_HEAD_INFO* info = item->data; for (int i = 0; i < g_Level.NumItems; i++) { diff --git a/TR5Main/Objects/TR5/Entity/tr5_laserhead_info.h b/TR5Main/Objects/TR5/Entity/tr5_laserhead_info.h new file mode 100644 index 000000000..2bfe8c9d7 --- /dev/null +++ b/TR5Main/Objects/TR5/Entity/tr5_laserhead_info.h @@ -0,0 +1,6 @@ +#pragma once +struct LASER_HEAD_INFO { + short baseItem; + short tentacles[8]; + short puzzleItem; +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR5/Entity/tr5_lion.cpp b/TR5Main/Objects/TR5/Entity/tr5_lion.cpp index b13a46a4a..9be3f7f91 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_lion.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_lion.cpp @@ -9,6 +9,7 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" BITE_INFO LionBite1 = { -2, -10, 250, 21 }; diff --git a/TR5Main/Objects/TR5/Entity/tr5_reaper.cpp b/TR5Main/Objects/TR5/Entity/tr5_reaper.cpp index ad5c17ef6..224c6c68d 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_reaper.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_reaper.cpp @@ -5,8 +5,8 @@ #include "setup.h" #include "level.h" #include "lara.h" +#include "creature_info.h" #include "control.h" - void InitialiseReaper(short itemNum) { ITEM_INFO* item; @@ -61,4 +61,4 @@ void ReaperControl(short itemNumber) CreatureAnimation(itemNumber, angle, 0); CreatureUnderwater(item, 1024); } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Entity/tr5_roman_statue.cpp b/TR5Main/Objects/TR5/Entity/tr5_roman_statue.cpp index 0635c8547..a120729ce 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_roman_statue.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_roman_statue.cpp @@ -13,6 +13,7 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" #define STATE_ROMAN_STATUE_STOP 1 #define STATE_ROMAN_STATUE_SCREAMING 2 @@ -599,7 +600,7 @@ void RomanStatueControl(short itemNumber) GetJointAbsPosition(item, &pos, 16); room = &g_Level.Rooms[item->roomNumber]; - floor = &XZ_GET_SECTOR(room, pos.x - room->x, pos.z - room->z); + floor = XZ_GET_SECTOR(room, pos.x - room->x, pos.z - room->z); // If floor is stopped, then try to find static meshes and shatter them, activating heavy triggers below if (floor->stopper) diff --git a/TR5Main/Objects/TR5/Entity/tr5_submarine.cpp b/TR5Main/Objects/TR5/Entity/tr5_submarine.cpp index 5c455d588..ef307764e 100644 --- a/TR5Main/Objects/TR5/Entity/tr5_submarine.cpp +++ b/TR5Main/Objects/TR5/Entity/tr5_submarine.cpp @@ -13,6 +13,8 @@ #include "level.h" #include "lara.h" #include "Sound\sound.h" +#include "creature_info.h" +#include "collide.h" static void TriggerSubmarineSparks(short itemNumber) { diff --git a/TR5Main/Objects/TR5/Object/tr5_bodypart.cpp b/TR5Main/Objects/TR5/Object/tr5_bodypart.cpp index 8d0fa3bd2..9d4e84674 100644 --- a/TR5Main/Objects/TR5/Object/tr5_bodypart.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_bodypart.cpp @@ -4,7 +4,8 @@ #include "Specific\trmath.h" #include "Sound\sound.h" #include "tr5_missile.h" - +#include "control.h" +#include "items.h" void ControlBodyPart(short fxNumber) { FX_INFO* fx = &EffectList[fxNumber]; diff --git a/TR5Main/Objects/TR5/Object/tr5_expandingplatform.cpp b/TR5Main/Objects/TR5/Object/tr5_expandingplatform.cpp index dadd90bb3..186d7222a 100644 --- a/TR5Main/Objects/TR5/Object/tr5_expandingplatform.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_expandingplatform.cpp @@ -8,7 +8,7 @@ #include "Sound\sound.h" #include "camera.h" #include "lara.h" - +#include "collide.h" void InitialiseExpandingPlatform(short itemNumber) { ITEM_INFO* item = &g_Level.Items[itemNumber]; diff --git a/TR5Main/Objects/TR5/Object/tr5_missile.cpp b/TR5Main/Objects/TR5/Object/tr5_missile.cpp index 301a20ce5..d4fe15070 100644 --- a/TR5Main/Objects/TR5/Object/tr5_missile.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_missile.cpp @@ -14,6 +14,7 @@ #include "Sound\sound.h" #include "tr5_roman_statue.h" #include "tr5_hydra.h" +#include "collide.h" int DebrisFlags; diff --git a/TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp b/TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp index b20d30326..1c4035547 100644 --- a/TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp @@ -9,7 +9,8 @@ #include "level.h" #include "input.h" #include "Sound\sound.h" -#define GET_PUSHABLEINFO(item) ((PUSHABLE_INFO*) item->data) +#include "setup.h" +#include "tr5_pushableblock_info.h" static OBJECT_COLLISION_BOUNDS PushableBlockBounds = { 0x0000, 0x0000, 0xFFC0, 0x0000, @@ -69,7 +70,8 @@ void InitialisePushableBlock(short itemNum) ClearMovableBlockSplitters(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); // allocate new pushable info - PUSHABLE_INFO* pushable = new PUSHABLE_INFO; + item->data = PUSHABLE_INFO(); + PUSHABLE_INFO* pushable = item->data; pushable->stackLimit = 3; // LUA pushable->gravity = 8; // LUA @@ -111,8 +113,6 @@ void InitialisePushableBlock(short itemNum) pushable->stopSound = SFX_TR4_PUSH_BLOCK_END; // LUA pushable->fallSound = SFX_TR4_BOULDER_FALL; // LUA - item->data = (void*) pushable; - FindStack(itemNum); // check for stack formation when pushables are initialised } @@ -132,7 +132,7 @@ void PushableBlockControl(short itemNumber) short roomNumber; FLOOR_INFO* floor; ROOM_INFO* r; - PUSHABLE_INFO* pushable = GET_PUSHABLEINFO(item); + PUSHABLE_INFO* pushable = item->data; int blockHeight = GetStackHeight(item); // do sound effects, it works for now @@ -381,7 +381,7 @@ void PushableBlockCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) short roomNumber = item->roomNumber; FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &roomNumber); - PUSHABLE_INFO* pushable = GET_PUSHABLEINFO(item); + PUSHABLE_INFO* pushable = item->data; int blockHeight = GetStackHeight(item); @@ -584,13 +584,13 @@ int TestBlockPush(ITEM_INFO* item, int blockhite, unsigned short quadrant) auto collResult = GetCollisionResult(x, y - blockhite, z, item->roomNumber); ROOM_INFO* r = &g_Level.Rooms[collResult.RoomNumber]; - if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper) + if (XZ_GET_SECTOR(r, x - r->x, z - r->z)->stopper) return 0; if (collResult.Position.Type) return 0; - if (GET_PUSHABLEINFO(item)->canFall) + if (((PUSHABLE_INFO*)item->data)->canFall) { if (collResult.Position.Floor < y) return 0; @@ -669,7 +669,7 @@ int TestBlockPull(ITEM_INFO* item, int blockhite, short quadrant) short roomNum = item->roomNumber; ROOM_INFO* r = &g_Level.Rooms[roomNum]; - if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper) + if (XZ_GET_SECTOR(r, x - r->x, z - r->z)->stopper) return 0; auto collResult = GetCollisionResult(x, y - blockhite, z, item->roomNumber); @@ -739,7 +739,7 @@ int TestBlockPull(ITEM_INFO* item, int blockhite, short quadrant) collResult = GetCollisionResult(x, y - LARA_HEIGHT, z, LaraItem->roomNumber); r = &g_Level.Rooms[roomNum]; - if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper) + if (XZ_GET_SECTOR(r, x - r->x, z - r->z)->stopper) return 0; if (collResult.Position.Floor != y) @@ -833,8 +833,8 @@ void MoveStackY(short itemNum, int y) void AddBridgeStack(short itemNum) { auto item = &g_Level.Items[itemNum]; - - if (GET_PUSHABLEINFO(item)->hasFloorCeiling) + PUSHABLE_INFO* pushable = item->data; + if (pushable->hasFloorCeiling) TEN::Floordata::AddBridge(itemNum); int stackIndex = g_Level.Items[itemNum].itemFlags[1]; @@ -842,7 +842,7 @@ void AddBridgeStack(short itemNum) { auto stackItem = &g_Level.Items[stackIndex]; - if (GET_PUSHABLEINFO(stackItem)->hasFloorCeiling) + if (pushable->hasFloorCeiling) TEN::Floordata::AddBridge(stackIndex); stackIndex = g_Level.Items[stackIndex].itemFlags[1]; @@ -852,8 +852,9 @@ void AddBridgeStack(short itemNum) void RemoveBridgeStack(short itemNum) { auto item = &g_Level.Items[itemNum]; + PUSHABLE_INFO* pushable = item->data; - if (GET_PUSHABLEINFO(item)->hasFloorCeiling) + if (pushable->hasFloorCeiling) TEN::Floordata::RemoveBridge(itemNum); int stackIndex = g_Level.Items[itemNum].itemFlags[1]; @@ -861,7 +862,7 @@ void RemoveBridgeStack(short itemNum) { auto stackItem = &g_Level.Items[stackIndex]; - if (GET_PUSHABLEINFO(stackItem)->hasFloorCeiling) + if (pushable->hasFloorCeiling) TEN::Floordata::RemoveBridge(stackIndex); stackIndex = g_Level.Items[stackIndex].itemFlags[1]; @@ -928,13 +929,14 @@ int FindStack(short itemNum) int GetStackHeight(ITEM_INFO* item) { - int height = GET_PUSHABLEINFO(item)->height; + PUSHABLE_INFO* pushable = item->data; + int height = pushable->height; auto stackItem = item; while (stackItem->itemFlags[1] != NO_ITEM) { stackItem = &g_Level.Items[stackItem->itemFlags[1]]; - height += GET_PUSHABLEINFO(stackItem)->height; + height += pushable->height; } return height; @@ -942,7 +944,9 @@ int GetStackHeight(ITEM_INFO* item) bool CheckStackLimit(ITEM_INFO* item) { - int limit = GET_PUSHABLEINFO(item)->stackLimit; + PUSHABLE_INFO* pushable = item->data; + + int limit = pushable->stackLimit; int count = 1; auto stackItem = item; @@ -961,7 +965,7 @@ bool CheckStackLimit(ITEM_INFO* item) std::optional PushableBlockFloor(short itemNumber, int x, int y, int z) { const auto& item = g_Level.Items[itemNumber]; - const auto& pushable = *(PUSHABLE_INFO*)item.data; + const auto& pushable = (PUSHABLE_INFO&)item.data; if (item.status != ITEM_INVISIBLE && pushable.hasFloorCeiling) { @@ -974,7 +978,7 @@ std::optional PushableBlockFloor(short itemNumber, int x, int y, int z) std::optional PushableBlockCeiling(short itemNumber, int x, int y, int z) { const auto& item = g_Level.Items[itemNumber]; - const auto& pushable = *(PUSHABLE_INFO*)item.data; + const auto& pushable = (PUSHABLE_INFO&)item.data; if (item.status != ITEM_INVISIBLE && pushable.hasFloorCeiling) return std::optional{item.pos.yPos}; diff --git a/TR5Main/Objects/TR5/Object/tr5_pushableblock.h b/TR5Main/Objects/TR5/Object/tr5_pushableblock.h index 057bf311c..51b27d072 100644 --- a/TR5Main/Objects/TR5/Object/tr5_pushableblock.h +++ b/TR5Main/Objects/TR5/Object/tr5_pushableblock.h @@ -1,29 +1,8 @@ #pragma once -#include "items.h" -#include "collide.h" +struct ITEM_INFO; +struct COLL_INFO; + -struct PUSHABLE_INFO -{ - int height; // height for collision, also in floor procedure - int weight; - int stackLimit; - int moveX; // used for pushable movement code - int moveZ; // used for pushable movement code - short linkedIndex; // using itemFlags[1] for now - short gravity; // fall acceleration - short loopSound; // looped sound index for movement - short stopSound; // ending sound index - short fallSound; // sound on hitting floor (if dropped) - short climb; // not used for now - bool canFall; // OCB 32 - bool hasFloorCeiling; // has floor and ceiling procedures (OCB 64) - bool disablePull; // OCB 128 - bool disablePush; // OCB 256 - bool disableW; // OCB 512 (W+E) - bool disableE; // OCB 512 (W+E) - bool disableN; // OCB 1024 (N+S) - bool disableS; // OCB 1024 (N+S) -}; void ClearMovableBlockSplitters(int x, int y, int z, short roomNumber); void InitialisePushableBlock(short itemNum); diff --git a/TR5Main/Objects/TR5/Object/tr5_pushableblock_info.h b/TR5Main/Objects/TR5/Object/tr5_pushableblock_info.h new file mode 100644 index 000000000..a1a41638b --- /dev/null +++ b/TR5Main/Objects/TR5/Object/tr5_pushableblock_info.h @@ -0,0 +1,22 @@ +#pragma once +struct PUSHABLE_INFO { + int height; // height for collision, also in floor procedure + int weight; + int stackLimit; + int moveX; // used for pushable movement code + int moveZ; // used for pushable movement code + short linkedIndex; // using itemFlags[1] for now + short gravity; // fall acceleration + short loopSound; // looped sound index for movement + short stopSound; // ending sound index + short fallSound; // sound on hitting floor (if dropped) + short climb; // not used for now + bool canFall; // OCB 32 + bool hasFloorCeiling; // has floor and ceiling procedures (OCB 64) + bool disablePull; // OCB 128 + bool disablePush; // OCB 256 + bool disableW; // OCB 512 (W+E) + bool disableE; // OCB 512 (W+E) + bool disableN; // OCB 1024 (N+S) + bool disableS; // OCB 1024 (N+S) +}; \ No newline at end of file diff --git a/TR5Main/Objects/TR5/Object/tr5_rollingball.cpp b/TR5Main/Objects/TR5/Object/tr5_rollingball.cpp index 8178dde95..e05d26c58 100644 --- a/TR5Main/Objects/TR5/Object/tr5_rollingball.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_rollingball.cpp @@ -7,6 +7,7 @@ #include "setup.h" #include "Sound\sound.h" #include "effects\effects.h" +#include "level.h" void RollingBallCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) { diff --git a/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp b/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp index 94980b98d..81b74958b 100644 --- a/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp @@ -6,7 +6,7 @@ #include "Sound\sound.h" #include "lara.h" #include "camera.h" - +#include "Box.h" void InitialiseTeleporter(short itemNumber) { /*ITEM_INFO* item = &g_Level.Items[itemNumber]; diff --git a/TR5Main/Objects/TR5/Object/tr5_twoblockplatform.cpp b/TR5Main/Objects/TR5/Object/tr5_twoblockplatform.cpp index 3ce2f3e8e..f8d955333 100644 --- a/TR5Main/Objects/TR5/Object/tr5_twoblockplatform.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_twoblockplatform.cpp @@ -5,6 +5,7 @@ #include "items.h" #include "lara.h" #include "Sound\sound.h" +#include "collide.h" void InitialiseTwoBlocksPlatform(short itemNumber) { diff --git a/TR5Main/Objects/TR5/Shatter/tr5_smashobject.cpp b/TR5Main/Objects/TR5/Shatter/tr5_smashobject.cpp index b35865eb1..cee6ea950 100644 --- a/TR5Main/Objects/TR5/Shatter/tr5_smashobject.cpp +++ b/TR5Main/Objects/TR5/Shatter/tr5_smashobject.cpp @@ -14,7 +14,7 @@ void InitialiseSmashObject(short itemNumber) item->meshBits = 1; ROOM_INFO* r = &g_Level.Rooms[item->roomNumber]; - FLOOR_INFO* floor = &XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z); + FLOOR_INFO* floor = XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z); BOX_INFO* box = &g_Level.Boxes[floor->box]; if (box->flags & 0x8000) box->flags |= BLOCKED; diff --git a/TR5Main/Objects/TR5/Switch/tr5_crowdove_switch.cpp b/TR5Main/Objects/TR5/Switch/tr5_crowdove_switch.cpp index 13b46b1f8..3d97c95c4 100644 --- a/TR5Main/Objects/TR5/Switch/tr5_crowdove_switch.cpp +++ b/TR5Main/Objects/TR5/Switch/tr5_crowdove_switch.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "generic_switch.h" #include "Sound\sound.h" +#include "box.h" using namespace TEN::Entities::Switches; diff --git a/TR5Main/Objects/TR5/Trap/tr5_deathslide.cpp b/TR5Main/Objects/TR5/Trap/tr5_deathslide.cpp index 8ebd4402e..920cfd729 100644 --- a/TR5Main/Objects/TR5/Trap/tr5_deathslide.cpp +++ b/TR5Main/Objects/TR5/Trap/tr5_deathslide.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "setup.h" #include "Sound\sound.h" +#include "box.h" OBJECT_COLLISION_BOUNDS DeathSlideBounds = { -256, 256, -100, 100, 256, 512, 0, 0, -ANGLE(25.0f), ANGLE(25.0f), 0, 0 }; PHD_VECTOR DeathSlidePosition(0, 0, 371); @@ -12,8 +13,8 @@ PHD_VECTOR DeathSlidePosition(0, 0, 371); void InitialiseDeathSlide(short itemNumber) { ITEM_INFO* item = &g_Level.Items[itemNumber]; - GAME_VECTOR* pos = game_malloc(); - item->data = pos; + item->data = GAME_VECTOR(); + GAME_VECTOR* pos = item->data; pos->x = item->pos.xPos; pos->y = item->pos.yPos; pos->z = item->pos.zPos; diff --git a/TR5Main/Objects/TR5/Trap/tr5_explosion.cpp b/TR5Main/Objects/TR5/Trap/tr5_explosion.cpp index dfdb5854b..4a47e19dc 100644 --- a/TR5Main/Objects/TR5/Trap/tr5_explosion.cpp +++ b/TR5Main/Objects/TR5/Trap/tr5_explosion.cpp @@ -13,7 +13,7 @@ #include "switch.h" #include "effects\debris.h" #include "generic_switch.h" - +#include "collide.h" using namespace TEN::Entities::Switches; void InitialiseExplosion(short itemNumber) diff --git a/TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp b/TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp index cbeb9ac6a..da99757f7 100644 --- a/TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp +++ b/TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp @@ -49,4 +49,4 @@ void FallingCeilingControl(short itemNumber) } } } -} \ No newline at end of file +} diff --git a/TR5Main/Objects/TR5/Trap/tr5_teethspike.cpp b/TR5Main/Objects/TR5/Trap/tr5_teethspike.cpp index 26b7897d5..02b288356 100644 --- a/TR5Main/Objects/TR5/Trap/tr5_teethspike.cpp +++ b/TR5Main/Objects/TR5/Trap/tr5_teethspike.cpp @@ -7,6 +7,7 @@ #include "Sound\sound.h" #include "effects\tomb4fx.h" #include "Specific\trmath.h" +#include "setup.h" short SPyoffs[8] = { diff --git a/TR5Main/Objects/TR5/tr5_objects.cpp b/TR5Main/Objects/TR5/tr5_objects.cpp index 649251d4a..cf883bd54 100644 --- a/TR5Main/Objects/TR5/tr5_objects.cpp +++ b/TR5Main/Objects/TR5/tr5_objects.cpp @@ -67,7 +67,8 @@ #include "level.h" /// register objects #include "object_helper.h" - +#include "creature_info.h" +#include "Box.h" using namespace TEN::Entities::TR5; static void StartBaddy(OBJECT_INFO *obj) @@ -1314,12 +1315,7 @@ void InitialiseTR5Objects() void AllocTR5Objects() { - Bats = game_malloc(NUM_BATS); ZeroMemory(Bats, NUM_BATS * sizeof(BAT_STRUCT)); - - Spiders = game_malloc(NUM_SPIDERS); ZeroMemory(Spiders, NUM_SPIDERS * sizeof(SPIDER_STRUCT)); - - Rats = game_malloc(NUM_RATS); ZeroMemory(Rats, NUM_RATS * sizeof(RAT_STRUCT)); } \ No newline at end of file diff --git a/TR5Main/Renderer/Render11Helper.cpp b/TR5Main/Renderer/Render11Helper.cpp index d8cf06de0..90bd50a23 100644 --- a/TR5Main/Renderer/Render11Helper.cpp +++ b/TR5Main/Renderer/Render11Helper.cpp @@ -17,7 +17,13 @@ #include "jeep.h" #include "motorbike.h" #include - +#include "creature_info.h" +#include "quad_info.h" +#include "jeep_info.h" +#include "motorbike_info.h" +#include "rubberboat_info.h" +#include "upv_info.h" +#include "biggun_info.h" extern GameConfiguration g_Configuration; extern GameFlow *g_GameFlow; @@ -217,91 +223,73 @@ namespace TEN::Renderer { RendererBone *currentBone = moveableObj.LinearizedBones[j]; currentBone->ExtraRotation = Vector3(0.0f, 0.0f, 0.0f); - - if (item->objectNumber == ID_QUAD) - { - QUAD_INFO* quad = (QUAD_INFO*)item->data; - if (j == 3 || j == 4) { - currentBone->ExtraRotation.x = TO_RAD(quad->rearRot); - } - else if (j == 6 || j == 7) { - currentBone->ExtraRotation.x = TO_RAD(quad->frontRot); - } + + item->data.apply( + [&j, ¤tBone](QUAD_INFO& quad) { + if(j == 3 || j == 4) { + currentBone->ExtraRotation.x = TO_RAD(quad.rearRot); + } else if(j == 6 || j == 7) { + currentBone->ExtraRotation.x = TO_RAD(quad.frontRot); } - else if (item->objectNumber == ID_JEEP) { - JEEP_INFO* jeep = (JEEP_INFO*)item->data; - switch (j) { - case 9: - currentBone->ExtraRotation.x = TO_RAD(jeep->rot1); - break; - case 10: - currentBone->ExtraRotation.x = TO_RAD(jeep->rot2); + }, + [&j, ¤tBone](JEEP_INFO& jeep) { + switch(j) { + case 9: + currentBone->ExtraRotation.x = TO_RAD(jeep.rot1); + break; + case 10: + currentBone->ExtraRotation.x = TO_RAD(jeep.rot2); - break; - case 12: - currentBone->ExtraRotation.x = TO_RAD(jeep->rot3); + break; + case 12: + currentBone->ExtraRotation.x = TO_RAD(jeep.rot3); - break; - case 13: - currentBone->ExtraRotation.x = TO_RAD(jeep->rot4); + break; + case 13: + currentBone->ExtraRotation.x = TO_RAD(jeep.rot4); - break; - } + break; } - else if (item->objectNumber == ID_MOTORBIKE) { - MOTORBIKE_INFO* bike = (MOTORBIKE_INFO*)item->data; - switch (j) { - case 2: - case 4: - currentBone->ExtraRotation.x = TO_RAD(bike->wheelRight); - break; - case 10: - currentBone->ExtraRotation.x = TO_RAD(bike->wheelLeft); - } + }, + [&j, ¤tBone](MOTORBIKE_INFO& bike) { + switch(j) { + case 2: + case 4: + currentBone->ExtraRotation.x = TO_RAD(bike.wheelRight); + break; + case 10: + currentBone->ExtraRotation.x = TO_RAD(bike.wheelLeft); } - else if (item->objectNumber == ID_RUBBER_BOAT) - { - RUBBER_BOAT_INFO* boat = (RUBBER_BOAT_INFO*)item->data; - if (j == 2) - currentBone->ExtraRotation.z = TO_RAD(boat->propRot); + }, + [&j, ¤tBone](RUBBER_BOAT_INFO& boat) { + if(j == 2) + currentBone->ExtraRotation.z = TO_RAD(boat.propRot); + }, + [&j, ¤tBone](SUB_INFO& upv) { + if(j == 3) + currentBone->ExtraRotation.z = TO_RAD(upv.FanRot); + }, + [&j, ¤tBone](BIGGUNINFO& biggun) { + if(j == 2) + currentBone->ExtraRotation.z = biggun.barrelZ; + }, + [&j, ¤tBone, &lastJoint](CREATURE_INFO& creature) { + if(currentBone->ExtraRotationFlags & ROT_Y) { + currentBone->ExtraRotation.y = TO_RAD(creature.jointRotation[lastJoint]); + lastJoint++; } - else if (item->objectNumber == ID_UPV) - { - SUB_INFO* upv = (SUB_INFO*)item->data; - if (j == 3) - currentBone->ExtraRotation.z = TO_RAD(upv->FanRot); - } - else if (item->objectNumber == ID_BIGGUN) - { - BIGGUNINFO* biggun = (BIGGUNINFO*)item->data; - if (j == 2) - currentBone->ExtraRotation.z = biggun->barrelZ; - } - else - { - CREATURE_INFO* creature = (CREATURE_INFO*)item->data; - if (creature != NULL) - { - if (currentBone->ExtraRotationFlags & ROT_Y) - { - currentBone->ExtraRotation.y = TO_RAD(creature->jointRotation[lastJoint]); - lastJoint++; - } + if(currentBone->ExtraRotationFlags & ROT_X) { + currentBone->ExtraRotation.x = TO_RAD(creature.jointRotation[lastJoint]); + lastJoint++; + } - if (currentBone->ExtraRotationFlags & ROT_X) - { - currentBone->ExtraRotation.x = TO_RAD(creature->jointRotation[lastJoint]); - lastJoint++; - } - - if (currentBone->ExtraRotationFlags & ROT_Z) - { - currentBone->ExtraRotation.z = TO_RAD(creature->jointRotation[lastJoint]); - lastJoint++; - } - } - } + if(currentBone->ExtraRotationFlags & ROT_Z) { + currentBone->ExtraRotation.z = TO_RAD(creature.jointRotation[lastJoint]); + lastJoint++; + } + } + ); } ANIM_FRAME* framePtr[2]; @@ -325,7 +313,6 @@ namespace TEN::Renderer { RendererItem *itemToDraw = view.itemsToDraw[i]; ITEM_INFO *item = itemToDraw->Item; - CREATURE_INFO *creature = (CREATURE_INFO *)item->data; // Lara has her own routine if (item->objectNumber == ID_LARA) diff --git a/TR5Main/Renderer/Renderer11Draw2D.cpp b/TR5Main/Renderer/Renderer11Draw2D.cpp index 015de6a33..8636e9f42 100644 --- a/TR5Main/Renderer/Renderer11Draw2D.cpp +++ b/TR5Main/Renderer/Renderer11Draw2D.cpp @@ -14,7 +14,7 @@ TEN::Renderer::RendererHUDBar* g_SFXVolumeBar; namespace TEN::Renderer { void Renderer11::initialiseBars() -{ + { std::array healthColors = { //top Vector4(82 / 255.0f,0,0,1), diff --git a/TR5Main/Renderer/Renderer11DrawEffect.cpp b/TR5Main/Renderer/Renderer11DrawEffect.cpp index 2370a65e5..3b868e9b7 100644 --- a/TR5Main/Renderer/Renderer11DrawEffect.cpp +++ b/TR5Main/Renderer/Renderer11DrawEffect.cpp @@ -19,6 +19,7 @@ #include "Quad/RenderQuad.h" #include #include +#include "control.h" extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD]; extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE]; diff --git a/TR5Main/Scripting/GameLogicScript.cpp b/TR5Main/Scripting/GameLogicScript.cpp index 4b4ff400f..ef4fede63 100644 --- a/TR5Main/Scripting/GameLogicScript.cpp +++ b/TR5Main/Scripting/GameLogicScript.cpp @@ -14,7 +14,7 @@ #include "pickup\pickup.h" #include "newinv2.h" #include "ObjectIDs.h" - +#include "camera.h" /*** Functions and callbacks for level-specific logic scripts. @files Level-specific diff --git a/TR5Main/Specific/input.cpp b/TR5Main/Specific/input.cpp index c2b2432da..2bf798ca5 100644 --- a/TR5Main/Specific/input.cpp +++ b/TR5Main/Specific/input.cpp @@ -5,6 +5,7 @@ #include "camera.h" #include "Sound\sound.h" #include "savegame.h" +#include "Renderer11.h" using TEN::Renderer::g_Renderer; diff --git a/TR5Main/Specific/level.cpp b/TR5Main/Specific/level.cpp index d0896366b..d0384968b 100644 --- a/TR5Main/Specific/level.cpp +++ b/TR5Main/Specific/level.cpp @@ -15,6 +15,7 @@ #include "GameFlowScript.h" #include #include +#include "Renderer11.h" using TEN::Renderer::g_Renderer; using std::vector; using std::string; @@ -813,34 +814,32 @@ void LoadRooms() void FreeLevel() { - malloc_ptr = malloc_buffer; - malloc_free = malloc_size; - g_Level.RoomTextures.clear(); - g_Level.MoveablesTextures.clear(); - g_Level.StaticsTextures.clear(); - g_Level.AnimatedTextures.clear(); - g_Level.SpritesTextures.clear(); - g_Level.AnimatedTexturesSequences.clear(); - g_Level.Rooms.clear(); - g_Level.ObjectTextures.clear(); - g_Level.Bones.clear(); - g_Level.Meshes.clear(); - MoveablesIds.clear(); - g_Level.Boxes.clear(); - g_Level.Overlaps.clear(); - g_Level.Anims.clear(); - g_Level.Changes.clear(); - g_Level.Ranges.clear(); - g_Level.Commands.clear(); - g_Level.Frames.clear(); - g_Level.Sprites.clear(); - g_Level.SoundDetails.clear(); - g_Level.SoundMap.clear(); - g_Level.FloorData.clear(); - g_Level.Cameras.clear(); - g_Level.Sinks.clear(); - g_Level.SoundSources.clear(); - g_Level.AIObjects.clear(); + g_Level.RoomTextures.resize(0); + g_Level.MoveablesTextures.resize(0); + g_Level.StaticsTextures.resize(0); + g_Level.AnimatedTextures.resize(0); + g_Level.SpritesTextures.resize(0); + g_Level.AnimatedTexturesSequences.resize(0); + g_Level.Rooms.resize(0); + g_Level.ObjectTextures.resize(0); + g_Level.Bones.resize(0); + g_Level.Meshes.resize(0); + MoveablesIds.resize(0); + g_Level.Boxes.resize(0); + g_Level.Overlaps.resize(0); + g_Level.Anims.resize(0); + g_Level.Changes.resize(0); + g_Level.Ranges.resize(0); + g_Level.Commands.resize(0); + g_Level.Frames.resize(0); + g_Level.Sprites.resize(0); + g_Level.SoundDetails.resize(0); + g_Level.SoundMap.resize(0); + g_Level.FloorData.resize(0); + g_Level.Cameras.resize(0); + g_Level.Sinks.resize(0); + g_Level.SoundSources.resize(0); + g_Level.AIObjects.resize(0); for (int i = 0; i < 2; i++) { @@ -1056,7 +1055,7 @@ unsigned CALLBACK LoadLevel(void* data) LoadBoxes(); - InitialiseLOTarray(true); + //InitialiseLOTarray(true); LoadAnimatedTextures(); LoadTextureInfos(); diff --git a/TR5Main/Specific/level.h b/TR5Main/Specific/level.h index cbc1c2e02..fdc114077 100644 --- a/TR5Main/Specific/level.h +++ b/TR5Main/Specific/level.h @@ -6,7 +6,7 @@ #include "newtypes.h" #include "items.h" #include "room.h" - +#include "item.h" #define AddPtr(p, t, n) p = (t*)((char*)(p) + (ptrdiff_t)(n)); #define MESHES(slot, mesh) (Objects[slot].meshIndex + mesh) diff --git a/TR5Main/Specific/phd_global.h b/TR5Main/Specific/phd_global.h index 85f12adbf..976d51ee1 100644 --- a/TR5Main/Specific/phd_global.h +++ b/TR5Main/Specific/phd_global.h @@ -130,8 +130,8 @@ struct LEVEL_CAMERA_INFO this->x = 0; this->y = 0; this->z = 0; - this->roomNumber = NULL; - this->flags = NULL; + this->roomNumber = 0; + this->flags = 0x0; } LEVEL_CAMERA_INFO(int xpos, int ypos, int zpos) @@ -139,8 +139,8 @@ struct LEVEL_CAMERA_INFO this->x = xpos; this->y = ypos; this->z = zpos; - this->roomNumber = NULL; - this->flags = NULL; + this->roomNumber = 0; + this->flags = 0x0; } LEVEL_CAMERA_INFO(int xpos, int ypos, int zpos, short room) @@ -149,12 +149,11 @@ struct LEVEL_CAMERA_INFO this->y = ypos; this->z = zpos; this->roomNumber = room; - this->flags = NULL; + this->flags = 0x0; } LEVEL_CAMERA_INFO(int xpos, int ypos, int zpos, short flags, bool isFlags) // use isFlags to use flag instead of newdata ! { - UNREFERENCED_PARAMETER(isFlags); this->x = xpos; this->y = ypos; this->z = zpos; @@ -205,7 +204,7 @@ struct SINK_INFO this->y = ypos; this->z = zpos; this->strength = strength; - this->boxIndex = NULL; + this->boxIndex = 0; } SINK_INFO(int xpos, int ypos, int zpos, short strength, short boxIndex) @@ -232,8 +231,8 @@ struct SOUND_SOURCE_INFO this->x = 0; this->y = 0; this->z = 0; - this->soundId = NULL; - this->flags = NULL; + this->soundId = 0; + this->flags = 0x0; } SOUND_SOURCE_INFO(int xpos, int ypos, int zpos) @@ -241,8 +240,8 @@ struct SOUND_SOURCE_INFO this->x = xpos; this->y = ypos; this->z = zpos; - this->soundId = NULL; - this->flags = NULL; + this->soundId = 0; + this->flags = 0x0; } SOUND_SOURCE_INFO(int xpos, int ypos, int zpos, short soundId) @@ -251,7 +250,7 @@ struct SOUND_SOURCE_INFO this->y = ypos; this->z = zpos; this->soundId = soundId; - this->flags = NULL; + this->flags = 0x0; } SOUND_SOURCE_INFO(int xpos, int ypos, int zpos, short soundId, short newflags) diff --git a/TR5Main/Specific/setup.cpp b/TR5Main/Specific/setup.cpp index 84b1149ba..f9d82a9f9 100644 --- a/TR5Main/Specific/setup.cpp +++ b/TR5Main/Specific/setup.cpp @@ -32,6 +32,7 @@ #include "generic_switch.h" #include "fullblock_switch.h" +#include "creature_info.h" using namespace TEN::Entities::Switches; diff --git a/TR5Main/Specific/setup.h b/TR5Main/Specific/setup.h index 4077dc335..65da7677a 100644 --- a/TR5Main/Specific/setup.h +++ b/TR5Main/Specific/setup.h @@ -1,8 +1,10 @@ #pragma once -#include "box.h" -#include "collide.h" -#include "objectslist.h" +#include "objectslist.h" +#include "phd_global.h" +struct ITEM_INFO; +struct COLL_INFO; +enum ZoneType : char; enum HitEffectEnum { HIT_NONE, diff --git a/TR5Main/TombEngine.vcxproj b/TR5Main/TombEngine.vcxproj index 638401854..455206624 100644 --- a/TR5Main/TombEngine.vcxproj +++ b/TR5Main/TombEngine.vcxproj @@ -64,9 +64,9 @@ Use TurnOffAllWarnings true - _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;CREATURE_AI_PRIORITY_OPTIMIZATION;%(PreprocessorDefinitions) false - $(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;%(AdditionalIncludeDirectories) + D:\Dokumente\TR5Main\TR5Main\Game\itemdata;$(SolutionDir)TR5Main\Game\itemdata;$(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL false true @@ -95,7 +95,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" Use TurnOffAllWarnings false - _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;CREATURE_AI_PRIORITY_OPTIMIZATION;%(PreprocessorDefinitions) false $(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;%(AdditionalIncludeDirectories) MultiThreadedDLL @@ -141,16 +141,23 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" + + + + + + + @@ -182,6 +189,18 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" + + + + + + + + + + + + @@ -480,13 +499,13 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" - + @@ -507,6 +526,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" + @@ -781,7 +801,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" - diff --git a/TR5Main/framework.h b/TR5Main/framework.h index b2f4c6cdb..8d30534d3 100644 --- a/TR5Main/framework.h +++ b/TR5Main/framework.h @@ -11,7 +11,6 @@ #include #include #include -#include "memory/malloc.h" #include "Game/debug/debug.h" #include #include