diff --git a/docs/progress.svg b/docs/progress.svg
index 8ef72672..187c6a8b 100644
--- a/docs/progress.svg
+++ b/docs/progress.svg
@@ -1144,7 +1144,7 @@
void __cdecl S_PrintShadow(int16_t radius, const BOUNDS_16 *bounds, const ITEM *item);
void __cdecl S_CalculateLight(int32_t x, int32_t y, int32_t z, int16_t room_num);
void __cdecl S_CalculateStaticLight(int16_t adder);
-void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM *room);
+void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade_1, int32_t shade_2, ROOM *room);
void __cdecl S_LightRoom(ROOM *room);
void __cdecl S_DrawHealthBar(int32_t percent);
void __cdecl S_DrawAirBar(int32_t percent);
@@ -1625,7 +1625,7 @@
int32_t __cdecl Collide_TestCollision(ITEM *item, const ITEM *lara_item);
void __cdecl HWR_InitState(void);
void __cdecl Lara_Col_Hang(ITEM *item, COLL_INFO *coll);
-void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM *room);
+void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade_1, int32_t shade_2, ROOM *room);
BOOL __cdecl S_Input_Key(KEYMAP keymap);
void __cdecl Item_Kill(int16_t item_num);
void __cdecl Gun_InitialiseNewWeapon(void);
diff --git a/docs/progress.txt b/docs/progress.txt
index db501f03..04b82d47 100644
--- a/docs/progress.txt
+++ b/docs/progress.txt
@@ -545,8 +545,8 @@ typedef struct __unaligned { // decompiled
int16_t box_num;
int16_t timer;
uint16_t flags;
- int16_t shade1;
- int16_t shade2;
+ int16_t shade_1;
+ int16_t shade_2;
int16_t carried_item;
void *data;
union {
@@ -885,9 +885,7 @@ typedef struct { // decompiled
typedef struct __unaligned { // decompiled
int16_t room;
- int16_t x;
- int16_t y;
- int16_t z;
+ XYZ_16 normal;
XYZ_16 vertex[4];
} PORTAL;
@@ -900,19 +898,19 @@ typedef struct __unaligned { // decompiled
int32_t x;
int32_t y;
int32_t z;
- int16_t intensity1;
- int16_t intensity2;
- int32_t falloff1;
- int32_t falloff2;
+ int16_t intensity_1;
+ int16_t intensity_2;
+ int32_t falloff_1;
+ int32_t falloff_2;
} LIGHT;
typedef struct __unaligned { // decompiled
- int32_t x;
- int32_t y;
- int32_t z;
- int16_t y_rot;
- int16_t shade1;
- int16_t shade2;
+ XYZ_16 pos;
+ struct __unaligned {
+ int16_t y;
+ } rot;
+ int16_t shade_1;
+ int16_t shade_2;
int16_t static_num;
} MESH;
@@ -932,16 +930,18 @@ typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int16_t *data;
PORTALS *portals;
- SECTOR *sector;
- LIGHT *light;
- MESH *mesh;
+ SECTOR *sectors;
+ LIGHT *lights;
+ MESH *meshes;
XYZ_32 pos;
int32_t min_floor;
int32_t max_ceiling;
- int16_t z_size;
- int16_t x_size;
- int16_t ambient1;
- int16_t ambient2;
+ struct __unaligned {
+ int16_t z;
+ int16_t x;
+ } size;
+ int16_t ambient_1;
+ int16_t ambient_2;
int16_t light_mode;
int16_t num_lights;
int16_t num_meshes;
@@ -4014,7 +4014,7 @@ typedef enum {
0x00450F80 0x01F1 -R void __cdecl S_PrintShadow(int16_t radius, const BOUNDS_16 *bounds, const ITEM *item);
0x00451180 0x02F6 -R void __cdecl S_CalculateLight(int32_t x, int32_t y, int32_t z, int16_t room_num);
0x00451480 0x0031 -R void __cdecl S_CalculateStaticLight(int16_t adder);
-0x004514C0 0x0124 -R void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM *room);
+0x004514C0 0x0124 -R void __cdecl S_CalculateStaticMeshLight(int32_t x, int32_t y, int32_t z, int32_t shade_1, int32_t shade_2, ROOM *room);
0x004515F0 0x0206 -R void __cdecl S_LightRoom(ROOM *room);
0x00451800 0x01CC -R void __cdecl S_DrawHealthBar(int32_t percent);
0x004519D0 0x01F6 -R void __cdecl S_DrawAirBar(int32_t percent);
diff --git a/src/game/camera.c b/src/game/camera.c
index c9d5e3e4..ecc68b28 100644
--- a/src/game/camera.c
+++ b/src/game/camera.c
@@ -243,7 +243,7 @@ void __cdecl Camera_SmartShift(
const ROOM *r = &g_Rooms[g_Camera.target.room_num];
int32_t z_sector = (g_Camera.target.z - r->pos.z) >> WALL_SHIFT;
int32_t x_sector = (g_Camera.target.x - r->pos.x) >> WALL_SHIFT;
- int16_t item_box = r->sector[z_sector + x_sector * r->z_size].box;
+ int16_t item_box = r->sectors[z_sector + x_sector * r->size.z].box;
const BOX_INFO *box = &g_Boxes[item_box];
int32_t left = (int32_t)box->left << WALL_SHIFT;
@@ -254,7 +254,7 @@ void __cdecl Camera_SmartShift(
r = &g_Rooms[target->room_num];
z_sector = (target->z - r->pos.z) >> WALL_SHIFT;
x_sector = (target->x - r->pos.x) >> WALL_SHIFT;
- int16_t camera_box = r->sector[z_sector + x_sector * r->z_size].box;
+ int16_t camera_box = r->sectors[z_sector + x_sector * r->size.z].box;
if (camera_box != NO_BOX
&& (target->z < left || target->z > right || target->x < top
diff --git a/src/game/collide.c b/src/game/collide.c
index ae8ba275..6d7753d7 100644
--- a/src/game/collide.c
+++ b/src/game/collide.c
@@ -309,7 +309,7 @@ int32_t __cdecl Collide_CollideStaticObjects(
const ROOM *const room = &g_Rooms[g_DrawRoomsArray[i]];
for (int32_t j = 0; j < room->num_meshes; j++) {
- const MESH *const mesh = &room->mesh[j];
+ const MESH *const mesh = &room->meshes[j];
const STATIC_INFO *const sinfo = &g_StaticObjects[mesh->static_num];
if (sinfo->flags & 1) {
@@ -320,35 +320,35 @@ int32_t __cdecl Collide_CollideStaticObjects(
int32_t x_max;
int32_t z_min;
int32_t z_max;
- int32_t y_min = mesh->y + sinfo->collision_bounds.min_y;
- int32_t y_max = mesh->y + sinfo->collision_bounds.max_y;
- switch (mesh->y_rot) {
+ const int32_t y_min = mesh->pos.y + sinfo->collision_bounds.min_y;
+ const int32_t y_max = mesh->pos.y + sinfo->collision_bounds.max_y;
+ switch (mesh->rot.y) {
case PHD_90:
- x_min = mesh->x + sinfo->collision_bounds.min_z;
- x_max = mesh->x + sinfo->collision_bounds.max_z;
- z_min = mesh->z - sinfo->collision_bounds.max_x;
- z_max = mesh->z - sinfo->collision_bounds.min_x;
+ x_min = mesh->pos.x + sinfo->collision_bounds.min_z;
+ x_max = mesh->pos.x + sinfo->collision_bounds.max_z;
+ z_min = mesh->pos.z - sinfo->collision_bounds.max_x;
+ z_max = mesh->pos.z - sinfo->collision_bounds.min_x;
break;
case -PHD_180:
- x_min = mesh->x - sinfo->collision_bounds.max_x;
- x_max = mesh->x - sinfo->collision_bounds.min_x;
- z_min = mesh->z - sinfo->collision_bounds.max_z;
- z_max = mesh->z - sinfo->collision_bounds.min_z;
+ x_min = mesh->pos.x - sinfo->collision_bounds.max_x;
+ x_max = mesh->pos.x - sinfo->collision_bounds.min_x;
+ z_min = mesh->pos.z - sinfo->collision_bounds.max_z;
+ z_max = mesh->pos.z - sinfo->collision_bounds.min_z;
break;
case -PHD_90:
- x_min = mesh->x - sinfo->collision_bounds.max_z;
- x_max = mesh->x - sinfo->collision_bounds.min_z;
- z_min = mesh->z + sinfo->collision_bounds.min_x;
- z_max = mesh->z + sinfo->collision_bounds.max_x;
+ x_min = mesh->pos.x - sinfo->collision_bounds.max_z;
+ x_max = mesh->pos.x - sinfo->collision_bounds.min_z;
+ z_min = mesh->pos.z + sinfo->collision_bounds.min_x;
+ z_max = mesh->pos.z + sinfo->collision_bounds.max_x;
break;
default:
- x_min = mesh->x + sinfo->collision_bounds.min_x;
- x_max = mesh->x + sinfo->collision_bounds.max_x;
- z_min = mesh->z + sinfo->collision_bounds.min_z;
- z_max = mesh->z + sinfo->collision_bounds.max_z;
+ x_min = mesh->pos.x + sinfo->collision_bounds.min_x;
+ x_max = mesh->pos.x + sinfo->collision_bounds.max_x;
+ z_min = mesh->pos.z + sinfo->collision_bounds.min_z;
+ z_max = mesh->pos.z + sinfo->collision_bounds.max_z;
break;
}
diff --git a/src/game/creature.c b/src/game/creature.c
index 881cd536..9898ef7d 100644
--- a/src/game/creature.c
+++ b/src/game/creature.c
@@ -92,7 +92,7 @@ void __cdecl Creature_AIInfo(ITEM *const item, AI_INFO *const info)
const ROOM *const r = &g_Rooms[item->room_num];
const int32_t z_sector = (item->pos.z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (item->pos.x - r->pos.x) >> WALL_SHIFT;
- item->box_num = r->sector[z_sector + x_sector * r->z_size].box;
+ item->box_num = r->sectors[z_sector + x_sector * r->size.z].box;
info->zone_num = zone[item->box_num];
}
@@ -100,7 +100,7 @@ void __cdecl Creature_AIInfo(ITEM *const item, AI_INFO *const info)
const ROOM *const r = &g_Rooms[enemy->room_num];
const int32_t z_sector = (enemy->pos.z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (enemy->pos.x - r->pos.x) >> WALL_SHIFT;
- enemy->box_num = r->sector[z_sector + x_sector * r->z_size].box;
+ enemy->box_num = r->sectors[z_sector + x_sector * r->size.z].box;
info->enemy_zone_num = zone[enemy->box_num];
}
diff --git a/src/game/items.c b/src/game/items.c
index bcd698d8..fab4ed9d 100644
--- a/src/game/items.c
+++ b/src/game/items.c
@@ -154,7 +154,7 @@ void __cdecl Item_Initialise(const int16_t item_num)
const int32_t dx = (item->pos.x - room->pos.x) >> WALL_SHIFT;
const int32_t dz = (item->pos.z - room->pos.z) >> WALL_SHIFT;
- const SECTOR *const sector = &room->sector[dx * room->z_size + dz];
+ const SECTOR *const sector = &room->sectors[dx * room->size.z + dz];
item->floor = sector->floor << 8;
if (g_SaveGame.bonus_flag && !g_IsDemoLevelType) {
diff --git a/src/game/lara/misc.c b/src/game/lara/misc.c
index 4da0cacd..767f7d34 100644
--- a/src/game/lara/misc.c
+++ b/src/game/lara/misc.c
@@ -1055,7 +1055,7 @@ void __cdecl Lara_BaddieCollision(ITEM *lara_item, COLL_INFO *coll)
if (roomies_count >= MAX_BADDIE_COLLISION) {
break;
}
- roomies[roomies_count++] = portals->portal[i].room;
+ roomies[roomies_count++] = portals->portal[i].room_num;
}
}
@@ -1556,23 +1556,23 @@ int32_t __cdecl Lara_GetWaterDepth(
z_sector = 0;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
- } else if (z_sector >= r->z_size - 1) {
- z_sector = r->z_size - 1;
+ } else if (z_sector >= r->size.z - 1) {
+ z_sector = r->size.z - 1;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
} else if (x_sector < 0) {
x_sector = 0;
- } else if (x_sector >= r->x_size) {
- x_sector = r->x_size - 1;
+ } else if (x_sector >= r->size.x) {
+ x_sector = r->size.x - 1;
}
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
const int16_t data = Room_GetDoor(sector);
if (data == NO_ROOM) {
break;
@@ -1591,7 +1591,7 @@ int32_t __cdecl Lara_GetWaterDepth(
}
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
}
return 0x7FFF;
}
@@ -1605,7 +1605,7 @@ int32_t __cdecl Lara_GetWaterDepth(
}
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
}
return NO_HEIGHT;
}
@@ -1713,7 +1713,7 @@ void __cdecl Lara_WaterCurrent(COLL_INFO *const coll)
const ROOM *const r = &g_Rooms[g_LaraItem->room_num];
const int32_t z_sector = (g_LaraItem->pos.z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (g_LaraItem->pos.x - r->pos.x) >> WALL_SHIFT;
- g_LaraItem->box_num = r->sector[z_sector + x_sector * r->z_size].box;
+ g_LaraItem->box_num = r->sectors[z_sector + x_sector * r->size.z].box;
if (g_Lara.creature == NULL) {
g_Lara.current_active = 0;
diff --git a/src/game/level.c b/src/game/level.c
index c807cf7b..5f577362 100644
--- a/src/game/level.c
+++ b/src/game/level.c
@@ -134,13 +134,13 @@ static void __cdecl M_LoadRooms(VFILE *const file)
VFile_Read(file, r->portals->portal, sizeof(PORTAL) * num_doors);
}
- r->z_size = VFile_ReadS16(file);
- r->x_size = VFile_ReadS16(file);
+ r->size.z = VFile_ReadS16(file);
+ r->size.x = VFile_ReadS16(file);
- r->sector = game_malloc(
- sizeof(SECTOR) * r->z_size * r->x_size, GBUF_ROOM_FLOOR);
- for (int32_t i = 0; i < r->z_size * r->x_size; i++) {
- SECTOR *const sector = &r->sector[i];
+ r->sectors = game_malloc(
+ sizeof(SECTOR) * r->size.z * r->size.x, GBUF_ROOM_FLOOR);
+ for (int32_t i = 0; i < r->size.z * r->size.x; i++) {
+ SECTOR *const sector = &r->sectors[i];
sector->idx = VFile_ReadU16(file);
sector->box = VFile_ReadS16(file);
sector->pit_room = VFile_ReadU8(file);
@@ -149,42 +149,42 @@ static void __cdecl M_LoadRooms(VFILE *const file)
sector->ceiling = VFile_ReadS8(file);
}
- r->ambient1 = VFile_ReadS16(file);
- r->ambient2 = VFile_ReadS16(file);
+ r->ambient_1 = VFile_ReadS16(file);
+ r->ambient_2 = VFile_ReadS16(file);
r->light_mode = VFile_ReadS16(file);
r->num_lights = VFile_ReadS16(file);
if (!r->num_lights) {
- r->light = NULL;
+ r->lights = NULL;
} else {
- r->light =
+ r->lights =
game_malloc(sizeof(LIGHT) * r->num_lights, GBUF_ROOM_LIGHTS);
for (int32_t i = 0; i < r->num_lights; i++) {
- LIGHT *const light = &r->light[i];
- light->x = VFile_ReadS32(file);
- light->y = VFile_ReadS32(file);
- light->z = VFile_ReadS32(file);
- light->intensity1 = VFile_ReadS16(file);
- light->intensity2 = VFile_ReadS16(file);
- light->falloff1 = VFile_ReadS32(file);
- light->falloff2 = VFile_ReadS32(file);
+ LIGHT *const light = &r->lights[i];
+ light->pos.x = VFile_ReadS32(file);
+ light->pos.y = VFile_ReadS32(file);
+ light->pos.z = VFile_ReadS32(file);
+ light->intensity_1 = VFile_ReadS16(file);
+ light->intensity_2 = VFile_ReadS16(file);
+ light->falloff_1 = VFile_ReadS32(file);
+ light->falloff_2 = VFile_ReadS32(file);
}
}
r->num_meshes = VFile_ReadS16(file);
if (!r->num_meshes) {
- r->mesh = NULL;
+ r->meshes = NULL;
} else {
- r->mesh = game_malloc(
+ r->meshes = game_malloc(
sizeof(MESH) * r->num_meshes, GBUF_ROOM_STATIC_MESHES);
for (int32_t i = 0; i < r->num_meshes; i++) {
- MESH *const mesh = &r->mesh[i];
- mesh->x = VFile_ReadS32(file);
- mesh->y = VFile_ReadS32(file);
- mesh->z = VFile_ReadS32(file);
- mesh->y_rot = VFile_ReadS16(file);
- mesh->shade1 = VFile_ReadS16(file);
- mesh->shade2 = VFile_ReadS16(file);
+ MESH *const mesh = &r->meshes[i];
+ mesh->pos.x = VFile_ReadS32(file);
+ mesh->pos.y = VFile_ReadS32(file);
+ mesh->pos.z = VFile_ReadS32(file);
+ mesh->rot.y = VFile_ReadS16(file);
+ mesh->shade_1 = VFile_ReadS16(file);
+ mesh->shade_2 = VFile_ReadS16(file);
mesh->static_num = VFile_ReadS16(file);
}
}
@@ -490,8 +490,8 @@ static void __cdecl M_LoadItems(VFILE *const file)
item->pos.y = VFile_ReadS32(file);
item->pos.z = VFile_ReadS32(file);
item->rot.y = VFile_ReadS16(file);
- item->shade1 = VFile_ReadS16(file);
- item->shade2 = VFile_ReadS16(file);
+ item->shade_1 = VFile_ReadS16(file);
+ item->shade_2 = VFile_ReadS16(file);
item->flags = VFile_ReadS16(file);
if (item->object_id < 0 || item->object_id >= O_NUMBER_OF) {
Shell_ExitSystemFmt(
diff --git a/src/game/lot.c b/src/game/lot.c
index 8ef81cca..40629b1f 100644
--- a/src/game/lot.c
+++ b/src/game/lot.c
@@ -189,7 +189,7 @@ void __cdecl LOT_CreateZone(ITEM *const item)
const ROOM *const r = &g_Rooms[item->room_num];
const int32_t z_sector = (item->pos.z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (item->pos.x - r->pos.x) >> WALL_SHIFT;
- item->box_num = r->sector[z_sector + x_sector * r->z_size].box;
+ item->box_num = r->sectors[z_sector + x_sector * r->size.z].box;
int16_t zone_num = zone[item->box_num];
int16_t flip_num = flip[item->box_num];
diff --git a/src/game/room.c b/src/game/room.c
index bcafe00c..33e3cbe7 100644
--- a/src/game/room.c
+++ b/src/game/room.c
@@ -32,11 +32,11 @@ int32_t __cdecl Room_FindByPos(
for (int32_t i = 0; i < g_RoomCount; i++) {
const ROOM *const room = &g_Rooms[i];
const int32_t x1 = room->pos.x + WALL_L;
- const int32_t x2 = room->pos.x + (room->x_size - 1) * WALL_L;
+ const int32_t x2 = room->pos.x + (room->size.x - 1) * WALL_L;
const int32_t y1 = room->max_ceiling;
const int32_t y2 = room->min_floor;
const int32_t z1 = room->pos.z + WALL_L;
- const int32_t z2 = room->pos.z + (room->z_size - 1) * WALL_L;
+ const int32_t z2 = room->pos.z + (room->size.z - 1) * WALL_L;
if (x >= x1 && x < x2 && y >= y1 && y <= y2 && z >= z1 && z < z2) {
return i;
}
@@ -100,7 +100,7 @@ int16_t __cdecl Room_GetTiltType(
const ROOM *const room = &g_Rooms[sector->pit_room];
const int32_t z_sector = (z - room->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - room->pos.x) >> WALL_SHIFT;
- sector = &room->sector[z_sector + x_sector * room->z_size];
+ sector = &room->sectors[z_sector + x_sector * room->size.z];
}
if ((y + 512 >= (sector->floor << 8)) && sector->idx != 0) {
@@ -127,23 +127,23 @@ SECTOR *__cdecl Room_GetSector(
z_sector = 0;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
- } else if (z_sector >= r->z_size - 1) {
- z_sector = r->z_size - 1;
+ } else if (z_sector >= r->size.z - 1) {
+ z_sector = r->size.z - 1;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
} else if (x_sector < 0) {
x_sector = 0;
- } else if (x_sector >= r->x_size) {
- x_sector = r->x_size - 1;
+ } else if (x_sector >= r->size.x) {
+ x_sector = r->size.x - 1;
}
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
const int16_t door = Room_GetDoor(sector);
if (door == NO_ROOM) {
break;
@@ -159,7 +159,7 @@ SECTOR *__cdecl Room_GetSector(
const ROOM *const r = &g_Rooms[*room_num];
const int32_t z_sector = ((z - r->pos.z) >> WALL_SHIFT);
const int32_t x_sector = ((x - r->pos.x) >> WALL_SHIFT);
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
if (y < (sector->floor << 8)) {
break;
}
@@ -170,7 +170,7 @@ SECTOR *__cdecl Room_GetSector(
const ROOM *const r = &g_Rooms[sector->sky_room];
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
if (y >= (sector->ceiling << 8)) {
break;
}
@@ -195,23 +195,23 @@ int32_t __cdecl Room_GetWaterHeight(
z_sector = 0;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
- } else if (z_sector >= r->z_size - 1) {
- z_sector = r->z_size - 1;
+ } else if (z_sector >= r->size.z - 1) {
+ z_sector = r->size.z - 1;
if (x_sector < 1) {
x_sector = 1;
- } else if (x_sector > r->x_size - 2) {
- x_sector = r->x_size - 2;
+ } else if (x_sector > r->size.x - 2) {
+ x_sector = r->size.x - 2;
}
} else if (x_sector < 0) {
x_sector = 0;
- } else if (x_sector >= r->x_size) {
- x_sector = r->x_size - 1;
+ } else if (x_sector >= r->size.x) {
+ x_sector = r->size.x - 1;
}
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
room_num = Room_GetDoor(sector);
} while (room_num != NO_ROOM);
@@ -223,7 +223,7 @@ int32_t __cdecl Room_GetWaterHeight(
}
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
}
return sector->ceiling << 8;
} else {
@@ -234,7 +234,7 @@ int32_t __cdecl Room_GetWaterHeight(
}
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
}
return NO_HEIGHT;
}
@@ -250,7 +250,7 @@ int32_t __cdecl Room_GetHeight(
const ROOM *const r = &g_Rooms[sector->pit_room];
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- sector = &r->sector[z_sector + x_sector * r->z_size];
+ sector = &r->sectors[z_sector + x_sector * r->size.z];
}
int32_t height = sector->floor << 8;
@@ -651,7 +651,7 @@ int32_t __cdecl Room_GetCeiling(
const ROOM *const r = &g_Rooms[f->sky_room];
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- f = &r->sector[z_sector + x_sector * r->z_size];
+ f = &r->sectors[z_sector + x_sector * r->size.z];
}
int32_t height = f->ceiling << 8;
@@ -690,7 +690,7 @@ int32_t __cdecl Room_GetCeiling(
const ROOM *const r = &g_Rooms[f->pit_room];
const int32_t z_sector = (z - r->pos.z) >> WALL_SHIFT;
const int32_t x_sector = (x - r->pos.x) >> WALL_SHIFT;
- f = &r->sector[z_sector + x_sector * r->z_size];
+ f = &r->sectors[z_sector + x_sector * r->size.z];
}
if (!f->idx) {
diff --git a/src/game/room_draw.c b/src/game/room_draw.c
index c7f04be2..179a0863 100644
--- a/src/game/room_draw.c
+++ b/src/game/room_draw.c
@@ -65,9 +65,9 @@ void __cdecl Room_GetBounds(void)
// clang-format off
const XYZ_32 offset = {
- .x = portal->x * (r->pos.x + portal->vertex[0].x - g_W2VMatrix._03),
- .y = portal->y * (r->pos.y + portal->vertex[0].y - g_W2VMatrix._13),
- .z = portal->z * (r->pos.z + portal->vertex[0].z - g_W2VMatrix._23),
+ .x = portal->normal.x * (r->pos.x + portal->vertex[0].x - g_W2VMatrix._03),
+ .y = portal->normal.y * (r->pos.y + portal->vertex[0].y - g_W2VMatrix._13),
+ .z = portal->normal.z * (r->pos.z + portal->vertex[0].z - g_W2VMatrix._23),
};
// clang-format on
@@ -75,7 +75,7 @@ void __cdecl Room_GetBounds(void)
continue;
}
- Room_SetBounds(&portal->x, portal->room, r);
+ Room_SetBounds(&portal->normal.x, portal->room_num, r);
}
Matrix_Pop();
}
@@ -238,33 +238,33 @@ void __cdecl Room_Clip(const ROOM *const r)
yv[0] = r->max_ceiling - r->pos.y;
zv[0] = WALL_L;
- xv[1] = (r->x_size - 1) * WALL_L;
+ xv[1] = (r->size.x - 1) * WALL_L;
yv[1] = r->max_ceiling - r->pos.y;
zv[1] = WALL_L;
- xv[2] = (r->x_size - 1) * WALL_L;
+ xv[2] = (r->size.x - 1) * WALL_L;
yv[2] = r->max_ceiling - r->pos.y;
- zv[2] = (r->z_size - 1) * WALL_L;
+ zv[2] = (r->size.z - 1) * WALL_L;
xv[3] = WALL_L;
yv[3] = r->max_ceiling - r->pos.y;
- zv[3] = (r->z_size - 1) * WALL_L;
+ zv[3] = (r->size.z - 1) * WALL_L;
xv[4] = WALL_L;
yv[4] = r->min_floor - r->pos.y;
zv[4] = WALL_L;
- xv[5] = (r->x_size - 1) * WALL_L;
+ xv[5] = (r->size.x - 1) * WALL_L;
yv[5] = r->min_floor - r->pos.y;
zv[5] = WALL_L;
- xv[6] = (r->x_size - 1) * WALL_L;
+ xv[6] = (r->size.x - 1) * WALL_L;
yv[6] = r->min_floor - r->pos.y;
- zv[6] = (r->z_size - 1) * WALL_L;
+ zv[6] = (r->size.z - 1) * WALL_L;
xv[7] = WALL_L;
yv[7] = r->min_floor - r->pos.y;
- zv[7] = (r->z_size - 1) * WALL_L;
+ zv[7] = (r->size.z - 1) * WALL_L;
bool clip_room = false;
bool clip[8];
@@ -398,17 +398,18 @@ void __cdecl Room_DrawSingleRoomObjects(const int16_t room_num)
g_PhdWinBottom = r->bound_bottom;
for (int32_t i = 0; i < r->num_meshes; i++) {
- const MESH *const mesh = &r->mesh[i];
+ const MESH *const mesh = &r->meshes[i];
const STATIC_INFO *const static_obj =
&g_StaticObjects[mesh->static_num];
if (static_obj->flags & 2) {
Matrix_Push();
- Matrix_TranslateAbs(mesh->x, mesh->y, mesh->z);
- Matrix_RotY(mesh->y_rot);
+ Matrix_TranslateAbs(mesh->pos.x, mesh->pos.y, mesh->pos.z);
+ Matrix_RotY(mesh->rot.y);
const int16_t bounds = S_GetObjectBounds(&static_obj->draw_bounds);
if (bounds) {
S_CalculateStaticMeshLight(
- mesh->x, mesh->y, mesh->z, mesh->shade1, mesh->shade2, r);
+ mesh->pos.x, mesh->pos.y, mesh->pos.z, mesh->shade_1,
+ mesh->shade_2, r);
Output_InsertPolygons(g_Meshes[static_obj->mesh_idx], bounds);
}
Matrix_Pop();
diff --git a/src/global/funcs.h b/src/global/funcs.h
index 9bebff30..11a0cd15 100644
--- a/src/global/funcs.h
+++ b/src/global/funcs.h
@@ -324,7 +324,7 @@
#define S_PrintShadow ((void __cdecl (*)(int16_t radius, const BOUNDS_16 *bounds, const ITEM *item))0x00450F80)
#define S_CalculateLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t room_num))0x00451180)
#define S_CalculateStaticLight ((void __cdecl (*)(int16_t adder))0x00451480)
-#define S_CalculateStaticMeshLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t shade1, int32_t shade2, ROOM *room))0x004514C0)
+#define S_CalculateStaticMeshLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t shade_1, int32_t shade_2, ROOM *room))0x004514C0)
#define S_LightRoom ((void __cdecl (*)(ROOM *room))0x004515F0)
#define S_DrawHealthBar ((void __cdecl (*)(int32_t percent))0x00451800)
#define S_DrawAirBar ((void __cdecl (*)(int32_t percent))0x004519D0)
diff --git a/subprojects/libtrx b/subprojects/libtrx
index 198f1036..0776388f 160000
--- a/subprojects/libtrx
+++ b/subprojects/libtrx
@@ -1 +1 @@
-Subproject commit 198f10361bc0994678deccbd281393750f39ab69
+Subproject commit 0776388ff52e6dade3ffc8d469806ec43a0dce18