Merge pull request #341 from diamante0018/isolate-stack
[Chat] Isolate stack
This commit is contained in:
commit
6c1339cc6b
@ -369,6 +369,7 @@ namespace Components
|
||||
{
|
||||
const auto entityId = Game::Scr_GetEntityId(self->s.number, 0);
|
||||
|
||||
Scripting::StackIsolation _;
|
||||
Game::Scr_AddInt(mode);
|
||||
Game::Scr_AddString(message);
|
||||
|
||||
|
26
src/Game/Scripting/StackIsolation.cpp
Normal file
26
src/Game/Scripting/StackIsolation.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
StackIsolation::StackIsolation()
|
||||
{
|
||||
this->inParamCount_ = Game::scrVmPub->inparamcount;
|
||||
this->outParamCount_ = Game::scrVmPub->outparamcount;
|
||||
this->top_ = Game::scrVmPub->top;
|
||||
this->maxStack_ = Game::scrVmPub->maxStack;
|
||||
|
||||
Game::scrVmPub->top = this->stack_;
|
||||
Game::scrVmPub->maxStack = &this->stack_[ARRAYSIZE(this->stack_) - 1];
|
||||
Game::scrVmPub->inparamcount = 0;
|
||||
Game::scrVmPub->outparamcount = 0;
|
||||
}
|
||||
|
||||
StackIsolation::~StackIsolation()
|
||||
{
|
||||
Game::Scr_ClearOutParams();
|
||||
Game::scrVmPub->inparamcount = this->inParamCount_;
|
||||
Game::scrVmPub->outparamcount = this->outParamCount_;
|
||||
Game::scrVmPub->top = this->top_;
|
||||
Game::scrVmPub->maxStack = this->maxStack_;
|
||||
}
|
||||
}
|
24
src/Game/Scripting/StackIsolation.hpp
Normal file
24
src/Game/Scripting/StackIsolation.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
class StackIsolation final
|
||||
{
|
||||
public:
|
||||
StackIsolation();
|
||||
~StackIsolation();
|
||||
|
||||
StackIsolation(StackIsolation&&) = delete;
|
||||
StackIsolation(const StackIsolation&) = delete;
|
||||
StackIsolation& operator=(StackIsolation&&) = delete;
|
||||
StackIsolation& operator=(const StackIsolation&) = delete;
|
||||
|
||||
private:
|
||||
Game::VariableValue stack_[512]{};
|
||||
|
||||
Game::VariableValue* maxStack_;
|
||||
Game::VariableValue* top_;
|
||||
unsigned int inParamCount_;
|
||||
unsigned int outParamCount_;
|
||||
};
|
||||
}
|
@ -141,6 +141,7 @@ using namespace std::literals;
|
||||
#include "Game/Structs.hpp"
|
||||
#include "Game/Functions.hpp"
|
||||
#include <Game/Scripting/Function.hpp>
|
||||
#include <Game/Scripting/StackIsolation.hpp>
|
||||
|
||||
#include "Utils/Stream.hpp" // Breaks order on purpose
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user