Initial implementations to support world teleportation via console, Add CVar for logging script messages

This commit is contained in:
Phillip Stephens 2018-06-12 19:07:13 -07:00
parent 00a4cbdac7
commit f6719cbec1
6 changed files with 28 additions and 8 deletions

View File

@ -77,6 +77,7 @@ public:
const SResInfo* GetResInfoForLoadPreferForward(CAssetId id) const;
const SResInfo* GetResInfoForLoadDirectionless(CAssetId id) const;
const SResInfo* GetResInfo(CAssetId id) const;
bool IsWorldPak() const { return x28_26_worldPak; }
u32 GetFakeStaticSize() const { return 0; }
void AsyncIdle();
};

View File

@ -54,6 +54,7 @@ public:
std::vector<std::pair<std::string, SObjectTag>> GetResourceIdToNameList() const;
void EnumerateResources(const std::function<bool(const SObjectTag&)>& lambda) const;
void EnumerateNamedResources(const std::function<bool(std::string_view, const SObjectTag&)>& lambda) const;
const std::list<std::unique_ptr<CPakFile>>& GetPaks() const { return x18_pakLoadedList; }
};
}

View File

@ -53,6 +53,7 @@
#include "World/CScriptDoor.hpp"
#include "World/CScriptDamageableTrigger.hpp"
#include "World/CScriptDebris.hpp"
#include "hecl/CVarManager.hpp"
#include <cmath>
namespace urde
@ -213,6 +214,8 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
ControlMapper::ResetCommandFilters();
x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow");
g_StateManager = this;
hecl::CVarManager::instance()->findOrMakeCVar("stateManager.logScripting"sv, "Prints object communication to the console", false, hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game);
}
CStateManager::~CStateManager()
@ -1090,10 +1093,10 @@ void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMes
{
if (dest && !dest->x30_26_scriptingBlocked)
{
#ifndef NDEBUG
LogModule.report(logvisor::Info, "Sending '%s' to '%s' id= 0x%.4X\n",
ScriptObjectMessageToStr(msg).data(), dest->GetName().data(), dest->GetUniqueId().id);
#endif
const hecl::CVar* logScripting = hecl::CVarManager::instance()->findCVar("stateManager.logScripting"sv);
if (logScripting && logScripting->toBoolean())
LogModule.report(logvisor::Info, "Sending '%s' to '%s' id= 0x%.4X\n",
ScriptObjectMessageToStr(msg).data(), dest->GetName().data(), dest->GetUniqueId().id);
dest->AcceptScriptMsg(msg, src, *this);
}
}

View File

@ -113,8 +113,8 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent,
CStreamAudioManager::SetMusicVolume(0x7f);
m->ResetGameState();
//std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
//x58_ioWinManager.AddIOWin(splash, 1000, 10000);
std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
x58_ioWinManager.AddIOWin(splash, 1000, 10000);
std::shared_ptr<CIOWin> mf = std::make_shared<CMainFlow>();
x58_ioWinManager.AddIOWin(mf, 0, 0);
@ -537,6 +537,20 @@ void CMain::Teleport(hecl::Console *, const std::vector<std::string>& args)
g_StateManager->Player()->Teleport(xf, *g_StateManager, false);
}
void CMain::ListWorlds(hecl::Console* con, const std::vector<std::string> &)
{
if (g_ResFactory && g_ResFactory->GetResLoader())
{
for (const auto& pak : g_ResFactory->GetResLoader()->GetPaks())
if (pak->IsWorldPak())
{
for (const auto& named : pak->GetNameList())
if (named.second.type == SBIG('MLVL'))
con->report(hecl::Console::Level::Info, "%s '%08X'", named.first.c_str(), named.second.id.Value());
}
}
}
void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx)
{
bool fusionBackup = g_GameState->SystemOptions().GetPlayerFusionSuitActive();
@ -641,7 +655,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer));
m_console->registerCommand("listWorlds"sv, "Lists loaded worlds"sv, ""sv, std::bind(&CMain::ListWorlds, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal);
InitializeSubsystems(storeMgr);
x128_globalObjects.PostInitialize();

View File

@ -333,6 +333,7 @@ public:
}
void Give(hecl::Console*, const std::vector<std::string>&);
void Teleport(hecl::Console*, const std::vector<std::string>&);
void ListWorlds(hecl::Console*, const std::vector<std::string>&);
hecl::Console* Console() const { return m_console.get(); }
};

2
hecl

@ -1 +1 @@
Subproject commit 667d4113b5475de7d25abc3807ee126749f90aa9
Subproject commit 01d4e0621e749a090d5d0bc992f529fcb714aab9