Skip to content

Commit 21ddbb6

Browse files
committed
-
1 parent 6e6fda1 commit 21ddbb6

26 files changed

Lines changed: 217 additions & 200 deletions

src/Carnage3D.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
<ClInclude Include="Convert.h" />
160160
<ClInclude Include="Decoration.h" />
161161
<ClInclude Include="Explosion.h" />
162-
<ClInclude Include="GameObjectDefs.h" />
163162
<ClInclude Include="game_version.h" />
164163
<ClInclude Include="GtaFontData.h" />
165164
<ClInclude Include="HUD.h" />

src/Carnage3D.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@
338338
<ClInclude Include="Projectile.h">
339339
<Filter>Game\GameObjects</Filter>
340340
</ClInclude>
341-
<ClInclude Include="GameObjectDefs.h">
342-
<Filter>Game\GameObjects</Filter>
343-
</ClInclude>
344341
<ClInclude Include="Decoration.h">
345342
<Filter>Game\GameObjects</Filter>
346343
</ClInclude>

src/CarnageGame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool CarnageGame::StartScenario(const std::string& mapName)
319319
{
320320
for (int zBlock = MAP_LAYERS_COUNT - 1; zBlock > -1; --zBlock)
321321
{
322-
BlockStyle* currBlock = gGameMap.GetBlock(xBlock, yBlock, zBlock);
322+
MapBlockInfo* currBlock = gGameMap.GetBlock(xBlock, yBlock, zBlock);
323323
if (currBlock->mGroundType == eGroundType_Field ||
324324
currBlock->mGroundType == eGroundType_Pawement ||
325325
currBlock->mGroundType == eGroundType_Road)

src/Decoration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "TimeManager.h"
44
#include "SpriteManager.h"
55

6-
Decoration::Decoration(GameObjectID id, GameObjectStyle* desc)
6+
Decoration::Decoration(GameObjectID id, GameObjectInfo* desc)
77
: GameObject(eGameObjectClass_Decoration, id)
88
, mGameObjectDesc(desc)
99
{

src/Decoration.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Decoration final: public GameObject
77
friend class GameObjectsManager;
88

99
public:
10-
Decoration(GameObjectID id, GameObjectStyle* desc);
10+
Decoration(GameObjectID id, GameObjectInfo* desc);
1111
~Decoration();
1212

1313
// override GameObject
@@ -22,7 +22,7 @@ class Decoration final: public GameObject
2222

2323
private:
2424
SpriteAnimation mAnimationState;
25-
GameObjectStyle* mGameObjectDesc = nullptr;
25+
GameObjectInfo* mGameObjectDesc = nullptr;
2626

2727
int mLifeDuration = 0; // number of animation cycles before decoration will be deleted, or 0 for endless lifetime
2828
};

src/GameCheatsWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void GameCheatsWindow::DoUI(ImGuiIO& imguiContext)
171171
{
172172
if (Vehicle* currCar = pedestrian->mCurrentCar)
173173
{
174-
CarStyle* carInformation = currCar->mCarStyle;
174+
VehicleInfo* carInformation = currCar->mCarStyle;
175175

176176
if (ImGui::CollapsingHeader("Vehicle Info"))
177177
{
@@ -240,7 +240,7 @@ void GameCheatsWindow::DoUI(ImGuiIO& imguiContext)
240240
ImGui::End();
241241
}
242242

243-
void GameCheatsWindow::CreateCarNearby(CarStyle* carStyle, Pedestrian* pedestrian)
243+
void GameCheatsWindow::CreateCarNearby(VehicleInfo* carStyle, Pedestrian* pedestrian)
244244
{
245245
if (carStyle == nullptr || pedestrian == nullptr)
246246
return;

src/GameCheatsWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GameCheatsWindow: public DebugWindow
2323
// @param deltaTime: Time since last frame
2424
void DoUI(ImGuiIO& imguiContext) override;
2525

26-
void CreateCarNearby(CarStyle* carStyle, Pedestrian* pedestrian);
26+
void CreateCarNearby(VehicleInfo* carStyle, Pedestrian* pedestrian);
2727
};
2828

2929
extern GameCheatsWindow gGameCheatsWindow;

src/GameDefs.h

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "GameObjectDefs.h"
4-
53
// most of game constants is mapped to GTA files format so don't change
64

75
// side length of block cube, do not change
@@ -24,10 +22,10 @@
2422
#define SPRITE_ZERO_ANGLE 90.0f // all sprites in game are rotated at 90 degrees
2523
#define MAP_SPRITE_SCALE (METERS_PER_MAP_UNIT / PIXELS_PER_MAP_UNIT)
2624
#define PED_SPRITE_DRAW_BOX_SIZE_PX 24 // with, height
27-
#define CAR_WHEEL_SIZE_W_PX 6
28-
#define CAR_WHEEL_SIZE_H_PX 12
25+
#define CAR_WHEEL_SIZE_W_PX 6
26+
#define CAR_WHEEL_SIZE_H_PX 12
2927

30-
#define GTA_CYCLES_PER_FRAME 24
28+
#define GTA_CYCLES_PER_FRAME 24
3129

3230
// in original gta1 map height levels is counting from top to bottom -
3331
// 0 is highest and 5 is lowest level
@@ -62,13 +60,68 @@
6260

6361
#define CAR_DELTA_ANIMS_SPEED 10.0f
6462

65-
// define generic gameobject information
66-
struct GameObjectStyle
63+
// forwards
64+
class GameObject;
65+
class Pedestrian;
66+
class Vehicle;
67+
class Projectile;
68+
class Decoration;
69+
class Obstacle;
70+
class Explosion;
71+
72+
// some game objects has null identifier, they are dacals, projectiles and short-lived effects
73+
#define GAMEOBJECT_ID_NULL 0
74+
75+
using GameObjectID = unsigned int; // unique id of gameobject instance in world
76+
77+
// gameobject class identifiers
78+
enum eGameObjectClass
79+
{
80+
eGameObjectClass_Car,
81+
eGameObjectClass_Pedestrian,
82+
eGameObjectClass_Projectile,
83+
eGameObjectClass_Powerup,
84+
eGameObjectClass_Decoration,
85+
eGameObjectClass_Obstacle,
86+
eGameObjectClass_Explosion,
87+
eGameObjectClass_COUNT,
88+
};
89+
90+
decl_enum_strings(eGameObjectClass);
91+
92+
enum eGameObjectFlags: unsigned short
93+
{
94+
eGameObjectFlags_None = 0,
95+
eGameObjectFlags_Invisible = BIT(0),
96+
eGameObjectFlags_CarObject = BIT(1),
97+
};
98+
99+
decl_enum_as_flags(eGameObjectFlags);
100+
101+
// game object type indices
102+
enum
103+
{
104+
GameObjectType_Null = 0,
105+
106+
GameObjectType_FirstBlood = 63,
107+
GameObjectType_Body = 64,
108+
// todo...
109+
GameObjectType_MissileProjectile = 31,
110+
GameObjectType_BulletProjectile = 74,
111+
GameObjectType_FireballProjectile = 75,
112+
113+
// todo...
114+
GameObjectType_MAX = 102
115+
};
116+
117+
// define gameobject type information
118+
struct GameObjectInfo
67119
{
68120
eGameObjectClass mClassID = eGameObjectClass_COUNT;
69121
eGameObjectFlags mFlags = eGameObjectFlags_None;
70122

71-
int mGameObjectIndex = 0; // index within loaded styles
123+
// index in the gameobject types table that are loaded with the style data
124+
int mObjectType = GameObjectType_Null;
72125

73126
// width, height and depth store the dimensions of the object with respect to collision checking
74127
// specified in meters
@@ -374,7 +427,7 @@ struct HLSRemap
374427
};
375428

376429
// define map block information
377-
struct BlockStyle
430+
struct MapBlockInfo
378431
{
379432
unsigned char mRemap;
380433

@@ -408,10 +461,10 @@ struct BlockStyle
408461
bool mIsRailway : 1;
409462
};
410463

411-
const unsigned int Sizeof_BlockStyle = sizeof(BlockStyle);
464+
const unsigned int Sizeof_BlockInfo = sizeof(MapBlockInfo);
412465

413466
// define map block anim information
414-
struct BlockAnimationStyle
467+
struct BlockAnimationInfo
415468
{
416469
int mBlock = 0; // the block number
417470
int mWhich = 0; // the area type ( 0 for side, 1 for lid )
@@ -421,7 +474,7 @@ struct BlockAnimationStyle
421474
};
422475

423476
// define car door information
424-
struct CarDoorStyle
477+
struct CarDoorInfo
425478
{
426479
short mRpx, mRpy;
427480
short mObject;
@@ -525,11 +578,12 @@ enum eCarConvertible
525578
};
526579
decl_enum_strings(eCarConvertible);
527580

528-
// define car class information
529-
struct CarStyle
581+
// define vehicle type information
582+
struct VehicleInfo
530583
{
531-
short mWidth, mHeight, mDepth; // dimensions of the car with respect to collision checking, x, y, z
532-
short mSprNum; // first sprite number offset for this car
584+
glm::vec3 mDimensions; // dimensions of the car with respect to collision checking, meters
585+
586+
int mSpriteIndex;
533587

534588
struct // specs, usage is unknown
535589
{
@@ -572,12 +626,12 @@ struct CarStyle
572626
int mHorn;
573627
int mSoundFunction;
574628
int mFastChangeFlag;
575-
short mDoorsCount;
576-
CarDoorStyle mDoors[MAX_CAR_DOORS];
629+
int mDoorsCount;
630+
CarDoorInfo mDoors[MAX_CAR_DOORS];
577631
};
578632

579633
// define sprite information
580-
struct SpriteStyle
634+
struct SpriteInfo
581635
{
582636
int mWidth;
583637
int mHeight;

src/GameMapHelpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rect& area, i
1515
for (int tiley = 0; tiley < area.h; ++tiley)
1616
for (int tilex = 0; tilex < area.w; ++tilex)
1717
{
18-
if (BlockStyle* blockInfo = cityScape.GetBlockClamp(tilex + area.x, tiley + area.y, layerIndex))
18+
if (MapBlockInfo* blockInfo = cityScape.GetBlockClamp(tilex + area.x, tiley + area.y, layerIndex))
1919
{
2020
for (int iface = 0; iface < eBlockFace_COUNT; ++iface)
2121
{
@@ -41,7 +41,7 @@ bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rect& area, M
4141
for (int tiley = 0; tiley < area.h; ++tiley)
4242
for (int tilex = 0; tilex < area.w; ++tilex)
4343
{
44-
if (BlockStyle* blockInfo = cityScape.GetBlockClamp(tilex + area.x, tiley + area.y, tilez))
44+
if (MapBlockInfo* blockInfo = cityScape.GetBlockClamp(tilex + area.x, tiley + area.y, tilez))
4545
{
4646
for (int iface = 0; iface < eBlockFace_COUNT; ++iface)
4747
{
@@ -56,7 +56,7 @@ bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rect& area, M
5656
return true;
5757
}
5858

59-
void GameMapHelpers::PutBlockFace(GameMapManager& cityScape, MapMeshData& meshData, int x, int y, int z, eBlockFace face, BlockStyle* blockInfo)
59+
void GameMapHelpers::PutBlockFace(GameMapManager& cityScape, MapMeshData& meshData, int x, int y, int z, eBlockFace face, MapBlockInfo* blockInfo)
6060
{
6161
assert(blockInfo && blockInfo->mFaces[face]);
6262
eBlockType blockType = (face == eBlockFace_Lid) ? eBlockType_Lid : eBlockType_Side;

src/GameMapHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ class GameMapHelpers final
2222

2323
private:
2424
// internals
25-
static void PutBlockFace(GameMapManager& city, MapMeshData& meshData, int x, int y, int z, eBlockFace face, BlockStyle* blockInfo);
25+
static void PutBlockFace(GameMapManager& city, MapMeshData& meshData, int x, int y, int z, eBlockFace face, MapBlockInfo* blockInfo);
2626
};

0 commit comments

Comments
 (0)