1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00
sapphire/src/servers/sapphire_zone/Event/EventHelper.cpp
2018-03-06 22:22:19 +01:00

86 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <Common.h>
#include <Exd/ExdDataGenerated.h>
#include "Framework.h"
#include "EventHelper.h"
#include "EventHandler.h"
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
extern Core::Framework g_framework;
using namespace Core::Common;
std::string Core::Event::getEventName( uint32_t eventId )
{
uint16_t eventType = eventId >> 16;
auto unknown = std::string{ "unknown" };
switch( eventType )
{
case Event::EventHandler::EventHandlerType::Quest:
{
auto questInfo = g_framework.getExdDataGen().get< Core::Data::Quest >( eventId );
if( !questInfo )
return unknown + "Quest";
std::string name = questInfo->id;
std::size_t pos = name.find_first_of( "_" );
return name.substr( 0, pos );
}
case Event::EventHandler::EventHandlerType::CustomTalk:
{
auto customTalkInfo = g_framework.getExdDataGen().get< Core::Data::CustomTalk >( eventId );
if( !customTalkInfo )
return unknown + "CustomTalk";
std::string name = customTalkInfo->name;
std::size_t pos = name.find_first_of( "_" );
return customTalkInfo->name.substr( 0, pos );
}
case Event::EventHandler::EventHandlerType::Opening:
{
auto openingInfo = g_framework.getExdDataGen().get< Core::Data::Opening >( eventId );
if( openingInfo )
return openingInfo->name;
return unknown + "Opening";
}
case Event::EventHandler::EventHandlerType::Aetheryte:
{
auto aetherInfo = g_framework.getExdDataGen().get< Core::Data::Aetheryte >( eventId & 0xFFFF );
if( aetherInfo->isAetheryte )
return "Aetheryte";
return "Aethernet";
}
case Event::EventHandler::EventHandlerType::ICDirector:
{
auto contentInfo = g_framework.getExdDataGen().get< Core::Data::InstanceContent >( eventId & 0xFFFF );
std::string name = contentInfo->name;
name.erase( boost::remove_if( name, boost::is_any_of( "★_ '()[]-\x1a\x1\x2\x1f\x1\x3.:" ) ), name.end() );
name[0] = toupper( name[0] );
return name;
}
case Event::EventHandler::EventHandlerType::Warp:
{
return "ChocoboTaxi";
}
default:
{
return unknown;
}
}
}
uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId )
{
auto levelInfo = g_framework.getExdDataGen().get< Core::Data::Level >( eventActorId );
if( levelInfo )
return levelInfo->objectKey;
return 0;
}