Skip to content

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nic11 committed Jan 16, 2025
1 parent d9e2182 commit 1d1d5a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
16 changes: 13 additions & 3 deletions papyrus-vm/src/papyrus-vm-lib/ActivePexInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,19 @@ VarValue ActivePexInstance::ExecuteAll(
agctx.AddUnsigned(ctx.stackData->stackIdHolder.GetStackId());
agctx.AddUnsigned(ctx.line);
auto g = agctx.AddLambdaWithRef([&ctx]() {
std::string s = "ExecutionContext:\n";
ctx.locals;
return s;
std::stringstream ss;
ss << "ExecutionContext:\n";
if (ctx.locals == nullptr) {
ss << "locals = nullptr\n";
} else {
ss << "locals = [" << ctx.locals->size() << "] [\n";
for (size_t i = 0; i < ctx.locals->size(); ++i) {
auto& local = (*ctx.locals)[i];
ss << " " << local.first << " = " << local.second << "\n";
}
ss << "]\n";
}
return std::move(ss).str();
});
g.Arm();

Expand Down
17 changes: 17 additions & 0 deletions skymp5-server/cpp/server_guest_lib/MpForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include "GetWeightFromRecord.h"
#include "MpObjectReference.h"
#include "WorldState.h"
#include "antigo/Context.h"
#include "gamemode_events/PapyrusEventEvent.h"
#include "script_objects/MpFormGameObject.h"
#include <sstream>

MpForm::MpForm()
{
Expand Down Expand Up @@ -34,6 +36,21 @@ void MpForm::Update()
void MpForm::SendPapyrusEvent(const char* eventName, const VarValue* arguments,
size_t argumentsCount)
{
ANTIGO_CONTEXT_INIT(ctx);
ctx.AddPtr(arguments);
ctx.AddUnsigned(argumentsCount);
auto g = ctx.AddLambdaWithRef([eventName, arguments, argumentsCount]{
std::stringstream ss;
ss << "eventName = " << eventName << "\n";
ss << "arguments = [" << argumentsCount << "] [\n";
for (size_t i = 0; i < argumentsCount; ++i) {
ss << " " << arguments[i];
}
ss << "]";
return std::move(ss).str();
});
g.Arm();

PapyrusEventEvent papyrusEventEvent(this, eventName, arguments,
argumentsCount);
papyrusEventEvent.Fire(parent);
Expand Down
1 change: 1 addition & 0 deletions skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ void MpObjectReference::SendPapyrusEvent(const char* eventName,
const VarValue* arguments,
size_t argumentsCount)
{
ANTIGO_CONTEXT_INIT(ctx);
if (!pImpl->scriptsInited) {
InitScripts();
pImpl->scriptsInited = true;
Expand Down

0 comments on commit 1d1d5a2

Please sign in to comment.