Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ CMakeSettings.json
*.patch
.claude/
images/
/Source/Resources/Automation/Artifacts/
/Source/Resources/Automation/Reports/

# Local validation findings
/ISSUES.md

# Local agent guidance
/AGENTS.md
Binary file added ShadowIssue.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion Source/Game-App/Game-App.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Solution.Util.CreateConsoleApp(mod.Name, Solution.Projects.Current.BinDir, mod.D
local projFile = mod.Path .. "/" .. mod.Name .. ".lua"
local files = Solution.Util.GetFilesForCpp(mod.Path)
table.insert(files, projFile)
table.insert(files, mod.Path .. "/Game-App/Resources/renderdoc.json")

Solution.Util.SetFiles(files)
Solution.Util.SetIncludes(mod.Path)
Expand All @@ -22,9 +23,14 @@ Solution.Util.CreateConsoleApp(mod.Name, Solution.Projects.Current.BinDir, mod.D
}
Solution.Util.SetFiles(appIconFiles)

postbuildcommands
{
'{COPYFILE} "' .. mod.Path .. '/Game-App/Resources/renderdoc.json" "%{cfg.targetdir}/renderdoc.json"'
}

vpaths
{
['Resources/*'] = { '*.rc', '**.ico' },
['Resources/*'] = { '*.rc', '**.ico', '**.json' },
["/*"] = { "*.lua", mod.Name .. "/**" }
}
end)
Expand Down
42 changes: 42 additions & 0 deletions Source/Game-App/Game-App/Resources/renderdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"file_format_version": "1.1.2",
"layer": {
"name": "VK_LAYER_RENDERDOC_Capture",
"type": "GLOBAL",
"library_path": ".\\renderdoc.dll",
"api_version": "1.4.324",
"implementation_version": "45",
"description": "RenderDoc capture layer",
"functions": {
"vkGetInstanceProcAddr": "VK_LAYER_RENDERDOC_CaptureGetInstanceProcAddr",
"vkGetDeviceProcAddr": "VK_LAYER_RENDERDOC_CaptureGetDeviceProcAddr",
"vkNegotiateLoaderLayerInterfaceVersion": "VK_LAYER_RENDERDOC_CaptureNegotiateLoaderLayerInterfaceVersion"
},
"instance_extensions": [
{
"name": "VK_EXT_debug_utils",
"spec_version": "1"
}
],
"device_extensions": [
{
"name": "VK_EXT_debug_marker",
"spec_version": "4",
"entrypoints": [
"vkDebugMarkerSetObjectTagEXT",
"vkDebugMarkerSetObjectNameEXT",
"vkCmdDebugMarkerBeginEXT",
"vkCmdDebugMarkerEndEXT",
"vkCmdDebugMarkerInsertEXT"
]
},
{
"name": "VK_EXT_tooling_info",
"spec_version": "1",
"entrypoints": [
"vkGetPhysicalDeviceToolPropertiesEXT"
]
}
]
}
}
42 changes: 26 additions & 16 deletions Source/Game-App/Game-App/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <quill/Backend.h>

#include <atomic>
#include <cstdio>
#include <iostream>
#include <string_view>
#include <thread>

#if WIN32
Expand All @@ -22,40 +24,48 @@
#include <unistd.h>
#endif

i32 main()
i32 main(i32 argc, char* argv[])
{
// MCPTools redirects the process streams to pipes. The C runtime otherwise
// block-buffers plain Luau print output, hiding automation progress until
// the buffer fills or the process exits.
std::setvbuf(stdout, nullptr, _IONBF, 0);
std::setvbuf(stderr, nullptr, _IONBF, 0);

#if WIN32
timeBeginPeriod(1);
#endif

bool enableRenderDoc = false;
for (i32 argumentIndex = 1; argumentIndex < argc; argumentIndex++)
{
if (std::string_view(argv[argumentIndex]) == "-renderdoc")
enableRenderDoc = true;
}

quill::Backend::start();

auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>("console_sink_1");
auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>("console_sink_1", false);
quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink), "%(time:<16) LOG_%(log_level:<11) %(message)", "%H:%M:%S.%Qms", quill::Timezone::LocalTime, quill::ClockSourceType::System);

Application app;
app.Start(true);
app.Start(true, enableRenderDoc);

ConsoleCommandHandler commandHandler;
#if WIN32
moodycamel::ConcurrentQueue<std::string> consoleCommands;
std::atomic_bool consoleInputRunning = true;
HANDLE consoleInput = GetStdHandle(STD_INPUT_HANDLE);
std::thread consoleInputThread;
if (consoleInput != nullptr && consoleInput != INVALID_HANDLE_VALUE)
std::thread consoleInputThread([&consoleCommands, &consoleInputRunning]()
{
consoleInputThread = std::thread([&consoleCommands, &consoleInputRunning]()
while (consoleInputRunning)
{
while (consoleInputRunning)
{
std::string command = StringUtils::GetLineFromCin();
if (!consoleInputRunning || std::cin.fail())
break;
std::string command = StringUtils::GetLineFromCin();
if (!consoleInputRunning || std::cin.fail())
break;

consoleCommands.enqueue(std::move(command));
}
});
}
consoleCommands.enqueue(std::move(command));
}
});
#else
pollfd consoleInput =
{
Expand Down
28 changes: 20 additions & 8 deletions Source/Game-Lib/Game-Lib/Application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
#include "Game-Lib/Scripting/Handlers/GameHandler.h"
#include "Game-Lib/Scripting/Handlers/UnitHandler.h"
#include "Game-Lib/Scripting/Handlers/TimeHandler.h"
#include "Game-Lib/Scripting/Handlers/SchedulerHandler.h"
#include "Game-Lib/Scripting/Handlers/CameraHandler.h"
#include "Game-Lib/Scripting/Handlers/MapHandler.h"
#include "Game-Lib/Scripting/Handlers/SceneHandler.h"
#include "Game-Lib/Scripting/Handlers/EditorToolHandler.h"
#include "Game-Lib/Scripting/Handlers/AssetHandler.h"
#include "Game-Lib/Util/AutomationUtil.h"
#include "Game-Lib/Util/AssetPath.h"
#include "Game-Lib/Util/AssetWriter.h"
#include "Game-Lib/Util/ClientDBUtil.h"
Expand Down Expand Up @@ -119,7 +121,9 @@ namespace
}
}

Application::Application() : _messagesInbound(256), _messagesOutbound(256)
Application::Application()
: _messagesInbound(256)
, _messagesOutbound(256)
{
ServiceLocator::SetApplication(this);
}
Expand All @@ -136,7 +140,7 @@ Application::~Application()
delete _assetWriter;
}

void Application::Start(bool startInSeparateThread)
void Application::Start(bool startInSeparateThread, bool enableRenderDoc)
{
if (_isRunning)
return;
Expand All @@ -145,12 +149,13 @@ void Application::Start(bool startInSeparateThread)
{
_isRunning = true;

std::thread applicationThread = std::thread(&Application::Run, this);
std::thread applicationThread =
std::thread(&Application::Run, this, enableRenderDoc);
applicationThread.detach();
}
else
{
_isRunning = Init();
_isRunning = Init(enableRenderDoc);
}
}

Expand Down Expand Up @@ -224,11 +229,11 @@ bool Application::TryGetMessageOutbound(MessageOutbound& message)
return messageFound;
}

void Application::Run()
void Application::Run(bool enableRenderDoc)
{
tracy::SetThreadName("Application Thread");

if (Init())
if (Init(enableRenderDoc))
{
Timer timer;
Timer updateTimer;
Expand Down Expand Up @@ -325,7 +330,7 @@ void Application::Run()
Stop();
}

bool Application::Init()
bool Application::Init(bool enableRenderDoc)
{
_registries.gameRegistry = new entt::registry();
_registries.uiRegistry = new entt::registry();
Expand Down Expand Up @@ -431,7 +436,7 @@ bool Application::Init()
Util::Texture::DiscoverAll();
Util::ClientDB::DiscoverAll();

_gameRenderer = new GameRenderer();
_gameRenderer = new GameRenderer(enableRenderDoc);
_imguiInputBridge = new ImGuiInputBridge(*_inputSystem);

NC_LOG_INFO("EditorHandler : Initializing");
Expand Down Expand Up @@ -461,6 +466,7 @@ bool Application::Init()
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Game, new Scripting::Game::GameHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Unit, new Scripting::Unit::UnitHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Time, new Scripting::Time::TimeHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Scheduler, new Scripting::Scheduler::SchedulerHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Camera, new Scripting::Camera::CameraHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Map, new Scripting::Map::MapHandler());
_luaManager->SetLuaHandler((Scripting::LuaHandlerID)MetaGen::Game::Lua::LuaHandlerTypeEnum::Scene, new Scripting::Scene::SceneHandler());
Expand Down Expand Up @@ -555,6 +561,12 @@ bool Application::Tick(f32 deltaTime)
break;
}

case MessageInbound::Type::AutomationRun:
{
Util::Automation::ExecuteScript(*_luaManager, message.requestId, message.data);
break;
}

