Skip to content

Commit 0746207

Browse files
committed
- added models lookup for roadmap tiles
1 parent a5a7508 commit 0746207

14 files changed

Lines changed: 176 additions & 87 deletions

File tree

DriverLevelTool/driver_routines/d2_types.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ enum ModelFlags2
225225
MODEL_FLAG_SMASHABLE = 0x800,
226226
MODEL_FLAG_LAMP = 0x1000,
227227
MODEL_FLAG_TREE = 0x2000,
228-
MODEL_FLAG_GRASS = 0x4000,
228+
MODEL_FLAG_GRASS = 0x4000, // D1 flag is DIFFERENT!!!
229229
MODEL_FLAG_PATH = 0x8000,
230230
};
231231

@@ -272,7 +272,7 @@ struct MODEL
272272

273273
int GetCollisionBoxCount()
274274
{
275-
if(collision_block != 0)
275+
if(collision_block > 0)
276276
return *(int*)((ubyte*)this + collision_block);
277277

278278
return 0;
@@ -467,4 +467,34 @@ struct Spool
467467

468468
#define REGION_EMPTY (0xFFFF)
469469

470+
//----------------------------------------------------------------------------
471+
472+
// LCF car cosmetics
473+
struct CAR_COSMETICS_D2
474+
{
475+
SVECTOR headLight;
476+
SVECTOR frontInd;
477+
SVECTOR backInd;
478+
SVECTOR brakeLight;
479+
SVECTOR revLight;
480+
SVECTOR policeLight;
481+
SVECTOR exhaust;
482+
SVECTOR smoke;
483+
SVECTOR fire;
484+
SVECTOR wheelDisp[4];
485+
short extraInfo;
486+
short powerRatio;
487+
short cbYoffset;
488+
short susCoeff;
489+
short traction;
490+
short wheelSize;
491+
SVECTOR cPoints[12];
492+
SVECTOR colBox;
493+
SVECTOR cog;
494+
short twistRateX;
495+
short twistRateY;
496+
short twistRateZ;
497+
short mass;
498+
};
499+
470500
#endif

DriverLevelTool/driver_routines/level.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,13 @@ ELevelFormat CDriverLevelLoader::GetFormat() const
277277
void CDriverLevelLoader::Initialize(OUT_CITYLUMP_INFO& lumpInfo, CDriverLevelTextures* textures, CDriverLevelModels* models, CBaseLevelMap* map)
278278
{
279279
m_lumpInfo = &lumpInfo;
280+
280281
m_textures = textures;
281282
m_models = models;
283+
282284
m_map = map;
285+
286+
m_map->Init(models, textures);
283287
}
284288

285289
void CDriverLevelLoader::Release()

DriverLevelTool/driver_routines/level.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class CDriverLevelLoader
9393

9494
OUT_CITYLUMP_INFO* m_lumpInfo;
9595

96+
CBaseLevelMap* m_map{ nullptr };
9697
CDriverLevelTextures* m_textures{ nullptr };
9798
CDriverLevelModels* m_models{ nullptr };
98-
CBaseLevelMap* m_map{ nullptr };
9999
};
100100

101101
#endif // LEVEL_H

DriverLevelTool/driver_routines/models.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ void CDriverLevelModels::FreeAll()
4646
if (carModelData.lowmodel)
4747
free(carModelData.lowmodel);
4848
}
49+
50+
m_model_names.clear();
4951
}
5052

5153
ModelRef_t* CDriverLevelModels::GetModelByIndex(int nIndex) const

DriverLevelTool/driver_routines/regions.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ CBaseLevelMap::~CBaseLevelMap()
187187
{
188188
}
189189

190+
void CBaseLevelMap::Init(CDriverLevelModels* models, CDriverLevelTextures* textures)
191+
{
192+
m_models = models;
193+
m_textures = textures;
194+
}
195+
190196
void CBaseLevelMap::FreeAll()
191197
{
192198
if (m_regionSpoolInfo)
@@ -239,14 +245,16 @@ int CBaseLevelMap::GetRegionsDown() const
239245
return m_regions_down;
240246
}
241247

242-
void CBaseLevelMap::WorldPositionToCellXZ(XZPAIR& cell, const VECTOR_NOPAD& position) const
248+
void CBaseLevelMap::WorldPositionToCellXZ(XZPAIR& cell, const VECTOR_NOPAD& position, const XZPAIR& offset /*= { 0 }*/) const
243249
{
244250
// @TODO: constants
245251
int units_across_halved = m_mapInfo.cells_across / 2 * m_mapInfo.cell_size;
246252
int units_down_halved = m_mapInfo.cells_down / 2 * m_mapInfo.cell_size;
247253

248-
cell.x = (position.vx + units_across_halved) / m_mapInfo.cell_size;
249-
cell.z = (position.vz + units_down_halved) / m_mapInfo.cell_size;
254+
const int squared_reg_size = m_mapInfo.region_size * m_mapInfo.region_size;
255+
256+
cell.x = (position.vx + units_across_halved + offset.x) / m_mapInfo.cell_size;
257+
cell.z = (position.vz + units_down_halved + offset.z) / m_mapInfo.cell_size;
250258
}
251259

