Skip to content

Commit

Permalink
Remove CAI_Space::script_engine() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 6, 2018
1 parent 9e56983 commit a25e635
Show file tree
Hide file tree
Showing 69 changed files with 546 additions and 554 deletions.
2 changes: 1 addition & 1 deletion src/xrGame/ActorCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ void CActorCondition::UpdateTutorialThresholds()
if (!b)
{
luabind::functor<void> fl;
R_ASSERT(ai().script_engine().functor<void>(cb_name, fl));
R_ASSERT(GEnv.ScriptEngine->functor<void>(cb_name, fl));
fl();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ActorEffector_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BOOL CAnimatorCamEffectorScriptCB::Valid()
if (!res && cb_name.size())
{
luabind::functor<void> fl;
R_ASSERT(ai().script_engine().functor<void>(*cb_name, fl));
R_ASSERT(GEnv.ScriptEngine->functor<void>(*cb_name, fl));
fl();
cb_name = "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC)
//R_ASSERT(Level().Objects.net_Find(E->ID) == nullptr);
if (Level().Objects.net_Find(E->ID) != nullptr)
{
ai().script_engine().script_log(LuaMessageType::Error, "CGameObject:net_Spawn() | Level().Objects.net_Find(E->ID) != nullptr (This mean object already exist on level by this ID) ID=%s s_name=%s", E->ID, E->s_name);
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CGameObject:net_Spawn() | Level().Objects.net_Find(E->ID) != nullptr (This mean object already exist on level by this ID) ID=%s s_name=%s", E->ID, E->s_name);
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/GamePersistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,12 @@ void CGamePersistent::LoadTitle(bool change_tip, shared_str map_name)
bool is_single = !xr_strcmp(m_game_params.m_game_type, "single");
if (is_single)
{
R_ASSERT(ai().script_engine().functor("loadscreen.get_tip_number", m_functor));
R_ASSERT(GEnv.ScriptEngine->functor("loadscreen.get_tip_number", m_functor));
tip_num = m_functor(map_name.c_str());
}
else
{
R_ASSERT(ai().script_engine().functor("loadscreen.get_mp_tip_number", m_functor));
R_ASSERT(GEnv.ScriptEngine->functor("loadscreen.get_mp_tip_number", m_functor));
tip_num = m_functor(map_name.c_str());
}
// tip_num = 83;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/GameTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void SScriptTaskHelper::init_functors(xr_vector<shared_str>& v_src, task_state_f

for (u32 idx = 0; it != it_e; ++it, ++idx)
{
bool functor_exists = ai().script_engine().functor(*(*it), v_dest[idx]);
bool functor_exists = GEnv.ScriptEngine->functor(*(*it), v_dest[idx]);
if (!functor_exists)
Log("Cannot find script function described in task objective ", *(*it));
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ CInventoryItem* CInventory::tpfGetObjectByIndex(int iIndex)
}
else
{
ai().script_engine().script_log(LuaMessageType::Error, "invalid inventory index!");
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "invalid inventory index!");
return (0);
}
R_ASSERT(false);
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ CLevel::~CLevel()
xr_delete(m_debug_renderer);
#endif
if (!GEnv.isDedicatedServer)
ai().script_engine().remove_script_process(ScriptProcessor::Level);
GEnv.ScriptEngine->remove_script_process(ScriptProcessor::Level);
xr_delete(game);
xr_delete(game_events);
xr_delete(m_pBulletManager);
Expand Down Expand Up @@ -555,7 +555,7 @@ void CLevel::OnFrame()
#endif
g_pGamePersistent->Environment().SetGameTime(GetEnvironmentGameDayTimeSec(), game->GetEnvironmentGameTimeFactor());
if (!GEnv.isDedicatedServer)
ai().script_engine().script_process(ScriptProcessor::Level)->update();
GEnv.ScriptEngine->script_process(ScriptProcessor::Level)->update();
m_ph_commander->update();
m_ph_commander_scripts->update();
stats.BulletManagerCommit.Begin();
Expand Down Expand Up @@ -590,7 +590,7 @@ void CLevel::OnFrame()
}

int psLUA_GCSTEP = 10;
void CLevel::script_gc() { lua_gc(ai().script_engine().lua(), LUA_GCSTEP, psLUA_GCSTEP); }
void CLevel::script_gc() { lua_gc(GEnv.ScriptEngine->lua(), LUA_GCSTEP, psLUA_GCSTEP); }
#ifdef DEBUG_PRECISE_PATH
void test_precise_path();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Level_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void CLevel::IR_OnKeyboardPress(int key)
// m_bSynchronization = false;
// }
// luabind::functor<void> functor;
// ai().script_engine().functor("alife_test.set_switch_online",functor);
// GEnv.ScriptEngine->functor("alife_test.set_switch_online",functor);
// functor(0,false);
// }
// return;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Level_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool CLevel::Load_GameSpecific_After()
if (!GEnv.isDedicatedServer)
{
// loading scripts
auto& scriptEngine = ai().script_engine();
auto& scriptEngine = *GEnv.ScriptEngine;
scriptEngine.remove_script_process(ScriptProcessor::Level);
shared_str scripts;
if (pLevel->section_exist("level_scripts") && pLevel->line_exist("level_scripts", "script"))
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/Level_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void CLevel::remove_objects()
g_b_ClearGameCaptions = true;

if (!GEnv.isDedicatedServer)
ai().script_engine().collect_all_garbage();
GEnv.ScriptEngine->collect_all_garbage();

stalker_animation_data_storage().clear();

Expand Down Expand Up @@ -163,7 +163,7 @@ void CLevel::net_Stop()
}

if (!GEnv.isDedicatedServer)
ai().script_engine().collect_all_garbage();
GEnv.ScriptEngine->collect_all_garbage();

#ifdef DEBUG
show_animation_stats();
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/Level_network_spawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void CLevel::g_sv_Spawn(CSE_Abstract* E)
u32 E_mem = 0;
if (g_bMEMO)
{
lua_gc(ai().script_engine().lua(), LUA_GCCOLLECT, 0);
lua_gc(ai().script_engine().lua(), LUA_GCCOLLECT, 0);
lua_gc(GEnv.ScriptEngine->lua(), LUA_GCCOLLECT, 0);
lua_gc(GEnv.ScriptEngine->lua(), LUA_GCCOLLECT, 0);
E_mem = Memory.mem_usage();
Memory.stat_calls = 0;
}
Expand Down Expand Up @@ -197,8 +197,8 @@ void CLevel::g_sv_Spawn(CSE_Abstract* E)
#ifdef DEBUG_MEMORY_MANAGER
if (g_bMEMO)
{
lua_gc(ai().script_engine().lua(), LUA_GCCOLLECT, 0);
lua_gc(ai().script_engine().lua(), LUA_GCCOLLECT, 0);
lua_gc(GEnv.ScriptEngine->lua(), LUA_GCCOLLECT, 0);
lua_gc(GEnv.ScriptEngine->lua(), LUA_GCCOLLECT, 0);
Msg("* %20s : %d bytes, %d ops", *E->s_name, Memory.mem_usage() - E_mem, Memory.stat_calls);
}
#endif // DEBUG_MEMORY_MANAGER
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/PDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void CPda::PlayScriptFunction()
if (xr_strcmp(m_functor_str, ""))
{
luabind::functor<void> m_functor;
R_ASSERT(ai().script_engine().functor(m_functor_str.c_str(), m_functor));
R_ASSERT(GEnv.ScriptEngine->functor(m_functor_str.c_str(), m_functor));
m_functor();
}
}
4 changes: 2 additions & 2 deletions src/xrGame/PhraseDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ LPCSTR CPhraseDialog::GetPhraseText(const shared_str& phrase_id, bool current_sp
if (ph->m_script_text_id.length() > 0)
{
luabind::functor<LPCSTR> lua_function;
bool functor_exists = ai().script_engine().functor(ph->m_script_text_id.c_str(), lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(ph->m_script_text_id.c_str(), lua_function);
THROW3(functor_exists, "Cannot find function", ph->m_script_text_id.c_str());

ph->m_script_text_val =
Expand Down Expand Up @@ -225,7 +225,7 @@ void CPhraseDialog::load_shared(LPCSTR)
LPCSTR func = pXML->Read(dialog_node, "init_func", 0, "");

luabind::functor<void> lua_function;
bool functor_exists = ai().script_engine().functor(func, lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(func, lua_function);
THROW3(functor_exists, "Cannot find precondition", func);
lua_function(this);
return;
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/PhraseScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ LPCSTR CDialogScriptHelper::GetScriptText(LPCSTR str_to_translate, const CGameOb
return str_to_translate;

luabind::functor<LPCSTR> lua_function;
bool functor_exists = ai().script_engine().functor(m_sScriptTextFunc.c_str(), lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(m_sScriptTextFunc.c_str(), lua_function);
THROW3(functor_exists, "Cannot find phrase script text ", m_sScriptTextFunc.c_str());

LPCSTR res = lua_function(pSpeakerGO1->lua_game_object(), pSpeakerGO2->lua_game_object(), dialog_id, phrase_id);
Expand All @@ -108,7 +108,7 @@ bool CDialogScriptHelper::Precondition(const CGameObject* pSpeakerGO, LPCSTR dia
{
luabind::functor<bool> lua_function;
THROW(*Preconditions()[i]);
bool functor_exists = ai().script_engine().functor(*Preconditions()[i], lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(*Preconditions()[i], lua_function);
THROW3(functor_exists, "Cannot find precondition", *Preconditions()[i]);
predicate_result = lua_function(pSpeakerGO->lua_game_object());
if (!predicate_result)
Expand All @@ -129,7 +129,7 @@ void CDialogScriptHelper::Action(const CGameObject* pSpeakerGO, LPCSTR dialog_id
{
luabind::functor<void> lua_function;
THROW(*Actions()[i]);
bool functor_exists = ai().script_engine().functor(*Actions()[i], lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(*Actions()[i], lua_function);
THROW3(functor_exists, "Cannot find phrase dialog script function", *Actions()[i]);
lua_function(pSpeakerGO->lua_game_object(), dialog_id);
}
Expand All @@ -153,7 +153,7 @@ bool CDialogScriptHelper::Precondition(const CGameObject* pSpeakerGO1, const CGa
{
luabind::functor<bool> lua_function;
THROW(*Preconditions()[i]);
bool functor_exists = ai().script_engine().functor(*Preconditions()[i], lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(*Preconditions()[i], lua_function);
THROW3(functor_exists, "Cannot find phrase precondition", *Preconditions()[i]);
predicate_result = lua_function(
pSpeakerGO1->lua_game_object(), pSpeakerGO2->lua_game_object(), dialog_id, phrase_id, next_phrase_id);
Expand All @@ -178,7 +178,7 @@ void CDialogScriptHelper::Action(
{
luabind::functor<void> lua_function;
THROW(*Actions()[i]);
bool functor_exists = ai().script_engine().functor(*Actions()[i], lua_function);
bool functor_exists = GEnv.ScriptEngine->functor(*Actions()[i], lua_function);
THROW3(functor_exists, "Cannot find phrase dialog script function", *Actions()[i]);
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/monsters/basemonster/base_monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ void CBaseMonster::ChangeTeam(int team, int squad, int group)
#ifdef DEBUG
if (!g_Alive())
{
ai().script_engine().print_stack();
GEnv.ScriptEngine->print_stack();
VERIFY2(g_Alive(), "you are trying to change team of a dead entity");
}
#endif // DEBUG
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/ai/stalker/ai_stalker_script_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction)
l_tObjectAction.m_bCompleted = true;
}
else
ai().script_engine().script_log(
GEnv.ScriptEngine->script_log(
LuaMessageType::Error, "cannot reload active item because it is not selected!");

// if (inventory().ActiveItem()) {
Expand All @@ -252,7 +252,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction)
// l_tObjectAction.m_bCompleted = true;
// }
// else
// ai().script_engine().script_log(LuaMessageType::Error,"cannot reload active item because it is
// GEnv.ScriptEngine->script_log(LuaMessageType::Error, "cannot reload active item because it is
// not
// selected!");
break;
Expand Down Expand Up @@ -298,7 +298,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction)
{
if (inventory().GetItemFromInventory(*l_tObjectAction.m_tpObject->cName()))
{
ai().script_engine().script_log(LuaMessageType::Error, "item is already in the inventory!");
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "item is already in the inventory!");
return ((l_tObjectAction.m_bCompleted = true) == false);
}
feel_touch_new(l_tObjectAction.m_tpObject);
Expand All @@ -309,7 +309,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction)
{
if (!inventory().GetItemFromInventory(*l_tObjectAction.m_tpObject->cName()))
{
ai().script_engine().script_log(LuaMessageType::Error, "item is not in the inventory!");
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "item is not in the inventory!");
return ((l_tObjectAction.m_bCompleted = true) == false);
}
DropItemSendMessage(l_tObjectAction.m_tpObject);
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/ai_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ void CAI_Space::RegisterScriptClasses()
{
_GetItem(*registrators, i, I);
luabind::functor<void> result;
if (!script_engine().functor(I, result))
if (!GEnv.ScriptEngine->functor(I, result))
{
script_engine().script_log(LuaMessageType::Error, "Cannot load class registrator %s!", I);
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "Cannot load class registrator %s!", I);
continue;
}
result(const_cast<CObjectFactory*>(&object_factory()));
Expand Down Expand Up @@ -115,7 +115,7 @@ void CAI_Space::LoadCommonScripts()
for (u32 i = 0; i < scriptCount; i++)
{
_GetItem(*scriptString, i, scriptName);
script_engine().load_file(scriptName, script_engine().GlobalNamespace);
GEnv.ScriptEngine->load_file(scriptName, CScriptEngine::GlobalNamespace);
}
}
xr_delete(l_tpIniFile);
Expand Down Expand Up @@ -160,7 +160,7 @@ void CAI_Space::unload(bool reload)
{
if (GEnv.isDedicatedServer)
return;
script_engine().unload();
GEnv.ScriptEngine->unload();
xr_delete(m_doors_manager);
AISpaceBase::Unload(reload);
}
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/ai_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class CAI_Space : public AISpaceBase
IC const CALifeSimulator& alife() const;
IC const CALifeSimulator* get_alife() const;
IC const CCoverManager& cover_manager() const;
// XXX: [ai] delete
IC CScriptEngine& script_engine() const;
IC moving_objects& moving_objects() const;
IC doors::manager& doors() const;
};
Expand Down
6 changes: 0 additions & 6 deletions src/xrGame/ai_space_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ IC const CCoverManager& CAI_Space::cover_manager() const
VERIFY(m_cover_manager);
return (*m_cover_manager);
}
// XXX: [ai] delete
IC CScriptEngine& CAI_Space::script_engine() const
{
VERIFY(GEnv.ScriptEngine);
return (*GEnv.ScriptEngine);
}

IC moving_objects& CAI_Space::moving_objects() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CALifeSimulator::CALifeSimulator(IPureServer* server, shared_str* command_line)

LPCSTR start_game_callback = pSettings->r_string(alife_section, "start_game_callback");
luabind::functor<void> functor;
R_ASSERT2(ai().script_engine().functor(start_game_callback, functor), "failed to get start game callback");
R_ASSERT2(GEnv.ScriptEngine->functor(start_game_callback, functor), "failed to get start game callback");
functor();

load(p.m_game_or_spawn, !xr_strcmp(p.m_new_or_load, "load") ? false : true, !xr_strcmp(p.m_new_or_load, "new"));
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/alife_storage_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void CALifeStorageManager::save(LPCSTR save_name_no_check, bool update_name)
//Alundaio: To get the savegame fname to make our own custom save states
#ifdef ENGINE_LUA_ALIFE_STORAGE_MANAGER_CALLBACKS
luabind::functor<void> funct;
ai().script_engine().functor("alife_storage_manager.CALifeStorageManager_save", funct);
GEnv.ScriptEngine->functor("alife_storage_manager.CALifeStorageManager_save", funct);
if (funct)
funct(static_cast<pcstr>(m_save_name));
#endif
Expand All @@ -114,7 +114,7 @@ void CALifeStorageManager::load(void* buffer, const u32& buffer_size, LPCSTR fil
//Alundaio: So we can get the fname to make our own custom save states
#ifdef ENGINE_LUA_ALIFE_STORAGE_MANAGER_CALLBACKS
luabind::functor<void> funct;
ai().script_engine().functor("alife_storage_manager.CALifeStorageManager_load", funct);
GEnv.ScriptEngine->functor("alife_storage_manager.CALifeStorageManager_load", funct);
if (funct)
funct(file_name);
#endif // _DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_update_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool CALifeUpdateManager::change_level(NET_Packet& net_packet)

#ifdef ENGINE_LUA_ALIFE_UPDAGE_MANAGER_CALLBACKS
luabind::functor<void> funct;
ai().script_engine().functor("_G.CALifeUpdateManager__on_before_change_level", funct);
GEnv.ScriptEngine->functor("_G.CALifeUpdateManager__on_before_change_level", funct);
if (funct)
funct(&net_packet);
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/base_client_classes_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ISheduledWrapper : public heritage<base, luabind_base>::result

/* static float shedule_Scale_static (base *self)
{
ai().script_engine().script_log(LuaMessageType::Error,"You are trying to call a pure virtual function
GEnv.ScriptEngine->script_log(LuaMessageType::Error,"You are trying to call a pure virtual function
ISheduled::shedule_Scale!\nReturning default value 1000.0");
return (1000.f);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ class IRenderableWrapper : public heritage<base, luabind_base>::result
static void renderable_Render_static (IRenderable *self)
{
ai().script_engine().script_log(LuaMessageType::Error,"You are trying to call a pure virtual function
GEnv.ScriptEngine->script_log(LuaMessageType::Error,"You are trying to call a pure virtual function
IRenderable::renderable_Render!");
}
Expand Down Expand Up @@ -289,7 +289,7 @@ class CEntityWrapper : public CEntity, public luabind::wrap_base

static void HitSignal_static(CEntity* self, float P, Fvector& local_dir, IGameObject* who, s16 element)
{
ai().script_engine().script_log(
GEnv.ScriptEngine->script_log(
LuaMessageType::Error, "You are trying to call a pure virtual function CEntity::HitSignal!");
}

Expand All @@ -300,7 +300,7 @@ class CEntityWrapper : public CEntity, public luabind::wrap_base

static void HitImpulse_static(float P, Fvector& vWorldDir, Fvector& vLocalDir)
{
ai().script_engine().script_log(
GEnv.ScriptEngine->script_log(
LuaMessageType::Error, "You are trying to call a pure virtual function CEntity::HitImpulse!");
}
};
Loading

0 comments on commit a25e635

Please sign in to comment.