27 #ifndef ICB_GAME_OBJECT_H 28 #define ICB_GAME_OBJECT_H 30 #include "engines/icb/common/px_rcutypes.h" 40 #define OB_INIT_SCRIPT 0 41 #define OB_LOGIC_CONTEXT 1 42 #define OB_ACTION_CONTEXT 2 47 uint32 m_var_table_offset;
54 uint32 m_script_name_hash_table_offset;
56 uint32 m_lvars_offset;
79 static const char *GetName(
CGame *game);
80 static uint32 GetNoLvars(
CGame *game) ;
81 static uint32 GetNoScripts(
CGame *game);
82 static uint32 GetSize(
CGame *game) {
return FROM_LE_32(game->m_size); }
85 static uint32 GetScriptNameFullHash(
CGame *game, uint32);
86 static uint32 GetScriptNamePartHash(
CGame *game, uint32);
88 static const char *GetScriptVariableName(
CGame *game, uint32);
89 static int32 GetVariable(
CGame *game,
const char *name);
91 static int32 IsVariableString(
CGame *game, uint32);
93 static void SetIntegerVariable(
CGame *game, uint32, int32);
95 static int32 GetIntegerVariable(
CGame *game, uint32);
96 static int32 *GetIntegerVariablePtr(
CGame *game, uint32);
97 static const char *GetStringVariable(
CGame *game, uint32);
99 static const char *GetStringValueOrDefault(
CGame *game,
const char *varName,
const char *defaultStr) {
101 var = GetVariable(game, varName);
105 return GetStringVariable(game, var);
108 static int32 GetIntegerValueOrDefault(
CGame *game,
const char *varName, int32 defaultInt) {
110 var = GetVariable(game, varName);
114 return GetIntegerVariable(game, var);
118 inline const char *CGameObject::GetName(
CGame *game) {
120 return ((
const char *)(((
const char *)game) + game->m_name_offset));
123 inline uint32 CGameObject::GetNoLvars(
CGame *game) {
125 return FROM_LE_32(game->m_noLvars);
128 inline uint32 CGameObject::GetNoScripts(
CGame *game) {
130 return FROM_LE_32(game->m_noScripts);
133 inline uint32 CGameObject::GetScriptNameFullHash(
CGame *game, uint32 scriptNo) {
134 assert(scriptNo < FROM_LE_32(game->m_noScripts));
135 return FROM_LE_32(((
const int32 *)(((
const char *)game) + FROM_LE_32(game->m_script_name_hash_table_offset)))[scriptNo * 2]);
138 inline uint32 CGameObject::GetScriptNamePartHash(
CGame *game, uint32 scriptNo) {
139 assert(scriptNo < FROM_LE_32(game->m_noScripts));
140 return FROM_LE_32(((
const int32 *)(((
const char *)game) + FROM_LE_32(game->m_script_name_hash_table_offset)))[scriptNo * 2 + 1]);
143 inline const char *CGameObject::GetScriptVariableName(
CGame *game, uint32 varNo) {
144 const char *currentPos;
147 currentPos = (((
const char *)game) + FROM_LE_32(game->m_var_table_offset));
148 table = (
const uint32 *)currentPos;
149 return ((
const char *)game) + FROM_LE_32(table[varNo * 2]);
152 inline int32 CGameObject::IsVariableString(
CGame *game, uint32 varNo) {
153 const char *currentPos;
156 currentPos = (((
const char *)game) + FROM_LE_32(game->m_var_table_offset));
157 table = (
const uint32 *)currentPos;
158 return FROM_LE_32(table[varNo * 2 + 1]);
161 inline int32 CGameObject::GetVariable(
CGame *game,
const char *name) {
162 const char *currentPos;
167 currentPos = (((
const char *)game) + FROM_LE_32(game->m_var_table_offset));
168 table = (
const uint32 *)currentPos;
172 for (whichVar = 0; whichVar < FROM_LE_32(game->m_noLvars); whichVar++) {
173 if (strcmp(name, ((
const char *)game) + FROM_LE_32(table[whichVar * 2])) == 0) {
175 whichVar = (int32)FROM_LE_32(game->m_noLvars);
182 inline void CGameObject::SetIntegerVariable(
CGame *game, uint32 lvar, int32 val) {
183 assert(lvar < FROM_LE_32(game->m_noLvars));
184 uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
185 WRITE_LE_UINT32(lvars + lvar, (uint32)val);
188 inline int32 CGameObject::GetIntegerVariable(
CGame *game, uint32 lvar) {
190 assert(lvar < FROM_LE_32(game->m_noLvars));
191 uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
192 return (int32)READ_LE_UINT32(lvars + lvar);
195 inline int32 *CGameObject::GetIntegerVariablePtr(
CGame *game, uint32 lvar) {
197 assert(lvar < FROM_LE_32(game->m_noLvars));
198 uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
199 return (int32 *)(lvars + lvar);
202 inline const char *CGameObject::GetStringVariable(
CGame *game, uint32 lvar) {
204 assert(lvar < FROM_LE_32(game->m_noLvars));
205 uint32 *lvars = (uint32 *)((byte *)game + FROM_LE_32(game->m_lvars_offset));
206 return (
const char *)game + (int32)READ_LE_UINT32(lvars + lvar);
Definition: px_game_object.h:71
Definition: px_game_object.h:44