1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00
sapphire/src/servers/sapphire_zone/Event/EventHelper.cpp

85 lines
2.3 KiB
C++
Raw Normal View History

2017-08-08 13:53:47 +02:00
#include "EventHelper.h"
2018-01-09 23:50:54 +01:00
#include "EventHandler.h"
#include <common/Common.h>
2018-01-31 02:06:11 +11:00
#include <common/Exd/ExdDataGenerated.h>
2017-08-08 13:53:47 +02:00
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
2018-01-31 02:06:11 +11:00
extern Core::Data::ExdDataGenerated g_exdDataGen;
2017-08-08 13:53:47 +02:00
using namespace Core::Common;
std::string Core::Event::getEventName( uint32_t eventId )
{
uint16_t eventType = eventId >> 16;
2017-11-28 17:16:12 +01:00
auto unknown = std::string{ "unknown" };
2017-08-08 13:53:47 +02:00
switch( eventType )
{
case Event::EventHandler::EventHandlerType::Quest:
2017-08-08 13:53:47 +02:00
{
2018-02-14 12:31:47 +01:00
auto questInfo = g_exdDataGen.get< Core::Data::Quest >( eventId );
2017-11-28 17:16:12 +01:00
if( !questInfo )
return unknown + "Quest";
std::string name = questInfo->id;
2017-11-28 17:16:12 +01:00
std::size_t pos = name.find_first_of( "_" );
2017-08-08 13:53:47 +02:00
2018-02-03 01:51:46 +01:00
return name.substr( 0, pos );
2017-08-08 13:53:47 +02:00
}
case Event::EventHandler::EventHandlerType::CustomTalk:
2017-08-08 13:53:47 +02:00
{
2018-02-14 12:31:47 +01:00
auto customTalkInfo = g_exdDataGen.get< Core::Data::CustomTalk >( eventId );
2017-11-28 17:16:12 +01:00
if( !customTalkInfo )
return unknown + "CustomTalk";
2017-08-08 13:53:47 +02:00
2018-01-31 02:06:11 +11:00
std::string name = customTalkInfo->name;
2017-11-28 17:16:12 +01:00
std::size_t pos = name.find_first_of( "_" );
2017-08-08 13:53:47 +02:00
2018-01-31 02:06:11 +11:00
return customTalkInfo->name.substr( 0, pos );
2017-08-08 13:53:47 +02:00
}
case Event::EventHandler::EventHandlerType::Opening:
2017-08-08 13:53:47 +02:00
{
2018-02-14 12:31:47 +01:00
auto openingInfo = g_exdDataGen.get< Core::Data::Opening >( eventId );
2017-08-08 13:53:47 +02:00
if( openingInfo )
return openingInfo->name;
2017-11-28 17:16:12 +01:00
return unknown + "Opening";
2017-08-08 13:53:47 +02:00
}
case Event::EventHandler::EventHandlerType::Aetheryte:
2017-08-08 13:53:47 +02:00
{
2018-02-14 12:31:47 +01:00
auto aetherInfo = g_exdDataGen.get< Core::Data::Aetheryte >( eventId & 0xFFFF );
2017-08-08 13:53:47 +02:00
if( aetherInfo->isAetheryte )
return "Aetheryte";
return "Aethernet";
}
case Event::EventHandler::EventHandlerType::ICDirector:
{
auto contentInfo = g_exdDataGen.get< Core::Data::InstanceContent >( eventId & 0xFFFF );
std::string name = contentInfo->name;
name.erase( boost::remove_if( name, boost::is_any_of( "_ '()[]" ) ), name.end() );
return name;
}
case Event::EventHandler::EventHandlerType::Warp:
2017-08-08 13:53:47 +02:00
{
return "ChocoboTaxi";
}
default:
{
2017-11-28 17:16:12 +01:00
return unknown;
2017-08-08 13:53:47 +02:00
}
}
}
uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId )
{
2018-02-14 12:31:47 +01:00
auto levelInfo = g_exdDataGen.get< Core::Data::Level >( eventActorId );
2017-08-08 13:53:47 +02:00
if( levelInfo )
2018-01-31 11:43:22 +01:00
return levelInfo->objectKey;
2017-08-08 13:53:47 +02:00
return 0;
}