1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00

Refactoring of event name generation

This commit is contained in:
Mordred 2017-11-28 17:16:12 +01:00
parent 935f5f5eba
commit 26a80fbcc6

View file

@ -12,47 +12,45 @@ std::string Core::Event::getEventName( uint32_t eventId )
{ {
uint16_t eventType = eventId >> 16; uint16_t eventType = eventId >> 16;
auto unknown = std::string{ "unknown" };
switch( eventType ) switch( eventType )
{ {
case EventType::Quest: case EventType::Quest:
{ {
auto questInfo = g_exdData.getQuestInfo( eventId ); auto questInfo = g_exdData.getQuestInfo( eventId );
if( questInfo ) if( !questInfo )
{ return unknown + "Quest";
std::string name = questInfo->name_intern;
std::size_t pos = name.find_first_of( "_" );
return questInfo->name_intern.substr( 0, pos ); std::string name = questInfo->name_intern;
} std::size_t pos = name.find_first_of( "_" );
return questInfo->name_intern.substr( 0, pos );
} }
break;
case EventType::CustomTalk: case EventType::CustomTalk:
{ {
auto customTalkInfo = g_exdData.getCustomTalkInfo( eventId ); auto customTalkInfo = g_exdData.getCustomTalkInfo( eventId );
if( customTalkInfo ) if( !customTalkInfo )
{ return unknown + "CustomTalk";
std::string name = customTalkInfo->name_intern;
std::size_t pos = name.find_first_of( "_" );
return customTalkInfo->name_intern.substr( 0, pos ); std::string name = customTalkInfo->name_intern;
} std::size_t pos = name.find_first_of( "_" );
return customTalkInfo->name_intern.substr( 0, pos );
} }
break;
case EventType::Opening: case EventType::Opening:
{ {
auto openingInfo = g_exdData.getOpeningInfo( eventId ); auto openingInfo = g_exdData.getOpeningInfo( eventId );
if( openingInfo ) if( openingInfo )
return openingInfo->name; return openingInfo->name;
return unknown + "Opening";
} }
break;
case EventType::Aetheryte: case EventType::Aetheryte:
{ {
auto aetherInfo = g_exdData.getAetheryteInfo( eventId & 0xFFFF ); auto aetherInfo = g_exdData.getAetheryteInfo( eventId & 0xFFFF );
if( aetherInfo->isAetheryte ) if( aetherInfo->isAetheryte )
return "Aetheryte"; return "Aetheryte";
return "Aethernet"; return "Aethernet";
} }
case EventType::ChocoPort: case EventType::ChocoPort:
{ {
@ -60,11 +58,9 @@ std::string Core::Event::getEventName( uint32_t eventId )
} }
default: default:
{ {
return ""; return unknown;
} }
} }
return "";
} }
uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId ) uint32_t Core::Event::mapEventActorToRealActor( uint32_t eventActorId )