1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00

Char creation will no longer crash lobby/api

This commit is contained in:
Mordred 2018-11-01 12:49:51 +01:00
parent 6d2c012cf2
commit 6aa7102b4e
3 changed files with 11 additions and 10 deletions

View file

@ -132,14 +132,17 @@ Core::Network::SapphireAPI::createCharacter( const int& accountId, const std::st
std::vector< int32_t > tmpVector2;
for( auto& v : json["content"] )
{
if( v.is_array() )
{
for( auto& vs : v )
{
tmpVector.push_back( vs.get< int >() );
tmpVector.push_back( std::stoi( std::string( vs ) ) );
}
}
if( !v.empty() )
tmpVector2.push_back( v.get< int >() );
if( !v.empty() && !v.is_array() )
tmpVector2.push_back( std::stoi( std::string( v ) ) );
}
// leaving this in for now for reference

View file

@ -488,9 +488,7 @@ void checkSession( shared_ptr< HttpServer::Response > response, shared_ptr< Http
else
{
std::string json_string = nlohmann::json( {
{ "result", result },
{ "result2", "penis" },
{ "result3", "wtf" }
{ "result", result }
} ).dump()
;
*response << buildHttpResponse( 200, json_string, JSON );

View file

@ -143,7 +143,7 @@ uint32_t Core::Network::RestConnector::getNextCharId()
if( content.find( "invalid" ) == std::string::npos )
{
return json["result"].get< uint32_t >();
return std::stoi( std::string( json["result"] ) );
}
else
{
@ -182,7 +182,7 @@ uint64_t Core::Network::RestConnector::getNextContentId()
if( content.find( "invalid" ) == std::string::npos )
{
return json["result"].get< uint64_t >();
return std::stoll( std::string( json["result"] ) );
}
else
{
@ -313,7 +313,7 @@ int Core::Network::RestConnector::createCharacter( char* sId, std::string name,
}
if( content.find( "invalid" ) == std::string::npos )
return json["result"].get< int >();
return std::stoi( json["result"].get< std::string >() );
return -1;
}
else