Skip to content

Commit 46c6f09

Browse files
committed
- one-shot model override loading for spooled cars
1 parent dab138a commit 46c6f09

5 files changed

Lines changed: 217 additions & 187 deletions

File tree

src_rebuild/Game/C/bcollide.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ int bcollided2d(CDATA2D *body, int* boxOverlap)
4646
}
4747

4848
// hmmm, why?
49-
as = RSIN(dtheta & 0x7ff); // rcossin_tbl[(dtheta & 0x7ff) * 2];
50-
ac = RSIN(dtheta + 1024 & 0x7ff); // rcossin_tbl[(dtheta + 1024 & 0x7ff) * 2];
49+
as = RSIN(dtheta & 2047); // rcossin_tbl[(dtheta & 0x7ff) * 2];
50+
ac = RSIN(dtheta + 1024 & 2047); // rcossin_tbl[(dtheta + 1024 & 0x7ff) * 2];
5151

5252
delta.vx = body[0].x.vx - body[1].x.vx;
5353
delta.vz = body[0].x.vz - body[1].x.vz;

src_rebuild/Game/C/gamesnd.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,17 @@ int ResidentModelsBodge(void)
206206
int i;
207207
int j;
208208

209-
j = MissionHeader->residentModels[4];
210-
211-
if (gCurrentMissionNumber == 24 || gCurrentMissionNumber == 27 ||
209+
if (gCurrentMissionNumber == 24 ||
210+
gCurrentMissionNumber == 27 ||
212211
gCurrentMissionNumber == 29 ||
213-
(gCurrentMissionNumber == 30 || gCurrentMissionNumber == 35))
212+
gCurrentMissionNumber == 30 ||
213+
gCurrentMissionNumber == 35)
214214
{
215215
return 3;
216216
}
217217

218+
j = MissionHeader->residentModels[4];
219+
218220
if (gCurrentMissionNumber - 50U < 16 && j == 12)
219221
{
220222
return 5;
@@ -224,7 +226,7 @@ int ResidentModelsBodge(void)
224226
{
225227
i = 11;
226228

227-
if (j != 9)
229+
if (j != 9 && j != i)
228230
return 3;
229231
}
230232
else if (GameLevel == 1)

src_rebuild/Game/C/models.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include "mission.h"
66
#include "cars.h"
77

8+
#if USE_PC_FILESYSTEM
9+
extern int gContentOverride;
10+
#endif
11+
812
MODEL dummyModel = { 0 };
913

1014
char* modelname_buffer = NULL;
@@ -243,14 +247,13 @@ int ProcessCarModelLump(char *lump_ptr, int lump_size)
243247
int lowOfs = offsets[2];
244248

245249
#if USE_PC_FILESYSTEM
246-
extern int gContentOverride;
247250
if (gContentOverride)
248251
{
249252
char* mem;
250253
if (mem = LoadCarModelFromFile(NULL, model_number, CAR_MODEL_CLEAN))
251254
{
252255
D_MALLOC_BEGIN();
253-
model = GetCarModel(mem, (char**)&mallocptr, 1, model_number, CAR_MODEL_CLEAN);
256+
model = GetCarModel(mem, (char**)&mallocptr, 1);
254257
D_MALLOC_END();
255258

256259
gCarCleanModelPtr[i] = model;
@@ -260,7 +263,7 @@ int ProcessCarModelLump(char *lump_ptr, int lump_size)
260263
if (mem = LoadCarModelFromFile(NULL, model_number, CAR_MODEL_DAMAGED))
261264
{
262265
D_MALLOC_BEGIN();
263-
model = GetCarModel(mem, (char**)&mallocptr, 1, model_number, CAR_MODEL_DAMAGED);
266+
model = GetCarModel(mem, (char**)&mallocptr, 1);
264267
D_MALLOC_END();
265268

266269
gCarDamModelPtr[i] = model;
@@ -270,7 +273,7 @@ int ProcessCarModelLump(char *lump_ptr, int lump_size)
270273
if (mem = LoadCarModelFromFile(NULL, model_number, CAR_MODEL_LOWDETAIL))
271274
{
272275
D_MALLOC_BEGIN();
273-
model = GetCarModel(mem, (char**)&mallocptr, 1, model_number, CAR_MODEL_LOWDETAIL);
276+
model = GetCarModel(mem, (char**)&mallocptr, 1);
274277
D_MALLOC_END();
275278

276279
gCarLowModelPtr[i] = model;
@@ -282,30 +285,39 @@ int ProcessCarModelLump(char *lump_ptr, int lump_size)
282285
if (cleanOfs != -1)
283286
{
284287
D_MALLOC_BEGIN();
285-
model = GetCarModel(models_offset + cleanOfs, (char**)&mallocptr, 1, model_number, CAR_MODEL_CLEAN);
288+
model = GetCarModel(models_offset + cleanOfs, (char**)&mallocptr, 1);
286289
gCarCleanModelPtr[i] = model;
287290
D_MALLOC_END();
288291
}
289292

290293
if (damOfs != -1)
291294
{
292295
D_MALLOC_BEGIN();
293-
model = GetCarModel(models_offset + damOfs, (char**)&mallocptr, 0, model_number, CAR_MODEL_DAMAGED);
296+
model = GetCarModel(models_offset + damOfs, (char**)&mallocptr, 0);
294297
gCarDamModelPtr[i] = model;
295298
D_MALLOC_END();
296299
}
297300

298301
if (lowOfs != -1)
299302
{
300303
D_MALLOC_BEGIN();
301-
model = GetCarModel(models_offset + lowOfs, (char**)&mallocptr, 1, model_number, CAR_MODEL_LOWDETAIL);
304+
model = GetCarModel(models_offset + lowOfs, (char**)&mallocptr, 1);
302305
gCarLowModelPtr[i] = model;
303306
D_MALLOC_END();
304307
}
305308
}
306309
}
307310

308311
D_MALLOC_BEGIN();
312+
313+
#if USE_PC_FILESYSTEM
314+
if (gContentOverride)
315+
{
316+
// extra spool memory needed
317+
specMemReq += 4096;
318+
}
319+
#endif
320+
309321
mallocptr = specmallocptr + specMemReq;
310322
specLoadBuffer = specmallocptr + specMemReq - 2048;
311323
D_MALLOC_END();
@@ -344,7 +356,7 @@ char* LoadCarModelFromFile(char* dest, int modelNumber, int type)
344356
#endif
345357

346358
// [D] [T]
347-
MODEL* GetCarModel(char *src, char **dest, int KeepNormals, int modelNumber, int type)
359+
MODEL* GetCarModel(char *src, char **dest, int KeepNormals)
348360
{
349361
int size;
350362
MODEL *model;

src_rebuild/Game/C/models.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern void ProcessMDSLump(char *lump_file, int lump_size); // 0x00064CFC
2929

3030
extern int ProcessCarModelLump(char *lump_ptr, int lump_size); // 0x00064E6C
3131

32-
extern MODEL * GetCarModel(char *src, char **dest, int KeepNormals, int modelNumber, int type); // 0x00065134
32+
extern MODEL * GetCarModel(char *src, char **dest, int KeepNormals); // 0x00065134
3333

3434
extern MODEL * FindModelPtrWithName(char *name); // 0x0005D40C
3535

0 commit comments

Comments
 (0)