1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Merge pull request #10 from amibu01/master

Add "@set classjob" command
This commit is contained in:
SapphireMordred 2017-08-09 14:41:23 +02:00 committed by GitHub
commit 188db87409
3 changed files with 34 additions and 0 deletions

View file

@ -243,6 +243,22 @@ void Core::GameCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlayer
pPlayer->resetDiscovery();
pPlayer->queuePacket( Network::Packets::Server::InitUIPacket( pPlayer ) );
}
else if( subCommand == "classjob" )
{
int32_t id;
sscanf( params.c_str(), "%d", &id );
g_log.debug( std::to_string( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) ) );
if( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) == 0 )
{
pPlayer->setLevelForClass( 1, static_cast<Core::Common::ClassJob> ( id ) );
pPlayer->setClassJob( static_cast<Core::Common::ClassJob> ( id ) );
}
else
pPlayer->setClassJob( static_cast<Core::Common::ClassJob> ( id ) );
}
}

View file

@ -700,6 +700,12 @@ uint8_t Core::Entity::Player::getLevel() const
return static_cast< uint8_t >( m_classArray[classJobIndex] );
}
uint8_t Core::Entity::Player::getLevelForClass( Core::Common::ClassJob pClass ) const
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( pClass )].exp_idx;
return static_cast< uint8_t >( m_classArray[classJobIndex] );
}
uint32_t Core::Entity::Player::getExp() const
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
@ -755,6 +761,14 @@ void Core::Entity::Player::setLevel( uint8_t level )
setSyncFlag( PlayerSyncFlags::ExpLevel );
}
void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJob classjob )
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( classjob )].exp_idx;
m_classArray[classJobIndex] = level;
setSyncFlag( PlayerSyncFlags::ExpLevel );
}
uint8_t Core::Entity::Player::getUserLevel() const
{
return m_userLevel;

View file

@ -231,6 +231,8 @@ public:
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! returns the level of the currently active class / job */
uint8_t getLevel() const override;
/*! returns the level of the provided class / job */
uint8_t getLevelForClass( Core::Common::ClassJob pClass ) const;
/*! returns the exp of the currently active class / job */
uint32_t getExp() const;
/*! sets the exp of the currently active class / job */
@ -241,6 +243,8 @@ public:
void gainLevel();
/*! set level on the currently active class / job to given level */
void setLevel( uint8_t level );
/*! set level on the provided class / job to given level */
void setLevelForClass( uint8_t level, Core::Common::ClassJob classjob );
/*! change class or job to given class / job */
void setClassJob( Core::Common::ClassJob classJob );
/*! returns a pointer to the class array */