Skip to content
Prev Previous commit
Next Next commit
tweak: entt 3.10.0 changes
  • Loading branch information
Yamashi committed Apr 25, 2022
commit 382fdbe441202c8d0767a49344a0c0aafd352e3f
2 changes: 1 addition & 1 deletion Code/client/Games/Skyrim/BSGraphics/BSGraphicsRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Hook_Renderer_Init(Renderer* self, BSGraphics::RendererInitOSData* aOSData,

Renderer_Init(self, aOSData, aFBData, aOut);

g_sRs = &World::Get().ctx<RenderSystemD3D11>();
g_sRs = &World::Get().ctx().at<RenderSystemD3D11>();
// This how the game does it too
g_RenderWindow = &self->Data.RenderWindowA[0];

Expand Down
5 changes: 2 additions & 3 deletions Code/client/Games/Skyrim/Interface/MenuControls.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once

class MenuControls
struct MenuControls
{
public:
static MenuControls* GetInstance();

void SetToggle(bool);

private:
private:
char pad_0000[128]; // 0x0000
bool isProcessing; // 0x0080
bool isBeastForm; // 0x0081
Expand Down
6 changes: 3 additions & 3 deletions Code/client/Services/Generic/InputService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ LRESULT CALLBACK InputService::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR
if (!pRenderer)
return 0;

auto &discord = World::Get().ctx<DiscordService>();
auto &discord = World::Get().ctx().at<DiscordService>();
discord.WndProcHandler(hwnd, uMsg, wParam, lParam);

const bool active = s_pOverlay->GetActive();
if (active)
{
auto& imgui = World::Get().ctx<ImguiService>();
auto& imgui = World::Get().ctx().at<ImguiService>();
imgui.WndProcHandler(hwnd, uMsg, wParam, lParam);
}

Expand All @@ -348,7 +348,7 @@ LRESULT CALLBACK InputService::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR

if (active)
{
auto& imgui = World::Get().ctx<ImguiService>();
auto& imgui = World::Get().ctx().at<ImguiService>();
imgui.RawInputHandler(input);
}

Expand Down
2 changes: 1 addition & 1 deletion Code/client/Services/Generic/TransportService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void TransportService::OnConnected()

// null if discord is not active
// TODO: think about user opt out
request.DiscordId = m_world.ctx<DiscordService>().GetUser().id;
request.DiscordId = m_world.ctx().at<DiscordService>().GetUser().id;
auto* pNpc = Cast<TESNPC>(PlayerCharacter::Get()->baseForm);
if (pNpc)
{
Expand Down
6 changes: 3 additions & 3 deletions Code/client/Services/PapyrusService.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ template <class Return, class Type, class... Args> struct LatentPapyrusFunction
TFunction m_pFunction;
};

#define PAPYRUS_FUNCTION(returnType, scope, name, ...) static PapyrusFunction<returnType, scope, __VA_ARGS__> s_p##name(World::Get().ctx<PapyrusService>().Get(#scope, #name));
#define GLOBAL_PAPYRUS_FUNCTION(returnType, scope, name, ...) static GlobalPapyrusFunction<returnType, __VA_ARGS__> s_p##name(World::Get().ctx<PapyrusService>().Get(#scope, #name));
#define LATENT_PAPYRUS_FUNCTION(returnType, scope, name, ...) static LatentPapyrusFunction<returnType, scope, __VA_ARGS__> s_p##name(World::Get().ctx<PapyrusService>().Get(#scope, #name));
#define PAPYRUS_FUNCTION(returnType, scope, name, ...) static PapyrusFunction<returnType, scope, __VA_ARGS__> s_p##name(World::Get().ctx().at<PapyrusService>().Get(#scope, #name));
#define GLOBAL_PAPYRUS_FUNCTION(returnType, scope, name, ...) static GlobalPapyrusFunction<returnType, __VA_ARGS__> s_p##name(World::Get().ctx().at<PapyrusService>().Get(#scope, #name));
#define LATENT_PAPYRUS_FUNCTION(returnType, scope, name, ...) static LatentPapyrusFunction<returnType, scope, __VA_ARGS__> s_p##name(World::Get().ctx().at<PapyrusService>().Get(#scope, #name));
4 changes: 2 additions & 2 deletions Code/client/TiltedOnlineApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void* TiltedOnlineApp::GetMainAddress() const
bool TiltedOnlineApp::BeginMain()
{
World::Create();
World::Get().ctx<DiscordService>().Init();
World::Get().set<RenderSystemD3D11>(World::Get().ctx<OverlayService>(), World::Get().ctx<ImguiService>());
World::Get().ctx().at<DiscordService>().Init();
World::Get().ctx().emplace<RenderSystemD3D11>(World::Get().ctx().at<OverlayService>(), World::Get().ctx().at<ImguiService>());

LoadScriptExender();
return true;
Expand Down
40 changes: 20 additions & 20 deletions Code/client/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ World::World()
, m_modSystem(m_dispatcher)
, m_lastFrameTime{ std::chrono::high_resolution_clock::now() }
{
set<ImguiService>();
set<DiscoveryService>(*this, m_dispatcher);
set<EntityService>(*this, m_dispatcher);
set<OverlayService>(*this, m_transport, m_dispatcher);
set<InputService>(ctx<OverlayService>());
set<CharacterService>(*this, m_dispatcher, m_transport);
set<TestService>(m_dispatcher, *this, m_transport, ctx<ImguiService>());
set<ScriptService>(*this, m_dispatcher, ctx<ImguiService>(), m_transport);
set<PapyrusService>(m_dispatcher);
set<DiscordService>(m_dispatcher);
set<EnvironmentService>(*this, m_dispatcher, ctx<ImguiService>(), m_transport);
set<QuestService>(*this, m_dispatcher, ctx<ImguiService>());
set<PartyService>(m_dispatcher, m_transport);
set<ActorValueService>(*this, m_dispatcher, m_transport);
set<InventoryService>(*this, m_dispatcher, m_transport);
set<MagicService>(*this, m_dispatcher, m_transport);
set<CommandService>(*this, m_transport, m_dispatcher);
ctx().emplace<ImguiService>();
ctx().emplace<DiscoveryService>(*this, m_dispatcher);
ctx().emplace<EntityService>(*this, m_dispatcher);
ctx().emplace<OverlayService>(*this, m_transport, m_dispatcher);
ctx().emplace<InputService>(ctx().at<OverlayService>());
ctx().emplace<CharacterService>(*this, m_dispatcher, m_transport);
ctx().emplace<TestService>(m_dispatcher, *this, m_transport, ctx().at<ImguiService>());
ctx().emplace<ScriptService>(*this, m_dispatcher, ctx().at<ImguiService>(), m_transport);
ctx().emplace<PapyrusService>(m_dispatcher);
ctx().emplace<DiscordService>(m_dispatcher);
ctx().emplace<EnvironmentService>(*this, m_dispatcher, ctx().at<ImguiService>(), m_transport);
ctx().emplace<QuestService>(*this, m_dispatcher, ctx().at<ImguiService>());
ctx().emplace<PartyService>(m_dispatcher, m_transport);
ctx().emplace<ActorValueService>(*this, m_dispatcher, m_transport);
ctx().emplace<InventoryService>(*this, m_dispatcher, m_transport);
ctx().emplace<MagicService>(*this, m_dispatcher, m_transport);
ctx().emplace<CommandService>(*this, m_transport, m_dispatcher);
}

World::~World() = default;
Expand Down Expand Up @@ -88,13 +88,13 @@ uint64_t World::GetTick() const noexcept

void World::Create() noexcept
{
if(entt::service_locator<World>::empty())
if(entt::locator<World>::has_value())
{
entt::service_locator<World>::set(std::make_shared<World>());
entt::locator<World>::emplace();
}
}

World& World::Get() noexcept
{
return entt::service_locator<World>::ref();
return entt::locator<World>::value();
}
8 changes: 4 additions & 4 deletions Code/client/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ struct World : entt::registry
TransportService& GetTransport() noexcept;
ModSystem& GetModSystem() noexcept;

PartyService& GetPartyService() noexcept { return ctx<PartyService>(); }
const PartyService& GetPartyService() const noexcept { return ctx<const PartyService>(); }
OverlayService& GetOverlayService() noexcept { return ctx<OverlayService>(); }
const OverlayService& GetOverlayService() const noexcept { return ctx<const OverlayService>(); }
PartyService& GetPartyService() noexcept { return ctx().at<PartyService>(); }
const PartyService& GetPartyService() const noexcept { return ctx().at<const PartyService>(); }
OverlayService& GetOverlayService() noexcept { return ctx().at<OverlayService>(); }
const OverlayService& GetOverlayService() const noexcept { return ctx().at<const OverlayService>(); }

auto &GetDispatcher() noexcept
{
Expand Down
2 changes: 1 addition & 1 deletion Code/immersive_launcher/TargetConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <cstdint>
#include <limits>
#include <BranchInfo.h>
#include <BuildInfo.h>

#define CLIENT_DLL 0

Expand Down
1 change: 0 additions & 1 deletion Code/immersive_launcher/launcher.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "winres.h"
#include "BuildInfo.h"
#include "BranchInfo.h"

VS_VERSION_INFO VERSIONINFO
FILEFLAGSMASK 0x17L
Expand Down
4 changes: 2 additions & 2 deletions Code/server/GameServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void GameServer::BindServerCommands()

m_commands.RegisterCommand<>("mods", "List all installed mods on this server", [&](Console::ArgStack&) {
auto out = spdlog::get("ConOut");
auto& mods = m_pWorld->ctx<ModsComponent>().GetServerMods();
auto& mods = m_pWorld->ctx().at<ModsComponent>().GetServerMods();
if (mods.size() == 0)
{
out->warn("No mods installed");
Expand Down Expand Up @@ -472,7 +472,7 @@ void GameServer::HandleAuthenticationRequest(const ConnectionId_t aConnectionId,
if (acRequest->Token == sToken.value())
{
Mods& responseList = serverResponse.UserMods;
auto& modsComponent = m_pWorld->ctx<ModsComponent>();
auto& modsComponent = m_pWorld->ctx().at<ModsComponent>();

if (IsMoPoActive())
{
Expand Down
2 changes: 1 addition & 1 deletion Code/server/Scripts/Party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Script
{
Vector<Player> players;

auto& partyService = m_pWorld->ctx<PartyService>();
auto& partyService = m_pWorld->ctx().at<PartyService>();

auto* pParty = partyService.GetById(m_partyId);
if (pParty)
Expand Down
26 changes: 13 additions & 13 deletions Code/server/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ World::World()
m_spAdminService = std::make_shared<AdminService>(*this, m_dispatcher);
spdlog::default_logger()->sinks().push_back(std::static_pointer_cast<spdlog::sinks::sink>(m_spAdminService));

set<CharacterService>(*this, m_dispatcher);
set<PlayerService>(*this, m_dispatcher);
set<EnvironmentService>(*this, m_dispatcher);
set<ModsComponent>();
set<ServerListService>(*this, m_dispatcher);
set<QuestService>(*this, m_dispatcher);
set<PartyService>(*this, m_dispatcher);
set<ActorValueService>(*this, m_dispatcher);
set<InventoryService>(*this, m_dispatcher);
set<MagicService>(*this, m_dispatcher);
set<OverlayService>(*this, m_dispatcher);
set<CommandService>(*this, m_dispatcher);
ctx().emplace<CharacterService>(*this, m_dispatcher);
ctx().emplace<PlayerService>(*this, m_dispatcher);
ctx().emplace<EnvironmentService>(*this, m_dispatcher);
ctx().emplace<ModsComponent>();
ctx().emplace<ServerListService>(*this, m_dispatcher);
ctx().emplace<QuestService>(*this, m_dispatcher);
ctx().emplace<PartyService>(*this, m_dispatcher);
ctx().emplace<ActorValueService>(*this, m_dispatcher);
ctx().emplace<InventoryService>(*this, m_dispatcher);
ctx().emplace<MagicService>(*this, m_dispatcher);
ctx().emplace<OverlayService>(*this, m_dispatcher);
ctx().emplace<CommandService>(*this, m_dispatcher);

ESLoader::ESLoader loader;
// emplace loaded mods into modscomponent.
m_recordCollection = loader.BuildRecordCollection();
for (const auto& it : loader.GetLoadOrder())
{
ctx<ModsComponent>().AddServerMod(it);
ctx().emplace<ModsComponent>().AddServerMod(it);
}

// late initialize the ScriptService to ensure all components are valid
Expand Down
16 changes: 8 additions & 8 deletions Code/server/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ struct World : entt::registry

entt::dispatcher& GetDispatcher() noexcept { return m_dispatcher; }
const entt::dispatcher& GetDispatcher() const noexcept { return m_dispatcher; }
CharacterService& GetCharacterService() noexcept { return ctx<CharacterService>(); }
const CharacterService& GetCharacterService() const noexcept { return ctx<const CharacterService>(); }
PlayerService& GetPlayerService() noexcept { return ctx<PlayerService>(); }
const PlayerService& GetPlayerService() const noexcept { return ctx<const PlayerService>(); }
CharacterService& GetCharacterService() noexcept { return ctx().at<CharacterService>(); }
const CharacterService& GetCharacterService() const noexcept { return ctx().at<const CharacterService>(); }
PlayerService& GetPlayerService() noexcept { return ctx().at<PlayerService>(); }
const PlayerService& GetPlayerService() const noexcept { return ctx().at<const PlayerService>(); }
ScriptService& GetScriptService() noexcept { return *m_scriptService; }
const ScriptService& GetScriptService() const noexcept { return *m_scriptService; }
EnvironmentService& GetEnvironmentService() noexcept { return ctx<EnvironmentService>(); }
const EnvironmentService& GetEnvironmentService() const noexcept { return ctx<const EnvironmentService>(); }
QuestService& GetQuestService() noexcept { return ctx<QuestService>(); }
const QuestService& GetQuestService() const noexcept { return ctx<const QuestService>(); }
EnvironmentService& GetEnvironmentService() noexcept { return ctx().at<EnvironmentService>(); }
const EnvironmentService& GetEnvironmentService() const noexcept { return ctx().at<const EnvironmentService>(); }
QuestService& GetQuestService() noexcept { return ctx().at<QuestService>(); }
const QuestService& GetQuestService() const noexcept { return ctx().at<const QuestService>(); }
PlayerManager& GetPlayerManager() noexcept { return m_playerManager; }
const PlayerManager& GetPlayerManager() const noexcept { return m_playerManager; }

Expand Down
3 changes: 1 addition & 2 deletions Code/server/server.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "winres.h"
#include "BuildInfo.h"
#include "BranchInfo.h"

VS_VERSION_INFO VERSIONINFO
FILEFLAGSMASK 0x17L
Expand Down Expand Up @@ -28,4 +27,4 @@ BEGIN
BEGIN
VALUE "Translation", 0x409, 1200
END
END
END
2 changes: 1 addition & 1 deletion Code/server_runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static bool IsEULAAccepted()

char* pValue;
size_t len;
errno_t err = _dupenv_s(&pValue, &len, "TILTED_ACCEPT_EULA");
auto err = _dupenv_s(&pValue, &len, "TILTED_ACCEPT_EULA");
TiltedPhoques::String env = err == 0 ? pValue : "0";
free(pValue);

Expand Down
1 change: 0 additions & 1 deletion Code/server_runner/server_runner.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "winres.h"
#include "BuildInfo.h"
#include "BranchInfo.h"

VS_VERSION_INFO VERSIONINFO
FILEFLAGSMASK 0x17L
Expand Down