mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-29 05:08:00 +03:00
inject: introduce OBJECT_3D editor
This adds the ability to edit OBJECT_3Ds (static mesh properties). It alos addresses potential memory corruption in the scenario where a new data type is present in an injection but it is being loaded into a version of the game that doesn't recognise it.
This commit is contained in:
parent
70bf6a089d
commit
77ca92d205
3 changed files with 43 additions and 2 deletions
|
@ -125,7 +125,9 @@ static void M_InitialiseBlock(VFILE *const file)
|
||||||
const INJECTION_DATA_TYPE data_type = VFile_ReadS32(file);
|
const INJECTION_DATA_TYPE data_type = VFile_ReadS32(file);
|
||||||
const int32_t data_count = VFile_ReadS32(file);
|
const int32_t data_count = VFile_ReadS32(file);
|
||||||
const int32_t data_size = VFile_ReadS32(file);
|
const int32_t data_size = VFile_ReadS32(file);
|
||||||
m_DataCounts[data_type] += data_count;
|
if (data_type >= 0 && data_type < IDT_NUMBER_OF) {
|
||||||
|
m_DataCounts[data_type] += data_count;
|
||||||
|
}
|
||||||
|
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
case IDT_ROOM_EDIT_META: {
|
case IDT_ROOM_EDIT_META: {
|
||||||
|
|
|
@ -37,6 +37,9 @@ static void M_ApplyFace3Edit(
|
||||||
const FACE_EDIT *edit, FACE3 *faces, uint16_t texture);
|
const FACE_EDIT *edit, FACE3 *faces, uint16_t texture);
|
||||||
static uint16_t *M_GetMeshTexture(const FACE_EDIT *edit);
|
static uint16_t *M_GetMeshTexture(const FACE_EDIT *edit);
|
||||||
|
|
||||||
|
static void M_Object3DEdits(const INJECTION *injection, int32_t data_count);
|
||||||
|
static BOUNDS_16 M_ReadBounds16(VFILE *file);
|
||||||
|
|
||||||
static void M_MeshEdits(
|
static void M_MeshEdits(
|
||||||
const INJECTION *const injection, const int32_t data_count)
|
const INJECTION *const injection, const int32_t data_count)
|
||||||
{
|
{
|
||||||
|
@ -207,4 +210,39 @@ static uint16_t *M_GetMeshTexture(const FACE_EDIT *const edit)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void M_Object3DEdits(
|
||||||
|
const INJECTION *const injection, const int32_t data_count)
|
||||||
|
{
|
||||||
|
for (int32_t i = 0; i < data_count; i++) {
|
||||||
|
const int32_t obj_id = VFile_ReadS32(injection->fp);
|
||||||
|
const bool collidable = VFile_ReadU8(injection->fp) == 1;
|
||||||
|
const bool visible = VFile_ReadU8(injection->fp) == 1;
|
||||||
|
const BOUNDS_16 collision_bounds = M_ReadBounds16(injection->fp);
|
||||||
|
const BOUNDS_16 draw_bounds = M_ReadBounds16(injection->fp);
|
||||||
|
|
||||||
|
STATIC_OBJECT_3D *const obj = Object_Get3DStatic(obj_id);
|
||||||
|
if (!obj->loaded) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->collidable = collidable;
|
||||||
|
obj->visible = visible;
|
||||||
|
obj->collision_bounds = collision_bounds;
|
||||||
|
obj->draw_bounds = draw_bounds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOUNDS_16 M_ReadBounds16(VFILE *const file)
|
||||||
|
{
|
||||||
|
BOUNDS_16 bounds = {};
|
||||||
|
bounds.min.x = VFile_ReadS16(file);
|
||||||
|
bounds.max.x = VFile_ReadS16(file);
|
||||||
|
bounds.min.y = VFile_ReadS16(file);
|
||||||
|
bounds.max.y = VFile_ReadS16(file);
|
||||||
|
bounds.min.z = VFile_ReadS16(file);
|
||||||
|
bounds.max.z = VFile_ReadS16(file);
|
||||||
|
return bounds;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_INJECT_EDITOR(IDT_MESH_EDITS, M_MeshEdits)
|
REGISTER_INJECT_EDITOR(IDT_MESH_EDITS, M_MeshEdits)
|
||||||
|
REGISTER_INJECT_EDITOR(IDT_OBJECT_3D_EDITS, M_Object3DEdits)
|
||||||
|
|
|
@ -65,7 +65,8 @@ typedef enum {
|
||||||
IDT_VIS_PORTAL_EDITS = 23,
|
IDT_VIS_PORTAL_EDITS = 23,
|
||||||
IDT_CAMERA_EDITS = 24,
|
IDT_CAMERA_EDITS = 24,
|
||||||
IDT_FRAME_EDITS = 25,
|
IDT_FRAME_EDITS = 25,
|
||||||
IDT_NUMBER_OF = 26,
|
IDT_OBJECT_3D_EDITS = 26,
|
||||||
|
IDT_NUMBER_OF = 27,
|
||||||
} INJECTION_DATA_TYPE;
|
} INJECTION_DATA_TYPE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue