From 570823166bb31c5ab81a8b5341da5a45bccffe71 Mon Sep 17 00:00:00 2001 From: Dantestyle Date: Mon, 30 Jul 2018 23:26:27 +0200 Subject: [PATCH 1/3] [Commands] QuestBitFlags Debug command --- .../DebugCommand/DebugCommandHandler.cpp | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index f80a0926..4d6f433a 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -159,7 +159,6 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost: pLog->debug( "[" + std::to_string( player.getId() ) + "] " + "subCommand " + subCommand + " params: " + params ); - if( ( ( subCommand == "pos" ) || ( subCommand == "posr" ) ) && ( params != "" ) ) { int32_t posX; @@ -321,6 +320,102 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost: { pTerriMgr->disableCurrentFestival(); } + else if ( subCommand == "BitFlag8" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if ( player.hasQuest( questId ) ) + { + if ( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag8( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } + else if ( subCommand == "BitFlag16" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if( player.hasQuest( questId ) ) + { + if( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag16( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } + else if ( subCommand == "BitFlag24" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if( player.hasQuest( questId ) ) + { + if( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag24( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } + else if ( subCommand == "BitFlag32" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if( player.hasQuest( questId ) ) + { + if( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag32( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } + else if ( subCommand == "BitFlag40" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if( player.hasQuest( questId ) ) + { + if( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag40( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } + else if ( subCommand == "BitFlag48" ) + { + uint16_t questId; + uint8_t questBit; + sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + + if( player.hasQuest( questId ) ) + { + if( !questBit == 0 || !questId == 0 ) + player.setQuestBitFlag48( questId, questBit, true ); + else + player.sendDebug( "Params are not correct" ); + } + else + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + } else { player.sendUrgent( subCommand + " is not a valid SET command." ); From ab45ff5b2b444f7ab7715b33f11830ec3001c823 Mon Sep 17 00:00:00 2001 From: Dantestyle Date: Tue, 31 Jul 2018 00:07:54 +0200 Subject: [PATCH 2/3] restyle it --- .../DebugCommand/DebugCommandHandler.cpp | 122 ++++++------------ 1 file changed, 39 insertions(+), 83 deletions(-) diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 4d6f433a..f3f88c7b 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -320,101 +320,57 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost: { pTerriMgr->disableCurrentFestival(); } - else if ( subCommand == "BitFlag8" ) + else if ( subCommand == "BitFlag" ) { uint16_t questId; uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); + int8_t BitFlag; + sscanf( params.c_str(), "%hu %hhu %hu", &BitFlag, &questId, &questBit ); - if ( player.hasQuest( questId ) ) + if( !player.hasQuest( questId ) ) { - if ( !questBit == 0 || !questId == 0 ) + player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); + return; + } + if( questBit == 0 || questId == 0 ) + { + player.sendDebug( "Params are not correct" ); + return; + } + + switch ( BitFlag ) + { + case 8: + { player.setQuestBitFlag8( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); - } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); - } - else if ( subCommand == "BitFlag16" ) - { - uint16_t questId; - uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); - - if( player.hasQuest( questId ) ) - { - if( !questBit == 0 || !questId == 0 ) + break; + } + case 16: + { player.setQuestBitFlag16( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); - } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); - } - else if ( subCommand == "BitFlag24" ) - { - uint16_t questId; - uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); - - if( player.hasQuest( questId ) ) - { - if( !questBit == 0 || !questId == 0 ) + break; + } + case 24: + { player.setQuestBitFlag24( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); - } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); - } - else if ( subCommand == "BitFlag32" ) - { - uint16_t questId; - uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); - - if( player.hasQuest( questId ) ) - { - if( !questBit == 0 || !questId == 0 ) + break; + } + case 32: + { player.setQuestBitFlag32( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); - } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); - } - else if ( subCommand == "BitFlag40" ) - { - uint16_t questId; - uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); - - if( player.hasQuest( questId ) ) - { - if( !questBit == 0 || !questId == 0 ) + break; + } + case 40: + { player.setQuestBitFlag40( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); - } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); - } - else if ( subCommand == "BitFlag48" ) - { - uint16_t questId; - uint8_t questBit; - sscanf( params.c_str(), "%hu %hhu", &questId, &questBit ); - - if( player.hasQuest( questId ) ) - { - if( !questBit == 0 || !questId == 0 ) + break; + } + case 48: + { player.setQuestBitFlag48( questId, questBit, true ); - else - player.sendDebug( "Params are not correct" ); + break; + } } - else - player.sendDebug( "Player doesn't have the quest with ID: " + std::to_string( questId ) ); } else { From 7034aee653f611f3a4336726dbb148acb82f9ee5 Mon Sep 17 00:00:00 2001 From: Dantestyle Date: Tue, 31 Jul 2018 00:09:29 +0200 Subject: [PATCH 3/3] Only for Maruhhuhu :D --- src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index f3f88c7b..9c93527f 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -325,7 +325,7 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost: uint16_t questId; uint8_t questBit; int8_t BitFlag; - sscanf( params.c_str(), "%hu %hhu %hu", &BitFlag, &questId, &questBit ); + sscanf( params.c_str(), "%hhu %hu %hhu", &BitFlag, &questId, &questBit ); if( !player.hasQuest( questId ) ) {