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:
hispidence 2021-08-04 16:51:28 +01:00
parent 052b03ec96
commit ead31e63f2
9 changed files with 36 additions and 61 deletions

View file

@ -1,4 +1,5 @@
#include "framework.h"
#include "ScriptAssert.h"
#include "GameScriptSoundSourceInfo.h"
#include "GameScriptPosition.h"
/***
@ -8,8 +9,6 @@ Sound source info
@pragma nostrip
*/
extern bool const WarningsAsErrors;
static constexpr auto LUA_CLASS_NAME{ "SoundSourceInfo" };
static auto index_error = index_error_maker(GameScriptSoundSourceInfo, LUA_CLASS_NAME);
@ -67,8 +66,7 @@ std::string GameScriptSoundSourceInfo::GetName() const
void GameScriptSoundSourceInfo::SetName(std::string const & id)
{
if (id.empty() && WarningsAsErrors)
throw TENScriptException("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_soundSource.luaName);