level: fix sprites-statics collisions

Resolves #2310.
This commit is contained in:
Marcin Kurczewski 2025-01-16 10:40:23 +01:00
parent b13b08f4bc
commit 46020df42d
5 changed files with 45 additions and 17 deletions

View file

@ -11,6 +11,7 @@
- changed the fix for transparent eyes on wolves to use black instead of off-white (#2252)
- changed the `/kill` command with no arguments to look for enemies within 5 tiles (#2297)
- fixed blood spawning on Lara from gunshots using incorrect positioning data (#2253)
- fixed ghost meshes appearing near statics in custom levels (#2310)
- fixed the upside-down camera fix to no longer limit Lara's vision (#2276, regression from 4.2)
- fixed being unable to load some old custom levels that contain certain (invalid) floor data (#2114, regression from 4.3)
- fixed a desync in the Lost Valley demo if responsive swim cancellation was enabled (#2113, regression from 4.6)

View file

@ -18,6 +18,7 @@
- fixed showing inventory ring up/down arrows when uncalled for (#2225)
- fixed Lara never stepping backwards off a step using her right foot (#1602)
- fixed blood spawning on Lara from gunshots using incorrect positioning data (#2253)
- fixed ghost meshes appearing near statics in custom levels (#2310)
- fixed Lara activating triggers one frame too early (#2205, regression from 0.7)
- fixed savegame incompatibility with OG (#2271, regression from 0.8)
- fixed stopwatch showing wrong UI in some circumstances (#2221, regression from 0.8)

View file

@ -236,7 +236,7 @@ static void M_LoadRooms(VFILE *file)
mesh->pos.z = VFile_ReadS32(file);
mesh->rot.y = VFile_ReadS16(file);
mesh->shade = VFile_ReadU16(file);
mesh->static_num = VFile_ReadU16(file);
mesh->static_num = VFile_ReadS16(file);
}
}
@ -409,7 +409,7 @@ static void M_LoadStaticObjects(VFILE *file)
object->c.max.y = VFile_ReadS16(file);
object->c.min.z = VFile_ReadS16(file);
object->c.max.z = VFile_ReadS16(file);
object->flags = VFile_ReadS16(file);
object->flags = VFile_ReadU16(file);
object->loaded = true;
}
@ -459,20 +459,29 @@ static void M_LoadSprites(VFILE *file)
m_LevelInfo.sprite_count = VFile_ReadS32(file);
for (int i = 0; i < m_LevelInfo.sprite_count; i++) {
const GAME_OBJECT_ID object_id = VFile_ReadS32(file);
const int32_t object_id = VFile_ReadS32(file);
const int16_t num_meshes = VFile_ReadS16(file);
const int16_t mesh_idx = VFile_ReadS16(file);
if (object_id >= 0 && object_id < O_NUMBER_OF) {
OBJECT *object = &g_Objects[object_id];
OBJECT *const object = &g_Objects[object_id];
object->mesh_count = num_meshes;
object->mesh_idx = mesh_idx;
object->loaded = 1;
} else if (object_id - O_NUMBER_OF < STATIC_NUMBER_OF) {
STATIC_INFO *object = &g_StaticObjects[object_id - O_NUMBER_OF];
object->mesh_count = num_meshes;
object->mesh_num = mesh_idx;
object->loaded = true;
STATIC_INFO *const object =
&g_StaticObjects[object_id - O_NUMBER_OF];
if (object->loaded) {
LOG_WARNING(
"sprite %d is already loaded "
"(trying to override %d:%d with %d:%d)",
object_id - O_NUMBER_OF, object->mesh_count,
object->mesh_num, num_meshes, mesh_idx);
} else {
object->mesh_count = num_meshes;
object->mesh_num = mesh_idx;
object->loaded = true;
}
} else {
Shell_ExitSystemFmt("Invalid sprite slot (%d)", object_id);
}

View file

@ -344,6 +344,7 @@ static void M_LoadStaticObjects(VFILE *const file)
static_obj->collision_bounds.min.z = VFile_ReadS16(file);
static_obj->collision_bounds.max.z = VFile_ReadS16(file);
static_obj->flags = VFile_ReadU16(file);
static_obj->loaded = true;
}
Benchmark_End(benchmark, NULL);
}
@ -409,17 +410,31 @@ static void M_LoadSprites(VFILE *const file)
const int32_t num_statics = VFile_ReadS32(file);
LOG_DEBUG("statics: %d", num_statics);
for (int32_t i = 0; i < num_statics; i++) {
int32_t object_id = VFile_ReadS32(file);
if (object_id >= O_NUMBER_OF) {
object_id -= O_NUMBER_OF;
STATIC_INFO *const static_object = &g_StaticObjects[object_id];
VFile_Skip(file, sizeof(int16_t));
static_object->mesh_idx = VFile_ReadS16(file);
} else {
const int32_t object_id = VFile_ReadS32(file);
const int16_t num_meshes = VFile_ReadS16(file);
const int16_t mesh_idx = VFile_ReadS16(file);
if (object_id >= 0 && object_id < O_NUMBER_OF) {
OBJECT *const object = &g_Objects[object_id];
object->mesh_count = VFile_ReadS16(file);
object->mesh_idx = VFile_ReadS16(file);
object->mesh_count = num_meshes;
object->mesh_idx = mesh_idx;
object->loaded = 1;
} else if (object_id - O_NUMBER_OF < MAX_STATIC_OBJECTS) {
STATIC_INFO *const object =
&g_StaticObjects[object_id - O_NUMBER_OF];
if (object->loaded) {
LOG_WARNING(
"sprite %d is already loaded "
"(trying to override %d:%d with %d:%d)",
object_id - O_NUMBER_OF, object->mesh_count,
object->mesh_idx, num_meshes, mesh_idx);
} else {
object->mesh_count = num_meshes;
object->mesh_idx = mesh_idx;
object->loaded = true;
}
} else {
Shell_ExitSystemFmt("Invalid sprite slot (%d)", object_id);
}
}

View file

@ -144,6 +144,8 @@ typedef enum {
} DRAW_TYPE;
typedef struct {
bool loaded;
int16_t mesh_count;
int16_t mesh_idx;
uint16_t flags;
BOUNDS_16 draw_bounds;