[Scummvm-git-logs] scummvm master -> 63cdc2f3eb616865bfdb584828c4597db962afcb
aquadran
noreply at scummvm.org
Sat Jul 30 19:26:18 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:
63cdc2f3eb ICB: Avoid casting CGameObject class to memory
Commit: 63cdc2f3eb616865bfdb584828c4597db962afcb
https://github.com/scummvm/scummvm/commit/63cdc2f3eb616865bfdb584828c4597db962afcb
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-07-30T21:26:14+02:00
Commit Message:
ICB: Avoid casting CGameObject class to memory
Changed paths:
engines/icb/animation.cpp
engines/icb/barriers.cpp
engines/icb/bone.cpp
engines/icb/chi.cpp
engines/icb/common/px_game_object.h
engines/icb/common/px_scriptengine.cpp
engines/icb/common/px_scriptengine.h
engines/icb/custom_logics.cpp
engines/icb/fn_animation.cpp
engines/icb/fn_interact.cpp
engines/icb/function.cpp
engines/icb/general_interaction.cpp
engines/icb/general_npc_animation.cpp
engines/icb/health_bar_pc.cpp
engines/icb/logic.cpp
engines/icb/mega_interaction.cpp
engines/icb/mission.cpp
engines/icb/options_manager_pc.cpp
engines/icb/p4.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/speech.cpp
engines/icb/stagedraw_pc_poly.cpp
diff --git a/engines/icb/animation.cpp b/engines/icb/animation.cpp
index 28cc29c7e21..73f3a4c48f2 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 *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -121,7 +121,7 @@ mcodeFunctionReturnCodes _game_session::fn_prop_animate(int32 &, int32 *params)
}
// didnt find the named anim so thats it
- Tdebug("objects_that_died.txt", "_game_session::fn_prop_animate object %s cant find anim %s", object->GetName(), anim_name);
+ Tdebug("objects_that_died.txt", "_game_session::fn_prop_animate object %s cant find anim %s", CGameObject::GetName(object), anim_name);
Shut_down_object("by fn_prop_animate");
return (IR_STOP);
}
@@ -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 *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -151,7 +151,7 @@ mcodeFunctionReturnCodes _game_session::fn_prop_set_to_last_frame(int32 &, int32
}
// didnt find the named anim so thats it
- Tdebug("objects_that_died.txt", "fn_prop_set_to_last_frame object %s cant find anim %s", object->GetName(), anim_name);
+ Tdebug("objects_that_died.txt", "fn_prop_set_to_last_frame object %s cant find anim %s", CGameObject::GetName(object), anim_name);
Shut_down_object("by fn_prop_set_to_last_frame");
return (IR_REPEAT);
@@ -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 *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -181,8 +181,8 @@ mcodeFunctionReturnCodes _game_session::fn_prop_set_to_first_frame(int32 &, int3
}
// didnt find the named anim so thats it
- Tdebug("objects_that_died.txt", "fn_prop_set_to_first_frame object %s cant find anim %s", object->GetName(), anim_name);
- Message_box("fn_prop_set_to_first_frame object %s cant find anim %s", object->GetName(), anim_name);
+ Tdebug("objects_that_died.txt", "fn_prop_set_to_first_frame object %s cant find anim %s", CGameObject::GetName(object), anim_name);
+ Message_box("fn_prop_set_to_first_frame object %s cant find anim %s", CGameObject::GetName(object), anim_name);
Shut_down_object("by fn_prop_set_to_first_frame");
return (IR_REPEAT);
}
@@ -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 *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -212,13 +212,13 @@ mcodeFunctionReturnCodes _game_session::fn_test_prop_anim(int32 &result, int32 *
return (IR_CONT);
}
- Message_box("fn_test_prop_anim object [%s] has anim [%s] but it has no frames", object->GetName(), anim_name);
+ Message_box("fn_test_prop_anim object [%s] has anim [%s] but it has no frames", CGameObject::GetName(object), anim_name);
result = 0;
return IR_CONT;
}
}
- Message_box("fn_test_prop_anim didnt find anim [%s] for object [%s]", anim_name, object->GetName());
+ Message_box("fn_test_prop_anim didnt find anim [%s] for object [%s]", anim_name, CGameObject::GetName(object));
result = 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 *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
// loop through all looking for our named anim
for (j = 0; j < index->num_anims; j++) {
@@ -247,11 +247,11 @@ uint32 _game_session::Validate_prop_anim(const char *anim_name) {
if (anim->num_frames)
return (j);
- Fatal_error("Validate_prop_anim object [%s] has anim [%s] but it has no frames", object->GetName(), anim_name);
+ Fatal_error("Validate_prop_anim object [%s] has anim [%s] but it has no frames", CGameObject::GetName(object), anim_name);
}
}
- Fatal_error("Validate_prop_anim didnt find anim [%s] for object [%s]", anim_name, object->GetName());
+ Fatal_error("Validate_prop_anim didnt find anim [%s] for object [%s]", anim_name, CGameObject::GetName(object));
return (FALSE8);
}
@@ -315,7 +315,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height_id(int32 &,
// the script
if (L->list[0] > (uint8)(anim->num_frames - 1))
- Fatal_error("%s corrupted in fn_inherit_prop_anim_height_id", object->GetName());
+ Fatal_error("%s corrupted in fn_inherit_prop_anim_height_id", CGameObject::GetName(object));
if ((uint8)L->list[0] == (anim->num_frames - 1)) {
// not looping
@@ -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(), LinkedDataObject::Fetch_items_name_by_number(objects, params[0]), anim_name);
+ Fatal_error("fn_inherit_prop_anim_height_id object [%s] prop [%s] cant find anim [%s]", CGameObject::GetName(object), LinkedDataObject::Fetch_items_name_by_number(objects, params[0]), anim_name);
return (IR_STOP);
}
@@ -369,7 +369,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height(int32 &, int
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[1]);
Zdebug("fn_inherit_prop_anim_height");
- Zdebug("ob %s", object->GetName());
+ Zdebug("ob %s", CGameObject::GetName(object));
Zdebug("prop %s anim %s", prop_name, anim_name);
// find entry for this object via its name, which we find via its number :(
@@ -436,7 +436,7 @@ mcodeFunctionReturnCodes _game_session::fn_inherit_prop_anim_height(int32 &, int
}
// didnt find the named anim so thats it
- Fatal_error("fn_inherit_prop_anim_height object [%s] prop [%s] cant find anim [%s]", object->GetName(), prop_name, anim_name);
+ Fatal_error("fn_inherit_prop_anim_height object [%s] prop [%s] cant find anim [%s]", CGameObject::GetName(object), prop_name, anim_name);
return (IR_STOP); //
}
diff --git a/engines/icb/barriers.cpp b/engines/icb/barriers.cpp
index 8e172172789..91033fbbafb 100644
--- a/engines/icb/barriers.cpp
+++ b/engines/icb/barriers.cpp
@@ -1054,7 +1054,7 @@ void _game_session::Prepare_megas_route_barriers(bool8 pl) {
Prepare_megas_abarriers(M->cur_slice, M->par_number);
if (M->number_of_barriers + M->number_of_animating > MAX_bars)
- Fatal_error("[%s] finds too many barriers - found %d + %d animating, total max %d", object->GetName(), M->number_of_barriers, M->number_of_animating, MAX_bars);
+ Fatal_error("[%s] finds too many barriers - found %d + %d animating, total max %d", CGameObject::GetName(object), M->number_of_barriers, M->number_of_animating, MAX_bars);
if (M->number_of_nudge > MAX_bars)
Fatal_error("too many player nudge barriers");
diff --git a/engines/icb/bone.cpp b/engines/icb/bone.cpp
index 003679f5a1b..8b47d5fec6a 100644
--- a/engines/icb/bone.cpp
+++ b/engines/icb/bone.cpp
@@ -93,7 +93,7 @@ void _game_session::UpdateCartridgeCase() {
M->bulletBounced++;
// this is where we make the bouncing sound...
- RegisterSound(cur_id, object->GetStringValueOrDefault(tinkleSfxVar, defaultTinkleSfx), tinkleDesc);
+ RegisterSound(cur_id, CGameObject::GetStringValueOrDefault(object, tinkleSfxVar, defaultTinkleSfx), tinkleDesc);
}
}
}
@@ -280,8 +280,8 @@ void UpdatePlayerLook() {
// target is an actor so need adjustment for eye height...
if (target->image_type == VOXEL) {
- c_game_object *pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, sel_id);
- int32 dead = pGameObject->GetIntegerVariable(pGameObject->GetVariable("state"));
+ CGame *pGameObject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, sel_id);
+ int32 dead = CGameObject::GetIntegerVariable(pGameObject, CGameObject::GetVariable(pGameObject, "state"));
if (target->object_type == __NON_ORGANIC_MEGA) { // robot (look down)
oy += ROBOT_EYE;
diff --git a/engines/icb/chi.cpp b/engines/icb/chi.cpp
index 568f2620057..2bac313f74c 100644
--- a/engines/icb/chi.cpp
+++ b/engines/icb/chi.cpp
@@ -139,7 +139,7 @@ mcodeFunctionReturnCodes _game_session::fn_send_chi_to_named_object(int32 &, int
history[cur_history].interaction = TRUE8;
history[cur_history].id = id;
- Tdebug("history.txt", ">> [%s] %d", object->GetName(), cur_id);
+ Tdebug("history.txt", ">> [%s] %d", CGameObject::GetName(object), cur_id);
return IR_CONT;
}
@@ -830,7 +830,7 @@ mcodeFunctionReturnCodes _game_session::fn_register_chi(int32 &, int32 *) {
if (is_there_a_chi)
Fatal_error("double call to fn_register_chi");
- Tdebug("chi.txt", "%s registers as chi", object->GetName());
+ Tdebug("chi.txt", "%s registers as chi", CGameObject::GetName(object));
is_there_a_chi = TRUE8;
chi_id = cur_id;
diff --git a/engines/icb/common/px_game_object.h b/engines/icb/common/px_game_object.h
index 1b88d8b54c9..965e5b17baf 100644
--- a/engines/icb/common/px_game_object.h
+++ b/engines/icb/common/px_game_object.h
@@ -41,151 +41,34 @@ enum _object_status { // possible values of object status field
#define OB_LOGIC_CONTEXT 1
#define OB_ACTION_CONTEXT 2
-#define c_game_object c_compressed_game_object
-
-class c_un_game_object {
- // Only ob_status is made public. To access the other elements use
- // the access functions. This is so that further changes to the structure
- // can be catered for through the access functions, and not needed where
- // any element is specifically referenced
-
-public:
- // Main access functions
- const char *GetName() const; // Get a pointer to the object name
- uint32 GetNoLvars() const; // Get the number of local variables
- uint32 GetNoScripts() const; // Get the number of scripts
- const char *GetScriptName(uint32) const; // Get the name of a script
- uint32 GetSize() { return (m_size); }
- uint32 GetLvarInfoOffset() { return (m_var_table_offset); }
-
- const char *GetScriptVariableName(uint32) const; // gets name
- int32 GetVariable(const char *name) const; // get's number of named variable
-
- int32 IsVariableString(uint32) const; // is variable a string (1=string, 0=int)
-
- void SetIntegerVariable(uint32, int32); // Sets the value of an integer variable
-
- int32 &GetIntegerVariable(uint32); // Get the value of an integer variable
- const char *GetStringVariable(uint32) const; // Get the value of a string variable
-
- const char *GetStringValueOrDefault(const char *varName, const char *defaultStr) {
- int32 var;
- var = GetVariable(varName);
- if (var == -1)
- return defaultStr;
- else
- return GetStringVariable(var);
- }
-
- int32 GetIntegerValueOrDefault(const char *varName, int32 defaultInt) {
- int32 var;
- var = GetVariable(varName);
- if (var == -1)
- return defaultInt;
- else
- return GetIntegerVariable(var);
- }
-
- // Let the new compressed object have full access to this one
- friend class c_compressed_game_objectCreator;
-
-protected: // The object data
+typedef struct {
uint32 m_size; // The size of the total data structure
uint32 m_var_table_offset;
-public:
uint32 ob_status; // low level internal stuff - see enum _object_status
-protected: // The rest of the data
// The offsets to the blocks of data. All offsets
// are from the start of the object
- uint32 m_script_name_table_offset; // Offset to the script name table
- uint32 m_lvars_offset; // Offset to the local variable data
- uint32 m_name_offset; // Offset to the object name
+
+ uint32 m_script_name_hash_table_offset; // Offset to the script name table
+
+ uint32 m_lvars_offset; // Offset to the local variable data
+ uint32 m_name_offset; // Offset to the object name
// Variable and script count
uint32 m_noLvars; // How many lvars this object has
uint32 m_noScripts; // The number of scripts associated with this object
-};
-
-inline const char *c_un_game_object::GetName() const {
- // Get a pointer to the object name
- return ((const char *)(((const char *) this) + m_name_offset));
-}
-
-inline uint32 c_un_game_object::GetNoLvars() const {
- // Get the number of local variables
- return (m_noLvars);
-}
-
-inline uint32 c_un_game_object::GetNoScripts() const {
- // Get the number of scripts
- return (m_noScripts);
-}
-
-inline const char *c_un_game_object::GetScriptName(uint32 scriptNo) const {
- assert(scriptNo < m_noScripts);
- return ((const char *)(((const char *) this) + ((const int32 *)(((const char *)this) + m_script_name_table_offset))[scriptNo]));
-}
-
-inline const char *c_un_game_object::GetScriptVariableName(uint32 varNo) const {
- const char *currentPos;
- const uint32 *table;
-
- currentPos = (((const char *) this) + m_var_table_offset);
- table = (const uint32 *)currentPos;
- return currentPos + table[varNo * 2];
-}
-
-inline int32 c_un_game_object::IsVariableString(uint32 varNo) const {
- const char *currentPos;
- const uint32 *table;
-
- currentPos = (((const char *) this) + m_var_table_offset);
- table = (const uint32 *)currentPos;
- return table[varNo * 2 + 1];
-}
-
-inline int32 c_un_game_object::GetVariable(const char *name) const {
- const char *currentPos;
- const uint32 *table;
- int32 retValue;
- int32 whichVar;
-
- currentPos = (((const char *) this) + m_var_table_offset);
- table = (const uint32 *)currentPos;
- retValue = -1;
-
- for (whichVar = 0; whichVar < (int32)m_noLvars; whichVar++) {
- if (strcmp(name, currentPos + table[whichVar * 2]) == 0) {
- retValue = whichVar;
- whichVar = (int32)m_noLvars;
- }
- }
-
- return retValue;
-}
-
-inline void c_un_game_object::SetIntegerVariable(uint32 lvar, int32 val) {
- assert(lvar < m_noLvars);
- (((int32 *)(((char *)this) + m_lvars_offset))[lvar]) = val;
-}
-
-inline int32 &c_un_game_object::GetIntegerVariable(uint32 lvar) {
- // Get an lvar value
- assert(lvar < m_noLvars);
- return (((int32 *)(((char *)this) + m_lvars_offset))[lvar]);
-}
+ /* This data is then followed by:
-inline const char *c_un_game_object::GetStringVariable(uint32 lvar) const {
- // Get an lvar value
- assert(lvar < m_noLvars);
- return (((const char *) this) + ((const int32 *)(((const char *)this) + m_lvars_offset))[lvar]);
-}
+ Null terminated object name
+ Object variable information block
+ Script names information block
+ */
+} CGame;
-class c_compressed_game_object {
+class CGameObject {
// Only ob_status is made public. To access the other elements use
// the access functions. This is so that further changes to the structure
// can be catered for through the access functions, and not needed where
@@ -193,208 +76,134 @@ class c_compressed_game_object {
public:
// Main access functions
- const char *GetName() const; // Get a pointer to the object name
- uint32 GetNoLvars() const; // Get the number of local variables
- uint32 GetNoScripts() const; // Get the number of scripts
- uint32 GetSize() { return (m_size); }
+ static const char *GetName(CGame *game); // Get a pointer to the object name
+ static uint32 GetNoLvars(CGame *game) ; // Get the number of local variables
+ static uint32 GetNoScripts(CGame *game); // Get the number of scripts
+ static uint32 GetSize(CGame *game) { return FROM_LE_32(game->m_size); }
// Using the hash system you cannot get names, only hashes
- uint32 GetScriptNameFullHash(uint32) const;
- uint32 GetScriptNamePartHash(uint32) const;
+ static uint32 GetScriptNameFullHash(CGame *game, uint32);
+ static uint32 GetScriptNamePartHash(CGame *game, uint32);
- const char *GetScriptVariableName(uint32) const; // gets name
- int32 GetVariable(const char *name) const; // get's number of named variable
+ static const char *GetScriptVariableName(CGame *game, uint32); // gets name
+ static int32 GetVariable(CGame *game, const char *name); // get's number of named variable
- int32 IsVariableString(uint32) const; // is variable a string (1=string, 0=int)
+ static int32 IsVariableString(CGame *game, uint32); // is variable a string (1=string, 0=int)
- void SetIntegerVariable(uint32, int32); // Sets the value of an integer variable
+ static void SetIntegerVariable(CGame *game, uint32, int32); // Sets the value of an integer variable
- int32 &GetIntegerVariable(uint32); // Get the value of an integer variable
- const char *GetStringVariable(uint32) const; // Get the value of a string variable
+ static int32 GetIntegerVariable(CGame *game, uint32); // Get the value of an integer variable
+ static int32 *GetIntegerVariablePtr(CGame *game, uint32); // Get the value of an integer variable
+ static const char *GetStringVariable(CGame *game, uint32); // Get the value of a string variable
- const char *GetStringValueOrDefault(const char *varName, const char *defaultStr) {
+ static const char *GetStringValueOrDefault(CGame *game, const char *varName, const char *defaultStr) {
int32 var;
- var = GetVariable(varName);
+ var = GetVariable(game, varName);
if (var == -1)
return defaultStr;
else
- return GetStringVariable(var);
+ return GetStringVariable(game, var);
}
- int32 GetIntegerValueOrDefault(const char *varName, int32 defaultInt) {
+ static int32 GetIntegerValueOrDefault(CGame *game, const char *varName, int32 defaultInt) {
int32 var;
- var = GetVariable(varName);
+ var = GetVariable(game, varName);
if (var == -1)
return defaultInt;
else
- return GetIntegerVariable(var);
+ return GetIntegerVariable(game, var);
}
-
- friend class c_compressed_game_objectCreator;
-
-protected: // The object data
- uint32 m_size; // The size of the total data structure
-
- uint32 m_var_table_offset;
-
-public:
- uint32 ob_status; // low level internal stuff - see enum _object_status
-
-protected: // The rest of the data
- // The offsets to the blocks of data. All offsets
- // are from the start of the object
-
- uint32 m_script_name_hash_table_offset; // Offset to the script name table
-
- uint32 m_lvars_offset; // Offset to the local variable data
- uint32 m_name_offset; // Offset to the object name
-
- // Variable and script count
- uint32 m_noLvars; // How many lvars this object has
- uint32 m_noScripts; // The number of scripts associated with this object
-
- /* This data is then followed by:
-
- Null terminated object name
- Object variable information block
- Script names information block
- */
};
-inline const char *c_compressed_game_object::GetName() const {
+inline const char *CGameObject::GetName(CGame *game) {
// Get a pointer to the object name
- return ((const char *)(((const char *) this) + m_name_offset));
+ return ((const char *)(((const char *)game) + game->m_name_offset));
}
-inline uint32 c_compressed_game_object::GetNoLvars() const {
+inline uint32 CGameObject::GetNoLvars(CGame *game) {
// Get the number of local variables
- return (m_noLvars);
+ return FROM_LE_32(game->m_noLvars);
}
-inline uint32 c_compressed_game_object::GetNoScripts() const {
+inline uint32 CGameObject::GetNoScripts(CGame *game) {
// Get the number of scripts
- return (m_noScripts);
+ return FROM_LE_32(game->m_noScripts);
}
-inline uint32 c_compressed_game_object::GetScriptNameFullHash(uint32 scriptNo) const {
- assert(scriptNo < m_noScripts);
- return (((const int32 *)(((const char *)this) + m_script_name_hash_table_offset))[scriptNo * 2]);
+inline uint32 CGameObject::GetScriptNameFullHash(CGame *game, uint32 scriptNo) {
+ assert(scriptNo < FROM_LE_32(game->m_noScripts));
+ return FROM_LE_32(((const int32 *)(((const char *)game) + FROM_LE_32(game->m_script_name_hash_table_offset)))[scriptNo * 2]);
}
-inline uint32 c_compressed_game_object::GetScriptNamePartHash(uint32 scriptNo) const {
- assert(scriptNo < m_noScripts);
- return (((const int32 *)(((const char *)this) + m_script_name_hash_table_offset))[scriptNo * 2 + 1]);
+inline uint32 CGameObject::GetScriptNamePartHash(CGame *game, uint32 scriptNo) {
+ assert(scriptNo < FROM_LE_32(game->m_noScripts));
+ return FROM_LE_32(((const int32 *)(((const char *)game) + FROM_LE_32(game->m_script_name_hash_table_offset)))[scriptNo * 2 + 1]);
}
-inline const char *c_compressed_game_object::GetScriptVariableName(uint32 varNo) const {
+inline const char *CGameObject::GetScriptVariableName(CGame *game, uint32 varNo) {
const char *currentPos;
const uint32 *table;
- currentPos = (((const char *) this) + m_var_table_offset);
+ currentPos = (((const char *)game) + FROM_LE_32(game->m_var_table_offset));
table = (const uint32 *)currentPos;
- return ((const char *)this) + table[varNo * 2];
+ return ((const char *)game) + FROM_LE_32(table[varNo * 2]);
}
-inline int32 c_compressed_game_object::IsVariableString(uint32 varNo) const {
+inline int32 CGameObject::IsVariableString(CGame *game, uint32 varNo) {
const char *currentPos;
const uint32 *table;
- currentPos = (((const char *) this) + m_var_table_offset);
+ currentPos = (((const char *)game) + FROM_LE_32(game->m_var_table_offset));
table = (const uint32 *)currentPos;
- return table[varNo * 2 + 1];
+ return FROM_LE_32(table[varNo * 2 + 1]);
}
-inline int32 c_compressed_game_object::GetVariable(const char *name) const {
+inline int32 CGameObject::GetVariable(CGame *game, const char *name) {
const char *currentPos;
const uint32 *table;
int32 retValue;
uint32 whichVar;
- currentPos = (((const char *) this) + m_var_table_offset);
+ currentPos = (((const char *)game) + FROM_LE_32(game->m_var_table_offset));
table = (const uint32 *)currentPos;
retValue = -1;
- for (whichVar = 0; whichVar < m_noLvars; whichVar++) {
- if (strcmp(name, ((const char *) this) + table[whichVar * 2]) == 0) {
+ for (whichVar = 0; whichVar < FROM_LE_32(game->m_noLvars); whichVar++) {
+ if (strcmp(name, ((const char *)game) + FROM_LE_32(table[whichVar * 2])) == 0) {
retValue = whichVar;
- whichVar = (int32)m_noLvars;
+ whichVar = (int32)FROM_LE_32(game->m_noLvars);
}
}
return retValue;
}
-inline void c_compressed_game_object::SetIntegerVariable(uint32 lvar, int32 val) {
- assert(lvar < m_noLvars);
- (((int32 *)(((char *)this) + m_lvars_offset))[lvar]) = val;
+inline void CGameObject::SetIntegerVariable(CGame *game, uint32 lvar, int32 val) {
+ assert(lvar < FROM_LE_32(game->m_noLvars));
+ uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
+ WRITE_LE_UINT32(lvars + lvar, (uint32)val);
}
-inline int32 &c_compressed_game_object::GetIntegerVariable(uint32 lvar) {
+inline int32 CGameObject::GetIntegerVariable(CGame *game, uint32 lvar) {
// Get an lvar value
- assert(lvar < m_noLvars);
- return (((int32 *)(((char *)this) + m_lvars_offset))[lvar]);
+ assert(lvar < FROM_LE_32(game->m_noLvars));
+ uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
+ return (int32)READ_LE_UINT32(lvars + lvar);
}
-inline const char *c_compressed_game_object::GetStringVariable(uint32 lvar) const {
+inline int32 *CGameObject::GetIntegerVariablePtr(CGame *game, uint32 lvar) {
// Get an lvar value
- assert(lvar < m_noLvars);
- return (((const char *) this) + ((const int32 *)(((const char *)this) + m_lvars_offset))[lvar]);
-}
-
-class CSettableGameObject : public c_un_game_object {
-public:
- // Setfunctions
- void SetSize(uint32); // Set the object size
- void SetVarTable(uint32); // set var table offset
- void Set_ob_status(uint32); // Set ob_status
- void SetScriptNameTableOffset(uint32); // Set the name table offset
- void SetLvarDataOffsetTable(uint32); // Set the lvars offset
-
- void SetNoLvars(uint32); // Set the number of variables
- void SetNoScripts(uint32); // Set the number of scripts
- void SetNameOffset(uint32); // Set the name offset
-};
-
-inline void CSettableGameObject::SetSize(uint32 size) {
- // Set the object size
- m_size = size;
- m_var_table_offset = 0xdeadbeef;
+ assert(lvar < FROM_LE_32(game->m_noLvars));
+ uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
+ return (int32 *)(lvars + lvar);
}
-inline void CSettableGameObject::SetVarTable(uint32 o) {
- // Set the object size
- m_var_table_offset = o;
-}
-
-inline void CSettableGameObject::Set_ob_status(uint32 status) {
- // Set ob_status
- ob_status = status;
-}
-
-inline void CSettableGameObject::SetNoLvars(uint32 n) {
- // Get the number of local variables
- m_noLvars = n;
-}
-
-inline void CSettableGameObject::SetNoScripts(uint32 n) {
- // Get the number of scripts
- m_noScripts = n;
-}
-
-inline void CSettableGameObject::SetScriptNameTableOffset(uint32 o) {
- // Set the name table offset
- m_script_name_table_offset = o;
-}
-
-inline void CSettableGameObject::SetLvarDataOffsetTable(uint32 o) {
- // Set the lvars offset
- m_lvars_offset = o;
-}
-
-inline void CSettableGameObject::SetNameOffset(uint32 o) {
- // Set the name offset
- m_name_offset = o;
+inline const char *CGameObject::GetStringVariable(CGame *game, uint32 lvar) {
+ // Get an lvar value
+ assert(lvar < FROM_LE_32(game->m_noLvars));
+ uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
+ return (const char *)game + (int32)READ_LE_UINT32(lvars + lvar);
}
} // End of namespace ICB
diff --git a/engines/icb/common/px_scriptengine.cpp b/engines/icb/common/px_scriptengine.cpp
index ec099be7654..49dbc3f7f6c 100644
--- a/engines/icb/common/px_scriptengine.cpp
+++ b/engines/icb/common/px_scriptengine.cpp
@@ -43,7 +43,7 @@ CpxGlobalScriptVariables *g_globalScriptVariables;
int32 stack[STACK_SIZE]; // The current stack
int32 stackPointer = 0; // Position within stack
-#define _SCRIPT_ENGINE_ERROR(mess) Fatal_error("Script engine error\nObject %s\nScript %s\nMessage %s", object->GetName(), scriptSourceName, mess)
+#define _SCRIPT_ENGINE_ERROR(mess) Fatal_error("Script engine error\nObject %s\nScript %s\nMessage %s", CGameObject::GetName(object), scriptSourceName, mess)
// Check the stack pointer is within bounds
#define CheckStackPointer \
@@ -116,7 +116,7 @@ extern mcodeFunctionReturnCodes fn_context_chosen_logic(int32 &, int32 *);
extern mcodeFunctionReturnCodes fn_start_player_interaction(int32 &, int32 *);
scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to the script data that can be modified
- c_game_object *object, // A pointer to the object that owns this object
+ CGame *object, // A pointer to the object that owns this object
int32 *engineReturnValue2,
const char *scriptSourceName) { // A value to return to the game engine
// Run a script
@@ -144,7 +144,7 @@ scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to
infiniteLoopCounter++;
if (infiniteLoopCounter > 10000) {
// Oh dear, what do we do now.
- Fatal_error("Internal script loop in object %s", object->GetName());
+ Fatal_error("Internal script loop in object %s", CGameObject::GetName(object));
}
int32 command = *(actualScript++);
@@ -176,10 +176,10 @@ scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to
case CP_PUSH_ADDRESS_LOCAL_VAR32: {
Fetch8(value); // Get the local variable number
- if (!((value >= 0) && (value < (int32)object->GetNoLvars())))
+ if (!((value >= 0) && (value < (int32)CGameObject::GetNoLvars(object))))
_SCRIPT_ENGINE_ERROR("Local variable out of range");
- ScriptTrace("Push address of local integer variable %d = %d", value, &object->GetIntegerVariable(value));
- PushOnStack(MemoryUtil::encodePtr((uint8 *)&object->GetIntegerVariable(value)));
+ ScriptTrace("Push address of local integer variable %d = %d", value, CGameObject::GetIntegerVariable(object, value));
+ PushOnStack(MemoryUtil::encodePtr((uint8 *)CGameObject::GetIntegerVariablePtr(object, value)));
} break;
case CP_SKIPONFALSE: { // 4 : Skip a chunk if a result if false
@@ -324,20 +324,20 @@ scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to
// Get the script index
Fetch32(parameter1);
- if (!((parameter1 >= 0) && (parameter1 < (int32)object->GetNoScripts())))
+ if (!((parameter1 >= 0) && (parameter1 < (int32)CGameObject::GetNoScripts(object))))
_SCRIPT_ENGINE_ERROR("Virtual script call out of range");
// Get the type
Fetch8(parameter2);
- ScriptTrace("if (%d) call virtual script %d (%d)", value, parameter1, object->GetScriptNameFullHash(parameter1));
+ ScriptTrace("if (%d) call virtual script %d (%d)", value, parameter1, CGameObject::GetScriptNameFullHash(object, parameter1));
if (value) {
parameter1 &= 0xffff;
int32 dummyReturnValue;
ScriptTrace("param2 = %d", parameter2);
- int32 scriptHash = object->GetScriptNameFullHash(parameter1);
+ int32 scriptHash = CGameObject::GetScriptNameFullHash(object, parameter1);
if (parameter2) {
ScriptTrace("interact");
fn_start_player_interaction(dummyReturnValue, &scriptHash);
@@ -360,31 +360,35 @@ scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to
case CP_PUSH_LOCAL_VAR32: // 16: Push a local variable on to the stack
Fetch8(value); // Get the local variable number
- if (!((value >= 0) && (value < (int32)object->GetNoLvars())))
+ if (!((value >= 0) && (value < (int32)CGameObject::GetNoLvars(object))))
_SCRIPT_ENGINE_ERROR("Unknown variable??");
- ScriptTrace("Push local integer variable %d = %d", value, object->GetIntegerVariable(value));
- PushOnStack(object->GetIntegerVariable(value));
+ ScriptTrace("Push local integer variable %d = %d", value, CGameObject::GetIntegerVariable(object, value));
+ PushOnStack(CGameObject::GetIntegerVariable(object, value));
break;
case CP_POP_LOCAL_VAR32: // 17 // Pop a local variable from the stack
Fetch8(value); // Get the local variable number
- if (!(value >= 0) && (value < (int32)object->GetNoLvars()))
+ if (!(value >= 0) && (value < (int32)CGameObject::GetNoLvars(object)))
_SCRIPT_ENGINE_ERROR("Unknown variable??");
ScriptTrace("Pop local variable %d", value);
- PopOffStack(object->GetIntegerVariable(value));
+ {
+ int32 varValue;
+ PopOffStack(varValue);
+ CGameObject::SetIntegerVariable(object, value, varValue);
+ }
break;
case CP_PUSH_LOCAL_VARSTRING: // 18: Push a local string variable on to the stack
Fetch8(value); // Get the local variable number
- if (!((value >= 0) && (value < (int32)object->GetNoLvars())))
+ if (!((value >= 0) && (value < (int32)CGameObject::GetNoLvars(object))))
_SCRIPT_ENGINE_ERROR("Unknown variable (string)??");
- ScriptTrace("Push local string variable %d = \"%s\"", value, object->GetStringVariable(value));
- PushOnStack(MemoryUtil::encodePtr((uint8 *)const_cast<char *>(object->GetStringVariable(value))));
+ ScriptTrace("Push local string variable %d = \"%s\"", value, CGameObject::GetStringVariable(object, value));
+ PushOnStack(MemoryUtil::encodePtr((uint8 *)const_cast<char *>(CGameObject::GetStringVariable(object, value))));
break;
case CP_DEBUG: { // 19: Debug options
diff --git a/engines/icb/common/px_scriptengine.h b/engines/icb/common/px_scriptengine.h
index d854117b2b3..5e887894500 100644
--- a/engines/icb/common/px_scriptengine.h
+++ b/engines/icb/common/px_scriptengine.h
@@ -43,7 +43,7 @@ enum scriptInterpreterReturnCodes {
};
scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to the script data that can be modified
- c_game_object *object, // A pointer to the object that owns this object
+ CGame *object, // A pointer to the object that owns this object
int32 *engineReturnValue = NULL,
const char *scriptSourceName = NULL); // A value to return to the game engine
diff --git a/engines/icb/custom_logics.cpp b/engines/icb/custom_logics.cpp
index 1b8d7f617cc..a5c96eb2f35 100644
--- a/engines/icb/custom_logics.cpp
+++ b/engines/icb/custom_logics.cpp
@@ -56,14 +56,14 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_simple_animator(int32 &, i
_animation_entry *anim;
// find entry for this object via its name
- index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
// get anim
anim = (_animation_entry *)(((char *)index) + index->anims[0]);
// check for no frame
if (!anim->num_frames) {
- Tdebug("objects_that_died.txt", "fn_set_custom_simple_animator [%s] loop anim has 0 frames", object->GetName());
+ Tdebug("objects_that_died.txt", "fn_set_custom_simple_animator [%s] loop anim has 0 frames", CGameObject::GetName(object));
Shut_down_object("by fn_set_custom_simple_animator");
return (IR_STOP);
}
@@ -73,12 +73,12 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_simple_animator(int32 &, i
L->big_mode = __CUSTOM_SIMPLE_ANIMATE;
- SA_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
+ SA_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, CGameObject::GetName(object));
// object will pause when off screen
L->hold_mode = prop_camera_hold;
- Tdebug("logic_modes.txt", "fn_set_custom_simple_animator switching [%s]", object->GetName());
+ Tdebug("logic_modes.txt", "fn_set_custom_simple_animator switching [%s]", CGameObject::GetName(object));
return (IR_CONT);
}
@@ -117,12 +117,12 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_button_operated_door(int32
// switch out of script mode
L->big_mode = __CUSTOM_BUTTON_OPERATED_DOOR;
- BOD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
+ BOD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, CGameObject::GetName(object));
BOD_OPEN_NO = Validate_prop_anim("opening");
BOD_CLOSE_NO = Validate_prop_anim("closing");
- Tdebug("logic_modes.txt", "fn_set_custom_button_operated_door switching [%s]", object->GetName());
+ Tdebug("logic_modes.txt", "fn_set_custom_button_operated_door switching [%s]", CGameObject::GetName(object));
// Set a symbol type so the Remora knows what to draw.
L->object_type = __BUTTON_OPERATED_DOOR;
@@ -160,8 +160,8 @@ void _game_session::Custom_button_operated_door() {
BOD_STATE = 1; // closed
// set state flag to 1
- var_num = object->GetVariable("state");
- object->SetIntegerVariable(var_num, 1);
+ var_num = CGameObject::GetVariable(object, "state");
+ CGameObject::SetIntegerVariable(object, var_num, 1);
} else {
BOD_WAIT_COUNT--;
return;
@@ -179,15 +179,15 @@ void _game_session::Custom_button_operated_door() {
BOD_WAIT_COUNT = 36;
BOD_STATE = 0; // open
// set state flag to 0
- var_num = object->GetVariable("state");
- object->SetIntegerVariable(var_num, 0);
+ var_num = CGameObject::GetVariable(object, "state");
+ CGameObject::SetIntegerVariable(object, var_num, 0);
} else
L->anim_pc++; // frame on
return;
} else if (BOD_CONTROL == BOD_CLOSING) {
// get index for object
- index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName());
+ index = (_animating_prop *)LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object));
anim = (_animation_entry *)(((char *)index) + index->anims[BOD_CLOSE_NO]);
// set frame
@@ -206,9 +206,9 @@ void _game_session::Custom_button_operated_door() {
if (!BOD_STATE) { // open
// ok, check to see if opened
// get state variable number
- var_num = object->GetVariable("state");
+ var_num = CGameObject::GetVariable(object, "state");
// get value
- if (!object->GetIntegerVariable(var_num)) {
+ if (!CGameObject::GetIntegerVariable(object, var_num)) {
BOD_CONTROL = BOD_WAITING; // just opened - set to wait for list of people to not be here
BOD_WAIT_COUNT = 36;
return; // zero so still open
@@ -249,10 +249,10 @@ void _game_session::Custom_button_operated_door() {
}
}
// get state variable number
- var_num = object->GetVariable("state");
+ var_num = CGameObject::GetVariable(object, "state");
// get value
- if (!object->GetIntegerVariable(var_num)) {
+ if (!CGameObject::GetIntegerVariable(object, var_num)) {
open = TRUE8; // now 0 so start opening
}
if (open) {
@@ -292,11 +292,11 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom_auto_door(int32 &, int32 *
L->big_mode = __CUSTOM_AUTO_DOOR;
// anim presets
- CAD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, object->GetName());
+ CAD_INDEX = LinkedDataObject::Fetch_item_number_by_name(prop_anims, CGameObject::GetName(object));
CAD_OPEN_NO = Validate_prop_anim("opening");
CAD_CLOSE_NO = Validate_prop_anim("closing");
- Tdebug("logic_modes.txt", "fn_set_custom_auto_door switching [%s]", object->GetName());
+ Tdebug("logic_modes.txt", "fn_set_custom_auto_door switching [%s]", CGameObject::GetName(object));
// Set a symbol type so the Remora knows what to draw.
L->object_type = __AUTO_DOOR;
diff --git a/engines/icb/fn_animation.cpp b/engines/icb/fn_animation.cpp
index 87e33e45810..81eaa626e9b 100644
--- a/engines/icb/fn_animation.cpp
+++ b/engines/icb/fn_animation.cpp
@@ -228,7 +228,7 @@ mcodeFunctionReturnCodes _game_session::fn_face_nicos_pan(int32 &, int32 *params
// setup
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);
+ Fatal_error("no NICO marker (fn_face_nico) ob %s, nico %s", CGameObject::GetName(object), nico_name);
new_pan = start_pos->direction;
@@ -870,7 +870,7 @@ mcodeFunctionReturnCodes _game_session::fn_easy_play_custom_anim_with_pan(int32
const char *anim_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("fn_easy_play_custom_anim_with_pan %s %s", object->GetName(), anim_name);
+ Zdebug("fn_easy_play_custom_anim_with_pan %s %s", CGameObject::GetName(object), anim_name);
if (!L->looping) {
// set anim up
@@ -1320,7 +1320,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_apply_bullet(int32 &, int32 *para
// 0 - nothing on screen
// 1 - normal light/muzzleflash/cartridge case
// default is 1
- int32 shotType = object->GetIntegerValueOrDefault("gun_effects", 1);
+ int32 shotType = CGameObject::GetIntegerValueOrDefault(object, "gun_effects", 1);
// if mega then do dynamic light (only if shotType isnt 0
if ((logic_structs[cur_id]->image_type == VOXEL) && (shotType == 1)) {
@@ -1368,9 +1368,9 @@ 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 *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
- int32 ret = ob->GetVariable("hits");
- uint32 hits = ob->GetIntegerVariable(ret);
+ CGame *ob = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
+ int32 ret = CGameObject::GetVariable(ob, "hits");
+ uint32 hits = CGameObject::GetIntegerVariable(ob, ret);
PXreal subp1, subp2;
if (L->image_type == PROP) { // we are prop
@@ -1395,7 +1395,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_apply_bullet(int32 &, int32 *para
} else if (hits)
hits--;
- ob->SetIntegerVariable(ret, hits);
+ CGameObject::SetIntegerVariable(ob, ret, hits);
}
MS->Call_socket(tid, "gun_shot", &retval); // the hit takes
@@ -1425,27 +1425,27 @@ mcodeFunctionReturnCodes _game_session::fn_new_apply_bullet(int32 &, int32 *para
if (M->is_evil) {
// take chi and player out of the equation
- int32 ret = object->GetVariable("cur_bullets");
+ int32 ret = CGameObject::GetVariable(object, "cur_bullets");
if (ret != -1) {
- int32 result = object->GetIntegerVariable(ret);
+ int32 result = CGameObject::GetIntegerVariable(object, ret);
if (!result) { // no bullets
- int32 clipret = object->GetVariable("number_of_clips");
- int32 no_clips = object->GetIntegerVariable(clipret);
+ int32 clipret = CGameObject::GetVariable(object, "number_of_clips");
+ int32 no_clips = CGameObject::GetIntegerVariable(object, clipret);
if (no_clips == -1)
Fatal_error("object has no 'number_of_clips' variable");
if (no_clips) { // has clips left
no_clips--; // 1 less
- object->SetIntegerVariable(clipret, no_clips);
+ CGameObject::SetIntegerVariable(object, clipret, no_clips);
int32 bull_per_clip = MS->player.GetBulletsPerClip();
- object->SetIntegerVariable(ret, bull_per_clip); // reload the gun
+ CGameObject::SetIntegerVariable(object, ret, bull_per_clip); // reload the gun
}
} else { // has bullets, fire one
result--;
- object->SetIntegerVariable(ret, result); // reload
+ CGameObject::SetIntegerVariable(object, ret, result); // reload
}
}
}
@@ -1489,7 +1489,7 @@ mcodeFunctionReturnCodes _game_session::fn_apply_anim_y(int32 &, int32 *params)
}
}
- Fatal_error("fn_apply_anim_y [%s] cant find generic anim [%s]", object->GetName(), anim_name);
+ Fatal_error("fn_apply_anim_y [%s] cant find generic anim [%s]", CGameObject::GetName(object), anim_name);
return IR_CONT;
}
@@ -1500,11 +1500,11 @@ mcodeFunctionReturnCodes _game_session::fn_add_y(int32 &, int32 *params) {
// params 0 value
if (L->image_type == PROP)
- Fatal_error("fn_add_y cant be used on a prop - %s", object->GetName());
+ Fatal_error("fn_add_y cant be used on a prop - %s", CGameObject::GetName(object));
M->actor_xyz.y += params[0];
- Tdebug("fn_add_y.txt", "%s +%d to %3.1f", object->GetName(), params[0], M->actor_xyz.y);
+ Tdebug("fn_add_y.txt", "%s +%d to %3.1f", CGameObject::GetName(object), params[0], M->actor_xyz.y);
return IR_CONT;
}
diff --git a/engines/icb/fn_interact.cpp b/engines/icb/fn_interact.cpp
index 94e68a2ddf0..524d4dfde22 100644
--- a/engines/icb/fn_interact.cpp
+++ b/engines/icb/fn_interact.cpp
@@ -281,7 +281,7 @@ mcodeFunctionReturnCodes _game_session::Core_prop_interact(int32 & /*result*/, i
Fatal_error("Core_prop_interact cant indentify animation %s", anim_name);
if (!I->IsAnimTable(anim))
- Fatal_error("Core_prop_interact finds [%s] doesnt have a [%s] animation", object->GetName(), params[0]);
+ Fatal_error("Core_prop_interact finds [%s] doesnt have a [%s] animation", CGameObject::GetName(object), params[0]);
} else {
Zdebug("calc *custom* target anim [%s]", anim_name);
I->Init_custom_animation(anim_name);
@@ -538,13 +538,13 @@ mcodeFunctionReturnCodes _game_session::fn_unregister_for_auto_interaction(int32
for (j = 0; j < MAX_auto_interact; j++) {
if (auto_interact_list[j] == (uint8)(cur_id + 1)) {
- Tdebug("auto_interact.txt", "- [%s] %d", object->GetName(), j);
+ Tdebug("auto_interact.txt", "- [%s] %d", CGameObject::GetName(object), j);
auto_interact_list[j] = 0; // slot not empty
return IR_CONT;
}
}
- Fatal_error("fn_unregister_for_auto_interaction cant unregister non registered object [%s]", object->GetName());
+ Fatal_error("fn_unregister_for_auto_interaction cant unregister non registered object [%s]", CGameObject::GetName(object));
return IR_CONT;
}
@@ -556,16 +556,16 @@ mcodeFunctionReturnCodes _game_session::fn_register_for_auto_interaction(int32 &
for (j = 0; j < MAX_auto_interact; j++) {
if (auto_interact_list[j] == (uint8)(cur_id + 1))
- Fatal_error("fn_register_for_auto_interaction finds double registration of %s", object->GetName());
+ Fatal_error("fn_register_for_auto_interaction finds double registration of %s", CGameObject::GetName(object));
if (!auto_interact_list[j]) { // empty slot
auto_interact_list[j] = (uint8)(cur_id + 1);
- Tdebug("auto_interact.txt", "+ [%s] %d", object->GetName(), j);
+ Tdebug("auto_interact.txt", "+ [%s] %d", CGameObject::GetName(object), j);
return IR_CONT;
}
}
- Fatal_error("fn_register_for_auto_interaction - list full - [%s]", object->GetName());
+ Fatal_error("fn_register_for_auto_interaction - list full - [%s]", CGameObject::GetName(object));
return IR_CONT;
}
diff --git a/engines/icb/function.cpp b/engines/icb/function.cpp
index af2e0dfeccc..329ffd3f5c9 100644
--- a/engines/icb/function.cpp
+++ b/engines/icb/function.cpp
@@ -364,16 +364,16 @@ mcodeFunctionReturnCodes _game_session::socket_force_new_logic(int32 &, int32 *p
script_hash = HashString(script_name);
if (g_px->socket_watch)
- Message_box("socket_force_new_logic - obj %s, script %s", socket_object->GetName(), script_name);
+ Message_box("socket_force_new_logic - obj %s, script %s", CGameObject::GetName(socket_object), script_name);
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < socket_object->GetNoScripts(); k++) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(socket_object); k++) {
// now check for actual script name
- if (script_hash == socket_object->GetScriptNamePartHash(k)) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(socket_object, k)) {
Zdebug("script %d matches", k);
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(socket_object, k));
if (g_px->socket_watch)
Message_box("replacing logic");
@@ -400,7 +400,7 @@ mcodeFunctionReturnCodes _game_session::socket_force_new_logic(int32 &, int32 *p
// didnt find the script in the target
// shut that object down as its full of holes!
- Fatal_error("socket_force_new_logic cant find script - obj %s, script %s", socket_object->GetName(), script_name);
+ Fatal_error("socket_force_new_logic cant find script - obj %s, script %s", CGameObject::GetName(socket_object), script_name);
return (IR_TERMINATE);
}
@@ -419,7 +419,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_voxel_image_path(int32 &, int32 *
// enforce this convention
if (!logic_structs[cur_id]->mega)
- Fatal_error("fn_set_voxel_image_path %s is not a mega", object->GetName());
+ Fatal_error("fn_set_voxel_image_path %s is not a mega", CGameObject::GetName(object));
const char *param0Str = (const char *)MemoryUtil::resolvePtr(params[0]);
const char *param1Str = (const char *)MemoryUtil::resolvePtr(params[1]);
@@ -454,7 +454,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_voxel_image_path(int32 &, int32 *
mcodeFunctionReturnCodes _game_session::fn_set_xyz(int32 &, int32 *) {
// set a game objects x,y,z worldspace coords
- Fatal_error("[%s] fn_set_xyz - not supported", object->GetName());
+ Fatal_error("[%s] fn_set_xyz - not supported", CGameObject::GetName(object));
return IR_CONT;
}
@@ -481,16 +481,16 @@ mcodeFunctionReturnCodes _game_session::fn_init_from_nico_file(int32 &, int32 *
_feature_info *start_pos;
- Zdebug("fn_init_from_nico_file - %s (cur_id %d)", object->GetName(), cur_id);
+ Zdebug("fn_init_from_nico_file - %s (cur_id %d)", CGameObject::GetName(object), cur_id);
if (L->image_type == VOXEL)
- Fatal_error("fn_init_from_nico_file called by a mega! [%s] - use fn_init_mega_from_nico", object->GetName());
+ Fatal_error("fn_init_from_nico_file called by a mega! [%s] - use fn_init_mega_from_nico", CGameObject::GetName(object));
// fetch tag file for this item
- start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, CGameObject::GetName(object));
if (!start_pos) {
- Message_box("fn_init_from_nico_file - missing nico for item %s", object->GetName());
+ Message_box("fn_init_from_nico_file - missing nico for item %s", CGameObject::GetName(object));
Shut_down_object("fn_init_from_nico_file - missing nico for item");
return IR_STOP;
}
@@ -515,7 +515,7 @@ mcodeFunctionReturnCodes _game_session::fn_init_from_nico_file(int32 &, int32 *
logic_structs[cur_id]->owner_floor_rect = floor_def->Return_floor_rect(FROM_LE_FLOAT32(start_pos->x), FROM_LE_FLOAT32(start_pos->z), FROM_LE_FLOAT32(start_pos->floor_y), 0);
if (logic_structs[cur_id]->owner_floor_rect == PXNULL) {
- Message_box("fn_init_from_nico_file - %s nico not on a legal floor position - object has been shutdown", object->GetName());
+ Message_box("fn_init_from_nico_file - %s nico not on a legal floor position - object has been shutdown", CGameObject::GetName(object));
Shut_down_object("fn_init_from_nico_file");
return IR_STOP;
}
@@ -531,7 +531,7 @@ mcodeFunctionReturnCodes _game_session::fn_check_for_nico(int32 &result, int32 *
_feature_info *start_pos;
- start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, CGameObject::GetName(object));
if (!start_pos)
result = FALSE8;
@@ -551,17 +551,17 @@ mcodeFunctionReturnCodes _game_session::fn_init_from_marker_file(int32 &, int32
_map_marker *start_pos;
- Zdebug("fn_init_from_marker_file - %s (cur_id %d)", object->GetName(), cur_id);
+ Zdebug("fn_init_from_marker_file - %s (cur_id %d)", CGameObject::GetName(object), cur_id);
// if this object does not have a voxel_info struct then we're done here!
if (!logic_structs[cur_id]->voxel_info)
Fatal_error("FN_INIT_FROM_MARKER_FILE fails because object is not registered as a mega.");
// fetch tag file for this item
- start_pos = (_map_marker *)markers.Fetch_marker_by_object_name(const_cast<char *>(object->GetName()));
+ start_pos = (_map_marker *)markers.Fetch_marker_by_object_name(const_cast<char *>(CGameObject::GetName(object)));
if (!start_pos) {
- Message_box("fn_init_from_marker_file missing map marker file entry for item %s. You must edit the markers - dont play the game.", object->GetName());
+ Message_box("fn_init_from_marker_file missing map marker file entry for item %s. You must edit the markers - dont play the game.", CGameObject::GetName(object));
Shut_down_object("fn_init_from_marker_file");
return IR_STOP;
}
@@ -586,17 +586,17 @@ mcodeFunctionReturnCodes _game_session::fn_init_mega_from_nico(int32 &, int32 *)
_feature_info *start_pos;
- Zdebug("fn_init_mega_from_nico - %s (cur_id %d)", object->GetName(), cur_id);
+ Zdebug("fn_init_mega_from_nico - %s (cur_id %d)", CGameObject::GetName(object), cur_id);
// if this object does not have a voxel_info struct then we're done here!
if (!logic_structs[cur_id]->voxel_info)
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 *)LinkedDataObject::Try_fetch_item_by_name(features, object->GetName());
+ start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, CGameObject::GetName(object));
if (!start_pos) {
- Message_box("fn_init_mega_from_nico missing nico for item %s", object->GetName());
+ Message_box("fn_init_mega_from_nico missing nico for item %s", CGameObject::GetName(object));
Shut_down_object("fn_init_mega_from_nico missing nico for item");
return IR_STOP;
}
@@ -624,7 +624,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico(int32 &, int32 *para
const char *nico_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("fn_teleport_to_nico - %s (to %s)", object->GetName(), nico_name);
+ Zdebug("fn_teleport_to_nico - %s (to %s)", CGameObject::GetName(object), nico_name);
// if this object does not have a voxel_info struct then we're done here!
if (!logic_structs[cur_id]->voxel_info)
@@ -633,7 +633,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico(int32 &, int32 *para
// fetch tag file for this item
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);
+ Fatal_error("no NICO marker (fn_teleport_to_nico) ob %s, nico %s", CGameObject::GetName(object), nico_name);
// set coordinates
logic_structs[cur_id]->mega->actor_xyz.x = FROM_LE_FLOAT32(start_pos->x);
@@ -668,7 +668,7 @@ mcodeFunctionReturnCodes _game_session::fn_panless_teleport_to_nico(int32 &, int
// fetch tag file for this item
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);
+ Fatal_error("no NICO marker (fn_panless_teleport_to_nico_) ob %s, nico %s", CGameObject::GetName(object), nico_name);
// set coordinates
logic_structs[cur_id]->mega->actor_xyz.x = FROM_LE_FLOAT32(start_pos->x);
@@ -691,7 +691,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico_y(int32 &, int32 *pa
const char *nico_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("fn_teleport_to_nico_y - %s (to %s)", object->GetName(), nico_name);
+ Zdebug("fn_teleport_to_nico_y - %s (to %s)", CGameObject::GetName(object), nico_name);
// if this object does not have a voxel_info struct then we're done here!
if (!logic_structs[cur_id]->voxel_info)
@@ -700,7 +700,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_to_nico_y(int32 &, int32 *pa
// fetch tag file for this item
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);
+ Fatal_error("no NICO marker (fn_teleport_to_nico_y) ob %s, nico %s", CGameObject::GetName(object), nico_name);
// set coordinates
logic_structs[cur_id]->mega->actor_xyz.y = FROM_LE_FLOAT32(start_pos->floor_y); // Gravitise_y(start_pos->y);
@@ -724,7 +724,7 @@ mcodeFunctionReturnCodes _game_session::fn_snap_to_nico_y(int32 &, int32 *params
const char *nico_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("fn_snap_to_nico_y - %s (to %s)", object->GetName(), nico_name);
+ Zdebug("fn_snap_to_nico_y - %s (to %s)", CGameObject::GetName(object), nico_name);
// if this object does not have a voxel_info struct then we're done here!
if (!logic_structs[cur_id]->voxel_info)
@@ -733,7 +733,7 @@ mcodeFunctionReturnCodes _game_session::fn_snap_to_nico_y(int32 &, int32 *params
// fetch tag file for this item
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);
+ Fatal_error("no NICO marker (fn_snap_to_nico_y) ob %s, nico %s", CGameObject::GetName(object), nico_name);
// set coordinates
logic_structs[cur_id]->mega->actor_xyz.y = FROM_LE_FLOAT32(start_pos->floor_y);
@@ -751,7 +751,7 @@ mcodeFunctionReturnCodes _game_session::fn_get_pan_from_nico(int32 &, int32 *par
const char *nico_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("fn_get_pan_from_nico - %s (nico %s)", object->GetName(), nico_name);
+ Zdebug("fn_get_pan_from_nico - %s (nico %s)", CGameObject::GetName(object), nico_name);
// fetch tag file for this item
start_pos = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, nico_name);
@@ -759,8 +759,8 @@ mcodeFunctionReturnCodes _game_session::fn_get_pan_from_nico(int32 &, int32 *par
if (!start_pos) {
// item does not have an entry but clearly expects one
// for now, just carry on and log a warning
- Zdebug("WARNING missing feature file entry for item %s", object->GetName());
- Fatal_error("no NICO marker (fn_get_pan_from_nico) %s", object->GetName());
+ Zdebug("WARNING missing feature file entry for item %s", CGameObject::GetName(object));
+ Fatal_error("no NICO marker (fn_get_pan_from_nico) %s", CGameObject::GetName(object));
}
// set pan
@@ -801,14 +801,14 @@ mcodeFunctionReturnCodes _game_session::fn_call_socket(int32 &result, int32 *par
Zdebug("fn_call_socket - obj %s, script %s", target_object_name, socket_script_name);
if (g_px->socket_watch)
- Message_box("%s fn_call_socket - obj %s, script %s", object->GetName(), target_object_name, socket_script_name);
+ Message_box("%s fn_call_socket - obj %s, script %s", CGameObject::GetName(object), target_object_name, socket_script_name);
script_hash = HashString(socket_script_name);
// get target object
- socket_object = (c_game_object *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, target_object_name);
+ socket_object = (CGame *)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);
+ Fatal_error("%s call to fn_call_socket - object %s doesnt exist", CGameObject::GetName(object), target_object_name);
// set socket_id ready for any special socket functions
socket_id = LinkedDataObject::Fetch_item_number_by_name(MS->objects, target_object_name);
@@ -816,14 +816,14 @@ mcodeFunctionReturnCodes _game_session::fn_call_socket(int32 &result, int32 *par
Fatal_error("fn_call_socket couldnt find object [%s]", target_object_name);
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < socket_object->GetNoScripts(); k++) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(socket_object); k++) {
// now check for actual script name
- if (script_hash == socket_object->GetScriptNamePartHash(k)) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(socket_object, k)) {
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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(socket_object, k));
// run the script - pass its object so vars can be accessed
RunScript(pc, socket_object, &retval);
@@ -874,25 +874,25 @@ bool8 _game_session::Call_socket(uint32 id, const char *script, int32 *retval) {
script_hash = HashString(script);
// get target object
- socket_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
+ socket_object = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!socket_object)
Fatal_error("internal Call_socket - named object dont exist");
- Zdebug("\nCall_socket - obj %s, script %s", socket_object->GetName(), script);
+ Zdebug("\nCall_socket - obj %s, script %s", CGameObject::GetName(socket_object), script);
// set this for socket fn_ functions
socket_id = id;
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < socket_object->GetNoScripts(); k++) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(socket_object); k++) {
// skip past the object:: aspect
// now check for actual script name
- if (script_hash == socket_object->GetScriptNamePartHash(k)) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(socket_object, k)) {
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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, socket_object->GetScriptNameFullHash(k));
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(socket_object, k));
int32 result = static_cast<int>(*retval);
@@ -905,7 +905,7 @@ bool8 _game_session::Call_socket(uint32 id, const char *script, int32 *retval) {
}
}
- Tdebug("Call_socket_fails.txt", "[%s] couldnt find script [%s] in [%s]", object->GetName(), script, socket_object->GetName());
+ Tdebug("Call_socket_fails.txt", "[%s] couldnt find script [%s] in [%s]", CGameObject::GetName(object), script, CGameObject::GetName(socket_object));
return (FALSE8);
}
@@ -956,7 +956,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport(int32 &, int32 *params) {
const char *target_object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
Zdebug("\nfn_teleport to %s x%d z%d", target_object_name, params[1], params[2]);
- Zdebug("cur_id %d [%s]", cur_id, object->GetName());
+ Zdebug("cur_id %d [%s]", cur_id, CGameObject::GetName(object));
// Made this so it takes a special name "from_origin" to indicate that the offset is to be applied
// from 0,0.
@@ -967,7 +967,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport(int32 &, int32 *params) {
Fatal_error("'destination' teleport object [%s] does not exist", target_object_name);
if (!logic_structs[tar]->prop_coords_set)
- Fatal_error("fn_teleport by [%s] finds object [%s] is not yet initialised :O - i.e. its not run its init script yet", object->GetName(),
+ Fatal_error("fn_teleport by [%s] finds object [%s] is not yet initialised :O - i.e. its not run its init script yet", CGameObject::GetName(object),
target_object_name);
if (logic_structs[tar]->image_type == PROP) {
@@ -1012,7 +1012,7 @@ mcodeFunctionReturnCodes _game_session::fn_teleport_z(int32 &, int32 *params) {
if (tar == 0xffffffff)
Fatal_error("'destination' teleport object [%s] does not exist", target_object_name);
if (!logic_structs[tar]->prop_coords_set)
- Fatal_error("fn_teleport by [%s] finds object [%s] is not yet initialised :O - i.e. its not run its init script yet", object->GetName(), target_object_name);
+ Fatal_error("fn_teleport by [%s] finds object [%s] is not yet initialised :O - i.e. its not run its init script yet", CGameObject::GetName(object), target_object_name);
if (logic_structs[tar]->image_type == PROP) {
logic_structs[cur_id]->mega->actor_xyz.y = floor_def->Gravitise_y(logic_structs[tar]->prop_xyz.y); // logic_structs[tar]->prop_xyz.y;
@@ -1253,22 +1253,22 @@ mcodeFunctionReturnCodes _game_session::fn_get_objects_lvar_value(int32 &result,
// 1 name of lvar
int32 ret;
- c_game_object *ob;
+ CGame *ob;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
const char *lvar_name = (const char *)MemoryUtil::resolvePtr(params[1]);
Zdebug("fn_get_objects_lvar_value - [%s] [%s]", object_name, lvar_name);
uint32 hash = HashString(object_name);
- ob = (c_game_object *)LinkedDataObject::Try_fetch_item_by_hash(objects, hash);
+ ob = (CGame *)LinkedDataObject::Try_fetch_item_by_hash(objects, hash);
if (!ob)
Fatal_error("fn_get_objects_lvar_value - illegal object [%s]", object_name);
- ret = ob->GetVariable(lvar_name);
+ ret = CGameObject::GetVariable(ob, lvar_name);
if (ret == -1)
- Fatal_error("%s finds fn_get_objects_lvar_value - target object [%s] doesnt have [%s] lvar", object->GetName(), object_name, lvar_name);
+ Fatal_error("%s finds fn_get_objects_lvar_value - target object [%s] doesnt have [%s] lvar", CGameObject::GetName(object), object_name, lvar_name);
- result = ob->GetIntegerVariable(ret);
+ result = CGameObject::GetIntegerVariable(ob, ret);
Zdebug(" var==%d", result);
@@ -1281,21 +1281,21 @@ mcodeFunctionReturnCodes _game_session::fn_set_objects_lvar_value(int32 &, int32
// 2 new value of lvar
int32 var_num;
- c_game_object *ob;
+ CGame *ob;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
const char *lvar_name = (const char *)MemoryUtil::resolvePtr(params[1]);
- Zdebug("[%s] calls fn_set_objects_lvar_value - [%s] [%s, %d]", object->GetName(), object_name, lvar_name, params[2]);
+ Zdebug("[%s] calls fn_set_objects_lvar_value - [%s] [%s, %d]", CGameObject::GetName(object), object_name, lvar_name, params[2]);
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, object_name);
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_name(objects, object_name);
if (!ob)
Fatal_error("fn_set_objects_lvar_value - illegal object [%s]", object_name);
- var_num = ob->GetVariable(lvar_name);
+ var_num = CGameObject::GetVariable(ob, lvar_name);
if (var_num == -1)
- Fatal_error("[%s] fn_set_objects_lvar_value - object [%s] doesnt have [%s] lvar", object->GetName(), object_name, lvar_name);
+ Fatal_error("[%s] fn_set_objects_lvar_value - object [%s] doesnt have [%s] lvar", CGameObject::GetName(object), object_name, lvar_name);
- ob->SetIntegerVariable(var_num, params[2]);
+ CGameObject::SetIntegerVariable(ob, var_num, params[2]);
Zdebug(" var==%d", params[2]);
@@ -1308,20 +1308,20 @@ mcodeFunctionReturnCodes _game_session::fn_set_ids_lvar_value(int32 &, int32 *pa
// 2 new value of lvar
int32 var_num;
- c_game_object *ob;
+ CGame *ob;
const char *lvar_name = (const char *)MemoryUtil::resolvePtr(params[1]);
Zdebug("fn_set_ids_lvar_value - [%s] [%s]", LinkedDataObject::Fetch_items_name_by_number(objects, params[0]), lvar_name);
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, params[0]);
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, params[0]);
if (!ob)
Fatal_error("fn_set_ids_lvar_value - illegal object [%d]", params[0]);
- var_num = ob->GetVariable(lvar_name);
+ var_num = CGameObject::GetVariable(ob, lvar_name);
if (var_num == -1)
Fatal_error("fn_set_ids_lvar_value - object [%d] doesnt have [%s] lvar", params[0], lvar_name);
- ob->SetIntegerVariable(var_num, params[2]);
+ CGameObject::SetIntegerVariable(ob, var_num, params[2]);
Zdebug(" var==%d", params[2]);
@@ -1332,16 +1332,16 @@ mcodeFunctionReturnCodes _game_session::fn_get_state_flag(int32 &result, int32 *
// params 0 name of object
int32 ret;
- c_game_object *ob;
+ CGame *ob;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, object_name);
+ ob = (CGame *)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");
+ ret = CGameObject::GetVariable(ob, "state");
if (ret == -1)
Fatal_error("fn_get_state_flag - object [%s] doesnt have 'state' lvar", object_name);
- result = ob->GetIntegerVariable(ret);
+ result = CGameObject::GetIntegerVariable(ob, ret);
return (IR_CONT);
}
@@ -1383,7 +1383,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_weapon(int32 &, int32 *params) {
}
}
- Fatal_error("WARNING - %s specified weapon does not exist [%s]", object->GetName(), weapon_name);
+ Fatal_error("WARNING - %s specified weapon does not exist [%s]", CGameObject::GetName(object), weapon_name);
return (IR_STOP);
}
@@ -1457,7 +1457,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_pose(int32 &, int32 *params) {
}
}
- Fatal_error("WARNING - %s specified weapon does not exist [%s]", object->GetName(), pose_name);
+ Fatal_error("WARNING - %s specified weapon does not exist [%s]", CGameObject::GetName(object), pose_name);
return (IR_STOP);
}
@@ -1520,7 +1520,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_player_pose(int32 &, int32 *param
}
}
- Fatal_error("WARNING - fn_set_player_pose %s specified weapon does not exist [%s]", object->GetName(), pose_name);
+ Fatal_error("WARNING - fn_set_player_pose %s specified weapon does not exist [%s]", CGameObject::GetName(object), pose_name);
return (IR_STOP);
}
@@ -1536,7 +1536,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_custom(int32 &, int32 *params) {
Zdebug("fn_set_custom [%s]", custom_name);
if (!M)
- Fatal_error("fn_set_custom finds [%s] is not a mega", object->GetName());
+ Fatal_error("fn_set_custom finds [%s] is not a mega", CGameObject::GetName(object));
Set_string(custom_name, M->custom_set, MAX_CUSTOM_NAME_LENGTH);
M->custom = TRUE8;
@@ -1555,7 +1555,7 @@ mcodeFunctionReturnCodes _game_session::fn_message(int32 &, int32 *params) {
if (params[0] < 256) {
Message_box("%d", params[0]);
} else {
- Message_box("%s - %s", object->GetName(), message);
+ Message_box("%s - %s", CGameObject::GetName(object), message);
}
return IR_CONT;
}
@@ -1563,9 +1563,9 @@ mcodeFunctionReturnCodes _game_session::fn_message(int32 &, int32 *params) {
mcodeFunctionReturnCodes _game_session::fn_message_var(int32 &, int32 *params) {
const char *var_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- uint32 var = object->GetVariable(var_name);
+ uint32 var = CGameObject::GetVariable(object, var_name);
if (var == 0xffffffff)
- Fatal_error("fn_message_var - object %s has no var %s", object->GetName(), var_name);
+ Fatal_error("fn_message_var - object %s has no var %s", CGameObject::GetName(object), var_name);
// pc has to muck around to clear sticky ctrl key
// hold until ctrl key released
@@ -1574,10 +1574,10 @@ mcodeFunctionReturnCodes _game_session::fn_message_var(int32 &, int32 *params) {
char txt[100];
- if (object->IsVariableString(var))
- sprintf(txt, "%s=\"%s\"", var_name, object->GetStringVariable(var));
+ if (CGameObject::IsVariableString(object, var))
+ sprintf(txt, "%s=\"%s\"", var_name, CGameObject::GetStringVariable(object, var));
else
- sprintf(txt, "%s=%d", var_name, object->GetIntegerVariable(var));
+ sprintf(txt, "%s=%d", var_name, CGameObject::GetIntegerVariable(object, var));
Message_box(txt);
@@ -1794,7 +1794,7 @@ mcodeFunctionReturnCodes _game_session::fn_hold_if_off_screen(int32 &, int32 *)
// no params
if (L->image_type != VOXEL)
- Fatal_error("fn_hold_if_off_screen only works with megas [%s]", object->GetName());
+ Fatal_error("fn_hold_if_off_screen only works with megas [%s]", CGameObject::GetName(object));
if (!Object_visible_to_camera(cur_id)) {
return (IR_REPEAT);
@@ -1855,12 +1855,12 @@ mcodeFunctionReturnCodes _game_session::fn_add_object_name_to_list(int32 &, int3
// check for list overflow
if (L->total_list == MAX_list)
- Fatal_error("fn_object_name_to_list [%s] has exceeded list size of %d", object->GetName(), MAX_list);
+ Fatal_error("fn_object_name_to_list [%s] has exceeded list size of %d", CGameObject::GetName(object), MAX_list);
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);
+ Fatal_error("[%s] callling fn_add_object_name_to_list finds [%s] is not a legal object", CGameObject::GetName(object), object_name);
L->list[L->total_list++] = (uint32)id;
@@ -1872,7 +1872,7 @@ mcodeFunctionReturnCodes _game_session::fn_add_object_id_to_list(int32 &, int32
// check for list overflow
if (L->total_list == MAX_list)
- Fatal_error("fn_object_id_to_list [%s] has exceeded list size of %d", object->GetName(), MAX_list);
+ Fatal_error("fn_object_id_to_list [%s] has exceeded list size of %d", CGameObject::GetName(object), MAX_list);
assert((uint32)params[0] < total_objects);
@@ -1984,7 +1984,7 @@ mcodeFunctionReturnCodes _game_session::fn_lib_lift_chord_and_chi(int32 &result,
// issue one warning at a time
if ((!has_platform) && (!issued_warning)) {
issued_warning = TRUE8;
- Message_box("lift [%s] says please can i have proper platform coords?", object->GetName());
+ Message_box("lift [%s] says please can i have proper platform coords?", CGameObject::GetName(object));
}
if (PXfabs(logic_structs[player.Fetch_player_id()]->mega->actor_xyz.y - lifty) < (200 * REAL_ONE)) { // slack for height calc
@@ -2074,18 +2074,18 @@ mcodeFunctionReturnCodes _game_session::fn_lift2_process(int32 &result, int32 *p
}
if (lift2s[cur_id].params[0] != params[0])
- Message_box("%s param 0 changed from %d to %d", object->GetName(), lift2s[cur_id].params[0], params[0]);
+ Message_box("%s param 0 changed from %d to %d", CGameObject::GetName(object), lift2s[cur_id].params[0], params[0]);
if (lift2s[cur_id].params[1] != params[1])
- Message_box("%s param 1 changed from %d to %d", object->GetName(), lift2s[cur_id].params[1], params[1]);
+ Message_box("%s param 1 changed from %d to %d", CGameObject::GetName(object), lift2s[cur_id].params[1], params[1]);
if (lift2s[cur_id].params[2] != params[2])
- Message_box("%s param 2 changed from %d to %d", object->GetName(), lift2s[cur_id].params[2], params[2]);
+ Message_box("%s param 2 changed from %d to %d", CGameObject::GetName(object), lift2s[cur_id].params[2], params[2]);
if (lift2s[cur_id].params[3] != params[3])
- Message_box("%s param 3 changed from %d to %d", object->GetName(), lift2s[cur_id].params[3], params[3]);
+ Message_box("%s param 3 changed from %d to %d", CGameObject::GetName(object), lift2s[cur_id].params[3], params[3]);
// check for no people in list! Could be redefined as an error in-fact
if (!L->total_list) {
if (!issued_warning) {
- Message_box("lift [%s] says no items in list", object->GetName());
+ Message_box("lift [%s] says no items in list", CGameObject::GetName(object));
issued_warning = TRUE8;
}
@@ -2110,7 +2110,7 @@ mcodeFunctionReturnCodes _game_session::fn_lift2_process(int32 &result, int32 *p
// issue one warning at a time
if ((!has_platform) && (!issued_warning)) {
issued_warning = TRUE8;
- Message_box("lift [%s] says please can i have proper platform coords?", object->GetName());
+ Message_box("lift [%s] says please can i have proper platform coords?", CGameObject::GetName(object));
}
for (j = 0; j < L->total_list; j++) {
@@ -2409,7 +2409,7 @@ mcodeFunctionReturnCodes _game_session::fn_three_sixty_interact(int32 &, int32 *
// set object to use the prop 360deg interaction type
if (L->image_type != PROP)
- Fatal_error("fn_three_sixty_interact - object [%s] is not a prop!", object->GetName());
+ Fatal_error("fn_three_sixty_interact - object [%s] is not a prop!", CGameObject::GetName(object));
L->three_sixty_interact |= THREE_SIXTY_INTERACT;
@@ -2450,10 +2450,10 @@ mcodeFunctionReturnCodes _game_session::fn_change_session(int32 &, int32 *params
g_mission->Set_init_nico_name(nico_name);
// save the players 'hits' variable
- c_game_object *ob;
- 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);
+ CGame *ob;
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
+ ret = CGameObject::GetVariable(ob, "hits");
+ g_mission->old_hits_value = CGameObject::GetIntegerVariable(ob, ret);
return (IR_STOP); // do no more
}
@@ -2484,8 +2484,8 @@ mcodeFunctionReturnCodes _game_session::fn_changed_sessions(int32 &result, int32
logic_structs[cur_id]->pan = nico->direction;
// reset current hits from previous session
- ret = object->GetVariable("hits");
- object->SetIntegerVariable(ret, g_mission->old_hits_value);
+ ret = CGameObject::GetVariable(object, "hits");
+ CGameObject::SetIntegerVariable(object, ret, g_mission->old_hits_value);
// has coords
logic_structs[cur_id]->prop_coords_set = TRUE8;
@@ -2638,7 +2638,7 @@ mcodeFunctionReturnCodes _game_session::fn_preload_custom_mega_anim(int32 &resul
mcodeFunctionReturnCodes _game_session::fn_no_logic(int32 &, int32 *) {
// set wait_status to no-logic which stops the script being invoked
- Tdebug("logic_modes.txt", "fn_no_logic freezing [%s]", object->GetName());
+ Tdebug("logic_modes.txt", "fn_no_logic freezing [%s]", CGameObject::GetName(object));
L->big_mode = __NO_LOGIC;
L->cycle_time = 0; // for mt display
@@ -2677,19 +2677,19 @@ mcodeFunctionReturnCodes _game_session::fn_mega_use_lift(int32 &, int32 *params)
// params 0 name of lift
- c_game_object *ob;
+ CGame *ob;
uint32 var_num;
const char *lift_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, lift_name);
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_name(objects, lift_name);
if (!ob)
Fatal_error("fn_use_lift - illegal object [%s]", lift_name);
- var_num = ob->GetVariable("request");
+ var_num = CGameObject::GetVariable(ob, "request");
if (var_num == (uint32)-1)
Fatal_error("fn_use_lift - object [%s] doesnt have REQUEST variable", lift_name);
- ob->SetIntegerVariable(var_num, 2); // two is trigger value
+ CGameObject::SetIntegerVariable(ob, var_num, 2); // two is trigger value
return (IR_CONT);
}
@@ -2697,16 +2697,16 @@ mcodeFunctionReturnCodes _game_session::fn_mega_use_lift(int32 &, int32 *params)
// fn_make_remora_beep(1) makes the remora beep notice us, 0 makes it not do...
mcodeFunctionReturnCodes _game_session::fn_make_remora_beep(int32 &, int32 *params) {
if (logic_structs[cur_id]->image_type != VOXEL)
- Fatal_error("fn_make_remora_beep - object %s is not a person! what is this?", object->GetName());
+ Fatal_error("fn_make_remora_beep - object %s is not a person! what is this?", CGameObject::GetName(object));
if (params[0] == 0) {
L->mega->make_remora_beep = FALSE8;
- Zdebug("%s->fn_make_remora_beep(no beep)\n", object->GetName());
+ Zdebug("%s->fn_make_remora_beep(no beep)\n", CGameObject::GetName(object));
} else if (params[0] == 1) {
L->mega->make_remora_beep = TRUE8;
- Zdebug("%s->fn_make_remora_beep(beep)\n", object->GetName());
+ Zdebug("%s->fn_make_remora_beep(beep)\n", CGameObject::GetName(object));
} else
- Fatal_error("fn_make_remora_beep - object [%s] called with value %d", object->GetName(), params[0]);
+ Fatal_error("fn_make_remora_beep - object [%s] called with value %d", CGameObject::GetName(object), params[0]);
return (IR_CONT);
}
@@ -2714,16 +2714,16 @@ mcodeFunctionReturnCodes _game_session::fn_make_remora_beep(int32 &, int32 *para
// fn_set_evil(1) sets us to evil mode for beeping and possibly scanner, fn_set_evil(0) sets us to harmless
mcodeFunctionReturnCodes _game_session::fn_set_evil(int32 &, int32 *params) {
if (logic_structs[cur_id]->image_type != VOXEL)
- Fatal_error("fn_set_evil - object %s is not a person! what is this?", object->GetName());
+ Fatal_error("fn_set_evil - object %s is not a person! what is this?", CGameObject::GetName(object));
if (params[0] == 0) {
L->mega->is_evil = FALSE8;
- Zdebug("%s->fn_set_evil(NOT_EVIL!)\n", object->GetName());
+ Zdebug("%s->fn_set_evil(NOT_EVIL!)\n", CGameObject::GetName(object));
} else if (params[0] == 1) {
L->mega->is_evil = TRUE8;
- Zdebug("%s->fn_set_evil(EVIL!)\n", object->GetName());
+ Zdebug("%s->fn_set_evil(EVIL!)\n", CGameObject::GetName(object));
} else
- Fatal_error("fn_set_evil - object [%s] called with value %d", object->GetName(), params[0]);
+ Fatal_error("fn_set_evil - object [%s] called with value %d", CGameObject::GetName(object), params[0]);
return (IR_CONT);
}
@@ -2940,18 +2940,18 @@ uint32 _game_session::Register_stair_or_ladder(const char *target, bool8 top, ui
uint8 j = 0;
if (!length)
- Fatal_error("%s has 0 length", object->GetName());
+ Fatal_error("%s has 0 length", CGameObject::GetName(object));
if (length > 1000)
- Fatal_error("%s has illegal length %d", object->GetName(), length);
+ Fatal_error("%s has illegal length %d", CGameObject::GetName(object), length);
// get our nico
- stair = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, const_cast<char *>(object->GetName()));
+ stair = (_feature_info *)LinkedDataObject::Try_fetch_item_by_name(features, const_cast<char *>(CGameObject::GetName(object)));
// get other end
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());
+ Fatal_error("fn_register_stairway - cant find nico %s", CGameObject::GetName(object));
if (!dest_stair)
Fatal_error("fn_register_stairway - cant find nico %s", target);
if (num_stairs == MAX_stairs)
@@ -3140,9 +3140,9 @@ mcodeFunctionReturnCodes _game_session::fn_set_shade_percentage(int32 &, int32 *
// set shade percentage figure for mega
if (L->image_type != VOXEL)
- Fatal_error("fn_set_shade_percentage [%s] says people only!", object->GetName());
+ Fatal_error("fn_set_shade_percentage [%s] says people only!", CGameObject::GetName(object));
if (params[0] > 99)
- Fatal_error("fn_set_shade_percentage [%s] percentages usually go 0-99", object->GetName());
+ Fatal_error("fn_set_shade_percentage [%s] percentages usually go 0-99", CGameObject::GetName(object));
M->inShadePercentage = (uint8)params[0];
@@ -3153,7 +3153,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_half_character_width(int32 &, int
// adjust the default barrier extrapolation for route barriers - for people like spectre who is very big
if (!M)
- Fatal_error("fn_set_door_width only for megas [%s]", object->GetName());
+ Fatal_error("fn_set_door_width only for megas [%s]", CGameObject::GetName(object));
M->extrap_size = (uint8)params[0];
@@ -3165,7 +3165,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_visible(int32 &, int32 *params) {
// params 0 0 off 1 on
if (!M)
- Fatal_error("%s fn_set_visible is for megas only", object->GetName());
+ Fatal_error("%s fn_set_visible is for megas only", CGameObject::GetName(object));
M->display_me = (bool8)params[0];
@@ -3206,7 +3206,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_to_dead(int32 &, int32 *) {
// set the dead flag - we have a flag for speed of access
if (!L->mega)
- Fatal_error("fn_set_to_dead called for [%s] but not a mega", object->GetName());
+ Fatal_error("fn_set_to_dead called for [%s] but not a mega", CGameObject::GetName(object));
L->mega->dead = TRUE8;
@@ -3217,10 +3217,10 @@ mcodeFunctionReturnCodes _game_session::fn_set_camera_hold(int32 &, int32 *param
// switch camera hold mode on or off
if (M)
- Fatal_error("fn_set_camera_hold called for [%s] but this is for props only", object->GetName());
+ Fatal_error("fn_set_camera_hold called for [%s] but this is for props only", CGameObject::GetName(object));
// find entry for this object via its name, which we find via its number :(
- if (!LinkedDataObject::Try_fetch_item_by_name(prop_anims, object->GetName()))
+ if (!LinkedDataObject::Try_fetch_item_by_name(prop_anims, CGameObject::GetName(object)))
return IR_CONT; // item has no prop entry - so keep it live
if (params[0])
@@ -3235,7 +3235,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_mega_wait_for_player(int32 &, int
// mega will pause until the player arrives
if (!M)
- Fatal_error("fn_set_mega_wait_for_player called for [%s] but not a mega", object->GetName());
+ Fatal_error("fn_set_mega_wait_for_player called for [%s] but not a mega", CGameObject::GetName(object));
L->big_mode = __MEGA_INITIAL_FLOOR_HELD;
@@ -3246,7 +3246,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_mega_off_camera_hold(int32 &, int
// mega will pause when not on_camera
if (!M)
- Fatal_error("fn_set_mega_off_camera_hold called for [%s] but not a mega", object->GetName());
+ Fatal_error("fn_set_mega_off_camera_hold called for [%s] but not a mega", CGameObject::GetName(object));
L->big_mode = __MEGA_PLAYER_FLOOR_HELD;
L->hold_mode = mega_player_floor_hold;
@@ -3260,7 +3260,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_mega_slice_hold(int32 &, int32 *p
// params 0 y distance to stray before character holds again
if (!M)
- Fatal_error("fn_set_mega_slice_hold called for [%s] but not a mega", object->GetName());
+ Fatal_error("fn_set_mega_slice_hold called for [%s] but not a mega", CGameObject::GetName(object));
L->big_mode = __MEGA_SLICE_HELD;
L->hold_mode = mega_slice_hold;
@@ -3277,7 +3277,7 @@ mcodeFunctionReturnCodes _game_session::fn_lock_y(int32 &, int32 *params) {
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);
+ Fatal_error("fn_lock_y by [%s] for nico [%s] finds no such nico", CGameObject::GetName(object), marker_name);
M->y_locked = TRUE8;
M->y_lock = nico->y;
diff --git a/engines/icb/general_interaction.cpp b/engines/icb/general_interaction.cpp
index b6e88d624e2..02e5dd5573c 100644
--- a/engines/icb/general_interaction.cpp
+++ b/engines/icb/general_interaction.cpp
@@ -52,7 +52,7 @@ bool8 _game_session::Find_interact_marker_in_anim(__mega_set_names animation, PX
// first check anim file will exist
if (!I->IsAnimTable(animation))
- Fatal_error("Find_interact_marker_in_anim finds [%s] doesnt have a [%s] animation", object->GetName(), master_anim_name_table[animation].name);
+ Fatal_error("Find_interact_marker_in_anim finds [%s] doesnt have a [%s] animation", CGameObject::GetName(object), master_anim_name_table[animation].name);
// open the file
PXanim *pAnim = (PXanim *)rs_anims->Res_open(I->get_info_name(animation), I->info_name_hash[animation], I->base_path, I->base_path_hash);
diff --git a/engines/icb/general_npc_animation.cpp b/engines/icb/general_npc_animation.cpp
index 6ca486c11bf..a4146b9df7d 100644
--- a/engines/icb/general_npc_animation.cpp
+++ b/engines/icb/general_npc_animation.cpp
@@ -407,7 +407,7 @@ void _game_session::Animate_turn_to_pan(__mega_set_names anim_type, uint32 speed
}
if ((info_pc >= pAnim->frame_qty) || (next_pc >= pAnim->frame_qty))
- Fatal_error("Animate_turn_to_pan [%s] using illegal frame", object->GetName());
+ Fatal_error("Animate_turn_to_pan [%s] using illegal frame", CGameObject::GetName(object));
// update engine pan with the difference between pan of previous frame and next frame
PXreal pan1, pan2;
diff --git a/engines/icb/health_bar_pc.cpp b/engines/icb/health_bar_pc.cpp
index 2a05bb4451b..dc97e1f1e09 100644
--- a/engines/icb/health_bar_pc.cpp
+++ b/engines/icb/health_bar_pc.cpp
@@ -77,9 +77,9 @@ 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 *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
- int32 ret = ob->GetVariable("hits");
- int32 health = ob->GetIntegerVariable(ret);
+ CGame *ob = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
+ int32 ret = CGameObject::GetVariable(ob, "hits");
+ int32 health = CGameObject::GetIntegerVariable(ob, ret);
// Sort out the speed the health bar is moving at
if (targetHealth == -1) {
diff --git a/engines/icb/logic.cpp b/engines/icb/logic.cpp
index b32b81b55ed..80ff6118d7d 100644
--- a/engines/icb/logic.cpp
+++ b/engines/icb/logic.cpp
@@ -460,7 +460,7 @@ void _game_session::Shut_down_object() {
prop_state_table[cur_id] = 0; // set to state 0 - in case killed because of illegal frame
- Tdebug("objects_that_died.txt", "**OBJECT '%s' [id=%d] has been shut down**", object->GetName(), cur_id);
+ Tdebug("objects_that_died.txt", "**OBJECT '%s' [id=%d] has been shut down**", CGameObject::GetName(object), cur_id);
}
mcodeFunctionReturnCodes _game_session::fn_kill_me(int32 &, int32 *) {
@@ -505,7 +505,7 @@ void _game_session::Shut_down_object(const char *ascii) {
prop_state_table[cur_id] = 0; // set to state 0 - in case killed because of illegal frame
- Tdebug("objects_that_died.txt", "**OBJECT '%s' [id=%d] has been shut down** %s", object->GetName(), cur_id, ascii);
+ Tdebug("objects_that_died.txt", "**OBJECT '%s' [id=%d] has been shut down** %s", CGameObject::GetName(object), cur_id, ascii);
}
bool8 _game_session::Console_shut_down_object(const char *name) {
@@ -692,11 +692,11 @@ mcodeFunctionReturnCodes _game_session::fn_new_script(int32 &, int32 *params) {
script_hash = HashString(script_name);
// try and find a script with the passed extention i.e. ???::looping
- for (k = 0; k < object->GetNoScripts(); k++) {
- if (script_hash == object->GetScriptNamePartHash(k)) {
+ for (k = 0; k < CGameObject::GetNoScripts(object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(object, k)) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, k));
// write actual offset
L->logic[1] = ad;
@@ -716,7 +716,7 @@ mcodeFunctionReturnCodes _game_session::fn_new_script(int32 &, int32 *params) {
}
}
- Fatal_error("fn_new_script - cant find script [%s] in object [%s]", script_name, object->GetName());
+ Fatal_error("fn_new_script - cant find script [%s] in object [%s]", script_name, CGameObject::GetName(object));
return IR_CONT; // keep daft compiler happy
}
@@ -732,16 +732,16 @@ mcodeFunctionReturnCodes _game_session::fn_gosub(int32 &, int32 *params) {
script_hash = HashString(script_name);
if (L->logic_level != 1)
- Fatal_error("object [%s] has performed an illegal gosub", object->GetName());
+ Fatal_error("object [%s] has performed an illegal gosub", CGameObject::GetName(object));
// try and find a script with the passed extention i.e. ???::looping
- for (k = 0; k < object->GetNoScripts(); k++) {
+ for (k = 0; k < CGameObject::GetNoScripts(object); k++) {
// now check for actual script name
- if (script_hash == object->GetScriptNamePartHash(k)) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(object, k)) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, k));
// write actual offset
L->logic[2] = ad;
@@ -760,7 +760,7 @@ mcodeFunctionReturnCodes _game_session::fn_gosub(int32 &, int32 *params) {
}
}
- Fatal_error("fn_gosub - cant find script [%s] in object [%s]", script_name, object->GetName());
+ Fatal_error("fn_gosub - cant find script [%s] in object [%s]", script_name, CGameObject::GetName(object));
return IR_CONT; // keep daft compiler happy
}
diff --git a/engines/icb/mega_interaction.cpp b/engines/icb/mega_interaction.cpp
index 02f2f94d06f..90dc9196eda 100644
--- a/engines/icb/mega_interaction.cpp
+++ b/engines/icb/mega_interaction.cpp
@@ -59,7 +59,7 @@ mcodeFunctionReturnCodes _game_session::fn_interact_with_id(int32 &, int32 *para
// params 0 id of target object
// 1 name of script
const char *script_name = (const char *)MemoryUtil::resolvePtr(params[1]);
- c_game_object *target_object;
+ CGame *target_object;
uint32 script_hash;
Zdebug("fn_interact_with_id with object");
@@ -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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, params[0]);
+ target_object = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, params[0]);
// set socket_id ready for any special socket functions
M->target_id = params[0];
@@ -77,13 +77,13 @@ mcodeFunctionReturnCodes _game_session::fn_interact_with_id(int32 &, int32 *para
M->interacting = TRUE8;
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < target_object->GetNoScripts(); k++) {
- if (script_hash == target_object->GetScriptNamePartHash(k)) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(target_object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(target_object, k)) {
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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(target_object, k));
// write actual offset
L->logic[2] = ad;
@@ -99,7 +99,7 @@ mcodeFunctionReturnCodes _game_session::fn_interact_with_id(int32 &, int32 *para
}
}
- Fatal_error("fn_interact_with_id - target object [%d] has not got a [%s] script", params[0], object->GetName());
+ Fatal_error("fn_interact_with_id - target object [%d] has not got a [%s] script", params[0], CGameObject::GetName(object));
return (IR_STOP);
}
@@ -114,7 +114,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_interacts(int32 &, int32 *params
// params 0 name of target object
// 1 name of script
- c_game_object *target_object;
+ CGame *target_object;
uint32 script_hash;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -125,7 +125,7 @@ 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 *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, object_name);
+ target_object = (CGame *)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);
@@ -136,12 +136,12 @@ mcodeFunctionReturnCodes _game_session::fn_mega_interacts(int32 &, int32 *params
M->interacting = TRUE8;
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < target_object->GetNoScripts(); k++) {
- if (script_hash == target_object->GetScriptNamePartHash(k)) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(target_object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(target_object, k)) {
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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(target_object, k));
// write actual offset
L->logic[2] = ad;
@@ -157,7 +157,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_interacts(int32 &, int32 *params
}
}
- Fatal_error("fn_mega_interacts - target object [%s] has not got a [%s] script", object_name, object->GetName());
+ Fatal_error("fn_mega_interacts - target object [%s] has not got a [%s] script", object_name, CGameObject::GetName(object));
return (IR_STOP);
}
@@ -167,7 +167,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_generic_interact(int32 &, int32
// params 0 ascii name of object
- c_game_object *target_object;
+ CGame *target_object;
uint32 script_hash;
const char *object_name = (const char *)MemoryUtil::resolvePtr(params[0]);
@@ -176,7 +176,7 @@ 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 *)LinkedDataObject::Try_fetch_item_by_name(MS->objects, object_name);
+ target_object = (CGame *)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);
@@ -187,13 +187,13 @@ mcodeFunctionReturnCodes _game_session::fn_mega_generic_interact(int32 &, int32
M->interacting = TRUE8;
// now try and find a script with the 'interact' extention i.e. ???::interact
- for (uint32 k = 0; k < target_object->GetNoScripts(); k++) {
- if (script_hash == target_object->GetScriptNamePartHash(k)) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(target_object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(target_object, k)) {
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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(target_object, k));
// write actual offset
L->logic[2] = ad;
@@ -209,7 +209,7 @@ mcodeFunctionReturnCodes _game_session::fn_mega_generic_interact(int32 &, int32
}
}
- Fatal_error("fn_mega_generic_interact - [%s] finds target object [%s] has not got an 'interact' script", object->GetName(), object_name);
+ Fatal_error("fn_mega_generic_interact - [%s] finds target object [%s] has not got an 'interact' script", CGameObject::GetName(object), object_name);
return (IR_STOP);
}
@@ -219,13 +219,13 @@ bool8 _game_session::chi_interacts(int32 id, const char *script_name) {
// set it up on level 2 and change script level
- c_game_object *target_object;
+ CGame *target_object;
uint32 script_hash;
script_hash = HashString(script_name);
// get target object
- target_object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
+ target_object = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!target_object)
Fatal_error("chi_interacts - object [%d] dont exist", id);
@@ -236,11 +236,11 @@ bool8 _game_session::chi_interacts(int32 id, const char *script_name) {
M->interacting = TRUE8;
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < target_object->GetNoScripts(); k++) {
- if (script_hash == target_object->GetScriptNamePartHash(k)) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(target_object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(target_object, k)) {
// script k is the one to run
// get the address of the script we want to run
- char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, target_object->GetScriptNameFullHash(k));
+ char *ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(target_object, k));
// write actual offset
L->logic[2] = ad;
diff --git a/engines/icb/mission.cpp b/engines/icb/mission.cpp
index b4fc49df3fa..c0df1bd46e5 100644
--- a/engines/icb/mission.cpp
+++ b/engines/icb/mission.cpp
@@ -394,7 +394,7 @@ uint32 _mission::Game_cycle() {
void _mission::Save_micro_session() {
// save all object lvars to a micro session
- c_game_object *object;
+ CGame *object;
uint32 j = 0;
uint32 i, k;
uint32 total_fvars = 0;
@@ -423,9 +423,9 @@ 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 *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
+ object = (CGame *)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));
+ Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, CGameObject::GetName(object), CGameObject::GetNoLvars(object), session->Fetch_object_status(i));
micro_sessions[j].micro_objects[i].status_flag = session->Fetch_object_status(i);
// if mega then save coord
@@ -446,14 +446,14 @@ void _mission::Save_micro_session() {
micro_sessions[j].micro_objects[i].total_lvars = 0;
- if (object->GetNoLvars() > MAX_lvars)
- Fatal_error("object [%s] has too many lvars - has %d, only %d allowed", object->GetName(), object->GetNoLvars(), MAX_lvars);
+ if (CGameObject::GetNoLvars(object) > MAX_lvars)
+ Fatal_error("object [%s] has too many lvars - has %d, only %d allowed", CGameObject::GetName(object), CGameObject::GetNoLvars(object), MAX_lvars);
- for (k = 0; k < object->GetNoLvars(); k++) {
- if (!object->IsVariableString(k)) {
- Tdebug("micro_session.txt", " saving lvar %d %s value %d", k, object->GetScriptVariableName(k), object->GetIntegerVariable(k));
+ for (k = 0; k < CGameObject::GetNoLvars(object); k++) {
+ if (!CGameObject::IsVariableString(object, k)) {
+ Tdebug("micro_session.txt", " saving lvar %d %s value %d", k, CGameObject::GetScriptVariableName(object, k), CGameObject::GetIntegerVariable(object, k));
- int32 value = object->GetIntegerVariable(k);
+ int32 value = CGameObject::GetIntegerVariable(object, k);
// Using 14-bits to pack lvar's
int32 packMin = -(1 << 13);
@@ -461,8 +461,8 @@ void _mission::Save_micro_session() {
if ((value < packMin) || (value > packMax)) {
// Don't do a message box for a CD build of the game!
- Message_box("Object '%s' lvar %d '%s' is too big to pack please try and reduce %d range is %d->%d", object->GetName(), k,
- object->GetScriptVariableName(k), value, packMin, packMax);
+ Message_box("Object '%s' lvar %d '%s' is too big to pack please try and reduce %d range is %d->%d", CGameObject::GetName(object), k,
+ CGameObject::GetScriptVariableName(object, k), value, packMin, packMax);
packData = 0;
}
@@ -471,7 +471,7 @@ void _mission::Save_micro_session() {
int32 lvarMax = +((1 << 15) - 1);
if ((value < lvarMin) || (value > lvarMax)) {
- Fatal_error("Object '%s' lvar %d '%s' is too big to save %d range is %d->%d", object->GetName(), k, object->GetScriptVariableName(k), value,
+ Fatal_error("Object '%s' lvar %d '%s' is too big to save %d range is %d->%d", CGameObject::GetName(object), k, CGameObject::GetScriptVariableName(object, k), value,
packMin, packMax);
}
@@ -483,7 +483,7 @@ void _mission::Save_micro_session() {
void _mission::Restore_micro_session_vars() {
// reload all object lvars from a micro session
- c_game_object *object;
+ CGame *object;
uint32 j = 0;
uint32 i, k;
uint32 lvar;
@@ -497,19 +497,19 @@ void _mission::Restore_micro_session_vars() {
// restore lvars
for (i = 0; i < session->Fetch_number_of_objects(); i++) {
- object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
+ object = (CGame *)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(),
+ Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, CGameObject::GetName(object), CGameObject::GetNoLvars(object),
micro_sessions[j].micro_objects[i].status_flag);
session->Set_object_status(i, micro_sessions[j].micro_objects[i].status_flag);
lvar = 0;
- for (k = 0; k < object->GetNoLvars(); k++) {
- if (!object->IsVariableString(k)) {
- Tdebug("micro_session.txt", " restoring lvar %d %s to %d", k, object->GetScriptVariableName(k),
+ for (k = 0; k < CGameObject::GetNoLvars(object); k++) {
+ if (!CGameObject::IsVariableString(object, k)) {
+ Tdebug("micro_session.txt", " restoring lvar %d %s to %d", k, CGameObject::GetScriptVariableName(object, k),
micro_sessions[j].micro_objects[i].lvar_value[lvar]);
// reset lvar value
- object->SetIntegerVariable(k, micro_sessions[j].micro_objects[i].lvar_value[lvar++]);
+ CGameObject::SetIntegerVariable(object, k, micro_sessions[j].micro_objects[i].lvar_value[lvar++]);
}
}
}
@@ -522,7 +522,7 @@ void _mission::Restore_micro_session_vars() {
void _mission::Restore_micro_session_coords(bool8 from_disk) {
// reload all object lvars from a micro session
- c_game_object *object;
+ CGame *object;
uint32 j = 0;
uint32 i;
uint32 index = 0;
@@ -536,9 +536,9 @@ 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 *)LinkedDataObject::Fetch_item_by_number(session->objects, i);
+ object = (CGame *)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(),
+ Tdebug("micro_session.txt", "\n object %d %s, %d vars - status %d", i, CGameObject::GetName(object), CGameObject::GetNoLvars(object),
micro_sessions[j].micro_objects[i].status_flag);
session->Set_object_status(i, 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 1fe9e58d2fd..c740ce10e55 100644
--- a/engines/icb/options_manager_pc.cpp
+++ b/engines/icb/options_manager_pc.cpp
@@ -641,9 +641,9 @@ void OptionsManager::StartGameOverOptions() {
bool8 regularPlayerDeath = TRUE8;
// Have we died under irregular circumstances?
- 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)
+ CGame *playerObj = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, MS->player.Fetch_player_id());
+ int32 state = CGameObject::GetVariable(playerObj, "state");
+ if (CGameObject::GetIntegerVariable(playerObj, state) == 2)
regularPlayerDeath = FALSE8;
InitialiseSounds();
diff --git a/engines/icb/p4.h b/engines/icb/p4.h
index be44be95a76..2920188b4fb 100644
--- a/engines/icb/p4.h
+++ b/engines/icb/p4.h
@@ -93,7 +93,7 @@ extern uint32 SONICS_BUFFER_SIZE;
#define ANIM_CHECK(a) \
if (!I->IsAnimTable(a)) \
Fatal_error("engine finds anim [%s] '%s' %X missing for object [%s]", (const char *)master_anim_name_table[a].name, I->get_info_name(a), I->info_name_hash[a], \
- object->GetName());
+ CGameObject::GetName(object));
enum __stub_modes {
__mission_and_console,
diff --git a/engines/icb/p4_pc.cpp b/engines/icb/p4_pc.cpp
index 8e23eaa38e4..d824a54d1c9 100644
--- a/engines/icb/p4_pc.cpp
+++ b/engines/icb/p4_pc.cpp
@@ -355,9 +355,9 @@ 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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, MS->player.Fetch_player_id());
- int32 ret = ob->GetVariable("state");
- if (ob->GetIntegerVariable(ret)) {
+ CGame *ob = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, MS->player.Fetch_player_id());
+ int32 ret = CGameObject::GetVariable(ob, "state");
+ if (CGameObject::GetIntegerVariable(ob, ret)) {
// Return to avoid deleting the mission
g_stub->Push_stub_mode(__gameover_menu);
return;
diff --git a/engines/icb/player.cpp b/engines/icb/player.cpp
index 27919933202..6fba98c2eca 100644
--- a/engines/icb/player.cpp
+++ b/engines/icb/player.cpp
@@ -236,14 +236,14 @@ __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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
+ MS->socket_object = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
res = MS->Call_socket(cur_interact_id, "gun_shot", &retval);
MS->Set_chi_permission(); // if chi's around she gets permission to start shooting
if (!res)
- Tdebug("gun_shot_errors.txt", "no [%s] for object [%s]", "gun_shot", MS->socket_object->GetName());
+ Tdebug("gun_shot_errors.txt", "no [%s] for object [%s]", "gun_shot", CGameObject::GetName(MS->socket_object));
}
} else {
// no hit play ricochet sound
@@ -556,7 +556,7 @@ mcodeFunctionReturnCodes _player::Gateway() {
// Jake 15/2/98 : set the default
__mode_return ret = __FINISHED_THIS_CYCLE;
int32 bull_per_clip;
- c_game_object *ob;
+ CGame *ob;
// Set the player control mode correctly
switch (g_px->display_mode) {
@@ -738,18 +738,18 @@ mcodeFunctionReturnCodes _player::Gateway() {
interact_lock = TRUE8;
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, player_id);
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, player_id);
// Make sure number of medi-packs is > 0
if (GetNoMediPacks() > 0) {
- hit_var = ob->GetVariable((const char *)"hits");
- hits = ob->GetIntegerVariable(hit_var);
+ hit_var = CGameObject::GetVariable(ob, (const char *)"hits");
+ hits = CGameObject::GetIntegerVariable(ob, hit_var);
if (hits != MAX_HITS) {
new_energy = hits + MAX_HITS / 2;
if (new_energy > MAX_HITS)
new_energy = MAX_HITS;
- ob->SetIntegerVariable(hit_var, new_energy); // full health again
+ CGameObject::SetIntegerVariable(ob, hit_var, new_energy); // full health again
UseMediPacks(1); // use the pack
// Play the medi-pack sound !
RegisterSoundSpecial(defaultUsingMediSfx, addingMediDesc, 127, 0);
@@ -1398,11 +1398,11 @@ __mode_return _player::Process_strike() {
// behind
ret = MS->Call_socket(cur_interact_id, "ko", &retval);
if (!ret)
- Fatal_error("no ko script for object [%s]", MS->socket_object->GetName());
+ Fatal_error("no ko script for object [%s]", CGameObject::GetName(MS->socket_object));
} else { // infront
ret = MS->Call_socket(cur_interact_id, "see_ko", &retval);
if (!ret)
- Fatal_error("no see_ko script for object [%s]", MS->socket_object->GetName());
+ Fatal_error("no see_ko script for object [%s]", CGameObject::GetName(MS->socket_object));
}
MS->Signal_to_other_guards(); // make other guards see this!
return __FINISHED_THIS_CYCLE;
@@ -3139,19 +3139,19 @@ void _game_session::Restart_player() {
player.Reset_player();
int32 var_num;
- c_game_object *ob;
+ CGame *ob;
- ob = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
+ ob = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, player.Fetch_player_id());
- var_num = ob->GetVariable("state");
+ var_num = CGameObject::GetVariable(ob, "state");
if (var_num == -1)
Fatal_error("Restart_player cant fetch state");
- ob->SetIntegerVariable(var_num, 0); // alive
+ CGameObject::SetIntegerVariable(ob, var_num, 0); // alive
- var_num = ob->GetVariable("hits");
+ var_num = CGameObject::GetVariable(ob, "hits");
if (var_num == -1)
Fatal_error("Restart_player cant fetch hits");
- ob->SetIntegerVariable(var_num, MAX_HITS); // another 10 hits
+ CGameObject::SetIntegerVariable(ob, var_num, MAX_HITS); // another 10 hits
L->logic_level = 0; // restart
L->logic_ref[1] = nullptr;
diff --git a/engines/icb/player_interaction.cpp b/engines/icb/player_interaction.cpp
index e63e06046e8..603e2ab6de2 100644
--- a/engines/icb/player_interaction.cpp
+++ b/engines/icb/player_interaction.cpp
@@ -286,7 +286,7 @@ __mode_return _player::Player_interact() {
// __FINISHED_THIS_CYCLE, or
// __MORE_THIS_CYCLE
- c_game_object *iobject;
+ CGame *iobject;
uint32 j;
// first check for auto-interact objects
@@ -295,15 +295,15 @@ __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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
+ iobject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
- Zdebug(" INTERACT with %s", iobject->GetName());
+ Zdebug(" INTERACT with %s", CGameObject::GetName(iobject));
// get the address of the script we want to run
- const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, CGameObject::GetScriptNameFullHash(iobject, OB_ACTION_CONTEXT)); //
if (pc == nullptr)
- Fatal_error("Object [%s] has no interact script", iobject->GetName());
+ Fatal_error("Object [%s] has no interact script", CGameObject::GetName(iobject));
// now run the action context script which may or may not set a new script on level 1
RunScript(pc, iobject);
@@ -315,13 +315,13 @@ __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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, cur_interact_id);
+ iobject = (CGame *)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 *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, iobject->GetScriptNameFullHash(OB_ACTION_CONTEXT)); //
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(MS->scripts, CGameObject::GetScriptNameFullHash(iobject, OB_ACTION_CONTEXT)); //
if (pc == nullptr)
- Fatal_error("Object [%s] has no interact script", iobject->GetName());
+ Fatal_error("Object [%s] has no interact script", CGameObject::GetName(iobject));
interact_lock = TRUE8; // switch the lock on
@@ -391,23 +391,23 @@ mcodeFunctionReturnCodes _game_session::fn_start_player_interaction(int32 &, int
bool8 _game_session::Engine_start_interaction(const char *script, uint32 id) {
// set the current mega object interacting named 'script' in target object 'id'
- c_game_object *iobject;
+ CGame *iobject;
uint32 script_hash;
script_hash = HashString(script);
// get target object
- iobject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
+ iobject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, id);
if (!iobject)
Fatal_error("Engine_start_interaction - named object dont exist"); // should never happen
// now try and find a script with the passed extention i.e. ???::looping
- for (uint32 k = 0; k < iobject->GetNoScripts(); k++) {
+ for (uint32 k = 0; k < CGameObject::GetNoScripts(iobject); k++) {
- if (script_hash == iobject->GetScriptNamePartHash(k)) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(iobject, k)) {
// script k is the one to run
// get the address of the script we want to run
- char *pc = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, iobject->GetScriptNameFullHash(k));
+ char *pc = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(iobject, k));
// set target id
M->target_id = id;
diff --git a/engines/icb/remora.cpp b/engines/icb/remora.cpp
index 8f428a641c8..fd4bdba93e8 100644
--- a/engines/icb/remora.cpp
+++ b/engines/icb/remora.cpp
@@ -981,12 +981,12 @@ void _remora::SetCommonActivateInfo(RemoraMode eMode) {
void _remora::AccessMenuLevelVariables(int32 *pnParams, MenuVariableAccessMode eRetrieve) {
uint32 i, j;
- c_game_object *pGameObject;
+ CGame *pGameObject;
char pcVarName[] = REMORA_MENU_LEVEL_NAME;
uint32 nDigitPos;
// Get the Remora's game object.
- pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_name(MS->objects, REMORA_NAME);
+ pGameObject = (CGame *)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;
@@ -998,24 +998,24 @@ void _remora::AccessMenuLevelVariables(int32 *pnParams, MenuVariableAccessMode e
// Find the variable in the Remora's game object.
j = 0;
- while ((j < pGameObject->GetNoLvars()) && strcmp(pcVarName, pGameObject->GetScriptVariableName(j)))
+ while ((j < CGameObject::GetNoLvars(pGameObject)) && strcmp(pcVarName, CGameObject::GetScriptVariableName(pGameObject, j)))
++j;
// If we ran out of variables, this is an error because we haven't found the one we're looking for.
- if (j == pGameObject->GetNoLvars())
+ if (j == CGameObject::GetNoLvars(pGameObject))
Fatal_error("Failed to find menu variable %s in _remora::AccessMenuLevelVariables()", pcVarName);
// Found it, so get or set it.
if (eRetrieve == GET)
- pnParams[i] = pGameObject->GetIntegerVariable(j);
+ pnParams[i] = CGameObject::GetIntegerVariable(pGameObject, j);
else
- pGameObject->SetIntegerVariable(j, pnParams[i]);
+ CGameObject::SetIntegerVariable(pGameObject, j, pnParams[i]);
}
}
_remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID) const {
__object_type eObjectType;
- c_game_object *pGameObject;
+ CGame *pGameObject;
uint32 nScriptVar, nVarVal;
// If it's player, always return same symbol.
@@ -1037,9 +1037,9 @@ _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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
- nScriptVar = pGameObject->GetVariable("state");
- nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
+ pGameObject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
+ nScriptVar = CGameObject::GetVariable(pGameObject, "state");
+ nVarVal = CGameObject::GetIntegerVariable(pGameObject, nScriptVar);
if (nVarVal == 1)
return (DEAD_HUMAN);
else
@@ -1049,9 +1049,9 @@ _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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
- nScriptVar = pGameObject->GetVariable("state");
- nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
+ pGameObject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
+ nScriptVar = CGameObject::GetVariable(pGameObject, "state");
+ nVarVal = CGameObject::GetIntegerVariable(pGameObject, nScriptVar);
if (nVarVal == 1)
return (DEAD_ROBOT);
else
@@ -1061,9 +1061,9 @@ _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 *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
- nScriptVar = pGameObject->GetVariable("state");
- nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
+ pGameObject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
+ nScriptVar = CGameObject::GetVariable(pGameObject, "state");
+ nVarVal = CGameObject::GetIntegerVariable(pGameObject, nScriptVar);
if (nVarVal == 1)
return (DEAD_HUMAN);
else
@@ -1071,9 +1071,9 @@ _remora::ScreenSymbol _remora::GetSymbolToDrawObject(_logic *pObject, uint32 nID
break;
case (__RECHARGE_POINT):
- pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
- nScriptVar = pGameObject->GetVariable("set_mine");
- nVarVal = pGameObject->GetIntegerVariable(nScriptVar);
+ pGameObject = (CGame *)LinkedDataObject::Fetch_item_by_number(MS->objects, nID);
+ nScriptVar = CGameObject::GetVariable(pGameObject, "set_mine");
+ nVarVal = CGameObject::GetIntegerVariable(pGameObject, nScriptVar);
if (nVarVal == 1)
return (RECHARGE_ARMED);
else
diff --git a/engines/icb/remora_pc.cpp b/engines/icb/remora_pc.cpp
index c8ec1a29e45..91663de7dcf 100644
--- a/engines/icb/remora_pc.cpp
+++ b/engines/icb/remora_pc.cpp
@@ -1087,7 +1087,7 @@ void _remora::DrawPulse() {
int32 nXCoord;
int32 nWhiteValue;
float fHighlightStep, fCurrentHighlight;
- c_game_object *pPlayer;
+ CGame *pPlayer;
uint32 nHits, nHealth;
// Calculate a base drawing point for the whole thing.
@@ -1095,8 +1095,8 @@ void _remora::DrawPulse() {
//nBaseY = REMORA_PULSE_Y;
// Work out player's health.
- pPlayer = (c_game_object *)LinkedDataObject::Fetch_item_by_name(MS->objects, "player");
- nHits = pPlayer->GetIntegerVariable(pPlayer->GetVariable("hits"));
+ pPlayer = (CGame *)LinkedDataObject::Fetch_item_by_name(MS->objects, "player");
+ nHits = CGameObject::GetIntegerVariable(pPlayer, CGameObject::GetVariable(pPlayer, "hits"));
// This counts from 10 down to zero (check player's script for this figure if it changes).
if (nHits > 6)
diff --git a/engines/icb/route_manager.cpp b/engines/icb/route_manager.cpp
index 4ba494de2ff..101023a69cd 100644
--- a/engines/icb/route_manager.cpp
+++ b/engines/icb/route_manager.cpp
@@ -305,7 +305,7 @@ mcodeFunctionReturnCodes _game_session::fn_tiny_route(int32 &result, int32 *para
if (L->looping < 2) {
- Tdebug("route_async.txt", "%s tiny", object->GetName());
+ Tdebug("route_async.txt", "%s tiny", CGameObject::GetName(object));
// check for free router
if (Is_router_busy())
@@ -509,7 +509,7 @@ mcodeFunctionReturnCodes _game_session::fn_route_to_nico(int32 &result, int32 *p
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);
+ Fatal_error("fn_route_to_nico - object [%s] cant find nico [%s]", CGameObject::GetName(object), nico_name);
// build route
if (!Setup_route(result, (int32)monica->x, (int32)monica->z, params[1], __FULL, TRUE8)) {
@@ -796,7 +796,7 @@ mcodeFunctionReturnCodes _game_session::Route_to_near_mega_core(const char *name
} else {
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);
+ Fatal_error("[%s] calling Route_to_near_mega_core - finds neither object or nico named [%s]", CGameObject::GetName(object), name);
// found mega with name!
// check we are within the distance and stop us if so
@@ -897,7 +897,7 @@ mcodeFunctionReturnCodes _game_session::fn_route_to_marker(int32 &result, int32
marker = (_map_marker *)markers.Fetch_marker_by_object_name(marker_name);
if (!marker)
- Fatal_error("fn_route_to_marker - object [%s] cant find marker [%s]", object->GetName(), marker_name);
+ Fatal_error("fn_route_to_marker - object [%s] cant find marker [%s]", CGameObject::GetName(object), marker_name);
// build route
if (!Setup_route(result, (int32)FROM_LE_FLOAT32(marker->x), (int32)FROM_LE_FLOAT32(marker->z), params[1], __FULL, TRUE8)) {
@@ -954,7 +954,7 @@ bool8 _game_session::Setup_route(int32 &result, int32 corex, int32 corez, int32
// quick CAPS check on the anim
if ((!L->voxel_info->IsAnimTable(L->cur_anim_type)))
- Fatal_error("mega [%s] has anim [%s] missing", object->GetName(), master_anim_name_table[L->cur_anim_type].name);
+ Fatal_error("mega [%s] has anim [%s] missing", CGameObject::GetName(object), master_anim_name_table[L->cur_anim_type].name);
// new route do prepare a route request form!
// initial x,z
diff --git a/engines/icb/session.cpp b/engines/icb/session.cpp
index 9d1d6e548ff..d114075f66c 100644
--- a/engines/icb/session.cpp
+++ b/engines/icb/session.cpp
@@ -488,7 +488,7 @@ void _game_session::Init_objects() {
script_hash = HashString("player::globals");
const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, script_hash);
if (pc) {
- object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, id);
+ object = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, id);
Tdebug("objects_init.txt", " initialising globals", (const char *)buf);
RunScript(pc, object);
}
@@ -508,9 +508,9 @@ 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 *)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());
+ object = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, j);
+ Tdebug("objects_init.txt", "\n\n---------------------------------------------------\n%d initialising object '%s'", j, CGameObject::GetName(object));
+ Zdebug("\n\n---------------------------------------------------\n%d initialising object '%s'", j, CGameObject::GetName(object));
Zdebug("[%d]", num_megas);
@@ -527,12 +527,12 @@ 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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_INIT_SCRIPT)); // run init script
+ const char *pc = (const char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, OB_INIT_SCRIPT)); // run init script
if (pc) {
RunScript(pc, object);
- strcpy(buf, object->GetName());
+ strcpy(buf, CGameObject::GetName(object));
strcat(buf, "::local_init");
uint32 script_hash;
@@ -540,7 +540,7 @@ void _game_session::Init_objects() {
script_hash = HashString(buf);
// Jso PSX can have nice session loading screen and details (for timing and to stop player getting bored)
- InitMsg(object->GetName());
+ InitMsg(CGameObject::GetName(object));
Tdebug("objects_init.txt", "search for [%s]", (const char *)buf);
@@ -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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
+ logic_structs[j]->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, 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");
@@ -606,7 +606,7 @@ void _game_session::Init_objects() {
I = L->voxel_info;
M = L->mega;
- object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, id);
+ object = (CGame *)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,10 +669,10 @@ void _game_session::Pre_initialise_objects() {
Zdebug("%d -[%d]", j, num_megas);
- object = (c_game_object *)LinkedDataObject::Fetch_item_by_number(objects, j);
+ object = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, j);
logic_structs[j] = g_logics[j];
- logic_structs[j]->___init((const char *)object->GetName());
+ logic_structs[j]->___init((const char *)CGameObject::GetName(object));
}
// Set up the event manager for this session. This has to be done after the barrier handler
@@ -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 *)LinkedDataObject::Fetch_item_by_number(objects, j);
+ object = (CGame *)LinkedDataObject::Fetch_item_by_number(objects, j);
// run appropriate logic
switch (L->big_mode) {
@@ -921,16 +921,16 @@ void _game_session::Pre_logic_event_check() {
if (L->context_request || g_oEventManager->HasEventPending(cur_id) || g_oSoundLogicEngine->SoundEventPendingForID(cur_id)) {
// Yes, the object has an event pending, so rerun its logic context.
if (L->context_request)
- Zdebug("[%s] internal request to rerun logic context", object->GetName());
+ Zdebug("[%s] internal request to rerun logic context", CGameObject::GetName(object));
else
- Zdebug("[%s] event means rerun logic context", object->GetName());
+ Zdebug("[%s] event means rerun logic context", CGameObject::GetName(object));
if ((L->image_type == VOXEL) && (M->interacting)) { // check for megas who are interacting
// interacting, so ignoring LOS event
Zdebug("interacting, so ignoring LOS event");
} else {
- L->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, (object->GetScriptNameFullHash(OB_LOGIC_CONTEXT)));
+ L->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, (CGameObject::GetScriptNameFullHash(object, 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
@@ -944,7 +944,7 @@ void _game_session::Pre_logic_event_check() {
void _game_session::Script_cycle() {
int32 ret;
- c_game_object *script_owner;
+ CGame *script_owner;
uint32 inner_cycles;
inner_cycles = 0; // to catch infnite_loops
@@ -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 *)LinkedDataObject::Fetch_item_by_number(objects, M->target_id);
+ script_owner = (CGame *)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 *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(OB_LOGIC_CONTEXT));
+ L->logic[0] = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, OB_LOGIC_CONTEXT));
// run script - context chooser will pick a new L 1 logic
RunScript(const_cast<const char *&>(L->logic[0]), object);
@@ -1006,7 +1006,7 @@ void _game_session::Script_cycle() {
// in the Remora's menu's now for it to trip this limit, and genuine infinite loops will
// still be caught.
if (inner_cycles == 1000)
- Fatal_error("object [%s] is in an infinite script loop!", object->GetName());
+ Fatal_error("object [%s] is in an infinite script loop!", CGameObject::GetName(object));
} while (ret); // ret==0 means quit for this object
}
@@ -1149,11 +1149,11 @@ void _game_session::Idle_manager() {
script_hash = HashString("idle");
// try and find a script with the passed extention i.e. ???::looping
- for (k = 0; k < object->GetNoScripts(); k++) {
- if (script_hash == object->GetScriptNamePartHash(k)) {
+ for (k = 0; k < CGameObject::GetNoScripts(object); k++) {
+ if (script_hash == CGameObject::GetScriptNamePartHash(object, k)) {
// script k is the one to run
// get the address of the script we want to run
- ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, object->GetScriptNameFullHash(k));
+ ad = (char *)LinkedDataObject::Try_fetch_item_by_hash(scripts, CGameObject::GetScriptNameFullHash(object, k));
// write actual offset
L->logic[2] = ad;
diff --git a/engines/icb/session.h b/engines/icb/session.h
index 44ac372c4e1..0dd333805e7 100644
--- a/engines/icb/session.h
+++ b/engines/icb/session.h
@@ -684,7 +684,7 @@ public:
bool8 Call_socket(uint32 id, const char *script, int32 *retval);
uint32 socket_id;
- c_game_object *socket_object;
+ CGame *socket_object;
void Create_initial_route(__rtype type);
@@ -1005,7 +1005,7 @@ private:
_logic *L; // current objects logic structure
_vox_image *I; // pointer to current objects _voxel_image structure - megas only
_mega *M; // pointer to current objects _mega struct - megas only
- c_game_object *object; // represents the current game object at logic run time
+ CGame *object; // represents the current game object at logic run time
uint32 script_var_value; // holds script variables passed back via fn_pass_flag_to_engine
// list of ids that are voxel characters - built per game cycle
@@ -1181,22 +1181,22 @@ inline uint32 _game_session::Fetch_session_cluster_hash() {
inline uint32 _game_session::Fetch_object_integer_variable(const char *pcName, const char *pcVar) const {
int32 nVariableNumber;
- c_game_object *pGameObject;
+ CGame *pGameObject;
// Get the object itself.
- pGameObject = (c_game_object *)LinkedDataObject::Fetch_item_by_name(objects, pcName);
+ pGameObject = (CGame *)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);
// Find the position of the requested variable.
- nVariableNumber = pGameObject->GetVariable(pcVar);
+ nVariableNumber = CGameObject::GetVariable(pGameObject, pcVar);
if (nVariableNumber == -1)
Fatal_error("_game_session::Fetch_object_integer_variable( %s, %s ) couldn't find variable", pcName, pcVar);
// Get the lvar.
- return (pGameObject->GetIntegerVariable(nVariableNumber));
+ return (CGameObject::GetIntegerVariable(pGameObject, nVariableNumber));
}
inline PXcamera &_game_session::GetCamera() { return set.GetCamera(); }
diff --git a/engines/icb/speech.cpp b/engines/icb/speech.cpp
index b9d042f7709..935d1d10f76 100644
--- a/engines/icb/speech.cpp
+++ b/engines/icb/speech.cpp
@@ -110,7 +110,7 @@ mcodeFunctionReturnCodes _game_session::fn_request_speech(int32 &result, int32 *
const char *scene_script_name = (const char *)MemoryUtil::resolvePtr(params[0]);
- Zdebug("[%s] fn_request_speech [%s]", object->GetName(), scene_script_name);
+ Zdebug("[%s] fn_request_speech [%s]", CGameObject::GetName(object), scene_script_name);
// there cannot be any other conversations happening - change to initial spec as it is not used and memory is required
if (total_convs) {
@@ -338,7 +338,7 @@ mcodeFunctionReturnCodes _game_session::fn_converse(int32 &, int32 *) {
int32 params;
mcodeFunctionReturnCodes ret;
- Zdebug("fn_converse [%s] - uid %d", object->GetName(), L->conversation_uid);
+ Zdebug("fn_converse [%s] - uid %d", CGameObject::GetName(object), L->conversation_uid);
if (L->conversation_uid == NO_SPEECH_REQUEST) {
// conversation has ended!
@@ -424,7 +424,7 @@ mcodeFunctionReturnCodes _game_session::fn_converse(int32 &, int32 *) {
void _game_session::Service_speech() {
// the system runs all speech scripts
- c_game_object *speech_object;
+ CGame *speech_object;
uint32 ret;
// anything going on?
@@ -452,7 +452,7 @@ 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 *)LinkedDataObject::Fetch_item_by_name(objects, "scenes");
+ speech_object = (CGame *)LinkedDataObject::Fetch_item_by_name(objects, "scenes");
cur_id = LinkedDataObject::Fetch_item_number_by_name(objects, "scenes");
L = logic_structs[cur_id];
I = nullptr;
diff --git a/engines/icb/stagedraw_pc_poly.cpp b/engines/icb/stagedraw_pc_poly.cpp
index a96f2029883..b3bb9e2db3d 100644
--- a/engines/icb/stagedraw_pc_poly.cpp
+++ b/engines/icb/stagedraw_pc_poly.cpp
@@ -447,9 +447,9 @@ 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 *)LinkedDataObject::Fetch_item_by_name(MS->objects, act.log->GetName());
+ CGame *ob = (CGame *)LinkedDataObject::Fetch_item_by_name(MS->objects, act.log->GetName());
- int32 ret = ob->GetVariable("state");
+ int32 ret = CGameObject::GetVariable(ob, "state");
// The snow_suit in Car_5 does not have a state flag
// so can't test ret == -1
@@ -458,7 +458,7 @@ void drawObjects(SDactor &act, PSXLampList &lamplist, PSXrgb *pAmbient, PSXShade
uvframe = -1;
if (ret != -1) {
- ret = ob->GetIntegerVariable(ret);
+ ret = CGameObject::GetIntegerVariable(ob, ret);
// which means ALIVE
if (ret == 0)
uvframe = gameCycle;
More information about the Scummvm-git-logs
mailing list