[Scummvm-git-logs] scummvm master -> 072fead8da0854437101de4bd72f62555e2c7d4c
aquadran
noreply at scummvm.org
Sat Jul 30 13:14:36 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
072fead8da ICB: Avoid casting LinkedDataFile class to memory
Commit: 072fead8da0854437101de4bd72f62555e2c7d4c
https://github.com/scummvm/scummvm/commit/072fead8da0854437101de4bd72f62555e2c7d4c
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-07-30T15:14:30+02:00
Commit Message:
ICB: Avoid casting LinkedDataFile class to memory
Changed paths:
engines/icb/animation.cpp
engines/icb/barriers.cpp
engines/icb/barriers.h
engines/icb/bone.cpp
engines/icb/chi.cpp
engines/icb/common/px_common.h
engines/icb/common/px_linkeddatafile.cpp
engines/icb/common/px_linkeddatafile.h
engines/icb/custom_logics.cpp
engines/icb/floors.cpp
engines/icb/floors.h
engines/icb/fn_animation.cpp
engines/icb/fn_event_functions.cpp
engines/icb/fn_interact.cpp
engines/icb/fn_sound.cpp
engines/icb/function.cpp
engines/icb/game_volume.cpp
engines/icb/game_volume.h
engines/icb/global_objects.cpp
engines/icb/global_objects.h
engines/icb/health_bar_pc.cpp
engines/icb/icon_menu_pc.cpp
engines/icb/line_of_sight.cpp
engines/icb/line_of_sight.h
engines/icb/logic.cpp
engines/icb/mega_interaction.cpp
engines/icb/mission.cpp
engines/icb/options_manager_pc.cpp
engines/icb/options_manager_pc.h
engines/icb/p4_pc.cpp
engines/icb/player.cpp
engines/icb/player_interaction.cpp
engines/icb/remora.cpp
engines/icb/remora_pc.cpp
engines/icb/route_manager.cpp
engines/icb/session.cpp
engines/icb/session.h
engines/icb/set.cpp
engines/icb/sound.cpp
engines/icb/sound_logic.cpp
engines/icb/speech.cpp
engines/icb/stagedraw_pc_poly.cpp
engines/icb/tracer.cpp
engines/icb/tracer.h
diff --git a/engines/icb/animation.cpp b/engines/icb/animation.cpp
index 2513402d7bf..28cc29c7e21 100644
--- a/engines/icb/animation.cpp
+++ b/engines/icb/animation.cpp
@@ -68,7 +68,7 @@ mcodeFunctionReturnCodes _game_session::fn_prop_animate(int32 &, int32 *params)
uint32 j;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -132,7 +132,7 @@ mcodeFunctionReturnCodes _game_session::fn_prop_set_to_last_frame(int32 &, int32
uint32 j;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -163,7 +163,7 @@ mcodeFunctionReturnCodes _game_session::fn_prop_set_to_first_frame(int32 &, int3
uint32 j;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -196,7 +196,7 @@ mcodeFunctionReturnCodes _game_session::fn_test_prop_anim(int32 &result, int32 *
uint32 j;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -235,7 +235,7 @@ uint32 _game_session::Validate_prop_anim(const char *anim_name) {
uint32 j;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
// loop through all looking for our named anim
for (j = 0; j < index->num_anims; j++) {
@@ -276,7 +276,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height_id(int32 &,
Zdebug("fn_inherit_prop_anim_height_id");
// find entry for this object via its name, which we find via its number :(
- index = (_animating_prop *)prop_anims->Fetch_item_by_name((const char *)objects->Fetch_items_name_by_number(params[0]));
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_name(prop_anims, (const char *)LinkedDataObject::Fetch_items_name_by_number(objects, params[0]));
// loop through all looking for our named anim
for (j = 0; j < index->num_anims; j++) {
@@ -345,7 +345,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height_id(int32 &,
}
// didnt find the named anim so thats it
- Fatal_error("fn_inherit_prop_anim_height_id object [%s] prop [%s] cant find anim [%s]", object->GetName(), objects->Fetch_items_name_by_number(params[0]), anim_name);
+ Fatal_error("fn_inherit_prop_anim_height_id object [%s] prop [%s] cant find anim [%s]", object->GetName(), LinkedDataObject::Fetch_items_name_by_number(objects, params[0]), anim_name);
return (IR_STOP);
}
@@ -373,7 +373,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height(int32 &, int
Zdebug("prop %s anim %s", prop_name, anim_name);
// find entry for this object via its name, which we find via its number :(
- index = (_animating_prop *)prop_anims->Fetch_item_by_name(prop_name);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_name(prop_anims, prop_name);
// loop through all looking for our named anim
for (j = 0; j < index->num_anims; j++) {
diff --git a/engines/icb/barriers.cpp b/engines/icb/barriers.cpp
index adb3d4a35bf..8e172172789 100644
--- a/engines/icb/barriers.cpp
+++ b/engines/icb/barriers.cpp
@@ -503,9 +503,9 @@ void _barrier_handler::___init() {
Tdebug("barriers.txt", "%s", (const char *)temp_buf);
uint32 buf_hash = NULL_HASH;
uint32 cluster_hash = MS->Fetch_session_cluster_hash();
- raw_barriers = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
+ raw_barriers = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
- num_bars = (uint32 *)raw_barriers->Fetch_item_by_name("Count");
+ num_bars = (uint32 *)LinkedDataObject::Fetch_item_by_name(raw_barriers, "Count");
total_barriers = *(num_bars);
@@ -519,9 +519,9 @@ void _barrier_handler::___init() {
Tdebug("barriers.txt", "%s", temp_buf);
buf_hash = NULL_HASH;
- route_wrapper = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
+ route_wrapper = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
- total_slices = route_wrapper->Fetch_number_of_items();
+ total_slices = LinkedDataObject::Fetch_number_of_items(route_wrapper);
if (total_slices > MAX_slices)
Fatal_error("_barrier_handler::___init finds too many slices - %d but only %d allowed", total_slices, MAX_slices);
@@ -535,7 +535,7 @@ void _barrier_handler::___init() {
uint32 j;
for (j = 0; j < total_slices; j++) {
- slice = (_routing_slice *)route_wrapper->Fetch_item_by_number(j);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, j);
Tdebug("slice.txt", "bottom %3.1f top %3.1f", slice->bottom, slice->top);
Tdebug("slice.txt", "%d parents", slice->num_parent_boxes);
}
@@ -821,7 +821,7 @@ _parent_box *_barrier_handler::Fetch_parent_num_on_slice_y(uint32 requested_pare
// first time in so compute the slice
if (!requested_parent) {
while (1) {
- slice = (_routing_slice *)route_wrapper->Fetch_item_by_number(cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((y >= slice->bottom) && (y < slice->top))
break;
@@ -857,7 +857,7 @@ _route_barrier *_barrier_handler::Fetch_barrier(uint32 num) {
if (num >= total_barriers)
Fatal_error("illegal barrier request %d", num);
- bar = (_route_barrier *)raw_barriers->Fetch_item_by_name("Data");
+ bar = (_route_barrier *)LinkedDataObject::Fetch_item_by_name(raw_barriers, "Data");
return &bar[num];
}
@@ -875,7 +875,7 @@ _parent_box *_barrier_handler::Fetch_parent_box_for_xyz(PXreal x, PXreal y, PXre
slice_num = 0;
while (1) {
- slice = (_routing_slice *)route_wrapper->Fetch_item_by_number(slice_num);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, slice_num);
if ((y >= slice->bottom) && (y < slice->top))
break;
@@ -929,7 +929,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
z = M->actor_xyz.z;
// on previous slice?
- slice = (_routing_slice *)session_barriers->route_wrapper->Fetch_item_by_number(M->cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
if ((y >= slice->bottom) && (y < slice->top) && (M->cur_parent))
if ((x > M->cur_parent->left) && (x < M->cur_parent->right) && (z > M->cur_parent->back) && (z < M->cur_parent->front)) {
// nothing has changed
@@ -944,7 +944,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
M->cur_slice = 0;
while (1) {
- slice = (_routing_slice *)session_barriers->route_wrapper->Fetch_item_by_number(M->cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
if ((y >= slice->bottom) && (y < slice->top))
break;
@@ -952,7 +952,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
M->cur_slice++;
if (M->cur_slice == session_barriers->total_slices) { // if so then must be last slice :O
M->cur_slice--;
- slice = (_routing_slice *)session_barriers->route_wrapper->Fetch_item_by_number(M->cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(session_barriers->route_wrapper, M->cur_slice);
break;
}
}
@@ -1077,13 +1077,13 @@ void _barrier_handler::Prepare_animating_barriers() {
Tdebug("anim_barriers.txt", "Preparing animating barriers");
- for (j = 0; j < MS->prop_anims->Fetch_number_of_items(); j++) {
- Tdebug("anim_barriers.txt", "\n%d %s", j, MS->prop_anims->Fetch_items_name_by_number(j));
+ for (j = 0; j < LinkedDataObject::Fetch_number_of_items(MS->prop_anims); j++) {
+ Tdebug("anim_barriers.txt", "\n%d %s", j, LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j));
_animating_prop *index;
_animation_entry *anim;
- index = (_animating_prop *)MS->prop_anims->Fetch_item_by_number(j);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(MS->prop_anims, j);
Tdebug("anim_barriers.txt", " has %d anims", index->num_anims);
@@ -1126,7 +1126,7 @@ void _barrier_handler::Prepare_animating_barriers() {
cur_slice = 0;
do {
- slice = (_routing_slice *)route_wrapper->Fetch_item_by_number(cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((bar->bottom() >= slice->bottom) && (bar->bottom() < slice->top))
break;
@@ -1145,12 +1145,11 @@ void _barrier_handler::Prepare_animating_barriers() {
"- %d parents",
slice->num_parent_boxes);
- int32 prop_number =
- MS->objects->Fetch_item_number_by_name((const char *)MS->prop_anims->Fetch_items_name_by_number(j));
+ int32 prop_number = LinkedDataObject::Fetch_item_number_by_name(MS->prop_anims, (const char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j));
if (prop_number == -1) {
Tdebug("anim_barriers.txt", " !!associated prop [%s] not a game object - so ignoring",
- (const char *)MS->prop_anims->Fetch_items_name_by_number(j));
+ (const char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j));
} else {
// now find parent the barrier would belong to
for (f = 0; f < slice->num_parent_boxes; f++) {
@@ -1161,8 +1160,8 @@ void _barrier_handler::Prepare_animating_barriers() {
// do we lie within the box?
if ((bar->x1() > parent->left) && (bar->x1() < parent->right) && (bar->z1() > parent->back) &&
(bar->z1() < parent->front)) {
- char *props_name = (char *)MS->prop_anims->Fetch_items_name_by_number(j);
- uint32 props_number = MS->objects->Fetch_item_number_by_name(props_name);
+ char *props_name = (char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j);
+ uint32 props_number = LinkedDataObject::Fetch_item_number_by_name(MS->objects, props_name);
if (!anim_slices[cur_slice].anim_parents[f]) {
anim_slices[cur_slice].anim_parents[f] = &anim_parent_table[parents_used++];
@@ -1232,12 +1231,12 @@ void _barrier_handler::Prepare_animating_barriers() {
for (j = 0; j < MAX_props; j++)
anim_prop_info[j].barriers_per_state = 0; // do it here so it can double up as 0 being an unused entry
- for (j = 0; j < MS->prop_anims->Fetch_number_of_items(); j++) {
- Tdebug("anim_barriers.txt", "\n**%d %s", j, MS->prop_anims->Fetch_items_name_by_number(j));
+ for (j = 0; j < LinkedDataObject::Fetch_number_of_items(MS->prop_anims); j++) {
+ Tdebug("anim_barriers.txt", "\n**%d %s", j, LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j));
_animating_prop *index;
_animation_entry *anim;
- index = (_animating_prop *)MS->prop_anims->Fetch_item_by_number(j);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(MS->prop_anims, j);
// loop through all looking for our named anim
if (index->num_anims) {
@@ -1272,7 +1271,7 @@ void _barrier_handler::Prepare_animating_barriers() {
// now compute slice for sample barrier
cur_slice = 0;
do {
- slice = (_routing_slice *)route_wrapper->Fetch_item_by_number(cur_slice);
+ slice = (_routing_slice *)LinkedDataObject::Fetch_item_by_number(route_wrapper, cur_slice);
if ((bar->bottom() >= slice->bottom) && (bar->bottom() < slice->top))
break;
cur_slice++;
@@ -1285,7 +1284,7 @@ void _barrier_handler::Prepare_animating_barriers() {
Tdebug("anim_barriers.txt", " sample bar puts prop in slice %d", cur_slice);
// get the prop number
- uint32 prop_number = MS->objects->Fetch_item_number_by_name((const char *)MS->prop_anims->Fetch_items_name_by_number(j));
+ uint32 prop_number = LinkedDataObject::Fetch_item_number_by_name(MS->prop_anims, (const char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j));
// gotta check for anims with no equivelent game objects
if (prop_number != 0xffffffff) {
@@ -1336,7 +1335,7 @@ void _barrier_handler::Prepare_animating_barriers() {
// ok, we've set up the anim barriers for this prop
Tdebug("anim_barriers.txt", " prop [%s] highest state %d, %d bars per state",
- (const char *)MS->prop_anims->Fetch_items_name_by_number(j), total_states,
+ (const char *)LinkedDataObject::Fetch_items_name_by_number(MS->prop_anims, j), total_states,
anim_prop_info[prop_number].barriers_per_state);
// note down total states
@@ -1371,7 +1370,7 @@ void _barrier_handler::Prepare_animating_barriers() {
for (j = 0; j < MS->Fetch_number_of_objects(); j++)
if (anim_prop_info[j].barriers_per_state) {
Tdebug("anim_barriers.txt", "prop %d", j);
- Tdebug("anim_barriers.txt", "prop %d [%s] has %d anim barriers, %d per frame", j, (const char *)MS->objects->Fetch_items_name_by_number(j),
+ Tdebug("anim_barriers.txt", "prop %d [%s] has %d anim barriers, %d per frame", j, (const char *)LinkedDataObject::Fetch_items_name_by_number(MS->objects, j),
anim_prop_info[j].total_states, anim_prop_info[j].barriers_per_state);
Tdebug("anim_barriers.txt", "total %d", anim_prop_info[j].barriers_per_state * (anim_prop_info[j].total_states));
for (uint16 k = 0; k < anim_prop_info[j].barriers_per_state * (anim_prop_info[j].total_states); k++)
diff --git a/engines/icb/barriers.h b/engines/icb/barriers.h
index c28d76fabcc..500350b699c 100644
--- a/engines/icb/barriers.h
+++ b/engines/icb/barriers.h
@@ -93,7 +93,7 @@ public:
_child_group *Fetch_child_box(_parent_box *parent, uint32 child);
_route_barrier *Fetch_barrier(uint32 num);
uint32 Fetch_total_barriers();
- _linked_data_file *Get_barrier_pointer() const { return raw_barriers; }
+ LinkedDataFile *Get_barrier_pointer() const { return raw_barriers; }
void Prepare_animating_barriers();
uint32 Get_anim_barriers(uint32 n, uint32 *oThisCubesBarriers, uint32 slice);
@@ -110,12 +110,12 @@ public:
_animating_parent anim_parent_table[MAX_floors]; // storage
// raw barriers
- _linked_data_file *raw_barriers; // raw route barriers used for routing/line of sight and maybe shadow geometry
+ LinkedDataFile *raw_barriers; // raw route barriers used for routing/line of sight and maybe shadow geometry
uint32 total_barriers;
// route barrier wrapper file
- _linked_data_file *route_wrapper;
+ LinkedDataFile *route_wrapper;
uint32 total_slices; // useful out of file
diff --git a/engines/icb/bone.cpp b/engines/icb/bone.cpp
index c70d7a6c5a5..003679f5a1b 100644
--- a/engines/icb/bone.cpp
+++ b/engines/icb/bone.cpp
@@ -280,7 +280,7 @@ void UpdatePlayerLook() {
// target is an actor so need adjustment for eye height...
if (target->image_type == VOXEL) {
- c_game_object *pGameObject = (c_game_object *)MS->objects->Fetch_item_by_number(sel_id);
+ c_game_object *pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, sel_id);
int32 dead = pGameObject->GetIntegerVariable(pGameObject->GetVariable("state"));
if (target->object_type == __NON_ORGANIC_MEGA) { // robot (look down)
@@ -479,7 +479,7 @@ mcodeFunctionReturnCodes _game_session::speak_simple_look(int32 &, int32 *params
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// object
- int32 object_id = objects->Fetch_item_number_by_name(object_name);
+ int32 object_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// direction
int32 l = params[1];
@@ -564,7 +564,7 @@ mcodeFunctionReturnCodes _game_session::speak_set_neck_vector(int32 &, int32 *pa
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- object_id = objects->Fetch_item_number_by_name(object_name);
+ object_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
x = params[1];
y = params[2];
z = params[3];
diff --git a/engines/icb/chi.cpp b/engines/icb/chi.cpp
index 709e9c976b2..568f2620057 100644
--- a/engines/icb/chi.cpp
+++ b/engines/icb/chi.cpp
@@ -117,7 +117,7 @@ mcodeFunctionReturnCodes _game_session::fn_record_player_interaction(int32 &, in
history[cur_history].interaction = TRUE8;
history[cur_history].id = M->target_id;
- Tdebug("history.txt", "-> [%s] %d", objects->Fetch_items_name_by_number(M->target_id), M->target_id);
+ Tdebug("history.txt", "-> [%s] %d", LinkedDataObject::Fetch_items_name_by_number(objects, M->target_id), M->target_id);
return IR_CONT;
}
@@ -126,7 +126,7 @@ mcodeFunctionReturnCodes _game_session::fn_send_chi_to_named_object(int32 &, int
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
uint32 id;
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_send_chi_to_named_object - illegal object [%s]", object_name);
diff --git a/engines/icb/common/px_common.h b/engines/icb/common/px_common.h
index 4d9d8f71e22..449ab8a9c70 100644
--- a/engines/icb/common/px_common.h
+++ b/engines/icb/common/px_common.h
@@ -97,20 +97,14 @@ enum _file_type {
#define STANDARD_HEADER_NAME_LENGTH 32 // Max length of the header name
-class px_standard_header {
-public:
+typedef struct {
int32 version; // This is incremented every time the object is updated
_file_type type; // enumerated value for every type of object in the game
int32 owner; // Who is responsible for producing this object
int32 unused; // For future expansion
int32 unused2; // For future expansion
char name[STANDARD_HEADER_NAME_LENGTH]; // 32 bytes worth of ascii name information
-
- void SetData(int32 version, _file_type type, int32 owner, const char *name);
- _file_type GetType() { return (type); }
- const char *GetName() { return (name); }
- uint32 GetVersion() { return (version); }
-};
+} px_standard_header;
typedef struct {
uint8 red;
diff --git a/engines/icb/common/px_linkeddatafile.cpp b/engines/icb/common/px_linkeddatafile.cpp
index 3442bb94921..bc61157bda8 100644
--- a/engines/icb/common/px_linkeddatafile.cpp
+++ b/engines/icb/common/px_linkeddatafile.cpp
@@ -33,19 +33,19 @@
namespace ICB {
// get NUMBER given HASH (does the search) - hashs must be ordered for this binary search to succeed.
-uint32 _linked_data_file::Fetch_item_number_by_hash(const uint32 hash) {
+uint32 LinkedDataObject::Fetch_item_number_by_hash(LinkedDataFile *file, const uint32 hash) {
int32 top, bottom;
int32 i;
uint32 current;
- if (!number_of_items)
+ if (!FROM_LE_32(file->number_of_items))
return PX_LINKED_DATA_FILE_ERROR;
- top = number_of_items - 1;
+ top = FROM_LE_32(file->number_of_items) - 1;
i = top >> 1;
bottom = 0;
for (;;) {
- current = list[i].name_hash_value;
+ current = FROM_LE_32(file->list[i].name_hash_value);
if (hash == current)
return i;
else if (top == bottom)
diff --git a/engines/icb/common/px_linkeddatafile.h b/engines/icb/common/px_linkeddatafile.h
index a0f35d0efc6..c2c5aae2b27 100644
--- a/engines/icb/common/px_linkeddatafile.h
+++ b/engines/icb/common/px_linkeddatafile.h
@@ -32,6 +32,8 @@
#include "engines/icb/common/px_clu_api.h"
#include "engines/icb/debug.h"
+#include "common/endian.h"
+
namespace ICB {
// This value is returned as an error condition.
@@ -46,80 +48,82 @@ typedef struct {
int32 data_offset; // Offset to the item
int32 data_size; // Size of the items data
uint32 name_hash_value; // hash value of name item...
-} _linkedDataFileEntry;
+} LinkedDataFileEntry;
-class _linked_data_file { // Should be CObjectFile
+typedef struct {
+ px_standard_header header;
-public:
- inline uint32 Fetch_number_of_items() { // how many
- return (number_of_items);
- }
+ uint32 number_of_items;
+ uint32 flags;
- inline uint32 GetHeaderVersion() { return (header.GetVersion()); }
+ LinkedDataFileEntry list[1]; // 1 used to prevent 0 sized array warnings
+ // This structure is a variable size and so should never
+ // be a parameter to sizeof anyway
+} LinkedDataFile;
- inline int32 OrderPreserved() { return ((flags) & (ORDER_PRESERVED_FLAG)); }
+class LinkedDataObject { // Should be CObjectFile
- inline int32 NameSearchable() { return (!OrderPreserved()); }
+public:
+ static inline uint32 Fetch_number_of_items(LinkedDataFile *file) { // how many
+ return (FROM_LE_32(file->number_of_items));
+ }
- uint32 Fetch_item_number_by_hash(const uint32 hash);
- uint32 Fetch_item_number_by_name(const char *name); // reference a number by its ascii name
+ static inline uint32 GetHeaderVersion(LinkedDataFile *file) { return (FROM_LE_32(file->header.version)); }
- void *Fetch_item_by_number(uint32 number); // reference a resource by number
+ static inline int32 OrderPreserved(LinkedDataFile *file) { return (FROM_LE_32(file->flags) & (ORDER_PRESERVED_FLAG)); }
- void *Fetch_item_by_name(const char *name); // reference a resource by its ascii name
+ static inline int32 NameSearchable(LinkedDataFile *file) { return (!OrderPreserved(file)); }
- void *Fetch_items_name_by_number(uint32 number); // return pointer to name of item number n
+ static uint32 Fetch_item_number_by_hash(LinkedDataFile *file, const uint32 hash);
+ static uint32 Fetch_item_number_by_name(LinkedDataFile *file, const char *name); // reference a number by its ascii name
- void *Try_fetch_item_by_name(const char *); // reference a resource by name
- void *Try_fetch_item_by_hash(uint32); // reference a resource by hash
+ static void *Fetch_item_by_number(LinkedDataFile *file, uint32 number); // reference a resource by number
- void *Try_fetch_item_by_script_name(const char *name);
+ static void *Fetch_item_by_name(LinkedDataFile *file, const char *name); // reference a resource by its ascii name
- px_standard_header header;
+ static void *Fetch_items_name_by_number(LinkedDataFile *file, uint32 number); // return pointer to name of item number n
- uint32 number_of_items;
- uint32 flags;
+ static void *Try_fetch_item_by_name(LinkedDataFile *file, const char *); // reference a resource by name
+ static void *Try_fetch_item_by_hash(LinkedDataFile *file, uint32); // reference a resource by hash
- _linkedDataFileEntry list[1]; // 1 used to prevent 0 sized array warnings
- // This structure is a variable size and so should never
- // be a parameter to sizeof anyway
+ static void *Try_fetch_item_by_script_name(LinkedDataFile *file, const char *name);
};
// get DATA given NUMBER
-inline void *_linked_data_file::Fetch_item_by_number(uint32 number) {
+inline void *LinkedDataObject::Fetch_item_by_number(LinkedDataFile *file, uint32 number) {
// illegal reference number
- assert(number < number_of_items);
+ assert(number < FROM_LE_32(file->number_of_items));
// return address of resource
- return (((uint8 *)&header) + list[number].data_offset);
+ return (((uint8 *)&file->header) + FROM_LE_32(file->list[number].data_offset));
}
// get NAME given NUMBER
-inline void *_linked_data_file::Fetch_items_name_by_number(uint32 number) {
+inline void *LinkedDataObject::Fetch_items_name_by_number(LinkedDataFile *file, uint32 number) {
// illegal reference number
- assert(number < number_of_items);
+ assert(number < FROM_LE_32(file->number_of_items));
// return name
- return (((uint8 *)&header) + list[number].name_offset);
+ return (((uint8 *)&file->header) + FROM_LE_32(file->list[number].name_offset));
}
// this is the one that does the search...
// get NUMBER given NAME (does search)
-inline uint32 _linked_data_file::Fetch_item_number_by_name(const char *name) {
+inline uint32 LinkedDataObject::Fetch_item_number_by_name(LinkedDataFile *file, const char *name) {
uint32 hash;
- if (!NameSearchable()) {
+ if (!NameSearchable(file)) {
Fatal_error("This file is not searchable by name and was created as such (name %s)", name);
}
hash = EngineHashString(name);
- return Fetch_item_number_by_hash(hash);
+ return Fetch_item_number_by_hash(file, hash);
}
// get ITEM given NAME (uses Try_fetch_item_by_name, fatal error if can't find)
-inline void *_linked_data_file::Fetch_item_by_name(const char *name) {
+inline void *LinkedDataObject::Fetch_item_by_name(LinkedDataFile *file, const char *name) {
void *search;
- search = Try_fetch_item_by_name(name);
+ search = Try_fetch_item_by_name(file, name);
if (search == 0) {
Fatal_error("pxLinked_data_file::Fetch_item_by_name Object %s not found", name);
@@ -132,40 +136,40 @@ inline void *_linked_data_file::Fetch_item_by_name(const char *name) {
}
// get DATA given NAME (uses get NUMBER given NAME and returns 0 if not found or uses get DATA given NUMBER to return DATA)
-inline void *_linked_data_file::Try_fetch_item_by_name(const char *name) {
+inline void *LinkedDataObject::Try_fetch_item_by_name(LinkedDataFile *file, const char *name) {
// as Fetch_item_with_name but will return 0 if entry could not be found as opposed to an assert
uint32 search = 0;
- search = Fetch_item_number_by_name(name);
+ search = Fetch_item_number_by_name(file, name);
if (search == PX_LINKED_DATA_FILE_ERROR)
return 0; // not found (legal)
else
- return Fetch_item_by_number(search);
+ return Fetch_item_by_number(file, search);
}
// get DATA given HASH (uses get NUMBER given HASH and returns 0 if not found or uses get DATA given NUMBER to return DATA)
-inline void *_linked_data_file::Try_fetch_item_by_hash(uint32 hash) {
+inline void *LinkedDataObject::Try_fetch_item_by_hash(LinkedDataFile *file, uint32 hash) {
// as Fetch_item_with_name but will return 0 if entry could not be found as opposed to an assert
uint32 search = 0;
- search = Fetch_item_number_by_hash(hash);
+ search = Fetch_item_number_by_hash(file, hash);
if (search == PX_LINKED_DATA_FILE_ERROR)
return 0; // not found (legal)
else
- return Fetch_item_by_number(search);
+ return Fetch_item_by_number(file, search);
}
-inline void *_linked_data_file::Try_fetch_item_by_script_name(const char *name) {
+inline void *LinkedDataObject::Try_fetch_item_by_script_name(LinkedDataFile *file, const char *name) {
uint32 search = 0;
do {
- if (strstr((const char *)((uint8 *)&header) + list[search].name_offset, (const char *)name))
- return (((uint8 *)&header) + list[search].data_offset);
+ if (strstr((const char *)((uint8 *)&file->header) + FROM_LE_32(file->list[search].name_offset), (const char *)name))
+ return (((uint8 *)&file->header) + FROM_LE_32(file->list[search].data_offset));
search++;
- } while (search < number_of_items);
+ } while (search < FROM_LE_32(file->number_of_items));
// not found at all
return (0);
diff --git a/engines/icb/custom_logics.cpp b/engines/icb/custom_logics.cpp
index 15688ba43a8..1b8d7f617cc 100644
--- a/engines/icb/custom_logics.cpp
+++ b/engines/icb/custom_logics.cpp
@@ -56,7 +56,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_simple_animator(int32 &, i
_animation_entry *anim;
// find entry for this object via its name
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
// get anim
anim = (_animation_entry *)(((char *)index) + index->anims[0]);
@@ -73,7 +73,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_simple_animator(int32 &, i
L->big_mode = __CUSTOM_SIMPLE_ANIMATE;
- SA_INDEX = prop_anims->Fetch_item_number_by_name(object->GetName());
+ SA_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
// object will pause when off screen
L->hold_mode = prop_camera_hold;
@@ -90,7 +90,7 @@ void _game_session::Custom_simple_animator() {
_animation_entry *anim;
// get index for object
- index = (_animating_prop *)prop_anims->Fetch_item_by_number(SA_INDEX);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(prop_anims, SA_INDEX);
// now then, lets make the assumption that anim 0 will be the 'looping' one
anim = (_animation_entry *)(((char *)index) + index->anims[0]);
@@ -117,7 +117,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_button_operated_door(int32
// switch out of script mode
L->big_mode = __CUSTOM_BUTTON_OPERATED_DOOR;
- BOD_INDEX = prop_anims->Fetch_item_number_by_name(object->GetName());
+ BOD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
BOD_OPEN_NO = Validate_prop_anim("opening");
BOD_CLOSE_NO = Validate_prop_anim("closing");
@@ -170,7 +170,7 @@ void _game_session::Custom_button_operated_door() {
if (BOD_CONTROL == BOD_OPENING) {
// get index for object
- index = (_animating_prop *)prop_anims->Fetch_item_by_number(BOD_INDEX);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(prop_anims, BOD_INDEX);
anim = (_animation_entry *)(((char *)index) + index->anims[BOD_OPEN_NO]);
prop_state_table[cur_id] = anim->frames[L->anim_pc];
@@ -187,7 +187,7 @@ void _game_session::Custom_button_operated_door() {
return;
} else if (BOD_CONTROL == BOD_CLOSING) {
// get index for object
- index = (_animating_prop *)prop_anims->Try_fetch_item_by_name(object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
anim = (_animation_entry *)(((char *)index) + index->anims[BOD_CLOSE_NO]);
// set frame
@@ -292,7 +292,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_auto_door(int32 &, int32 *
L->big_mode = __CUSTOM_AUTO_DOOR;
// anim presets
- CAD_INDEX = prop_anims->Fetch_item_number_by_name(object->GetName());
+ CAD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
CAD_OPEN_NO = Validate_prop_anim("opening");
CAD_CLOSE_NO = Validate_prop_anim("closing");
@@ -334,7 +334,7 @@ void _game_session::Custom_auto_door() {
if (CAD_STATE == CAD_OPENING) { // doors opening
// get index for object
- index = (_animating_prop *)prop_anims->Fetch_item_by_number(CAD_INDEX);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(prop_anims, CAD_INDEX);
anim = (_animation_entry *)(((char *)index) + index->anims[CAD_OPEN_NO]);
prop_state_table[cur_id] = anim->frames[L->anim_pc];
@@ -370,7 +370,7 @@ void _game_session::Custom_auto_door() {
return;
}
// get index for object
- index = (_animating_prop *)prop_anims->Fetch_item_by_number(CAD_INDEX);
+ index = (_animating_prop *)LinkedDataObject::Fetch_item_by_number(prop_anims, CAD_INDEX);
// when closing we reverse the opening anim - until the done when we set to last frame of closing
anim = (_animation_entry *)(((char *)index) + index->anims[CAD_OPEN_NO]);
@@ -416,7 +416,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_cad_lock_status(int32 &, int32 *p
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
uint32 id;
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
logic_structs[id]->list[5] = params[1];
return IR_CONT;
@@ -429,7 +429,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_cad_state_flag(int32 &result, int
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
uint32 id;
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (logic_structs[id]->EXT_CAD_STATE == CAD_OPEN)
result = 1;
else
diff --git a/engines/icb/floors.cpp b/engines/icb/floors.cpp
index 16db5c40d4f..9e726bedbf5 100644
--- a/engines/icb/floors.cpp
+++ b/engines/icb/floors.cpp
@@ -60,14 +60,14 @@ void _floor_world::___init() {
Fatal_error("_floor_world::___init string len error");
uint32 cluster_hash = MS->Fetch_session_cluster_hash();
- floors = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
+ floors = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, MS->Fetch_session_cluster(), cluster_hash);
// Check the file schema
- if (floors->GetHeaderVersion() != VERSION_PXWGFLOORS)
- Fatal_error("Incorrect version number for floor data [%s] - file has %d, engine has %d", temp_buf, floors->GetHeaderVersion(), VERSION_PXWGFLOORS);
+ if (LinkedDataObject::GetHeaderVersion(floors) != VERSION_PXWGFLOORS)
+ Fatal_error("Incorrect version number for floor data [%s] - file has %d, engine has %d", temp_buf, LinkedDataObject::GetHeaderVersion(floors), VERSION_PXWGFLOORS);
// set this for convenience
- total_floors = floors->Fetch_number_of_items();
+ total_floors = LinkedDataObject::Fetch_number_of_items(floors);
Tdebug("floors.txt", "##total floors %d", total_floors);
// check for no floors
@@ -82,7 +82,7 @@ void _floor_world::___init() {
int32 nMissing = 0;
for (j = 0; j < total_floors; j++) {
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if (total_heights) {
// see if this height is already defined
@@ -135,7 +135,7 @@ void _floor_world::___init() {
// create room height table
for (j = 0; j < total_floors; j++) {
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
for (k = 0; k < total_heights; k++) {
if (floor->base_height == heights[k]) {
@@ -203,7 +203,7 @@ _floor_world::~_floor_world() {
uint32 _floor_world::Fetch_floor_number_by_name(const char *name) {
// return a pointer to a named floor to an external routine - most likely a fn_funtion
- return (floors->Fetch_item_number_by_name(name));
+ return (LinkedDataObject::Fetch_item_number_by_name(floors, name));
}
uint32 _floor_world::Return_floor_rect(PXreal x, PXreal z, PXreal y, uint32 rubber) {
@@ -216,7 +216,7 @@ uint32 _floor_world::Return_floor_rect(PXreal x, PXreal z, PXreal y, uint32 rubb
for (j = 0; j < total_floors; j++) {
_floor *floor;
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if (floor->base_height == (int32)y) {
// this floor is in our view level
@@ -237,7 +237,7 @@ uint32 _floor_world::Return_floor_rect(PXreal x, PXreal z, PXreal y, uint32 rubb
bool8 _floor_world::Point_on_rubber_floor(PXreal x, PXreal z, PXreal y, uint32 rubber, uint32 rect_num) {
_floor *floor;
- floor = (_floor *)floors->Fetch_item_by_number(rect_num);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, rect_num);
if (floor->base_height == (int32)y) {
// if hit then return floor number
@@ -260,7 +260,7 @@ uint32 _floor_world::Locate_floor_rect(PXreal x, PXreal z, PXreal y, _floor **rc
for (j = 0; j < total_floors; j++) {
_floor *floor;
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if (floor->base_height == (int32)y) {
// this floor is in our view level
@@ -299,7 +299,7 @@ void _floor_world::Set_floor_rect_flag(_logic *log) {
// ylocking
// first see if we're one same one as last time
- floor = (_floor *)floors->Fetch_item_by_number(log->owner_floor_rect);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, log->owner_floor_rect);
if ((y >= (floor->base_height - (0 * REAL_ONE))) && ((y <= (floor_y_volume[log->owner_floor_rect] - (0 * REAL_ONE))))) // this floor is in our view level
if ((log->mega->actor_xyz.x >= (floor->rect.x1 - FLOOR_RUBBER)) && (log->mega->actor_xyz.x <= (floor->rect.x2 + FLOOR_RUBBER)) &&
(log->mega->actor_xyz.z >= (floor->rect.z1 - FLOOR_RUBBER)) && (log->mega->actor_xyz.z <= (floor->rect.z2 + FLOOR_RUBBER))) {
@@ -309,7 +309,7 @@ void _floor_world::Set_floor_rect_flag(_logic *log) {
// search through all floors
for (j = 0; j < total_floors; j++) {
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if ((y >= (floor->base_height - (0 * REAL_ONE))) && ((y <= (floor_y_volume[j] - (0 * REAL_ONE))))) {
// this floor is in our view level
@@ -336,7 +336,7 @@ uint32 _floor_world::Return_non_rubber_floor_no(_logic *log, uint32 cur_rubber_f
_floor *floor;
// first see if we're one same one as last time
- floor = (_floor *)floors->Fetch_item_by_number(cur_rubber_floor);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, cur_rubber_floor);
if ((log->mega->actor_xyz.y >= floor->base_height) && ((log->mega->actor_xyz.y <= floor_y_volume[log->owner_floor_rect]))) // this floor is in our view level
if ((log->mega->actor_xyz.x >= (floor->rect.x1)) && (log->mega->actor_xyz.x <= (floor->rect.x2)) && (log->mega->actor_xyz.z >= (floor->rect.z1)) &&
(log->mega->actor_xyz.z <= (floor->rect.z2))) {
@@ -345,7 +345,7 @@ uint32 _floor_world::Return_non_rubber_floor_no(_logic *log, uint32 cur_rubber_f
// search through all floors
for (j = 0; j < total_floors; j++) {
- floor = (_floor *)floors->Fetch_item_by_number(j);
+ floor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if ((log->mega->actor_xyz.y >= floor->base_height) && ((log->mega->actor_xyz.y <= floor_y_volume[j]))) {
// this floor is in our view level
@@ -423,7 +423,7 @@ int32 _floor_world::Project_point_down_through_floors(int32 nX, int32 nY, int32
nY = (int32)heights[nSliceIndex];
for (j = 0; j < total_floors; ++j) {
- pFloor = (_floor *)floors->Fetch_item_by_number(j);
+ pFloor = (_floor *)LinkedDataObject::Fetch_item_by_number(floors, j);
if (pFloor->base_height == nY) {
// Floor at this height, so check its position.
diff --git a/engines/icb/floors.h b/engines/icb/floors.h
index 22a7b111f26..e9b04a71841 100644
--- a/engines/icb/floors.h
+++ b/engines/icb/floors.h
@@ -77,7 +77,7 @@ public:
int32 Project_point_down_through_floors(int32 nX, int32 nY, int32 nZ);
- _linked_data_file *floors; // the floor definition file
+ LinkedDataFile *floors; // the floor definition file
private:
uint32 total_floors; // total number of individual floors
@@ -104,12 +104,12 @@ inline uint32 _floor_world::Fetch_total_floors() { return (total_floors); }
inline _floor *_floor_world::Fetch_named_floor(const char *name) {
// return a pointer to a named floor to an external routine - most likely a fn_funtion
- return ((_floor *)floors->Fetch_item_by_name(name));
+ return ((_floor *)LinkedDataObject::Fetch_item_by_name(floors, name));
}
inline _floor *_floor_world::Fetch_floor_number(uint32 num) {
// return a pointer to a named floor to an external routine - most likely a fn_funtion
- return ((_floor *)floors->Fetch_item_by_number(num));
+ return ((_floor *)LinkedDataObject::Fetch_item_by_number(floors, num));
}
} // End of namespace ICB
diff --git a/engines/icb/fn_animation.cpp b/engines/icb/fn_animation.cpp
index 8ae5799791b..45f64b8d5c2 100644
--- a/engines/icb/fn_animation.cpp
+++ b/engines/icb/fn_animation.cpp
@@ -226,7 +226,7 @@ mcodeFunctionReturnCodes _game_session::fn_face_nicos_pan(int32 &, int32 *params
if (!L->looping) {
// setup
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos)
Fatal_error("no NICO marker (fn_face_nico) ob %s, nico %s", object->GetName(), nico_name);
@@ -292,7 +292,7 @@ mcodeFunctionReturnCodes _game_session::fn_face_object(int32 &, int32 *params) {
// setup
_logic *log;
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
log = Fetch_object_struct(id);
@@ -341,7 +341,7 @@ mcodeFunctionReturnCodes _game_session::fn_fast_face_object(int32 &, int32 *para
// setup
_logic *log;
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
log = Fetch_object_struct(id);
@@ -528,7 +528,7 @@ mcodeFunctionReturnCodes _game_session::fn_snap_face_object(int32 &, int32 *para
Zdebug("fn_snap_face_object [%s]", object_name);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_snap_face_object cant find target object %s", object_name);
@@ -1272,7 +1272,7 @@ mcodeFunctionReturnCodes _game_session::fn_sync_with_mega(int32 &, int32 *params
const char *mega_name = (const char *)MemoryUtil::resolvePtr(params[0]);
if (!L->looping) {
- L->list[0] = objects->Fetch_item_number_by_name(mega_name);
+ L->list[0] = LinkedDataObject::Fetch_item_number_by_name(objects, mega_name);
L->list[1] = 42; // we are here
L->looping = TRUE8; // dont do this again
}
@@ -1331,7 +1331,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_apply_bullet(int32 &, int32 *para
}
// get id
- tid = objects->Fetch_item_number_by_name(target_name);
+ tid = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
// how near
if (L->image_type == PROP) { // we are prop
@@ -1368,7 +1368,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_apply_bullet(int32 &, int32 *para
MS->player.being_shot = 3; // cant shoot for 3 cycles (engine anim over three frames)
MS->player.shot_by_id = (int8)cur_id; // shot by us...!
- c_game_object *ob = (c_game_object *)objects->Fetch_item_by_number(player.Fetch_player_id());
+ c_game_object *ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
int32 ret = ob->GetVariable("hits");
uint32 hits = ob->GetIntegerVariable(ret);
diff --git a/engines/icb/fn_event_functions.cpp b/engines/icb/fn_event_functions.cpp
index fd14b6e9211..05b30dbec73 100644
--- a/engines/icb/fn_event_functions.cpp
+++ b/engines/icb/fn_event_functions.cpp
@@ -157,7 +157,7 @@ mcodeFunctionReturnCodes _game_session::fn_register_object_for_event(int32 &, in
const char *event_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Call the function that does the work in the event manager.
g_oEventManager->RegisterForEvent(nObjectID, event_name);
@@ -173,7 +173,7 @@ mcodeFunctionReturnCodes _game_session::fn_unregister_object_for_event(int32 &,
const char *event_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Call the function that does the work in the event manager.
g_oEventManager->UnregisterForEvent(nObjectID, event_name);
@@ -242,7 +242,7 @@ mcodeFunctionReturnCodes _game_session::fn_event_check_last_sender(int32 &result
const char *event_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Find the sender of the named event.
result = g_oEventManager->DidObjectSendLastNamedEvent(cur_id, nObjectID, event_name);
@@ -268,7 +268,7 @@ mcodeFunctionReturnCodes _game_session::fn_post_named_event_to_object(int32 &, i
const char *event_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Get ID of target and make sure it is valid.
- nTargetID = objects->Fetch_item_number_by_name(object_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Post the event.
g_oEventManager->PostNamedEventToObject(event_name, nTargetID, cur_id);
@@ -312,7 +312,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_registered_for_event(int32
const char *event_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Get ID of object and make sure it is valid.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Make the engine call.
result = g_oEventManager->IsObjectRegisteredForEvent(nObjectID, event_name);
@@ -349,7 +349,7 @@ mcodeFunctionReturnCodes _game_session::fn_register_for_line_of_sight(int32 &, i
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Now we can make the actual call to the line-of-sight object.
PXTRY
@@ -372,7 +372,7 @@ mcodeFunctionReturnCodes _game_session::fn_unregister_for_line_of_sight(int32 &,
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Now we can make the actual call to the line-of-sight object.
PXTRY
@@ -397,9 +397,9 @@ mcodeFunctionReturnCodes _game_session::fn_register_object_for_line_of_sight(int
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the objects' IDs.
- nObserverID = objects->Fetch_item_number_by_name(observer_name);
+ nObserverID = LinkedDataObject::Fetch_item_number_by_name(objects, observer_name);
- nTargetID = objects->Fetch_item_number_by_name(target_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
// Now we can make the actual call to the line-of-sight object.
if ((nTargetID != PX_LINKED_DATA_FILE_ERROR) && (nObserverID != PX_LINKED_DATA_FILE_ERROR)) {
@@ -426,9 +426,9 @@ mcodeFunctionReturnCodes _game_session::fn_unregister_object_for_line_of_sight(i
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the objects' IDs.
- nObserverID = objects->Fetch_item_number_by_name(observer_name);
+ nObserverID = LinkedDataObject::Fetch_item_number_by_name(objects, observer_name);
- nTargetID = objects->Fetch_item_number_by_name(target_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
// Now we can make the actual call to the line-of-sight object.
if ((nTargetID != PX_LINKED_DATA_FILE_ERROR) && (nObserverID != PX_LINKED_DATA_FILE_ERROR)) {
@@ -453,7 +453,7 @@ mcodeFunctionReturnCodes _game_session::fn_can_see(int32 &result, int32 *params)
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// Find ID of target object.
- nTargetID = objects->Fetch_item_number_by_name(target_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
// Don't call line-of-sight for an invalid ID.
if (nTargetID != PX_LINKED_DATA_FILE_ERROR) {
@@ -482,12 +482,12 @@ mcodeFunctionReturnCodes _game_session::fn_can_object_see(int32 &result, int32 *
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// Find the objects' IDs.
- nObserverID = objects->Fetch_item_number_by_name(observer_name);
+ nObserverID = LinkedDataObject::Fetch_item_number_by_name(objects, observer_name);
if (nObserverID == PX_LINKED_DATA_FILE_ERROR)
Fatal_error("Object %s not found in fn_can_object_see()", observer_name);
- nTargetID = objects->Fetch_item_number_by_name(target_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
if (nTargetID == PX_LINKED_DATA_FILE_ERROR)
Fatal_error("Object %s not found in fn_can_object_see()", target_name);
@@ -580,7 +580,7 @@ mcodeFunctionReturnCodes _game_session::fn_line_of_sight_now(int32 &result, int3
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- nTargetID = objects->Fetch_item_number_by_name(target_name);
+ nTargetID = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
if (nTargetID == PX_LINKED_DATA_FILE_ERROR)
Fatal_error("Object %s not found in fn_line_of_sight_now()", target_name);
diff --git a/engines/icb/fn_interact.cpp b/engines/icb/fn_interact.cpp
index ff13af75a2a..e28a830a192 100644
--- a/engines/icb/fn_interact.cpp
+++ b/engines/icb/fn_interact.cpp
@@ -82,7 +82,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_interacting(int32 &, int32 *param
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_set_interacting - illegal object [%s]", object_name);
@@ -161,7 +161,7 @@ mcodeFunctionReturnCodes _game_session::fn_sony_door_interact(int32 &result, int
if (!L->looping) {
// work out which button to interact with
- id = objects->Fetch_item_number_by_name(button1_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, button1_name);
if (id == 0xffffffff)
Fatal_error("fn_sony_door_interact - illegal object [%s]", button1_name);
@@ -194,7 +194,7 @@ mcodeFunctionReturnCodes _game_session::fn_sony_door_interact(int32 &result, int
}
// there is another button so lets take a look to see it is named correctly
- id = objects->Fetch_item_number_by_name(button2_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, button2_name);
if (id == 0xffffffff)
Fatal_error("fn_sony_door_interact - illegal object [%s]", button2_name);
@@ -520,7 +520,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_interact_object(int32 &resu
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_interact_object - object [%s] does not exist", object_name);
diff --git a/engines/icb/fn_sound.cpp b/engines/icb/fn_sound.cpp
index 9ab4a9d7947..add04fb179d 100644
--- a/engines/icb/fn_sound.cpp
+++ b/engines/icb/fn_sound.cpp
@@ -171,7 +171,7 @@ mcodeFunctionReturnCodes _game_session::fn_stop_sfx(int32 &, int32 *params) {
strcpy(tempSnd, sub + strlen("::"));
- int32 obj = MS->objects->Fetch_item_number_by_name(tempObj);
+ int32 obj = LinkedDataObject::Fetch_item_number_by_name(MS->objects, tempObj);
if (obj != -1)
RemoveRegisteredSound(obj, tempSnd);
diff --git a/engines/icb/function.cpp b/engines/icb/function.cpp
index 532be187b62..af2e0dfeccc 100644
--- a/engines/icb/function.cpp
+++ b/engines/icb/function.cpp
@@ -373,7 +373,7 @@ mcodeFunctionReturnCodes _game_session::socket_force_new_logic(int32 &, int32 *p
Zdebug("script %d matches", k);
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)scripts->Try_fetch_item_by_hash(socket_object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
if (g_px->socket_watch)
Message_box("replacing logic");
@@ -487,7 +487,7 @@ mcodeFunctionReturnCodes _game_session::fn_init_from_nico_file(int32 &, int32 *
Fatal_error("fn_init_from_nico_file called by a mega! [%s] - use fn_init_mega_from_nico", object->GetName());
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
if (!start_pos) {
Message_box("fn_init_from_nico_file - missing nico for item %s", object->GetName());
@@ -531,7 +531,7 @@ mcodeFunctionReturnCodes _game_session::fn_check_for_nico(int32 &result, int32 *
_feature_info *start_pos;
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
if (!start_pos)
result = FALSE8;
@@ -593,7 +593,7 @@ mcodeFunctionReturnCodes _game_session::fn_init_mega_from_nico(int32 &, int32 *)
Fatal_error("fn_init_mega_from_nico fails because object is not registered as a mega");
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
if (!start_pos) {
Message_box("fn_init_mega_from_nico missing nico for item %s", object->GetName());
@@ -631,7 +631,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico(int32 &, int32 *para
Fatal_error("fn_teleport_to_nico fails because object is not registered as a mega");
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos)
Fatal_error("no NICO marker (fn_teleport_to_nico) ob %s, nico %s", object->GetName(), nico_name);
@@ -666,7 +666,7 @@ mcodeFunctionReturnCodes _game_session::fn_panless_teleport_to_nico(int32 &, int
Fatal_error("fn_panless_teleport_to_nico_ fails because object is not registered as a mega");
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos)
Fatal_error("no NICO marker (fn_panless_teleport_to_nico_) ob %s, nico %s", object->GetName(), nico_name);
@@ -698,7 +698,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico_y(int32 &, int32 *pa
Fatal_error("fn_teleport_to_nico_y fails because object is not registered as a mega");
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos)
Fatal_error("no NICO marker (fn_teleport_to_nico_y) ob %s, nico %s", object->GetName(), nico_name);
@@ -731,7 +731,7 @@ mcodeFunctionReturnCodes _game_session::fn_snap_to_nico_y(int32 &, int32 *params
Fatal_error("fn_snap_to_nico_y fails because object is not registered as a mega");
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos)
Fatal_error("no NICO marker (fn_snap_to_nico_y) ob %s, nico %s", object->GetName(), nico_name);
@@ -754,7 +754,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_pan_from_nico(int32 &, int32 *par
Zdebug("fn_get_pan_from_nico - %s (nico %s)", object->GetName(), nico_name);
// fetch tag file for this item
- start_pos = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!start_pos) {
// item does not have an entry but clearly expects one
@@ -806,12 +806,12 @@ mcodeFunctionReturnCodes _game_session::fn_call_socket(int32 &result, int32 *par
script_hash = HashString(socket_script_name);
// get target object
- socket_object = (c_game_object *)MS->objects->Try_fetch_item_by_name(target_object_name);
+ socket_object = (c_game_object *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, target_object_name);
if (!socket_object)
Fatal_error("%s call to fn_call_socket - object %s doesnt exist", object->GetName(), target_object_name);
// set socket_id ready for any special socket functions
- socket_id = MS->objects->Fetch_item_number_by_name(target_object_name);
+ socket_id = LinkedDataObject::Fetch_item_number_by_name(MS->objects, target_object_name);
if (socket_id == 0xffffffff)
Fatal_error("fn_call_socket couldnt find object [%s]", target_object_name);
@@ -823,7 +823,7 @@ mcodeFunctionReturnCodes _game_session::fn_call_socket(int32 &result, int32 *par
// script k is the one to run
// get the address of the script we want to run
- const char *pc = (const char *)scripts->Try_fetch_item_by_hash(socket_object->GetScriptNameFullHash(k));
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
// run the script - pass its object so vars can be accessed
RunScript(pc, socket_object, &retval);
@@ -874,7 +874,7 @@ bool8 _game_session::Call_socket(uint32 id, const char *script, int32 *retval) {
script_hash = HashString(script);
// get target object
- socket_object = (c_game_object *)MS->objects->Fetch_item_by_number(id);
+ socket_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!socket_object)
Fatal_error("internal Call_socket - named object dont exist");
@@ -892,7 +892,7 @@ bool8 _game_session::Call_socket(uint32 id, const char *script, int32 *retval) {
Zdebug("calling socket %d", k);
// script k is the one to run
// get the address of the script we want to run
- const char *pc = (const char *)scripts->Try_fetch_item_by_hash(socket_object->GetScriptNameFullHash(k));
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
int32 result = static_cast<int>(*retval);
@@ -961,7 +961,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport(int32 &, int32 *params) {
// Made this so it takes a special name "from_origin" to indicate that the offset is to be applied
// from 0,0.
if (strcmp(target_object_name, "from_origin") != 0) {
- uint32 tar = MS->objects->Fetch_item_number_by_name(target_object_name);
+ uint32 tar = LinkedDataObject::Fetch_item_number_by_name(MS->objects, target_object_name);
if (tar == 0xffffffff)
Fatal_error("'destination' teleport object [%s] does not exist", target_object_name);
@@ -1007,7 +1007,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_z(int32 &, int32 *params) {
Zdebug("fn_teleport_z to %s", target_object_name);
- uint32 tar = MS->objects->Fetch_item_number_by_name(target_object_name);
+ uint32 tar = LinkedDataObject::Fetch_item_number_by_name(MS->objects, target_object_name);
if (tar == 0xffffffff)
Fatal_error("'destination' teleport object [%s] does not exist", target_object_name);
@@ -1064,7 +1064,7 @@ mcodeFunctionReturnCodes _game_session::fn_are_we_on_this_floor(int32 &result, i
return IR_CONT;
uint32 hash = HashString(floor_name);
- floor_id = floor_def->floors->Fetch_item_number_by_hash(hash);
+ floor_id = LinkedDataObject::Fetch_item_number_by_hash(floor_def->floors, hash);
if (floor_id == 0xffffffff)
Fatal_error("fn_are_we_on_this_floor cant locate floor [%s]", floor_name);
@@ -1089,7 +1089,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_on_our_floor(int32 &result,
if (first_session_cycle)
return IR_CONT;
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_on_our_floor - illegal object [%s]", object_name);
@@ -1167,7 +1167,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_on_screen(int32 &result, in
}
// get object to check
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_on_screen - illegal object [%s]", object_name);
@@ -1260,7 +1260,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_objects_lvar_value(int32 &result,
Zdebug("fn_get_objects_lvar_value - [%s] [%s]", object_name, lvar_name);
uint32 hash = HashString(object_name);
- ob = (c_game_object *)objects->Try_fetch_item_by_hash(hash);
+ ob = (c_game_object *)LinkedDataObject::Try_fetch_item_by_hash(objects, hash);
if (!ob)
Fatal_error("fn_get_objects_lvar_value - illegal object [%s]", object_name);
@@ -1287,7 +1287,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_objects_lvar_value(int32 &, int32
Zdebug("[%s] calls fn_set_objects_lvar_value - [%s] [%s, %d]", object->GetName(), object_name, lvar_name, params[2]);
- ob = (c_game_object *)objects->Fetch_item_by_name(object_name);
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, object_name);
if (!ob)
Fatal_error("fn_set_objects_lvar_value - illegal object [%s]", object_name);
@@ -1311,9 +1311,9 @@ mcodeFunctionReturnCodes _game_session::fn_set_ids_lvar_value(int32 &, int32 *pa
c_game_object *ob;
const char *lvar_name = (const char *)MemoryUtil::resolvePtr(params[1]);
- Zdebug("fn_set_ids_lvar_value - [%s] [%s]", objects->Fetch_items_name_by_number(params[0]), lvar_name);
+ Zdebug("fn_set_ids_lvar_value - [%s] [%s]", LinkedDataObject::Fetch_items_name_by_number(objects, params[0]), lvar_name);
- ob = (c_game_object *)objects->Fetch_item_by_number(params[0]);
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, params[0]);
if (!ob)
Fatal_error("fn_set_ids_lvar_value - illegal object [%d]", params[0]);
@@ -1335,7 +1335,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_state_flag(int32 &result, int32 *
c_game_object *ob;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- ob = (c_game_object *)objects->Fetch_item_by_name(object_name);
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, object_name);
if (!ob)
Fatal_error("fn_get_state_flag - illegal object [%s]", object_name);
ret = ob->GetVariable("state");
@@ -1350,7 +1350,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_dead(int32 &result, int32 *
// params 0 name of object
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (!logic_structs[id]->mega)
Fatal_error("fn_get_state_flag - object [%s] not mega", object_name);
@@ -1405,7 +1405,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_an_object_crouching(int32 &result,
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_an_object_crouching - illegal object [%s]", object_name);
@@ -1595,7 +1595,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_objects_x(int32 &result, int32 *p
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_get_objects_x - illegal object [%s]", object_name);
@@ -1617,7 +1617,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_objects_y(int32 &result, int32 *p
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_get_objects_y - illegal object [%s]", object_name);
@@ -1639,7 +1639,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_objects_z(int32 &result, int32 *p
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_get_objects_z - illegal object [%s]", object_name);
@@ -1660,7 +1660,7 @@ mcodeFunctionReturnCodes _game_session::fn_has_mega_our_height(int32 &result, in
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// get target
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_has_mega_our_height - illegal object [%s]", object_name);
@@ -1688,7 +1688,7 @@ mcodeFunctionReturnCodes _game_session::fn_near(int32 &result, int32 *params) {
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_dead - illegal object [%s]", object_name);
@@ -1743,10 +1743,10 @@ mcodeFunctionReturnCodes _game_session::fn_is_mega_near_mega(int32 &result, int3
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
const char *other_object_name = (const char *)MemoryUtil::resolvePtr(params[1]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_mega_near_mega - illegal object [%s]", object_name);
- id2 = (uint32)objects->Fetch_item_number_by_name(other_object_name);
+ id2 = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, other_object_name);
if (id2 == 0xffffffff)
Fatal_error("fn_is_mega_near_mega - illegal object [%s]", other_object_name);
@@ -1814,7 +1814,7 @@ mcodeFunctionReturnCodes _game_session::fn_object_near_nico(int32 &result, int32
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
const char *nico_name = (const char *)MemoryUtil::resolvePtr(params[1]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_object_near_nico - illegal object [%s]", object_name);
@@ -1823,7 +1823,7 @@ mcodeFunctionReturnCodes _game_session::fn_object_near_nico(int32 &result, int32
Fatal_error("fn_object_near_nico object [%s] is not a mega!", object_name);
// fetch tag file for this item
- nico = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ nico = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!nico)
Fatal_error("fn_object_near_nico cant find nico [%s]", nico_name);
@@ -1857,7 +1857,7 @@ mcodeFunctionReturnCodes _game_session::fn_add_object_name_to_list(int32 &, int3
if (L->total_list == MAX_list)
Fatal_error("fn_object_name_to_list [%s] has exceeded list size of %d", object->GetName(), MAX_list);
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == -1)
Fatal_error("[%s] callling fn_add_object_name_to_list finds [%s] is not a legal object", object->GetName(), object_name);
@@ -1903,7 +1903,7 @@ mcodeFunctionReturnCodes _game_session::fn_lift_process_list(int32 &result, int3
return (IR_CONT);
}
- monica = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!monica)
Fatal_error("fn_lift_process_list cant find nico [%s]", nico_name);
@@ -1967,7 +1967,7 @@ mcodeFunctionReturnCodes _game_session::fn_lib_lift_chord_and_chi(int32 &result,
return IR_CONT;
}
- monica = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!monica)
Fatal_error("fn_lift_process_list cant find nico [%s]", nico_name);
lifty = monica->y;
@@ -2094,7 +2094,7 @@ mcodeFunctionReturnCodes _game_session::fn_lift2_process(int32 &result, int32 *p
}
// get nico
- monica = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!monica)
Fatal_error("fn_lift_process_list cant find nico [%s]", nico_name);
lifty = monica->y;
@@ -2313,7 +2313,7 @@ mcodeFunctionReturnCodes _game_session::fn_hold_while_list_near_nico(int32 &resu
return (IR_CONT);
}
- monica = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!monica)
Fatal_error("fn_lift_process_list cant find nico [%s]", nico_name);
@@ -2353,7 +2353,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_watch(int32 &, int32 *params) {
// params 0 name of object
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_set_watch - object [%s] does not exist", object_name);
@@ -2451,7 +2451,7 @@ mcodeFunctionReturnCodes _game_session::fn_change_session(int32 &, int32 *params
// save the players 'hits' variable
c_game_object *ob;
- ob = (c_game_object *)objects->Fetch_item_by_number(player.Fetch_player_id());
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
ret = ob->GetVariable("hits");
g_mission->old_hits_value = ob->GetIntegerVariable(ret);
@@ -2469,7 +2469,7 @@ mcodeFunctionReturnCodes _game_session::fn_changed_sessions(int32 &result, int32
result = g_mission->Is_there_init_nico();
if (result) { // nico is waiting Removed explicit test against TRUE8 to get rid of VC5 warning
- nico = (_feature_info *)features->Try_fetch_item_by_name(g_mission->Return_init_nico_name());
+ nico = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, g_mission->Return_init_nico_name());
if (!nico)
Fatal_error("fn_changed_sessions cant find nico [%s]", g_mission->Return_init_nico_name());
@@ -2491,7 +2491,7 @@ mcodeFunctionReturnCodes _game_session::fn_changed_sessions(int32 &result, int32
logic_structs[cur_id]->prop_coords_set = TRUE8;
// move player forwards a little
- if (cur_id == objects->Fetch_item_number_by_name("chi")) {
+ if (cur_id == LinkedDataObject::Fetch_item_number_by_name(objects, "chi")) {
// we are the player then jump player in-front of chi
PXfloat ang = nico->direction * TWO_PI;
@@ -2547,7 +2547,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_adjacent(int32 &result, int
return (IR_CONT);
}
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_on_our_floor - illegal object [%s]", object_name);
@@ -2585,11 +2585,11 @@ mcodeFunctionReturnCodes _game_session::fn_is_object_on_this_floor(int32 &result
Zdebug("fn_is_object_on_this_floor [%s], [%s]", object_name, floor_name);
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_object_on_our_floor - illegal object [%s]", object_name);
- floor_id = floor_def->floors->Fetch_item_number_by_name(floor_name);
+ floor_id = LinkedDataObject::Fetch_item_number_by_name(floor_def->floors, floor_name);
if (floor_id == 0xffffffff)
Fatal_error("fn_are_we_on_this_floor cant locate floor [%s]", floor_name);
@@ -2655,7 +2655,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_sleep(int32 &, int32 *params) {
uint32 id;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = objects->Fetch_item_number_by_name(object_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_set_sleep - illegal object [%s]", object_name);
@@ -2681,7 +2681,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_use_lift(int32 &, int32 *params)
uint32 var_num;
const char *lift_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- ob = (c_game_object *)objects->Fetch_item_by_name(lift_name);
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, lift_name);
if (!ob)
Fatal_error("fn_use_lift - illegal object [%s]", lift_name);
@@ -2761,7 +2761,7 @@ mcodeFunctionReturnCodes _game_session::fn_is_mega_within_area(int32 &result, in
uint32 id;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = (uint32)objects->Fetch_item_number_by_name(object_name);
+ id = (uint32)LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_is_mega_within_area - illegal object [%s]", object_name);
@@ -2945,10 +2945,10 @@ uint32 _game_session::Register_stair_or_ladder(const char *target, bool8 top, ui
Fatal_error("%s has illegal length %d", object->GetName(), length);
// get our nico
- stair = (_feature_info *)features->Try_fetch_item_by_name(const_cast<char *>(object->GetName()));
+ stair = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, const_cast<char *>(object->GetName()));
// get other end
- dest_stair = (_feature_info *)features->Try_fetch_item_by_name(target);
- dest_stair_id = objects->Fetch_item_number_by_name(target);
+ dest_stair = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, target);
+ dest_stair_id = LinkedDataObject::Fetch_item_number_by_name(objects, target);
if (!stair)
Fatal_error("fn_register_stairway - cant find nico %s", object->GetName());
@@ -3178,7 +3178,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_object_visible(int32 &, int32 *pa
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// Find the target object's ID.
- nObjectID = objects->Fetch_item_number_by_name(object_name);
+ nObjectID = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// Make sure object is a mega character.
if (!(logic_structs[nObjectID]->mega))
@@ -3220,7 +3220,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_camera_hold(int32 &, int32 *param
Fatal_error("fn_set_camera_hold called for [%s] but this is for props only", object->GetName());
// find entry for this object via its name, which we find via its number :(
- if (!prop_anims->Try_fetch_item_by_name(object->GetName()))
+ if (!LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName()))
return IR_CONT; // item has no prop entry - so keep it live
if (params[0])
@@ -3275,7 +3275,7 @@ mcodeFunctionReturnCodes _game_session::fn_lock_y(int32 &, int32 *params) {
_feature_info *nico;
const char *marker_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- nico = (_feature_info *)features->Try_fetch_item_by_name(marker_name);
+ nico = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, marker_name);
if (!nico)
Fatal_error("fn_lock_y by [%s] for nico [%s] finds no such nico", object->GetName(), marker_name);
diff --git a/engines/icb/game_volume.cpp b/engines/icb/game_volume.cpp
index 189e6bbc679..67eb91e1dfb 100644
--- a/engines/icb/game_volume.cpp
+++ b/engines/icb/game_volume.cpp
@@ -29,7 +29,7 @@
namespace ICB {
-void _game_volume::SetUpParameters(_linked_data_file *pyLOSData) {
+void _game_volume::SetUpParameters(LinkedDataFile *pyLOSData) {
uint32 i;
_barrier_slice *pSlice;
_slice_limit sSliceLimit;
@@ -39,7 +39,7 @@ void _game_volume::SetUpParameters(_linked_data_file *pyLOSData) {
// Get the first slice and use this to set the horizontal sizes, since they all share the
// same horizontal sizes.
- pSlice = (_barrier_slice *)pyLOSData->Fetch_item_by_number(0);
+ pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, 0);
m_fLeftEdge = pSlice->left_edge;
m_fRightEdge = pSlice->right_edge;
m_fBackEdge = pSlice->back_edge;
@@ -54,10 +54,10 @@ void _game_volume::SetUpParameters(_linked_data_file *pyLOSData) {
m_nMinimumZIndex = (int32)(m_fBackEdge / (PXreal)FLOOR_CUBE_SIZE);
// Now set the slice heights.
- m_nNumSlices = pyLOSData->Fetch_number_of_items();
+ m_nNumSlices = LinkedDataObject::Fetch_number_of_items(pyLOSData);
for (i = 0; i < m_nNumSlices; ++i) {
- pSlice = (_barrier_slice *)pyLOSData->Fetch_item_by_number(i);
+ pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pyLOSData, i);
sSliceLimit.fTop = pSlice->top;
sSliceLimit.fBottom = pSlice->bottom;
m_oSliceLimits[i] = sSliceLimit;
diff --git a/engines/icb/game_volume.h b/engines/icb/game_volume.h
index 9775ded2249..8c2bd829b17 100644
--- a/engines/icb/game_volume.h
+++ b/engines/icb/game_volume.h
@@ -95,7 +95,7 @@ public:
inline const _game_volume &operator=(const _game_volume &oOpB);
// This single function sets up all the parameters.
- void SetUpParameters(_linked_data_file *pyLOSData);
+ void SetUpParameters(LinkedDataFile *pyLOSData);
// Gets and sets.
PXreal GetAbsoluteTop() const { return (m_fAbsoluteTop); }
@@ -118,7 +118,7 @@ public:
bool8 GetCubeAndIndices(const px3DRealPoint &oPoint, _XYZ_index &oIndex, _bullet_cube &oCube) const;
protected:
- _linked_data_file *m_pyLOSMemFile; // Pointer to the line-of-sight data file.
+ LinkedDataFile *m_pyLOSMemFile; // Pointer to the line-of-sight data file.
private:
PXreal m_fAbsoluteTop; // The 'roof' of the cube.
diff --git a/engines/icb/global_objects.cpp b/engines/icb/global_objects.cpp
index 58d5cad364f..19e13246cc5 100644
--- a/engines/icb/global_objects.cpp
+++ b/engines/icb/global_objects.cpp
@@ -62,7 +62,7 @@ res_man *rs_font = nullptr; // pointer to which res_man to use for font data
// global test only
res_man *global_text_resman = nullptr;
-_linked_data_file *global_text;
+LinkedDataFile *global_text;
// route-manager service object
// doesnt depend on session specific extrernal data so we make it global service
diff --git a/engines/icb/global_objects.h b/engines/icb/global_objects.h
index 22c627929ac..97ae52ec2d0 100644
--- a/engines/icb/global_objects.h
+++ b/engines/icb/global_objects.h
@@ -58,7 +58,7 @@ extern res_man *rs_font; // pointer to which res_man to use for font data
// global test file only in this resman
extern res_man *global_text_resman;
-extern _linked_data_file *global_text;
+extern LinkedDataFile *global_text;
extern text_sprite *g_text_bloc1;
extern text_sprite *g_text_bloc2;
diff --git a/engines/icb/health_bar_pc.cpp b/engines/icb/health_bar_pc.cpp
index 67cfefa090f..2a05bb4451b 100644
--- a/engines/icb/health_bar_pc.cpp
+++ b/engines/icb/health_bar_pc.cpp
@@ -77,7 +77,7 @@ void _game_session::Draw_health_bar() {
General_draw_line_24_32(BAR_X + BAR_W + 2, BAR_Y - 1, BAR_X + BAR_W + 2, BAR_Y + BAR_H + 2, &pen, ad, pitch);
// Find out how much health the player has (0 dead -- 10 full)
- c_game_object *ob = (c_game_object *)objects->Fetch_item_by_number(player.Fetch_player_id());
+ c_game_object *ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
int32 ret = ob->GetVariable("hits");
int32 health = ob->GetIntegerVariable(ret);
diff --git a/engines/icb/icon_menu_pc.cpp b/engines/icb/icon_menu_pc.cpp
index 056bf60f41d..43499fe34d6 100644
--- a/engines/icb/icon_menu_pc.cpp
+++ b/engines/icb/icon_menu_pc.cpp
@@ -346,7 +346,7 @@ void _icon_menu::DrawIconMenu() {
surface_manager->Blit_surface_to_surface(m_pnHiLiteSurfaceIDs[nIconIndex], working_buffer_id, &sFromRectangle, &sToRectangle, DDBLT_KEYSRC);
// Look for the icon label in the global text file.
- pcIconLabel = (const char *)global_text->Try_fetch_item_by_hash(nHashRef);
+ pcIconLabel = (const char *)LinkedDataObject::Try_fetch_item_by_hash(global_text, nHashRef);
// If we found it, display it.
if (pcIconLabel && (g_px->display_mode == THREED)) {
diff --git a/engines/icb/line_of_sight.cpp b/engines/icb/line_of_sight.cpp
index 0a3aace2fba..180beca8472 100644
--- a/engines/icb/line_of_sight.cpp
+++ b/engines/icb/line_of_sight.cpp
@@ -41,7 +41,7 @@ int32 john_total_traces = 0;
void _line_of_sight::Initialise() {
uint32 i;
_floor_world *pFloorWorld;
- _linked_data_file *pyBarriers;
+ LinkedDataFile *pyBarriers;
uint32 oFileName_hash = NULL_HASH;
// Set the number of subscribers processed per cycle back to its starting value.
@@ -65,13 +65,13 @@ void _line_of_sight::Initialise() {
#endif
uint32 cluster_hash = MS->Fetch_session_cluster_hash();
- m_pyLOSData = (_linked_data_file *)private_session_resman->Res_open(oFileName, oFileName_hash, MS->Fetch_session_cluster(), cluster_hash);
+ m_pyLOSData = (LinkedDataFile *)private_session_resman->Res_open(oFileName, oFileName_hash, MS->Fetch_session_cluster(), cluster_hash);
Zdebug("private_session_resman opened %s", (const char *)oFileName);
// Check file version is correct.
- if (m_pyLOSData->GetHeaderVersion() != VERSION_PXWGLINEOFSIGHT)
- Fatal_error(".pxwglineofsight version check failed (file has %d, engine has %d)", m_pyLOSData->GetHeaderVersion(), VERSION_PXWGLINEOFSIGHT);
+ if (LinkedDataObject::GetHeaderVersion(m_pyLOSData) != VERSION_PXWGLINEOFSIGHT)
+ Fatal_error(".pxwglineofsight version check failed (file has %d, engine has %d)", LinkedDataObject::GetHeaderVersion(m_pyLOSData), VERSION_PXWGLINEOFSIGHT);
// The tracer object can be initialised now we have the barrier map.
g_oTracer->SetUpParameters(m_pyLOSData);
diff --git a/engines/icb/line_of_sight.h b/engines/icb/line_of_sight.h
index 7b3dc7e5dea..b64f0aea67f 100644
--- a/engines/icb/line_of_sight.h
+++ b/engines/icb/line_of_sight.h
@@ -125,12 +125,12 @@ public:
_barrier_logic_value GetLastImpactType() const { return (m_eImpactType); }
// This allows other classes to get at the barrier slices (the Remora needs this).
- _linked_data_file *GetSlicesPointer() const { return (m_pyLOSData); }
+ LinkedDataFile *GetSlicesPointer() const { return (m_pyLOSData); }
bool8 FailingOnHeight() const { return (m_bFailingOnHeight); }
private:
- _linked_data_file *m_pyLOSData; // Pointer to the loaded line-of-sight data file.
+ LinkedDataFile *m_pyLOSData; // Pointer to the loaded line-of-sight data file.
uint32 m_nSubsPerCycle; // How many subscribers to process per cycle.
uint32 m_nFirstSubscriber; // Number of first subscriber to process
uint32 m_nNumObjects; // Number of subscribers to this service.
diff --git a/engines/icb/logic.cpp b/engines/icb/logic.cpp
index 7687cc775da..b32b81b55ed 100644
--- a/engines/icb/logic.cpp
+++ b/engines/icb/logic.cpp
@@ -281,7 +281,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_persons_weapon(int32 &result, int
const char *mega_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- id = objects->Fetch_item_number_by_name(mega_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, mega_name);
if (id == 0xffffffff)
Fatal_error("fn_get_persons_weapon: object [%s] does not exist", mega_name);
@@ -395,7 +395,7 @@ void _game_session::Set_script(const char *script_name) {
// set the script on the current level
char *ad;
- ad = (char *)scripts->Fetch_item_by_name(script_name);
+ ad = (char *)LinkedDataObject::Fetch_item_by_name(scripts, script_name);
L->logic[L->logic_level] = ad;
@@ -412,7 +412,7 @@ void _game_session::Context_check(uint32 script_name) {
Zdebug("context check");
- ad = (char *)scripts->Try_fetch_item_by_hash(script_name);
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, script_name);
Zdebug("context_check ad=%d ref=%d", ad, L->logic_ref[1]);
@@ -475,7 +475,7 @@ mcodeFunctionReturnCodes _game_session::fn_kill_object(int32 &, int32 *params) {
// kill this object
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_kill_object finds [%s] does not exist", object_name);
@@ -511,7 +511,7 @@ void _game_session::Shut_down_object(const char *ascii) {
bool8 _game_session::Console_shut_down_object(const char *name) {
// we have name of object
- uint32 id = objects->Fetch_item_number_by_name(name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, name);
if (id == 0xffffffff)
return (FALSE8);
@@ -529,7 +529,7 @@ bool8 _game_session::Console_shut_down_object(const char *name) {
bool8 _game_session::Free_object(const char *name) {
// we have name of object
- uint32 id = objects->Fetch_item_number_by_name(name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, name);
if (id == 0xffffffff)
return (FALSE8);
@@ -649,7 +649,7 @@ mcodeFunctionReturnCodes _game_session::fn_object_rerun_logic_context(int32 &, i
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 id = objects->Fetch_item_number_by_name(object_name);
+ uint32 id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
if (id == 0xffffffff)
Fatal_error("fn_object_rerun_logic_context cant find object [%s]", object_name);
@@ -696,7 +696,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_script(int32 &, int32 *params) {
if (script_hash == object->GetScriptNamePartHash(k)) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
// write actual offset
L->logic[1] = ad;
@@ -741,7 +741,7 @@ mcodeFunctionReturnCodes _game_session::fn_gosub(int32 &, int32 *params) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
@@ -770,7 +770,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_strike_overide(int32 &, int32 *pa
// params 0 name of mega
// 1 0 off 1 on
const char *mega_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 tar = MS->objects->Fetch_item_number_by_name(mega_name);
+ uint32 tar = LinkedDataObject::Fetch_item_number_by_name(MS->objects, mega_name);
if (tar == 0xffffffff)
Fatal_error("fn_set_strike_overide finds object [%s] does not exist", mega_name);
@@ -790,7 +790,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_shoot_overide(int32 &, int32 *par
const char *mega_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 tar = MS->objects->Fetch_item_number_by_name(mega_name);
+ uint32 tar = LinkedDataObject::Fetch_item_number_by_name(MS->objects, mega_name);
if (tar == 0xffffffff)
Fatal_error("fn_set_shoot_overide finds object [%s] does not exist", mega_name);
@@ -836,7 +836,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_dynamic_light(int32 &, int32 *par
mcodeFunctionReturnCodes _game_session::speak_set_dynamic_light(int32 &, int32 *params) {
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- int32 obj_id = objects->Fetch_item_number_by_name(object_name);
+ int32 obj_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
logic_structs[obj_id]->mega->SetDynamicLight(params[1], // cycles
params[2], params[3], params[4], // rgb
diff --git a/engines/icb/mega_interaction.cpp b/engines/icb/mega_interaction.cpp
index 8e1fed61707..02f2f94d06f 100644
--- a/engines/icb/mega_interaction.cpp
+++ b/engines/icb/mega_interaction.cpp
@@ -68,7 +68,7 @@ mcodeFunctionReturnCodes _game_session::fn_interact_with_id(int32 &, int32 *para
script_hash = HashString(script_name);
// get target object
- target_object = (c_game_object *)MS->objects->Fetch_item_by_number(params[0]);
+ target_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, params[0]);
// set socket_id ready for any special socket functions
M->target_id = params[0];
@@ -83,7 +83,7 @@ mcodeFunctionReturnCodes _game_session::fn_interact_with_id(int32 &, int32 *para
// script k is the one to run
// get the address of the script we want to run
- char *ad = (char *)scripts->Try_fetch_item_by_hash(target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
@@ -125,12 +125,12 @@ mcodeFunctionReturnCodes _game_session::fn_mega_interacts(int32 &, int32 *params
Zdebug("fn_mega_interacts with object [%s], script [%s]", object_name, script_name);
// get target object
- target_object = (c_game_object *)MS->objects->Try_fetch_item_by_name(object_name);
+ target_object = (c_game_object *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, object_name);
if (!target_object)
Fatal_error("fn_mega_interacts - named object [%s] dont exist", object_name);
// set socket_id ready for any special socket functions
- M->target_id = objects->Fetch_item_number_by_name(object_name);
+ M->target_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// set this flag to avoid interact with id=0 based problems
M->interacting = TRUE8;
@@ -141,7 +141,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_interacts(int32 &, int32 *params
Zdebug("found target interact script", k);
// script k is the one to run
// get the address of the script we want to run
- char *ad = (char *)scripts->Try_fetch_item_by_hash(target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
@@ -176,12 +176,12 @@ mcodeFunctionReturnCodes _game_session::fn_mega_generic_interact(int32 &, int32
Zdebug("fn_mega_generic_interact with [%s]", object_name);
// get target object
- target_object = (c_game_object *)MS->objects->Try_fetch_item_by_name(object_name);
+ target_object = (c_game_object *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, object_name);
if (!target_object)
Fatal_error("fn_mega_generic_interact - named object [%s] dont exist", object_name);
// set socket_id ready for any special socket functions
- M->target_id = objects->Fetch_item_number_by_name(object_name);
+ M->target_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// set this flag to avoid interact with id=0 based problems
M->interacting = TRUE8;
@@ -193,7 +193,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_generic_interact(int32 &, int32
// script k is the one to run
// get the address of the script we want to run
- char *ad = (char *)scripts->Try_fetch_item_by_hash(target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
@@ -225,7 +225,7 @@ bool8 _game_session::chi_interacts(int32 id, const char *script_name) {
script_hash = HashString(script_name);
// get target object
- target_object = (c_game_object *)MS->objects->Fetch_item_by_number(id);
+ target_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!target_object)
Fatal_error("chi_interacts - object [%d] dont exist", id);
@@ -240,7 +240,7 @@ bool8 _game_session::chi_interacts(int32 id, const char *script_name) {
if (script_hash == target_object->GetScriptNamePartHash(k)) {
// script k is the one to run
// get the address of the script we want to run
- char *ad = (char *)scripts->Try_fetch_item_by_hash(target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
diff --git a/engines/icb/mission.cpp b/engines/icb/mission.cpp
index 0d7b07b65ad..b4fc49df3fa 100644
--- a/engines/icb/mission.cpp
+++ b/engines/icb/mission.cpp
@@ -423,7 +423,7 @@ void _mission::Save_micro_session() {
micro_sessions[j].number_of_micro_objects = session->Fetch_number_of_objects();
for (i = 0; i < session->Fetch_number_of_objects(); i++) {
- object = (c_game_object *)session->objects->Fetch_item_by_number(i);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, object->GetName(), object->GetNoLvars(), session->Fetch_object_status(i));
micro_sessions[j].micro_objects[i].status_flag = session->Fetch_object_status(i);
@@ -497,7 +497,7 @@ void _mission::Restore_micro_session_vars() {
// restore lvars
for (i = 0; i < session->Fetch_number_of_objects(); i++) {
- object = (c_game_object *)session->objects->Fetch_item_by_number(i);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, object->GetName(), object->GetNoLvars(),
micro_sessions[j].micro_objects[i].status_flag);
@@ -536,7 +536,7 @@ void _mission::Restore_micro_session_coords(bool8 from_disk) {
// restore lvars
for (i = 0; i < session->Fetch_number_of_objects(); i++) {
- object = (c_game_object *)session->objects->Fetch_item_by_number(i);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, object->GetName(), object->GetNoLvars(),
micro_sessions[j].micro_objects[i].status_flag);
diff --git a/engines/icb/options_manager_pc.cpp b/engines/icb/options_manager_pc.cpp
index 890eff6f9da..1fe9e58d2fd 100644
--- a/engines/icb/options_manager_pc.cpp
+++ b/engines/icb/options_manager_pc.cpp
@@ -104,7 +104,7 @@ void Init_play_movie(const char *param0, bool8 param1);
uint32 GetFileSz(const char *path);
// Translation tweaks
-_linked_data_file *LoadTranslatedFile(const char *session, const char *mission);
+LinkedDataFile *LoadTranslatedFile(const char *session, const char *mission);
// Death text functions and defines
#define MAX_DEATH_TEXT 4
@@ -641,7 +641,7 @@ void OptionsManager::StartGameOverOptions() {
bool8 regularPlayerDeath = TRUE8;
// Have we died under irregular circumstances?
- c_game_object *playerObj = (c_game_object *)MS->objects->Fetch_item_by_number(MS->player.Fetch_player_id());
+ c_game_object *playerObj = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, MS->player.Fetch_player_id());
int32 state = playerObj->GetVariable("state");
if (playerObj->GetIntegerVariable(state) == 2)
regularPlayerDeath = FALSE8;
@@ -5515,12 +5515,12 @@ const char *OptionsManager::GetTextFromReference(uint32 hashRef) {
// Get the text via a label
if (m_global_text)
- textLine = (char *)m_global_text->Try_fetch_item_by_hash(hashRef);
+ textLine = (char *)LinkedDataObject::Try_fetch_item_by_hash(m_global_text, hashRef);
if (!textLine) {
// Try again with reloaded text file
LoadGlobalTextFile();
- textLine = (char *)m_global_text->Try_fetch_item_by_hash(hashRef);
+ textLine = (char *)LinkedDataObject::Try_fetch_item_by_hash(m_global_text, hashRef);
if (!textLine)
return "Missing text!";
}
@@ -5569,8 +5569,8 @@ void OptionsManager::LoadBitmapFont() {
pxString font_cluster = FONT_CLUSTER_PATH;
m_font_file = (_pxBitmap *)rs_font->Res_open(m_fontName, hashedname, font_cluster, font_cluster_hash);
- if (m_font_file->schema != PC_BITMAP_SCHEMA)
- Fatal_error("Incorrect versions loading [%s] (engine has %d, data has %d", m_fontName, PC_BITMAP_SCHEMA, m_font_file->schema);
+ if (FROM_LE_32(m_font_file->schema) != PC_BITMAP_SCHEMA)
+ Fatal_error("Incorrect versions loading [%s] (engine has %d, data has %d", m_fontName, PC_BITMAP_SCHEMA, FROM_LE_32(m_font_file->schema));
m_fontPalette = (uint32 *)&m_font_file->palette[0];
}
@@ -5595,9 +5595,9 @@ void OptionsManager::LoadGlobalTextFile() {
if (m_global_text == nullptr)
m_global_text = LoadTranslatedFile("global", "global\\global\\");
} else
- m_global_text = (_linked_data_file *)rs1->Res_open(textFileName, buf_hash, globalClusterFile, globalClusterHash);
+ m_global_text = (LinkedDataFile *)rs1->Res_open(textFileName, buf_hash, globalClusterFile, globalClusterHash);
- m_global_text = (_linked_data_file *)rs1->Res_open(textFileName, buf_hash, globalClusterFile, globalClusterHash);
+ m_global_text = (LinkedDataFile *)rs1->Res_open(textFileName, buf_hash, globalClusterFile, globalClusterHash);
}
bool8 OptionsManager::SetCharacterSprite(char c) {
diff --git a/engines/icb/options_manager_pc.h b/engines/icb/options_manager_pc.h
index d7a170cc797..b70f4952845 100644
--- a/engines/icb/options_manager_pc.h
+++ b/engines/icb/options_manager_pc.h
@@ -293,7 +293,7 @@ private:
uint32 m_fontHeight;
_pxPCSprite *m_currentSprite;
_rgb m_selectedShade;
- _linked_data_file *m_global_text;
+ LinkedDataFile *m_global_text;
_rgb m_drawColour; // Current primitive drawing colour
diff --git a/engines/icb/p4_pc.cpp b/engines/icb/p4_pc.cpp
index d3516ca29ca..8e23eaa38e4 100644
--- a/engines/icb/p4_pc.cpp
+++ b/engines/icb/p4_pc.cpp
@@ -355,7 +355,7 @@ void Mission_and_console() {
// the mission has terminated of its own accord - as apposed to a user quit
// if the player died then we bring up a restart/continue menu here
- c_game_object *ob = (c_game_object *)MS->objects->Fetch_item_by_number(MS->player.Fetch_player_id());
+ c_game_object *ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, MS->player.Fetch_player_id());
int32 ret = ob->GetVariable("state");
if (ob->GetIntegerVariable(ret)) {
// Return to avoid deleting the mission
diff --git a/engines/icb/player.cpp b/engines/icb/player.cpp
index 5ceda713b33..375339b809d 100644
--- a/engines/icb/player.cpp
+++ b/engines/icb/player.cpp
@@ -236,7 +236,7 @@ __mode_return _player::Player_press_fire_button() {
if ((interact_selected) && (MS->Call_socket(cur_interact_id, "give_state", &retval))) {
if (!retval) {
// try to fetch the object
- MS->socket_object = (c_game_object *)MS->objects->Fetch_item_by_number(cur_interact_id);
+ MS->socket_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
res = MS->Call_socket(cur_interact_id, "gun_shot", &retval);
@@ -738,7 +738,7 @@ mcodeFunctionReturnCodes _player::Gateway() {
interact_lock = TRUE8;
- ob = (c_game_object *)MS->objects->Fetch_item_by_number(player_id);
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, player_id);
// Make sure number of medi-packs is > 0
if (GetNoMediPacks() > 0) {
@@ -1912,7 +1912,7 @@ void _player::Add_to_interact_history() {
// record it
MS->history[MS->cur_history].interaction = TRUE8;
MS->history[MS->cur_history].id = MS->stairs[stair_num].stair_id;
- Tdebug("history.txt", "Stair [%s]", MS->objects->Fetch_items_name_by_number(MS->stairs[stair_num].stair_id));
+ Tdebug("history.txt", "Stair [%s]", LinkedDataObject::Fetch_items_name_by_number(MS->objects, MS->stairs[stair_num].stair_id));
MS->floor_def->Set_floor_rect_flag(log);
Tdebug("history.txt", "...%d", log->owner_floor_rect);
@@ -3141,7 +3141,7 @@ void _game_session::Restart_player() {
int32 var_num;
c_game_object *ob;
- ob = (c_game_object *)objects->Fetch_item_by_number(player.Fetch_player_id());
+ ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
var_num = ob->GetVariable("state");
if (var_num == -1)
diff --git a/engines/icb/player_interaction.cpp b/engines/icb/player_interaction.cpp
index f93f6a3d21a..e63e06046e8 100644
--- a/engines/icb/player_interaction.cpp
+++ b/engines/icb/player_interaction.cpp
@@ -295,12 +295,12 @@ __mode_return _player::Player_interact() {
for (j = 0; j < MAX_auto_interact; j++)
if (MS->auto_interact_list[j] == (cur_interact_id + 1)) {
// try to fetch the object
- iobject = (c_game_object *)MS->objects->Fetch_item_by_number(cur_interact_id);
+ iobject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
Zdebug(" INTERACT with %s", iobject->GetName());
// get the address of the script we want to run
- const char *pc = (const char *)MS->scripts->Try_fetch_item_by_hash(iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
if (pc == nullptr)
Fatal_error("Object [%s] has no interact script", iobject->GetName());
@@ -315,10 +315,10 @@ __mode_return _player::Player_interact() {
// check for interact button AND there being an object to interact with
if ((cur_state.IsButtonSet(__INTERACT)) && (interact_selected) && (!interact_lock) && (!stood_on_lift)) {
// try to fetch the object
- iobject = (c_game_object *)MS->objects->Fetch_item_by_number(cur_interact_id);
+ iobject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
// get the address of the script we want to run
- const char *pc = (const char *)MS->scripts->Try_fetch_item_by_hash(iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
if (pc == nullptr)
Fatal_error("Object [%s] has no interact script", iobject->GetName());
@@ -371,7 +371,7 @@ mcodeFunctionReturnCodes _game_session::fn_start_player_interaction(int32 &, int
M->interacting = TRUE8;
// fetch action script
- ad = (char *)scripts->Try_fetch_item_by_hash(params[0] /*(uint32)params*/);
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, params[0] /*(uint32)params*/);
// write actual offset
L->logic[1] = ad;
@@ -397,7 +397,7 @@ bool8 _game_session::Engine_start_interaction(const char *script, uint32 id) {
script_hash = HashString(script);
// get target object
- iobject = (c_game_object *)MS->objects->Fetch_item_by_number(id);
+ iobject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!iobject)
Fatal_error("Engine_start_interaction - named object dont exist"); // should never happen
@@ -407,7 +407,7 @@ bool8 _game_session::Engine_start_interaction(const char *script, uint32 id) {
if (script_hash == iobject->GetScriptNamePartHash(k)) {
// script k is the one to run
// get the address of the script we want to run
- char *pc = (char *)scripts->Try_fetch_item_by_hash(iobject->GetScriptNameFullHash(k));
+ char *pc = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, iobject->GetScriptNameFullHash(k));
// set target id
M->target_id = id;
diff --git a/engines/icb/remora.cpp b/engines/icb/remora.cpp
index e4203eb9f66..8f428a641c8 100644
--- a/engines/icb/remora.cpp
+++ b/engines/icb/remora.cpp
@@ -24,6 +24,7 @@
*
*/
+#include "engines/icb/common/px_linkeddatafile.h"
#include "engines/icb/remora.h"
#include "engines/icb/line_of_sight.h"
#include "engines/icb/sound.h"
@@ -447,7 +448,7 @@ void _remora::CycleRemoraLogic(const _input &sKeyboardState) {
// Remora is now inactive.
m_eGameState = INACTIVE;
- nRemoraID = MS->objects->Fetch_item_number_by_name(REMORA_NAME);
+ nRemoraID = LinkedDataObject::Fetch_item_number_by_name(MS->objects, REMORA_NAME);
if (nRemoraID == PX_LINKED_DATA_FILE_ERROR)
Fatal_error("No logic object for Remora in _remora::CycleRemoraLogic()");
@@ -633,14 +634,14 @@ void _remora::SetupPicture(uint32 nXPixelOffset, const char *pcPictureName) {
}
void _remora::AddFloorRange(uint32 nLower, uint32 nUpper) {
- _linked_data_file *pSlices;
+ LinkedDataFile *pSlices;
// Check that top value is within the available slices (bottom one must be because it is unsigned). First,
// get the pointer to the slices (this will already have been loaded by the line-of-sight engine).
pSlices = g_oLineOfSight->GetSlicesPointer();
- if (nUpper >= pSlices->Fetch_number_of_items())
- nUpper = pSlices->Fetch_number_of_items() - 1;
+ if (nUpper >= LinkedDataObject::Fetch_number_of_items(pSlices))
+ nUpper = LinkedDataObject::Fetch_number_of_items(pSlices) - 1;
// Upper must be greater than lower, or it isn't a range.
if (nUpper <= nLower)
@@ -734,14 +735,14 @@ const char *_remora::LocateTextFromReference(uint32 nHashRef) {
const char *pcTextLine;
// Look for the reference.
- pcTextLine = (const char *)MS->text->Try_fetch_item_by_hash(nHashRef);
+ pcTextLine = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->text, nHashRef);
// If we found it, return it.
if (pcTextLine)
return (pcTextLine);
// Look in the global text file.
- pcTextLine = (const char *)global_text->Try_fetch_item_by_hash(nHashRef);
+ pcTextLine = (const char *)LinkedDataObject::Try_fetch_item_by_hash(global_text, nHashRef);
// Return the pointer regardless.
return (pcTextLine);
@@ -897,7 +898,7 @@ void _remora::DrawVoiceOverText() const {
void _remora::SetCommonActivateInfo(RemoraMode eMode) {
uint32 i, j;
_logic *pPlayerObject;
- _linked_data_file *pSlices;
+ LinkedDataFile *pSlices;
_barrier_slice *pSlice;
int32 nSlice;
uint32 nNumSlices;
@@ -930,12 +931,12 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
pSlices = g_oLineOfSight->GetSlicesPointer();
// Find out which slice we're in.
- nNumSlices = pSlices->Fetch_number_of_items();
+ nNumSlices = LinkedDataObject::Fetch_number_of_items(pSlices);
nSlice = 0;
for (i = 0; i < nNumSlices; ++i) {
// Get the slice.
- pSlice = (_barrier_slice *)pSlices->Fetch_item_by_number(i);
+ pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, i);
// See if the player's feet are in this slice.
if ((m_nPlayerY >= pSlice->bottom) && (m_nPlayerY < pSlice->top))
@@ -953,7 +954,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
bInFloorRange = TRUE8;
for (j = m_pFloorRanges[i].s_nLower; j <= m_pFloorRanges[i].s_nUpper; ++j) {
- m_pSlices[m_nNumCurrentFloorRanges] = (_barrier_slice *)pSlices->Fetch_item_by_number(j);
+ m_pSlices[m_nNumCurrentFloorRanges] = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, j);
m_pnSlices[m_nNumCurrentFloorRanges] = j;
++m_nNumCurrentFloorRanges;
}
@@ -965,7 +966,7 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
// If we didn't set a floor range then we must set a single floor slice.
if (!bInFloorRange) {
// Only one slice required to be displayed.
- m_pSlices[0] = (_barrier_slice *)pSlices->Fetch_item_by_number(nSlice);
+ m_pSlices[0] = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(pSlices, nSlice);
m_pnSlices[0] = nSlice;
m_nNumCurrentFloorRanges = 1;
}
@@ -985,7 +986,7 @@ void _remora::AccessMenuLevelVariables(int32 *pnParams, MenuVariableAccessMode e
uint32 nDigitPos;
// Get the Remora's game object.
- pGameObject = (c_game_object *)MS->objects->Fetch_item_by_name(REMORA_NAME);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_name(MS->objects, REMORA_NAME);
// Get the position where we need to add the digit to the menu variable name.
nDigitPos = strlen(pcVarName) - 1;
@@ -1036,7 +1037,7 @@ _remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID
case (__ORGANIC_MEGA):
// Need to find out if the human is alive or dead.
- pGameObject = (c_game_object *)MS->objects->Fetch_item_by_number(nID);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
nScriptVar = pGameObject->GetVariable("state");
nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
if (nVarVal == 1)
@@ -1048,7 +1049,7 @@ _remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID
case (__NON_ORGANIC_MEGA):
// Need to find out if the robot is alive or dead.
- pGameObject = (c_game_object *)MS->objects->Fetch_item_by_number(nID);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
nScriptVar = pGameObject->GetVariable("state");
nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
if (nVarVal == 1)
@@ -1060,7 +1061,7 @@ _remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID
case (__REMORA_CARRIER):
// This is an object carrying a Remora, but only the player gets a special symbol now.
- pGameObject = (c_game_object *)MS->objects->Fetch_item_by_number(nID);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
nScriptVar = pGameObject->GetVariable("state");
nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
if (nVarVal == 1)
@@ -1070,7 +1071,7 @@ _remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID
break;
case (__RECHARGE_POINT):
- pGameObject = (c_game_object *)MS->objects->Fetch_item_by_number(nID);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
nScriptVar = pGameObject->GetVariable("set_mine");
nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
if (nVarVal == 1)
diff --git a/engines/icb/remora_pc.cpp b/engines/icb/remora_pc.cpp
index ddfdfbaa68b..c8ec1a29e45 100644
--- a/engines/icb/remora_pc.cpp
+++ b/engines/icb/remora_pc.cpp
@@ -1095,7 +1095,7 @@ void _remora::DrawPulse() {
//nBaseY = REMORA_PULSE_Y;
// Work out player's health.
- pPlayer = (c_game_object *)MS->objects->Fetch_item_by_name("player");
+ pPlayer = (c_game_object *)LinkedDataObject::Fetch_item_by_name(MS->objects, "player");
nHits = pPlayer->GetIntegerVariable(pPlayer->GetVariable("hits"));
// This counts from 10 down to zero (check player's script for this figure if it changes).
diff --git a/engines/icb/route_manager.cpp b/engines/icb/route_manager.cpp
index 0cb4329618b..b65544d7df5 100644
--- a/engines/icb/route_manager.cpp
+++ b/engines/icb/route_manager.cpp
@@ -504,7 +504,7 @@ mcodeFunctionReturnCodes _game_session::fn_route_to_nico(int32 &result, int32 *p
return IR_REPEAT;
}
- monica = (_feature_info *)features->Try_fetch_item_by_name(nico_name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
if (!monica)
Fatal_error("fn_route_to_nico - object [%s] cant find nico [%s]", object->GetName(), nico_name);
@@ -613,7 +613,7 @@ mcodeFunctionReturnCodes _game_session::fn_spectre_route_to_mega(int32 &result,
const char *mega_name = (const char *)MemoryUtil::resolvePtr(params[0]);
// get object to check
- id = objects->Fetch_item_number_by_name(mega_name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, mega_name);
if (id == 0xffffffff)
Fatal_error("fn_spectre_route_to_mega - illegal object [%s]", mega_name);
@@ -786,13 +786,13 @@ mcodeFunctionReturnCodes _game_session::Route_to_near_mega_core(const char *name
// get object to check
- monica = (_feature_info *)features->Try_fetch_item_by_name(name);
+ monica = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, name);
if (monica) {
x = monica->x;
z = monica->z;
} else {
- id = objects->Fetch_item_number_by_name(name);
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, name);
if (id == 0xffffffff)
Fatal_error("[%s] calling Route_to_near_mega_core - finds neither object or nico named [%s]", object->GetName(), name);
// found mega with name!
diff --git a/engines/icb/session.cpp b/engines/icb/session.cpp
index 007ce216ccc..9d1d6e548ff 100644
--- a/engines/icb/session.cpp
+++ b/engines/icb/session.cpp
@@ -52,7 +52,7 @@ namespace ICB {
// Translation tweaks
-_linked_data_file *LoadTranslatedFile(const char *session, const char *mission);
+LinkedDataFile *LoadTranslatedFile(const char *session, const char *mission);
// prototypes
@@ -161,10 +161,10 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// Make Res_open compute the hash value
buf_hash = NULL_HASH;
- objects = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ objects = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
// set this for convenience
- total_objects = objects->Fetch_number_of_items();
+ total_objects = LinkedDataObject::Fetch_number_of_items(objects);
Zdebug("total objects %d", total_objects);
if (total_objects >= MAX_session_objects)
@@ -186,7 +186,7 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// so PSX can have nice session loading screen and details (for timing and to stop player getting bored)
LoadMsg("Session Scripts");
buf_hash = NULL_HASH;
- scripts = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ scripts = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
// display script version info
// also available on console
@@ -200,11 +200,11 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// so PSX can have nice session loading screen and details (for timing and to stop player getting bored)
LoadMsg("Session PropAnims");
buf_hash = NULL_HASH;
- prop_anims = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ prop_anims = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
// Check file version is correct.
- if (prop_anims->GetHeaderVersion() != VERSION_PXWGPROPANIMS)
- Fatal_error("%s version check failed (file has %d, engine has %d)", temp_buf, prop_anims->GetHeaderVersion(), VERSION_PXWGPROPANIMS);
+ if (LinkedDataObject::GetHeaderVersion(prop_anims) != VERSION_PXWGPROPANIMS)
+ Fatal_error("%s version check failed (file has %d, engine has %d)", temp_buf, LinkedDataObject::GetHeaderVersion(prop_anims), VERSION_PXWGPROPANIMS);
// init features file
// we stick this in the private cache so it hangs around and later in-game references wont cause a main pool reload
@@ -215,7 +215,7 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// so PSX can have nice session loading screen and details (for timing and to stop player getting bored)
LoadMsg("Session Features");
buf_hash = NULL_HASH;
- features = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ features = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
// engine knows no set/camera chosen
Reset_camera_director();
@@ -250,7 +250,7 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// Ok, translators mode has been activated
text = LoadTranslatedFile(mission, session_name);
} else
- text = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ text = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
} else
Fatal_error("Missing Text File \"%s\"", temp_buf);
@@ -277,7 +277,7 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
// Ok, translators mode has been activated
global_text = LoadTranslatedFile("global", "global\\global\\");
} else
- global_text = (_linked_data_file *)private_session_resman->Res_open(textFileName, buf_hash, global_cluster, global_cluster_hash);
+ global_text = (LinkedDataFile *)private_session_resman->Res_open(textFileName, buf_hash, global_cluster, global_cluster_hash);
} else {
Fatal_error("Failed to find global text file [%s][%s]", textFileName, global_cluster);
@@ -318,13 +318,13 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
uint32 len = private_session_resman->Check_file_size(temp_buf, buf_hash, session_cluster, session_cluster_hash);
if (len) {
- walk_areas = (_linked_data_file *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
- Tdebug("walkareas.txt", "%d top level walkareas\n", walk_areas->Fetch_number_of_items());
+ walk_areas = (LinkedDataFile *)private_session_resman->Res_open(temp_buf, buf_hash, session_cluster, session_cluster_hash);
+ Tdebug("walkareas.txt", "%d top level walkareas\n", LinkedDataObject::Fetch_number_of_items(walk_areas));
int32 nMissing = 0;
- for (uint32 k = 0; k < walk_areas->Fetch_number_of_items(); k++) {
+ for (uint32 k = 0; k < LinkedDataObject::Fetch_number_of_items(walk_areas); k++) {
INTEGER_WalkAreaFile *inner_wa;
- inner_wa = (INTEGER_WalkAreaFile *)walk_areas->Fetch_item_by_number(k);
+ inner_wa = (INTEGER_WalkAreaFile *)LinkedDataObject::Fetch_item_by_number(walk_areas, k);
Tdebug("walkareas.txt", "\nclump %d has %d inner items", k, inner_wa->GetNoAreas());
@@ -383,7 +383,7 @@ void _game_session::___init(const char *mission, const char *new_session_name) {
}
void _game_session::Script_version_check() {
- if (FN_ROUTINES_DATA_VERSION != scripts->GetHeaderVersion())
+ if (FN_ROUTINES_DATA_VERSION != LinkedDataObject::GetHeaderVersion(scripts))
Fatal_error("WARNING! SCRIPTS AND ENGINE ARE NOT SAME VERSION");
}
@@ -482,13 +482,13 @@ void _game_session::Init_objects() {
// only do this at start of mission - never again afterward - i.e. not when returning to first session from another
uint32 script_hash;
- id = objects->Fetch_item_number_by_name("player"); // returns -1 if object not in existence
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, "player"); // returns -1 if object not in existence
if (id == 0xffffffff)
Fatal_error("Init_objects cant find 'player'");
script_hash = HashString("player::globals");
- const char *pc = (const char *)scripts->Try_fetch_item_by_hash(script_hash);
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, script_hash);
if (pc) {
- object = (c_game_object *)objects->Fetch_item_by_number(id);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, id);
Tdebug("objects_init.txt", " initialising globals", (const char *)buf);
RunScript(pc, object);
}
@@ -508,7 +508,7 @@ void _game_session::Init_objects() {
// event manager have been initialised in case calls get made to these services in any of the
// objects' InitScripts.
for (j = 0; ((j < total_objects)); j++) {
- object = (c_game_object *)objects->Fetch_item_by_number(j);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, j);
Tdebug("objects_init.txt", "\n\n---------------------------------------------------\n%d initialising object '%s'", j, object->GetName());
Zdebug("\n\n---------------------------------------------------\n%d initialising object '%s'", j, object->GetName());
@@ -527,7 +527,7 @@ void _game_session::Init_objects() {
// the init script is always script 0 for the object
// the init script may or may not be overiden
// get the address of the script we want to run
- const char *pc = (const char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(OB_INIT_SCRIPT)); // run init script
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_INIT_SCRIPT)); // run init script
if (pc) {
RunScript(pc, object);
@@ -544,7 +544,7 @@ void _game_session::Init_objects() {
Tdebug("objects_init.txt", "search for [%s]", (const char *)buf);
- pc = (const char *)scripts->Try_fetch_item_by_hash(script_hash);
+ pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, script_hash);
if (pc) {
// set M and I for FN_ functions that may be called
@@ -562,7 +562,7 @@ void _game_session::Init_objects() {
logic_structs[j]->logic_level = 0;
// set base logic to logic context script
- logic_structs[j]->logic[0] = (char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
+ logic_structs[j]->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
// **note, we dont need to set up the script reference (logic_ref) for level 0
} else
Shut_down_object("by initialise - no init script");
@@ -599,14 +599,14 @@ void _game_session::Init_objects() {
// init the player object number
// get id
- id = objects->Fetch_item_number_by_name("player"); // returns -1 if object not in existence
+ id = LinkedDataObject::Fetch_item_number_by_name(objects, "player"); // returns -1 if object not in existence
if (id != 0xffffffff) {
L = logic_structs[id]; // fetch logic struct for player object
I = L->voxel_info;
M = L->mega;
- object = (c_game_object *)objects->Fetch_item_by_number(id);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, id);
// not if this object has been shut-down - for not having a map marker for example
if (L->ob_status != OB_STATUS_HELD)
@@ -669,7 +669,7 @@ void _game_session::Pre_initialise_objects() {
Zdebug("%d -[%d]", j, num_megas);
- object = (c_game_object *)objects->Fetch_item_by_number(j);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, j);
logic_structs[j] = g_logics[j];
logic_structs[j]->___init((const char *)object->GetName());
@@ -778,7 +778,7 @@ void _game_session::One_logic_cycle() {
cur_id = j; // fast reference for engine functions
// fetch the object that is our current object
// 'object' needed as logic code may ask it for the objects name, etc.
- object = (c_game_object *)objects->Fetch_item_by_number(j);
+ object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, j);
// run appropriate logic
switch (L->big_mode) {
@@ -930,7 +930,7 @@ void _game_session::Pre_logic_event_check() {
// interacting, so ignoring LOS event
Zdebug("interacting, so ignoring LOS event");
} else {
- L->logic[0] = (char *)scripts->Try_fetch_item_by_hash((object->GetScriptNameFullHash(OB_LOGIC_CONTEXT)));
+ L->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, (object->GetScriptNameFullHash(OB_LOGIC_CONTEXT)));
// run script - context chooser MAY pick a new L 1 logic
// we call this now so the new script will be setup and ready to run
@@ -956,7 +956,7 @@ void _game_session::Script_cycle() {
if ((L->image_type == VOXEL) && (M->interacting)) { // check for megas who are interacting
// object is running someone elses interaction script
// so get their object and pass to interpretter so that local vars can be accessed correctly
- script_owner = (c_game_object *)objects->Fetch_item_by_number(M->target_id);
+ script_owner = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, M->target_id);
} else {
script_owner = object; // object running its own script
}
@@ -985,7 +985,7 @@ void _game_session::Script_cycle() {
// it is acceptable to choose the logic that had previously been running
// temp reset PC the hard way
- L->logic[0] = (char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
+ L->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
// run script - context chooser will pick a new L 1 logic
RunScript(const_cast<const char *&>(L->logic[0]), object);
@@ -1019,7 +1019,7 @@ uint32 _game_session::Fetch_prop_state(char *prop_name) {
uint32 j;
if (camera_hack == FALSE8) {
- prop_number = objects->Fetch_item_number_by_name(prop_name);
+ prop_number = LinkedDataObject::Fetch_item_number_by_name(objects, prop_name);
if (prop_number != 0xffffffff)
return (prop_state_table[prop_number]); // get prop state (pc)
@@ -1061,7 +1061,7 @@ void _game_session::Set_prop_state(char *prop_name, uint32 value) {
uint32 j;
if (camera_hack == FALSE8) {
- prop_number = objects->Fetch_item_number_by_name(prop_name);
+ prop_number = LinkedDataObject::Fetch_item_number_by_name(objects, prop_name);
if (prop_number != 0xffffffff)
prop_state_table[prop_number] = value; // set prop state (pc)
@@ -1153,7 +1153,7 @@ void _game_session::Idle_manager() {
if (script_hash == object->GetScriptNamePartHash(k)) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)scripts->Try_fetch_item_by_hash(object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
// write actual offset
L->logic[2] = ad;
@@ -1187,7 +1187,7 @@ void _game_session::Set_init_voxel_floors() {
Prepare_megas_route_barriers(TRUE8); // update barriers
}
-_linked_data_file *LoadTranslatedFile(const char *mission, const char *session) {
+LinkedDataFile *LoadTranslatedFile(const char *mission, const char *session) {
// Get the actual session name
const char *sessionstart = session + strlen(mission) + 1;
pxString actsession;
@@ -1217,7 +1217,7 @@ _linked_data_file *LoadTranslatedFile(const char *mission, const char *session)
// 0 terminate the string
memPtr[len] = 0;
- return ((_linked_data_file *)memPtr);
+ return ((LinkedDataFile *)memPtr);
}
} // End of namespace ICB
diff --git a/engines/icb/session.h b/engines/icb/session.h
index 03442112f60..44ac372c4e1 100644
--- a/engines/icb/session.h
+++ b/engines/icb/session.h
@@ -938,14 +938,14 @@ public:
_barrier_handler *session_barriers; // pointer to _barrier_handler object - loads file so must be pointer
// game object stuff - objects.linked
- _linked_data_file *objects;
+ LinkedDataFile *objects;
uint32 total_objects; // number of objects in the objects.object file - pulled out at session start for convenience
_logic *logic_structs[MAX_session_objects]; // pointers to current sessions logic structs
uint32 num_megas; // keeps a running total of megas initialised - used when assigning megas structures
uint32 num_vox_images; // as above but for vox_images - in theory these 2 counters are the same thing but that would be an assumption too far tbh
// and the scripts.linked file
- _linked_data_file *scripts;
+ LinkedDataFile *scripts;
// handles player object and user interface
_player player;
@@ -955,10 +955,10 @@ public:
_marker markers;
// initial map tag positions of props, people, etc.
- _linked_data_file *features;
+ LinkedDataFile *features;
// ascii speech text
- _linked_data_file *text;
+ LinkedDataFile *text;
// list of auto interact objects
uint8 auto_interact_list[MAX_auto_interact];
@@ -970,13 +970,13 @@ public:
uint32 remora_font_hash; // the hash value of the speech_font_one string
// prop animations
- _linked_data_file *prop_anims; // prop anims are loaded into the special private_session_resman
+ LinkedDataFile *prop_anims; // prop anims are loaded into the special private_session_resman
// make los_timing be global so we can print it at a global level
uint32 los_time;
uint32 total_was; // how many individual walk-areas
- _linked_data_file *walk_areas;
+ LinkedDataFile *walk_areas;
const __aWalkArea *wa_list[MAX_was]; // walk areas
bool8 manual_camera; // overiden by a script command
@@ -1184,7 +1184,7 @@ inline uint32 _game_session::Fetch_object_integer_variable(const char *pcName, c
c_game_object *pGameObject;
// Get the object itself.
- pGameObject = (c_game_object *)objects->Fetch_item_by_name(pcName);
+ pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, pcName);
if (!pGameObject)
Fatal_error("_game_session::Fetch_object_integer_variable( %s, %s ) couldn't find object", pcName, pcVar);
diff --git a/engines/icb/set.cpp b/engines/icb/set.cpp
index 9c8a802e828..c716997f323 100644
--- a/engines/icb/set.cpp
+++ b/engines/icb/set.cpp
@@ -31,6 +31,7 @@
#include "engines/icb/mission.h"
#include "engines/icb/session.h"
#include "engines/icb/common/px_string.h"
+#include "engines/icb/common/px_linkeddatafile.h"
#include "engines/icb/res_man.h"
#include "engines/icb/global_objects.h"
#include "engines/icb/global_switches.h"
@@ -108,7 +109,7 @@ void _game_session::GetSelectedPropRGB(uint8 &r, uint8 &g, uint8 &b) {
}
bool8 _game_session::IsPropSelected(const char *propName) {
- uint32 prop_number = objects->Fetch_item_number_by_name(propName);
+ uint32 prop_number = LinkedDataObject::Fetch_item_number_by_name(objects, propName);
if (prop_number == 0xFFFFFFFF)
return FALSE8;
@@ -136,9 +137,9 @@ void _game_session::Render_3d_nicos() {
ad = surface_manager->Lock_surface(working_buffer_id);
pitch = surface_manager->Get_pitch(working_buffer_id);
- for (j = 0; j < features->Fetch_number_of_items(); j++) {
+ for (j = 0; j < LinkedDataObject::Fetch_number_of_items(features); j++) {
// get nico
- feature = (_feature_info *)MS->features->Fetch_item_by_number(j);
+ feature = (_feature_info *)LinkedDataObject::Fetch_item_by_number(MS->features, j);
// setup camera : have to do this once per frame because
// clip_text_print does a Res_open and in principal this
@@ -163,7 +164,7 @@ void _game_session::Render_3d_nicos() {
// print name if on screen
if (result) {
Clip_text_print(&pen, (uint32)(filmpos.x + (SCREEN_WIDTH / 2)), (uint32)((SCREEN_DEPTH / 2) - filmpos.y), ad, pitch, "%s %3.1f",
- (char *)features->Fetch_items_name_by_number(j), feature->direction);
+ (char *)LinkedDataObject::Fetch_items_name_by_number(features, j), feature->direction);
}
}
diff --git a/engines/icb/sound.cpp b/engines/icb/sound.cpp
index 97d3132d2f6..b8383138558 100644
--- a/engines/icb/sound.cpp
+++ b/engines/icb/sound.cpp
@@ -252,10 +252,10 @@ int32 EvalEnv(const CEnvelope &env, int32 x) {
}
// get the sfxlist file!
-_linked_data_file *GetMissionSfxFile() {
+LinkedDataFile *GetMissionSfxFile() {
uint32 fileHash;
uint32 clusterHash;
- _linked_data_file *f = nullptr;
+ LinkedDataFile *f = nullptr;
// if no mission return NULL
if (!g_mission) {
@@ -268,17 +268,17 @@ _linked_data_file *GetMissionSfxFile() {
fileHash = NULL_HASH;
clusterHash = MS->Fetch_session_cluster_hash();
- f = (_linked_data_file *)private_session_resman->Res_open("m_sfxlist", fileHash, MS->Fetch_session_cluster(), clusterHash);
+ f = (LinkedDataFile *)private_session_resman->Res_open("m_sfxlist", fileHash, MS->Fetch_session_cluster(), clusterHash);
}
- if ((f->GetHeaderVersion() != SFX_VERSION) || (f->header.type != FT_COMPILED_SFX))
- Fatal_error("Sound: mission::the.cmpsfxlist, Header wrong, engine:%d,%08x file:%d,%08x\n", SFX_VERSION, FT_COMPILED_SFX, f->GetHeaderVersion(), f->header.type);
+ if ((LinkedDataObject::GetHeaderVersion(f) != SFX_VERSION) || (FROM_LE_32(f->header.type) != FT_COMPILED_SFX))
+ Fatal_error("Sound: mission::the.cmpsfxlist, Header wrong, engine:%d,%08x file:%d,%08x\n", SFX_VERSION, FT_COMPILED_SFX, LinkedDataObject::GetHeaderVersion(f), FROM_LE_32(f->header.type));
return f;
}
-_linked_data_file *GetSessionSfxFile() {
+LinkedDataFile *GetSessionSfxFile() {
// if no session return NULL
if ((!g_mission) || (!(g_mission->session))) {
@@ -288,48 +288,48 @@ _linked_data_file *GetSessionSfxFile() {
uint32 fileHash = NULL_HASH;
uint32 clusterHash = MS->Fetch_session_cluster_hash();
- _linked_data_file *f;
+ LinkedDataFile *f;
// For the PC clustering the sfx file does not have the path, just the name
- f = (_linked_data_file *)private_session_resman->Res_open(
+ f = (LinkedDataFile *)private_session_resman->Res_open(
"s_sfxlist",
fileHash, MS->Fetch_session_cluster(), clusterHash);
- if ((f->GetHeaderVersion() != SFX_VERSION) || (f->header.type != FT_COMPILED_SFX))
- Fatal_error("Sound: session::the.cmpsfxlist, Header wrong, engine:%d,%08x file:%d,%08x\n", SFX_VERSION, FT_COMPILED_SFX, f->GetHeaderVersion(), f->header.type);
+ if ((LinkedDataObject::GetHeaderVersion(f) != SFX_VERSION) || (FROM_LE_32(f->header.type) != FT_COMPILED_SFX))
+ Fatal_error("Sound: session::the.cmpsfxlist, Header wrong, engine:%d,%08x file:%d,%08x\n", SFX_VERSION, FT_COMPILED_SFX, LinkedDataObject::GetHeaderVersion(f), FROM_LE_32(f->header.type));
return f;
}
// get a pointer to sfx (number) in the mission or session sfx file
CSfx *GetMissionSfx(int32 number) {
- _linked_data_file *linkedSfx;
+ LinkedDataFile *linkedSfx;
linkedSfx = GetMissionSfxFile();
- return (CSfx *)linkedSfx->Fetch_item_by_number(number);
+ return (CSfx *)LinkedDataObject::Fetch_item_by_number(linkedSfx, number);
}
CSfx *GetSessionSfx(int32 number) {
- _linked_data_file *linkedSfx;
+ LinkedDataFile *linkedSfx;
linkedSfx = GetSessionSfxFile();
- return (CSfx *)linkedSfx->Fetch_item_by_number(number);
+ return (CSfx *)LinkedDataObject::Fetch_item_by_number(linkedSfx, number);
}
// return a number for the sfx (in either mision or session) -1 means the sfx is not in the sound file (probabily in the other one)
int32 WhichMissionSfx(uint32 sfx) {
- _linked_data_file *linkedSfx;
+ LinkedDataFile *linkedSfx;
uint32 n;
linkedSfx = GetMissionSfxFile();
if (linkedSfx == nullptr)
return -1;
- n = linkedSfx->Fetch_item_number_by_hash(sfx);
+ n = LinkedDataObject::Fetch_item_number_by_hash(linkedSfx, sfx);
if (n == PX_LINKED_DATA_FILE_ERROR)
return -1;
@@ -338,14 +338,14 @@ int32 WhichMissionSfx(uint32 sfx) {
}
int32 WhichSessionSfx(uint32 sfx) {
- _linked_data_file *linkedSfx;
+ LinkedDataFile *linkedSfx;
uint32 n;
linkedSfx = GetSessionSfxFile();
if (linkedSfx == nullptr)
return -1;
- n = linkedSfx->Fetch_item_number_by_hash(sfx);
+ n = LinkedDataObject::Fetch_item_number_by_hash(linkedSfx, sfx);
if (n == PX_LINKED_DATA_FILE_ERROR)
return -1;
@@ -1034,7 +1034,7 @@ void RegisterSoundOffset(uint32 obj, const char *offsetName, const char *sfxName
else if (isNico) {
// is nico so get position of it...
// x=, y=, z=
- _feature_info *fi = (_feature_info *)(MS->features->Fetch_item_by_name(offsetName));
+ _feature_info *fi = (_feature_info *)(LinkedDataObject::Fetch_item_by_name(MS->features, offsetName));
x = fi->x;
y = fi->y;
z = fi->z;
@@ -1044,7 +1044,7 @@ void RegisterSoundOffset(uint32 obj, const char *offsetName, const char *sfxName
else {
// is mega object so attach sound to it
// obj=
- obj = MS->objects->Fetch_item_number_by_name(offsetName);
+ obj = LinkedDataObject::Fetch_item_number_by_name(MS->objects, offsetName);
g_registeredSounds[i]->RegisterFromObject(obj, sndID, sfxName, sfxHash, xo, yo, zo, volume_offset);
}
@@ -1059,7 +1059,7 @@ void RegisterSound(uint32 obj, const char *sfxName, uint32 sfxHash, const char *
if (obj == SPECIAL_SOUND)
name = nullptr;
else
- name = (const char *)(MS->objects->Fetch_items_name_by_number(obj));
+ name = (const char *)(LinkedDataObject::Fetch_items_name_by_number(MS->objects, obj));
RegisterSoundOffset(obj, name, sfxName, sfxHash, sndID, (PXreal)0, (PXreal)0, (PXreal)0, 0, 0, volume_offset);
}
@@ -1075,7 +1075,7 @@ void RegisterSoundTime(uint32 obj, const char *sfxName, uint32 sfxHash, const ch
if (obj == SPECIAL_SOUND)
name = nullptr;
else
- name = (const char *)(MS->objects->Fetch_items_name_by_number(obj));
+ name = (const char *)(LinkedDataObject::Fetch_items_name_by_number(MS->objects, obj));
RegisterSoundOffset(obj, name, sfxName, sfxHash, sndID, (PXreal)0, (PXreal)0, (PXreal)0, 0, time, volume_offset);
}
diff --git a/engines/icb/sound_logic.cpp b/engines/icb/sound_logic.cpp
index aa35b1c6318..4c2afbfd72e 100644
--- a/engines/icb/sound_logic.cpp
+++ b/engines/icb/sound_logic.cpp
@@ -225,7 +225,7 @@ void _sound_logic::NewSound(uint32 nObjectID, int32 nX, int32 nY, int32 nZ, cons
// Don't put up a new SFX subtitle if one is being displayed already.
if (m_nSFXSubtitleTimer == 0) {
// Here, we put up a SFX subtitle if one is listed for the sound.
- m_pcSFXSubtitleText = (const char *)global_text->Try_fetch_item_by_hash(nSoundHash);
+ m_pcSFXSubtitleText = (const char *)LinkedDataObject::Try_fetch_item_by_hash(global_text, nSoundHash);
if (m_pcSFXSubtitleText)
m_nSFXSubtitleTimer = Get_reading_time(m_pcSFXSubtitleText);
diff --git a/engines/icb/speech.cpp b/engines/icb/speech.cpp
index db017213c7f..b9d042f7709 100644
--- a/engines/icb/speech.cpp
+++ b/engines/icb/speech.cpp
@@ -139,7 +139,7 @@ mcodeFunctionReturnCodes _game_session::fn_request_speech(int32 &result, int32 *
// form name of speech script
sprintf(temp_buf, "scenes::%s", scene_script_name);
- S.script_pc = (char *)scripts->Try_fetch_item_by_name(temp_buf); // run init script
+ S.script_pc = (char *)LinkedDataObject::Try_fetch_item_by_name(scripts, temp_buf); // run init script
// conversation script doesnt exist
if (!S.script_pc)
@@ -182,7 +182,7 @@ mcodeFunctionReturnCodes _game_session::fn_add_talker(int32 &, int32 *params) {
Fatal_error("fn_add_talker called but in wrong order");
// convert the ascii name into an object id
- talk_id = objects->Fetch_item_number_by_name(object_name);
+ talk_id = LinkedDataObject::Fetch_item_number_by_name(objects, object_name);
// check for illegal object
if (talk_id >= total_objects)
@@ -452,8 +452,8 @@ void _game_session::Service_speech() {
switch (speech_info[CONV_ID].state) {
case __PROCESS: // run the script
// get the dummy speech object
- speech_object = (c_game_object *)objects->Fetch_item_by_name("scenes");
- cur_id = objects->Fetch_item_number_by_name("scenes");
+ speech_object = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, "scenes");
+ cur_id = LinkedDataObject::Fetch_item_number_by_name(objects, "scenes");
L = logic_structs[cur_id];
I = nullptr;
M = nullptr;
@@ -538,13 +538,13 @@ mcodeFunctionReturnCodes _game_session::fn_speak(int32 &, int32 *params) {
// work out position using speakers position
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(person_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, person_name);
if (speaker_id == PX_LINKED_DATA_FILE_ERROR)
Fatal_error("Unable to find object ID for [%s] in fn_speak()", person_name);
if (text) {
// retrieve text line
- ascii = (char *)text->Try_fetch_item_by_name(text_label);
+ ascii = (char *)LinkedDataObject::Try_fetch_item_by_name(text, text_label);
if (!ascii)
ascii = error;
@@ -787,10 +787,10 @@ mcodeFunctionReturnCodes _game_session::speak_object_face_object(int32 &, int32
const char *target_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(speaker_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, speaker_name);
// fetch target
- tar_id = objects->Fetch_item_number_by_name(target_name);
+ tar_id = LinkedDataObject::Fetch_item_number_by_name(objects, target_name);
// find next com slot
while ((speech_info[0].coms[com_no].active == TRUE8) && (speech_info[0].coms[com_no].id != speaker_id))
@@ -826,7 +826,7 @@ mcodeFunctionReturnCodes _game_session::speak_play_generic_anim(int32 &, int32 *
Zdebug("speak_play_generic_anim [%s] to face [%s]", person_name, anim_name);
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(person_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, person_name);
while ((speech_info[0].coms[com_no].active == TRUE8) && (speech_info[0].coms[com_no].id != speaker_id))
com_no++;
@@ -860,7 +860,7 @@ mcodeFunctionReturnCodes _game_session::speak_set_custom(int32 &, int32 *params)
const char *custom_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(person_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, person_name);
if (speaker_id == -1)
Fatal_error("speak_set_custom cant find object [%s]", person_name);
@@ -887,7 +887,7 @@ mcodeFunctionReturnCodes _game_session::speak_preload_custom_anim(int32 &, int32
#define MM logic_structs[speaker_id]->mega
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(mega_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, mega_name);
// build that name
II->Init_custom_animation(mega_name);
@@ -917,7 +917,7 @@ mcodeFunctionReturnCodes _game_session::speak_play_custom_anim(int32 &, int32 *p
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(speaker_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, speaker_name);
while ((speech_info[0].coms[com_no].active == TRUE8) && (speech_info[0].coms[com_no].id != speaker_id))
com_no++;
@@ -952,7 +952,7 @@ mcodeFunctionReturnCodes _game_session::speak_reverse_custom_anim(int32 &, int32
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[1]);
// fetch the speaker
- speaker_id = objects->Fetch_item_number_by_name(speaker_name);
+ speaker_id = LinkedDataObject::Fetch_item_number_by_name(objects, speaker_name);
while ((speech_info[0].coms[com_no].active == TRUE8) && (speech_info[0].coms[com_no].id != speaker_id))
com_no++;
diff --git a/engines/icb/stagedraw_pc_poly.cpp b/engines/icb/stagedraw_pc_poly.cpp
index bb2b9bd9e99..918c0a6bdf5 100644
--- a/engines/icb/stagedraw_pc_poly.cpp
+++ b/engines/icb/stagedraw_pc_poly.cpp
@@ -447,7 +447,7 @@ void drawObjects(SDactor &act, PSXLampList &lamplist, PSXrgb *pAmbient, PSXShade
if (g_mission->session->objects == nullptr || strcmp(act.log->GetName(), "StageView") == 0) {
uvframe = gameCycle;
} else {
- c_game_object *ob = (c_game_object *)MS->objects->Fetch_item_by_name(act.log->GetName());
+ c_game_object *ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(MS->objects, act.log->GetName());
int32 ret = ob->GetVariable("state");
diff --git a/engines/icb/tracer.cpp b/engines/icb/tracer.cpp
index dab3b67a65c..6f63545776e 100644
--- a/engines/icb/tracer.cpp
+++ b/engines/icb/tracer.cpp
@@ -219,7 +219,7 @@ void _tracer::GetBarriersForCube(const _XYZ_index &oCubeIndices, uint32 *oThisCu
uint32 *pBarrierArray;
// Get to the right slice.
- pSlice = (_barrier_slice *)m_pyLOSMemFile->Fetch_item_by_number(oCubeIndices.nY);
+ pSlice = (_barrier_slice *)LinkedDataObject::Fetch_item_by_number(m_pyLOSMemFile, oCubeIndices.nY);
// Get to the right cube entry.
nActualIndex = oCubeIndices.nZ * pSlice->row_length + oCubeIndices.nX;
diff --git a/engines/icb/tracer.h b/engines/icb/tracer.h
index 99d554d5664..330a5477100 100644
--- a/engines/icb/tracer.h
+++ b/engines/icb/tracer.h
@@ -51,13 +51,13 @@ public:
bool8 Trace(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, _barrier_ray_type eRayType, px3DRealPoint &oImpact, _barrier_logic_value eImpactType);
// Call this before using the tracer, to point it at its barriers.
- void SetBarrierPointer(_linked_data_file *pyBarriers) { m_pyBarrierMemFile = pyBarriers; }
+ void SetBarrierPointer(LinkedDataFile *pyBarriers) { m_pyBarrierMemFile = pyBarriers; }
// Call this to give the tracer access to the floor data.
void SetFloorsPointer(_floor_world *pFloorWorld) { m_pFloorWorld = pFloorWorld; }
private:
- _linked_data_file *m_pyBarrierMemFile; // The memory image of the barrier file.
+ LinkedDataFile *m_pyBarrierMemFile; // The memory image of the barrier file.
_floor_world *m_pFloorWorld; // The floors data (loaded by the routing code).
PXreal m_fXDiff, m_fYDiff, m_fZDiff; // Delta x, y and z for the line we're tracing.
PXreal m_fSqrLength; // Square length of the vector we're tracing.
@@ -90,7 +90,7 @@ inline const _route_barrier *_tracer::GetBarrier(uint32 i) const {
if (!m_pyBarrierMemFile)
Fatal_error("No barrier file in _tracer::GetBarrier()");
- pBarriers = (_route_barrier *)m_pyBarrierMemFile->Fetch_item_by_name("Data");
+ pBarriers = (_route_barrier *)LinkedDataObject::Fetch_item_by_name(m_pyBarrierMemFile, "Data");
return &(pBarriers[i]);
}
More information about the Scummvm-git-logs
mailing list