From a73721764f2d27eba09316317b5fa3a7afe6bc82 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Thu, 19 Oct 2017 16:18:16 -0700 Subject: [PATCH 01/22] Fixing some type alignments via casting - static_cast for reasonable values - at least one stray float --- src/servers/Server_Common/Crypt/base64.cpp | 4 ++-- src/servers/Server_Lobby/client_http.hpp | 6 +++--- src/servers/Server_REST/main.cpp | 2 +- src/servers/Server_REST/server_http.hpp | 2 +- src/servers/Server_Zone/Actor/BattleNpc.cpp | 2 +- src/servers/Server_Zone/Actor/CalcBattle.cpp | 4 ++-- src/servers/Server_Zone/Actor/Player.cpp | 2 +- src/servers/Server_Zone/Actor/PlayerQuest.cpp | 2 +- src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/servers/Server_Common/Crypt/base64.cpp b/src/servers/Server_Common/Crypt/base64.cpp index 3ad4db0d..c6c23efc 100644 --- a/src/servers/Server_Common/Crypt/base64.cpp +++ b/src/servers/Server_Common/Crypt/base64.cpp @@ -93,7 +93,7 @@ std::string Core::Util::base64_decode( std::string const& encoded_string ) { char_array_4[i++] = encoded_string[in_]; in_++; if( i == 4 ) { for( i = 0; i < 4; i++ ) - char_array_4[i] = base64_chars.find( char_array_4[i] ); + char_array_4[i] = static_cast( base64_chars.find( char_array_4[i] ) ); char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 ); char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 ); @@ -110,7 +110,7 @@ std::string Core::Util::base64_decode( std::string const& encoded_string ) { char_array_4[j] = 0; for( j = 0; j < 4; j++ ) - char_array_4[j] = base64_chars.find( char_array_4[j] ); + char_array_4[j] = static_cast( base64_chars.find( char_array_4[j] ) ); char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 ); char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 ); diff --git a/src/servers/Server_Lobby/client_http.hpp b/src/servers/Server_Lobby/client_http.hpp index c7b9137b..b099c74f 100644 --- a/src/servers/Server_Lobby/client_http.hpp +++ b/src/servers/Server_Lobby/client_http.hpp @@ -266,7 +266,7 @@ namespace SimpleWeb { if( content_length>num_additional_bytes ) { auto timer = get_timeout_timer(); boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( content_length - num_additional_bytes ), + boost::asio::transfer_exactly( static_cast( content_length - num_additional_bytes ) ), [this, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); @@ -307,7 +307,7 @@ namespace SimpleWeb { line.pop_back(); std::streamsize length = stol( line, 0, 16 ); - auto num_additional_bytes = static_cast( response->content_buffer.size() - bytes_transferred ); + auto num_additional_bytes = response->content_buffer.size() - bytes_transferred; auto post_process = [this, &response, &streambuf, length] { std::ostream stream( &streambuf ); @@ -332,7 +332,7 @@ namespace SimpleWeb { if( ( 2 + length )>num_additional_bytes ) { auto timer = get_timeout_timer(); boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( 2 + length - num_additional_bytes ), + boost::asio::transfer_exactly( static_cast( 2 + length - num_additional_bytes ) ), [this, post_process, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index 7173db63..b509e9cf 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -149,7 +149,7 @@ bool loadSettings( int32_t argc, char* argv[] ) params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); - server.config.port = std::stoul( m_pConfig->getValue( "Settings.General.HttpPort", "80" ) ); + server.config.port = static_cast( std::stoul( m_pConfig->getValue( "Settings.General.HttpPort", "80" ) ) ); if( !g_database.initialize( params ) ) { diff --git a/src/servers/Server_REST/server_http.hpp b/src/servers/Server_REST/server_http.hpp index 82ee541a..64f10234 100644 --- a/src/servers/Server_REST/server_http.hpp +++ b/src/servers/Server_REST/server_http.hpp @@ -282,7 +282,7 @@ namespace SimpleWeb { //Set timeout on the following boost::asio::async-read or write function auto timer=this->get_timeout_timer(socket, config.timeout_content); boost::asio::async_read(*socket, request->streambuf, - boost::asio::transfer_exactly(content_length-num_additional_bytes), + boost::asio::transfer_exactly(static_cast(content_length-num_additional_bytes)), [this, socket, request, timer] (const boost::system::error_code& ec, size_t /*bytes_transferred*/) { if(timer) diff --git a/src/servers/Server_Zone/Actor/BattleNpc.cpp b/src/servers/Server_Zone/Actor/BattleNpc.cpp index d8f098e9..d9d62e36 100644 --- a/src/servers/Server_Zone/Actor/BattleNpc.cpp +++ b/src/servers/Server_Zone/Actor/BattleNpc.cpp @@ -451,7 +451,7 @@ void Core::Entity::BattleNpc::onDeath() // todo: this is actually retarded, we need real rand() - srand( time( NULL ) ); + srand( static_cast( time( NULL ) ) ); auto pPlayer = pHateEntry->m_pActor->getAsPlayer(); pPlayer->gainExp( exp ); diff --git a/src/servers/Server_Zone/Actor/CalcBattle.cpp b/src/servers/Server_Zone/Actor/CalcBattle.cpp index 5bc0d252..9687b02a 100644 --- a/src/servers/Server_Zone/Actor/CalcBattle.cpp +++ b/src/servers/Server_Zone/Actor/CalcBattle.cpp @@ -38,7 +38,7 @@ float CalcBattle::calculateBaseStat( PlayerPtr pPlayer ) // SB Base Stat Formula (Aligned) if ( level > 60 ) { - base = ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8); + base = static_cast( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) ); } // HW Base Stat Formula (Aligned) else if ( level > 50 ) @@ -77,7 +77,7 @@ uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer ) // These values are not precise. if ( level >= 60 ) - approxBaseHp = 2600 + ( level - 60 ) * 100; + approxBaseHp = static_cast( 2600 + ( level - 60 ) * 100 ); else if ( level >= 50 ) approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) ); else diff --git a/src/servers/Server_Zone/Actor/Player.cpp b/src/servers/Server_Zone/Actor/Player.cpp index 39d5d709..349fc15e 100644 --- a/src/servers/Server_Zone/Actor/Player.cpp +++ b/src/servers/Server_Zone/Actor/Player.cpp @@ -345,7 +345,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type ) void Core::Entity::Player::forceZoneing( uint32_t zoneId ) { - m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0 ); + m_queuedZoneing = boost::make_shared< QueuedZoning >( zoneId, getPos(), Util::getTimeMs(), 0.f ); //performZoning( zoneId, Common::ZoneingType::None, getPos() ); } diff --git a/src/servers/Server_Zone/Actor/PlayerQuest.cpp b/src/servers/Server_Zone/Actor/PlayerQuest.cpp index 668460a7..ab617d2e 100644 --- a/src/servers/Server_Zone/Actor/PlayerQuest.cpp +++ b/src/servers/Server_Zone/Actor/PlayerQuest.cpp @@ -1147,7 +1147,7 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional exp = questInfo->reward_exp_factor; - uint16_t rewardItemCount = questInfo->reward_item.size(); + auto rewardItemCount = questInfo->reward_item.size(); uint16_t optionalItemCount = questInfo->reward_item_optional.size() > 0 ? 1 : 0; uint32_t gilReward = questInfo->reward_gil; diff --git a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp index 9a6dcd6a..df033f74 100644 --- a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp @@ -216,8 +216,8 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[pPlayer->getZoneId()].aetheryte_index ); // calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets - auto cost = ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + - pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100; + auto cost = static_cast ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + + pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 ); // cap at 999 gil cost = cost > 999 ? 999 : cost; From 279563b90fcf1b34548e51797c6eb11aa2f70a95 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Fri, 20 Oct 2017 14:12:24 -0700 Subject: [PATCH 02/22] Fixing spacing issues for casts --- src/servers/Server_Common/Crypt/base64.cpp | 4 ++-- src/servers/Server_Lobby/client_http.hpp | 4 ++-- src/servers/Server_REST/main.cpp | 2 +- src/servers/Server_REST/server_http.hpp | 2 +- src/servers/Server_Zone/Actor/BattleNpc.cpp | 2 +- src/servers/Server_Zone/Actor/CalcBattle.cpp | 4 ++-- src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/servers/Server_Common/Crypt/base64.cpp b/src/servers/Server_Common/Crypt/base64.cpp index c6c23efc..8037dec4 100644 --- a/src/servers/Server_Common/Crypt/base64.cpp +++ b/src/servers/Server_Common/Crypt/base64.cpp @@ -93,7 +93,7 @@ std::string Core::Util::base64_decode( std::string const& encoded_string ) { char_array_4[i++] = encoded_string[in_]; in_++; if( i == 4 ) { for( i = 0; i < 4; i++ ) - char_array_4[i] = static_cast( base64_chars.find( char_array_4[i] ) ); + char_array_4[i] = static_cast< uint8_t >( base64_chars.find( char_array_4[i] ) ); char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 ); char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 ); @@ -110,7 +110,7 @@ std::string Core::Util::base64_decode( std::string const& encoded_string ) { char_array_4[j] = 0; for( j = 0; j < 4; j++ ) - char_array_4[j] = static_cast( base64_chars.find( char_array_4[j] ) ); + char_array_4[j] = static_cast< uint8_t >( base64_chars.find( char_array_4[j] ) ); char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 ); char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 ); diff --git a/src/servers/Server_Lobby/client_http.hpp b/src/servers/Server_Lobby/client_http.hpp index b099c74f..656b8d01 100644 --- a/src/servers/Server_Lobby/client_http.hpp +++ b/src/servers/Server_Lobby/client_http.hpp @@ -266,7 +266,7 @@ namespace SimpleWeb { if( content_length>num_additional_bytes ) { auto timer = get_timeout_timer(); boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( static_cast( content_length - num_additional_bytes ) ), + boost::asio::transfer_exactly( static_cast< size_t >( content_length - num_additional_bytes ) ), [this, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); @@ -332,7 +332,7 @@ namespace SimpleWeb { if( ( 2 + length )>num_additional_bytes ) { auto timer = get_timeout_timer(); boost::asio::async_read( *socket, response->content_buffer, - boost::asio::transfer_exactly( static_cast( 2 + length - num_additional_bytes ) ), + boost::asio::transfer_exactly( static_cast< size_t >( 2 + length - num_additional_bytes ) ), [this, post_process, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) { if( timer ) timer->cancel(); diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index b509e9cf..28f7c16d 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -149,7 +149,7 @@ bool loadSettings( int32_t argc, char* argv[] ) params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); - server.config.port = static_cast( std::stoul( m_pConfig->getValue( "Settings.General.HttpPort", "80" ) ) ); + server.config.port = static_cast< unsigned short >( std::stoul( m_pConfig->getValue( "Settings.General.HttpPort", "80" ) ) ); if( !g_database.initialize( params ) ) { diff --git a/src/servers/Server_REST/server_http.hpp b/src/servers/Server_REST/server_http.hpp index 64f10234..e946afe2 100644 --- a/src/servers/Server_REST/server_http.hpp +++ b/src/servers/Server_REST/server_http.hpp @@ -282,7 +282,7 @@ namespace SimpleWeb { //Set timeout on the following boost::asio::async-read or write function auto timer=this->get_timeout_timer(socket, config.timeout_content); boost::asio::async_read(*socket, request->streambuf, - boost::asio::transfer_exactly(static_cast(content_length-num_additional_bytes)), + boost::asio::transfer_exactly(static_cast< size_t >(content_length-num_additional_bytes)), [this, socket, request, timer] (const boost::system::error_code& ec, size_t /*bytes_transferred*/) { if(timer) diff --git a/src/servers/Server_Zone/Actor/BattleNpc.cpp b/src/servers/Server_Zone/Actor/BattleNpc.cpp index d9d62e36..6e64015a 100644 --- a/src/servers/Server_Zone/Actor/BattleNpc.cpp +++ b/src/servers/Server_Zone/Actor/BattleNpc.cpp @@ -451,7 +451,7 @@ void Core::Entity::BattleNpc::onDeath() // todo: this is actually retarded, we need real rand() - srand( static_cast( time( NULL ) ) ); + srand( static_cast< unsigned int> ( time( NULL ) ) ); auto pPlayer = pHateEntry->m_pActor->getAsPlayer(); pPlayer->gainExp( exp ); diff --git a/src/servers/Server_Zone/Actor/CalcBattle.cpp b/src/servers/Server_Zone/Actor/CalcBattle.cpp index 9687b02a..ce2e3a84 100644 --- a/src/servers/Server_Zone/Actor/CalcBattle.cpp +++ b/src/servers/Server_Zone/Actor/CalcBattle.cpp @@ -38,7 +38,7 @@ float CalcBattle::calculateBaseStat( PlayerPtr pPlayer ) // SB Base Stat Formula (Aligned) if ( level > 60 ) { - base = static_cast( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) ); + base = static_cast< float >( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) ); } // HW Base Stat Formula (Aligned) else if ( level > 50 ) @@ -77,7 +77,7 @@ uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer ) // These values are not precise. if ( level >= 60 ) - approxBaseHp = static_cast( 2600 + ( level - 60 ) * 100 ); + approxBaseHp = static_cast< float >( 2600 + ( level - 60 ) * 100 ); else if ( level >= 50 ) approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) ); else diff --git a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp index df033f74..0f53871d 100644 --- a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp @@ -216,7 +216,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in auto fromAetheryte = g_exdData.getAetheryteInfo( g_exdData.m_zoneInfoMap[pPlayer->getZoneId()].aetheryte_index ); // calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets - auto cost = static_cast ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + + auto cost = static_cast< uint16_t > ( ( sqrt( pow( fromAetheryte->map_coord_x - targetAetheryte->map_coord_x, 2 ) + pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 ); // cap at 999 gil From 6789dad0e8cab1ce1e2d991e7c3481a4eb22720d Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 20 Oct 2017 22:50:21 +0100 Subject: [PATCH 03/22] fixed map export legit this time --- src/tools/pcb_reader/main.cpp | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/tools/pcb_reader/main.cpp b/src/tools/pcb_reader/main.cpp index 7125efd6..647d08e5 100644 --- a/src/tools/pcb_reader/main.cpp +++ b/src/tools/pcb_reader/main.cpp @@ -258,12 +258,16 @@ int main( int argc, char* argv[] ) } return false; }; - auto pushVerts = [&]( const PCB_FILE& pcb_file, const std::string& name, const vec3* scale = nullptr, const vec3* rotation = nullptr, const vec3* translation = nullptr ) + auto pushVerts = [&]( const PCB_FILE& pcb_file, const std::string& name, + const vec3* scale = nullptr, + const vec3* rotation = nullptr, + const vec3* translation = nullptr, + const SGB_MODEL_ENTRY* pSgbEntry = nullptr) { char name2[0x100]; memset( name2, 0, 0x100 ); sprintf( &name2[0], "%s_%u", &name[0], objCount[name]++ ); - //fprintf( fp_out, "o %s\n", &name2[0] ); + fprintf( fp_out, "o %s\n", &name2[0] ); uint32_t groupCount = 0; for( const auto &entry : pcb_file.entries ) @@ -274,6 +278,20 @@ int main( int argc, char* argv[] ) auto makeTranslation = [&]( vec3& v ) { + if( pSgbEntry ) + { + v.x *= pSgbEntry->header.scale.x; + v.y *= pSgbEntry->header.scale.y; + v.z *= pSgbEntry->header.scale.z; + + v = v * matrix4::rotateX( pSgbEntry->header.rotation.x ); + v = v * matrix4::rotateY( pSgbEntry->header.rotation.y ); + v = v * matrix4::rotateZ( pSgbEntry->header.rotation.z ); + + v.x += pSgbEntry->header.translation.x; + v.y += pSgbEntry->header.translation.y; + v.z += pSgbEntry->header.translation.z; + } if( scale ) { v.x *= scale->x; @@ -338,7 +356,7 @@ int main( int argc, char* argv[] ) totalGroups++; for( const auto& pEntry : group.entries ) { - LGB_GIMMICK_ENTRY* pGimmick = dynamic_cast( pEntry.get() ); + auto pGimmick = dynamic_cast( pEntry.get() ); auto pBgParts = dynamic_cast( pEntry.get() ); std::string fileName( "" ); @@ -346,7 +364,7 @@ int main( int argc, char* argv[] ) totalGroupEntries++; // write files - auto writeOutput = [&]( const std::string& fileName, const vec3* scale, const vec3* rotation, const vec3* translation ) -> bool + auto writeOutput = [&]( const std::string& fileName, const vec3* scale, const vec3* rotation, const vec3* translation, const SGB_MODEL_ENTRY* pModel = nullptr) -> bool { { const auto& it = pcbFiles.find( fileName ); @@ -361,7 +379,7 @@ int main( int argc, char* argv[] ) if( it != pcbFiles.end() ) { const auto& pcb_file = it->second; - pushVerts( pcb_file, fileName, scale, rotation, translation ); + pushVerts( pcb_file, fileName, scale, rotation, translation, pModel ); } return true; }; @@ -369,14 +387,7 @@ int main( int argc, char* argv[] ) if( pBgParts ) { fileName = pBgParts->collisionFileName; - - if( !writeOutput( fileName, &pBgParts->header.scale, &pBgParts->header.rotation, &pBgParts->header.translation ) ) - { - fileName = pBgParts->modelFileName; - boost::replace_all( fileName, "bgparts", "collision" ); - boost::replace_all( fileName, ".mdl", ".pcb" ); - writeOutput( fileName, &pBgParts->header.scale, &pBgParts->header.rotation, &pBgParts->header.translation ); - } + writeOutput( fileName, &pBgParts->header.scale, &pBgParts->header.rotation, &pBgParts->header.translation ); } // gimmick entry @@ -401,13 +412,7 @@ int main( int argc, char* argv[] ) { auto pModel = dynamic_cast( pEntry.get() ); fileName = pModel->collisionFileName; - if( !writeOutput( fileName, &pGimmick->header.scale, &pGimmick->header.rotation, &pGimmick->header.translation ) ) - { - fileName = pModel->modelFileName; - boost::replace_all( fileName, "bgparts", "collision" ); - boost::replace_all( fileName, ".mdl", ".pcb" ); - writeOutput( fileName, &pGimmick->header.scale, &pGimmick->header.rotation, &pGimmick->header.translation ); - } + writeOutput( fileName, &pGimmick->header.scale, &pGimmick->header.rotation, &pGimmick->header.translation, pModel ); } } } From 33203148d726506796c7975019c243db0759e92d Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 16:41:09 +1100 Subject: [PATCH 04/22] fix a vs xml linting error --- bin/config/settings_zone.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/config/settings_zone.xml b/bin/config/settings_zone.xml index 2b0a3a4a..2d04d270 100644 --- a/bin/config/settings_zone.xml +++ b/bin/config/settings_zone.xml @@ -23,6 +23,6 @@ <<<Welcome to Sapphire>>> This is a very good server You can change these messages by editing MotDArray in config/settings_zone.xml - + From 5d9ab6fe484581cf395b0c5c5427da6d6df46b12 Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 19:21:43 +1100 Subject: [PATCH 05/22] gm command fix, quest debug output change --- .../Server_Zone/Network/Handlers/GMCommandHandlers.cpp | 9 ++++++--- src/servers/Server_Zone/Script/ScriptManager.cpp | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/servers/Server_Zone/Network/Handlers/GMCommandHandlers.cpp b/src/servers/Server_Zone/Network/Handlers/GMCommandHandlers.cpp index cae64bc6..3d79409e 100644 --- a/src/servers/Server_Zone/Network/Handlers/GMCommandHandlers.cpp +++ b/src/servers/Server_Zone/Network/Handlers/GMCommandHandlers.cpp @@ -282,13 +282,16 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac } case GmCommand::Teri: { - if( param1 < 128 ) - pPlayer->sendUrgent( "Zone ID out of range." ); + auto zoneInfo = g_zoneMgr.getZone( param1 ); + if ( !zoneInfo ) + { + pPlayer->sendUrgent( "Invalid zone " + std::to_string( param1 ) ); + } else { targetPlayer->setPosition( targetPlayer->getPos() ); targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); - pPlayer->sendNotice( targetPlayer->getName() + " was warped to Zone " + std::to_string( param1 ) ); + pPlayer->sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName( ) + ")" ); } break; } diff --git a/src/servers/Server_Zone/Script/ScriptManager.cpp b/src/servers/Server_Zone/Script/ScriptManager.cpp index 61c331bd..bc42558c 100644 --- a/src/servers/Server_Zone/Script/ScriptManager.cpp +++ b/src/servers/Server_Zone/Script/ScriptManager.cpp @@ -91,7 +91,7 @@ bool Core::Scripting::ScriptManager::onTalk( Core::Entity::PlayerPtr pPlayer, ui std::string objName = Event::getEventName( eventId ); pPlayer->sendDebug("Actor: " + - std::to_string( actorId ) + + std::to_string( actorId ) + " -> " + std::to_string( Core::Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ) ) + " \neventId: " + std::to_string( eventId ) + " (0x" + boost::str( boost::format( "%|08X|" ) @@ -114,18 +114,18 @@ bool Core::Scripting::ScriptManager::onTalk( Core::Entity::PlayerPtr pPlayer, ui } catch( std::exception& e ) { + pPlayer->sendDebug( e.what( ) ); if( eventType == Common::EventType::Quest ) { auto questInfo = g_exdData.getQuestInfo( eventId ); if( questInfo ) { - pPlayer->sendDebug( "Quest not implemented: " + questInfo->name + "\n" + e.what() ); + pPlayer->sendUrgent( "Quest not implemented: " + questInfo->name ); return false; } } - pPlayer->sendDebug( e.what() ); return false; } return true; From ee552440bac6cc7eb676d2951fe73feaed467ed4 Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 19:22:05 +1100 Subject: [PATCH 06/22] ignore files generated by edit and continue --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 052e2908..97aa43f5 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ src/libraries/external/boost_* # sapphire version src/servers/Server_Common/Version\.cpp + +# edit and continue files +/enc_temp_folder \ No newline at end of file From c79affb1376925022b958823eea09b43753bdee2 Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 22:23:28 +1100 Subject: [PATCH 07/22] fix a compile warning --- src/servers/Server_Zone/Actor/Actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/Server_Zone/Actor/Actor.cpp b/src/servers/Server_Zone/Actor/Actor.cpp index 33f20c6b..4c3addc8 100644 --- a/src/servers/Server_Zone/Actor/Actor.cpp +++ b/src/servers/Server_Zone/Actor/Actor.cpp @@ -685,7 +685,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint32_t actionId, u case ActionEffectType::Damage: { - effectPacket.data().effects[0].value = param1; + effectPacket.data().effects[0].value = static_cast< uint16_t >( param1 ); effectPacket.data().effects[0].effectType = ActionEffectType::Damage; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::NormalDamage; effectPacket.data().effects[0].unknown_3 = 7; From 72e8b8623973f57aaa3ca79dfd807910e2d3584c Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 22:24:04 +1100 Subject: [PATCH 08/22] expose isincombat to scripts - isInCombat doesn't work though --- src/servers/Server_Zone/Script/ScriptManagerInit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/servers/Server_Zone/Script/ScriptManagerInit.cpp b/src/servers/Server_Zone/Script/ScriptManagerInit.cpp index d36a7dbe..55c2135f 100644 --- a/src/servers/Server_Zone/Script/ScriptManagerInit.cpp +++ b/src/servers/Server_Zone/Script/ScriptManagerInit.cpp @@ -52,6 +52,7 @@ int Core::Scripting::ScriptManager::init() m_pChaiHandler->add( chaiscript::fun( &Entity::Player::returnToHomepoint ), "returnToHomepoint" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::teleport ), "teleport" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::prepareZoning ), "prepareZoning" ); + m_pChaiHandler->add( chaiscript::fun( &Entity::Player::isInCombat ), "isInCombat" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getCurrency ), "getCurrency" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::addCurrency ), "addCurrency" ); From adc33d86126582994c29113afeb2a5d138f9c6f3 Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 23:40:36 +1100 Subject: [PATCH 09/22] fix aetheryte_index being incorrect and causing a server crash --- src/servers/Server_Common/Exd/ExdData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/Server_Common/Exd/ExdData.cpp b/src/servers/Server_Common/Exd/ExdData.cpp index f7822502..9ac2197a 100644 --- a/src/servers/Server_Common/Exd/ExdData.cpp +++ b/src/servers/Server_Common/Exd/ExdData.cpp @@ -88,7 +88,7 @@ bool Core::Data::ExdData::loadZoneInfo() uint16_t weather_rate = getField< uint16_t >( fields, 10 ) > 75 ? 0 : getField< uint16_t >( fields, 10 ); auto weatherRateFields = weatherRate.get_row( weather_rate ); - int32_t aetheryte_index = getField< int32_t >( fields, 20 ); + int32_t aetheryte_index = getField< int32_t >( fields, 23 ); ZoneInfo info{ 0 }; From 8957e1672b84d9de0562104d8a892d7b85bebb06 Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 23:40:51 +1100 Subject: [PATCH 10/22] compiler warning fix --- src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp index 0f53871d..492eaae6 100644 --- a/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/ActionHandler.cpp @@ -125,7 +125,7 @@ void Core::Network::GameConnection::actionHandler( const Packets::GamePacket& in } case 0x12E: // Set player title { - pPlayer->setTitle( param1 ); + pPlayer->setTitle( static_cast< uint16_t >( param1 ) ); break; } case 0x12F: // Get title list From 7707b4a7508391f95e574ee820559c724f7d230b Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sat, 21 Oct 2017 23:41:09 +1100 Subject: [PATCH 11/22] !unlock and !help debug commands --- .../DebugCommand/DebugCommandHandler.cpp | 26 ++++++++++++++++--- .../DebugCommand/DebugCommandHandler.h | 6 +++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp index c1f8f2f7..0284a1e9 100644 --- a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.cpp @@ -44,12 +44,13 @@ Core::DebugCommandHandler::DebugCommandHandler() registerCommand( "set", &DebugCommandHandler::set, "Loads and injects a premade Packet.", 1 ); registerCommand( "get", &DebugCommandHandler::get, "Loads and injects a premade Packet.", 1 ); registerCommand( "add", &DebugCommandHandler::add, "Loads and injects a premade Packet.", 1 ); - registerCommand( "inject", &DebugCommandHandler::injectPacket, "Loads and injects a premade Packet.", 1 ); - registerCommand( "injectc", &DebugCommandHandler::injectChatPacket, "Loads and injects a premade Packet.", 1 ); - registerCommand( "script_reload", &DebugCommandHandler::scriptReload, "Loads and injects a premade Packet.", 1 ); + registerCommand( "inject", &DebugCommandHandler::injectPacket, "Loads and injects a premade packet.", 1 ); + registerCommand( "injectc", &DebugCommandHandler::injectChatPacket, "Loads and injects a premade chat packet.", 1 ); + registerCommand( "script_reload", &DebugCommandHandler::scriptReload, "Reload all server scripts", 1 ); registerCommand( "nudge", &DebugCommandHandler::nudge, "Nudges you forward/up/down", 1 ); registerCommand( "info", &DebugCommandHandler::serverInfo, "Send server info", 0 ); - + registerCommand( "unlock", &DebugCommandHandler::unlockCharacter, "Unlock character", 1 ); + registerCommand( "help", &DebugCommandHandler::help, "Shows registered commands", 0 ); } // clear all loaded commands @@ -121,6 +122,18 @@ void Core::DebugCommandHandler::scriptReload( char * data, Core::Entity::PlayerP pPlayer->sendDebug( "Scripts reloaded." ); } +void Core::DebugCommandHandler::help( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) +{ + pPlayer->sendDebug( "Registered debug commands:" ); + for ( auto cmd : m_commandMap ) + { + if ( pPlayer->getGmRank( ) >= cmd.second->m_gmLevel ) + { + pPlayer->sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText( ) ); + } + } +} + void Core::DebugCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr command ) { std::string subCommand = ""; @@ -502,3 +515,8 @@ void Core::DebugCommandHandler::serverInfo( char * data, Core::Entity::PlayerPtr pPlayer->sendDebug( "Compiled: " __DATE__ " " __TIME__ ); pPlayer->sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) ); } + +void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command ) +{ + pPlayer->unlock( ); +} diff --git a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h index 12ff13b3..17dc3258 100644 --- a/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h +++ b/src/servers/Server_Zone/DebugCommand/DebugCommandHandler.h @@ -27,6 +27,9 @@ public: // execute command if registered void execCommand( char * data, Entity::PlayerPtr pPlayer ); + // help command + void help( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); + // command handler callbacks void set( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); void get( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); @@ -39,6 +42,9 @@ public: void nudge( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); void serverInfo( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); + void unlockCharacter( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); + void targetInfo( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr command ); + }; } From f8796e1ecc6448662a46b2698d53bd9b011d08f0 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sat, 21 Oct 2017 20:47:50 -0700 Subject: [PATCH 12/22] Remove unreferenced parameters - exceptions had unused parameters --- src/servers/Server_REST/main.cpp | 2 +- src/servers/Server_REST/server_http.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index 28f7c16d..2e6999dc 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -709,7 +709,7 @@ int main(int argc, char* argv[]) else throw invalid_argument( "could not read file" ); } - catch( const exception &e ) + catch( const exception & ) { string content = "Path not found: " + request->path; *response << "HTTP/1.1 400 Bad Request\r\nContent-Length: " << content.length() << "\r\n\r\n" << content; diff --git a/src/servers/Server_REST/server_http.hpp b/src/servers/Server_REST/server_http.hpp index e946afe2..b8e8e8a9 100644 --- a/src/servers/Server_REST/server_http.hpp +++ b/src/servers/Server_REST/server_http.hpp @@ -273,7 +273,7 @@ namespace SimpleWeb { try { content_length=stoull(it->second); } - catch(const std::exception &e) { + catch( const std::exception & ) { if(on_error) on_error(request, boost::system::error_code(boost::system::errc::protocol_error, boost::system::generic_category())); return; @@ -388,7 +388,7 @@ namespace SimpleWeb { try { http_version=stof(request->http_version); } - catch(const std::exception &e){ + catch( const std::exception & ){ if(on_error) on_error(request, boost::system::error_code(boost::system::errc::protocol_error, boost::system::generic_category())); return; @@ -410,7 +410,7 @@ namespace SimpleWeb { try { resource_function(response, request); } - catch(const std::exception &e) { + catch( const std::exception & ) { if(on_error) on_error(request, boost::system::error_code(boost::system::errc::operation_canceled, boost::system::generic_category())); return; From e50fd76062362e3848c3387f135a2c22c3f31310 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sat, 21 Oct 2017 22:09:03 -0700 Subject: [PATCH 13/22] Fix up Flags around Edit and Continue - remove /SAFESEH:NO - apply /INCREMENTAL /ZI (debug only) - remove sprinkling of /INCREMENTAL /ZI --- cmake/compiler.cmake | 6 +++--- src/servers/Server_Lobby/CMakeLists.txt | 5 ----- src/servers/Server_REST/CMakeLists.txt | 5 ----- src/servers/Server_Zone/CMakeLists.txt | 5 ----- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 760de187..ce738e14 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -8,11 +8,11 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") - + # edit and continue if(CMAKE_BUILD_TYPE STREQUAL "Debug") - message(STATUS "Disabling /SAFESEH") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + message(STATUS "Enabling Edit and Continue..") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL /ZI") endif() endif() diff --git a/src/servers/Server_Lobby/CMakeLists.txt b/src/servers/Server_Lobby/CMakeLists.txt index b705f393..57e57488 100644 --- a/src/servers/Server_Lobby/CMakeLists.txt +++ b/src/servers/Server_Lobby/CMakeLists.txt @@ -20,11 +20,6 @@ set_target_properties(server_lobby PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" ) -if(MSVC) - message(STATUS "Enabling Edit and Continue..") - set_property(TARGET server_lobby APPEND_STRING PROPERTY COMPILE_FLAGS " /INCREMENTAL /ZI") -endif() - if (UNIX) target_link_libraries(server_lobby Common xivdat pthread mysqlclient dl z) else() diff --git a/src/servers/Server_REST/CMakeLists.txt b/src/servers/Server_REST/CMakeLists.txt index 1b54bf9e..59de42a2 100644 --- a/src/servers/Server_REST/CMakeLists.txt +++ b/src/servers/Server_REST/CMakeLists.txt @@ -19,11 +19,6 @@ set_target_properties(server_rest PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" ) -if(MSVC) - message(STATUS "Enabling Edit and Continue..") - set_property(TARGET server_rest APPEND_STRING PROPERTY COMPILE_FLAGS " /INCREMENTAL /ZI") -endif() - if (UNIX) target_link_libraries (server_rest Common xivdat pthread mysqlclient dl z) else() diff --git a/src/servers/Server_Zone/CMakeLists.txt b/src/servers/Server_Zone/CMakeLists.txt index a0455608..50a34131 100644 --- a/src/servers/Server_Zone/CMakeLists.txt +++ b/src/servers/Server_Zone/CMakeLists.txt @@ -35,11 +35,6 @@ set_target_properties(server_zone PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/" ) -if(MSVC) - message(STATUS "Enabling Edit and Continue..") - set_property(TARGET server_zone APPEND_STRING PROPERTY COMPILE_FLAGS " /INCREMENTAL /ZI") -endif() - if (UNIX) target_link_libraries ( server_zone Common xivdat pthread mysqlclient dl z ) else() From 0429cd9d1ccdd9aa34f43bb4135b7fd78262a0ac Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sun, 22 Oct 2017 21:39:54 +1100 Subject: [PATCH 14/22] add server commit history to login page --- bin/web/assets/css/global.css | 24 +++++++++ bin/web/login.html | 91 ++++++++++++++++++++--------------- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/bin/web/assets/css/global.css b/bin/web/assets/css/global.css index 5a9c8375..290a0199 100644 --- a/bin/web/assets/css/global.css +++ b/bin/web/assets/css/global.css @@ -7,6 +7,7 @@ body { font-size: 12px; line-height: 14px; height: 100%; + overflow: hidden; } .contentContainer{ @@ -137,3 +138,26 @@ p.pageSubTitle{ margin:0 auto; } +.commit-history { + padding-left: 20px; +} + +.commit-history li a { + color: #fff; +} + +.commit-history li a:hover { + color: #bbb; +} + +.s-left-half { + overflow-y: auto; +} + +.s-link-badge { + font-size: 15px; +} + +h2 { + font-size: 19px; +} \ No newline at end of file diff --git a/bin/web/login.html b/bin/web/login.html index 97f15031..f9a5e5a8 100644 --- a/bin/web/login.html +++ b/bin/web/login.html @@ -2,12 +2,12 @@ - - - Sapphire - Login - - - + + + Sapphire - Login + + + - +
+
+ + + - + \ No newline at end of file From 80d623ae952acfc7742e0d88d80ed757ca7934ac Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Sun, 22 Oct 2017 21:46:55 +1100 Subject: [PATCH 15/22] _blank creates an empty frame while opening the page in the default web browser --- bin/web/createUser.html | 4 ++-- bin/web/login.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/web/createUser.html b/bin/web/createUser.html index 9666e35f..fe9398e0 100644 --- a/bin/web/createUser.html +++ b/bin/web/createUser.html @@ -48,10 +48,10 @@
diff --git a/bin/web/login.html b/bin/web/login.html index f9a5e5a8..24a0d591 100644 --- a/bin/web/login.html +++ b/bin/web/login.html @@ -51,10 +51,10 @@
From 1d511299f897c40100d087df5ba465843f3a49fd Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 09:28:19 -0700 Subject: [PATCH 16/22] Correctly applying /ZI for debug - /ZI is not a link flag - /ZI is not settable via CMAKE_CXX_FLAGS - /Zi is default unless add_defitions(/ZI) --- cmake/compiler.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index ce738e14..0add161f 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -9,10 +9,15 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") - # edit and continue if(CMAKE_BUILD_TYPE STREQUAL "Debug") + # edit and continue message(STATUS "Enabling Edit and Continue..") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL /ZI") + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZI") + add_definitions(/ZI) + + # incremental linking + message(STATUS "Enabling Incremental Linking..") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL") endif() endif() From e5c1dcc78cd77bd97915034f8134cb885a95ab5a Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 09:29:22 -0700 Subject: [PATCH 17/22] Removing comment --- cmake/compiler.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 0add161f..c5528976 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -12,7 +12,6 @@ else() if(CMAKE_BUILD_TYPE STREQUAL "Debug") # edit and continue message(STATUS "Enabling Edit and Continue..") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZI") add_definitions(/ZI) # incremental linking From a162a7caea5d9669a1663b2cb581f57f48fa3160 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 10:43:33 -0700 Subject: [PATCH 18/22] Need to disable SAFESEH before /ZI --- cmake/compiler.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index c5528976..ebf42d84 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -10,6 +10,10 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") if(CMAKE_BUILD_TYPE STREQUAL "Debug") + # disabling SAFESEH + message(STATUS "Disabling Safe Exception Handlers..") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + # edit and continue message(STATUS "Enabling Edit and Continue..") add_definitions(/ZI) From b15fc7164cff6eb6cb09f52bb6f32b05f763e5b5 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 18:11:00 -0700 Subject: [PATCH 19/22] Addressing unchecked iterator issues with core project - std::equal can take a 2nd iterator end - use _SCL_SECURE_NO_WARNINGS for std::copy issues in exd_common_gen --- src/servers/Server_REST/main.cpp | 6 +++--- src/tools/exd_common_gen/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index 2e6999dc..a883a2d1 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -597,7 +597,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / "news.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) throw invalid_argument( "path must be within root path" ); if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); @@ -638,7 +638,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / "headlines.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) throw invalid_argument( "path must be within root path" ); if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); @@ -683,7 +683,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / request->path ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) throw invalid_argument( "path must be within root path" ); if( boost::filesystem::is_directory( path ) ) path /= "index.html"; diff --git a/src/tools/exd_common_gen/CMakeLists.txt b/src/tools/exd_common_gen/CMakeLists.txt index 2d5839d9..986a5342 100644 --- a/src/tools/exd_common_gen/CMakeLists.txt +++ b/src/tools/exd_common_gen/CMakeLists.txt @@ -27,6 +27,9 @@ if (UNIX) target_link_libraries (exd_common_gen Common xivdat pthread mysqlclient dl z) else() target_link_libraries (exd_common_gen Common xivdat libmysql zlib1) + + # ignore unchecked iterators warnings from msvc + add_definitions(-D_SCL_SECURE_NO_WARNINGS) endif() target_link_libraries(exd_common_gen ${Boost_LIBRARIES} ${Boost_LIBRARIES}) From 818f617661b134646cd57dfed2d4239525643ec0 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 18:53:58 -0700 Subject: [PATCH 20/22] Quantity treated as uint32_t at packet level - move tryAddItem/AddItem to uint32_t from uint16_t --- src/servers/Server_Zone/Actor/Player.h | 4 ++-- src/servers/Server_Zone/Actor/PlayerInventory.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/servers/Server_Zone/Actor/Player.h b/src/servers/Server_Zone/Actor/Player.h index 95fd1b89..7b08e911 100644 --- a/src/servers/Server_Zone/Actor/Player.h +++ b/src/servers/Server_Zone/Actor/Player.h @@ -197,9 +197,9 @@ public: // Inventory / Item / Currency ////////////////////////////////////////////////////////////////////////////////////////////////////// /*! add an item to the first free slot in one of the 4 main containers */ - bool tryAddItem( uint16_t catalogId, uint16_t quantity ); + bool tryAddItem( uint16_t catalogId, uint32_t quantity ); /*! add an item to a given container */ - bool addItem( uint16_t containerId, uint16_t catalogId, uint16_t quantity ); + bool addItem( uint16_t containerId, uint16_t catalogId, uint32_t quantity ); /*! equip an item to a specified slot */ void equipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem, bool sendModel ); /*! remove an item from an equipment slot */ diff --git a/src/servers/Server_Zone/Actor/PlayerInventory.cpp b/src/servers/Server_Zone/Actor/PlayerInventory.cpp index b5380d82..acc6632c 100644 --- a/src/servers/Server_Zone/Actor/PlayerInventory.cpp +++ b/src/servers/Server_Zone/Actor/PlayerInventory.cpp @@ -189,10 +189,10 @@ void Core::Entity::Player::removeCrystal( uint8_t type, uint32_t amount ) queuePacket( invUpPacket ); } -bool Core::Entity::Player::tryAddItem( uint16_t catalogId, uint16_t quantity ) +bool Core::Entity::Player::tryAddItem( uint16_t catalogId, uint32_t quantity ) { - for( uint8_t i = 0; i < 4; i++ ) + for( uint16_t i = 0; i < 4; i++ ) { if( m_pInventory->addItem( i, -1, catalogId, quantity ) != -1 ) { @@ -202,7 +202,7 @@ bool Core::Entity::Player::tryAddItem( uint16_t catalogId, uint16_t quantity ) return false; } -bool Core::Entity::Player::addItem( uint16_t containerId, uint16_t catalogId, uint16_t quantity ) +bool Core::Entity::Player::addItem( uint16_t containerId, uint16_t catalogId, uint32_t quantity ) { if( m_pInventory->addItem( containerId, -1, catalogId, quantity ) != -1 ) return true; From c9a53b5d2b25d9dbd696e1fcad99874642fb0328 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Sun, 22 Oct 2017 20:51:25 -0700 Subject: [PATCH 21/22] More static_cast - expand some types - gnarly std::pair issue with short to int8_t - getLinkshellById now uses uint32_t --- src/servers/Server_Zone/Actor/PlayerQuest.cpp | 8 ++++---- src/servers/Server_Zone/Inventory/Inventory.cpp | 6 +++--- src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp | 2 +- src/servers/Server_Zone/Linkshell/LinkshellMgr.h | 2 +- .../Server_Zone/Network/Handlers/EventHandlers.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/servers/Server_Zone/Actor/PlayerQuest.cpp b/src/servers/Server_Zone/Actor/PlayerQuest.cpp index ab617d2e..579a0fe1 100644 --- a/src/servers/Server_Zone/Actor/PlayerQuest.cpp +++ b/src/servers/Server_Zone/Actor/PlayerQuest.cpp @@ -74,7 +74,7 @@ bool Core::Entity::Player::loadActiveQuests() void Core::Entity::Player::finishQuest( uint16_t questId ) { - int16_t idx = getQuestIndex( questId ); + auto idx = static_cast< uint8_t >( getQuestIndex( questId ) ); if( ( idx != -1 ) && ( m_activeQuests[idx] != nullptr ) ) { @@ -123,7 +123,7 @@ void Core::Entity::Player::unfinishQuest( uint16_t questId ) void Core::Entity::Player::removeQuest( uint16_t questId ) { - int16_t idx = getQuestIndex( questId ); + auto idx = static_cast< uint8_t >( getQuestIndex( questId ) ); if( ( idx != -1 ) && ( m_activeQuests[idx] != nullptr ) ) { @@ -978,7 +978,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence ) if( hasQuest( questId ) ) { GamePacketNew< FFXIVIpcQuestUpdate, ServerZoneIpcType > pe_qa( getId() ); - int16_t index = getQuestIndex( questId ); + auto index = static_cast< uint8_t >( getQuestIndex( questId ) ); auto pNewQuest = m_activeQuests[index]; pe_qa.data().slot = index; pNewQuest->c.sequence = sequence; @@ -1038,7 +1038,7 @@ void Core::Entity::Player::sendQuestTracker() if( m_questTracking[ii] >= 0 ) { trackerPacket.data().entry[ii].active = 1; - trackerPacket.data().entry[ii].questIndex = m_questTracking[ii]; + trackerPacket.data().entry[ii].questIndex = static_cast< uint8_t >( m_questTracking[ii] ); } } queuePacket( trackerPacket ); diff --git a/src/servers/Server_Zone/Inventory/Inventory.cpp b/src/servers/Server_Zone/Inventory/Inventory.cpp index 2b552583..2a859076 100644 --- a/src/servers/Server_Zone/Inventory/Inventory.cpp +++ b/src/servers/Server_Zone/Inventory/Inventory.cpp @@ -108,7 +108,7 @@ Core::Inventory::InvSlotPairVec Core::Inventory::getSlotsOfItemsInInventory( uin for( auto item : inv->getItemMap() ) { if( item.second && item.second->getId() == catalogId ) - outVec.push_back( std::make_pair( i, item.first ) ); + outVec.push_back( std::make_pair( i, static_cast< int8_t >( item.first ) ) ); } } return outVec; @@ -118,7 +118,7 @@ Core::Inventory::InvSlotPair Core::Inventory::getFreeBagSlot() { for( auto i : { Bag0, Bag1, Bag2, Bag3 } ) { - int16_t freeSlot = m_inventoryMap[i]->getFreeSlot(); + auto freeSlot = static_cast< int8_t >( m_inventoryMap[i]->getFreeSlot() ); if( freeSlot != -1 ) return std::make_pair( i, freeSlot ); @@ -457,7 +457,7 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t return -1; } - int16_t rSlotId = -1; + int8_t rSlotId = -1; //if( itemInfo->stack_size > 1 ) //{ diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp index 077f42d0..ab95f728 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp @@ -71,7 +71,7 @@ Core::LinkshellPtr Core::LinkshellMgr::getLinkshellByName( const std::string& na return it->second; } -Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint64_t lsId ) +Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint32_t lsId ) { auto it = m_linkshellIdMap.find( lsId ); if( it == m_linkshellIdMap.end() ) diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h index d5083506..887b1f4b 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h @@ -16,7 +16,7 @@ private: std::map< std::string, LinkshellPtr > m_linkshellNameMap; LinkshellPtr getLinkshellByName( const std::string& name ); - LinkshellPtr getLinkshellById( uint64_t lsId ); + LinkshellPtr getLinkshellById( uint32_t lsId ); public: LinkshellMgr(); diff --git a/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp b/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp index d310ffc4..e8c8ced0 100644 --- a/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/Server_Zone/Network/Handlers/EventHandlers.cpp @@ -141,7 +141,7 @@ void Core::Network::GameConnection::eventHandler( const Packets::GamePacket& inP GamePacketNew< FFXIVIpcEventLinkshell, ServerZoneIpcType > linkshellEvent( pPlayer->getId() ); linkshellEvent.data().eventId = eventId; - linkshellEvent.data().scene = subEvent; + linkshellEvent.data().scene = static_cast< uint8_t >(subEvent); linkshellEvent.data().param3 = 1; linkshellEvent.data().unknown1 = 0x15a; pPlayer->queuePacket( linkshellEvent ); From 24f937fd6101abc3ec02fc4287ee8189fb0c7566 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Mon, 23 Oct 2017 08:33:47 -0700 Subject: [PATCH 22/22] Fixing linkshellid to uint64_t updating methods, internal collection, and sql representation --- sql/infolinkshell.sql | 2 +- src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp | 4 ++-- src/servers/Server_Zone/Linkshell/LinkshellMgr.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/infolinkshell.sql b/sql/infolinkshell.sql index 66e7b224..a9e54d6c 100644 --- a/sql/infolinkshell.sql +++ b/sql/infolinkshell.sql @@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `infolinkshell`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `infolinkshell` ( - `LinkshellId` int(20) NOT NULL AUTO_INCREMENT, + `LinkshellId` bigint(20) NOT NULL AUTO_INCREMENT, `MasterCharacterId` int(20) DEFAULT NULL, `CharacterIdList` blob, `LinkshellName` varchar(32) DEFAULT NULL, diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp index ab95f728..ffcfc9af 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.cpp @@ -29,7 +29,7 @@ bool Core::LinkshellMgr::loadLinkshells() do { - uint32_t linkshellId = field[0].get< uint32_t >(); + uint64_t linkshellId = field[0].get< uint64_t >(); uint32_t masterId = field[1].get< uint32_t >(); std::string name = field[3].getString(); @@ -71,7 +71,7 @@ Core::LinkshellPtr Core::LinkshellMgr::getLinkshellByName( const std::string& na return it->second; } -Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint32_t lsId ) +Core::LinkshellPtr Core::LinkshellMgr::getLinkshellById( uint64_t lsId ) { auto it = m_linkshellIdMap.find( lsId ); if( it == m_linkshellIdMap.end() ) diff --git a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h index 887b1f4b..8237bb55 100644 --- a/src/servers/Server_Zone/Linkshell/LinkshellMgr.h +++ b/src/servers/Server_Zone/Linkshell/LinkshellMgr.h @@ -12,11 +12,11 @@ typedef boost::shared_ptr< Linkshell > LinkshellPtr; class LinkshellMgr { private: - std::map< uint32_t, LinkshellPtr > m_linkshellIdMap; + std::map< uint64_t, LinkshellPtr > m_linkshellIdMap; std::map< std::string, LinkshellPtr > m_linkshellNameMap; LinkshellPtr getLinkshellByName( const std::string& name ); - LinkshellPtr getLinkshellById( uint32_t lsId ); + LinkshellPtr getLinkshellById( uint64_t lsId ); public: LinkshellMgr();