mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 04:26:42 +03:00
Replace WarningsAsErrors usage with ScriptAssert usage.
For recoverable errors, add some recovery behaviour and logging so a level designer can see in the log what was done as a result of the error. Warn about default behaviour if no callbacks are added.
This commit is contained in:
parent
052b03ec96
commit
ead31e63f2
9 changed files with 36 additions and 61 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "framework.h"
|
||||
#include "ScriptAssert.h"
|
||||
#include "GameScriptItemInfo.h"
|
||||
#include "items.h"
|
||||
#include "objectslist.h"
|
||||
|
@ -19,8 +20,6 @@ pickups, and Lara herself.
|
|||
@pragma nostrip
|
||||
*/
|
||||
|
||||
extern bool const WarningsAsErrors;
|
||||
|
||||
constexpr auto LUA_CLASS_NAME{ "ItemInfo" };
|
||||
|
||||
static auto index_error = index_error_maker(GameScriptItemInfo, LUA_CLASS_NAME);
|
||||
|
@ -294,8 +293,7 @@ std::string GameScriptItemInfo::GetName() const
|
|||
|
||||
void GameScriptItemInfo::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
ScriptAssert(!id.empty(), "Name cannot be blank", ERROR_MODE::TERMINATE);
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_item->luaName);
|
||||
|
@ -347,8 +345,7 @@ void GameScriptItemInfo::SetHP(short hp)
|
|||
if(Objects[m_item->objectNumber].intelligent &&
|
||||
(hp < 0 || hp > Objects[m_item->objectNumber].hitPoints))
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
throw TENScriptException("invalid HP");
|
||||
ScriptAssert(false, "Invalid value: " + hp);
|
||||
if (hp < 0)
|
||||
{
|
||||
hp = 0;
|
||||
|
@ -484,8 +481,8 @@ void GameScriptItemInfo::SetRoom(short room)
|
|||
{
|
||||
if (room < 0 || static_cast<size_t>(room) >= g_Level.Rooms.size())
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
throw TENScriptException("invalid room number");
|
||||
ScriptAssert(false, "Invalid room number: " + room);
|
||||
TENLog("Room number will not be set", LogLevel::Warning, LogConfig::All);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue