Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad performance of script command tracing #751

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
Options and Actions
--]]

newoption {
trigger = "script-tracing",
description = "Enable script command trace logging (Slow!)"
}
newoption {
trigger = "outdir",
value = "path",
Expand Down
8 changes: 7 additions & 1 deletion source/game_sa/Scripts/RunningScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,13 @@ OpcodeResult CRunningScript::ProcessOneCommand() {
};
} op = { CTheScripts::Read2BytesFromScript(m_IP) };

SPDLOG_LOGGER_TRACE(logger, "[{}][IP: {:#x} + {:#x}]: {} [{:#x}]", m_szName, LOG_PTR(m_pBaseIP), LOG_PTR(m_IP - m_pBaseIP), notsa::script::GetScriptCommandName((eScriptCommands)op.command), (size_t)op.command);
#ifdef NOTSA_SCRIPT_TRACING
// snprintf is faster (in debug at least) - Gotta stick to it for now
char msg[4096];
sprintf_s(msg, "[%s][IP: 0x%X + 0x%X]: %s [0x%X]", m_szName, LOG_PTR(m_pBaseIP), LOG_PTR(m_IP - m_pBaseIP), notsa::script::GetScriptCommandName((eScriptCommands)op.command).data(), (size_t)op.command);
Pirulax marked this conversation as resolved.
Show resolved Hide resolved
SPDLOG_LOGGER_TRACE(logger, msg);
//SPDLOG_LOGGER_TRACE(logger, "[{}][IP: {:#x} + {:#x}]: {} [{:#x}]", m_szName, LOG_PTR(m_pBaseIP), LOG_PTR(m_IP - m_pBaseIP), notsa::script::GetScriptCommandName((eScriptCommands)op.command), (size_t)op.command);
#endif

m_bNotFlag = op.notFlag;

Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Scripts/TheScripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ struct tScriptSearchlight {
m_Tower = nullptr;
m_Housing = nullptr;
m_Bulb = nullptr;
m_TargetSpot = nullptr;
m_TargetSpot = CVector{};
vf64 = CVector{};
vf70 = CVector{};
}
Expand Down
4 changes: 4 additions & 0 deletions source/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ project "gta_sa_modern"
"../libs/tracy/public",
"../libs/json/include"
}

filter "options:script-tracing"
defines { "NOTSA_SCRIPT_TRACING" }
filter {}

defines {
"NOMINMAX",
Expand Down
Loading