mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-11 04:56:49 +03:00
Move index_error_maker into new file (ScriptUtil.h). Add newindex_error_maker. Make them call ScriptAssert instead of just throwing an exception so it won't terminate the application on WARN or SILENT error modes.
This commit is contained in:
parent
6727138e64
commit
e74fa376d1
4 changed files with 17 additions and 7 deletions
|
@ -3,13 +3,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
|
|
||||||
{ \
|
|
||||||
std::string err = "Attempted to read non-existant var \"" + key.as<std::string>() + "\" from " + LUA_CLASS_NAME; \
|
|
||||||
throw TENScriptException(err); \
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S> using callbackSetName = std::function<bool(std::string const&, S identifier)>;
|
template <typename S> using callbackSetName = std::function<bool(std::string const&, S identifier)>;
|
||||||
using callbackRemoveName = std::function<bool(std::string const&)>;
|
using callbackRemoveName = std::function<bool(std::string const&)>;
|
||||||
|
|
||||||
|
|
13
TR5Main/Scripting/ScriptUtil.h
Normal file
13
TR5Main/Scripting/ScriptUtil.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
|
||||||
|
{ \
|
||||||
|
std::string err = "Attempted to read non-existant var \"" + key.as<std::string>() + "\" from " + LUA_CLASS_NAME; \
|
||||||
|
ScriptAssert(false, err);\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define newindex_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
|
||||||
|
{ \
|
||||||
|
std::string err = "Attempted to set non-existant var \"" + key.as<std::string>() + "\" of " + LUA_CLASS_NAME; \
|
||||||
|
ScriptAssert(false, err);\
|
||||||
|
}
|
||||||
|
|
|
@ -410,6 +410,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
||||||
<ClInclude Include="Scripting\LuaHandler.h" />
|
<ClInclude Include="Scripting\LuaHandler.h" />
|
||||||
<ClInclude Include="Scripting\ObjectIDs.h" />
|
<ClInclude Include="Scripting\ObjectIDs.h" />
|
||||||
<ClInclude Include="Scripting\ScriptAssert.h" />
|
<ClInclude Include="Scripting\ScriptAssert.h" />
|
||||||
|
<ClInclude Include="Scripting\ScriptUtil.h" />
|
||||||
<ClInclude Include="Specific\configuration.h" />
|
<ClInclude Include="Specific\configuration.h" />
|
||||||
<ClInclude Include="Specific\IO\ChunkId.h" />
|
<ClInclude Include="Specific\IO\ChunkId.h" />
|
||||||
<ClInclude Include="Specific\IO\ChunkWriter.h" />
|
<ClInclude Include="Specific\IO\ChunkWriter.h" />
|
||||||
|
|
|
@ -1050,6 +1050,9 @@
|
||||||
<ClInclude Include="Scripting\ItemEnumPair.h">
|
<ClInclude Include="Scripting\ItemEnumPair.h">
|
||||||
<Filter>File di intestazione</Filter>
|
<Filter>File di intestazione</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Scripting\ScriptUtil.h">
|
||||||
|
<Filter>File di intestazione</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Game\box.cpp">
|
<ClCompile Include="Game\box.cpp">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue