Skip to content

Commit

Permalink
Throw exception if duplicate definitions of actions are found
Browse files Browse the repository at this point in the history
  • Loading branch information
arieshi255 committed Jun 27, 2024
1 parent 88ae073 commit e2e6b3e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/world/Action/ActionLutData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fstream>
#include <filesystem>
#include <iostream>
#include <Logging/Logger.h>

using namespace Sapphire;
using namespace Sapphire::World::Action;
Expand Down Expand Up @@ -138,6 +139,10 @@ bool ActionLutData::cacheActions()
{
auto id = std::stoi( i.key() );
auto action = i.value().get< ActionEntry >();

if( ActionLut::m_actionLut.count( id ) > 0 )
throw std::runtime_error( fmt::format( "Action with ID {} cannot be defined more than once (defined again in {})", i.key(), p.path().string() ) );

ActionLut::m_actionLut.try_emplace( id, action );
}

Expand Down

0 comments on commit e2e6b3e

Please sign in to comment.