mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-06 19:01:06 +03:00
Replace std::runtime_exception with TENScriptException.
This commit is contained in:
parent
dfcbdb753a
commit
a637701d63
8 changed files with 16 additions and 16 deletions
|
@ -441,7 +441,9 @@ std::unique_ptr<GameScriptItemInfo> GameScript::GetItemById(int id)
|
|||
if (m_itemsMapId.find(id) == m_itemsMapId.end())
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
throw "item id not found";
|
||||
{
|
||||
throw TENScriptException{ "item id not found" };
|
||||
}
|
||||
return std::unique_ptr<GameScriptItemInfo>(nullptr);
|
||||
}
|
||||
|
||||
|
@ -457,7 +459,7 @@ std::unique_ptr<T> GetTByName(std::string const & type, std::string const& name,
|
|||
{
|
||||
std::string error = type + " name not found: ";
|
||||
error += name;
|
||||
throw std::runtime_error{error};
|
||||
throw TENScriptException{error};
|
||||
}
|
||||
return std::unique_ptr<T>(nullptr);
|
||||
}
|
||||
|
@ -669,8 +671,7 @@ void GameScript::ExecuteFunction(std::string const & name)
|
|||
if (WarningsAsErrors && !r.valid())
|
||||
{
|
||||
sol::error err = r;
|
||||
std::cerr << "An error occurred: " << err.what() << "\n";
|
||||
throw std::runtime_error(err.what());
|
||||
throw TENScriptException(err.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,8 +680,7 @@ static void doCallback(sol::protected_function const & func) {
|
|||
if (WarningsAsErrors && !r.valid())
|
||||
{
|
||||
sol::error err = r;
|
||||
std::cerr << "An error occurred: " << err.what() << "\n";
|
||||
throw std::runtime_error(err.what());
|
||||
throw TENScriptException(err.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ void GameScript::InitCallbacks()
|
|||
std::string err{ "Level's script file requires callback \"" };
|
||||
err += std::string{ luaFunc };
|
||||
err += "\"";
|
||||
throw std::runtime_error(err);
|
||||
throw TENScriptException(err);
|
||||
}
|
||||
};
|
||||
assignCB(m_onStart, "OnStart");
|
||||
|
|
|
@ -106,7 +106,7 @@ std::string GameScriptAIObject::GetName() const
|
|||
void GameScriptAIObject::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
throw TENScriptException("Name cannot be blank");
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_aiObject.luaName);
|
||||
|
|
|
@ -64,7 +64,7 @@ std::string GameScriptCameraInfo::GetName() const
|
|||
void GameScriptCameraInfo::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
throw TENScriptException("Name cannot be blank");
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_camera.luaName);
|
||||
|
|
|
@ -348,7 +348,7 @@ void GameScriptItemInfo::SetHP(short hp)
|
|||
(hp < 0 || hp > Objects[m_item->objectNumber].hitPoints))
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
throw std::runtime_error("invalid HP");
|
||||
throw TENScriptException("invalid HP");
|
||||
if (hp < 0)
|
||||
{
|
||||
hp = 0;
|
||||
|
@ -485,7 +485,7 @@ void GameScriptItemInfo::SetRoom(short room)
|
|||
if (room < 0 || static_cast<size_t>(room) >= g_Level.Rooms.size())
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
throw std::runtime_error("invalid room number");
|
||||
throw TENScriptException("invalid room number");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ std::string GameScriptMeshInfo::GetName() const
|
|||
void GameScriptMeshInfo::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
throw TENScriptException("Name cannot be blank");
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_mesh.luaName);
|
||||
|
|
|
@ -39,7 +39,7 @@ template <typename T, typename S> callbackSetName<S> GameScriptNamedBase<T, S>::
|
|||
std::string err = "\"Set Name\" callback is not set.";
|
||||
if (WarningsAsErrors)
|
||||
{
|
||||
throw std::runtime_error(err);
|
||||
throw TENScriptException(err);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ template <typename T, typename S> callbackRemoveName GameScriptNamedBase<T, S>::
|
|||
std::string err = "\"Remove Name\" callback is not set.";
|
||||
if (WarningsAsErrors)
|
||||
{
|
||||
throw std::runtime_error(err);
|
||||
throw TENScriptException(err);
|
||||
}
|
||||
return false;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ std::string GameScriptSinkInfo::GetName() const
|
|||
void GameScriptSinkInfo::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
throw TENScriptException("Name cannot be blank");
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_sink.luaName);
|
||||
|
|
|
@ -68,7 +68,7 @@ std::string GameScriptSoundSourceInfo::GetName() const
|
|||
void GameScriptSoundSourceInfo::SetName(std::string const & id)
|
||||
{
|
||||
if (id.empty() && WarningsAsErrors)
|
||||
throw std::runtime_error("Name cannot be blank");
|
||||
throw TENScriptException("Name cannot be blank");
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_soundSource.luaName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue