1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 08:57:44 +00:00

some api json cleanup

This commit is contained in:
NotAdam 2019-07-20 21:42:21 +10:00
parent 91497e8ab2
commit 9a5dcaa57e

View file

@ -139,22 +139,80 @@ std::string PlayerMinimal::getLevelsString()
std::string PlayerMinimal::getInfoJson() std::string PlayerMinimal::getInfoJson()
{ {
std::string charDetails = "{\"content\":[\"" + std::string( getName() ) + "\"," + auto payload = nlohmann::json();
getLevelsString() + "," auto& c = payload["content"];
"\"0\",\"0\",\"0\",\"" +
std::to_string( getBirthMonth() ) + c.push_back( getName() );
"\",\"" + std::to_string( getBirthDay() ) +
"\",\"" + std::to_string( getGuardianDeity() ) + // class levels
"\",\"" + std::to_string( m_class ) + auto levelsArray = nlohmann::json();
"\",\"0\",\"" + std::to_string( getZoneId() ) + for( int i = 0; i < Common::CLASSJOB_SLOTS; ++i )
"\",\"0\"," + {
"[" + getLookString() + "]," + // these must be strings
"\"" + std::to_string( m_modelMainWeapon ) + "\",\"" + std::to_string( m_modelSubWeapon ) + "\"," + levelsArray.push_back( std::to_string( m_classMap[ i ] ) );
"[" + getModelString() + "]," + }
"\"1\",\"0\",\"0\",\"0\",\"" + std::to_string( m_equipDisplayFlags ) +
"\",\"0\",\"\",\"0\",\"0\"]," + c.push_back( levelsArray );
"\"classname\":\"ClientSelectData\",\"classid\":116}";
return charDetails; // unknowns
c.push_back( "0" );
c.push_back( "0" );
c.push_back( "0" );
//
c.push_back( std::to_string( getBirthMonth() ) );
c.push_back( std::to_string( getBirthDay() ) );
c.push_back( std::to_string( getGuardianDeity() ) );
c.push_back( std::to_string( m_class ) );
// unknown
c.push_back( "0" );
c.push_back( std::to_string( getZoneId() ) );
// unknown
c.push_back( "0" );
// look map
auto lookArray = nlohmann::json();
for( auto& it : m_lookMap )
{
lookArray.push_back( std::to_string( it.second ) );
}
c.push_back( lookArray );
// weapons
c.push_back( std::to_string( m_modelMainWeapon ) );
c.push_back( std::to_string( m_modelSubWeapon ) );
// model
auto modelArray = nlohmann::json();
for( auto i : m_modelEquip )
{
modelArray.push_back( std::to_string( i ) );
}
c.push_back( modelArray );
// unknowns
c.push_back( "1" );
c.push_back( "0" );
c.push_back( "0" );
c.push_back( "0" );
c.push_back( std::to_string( m_equipDisplayFlags ) );
// unknowns
c.push_back( "0" );
c.push_back( "0" );
c.push_back( "0" );
c.push_back( "0" );
payload["classname"] = "ClientSelectData";
payload["classid"] = 116;
return payload.dump();
} }
uint8_t PlayerMinimal::getClassLevel() uint8_t PlayerMinimal::getClassLevel()