1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 21:57:44 +00:00

GM Ranks, some fixes

This commit is contained in:
amibu 2017-09-11 18:59:50 +02:00
parent 4b914aae3c
commit cb7c6ab65e
13 changed files with 398 additions and 357 deletions

View file

@ -11,7 +11,7 @@
<LobbyHost>127.0.0.1</LobbyHost>
<!-- IP of the frontier server -->
<FrontierHost>127.0.0.1</FrontierHost>
<!-- Secret used for server auth -->
<!-- Secret used for server auth - you *must* change this for public servers -->
<ServerSecret>default</ServerSecret>
<!-- Web server port -->
<HttpPort>80</HttpPort>
@ -23,4 +23,9 @@
<Database>sapphire</Database>
</Mysql>
</General>
<Parameters>
<!-- GM Rank for newly created characters - should be changed to 0 for public servers -->
<DefaultGMRank>255</DefaultGMRank>
</Parameters>
</Settings>

View file

@ -218,7 +218,7 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
uint64_t lookupId = *reinterpret_cast< uint64_t* >( &packet.data[0] + 0x18 );
uint32_t logInCharId;
uint32_t logInCharId = -1;
std::string logInCharName;
auto charList = g_restConnector.getCharList( ( char * )m_pSession->getSessionId() );
for( uint32_t i = 0; i < charList.size(); i++ )
@ -233,6 +233,8 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
}
}
if( logInCharId == -1 )
return;
g_log.info( "[" + std::to_string( m_pSession->getAccountID() ) + "] Logging in as " + logInCharName + "(" + std::to_string( logInCharId ) + ")" );

View file

@ -270,6 +270,7 @@ namespace Core {
" unlocks, "
" QuestTracking, "
" Aetheryte, "
" GMRank, "
" UPDATE_DATE ) "
" VALUES (" + std::to_string( m_iD ) + ", "
+ std::to_string( m_guardianDeity ) + ", "
@ -283,7 +284,8 @@ namespace Core {
+ "UNHEX('" + std::string( Util::binaryToHexString( (uint8_t*)questComplete, 200 ) ) + "'), "
+ "UNHEX('" + std::string( Util::binaryToHexString( (uint8_t*)unlocks, 64 ) ) + "'), "
+ "UNHEX('" + std::string( Util::binaryToHexString( (uint8_t*)questTracking, 10 ) ) + "'), "
+ "UNHEX('" + std::string( Util::binaryToHexString( (uint8_t*)aetherytes, 12 ) ) + "'), NOW());" );
+ "UNHEX('" + std::string( Util::binaryToHexString( (uint8_t*)aetherytes, 12 ) ) + "'),"
+ std::to_string( m_gmRank ) + ", NOW());" );
g_database.execute( "INSERT INTO characlass (CharacterId, Lv_" + std::to_string( g_exdData.m_classJobInfoMap[m_class].exp_idx ) + ", UPDATE_DATE ) "

View file

@ -140,6 +140,16 @@ namespace Core {
m_tribe = tribe;
}
uint8_t getGmRank()
{
return m_birthMonth;
}
void setGmRank( uint8_t rank )
{
m_gmRank = rank;
}
uint32_t m_modelEquip[10];
private:
@ -162,6 +172,8 @@ namespace Core {
std::map<uint8_t, uint16_t> m_classMap;
uint8_t m_look[26];
uint8_t m_gmRank;
char m_name[34];

View file

@ -113,7 +113,7 @@ bool Core::Network::SapphireAPI::createAccount( const std::string& username, con
}
int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std::string& name, const std::string& infoJson )
int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std::string& name, const std::string& infoJson, const int& gmRank )
{
Core::PlayerMinimal newPlayer;
@ -166,6 +166,7 @@ int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std
newPlayer.setBirthDay( tmpVector2.at( 3 ), tmpVector2.at( 2 ) );
newPlayer.setClass( tmpVector2.at( 4 ) );
newPlayer.setTribe( tmpVector2.at( 5 ) );
newPlayer.setGmRank( gmRank );
newPlayer.saveAsNew();

View file

@ -27,7 +27,7 @@ namespace Core
bool createAccount( const std::string& username, const std::string& pass, std::string& sId );
int32_t createCharacter( const int& accountId, const std::string& name, const std::string& infoJson );
int32_t createCharacter( const int& accountId, const std::string& name, const std::string& infoJson, const int& gmRank );
void deleteCharacter( std::string name, uint32_t accountId );

View file

@ -331,7 +331,7 @@ int main(int argc, char* argv[])
}
else
{
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson );
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( "Settings.Parameters.DefaultGMRank", 255 ) );
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
*response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;