case MessageInbound::Type::ReloadScripts:
{
ServiceLocator::GetLuaManager()->SetDirty();
Expand Down
6 changes: 3 additions & 3 deletions Source/Game-Lib/Game-Lib/Application/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Application
Application();
~Application();

void Start(bool startInSeparateThread);
void Start(bool startInSeparateThread, bool enableRenderDoc = false);
void Stop();
void RequestExit();

Expand All @@ -54,9 +54,9 @@ class Application
bool Tick(f32 deltaTime);

private:
void Run();
void Run(bool enableRenderDoc);

bool Init();
bool Init(bool enableRenderDoc);
bool Render(f32 deltaTime, f32& timeSpentWaiting);

void DatabaseReload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ConsoleCommandHandler::ConsoleCommandHandler()
RegisterCommand("ping"_h, &ConsoleCommands::CommandPing);
RegisterCommand("lua"_h, &ConsoleCommands::CommandDoString);
RegisterCommand("eval"_h, &ConsoleCommands::CommandDoString);
RegisterCommand("automation_run"_h, &ConsoleCommands::CommandAutomationRun);
RegisterCommand("r"_h, &ConsoleCommands::CommandReloadScripts);
RegisterCommand("reload"_h, &ConsoleCommands::CommandReloadScripts);
RegisterCommand("reloadscripts"_h, &ConsoleCommands::CommandReloadScripts);
Expand Down
14 changes: 14 additions & 0 deletions Source/Game-Lib/Game-Lib/Application/ConsoleCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "Application.h"
#include "Message.h"

#include <Base/Util/DebugHandler.h>

void ConsoleCommands::CommandPrint(Application& app, std::vector<std::string>& subCommands)
{
if (subCommands.size() == 0)
Expand Down Expand Up @@ -55,6 +57,18 @@ void ConsoleCommands::CommandDoString(Application& app, std::vector<std::string>
app.PassMessage(message);
}

void ConsoleCommands::CommandAutomationRun(Application& app, std::vector<std::string>& subCommands)
{
if (subCommands.size() != 2)
{
NC_LOG_ERROR("Usage: automation_run <request-id> Scripts/<path>.luau");
return;
}

MessageInbound message(MessageInbound::Type::AutomationRun, subCommands[1], subCommands[0]);
app.PassMessage(message);
}

void ConsoleCommands::CommandReloadScripts(Application& app, std::vector<std::string>& subCommands)
{
MessageInbound message(MessageInbound::Type::ReloadScripts);
Expand Down
3 changes: 2 additions & 1 deletion Source/Game-Lib/Game-Lib/Application/ConsoleCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ConsoleCommands
static void CommandPing(Application& app, std::vector<std::string>& subCommands);
static void CommandExit(Application& app, std::vector<std::string>& subCommands);
static void CommandDoString(Application& app, std::vector<std::string>& subCommands);
static void CommandAutomationRun(Application& app, std::vector<std::string>& subCommands);
static void CommandReloadScripts(Application& app, std::vector<std::string>& subCommands);
static void CommandRefreshDB(Application& app, std::vector<std::string>& subCommands);
};
};
10 changes: 8 additions & 2 deletions Source/Game-Lib/Game-Lib/Application/Message.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once
#include <Base/Types.h>

#include <string>
#include <utility>

struct MessageInbound
{
public:
Expand All @@ -10,17 +13,20 @@ struct MessageInbound
Print,
Ping,
DoString,
AutomationRun,
ReloadScripts,
RefreshDB,
Exit
};

public:
MessageInbound() { }
MessageInbound(Type inType, std::string inData = "") : type(inType), data(inData) { }
MessageInbound(Type inType, std::string inData = "", std::string inRequestId = "")
: type(inType), data(std::move(inData)), requestId(std::move(inRequestId)) { }

Type type = Type::Invalid;
std::string data = "";
std::string requestId = "";
};

struct MessageOutbound
Expand All @@ -40,4 +46,4 @@ struct MessageOutbound

Type type = Type::Invalid;
std::string data = "";
};
};
19 changes: 18 additions & 1 deletion Source/Game-Lib/Game-Lib/ECS/Components/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ namespace ECS::Components
u32 mapId;
};

enum class MapLoadFailureReason : u8
{
MissingDatabaseRecord,
MissingHeader,
InvalidHeader,
MissingBaseModel,
NoChunks,
NoAvailableChunks,
};

struct MapLoadFailedEvent
{
public:
u32 mapId;
MapLoadFailureReason reason;
};

struct ModelLoadedEventFlags
{
public:
Expand All @@ -24,4 +41,4 @@ namespace ECS::Components
public:
ModelLoadedEventFlags flags = { 0 };
};
}
}
Loading
Loading