252260
//-------------------------------------------------------------
@@ -383,6 +391,9 @@ void CBaseLevelMap::LoadInAreaTPages(const SPOOL_CONTEXT& ctx, int areaDataNum)
383391
if (areaDataNum == 255)
384392
return;
385393

394+
if (!m_textures)
395+
return;
396+
386397
AreaDataStr& areaData = m_areaData[areaDataNum];
387398
AreaTpageList& areaTPages = m_areaTPages[areaDataNum];
388399

@@ -395,7 +406,7 @@ void CBaseLevelMap::LoadInAreaTPages(const SPOOL_CONTEXT& ctx, int areaDataNum)
395406
if (areaTPages.pageIndexes[i] == 0xFF)
396407
break;
397408

398-
CTexturePage* tpage = ctx.textures->GetTPage(areaTPages.pageIndexes[i]);
409+
CTexturePage* tpage = m_textures->GetTPage(areaTPages.pageIndexes[i]);
399410

400411
// assign
401412
areaTPages.tpage[i] = tpage;
@@ -412,6 +423,9 @@ void CBaseLevelMap::LoadInAreaModels(const SPOOL_CONTEXT& ctx, int areaDataNum)
412423
if (areaDataNum == -1)
413424
return;
414425

426+
if (!m_models)
427+
return;
428+
415429
AreaDataStr& areaData = m_areaData[areaDataNum];
416430

417431
int length = areaData.model_size;
@@ -438,7 +452,7 @@ void CBaseLevelMap::LoadInAreaModels(const SPOOL_CONTEXT& ctx, int areaDataNum)
438452

439453
if (modelSize > 0)
440454
{
441-
ModelRef_t* ref = ctx.models->GetModelByIndex(new_model_numbers[i]);
455+
ModelRef_t* ref = m_models->GetModelByIndex(new_model_numbers[i]);
442456

443457
// @FIXME: is that correct? Analyze duplicated models...
444458
if (ref->model)
@@ -456,7 +470,7 @@ void CBaseLevelMap::LoadInAreaModels(const SPOOL_CONTEXT& ctx, int areaDataNum)
456470

457471
ctx.dataStream->Read(ref->model, modelSize, 1);
458472

459-
ctx.models->OnModelLoaded(ref);
473+
m_models->OnModelLoaded(ref);
460474
}
461475
}
462476

DriverLevelTool/driver_routines/regions.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ struct SPOOL_CONTEXT
2323
IVirtualStream* dataStream;
2424

2525
OUT_CITYLUMP_INFO* lumpInfo;
26-
CDriverLevelTextures* textures;
27-
CDriverLevelModels* models;
2826
};
2927

3028
class CBaseLevelRegion
@@ -73,6 +71,7 @@ class CBaseLevelMap
7371
CBaseLevelMap();
7472
virtual ~CBaseLevelMap();
7573

74+
void Init(CDriverLevelModels* models, CDriverLevelTextures* textures);
7675
virtual void FreeAll();
7776

7877
//----------------------------------------
@@ -103,10 +102,10 @@ class CBaseLevelMap
103102
virtual CBaseLevelRegion* GetRegion(int regionIdx) const = 0;
104103

105104
virtual int MapHeight(const VECTOR_NOPAD& position) const = 0;
106-
virtual int FindSurface(const VECTOR_NOPAD& position, VECTOR_NOPAD& outNormal, VECTOR_NOPAD& outPoint, sdPlane** outPlane) const = 0;
105+
virtual int FindSurface(const VECTOR_NOPAD& position, VECTOR_NOPAD& outNormal, VECTOR_NOPAD& outPoint, sdPlane& outPlane) const = 0;
107106

108107
// converters
109-
void WorldPositionToCellXZ(XZPAIR& cell, const VECTOR_NOPAD& position) const;
108+
void WorldPositionToCellXZ(XZPAIR& cell, const VECTOR_NOPAD& position, const XZPAIR& offset = {0}) const;
110109

111110
const OUT_CELL_FILE_HEADER& GetMapInfo() const;
112111

@@ -127,6 +126,9 @@ class CBaseLevelMap
127126
OUT_CELL_FILE_HEADER m_mapInfo;
128127

129128
ELevelFormat m_format;
129+
130+
CDriverLevelTextures* m_textures{ nullptr };
131+
CDriverLevelModels* m_models{ nullptr };
130132

131133
Spool* m_regionSpoolInfo{ nullptr }; // region data info
132134
ushort* m_regionSpoolInfoOffsets{ nullptr }; // region offset table

0 commit comments

Comments
 (0)