View file

@ -110,6 +110,16 @@ uint16_t Core::Entity::Player::getZoneId() const
return m_zoneId;
}
uint8_t Core::Entity::Player::getGmRank() const
{
return m_gmRank;
}
void Core::Entity::Player::setGmRank( uint8_t rank )
{
m_gmRank = rank;
}
uint8_t Core::Entity::Player::getMode() const
{
return m_mode;
@ -780,11 +790,6 @@ void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJ
setSyncFlag( PlayerSyncFlags::ExpLevel );
}
uint8_t Core::Entity::Player::getUserLevel() const
{
return m_userLevel;
}
void Core::Entity::Player::eventActionStart( uint32_t eventId,
uint32_t action,
ActionCallback finishCallback,

View file

@ -478,6 +478,9 @@ public:
uint16_t getZoneId() const;
uint8_t getGmRank() const;
void setGmRank( uint8_t rank );
uint8_t getMode() const;
void setMode( uint8_t mode );
@ -589,7 +592,7 @@ private:
boost::shared_ptr< Common::QuestActive > m_activeQuests[30];
int16_t m_questTracking[5];
uint8_t m_stateFlags[7];
uint8_t m_userLevel;
uint8_t m_gmRank;
uint16_t zoneId;
bool m_bInCombat;

View file

@ -80,7 +80,8 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
"cd.GrandCompany, "
"cd.GrandCompanyRank, "
"cd.CFPenaltyUntil, "
"cd.OpeningSequence "
"cd.OpeningSequence, "
"cd.GMRank "
"FROM charabase AS c "
" INNER JOIN charadetail AS cd "
" ON c.CharacterId = cd.CharacterId "
@ -171,13 +172,13 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
m_openingSequence = field[36].getUInt32();
m_gmRank = field[37].getUInt8();
m_pCell = nullptr;
if( !loadActiveQuests() || !loadClassData() || !loadSearchInfo() )
g_log.error( "Player id " + char_id_str + " data corrupt!" );
m_userLevel = 1;
m_maxHp = getMaxHp();
m_maxMp = getMaxMp();

View file

@ -70,6 +70,12 @@ void Core::DebugCommandHandler::registerCommand( const std::string& n, Core::Deb
void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPtr pPlayer )
{
if( pPlayer->getGmRank() <= 0 )
{
pPlayer->sendUrgent( "You are not allowed to use debug commands." );
return;
}
// define callback pointer
void ( DebugCommandHandler::*pf )( char *, Entity::PlayerPtr, boost::shared_ptr< DebugCommand > );

View file

@ -49,380 +49,384 @@ using namespace Core::Network::Packets::Server;
enum GmCommand
{
Pos = 0x0000,
Lv = 0x0001,
Race = 0x0002,
Tribe = 0x0003,
Sex = 0x0004,
Time = 0x0005,
Weather = 0x0006,
Call = 0x0007,
Inspect = 0x0008,
Speed = 0x0009,
Invis = 0x000D,
Pos = 0x0000,
Lv = 0x0001,
Race = 0x0002,
Tribe = 0x0003,
Sex = 0x0004,
Time = 0x0005,
Weather = 0x0006,
Call = 0x0007,
Inspect = 0x0008,
Speed = 0x0009,
Invis = 0x000D,
Raise = 0x0010,
Kill = 0x000E,
Icon = 0x0012,
Raise = 0x0010,
Kill = 0x000E,
Icon = 0x0012,
Hp = 0x0064,
Mp = 0x0065,
Tp = 0x0066,
Gp = 0x0067,
Hp = 0x0064,
Mp = 0x0065,
Tp = 0x0066,
Gp = 0x0067,
Item = 0x00C8,
Gil = 0x00C9,
Collect = 0x00CA,
Item = 0x00C8,
Gil = 0x00C9,
Collect = 0x00CA,
QuestAccept = 0x012C,
QuestCancel = 0x012D,
QuestComplete = 0x012E,
QuestIncomplete = 0x012F,
QuestSequence = 0x0130,
QuestInspect = 0x0131,
GC = 0x0154,
GCRank = 0x0155,
TeriInfo = 0x025D,
Jump = 0x025E,
JumpNpc = 0x025F,
QuestAccept = 0x012C,
QuestCancel = 0x012D,
QuestComplete = 0x012E,
QuestIncomplete = 0x012F,
QuestSequence = 0x0130,
QuestInspect = 0x0131,
GC = 0x0154,
GCRank = 0x0155,
TeriInfo = 0x025D,
Jump = 0x025E,
JumpNpc = 0x025F,
};
void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer )
void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer )
{
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
uint32_t param1 = inPacket.getValAt< uint32_t >( 0x24 );
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 );
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
if( pPlayer->getGmRank() <= 0 )
return;
g_log.debug( pPlayer->getName() + " used GM1 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) );
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
uint32_t param1 = inPacket.getValAt< uint32_t >( 0x24 );
uint32_t param2 = inPacket.getValAt< uint32_t >( 0x28 );
uint32_t param3 = inPacket.getValAt< uint32_t >( 0x38 );
Core::Entity::ActorPtr targetActor;
g_log.debug( pPlayer->getName() + " used GM1 commandId: " + std::to_string( commandId ) +
", params: " + std::to_string( param1 ) + ", " +
std::to_string( param2 ) + ", " + std::to_string( param3 ) );
Core::Entity::ActorPtr targetActor;
if( pPlayer->getId() == param3 )
{
targetActor = pPlayer;
}
else {
auto inRange = pPlayer->getInRangeActors();
for( auto actor : inRange )
{
if( actor->getId() == param3 )
targetActor = actor;
}
}
if( pPlayer->getId() == param3 )
{
targetActor = pPlayer;
}
else {
auto inRange = pPlayer->getInRangeActors();
for( auto actor : inRange )
{
if( actor->getId() == param3 )
targetActor = actor;
}
}
if( !targetActor )
return;
auto targetPlayer = targetActor->getAsPlayer();
if( !targetActor )
return;
auto targetPlayer = targetActor->getAsPlayer();
switch( commandId )
{
case GmCommand::Kill:
{
targetActor->takeDamage( 9999999 );
pPlayer->sendNotice( "Killed " + std::to_string( targetActor->getId() ) );
break;
}
case GmCommand::QuestSequence:
{
targetPlayer->updateQuest( param1, param2 );
break;
}
case GmCommand::QuestComplete:
{
targetPlayer->finishQuest( param1 );
break;
}
case GmCommand::QuestAccept:
{
targetPlayer->updateQuest( param1, 1 );
break;
}
case GmCommand::QuestCancel:
{
targetPlayer->removeQuest( param1 );
break;
}
case GmCommand::QuestIncomplete:
{
targetPlayer->unfinishQuest( param1 );
break;
}
case GmCommand::Speed:
{
targetPlayer->queuePacket( ActorControlPacket143( pPlayer->getId(), Flee, param1 ) );
pPlayer->sendNotice( "Speed for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Gil:
{
targetPlayer->addCurrency( 1, param1 );
pPlayer->sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() );
break;
}
case GmCommand::Lv:
{
targetPlayer->setLevel( param1 );
pPlayer->sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Hp:
{
targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Hp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Mp:
{
targetPlayer->setMp( param1 );
pPlayer->sendNotice( "Mp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Gp:
{
targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Gp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Sex:
{
targetPlayer->setLookAt( CharaLook::Gender, param1 );
pPlayer->sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetActor->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Race:
{
targetPlayer->setLookAt( CharaLook::Race, param1 );
pPlayer->sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Tribe:
{
targetPlayer->setLookAt( CharaLook::Tribe, param1 );
pPlayer->sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Item:
{
if( param2 < 1 || param2 > 99 )
{
param2 = 1;
}
switch( commandId )
{
case GmCommand::Kill:
{
targetActor->takeDamage( 9999999 );
pPlayer->sendNotice( "Killed " + std::to_string( targetActor->getId() ) );
break;
}
case GmCommand::QuestSequence:
{
targetPlayer->updateQuest( param1, param2 );
break;
}
case GmCommand::QuestComplete:
{
targetPlayer->finishQuest( param1 );
break;
}
case GmCommand::QuestAccept:
{
targetPlayer->updateQuest( param1, 1 );
break;
}
case GmCommand::QuestCancel:
{
targetPlayer->removeQuest( param1 );
break;
}
case GmCommand::QuestIncomplete:
{
targetPlayer->unfinishQuest( param1 );
break;
}
case GmCommand::Speed:
{
targetPlayer->queuePacket( ActorControlPacket143( pPlayer->getId(), Flee, param1 ) );
pPlayer->sendNotice( "Speed for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Gil:
{
targetPlayer->addCurrency( 1, param1 );
pPlayer->sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() );
break;
}
case GmCommand::Lv:
{
targetPlayer->setLevel( param1 );
pPlayer->sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Hp:
{
targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Hp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Mp:
{
targetPlayer->setMp( param1 );
pPlayer->sendNotice( "Mp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Gp:
{
targetPlayer->setHp( param1 );
pPlayer->sendNotice( "Gp for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::Sex:
{
targetPlayer->setLookAt( CharaLook::Gender, param1 );
pPlayer->sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetActor->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Race:
{
targetPlayer->setLookAt( CharaLook::Race, param1 );
pPlayer->sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Tribe:
{
targetPlayer->setLookAt( CharaLook::Tribe, param1 );
pPlayer->sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
targetPlayer->spawn( targetPlayer );
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
break;
}
case GmCommand::Item:
{
if( param2 < 1 || param2 > 99 )
{
param2 = 1;
}
if( ( param1 == 0xcccccccc ) )
{
pPlayer->sendUrgent( "Syntaxerror." );
return;
}
if( ( param1 == 0xcccccccc ) )
{
pPlayer->sendUrgent( "Syntaxerror." );
return;
}
if( !targetPlayer->addItem( -1, param1, param2 ) )
pPlayer->sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
break;
}
case GmCommand::Weather:
{
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
pPlayer->sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
targetPlayer->getName() + " set in range." );
break;
}
case GmCommand::TeriInfo:
{
pPlayer->sendNotice( "ZoneId: " + std::to_string( pPlayer->getZoneId() ) + "\nName: " +
pPlayer->getCurrentZone()->getName() + "\nInternalName: " +
pPlayer->getCurrentZone()->getInternalName() + "\nPopCount: " +
std::to_string( pPlayer->getCurrentZone()->getPopCount() ) +
"\nCurrentWeather:" + std::to_string( pPlayer->getCurrentZone()->getCurrentWeather() ) +
"\nNextWeather:" + std::to_string( pPlayer->getCurrentZone()->getNextWeather() ) );
break;
}
case GmCommand::Jump:
{
if( !targetPlayer->addItem( -1, param1, param2 ) )
pPlayer->sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
break;
}
case GmCommand::Weather:
{
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
pPlayer->sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
targetPlayer->getName() + " set in range." );
break;
}
case GmCommand::TeriInfo:
{
pPlayer->sendNotice( "ZoneId: " + std::to_string( pPlayer->getZoneId() ) + "\nName: " +
pPlayer->getCurrentZone()->getName() + "\nInternalName: " +
pPlayer->getCurrentZone()->getInternalName() + "\nPopCount: " +
std::to_string( pPlayer->getCurrentZone()->getPopCount() ) +
"\nCurrentWeather:" + std::to_string( pPlayer->getCurrentZone()->getCurrentWeather() ) +
"\nNextWeather:" + std::to_string( pPlayer->getCurrentZone()->getNextWeather() ) );
break;
}
case GmCommand::Jump:
{
auto inRange = pPlayer->getInRangeActors();
for( auto actor : inRange )
{
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() );
}
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() + " in range." );
break;
}
case GmCommand::Collect:
{
uint32_t gil = targetPlayer->getCurrency( 1 );
auto inRange = pPlayer->getInRangeActors();
for( auto actor : inRange )
{
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() );
}
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() + " in range." );
break;
}
case GmCommand::Collect:
{
uint32_t gil = targetPlayer->getCurrency( 1 );
if( gil < param1 )
{
pPlayer->sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
}
else
{
targetPlayer->removeCurrency( 1, param1 );
pPlayer->sendNotice( "Removed " + std::to_string( param1 ) +
" Gil from " + targetPlayer->getName() +
"(" + std::to_string( gil ) + " before)" );
}
break;
}
case GmCommand::Icon:
{
targetPlayer->setOnlineStatusMask( param1 );
if( gil < param1 )
{
pPlayer->sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
}
else
{
targetPlayer->removeCurrency( 1, param1 );
pPlayer->sendNotice( "Removed " + std::to_string( param1 ) +
" Gil from " + targetPlayer->getName() +
"(" + std::to_string( gil ) + " before)" );
}
break;
}
case GmCommand::Icon:
{
targetPlayer->setOnlineStatusMask( param1 );
GamePacketNew< FFXIVIpcSetOnlineStatus, ServerZoneIpcType > statusPacket( targetPlayer->getId() );
statusPacket.data().onlineStatusFlags = param1;
queueOutPacket( statusPacket );
GamePacketNew< FFXIVIpcSetOnlineStatus, ServerZoneIpcType > statusPacket( targetPlayer->getId() );
statusPacket.data().onlineStatusFlags = param1;
queueOutPacket( statusPacket );
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = param1;
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket );
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
searchInfoPacket.data().onlineStatusFlags = param1;
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
sprintf( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
targetPlayer->queuePacket( searchInfoPacket );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ),
true );
pPlayer->sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::GC:
{
targetPlayer->setGc( param1 );
pPlayer->sendNotice( "GC for " + targetPlayer->getName() +
" was set to " + std::to_string( targetPlayer->getGc() ) );
break;
}
case GmCommand::GCRank:
{
targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 );
pPlayer->sendNotice( "GC Rank for " + targetPlayer->getName() +
" for GC " + std::to_string( targetPlayer->getGc()) +
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
break;
}
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ),
true );
pPlayer->sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
break;
}
case GmCommand::GC:
{
targetPlayer->setGc( param1 );
pPlayer->sendNotice( "GC for " + targetPlayer->getName() +
" was set to " + std::to_string( targetPlayer->getGc() ) );
break;
}
case GmCommand::GCRank:
{
targetPlayer->setGcRankAt( targetPlayer->getGc() - 1, param1 );
pPlayer->sendNotice( "GC Rank for " + targetPlayer->getName() +
" for GC " + std::to_string( targetPlayer->getGc() ) +
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
break;
}
default:
pPlayer->sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
break;
}
default:
pPlayer->sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
break;
}
pPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
targetPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
pPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
targetPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
}
void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket,
Entity::PlayerPtr pPlayer )
void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer )
{
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
std::string param1 = inPacket.getStringAt( 0x34 );
if( pPlayer->getGmRank() <= 0 )
return;
g_log.debug( pPlayer->getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
uint32_t commandId = inPacket.getValAt< uint32_t >( 0x20 );
std::string param1 = inPacket.getStringAt( 0x34 );
auto targetSession = g_serverZone.getSession( param1 );
Core::Entity::ActorPtr targetActor;
g_log.debug( pPlayer->getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
if( targetSession != nullptr )
{
targetActor = targetSession->getPlayer();
}
else
{
if( param1 == "self" )
{
targetActor = pPlayer;
}
else
{
pPlayer->sendUrgent("Player " + param1 + " not found on this server.");
return;
}
}
auto targetSession = g_serverZone.getSession( param1 );
Core::Entity::ActorPtr targetActor;
if( !targetActor )
return;
auto targetPlayer = targetActor->getAsPlayer();
if( targetSession != nullptr )
{
targetActor = targetSession->getPlayer();
}
else
{
if( param1 == "self" )
{
targetActor = pPlayer;
}
else
{
pPlayer->sendUrgent( "Player " + param1 + " not found on this server." );
return;
}
}
switch( commandId )
{
case GmCommand::Raise:
{
targetPlayer->resetHp();
targetPlayer->resetMp();
targetPlayer->setStatus( Entity::Actor::ActorStatus::Idle );
targetPlayer->setSyncFlag( Status );
if( !targetActor )
return;
auto targetPlayer = targetActor->getAsPlayer();
targetPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
pPlayer->sendNotice( "Raised " + targetPlayer->getName());
break;
}
case GmCommand::Jump:
{
if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
{
pPlayer->setZone( targetPlayer->getZoneId() );
}
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() );
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName());
break;
}
case GmCommand::Call:
{
if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
targetPlayer->setZone( pPlayer->getZoneId() );
switch( commandId )
{
case GmCommand::Raise:
{
targetPlayer->resetHp();
targetPlayer->resetMp();
targetPlayer->setStatus( Entity::Actor::ActorStatus::Idle );
targetPlayer->setSyncFlag( Status );
targetPlayer->changePosition( pPlayer->getPos().x, pPlayer->getPos().y, pPlayer->getPos().z,
pPlayer->getRotation() );
pPlayer->sendNotice( "Calling " + targetPlayer->getName() );
break;
}
case GmCommand::Inspect:
{
pPlayer->sendNotice( "Name: " + targetPlayer->getName() +
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() +
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
"\nClass: " + std::to_string( targetPlayer->getClass() ) +
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
break;
}
targetPlayer->sendToInRangeSet( ActorControlPacket143( pPlayer->getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatus,
static_cast< uint8_t >( Entity::Actor::ActorStatus::Idle ) ), true );
pPlayer->sendNotice( "Raised " + targetPlayer->getName() );
break;
}
case GmCommand::Jump:
{
if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
{
pPlayer->setZone( targetPlayer->getZoneId() );
}
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() );
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() );
break;
}
case GmCommand::Call:
{
if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
targetPlayer->setZone( pPlayer->getZoneId() );
default:
pPlayer->sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
break;
}
targetPlayer->changePosition( pPlayer->getPos().x, pPlayer->getPos().y, pPlayer->getPos().z,
pPlayer->getRotation() );
pPlayer->sendNotice( "Calling " + targetPlayer->getName() );
break;
}
case GmCommand::Inspect:
{
pPlayer->sendNotice( "Name: " + targetPlayer->getName() +
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
"\nZone: " + targetPlayer->getCurrentZone()->getName() +
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
"\nClass: " + std::to_string( targetPlayer->getClass() ) +
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
break;
}
pPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
targetPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
default:
pPlayer->sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
break;
}
pPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
targetPlayer->setSyncFlag( Common::PlayerSyncFlags::All );
}

View file

@ -45,7 +45,7 @@ namespace Server {
m_data.tPCurr = pPlayer->getTp();
m_data.hPMax = pPlayer->getMaxHp();
m_data.mPMax = pPlayer->getMaxMp();
m_data.gmRank = 0xff;
m_data.gmRank = pPlayer->getGmRank();
//m_data.tPMax = 3000;
m_data.level = pPlayer->getLevel();
memcpy( m_data.look, pPlayer->getLookArray(), 26 );