mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-09 03:58:19 +03:00
Integrated ITEM_DATA into ITEM_INFO
TODO: See what happens with ENEMY_JEEP
This commit is contained in:
parent
be16255efc
commit
f7080f56c9
37 changed files with 263 additions and 191 deletions
|
@ -63,7 +63,8 @@ void FlareControl(short itemNumber)
|
|||
|
||||
DoProperDetection(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,11 @@ void CreateFlare(GAME_OBJECT_ID objectNum, int thrown)
|
|||
|
||||
if (objectNum == ID_FLARE_ITEM)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
|
|
@ -364,7 +364,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 +403,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 +446,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;
|
||||
|
@ -1398,9 +1398,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;
|
||||
|
@ -1423,7 +1423,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;
|
||||
|
@ -1525,7 +1525,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;
|
||||
|
@ -1645,7 +1645,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;
|
||||
|
|
|
@ -53,6 +53,16 @@ enum MOOD_TYPE {
|
|||
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;
|
||||
|
||||
};
|
||||
struct CREATURE_INFO {
|
||||
short jointRotation[4];
|
||||
short maximumTurn;
|
||||
|
@ -67,7 +77,7 @@ struct CREATURE_INFO {
|
|||
bool monkeyAhead;
|
||||
MOOD_TYPE mood;
|
||||
ITEM_INFO* enemy;
|
||||
ITEM_INFO aiTarget;
|
||||
CREATURE_TARGET aiTarget;
|
||||
short pad;
|
||||
short itemNum;
|
||||
PHD_VECTOR target;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "floordata.h"
|
||||
struct ITEM_INFO;
|
||||
struct DOORPOS_DATA {
|
||||
FLOOR_INFO* floor;
|
||||
FLOOR_INFO data;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "framework.h"
|
||||
#include "trmath.h"
|
||||
#include "floordata.h"
|
||||
#include "trmath.h"
|
||||
#include "room.h"
|
||||
#include "level.h"
|
||||
#include "setup.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "trmath.h"
|
||||
#include "items.h"
|
||||
|
||||
#include <optional>
|
||||
#include "roomvector.h"
|
||||
struct SECTOR_COLLISION_INFO
|
||||
{
|
||||
float SplitAngle;
|
||||
|
@ -9,9 +9,8 @@ struct SECTOR_COLLISION_INFO
|
|||
Vector3 Planes[2];
|
||||
};
|
||||
|
||||
class FLOOR_INFO
|
||||
struct FLOOR_INFO
|
||||
{
|
||||
public:
|
||||
int index;
|
||||
int box;
|
||||
int fx;
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
#include <cstdint>
|
||||
#include "phd_global.h"
|
||||
#include <string>
|
||||
#include "itemdata.h"
|
||||
#include "roomvector.h"
|
||||
enum GAME_OBJECT_ID : short;
|
||||
|
||||
struct ROOM_VECTOR {
|
||||
int roomNumber;
|
||||
int yNumber;
|
||||
};
|
||||
|
||||
|
||||
struct ITEM_INFO {
|
||||
int floor;
|
||||
|
@ -35,7 +34,7 @@ struct ITEM_INFO {
|
|||
short afterDeath;
|
||||
short firedWeapon;
|
||||
short itemFlags[8];
|
||||
void* data;
|
||||
ITEM_DATA data;
|
||||
PHD_3DPOS pos;
|
||||
bool active;
|
||||
short status; // ItemStatus enum
|
||||
|
|
4
TR5Main/Game/itemdata/itemdata.cpp
Normal file
4
TR5Main/Game/itemdata/itemdata.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "framework.h"
|
||||
#include "itemdata.h"
|
||||
|
||||
ITEM_DATA::ITEM_DATA() : ITEM_DATA(ITEM_DATA_TYPE<std::nullptr_t>()) {}
|
|
@ -9,11 +9,21 @@
|
|||
#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 <stdexcept>
|
||||
#include "phd_global.h"
|
||||
#include "tr4_wraith_info.h"
|
||||
#include "tr5_pushableblock_info.h"
|
||||
|
||||
template<class... Ts> struct overload : Ts... { using Ts::operator()...; };
|
||||
template<class... Ts> overload(Ts...)->overload<Ts...>; // line not needed in C++20...
|
||||
|
||||
struct ITEM_INFO;
|
||||
|
||||
//Type Wrapper to construct a ITEM_DATA
|
||||
|
@ -23,10 +33,20 @@ struct ITEM_DATA_TYPE {
|
|||
};
|
||||
class ITEM_DATA {
|
||||
std::variant<std::nullptr_t,
|
||||
char,
|
||||
short,
|
||||
int,
|
||||
long,
|
||||
long long,
|
||||
unsigned char,
|
||||
unsigned short,
|
||||
unsigned int,
|
||||
unsigned long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double,
|
||||
long double,
|
||||
ITEM_INFO,
|
||||
ITEM_INFO*,
|
||||
CREATURE_INFO,
|
||||
LASER_HEAD_INFO,
|
||||
QUAD_INFO,
|
||||
|
@ -37,13 +57,22 @@ class ITEM_DATA {
|
|||
KAYAK_INFO,
|
||||
DOOR_DATA,
|
||||
SKIDOO_INFO,
|
||||
SUB_INFO
|
||||
SUB_INFO,
|
||||
BOAT_INFO,
|
||||
GAME_VECTOR,
|
||||
WRAITH_INFO,
|
||||
RUBBER_BOAT_INFO,
|
||||
PUSHABLE_INFO,
|
||||
CART_INFO
|
||||
> data;
|
||||
|
||||
public:
|
||||
ITEM_DATA();
|
||||
//we have to use a wrapper for a type, because the compiler needs to distinguish different overloads
|
||||
template<typename D>
|
||||
ITEM_DATA(ITEM_DATA_TYPE<D> type) : data(ITEM_DATA_TYPE::type{}) {
|
||||
}
|
||||
ITEM_DATA(ITEM_DATA_TYPE<D> type) : data(ITEM_DATA_TYPE<D>::type{}) {}
|
||||
|
||||
template<typename D>
|
||||
ITEM_DATA(D&& type) : data(type) {}
|
||||
|
||||
|
||||
// conversion operators to keep original syntax!
|
||||
|
@ -67,8 +96,34 @@ class ITEM_DATA {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T& operator=(T* newData){
|
||||
ITEM_DATA& operator=(T* newData) {
|
||||
data = *newData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ITEM_DATA& operator=(std::nullptr_t null) {
|
||||
data = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ITEM_DATA& operator=(T& newData) {
|
||||
data = newData;
|
||||
return *this;
|
||||
}
|
||||
template<typename T>
|
||||
ITEM_DATA& operator=(T&& newData) {
|
||||
data = newData;
|
||||
return *this;
|
||||
}
|
||||
operator bool() {
|
||||
return !std::holds_alternative<std::nullptr_t>(data);
|
||||
}
|
||||
struct foo {
|
||||
void operator()(double& d) {}
|
||||
};
|
||||
|
||||
auto& get() const {
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,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->drawRoom = (((item->pos.zPos - room->z) / SECTOR(1)) & 0xFF) | ((((item->pos.xPos - room->x) / SECTOR(1)) & 0xFF) * 256);
|
||||
item->TOSSPAD = item->pos.yRot & 0xE000;
|
||||
item->itemFlags[2] = item->roomNumber | ((item->pos.yPos - room->minfloor) & 0xFF00);
|
||||
|
|
5
TR5Main/Game/roomvector.h
Normal file
5
TR5Main/Game/roomvector.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
struct ROOM_VECTOR {
|
||||
int roomNumber;
|
||||
int yNumber;
|
||||
};
|
|
@ -1022,7 +1022,7 @@ bool SaveGame::readItemChunks(ChunkId* chunkId, int maxSize, int itemNumber)
|
|||
QUAD_INFO* quadInfo = game_malloc<QUAD_INFO>();
|
||||
m_stream->ReadBytes(reinterpret_cast<byte*>(quadInfo), sizeof(QUAD_INFO));
|
||||
if (item->objectNumber == ID_QUAD)
|
||||
item->data = (void*)quadInfo;
|
||||
item->data = quadInfo;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1418,7 +1418,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 +1465,8 @@ bool SaveGame::readTorpedo()
|
|||
|
||||
void SaveGame::saveItemQuadInfo(int itemNumber, int arg2)
|
||||
{
|
||||
m_stream->WriteBytes(reinterpret_cast<byte*>(g_Level.Items[itemNumber].data), sizeof(QUAD_INFO));
|
||||
|
||||
//m_stream->WriteBytes(reinterpret_cast<byte*>(g_Level.Items[itemNumber].data), sizeof(QUAD_INFO));
|
||||
}
|
||||
|
||||
void SaveGame::saveRats(int arg1, int arg2)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "sphere.h"
|
||||
#include "draw.h"
|
||||
#include "collide.h"
|
||||
#include "floordata.h"
|
||||
namespace TEN::Entities::Switches
|
||||
{
|
||||
OBJECT_COLLISION_BOUNDS SwitchBounds =
|
||||
|
|
|
@ -61,7 +61,7 @@ void DoppelgangerControl(short itemNum)
|
|||
|
||||
ref = findReference(item, ID_BACON_REFERENCE); // find reference point
|
||||
|
||||
if (item->data == NULL)
|
||||
if (!item->data)
|
||||
{
|
||||
if (ref == nullptr) // if no reference found, she doesn't move
|
||||
{
|
||||
|
@ -106,7 +106,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "lara.h"
|
||||
#include "sound.h"
|
||||
#include "creature_info.h"
|
||||
#include "floordata.h"
|
||||
BITE_INFO knifeLeft = { 0, 0, 0, 5 };
|
||||
BITE_INFO knifeRight = { 0, 0, 0, 8 };
|
||||
|
||||
|
|
|
@ -45,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++;
|
||||
}
|
||||
|
|
|
@ -495,7 +495,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;
|
||||
|
||||
|
@ -815,8 +815,8 @@ void InitialiseSpeedBoat(short itemNum)
|
|||
BOAT_INFO* binfo;
|
||||
|
||||
boat = &g_Level.Items[itemNum];
|
||||
binfo = game_malloc<BOAT_INFO>();
|
||||
boat->data = (void*)binfo;
|
||||
boat->data = ITEM_DATA(ITEM_DATA_TYPE<BOAT_INFO>());
|
||||
binfo = boat->data;
|
||||
binfo->boatTurn = 0;
|
||||
binfo->leftFallspeed = 0;
|
||||
binfo->rightFallspeed = 0;
|
||||
|
|
|
@ -79,9 +79,8 @@ enum SKIDOO_STATE
|
|||
void InitialiseSkidoo(short itemNum)
|
||||
{
|
||||
ITEM_INFO* skidoo = &g_Level.Items[itemNum];
|
||||
|
||||
SKIDOO_INFO* skinfo = game_malloc<SKIDOO_INFO>();
|
||||
skidoo->data = (void*)skinfo;
|
||||
skidoo->data = ITEM_DATA(ITEM_DATA_TYPE<SKIDOO_INFO>());
|
||||
SKIDOO_INFO* skinfo = skidoo->data;
|
||||
|
||||
skinfo->alreadyCdPlayed = false;
|
||||
|
||||
|
|
|
@ -121,10 +121,9 @@ void BigGunInitialise(short itemNum)
|
|||
BIGGUNINFO *gun;
|
||||
|
||||
obj = &g_Level.Items[itemNum];
|
||||
obj->data = ITEM_DATA(ITEM_DATA_TYPE<BIGGUNINFO>());
|
||||
|
||||
gun = (BIGGUNINFO*)malloc(sizeof(BIGGUNINFO));
|
||||
obj->data = malloc(sizeof(BIGGUNINFO));
|
||||
|
||||
gun = obj->data;
|
||||
gun->flags = 0;
|
||||
gun->fireCount = 0;
|
||||
gun->xRot = GETOFF_FRAME;
|
||||
|
|
|
@ -775,8 +775,8 @@ void InitialiseMineCart(short itemNum)
|
|||
CART_INFO* cart;
|
||||
|
||||
v = &g_Level.Items[itemNum];
|
||||
cart = game_malloc<CART_INFO>();
|
||||
v->data = (void*)cart;
|
||||
v->data = CART_INFO();
|
||||
cart = v->data;
|
||||
cart->Flags = NULL;
|
||||
cart->Speed = 0;
|
||||
cart->YVel = 0;
|
||||
|
@ -842,8 +842,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);
|
||||
|
||||
|
|
|
@ -49,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)
|
||||
|
|
|
@ -832,11 +832,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<SUB_INFO>();
|
||||
v->data = (void*)sub;
|
||||
v->data = ITEM_DATA(ITEM_DATA_TYPE<SUB_INFO>());
|
||||
SUB_INFO* sub = v->data;
|
||||
sub->Vel = sub->Rot = 0;
|
||||
sub->Flags = UPV_SURFACE;
|
||||
sub->WeaponTimer = 0;
|
||||
|
|
|
@ -145,16 +145,10 @@ void EnemyJeepControl(short itemNumber)
|
|||
AI_INFO info;
|
||||
CreatureAIInfo(item, &info);
|
||||
|
||||
ITEM_INFO* target = &creature->aiTarget;
|
||||
creature->enemy = target;
|
||||
creature->enemy = nullptr;
|
||||
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;
|
||||
|
@ -326,7 +320,7 @@ void EnemyJeepControl(short itemNumber)
|
|||
|
||||
if (aiObject != NULL)
|
||||
{
|
||||
creature->enemy = target;
|
||||
creature->enemy = nullptr;
|
||||
target->objectNumber = aiObject->objectNumber;
|
||||
target->roomNumber = aiObject->roomNumber;
|
||||
target->pos.xPos = aiObject->x;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <Game/Lara/lara_one_gun.h>
|
||||
#include "creature_info.h"
|
||||
#include "control.h"
|
||||
void SasControl(short itemNumber)
|
||||
namespace TEN::Entities::TR4
|
||||
{
|
||||
enum SAS_STATES
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "tomb4fx.h"
|
||||
#include "level.h"
|
||||
#include "creature_info.h"
|
||||
|
||||
#include "floordata.h"
|
||||
namespace TEN::Entities::TR4
|
||||
{
|
||||
BITE_INFO skeletonBite = { 0, -16, 200, 11 };
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <lara.h>
|
||||
#include <traps.h>
|
||||
#include <tomb4fx.h>
|
||||
|
||||
#include "tr4_wraith_info.h"
|
||||
constexpr auto WRAITH_COUNT = 8;
|
||||
|
||||
short WraithSpeed = 64;
|
||||
|
|
|
@ -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);
|
||||
|
|
12
TR5Main/Objects/TR4/Entity/tr4_wraith_info.h
Normal file
12
TR5Main/Objects/TR4/Entity/tr4_wraith_info.h
Normal file
|
@ -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;
|
||||
};
|
|
@ -28,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;
|
||||
}
|
||||
|
|
|
@ -140,8 +140,8 @@ void InitialiseMotorbike(short itemNumber)
|
|||
MOTORBIKE_INFO* motorbike;
|
||||
|
||||
item = &g_Level.Items[itemNumber];
|
||||
motorbike = game_malloc<MOTORBIKE_INFO>();
|
||||
item->data = (void*)motorbike;
|
||||
item->data = ITEM_DATA(MOTORBIKE_INFO());
|
||||
motorbike = item->data;
|
||||
motorbike->velocity = 0;
|
||||
motorbike->bikeTurn = 0;
|
||||
motorbike->pitch = 0;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "input.h"
|
||||
#include "sound.h"
|
||||
#include "setup.h"
|
||||
#define GET_PUSHABLEINFO(item) ((PUSHABLE_INFO*) item->data)
|
||||
#include "tr5_pushableblock_info.h"
|
||||
|
||||
static OBJECT_COLLISION_BOUNDS PushableBlockBounds = {
|
||||
0x0000, 0x0000, 0xFFC0, 0x0000,
|
||||
|
@ -70,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
|
||||
|
@ -112,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
|
||||
}
|
||||
|
||||
|
@ -133,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
|
||||
|
@ -382,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);
|
||||
|
||||
|
@ -593,7 +592,7 @@ int TestBlockPush(ITEM_INFO* item, int blockhite, unsigned short quadrant)
|
|||
if (HeightType)
|
||||
return 0;
|
||||
|
||||
if (GET_PUSHABLEINFO(item)->canFall)
|
||||
if (((PUSHABLE_INFO*)item->data)->canFall)
|
||||
{
|
||||
if (floorHeight < y)
|
||||
return 0;
|
||||
|
@ -834,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];
|
||||
|
@ -843,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];
|
||||
|
@ -853,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];
|
||||
|
@ -862,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];
|
||||
|
@ -929,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;
|
||||
|
@ -943,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;
|
||||
|
@ -962,7 +965,7 @@ bool CheckStackLimit(ITEM_INFO* item)
|
|||
std::optional<int> 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)
|
||||
{
|
||||
|
@ -975,7 +978,7 @@ std::optional<int> PushableBlockFloor(short itemNumber, int x, int y, int z)
|
|||
std::optional<int> 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};
|
||||
|
|
|
@ -2,28 +2,7 @@
|
|||
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);
|
||||
|
|
22
TR5Main/Objects/TR5/Object/tr5_pushableblock_info.h
Normal file
22
TR5Main/Objects/TR5/Object/tr5_pushableblock_info.h
Normal file
|
@ -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)
|
||||
};
|
|
@ -223,91 +223,76 @@ 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;
|
||||
auto& data = item->data.get();
|
||||
std::visit(overload{
|
||||
[&j,¤tBone](QUAD_INFO& quad) {
|
||||
if(j == 3 || j == 4) {
|
||||
currentBone->ExtraRotation.x = TO_RAD(quad->rearRot);
|
||||
currentBone->ExtraRotation.x = TO_RAD(quad.rearRot);
|
||||
} else if(j == 6 || j == 7) {
|
||||
currentBone->ExtraRotation.x = TO_RAD(quad.frontRot);
|
||||
}
|
||||
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;
|
||||
},
|
||||
[&j,¤tBone](JEEP_INFO& jeep) {
|
||||
switch(j) {
|
||||
case 9:
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep->rot1);
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep.rot1);
|
||||
break;
|
||||
case 10:
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep->rot2);
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep.rot2);
|
||||
|
||||
break;
|
||||
case 12:
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep->rot3);
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep.rot3);
|
||||
|
||||
break;
|
||||
case 13:
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep->rot4);
|
||||
currentBone->ExtraRotation.x = TO_RAD(jeep.rot4);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (item->objectNumber == ID_MOTORBIKE) {
|
||||
MOTORBIKE_INFO* bike = (MOTORBIKE_INFO*)item->data;
|
||||
},
|
||||
[&j,¤tBone](MOTORBIKE_INFO& bike) {
|
||||
switch(j) {
|
||||
case 2:
|
||||
case 4:
|
||||
currentBone->ExtraRotation.x = TO_RAD(bike->wheelRight);
|
||||
currentBone->ExtraRotation.x = TO_RAD(bike.wheelRight);
|
||||
break;
|
||||
case 10:
|
||||
currentBone->ExtraRotation.x = TO_RAD(bike->wheelLeft);
|
||||
currentBone->ExtraRotation.x = TO_RAD(bike.wheelLeft);
|
||||
}
|
||||
}
|
||||
else if (item->objectNumber == ID_RUBBER_BOAT)
|
||||
{
|
||||
RUBBER_BOAT_INFO* boat = (RUBBER_BOAT_INFO*)item->data;
|
||||
},
|
||||
[&j,¤tBone](RUBBER_BOAT_INFO& boat) {
|
||||
if(j == 2)
|
||||
currentBone->ExtraRotation.z = TO_RAD(boat->propRot);
|
||||
}
|
||||
else if (item->objectNumber == ID_UPV)
|
||||
{
|
||||
SUB_INFO* upv = (SUB_INFO*)item->data;
|
||||
currentBone->ExtraRotation.z = TO_RAD(boat.propRot);
|
||||
},
|
||||
[&j, ¤tBone](SUB_INFO& upv) {
|
||||
if(j == 3)
|
||||
currentBone->ExtraRotation.z = TO_RAD(upv->FanRot);
|
||||
}
|
||||
else if (item->objectNumber == ID_BIGGUN)
|
||||
{
|
||||
BIGGUNINFO* biggun = (BIGGUNINFO*)item->data;
|
||||
currentBone->ExtraRotation.z = TO_RAD(upv.FanRot);
|
||||
},
|
||||
[&j, ¤tBone](BIGGUNINFO& biggun) {
|
||||
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]);
|
||||
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++;
|
||||
}
|
||||
|
||||
if (currentBone->ExtraRotationFlags & ROT_X)
|
||||
{
|
||||
currentBone->ExtraRotation.x = TO_RAD(creature->jointRotation[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]);
|
||||
if(currentBone->ExtraRotationFlags & ROT_Z) {
|
||||
currentBone->ExtraRotation.z = TO_RAD(creature.jointRotation[lastJoint]);
|
||||
lastJoint++;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
[](auto&) {},
|
||||
}, data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
ANIM_FRAME* framePtr[2];
|
||||
|
@ -331,7 +316,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)
|
||||
|
|
|
@ -146,6 +146,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
|||
<ClInclude Include="Game\footprint.h" />
|
||||
<ClInclude Include="Game\groundfx.h" />
|
||||
<ClInclude Include="Game\item.h" />
|
||||
<ClInclude Include="Game\roomvector.h" />
|
||||
<ClInclude Include="Objects\TR2\Vehicles\boat_info.h" />
|
||||
<ClInclude Include="Game\creature_info.h" />
|
||||
<ClInclude Include="Game\itemdata\itemdata.h" />
|
||||
|
@ -193,9 +194,11 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
|||
<ClInclude Include="Objects\TR3\Vehicles\quad_info.h" />
|
||||
<ClInclude Include="Objects\TR3\Vehicles\rubberboat_info.h" />
|
||||
<ClInclude Include="Objects\TR3\Vehicles\upv_info.h" />
|
||||
<ClInclude Include="Objects\TR4\Entity\tr4_wraith_info.h" />
|
||||
<ClInclude Include="Objects\TR4\Vehicles\jeep_info.h" />
|
||||
<ClInclude Include="Objects\TR4\Vehicles\motorbike_info.h" />
|
||||
<ClInclude Include="Objects\TR5\Entity\tr5_laserhead_info.h" />
|
||||
<ClInclude Include="Objects\TR5\Object\tr5_pushableblock_info.h" />
|
||||
<ClInclude Include="Objects\TR5\Switch\tr5_crowdove_switch.h" />
|
||||
<ClInclude Include="Scripting\GameScriptAIObject.h" />
|
||||
<ClInclude Include="Scripting\GameScriptAudioTrack.h" />
|
||||
|
@ -517,6 +520,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
|||
<ClCompile Include="Game\explosion.cpp" />
|
||||
<ClCompile Include="Game\floordata.cpp" />
|
||||
<ClCompile Include="Game\footprint.cpp" />
|
||||
<ClCompile Include="Game\itemdata\itemdata.cpp" />
|
||||
<ClCompile Include="Game\Lara\lara_basic.cpp" />
|
||||
<ClCompile Include="Game\Lara\lara_cheat.cpp" />
|
||||
<ClCompile Include="Game\Lara\lara_collide.cpp" />
|
||||
|
|
|
@ -1128,6 +1128,15 @@
|
|||
<ClInclude Include="Game\door_data.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Game\roomvector.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Objects\TR4\Entity\tr4_wraith_info.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Objects\TR5\Object\tr5_pushableblock_info.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Game\box.cpp">
|
||||
|
@ -2033,6 +2042,9 @@
|
|||
<ClCompile Include="Objects\TR5\Switch\tr5_crowdove_switch.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Game\itemdata\itemdata.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue