1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 10:47:45 +00:00

Merge pull request #963 from arieshi255/fix-lut

[3.x] Throw exception if duplicate definitions of actions are found
This commit is contained in:
Mordred 2024-06-27 13:43:32 +02:00 committed by GitHub
commit 2a0e423051
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@
#include <fstream> #include <fstream>
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include <Logging/Logger.h>
using namespace Sapphire; using namespace Sapphire;
using namespace Sapphire::World::Action; using namespace Sapphire::World::Action;
@ -138,6 +139,10 @@ bool ActionLutData::cacheActions()
{ {
auto id = std::stoi( i.key() ); auto id = std::stoi( i.key() );
auto action = i.value().get< ActionEntry >(); 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 ); ActionLut::m_actionLut.try_emplace( id, action );
} }