mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 12:36:45 +03:00
Remove AddLuaId and GetItemById.
This commit is contained in:
parent
895a7ae025
commit
052b03ec96
2 changed files with 1 additions and 40 deletions
|
@ -104,15 +104,6 @@ Get an ItemInfo by its name.
|
|||
*/
|
||||
m_lua->set_function("GetItemByName", &GameScript::GetItemByName, this);
|
||||
|
||||
/***
|
||||
Get an ItemInfo by its integer ID.
|
||||
Not sure if we're using this.
|
||||
@function GetItemByID
|
||||
@tparam int ID the ID of the item
|
||||
@return a non-owning ItemInfo referencing the item.
|
||||
*/
|
||||
m_lua->set_function("GetItemByID", &GameScript::GetItemById, this);
|
||||
|
||||
/***
|
||||
Get a MeshInfo by its name.
|
||||
@function GetMeshByName
|
||||
|
@ -222,11 +213,6 @@ void GameScript::AddTrigger(LuaFunction* function)
|
|||
(*m_lua).script(function->Code);
|
||||
}
|
||||
|
||||
void GameScript::AddLuaId(int luaId, short itemNumber)
|
||||
{
|
||||
m_itemsMapId.insert(std::pair<int, short>(luaId, itemNumber));
|
||||
}
|
||||
|
||||
bool GameScript::RemoveLuaNameItem(std::string const & luaName)
|
||||
{
|
||||
return m_itemsMapName.erase(luaName);
|
||||
|
@ -436,34 +422,11 @@ void GameScript::SetVariables(std::map<std::string, T>& locals, std::map<std::st
|
|||
template void GameScript::SetVariables<bool>(std::map<std::string, bool>& locals, std::map<std::string, bool>& globals);
|
||||
template void GameScript::SetVariables<float>(std::map<std::string, float>& locals, std::map<std::string, float>& globals);
|
||||
template void GameScript::SetVariables<std::string>(std::map<std::string, std::string>& locals, std::map<std::string, std::string>& globals);
|
||||
std::unique_ptr<GameScriptItemInfo> GameScript::GetItemById(int id)
|
||||
{
|
||||
if (m_itemsMapId.find(id) == m_itemsMapId.end())
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
{
|
||||
throw TENScriptException{ "item id not found" };
|
||||
}
|
||||
return std::unique_ptr<GameScriptItemInfo>(nullptr);
|
||||
}
|
||||
|
||||
return std::make_unique<GameScriptItemInfo>(m_itemsMapId[id], false);
|
||||
}
|
||||
|
||||
template <typename T, typename Stored>
|
||||
std::unique_ptr<T> GetTByName(std::string const & type, std::string const& name, std::map<std::string, Stored> const & map)
|
||||
{
|
||||
if (map.find(name) == map.end())
|
||||
{
|
||||
if (WarningsAsErrors)
|
||||
{
|
||||
std::string error = type + " name not found: ";
|
||||
error += name;
|
||||
throw TENScriptException{error};
|
||||
}
|
||||
return std::unique_ptr<T>(nullptr);
|
||||
}
|
||||
|
||||
ScriptAssert(map.find(name) != map.end(), std::string{ type + " name not found: " + name }, ERROR_MODE::TERMINATE);
|
||||
return std::make_unique<T>(map.at(name), false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue