1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-07 19:27:45 +00:00

warning cleanups; less raw pointers;

This commit is contained in:
Alice Ogeda 2022-01-27 18:35:19 -03:00
parent a27bb3e687
commit 56545371a3
12 changed files with 35 additions and 25 deletions

View file

@ -35,7 +35,7 @@ void PlayerMinimal::load( uint64_t charId )
return;
m_characterId = charId;
m_id = res->getUInt64( "EntityId" );
m_id = res->getUInt( "EntityId" );
memset( m_name, 0, 32 );

View file

@ -116,7 +116,7 @@ int SapphireApi::createCharacter( const uint32_t accountId, const std::string& n
const char* ptr = infoJson.c_str() + 50;
std::string lookPart( ptr );
int32_t pos = lookPart.find_first_of( "]" );
auto pos = lookPart.find_first_of( "]" );
if( pos != std::string::npos )
{
lookPart = lookPart.substr( 0, pos + 1 );
@ -188,7 +188,7 @@ void SapphireApi::deleteCharacter( std::string name, const uint32_t accountId )
}
}
int32_t id = deletePlayer.getCharacterId();
auto id = deletePlayer.getCharacterId();
g_charaDb.execute( "DELETE FROM charainfo WHERE CharacterId = " + std::to_string( id ) + ";" );
g_charaDb.execute( "DELETE FROM characlass WHERE CharacterId = " + std::to_string( id ) + ";" );

View file

@ -15,7 +15,7 @@ LobbyPacketContainer::LobbyPacketContainer( uint8_t* encKey )
m_encKey = encKey;
memset( m_dataBuf, 0, 0x1570 );
memset( m_dataBuf.data(), 0, 0x1570 );
}
LobbyPacketContainer::~LobbyPacketContainer()
@ -25,14 +25,14 @@ LobbyPacketContainer::~LobbyPacketContainer()
void LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry )
{
memcpy( m_dataBuf + m_header.size, &pEntry->getData()[ 0 ], pEntry->getSize() );
memcpy( m_dataBuf.data() + m_header.size, &pEntry->getData()[ 0 ], pEntry->getSize() );
// encryption key is set, we want to encrypt this packet
if( m_encKey != nullptr )
{
BlowFish blowfish;
blowfish.initialize( m_encKey, 0x10 );
blowfish.Encode( m_dataBuf + m_header.size + 0x10, m_dataBuf + m_header.size + 0x10, pEntry->getSize() - 0x10 );
blowfish.Encode( m_dataBuf.data() + m_header.size + 0x10, m_dataBuf.data() + m_header.size + 0x10, pEntry->getSize() - 0x10 );
}
m_header.size += pEntry->getSize();
@ -51,6 +51,8 @@ uint8_t* LobbyPacketContainer::getRawData( bool addstuff )
m_header.unknown_0 = 0xff41a05252;
m_header.timestamp = Common::Util::getTimeMs();
}
memcpy( m_dataBuf, &m_header, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
return m_dataBuf;
memcpy( m_dataBuf.data(), &m_header, sizeof( Sapphire::Network::Packets::FFXIVARR_PACKET_HEADER ) );
return m_dataBuf.data();
}

View file

@ -1,6 +1,7 @@
#ifndef LOBBY_PACKET_CONTAINER_H_
#define LOBBY_PACKET_CONTAINER_H_
#include <array>
#include <vector>
#include <string.h>
@ -34,7 +35,7 @@ namespace Sapphire::Network::Packets
std::vector< FFXIVPacketBasePtr > m_entryList;
uint8_t m_dataBuf[0x2000];
std::array< uint8_t, 0x2000 > m_dataBuf{ 0 };
};

View file

@ -4,6 +4,7 @@
#include <Logging/Logger.h>
#include <Crypt/base64.h>
#include <iomanip>
#include <memory>
#include <nlohmann/json.hpp>
@ -66,7 +67,7 @@ Lobby::LobbySessionPtr Lobby::RestConnector::getSession( char* sId )
if( content.find( "invalid" ) == std::string::npos )
{
LobbySessionPtr pSession( new Lobby::LobbySession() );
auto pSession = std::make_shared< Lobby::LobbySession >();
pSession->setAccountID( json["result"].get< uint32_t >() );
pSession->setSessionId( sId );
return pSession;

View file

@ -499,7 +499,7 @@ int main( int argc, char** argv )
Logger::info( "Export in progress" );
uint32_t updateInterval = rows.size() / 20;
auto updateInterval = rows.size() / 20;
uint32_t i = 0;
for( const auto& row : rows )
{

View file

@ -86,5 +86,5 @@ void ItemAction::handleMountItem()
auto player = getSourceChara()->getAsPlayer();
player->unlockMount( m_itemAction->data().Calcu0Arg[ 0 ] );
player->dropInventoryItem ( static_cast< Common::InventoryType >( m_itemSourceContainer ), m_itemSourceSlot );
player->dropInventoryItem( static_cast< Common::InventoryType >( m_itemSourceContainer ), m_itemSourceSlot );
}

View file

@ -2127,7 +2127,7 @@ void Sapphire::Entity::Player::setFalling( bool state, const Common::FFXIVARR_PO
// get hp percentage starting from 0.1, increasing to 100% at max height
float hpPer = std::min( 0.1f + ( deltaMax - 10.f ) / 20.f, 1.f );
uint32_t damage = getMaxHp() * hpPer;
auto damage = static_cast< uint32_t >( getMaxHp() * hpPer );
// check if player has aggro - if not, player should "live"
if( m_actorIdTohateSlotMap.empty() )

View file

@ -90,7 +90,7 @@ bool HousingMgr::init()
Logger::debug( "HousingMgr: Checking land counts" );
uint32_t houseCount = 0;
size_t houseCount = 0;
for( auto& landSet : m_landCache )
{
auto count = landSet.second.size();

View file

@ -144,18 +144,23 @@ void InventoryMgr::updateHousingItemPosition( Inventory::HousingItemPtr item )
// ItemId, PosX, PosY, PosZ, Rotation, PosX, PosY, PosZ, Rotation
auto pos = item->getPos();
auto rot = item->getRot();
auto posX = static_cast< uint32_t >( pos.x );
auto posY = static_cast< uint32_t >( pos.y );
auto posZ = static_cast< uint32_t >( pos.z );
auto rot = static_cast< int32_t >( item->getRot() );
stmt->setUInt64( 1, item->getUId() );
stmt->setUInt( 2, pos.x );
stmt->setUInt( 3, pos.y );
stmt->setUInt( 4, pos.z );
stmt->setUInt( 2, posX );
stmt->setUInt( 3, posY );
stmt->setUInt( 4, posZ );
stmt->setInt( 5, rot );
stmt->setUInt( 6, pos.x );
stmt->setUInt( 7, pos.y );
stmt->setUInt( 8, pos.z );
stmt->setUInt( 6, posX );
stmt->setUInt( 7, posY );
stmt->setUInt( 8, posZ );
stmt->setInt( 9, rot );
db.execute( stmt );

View file

@ -583,6 +583,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
break;
}
break;
}
case PacketCommand::FINISH_LOADING: // Finish zoning
{
@ -637,7 +638,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
case PacketCommand::HOUSING_LOCK_LAND_BY_BUILD:
{
auto hZone = std::dynamic_pointer_cast< HousingZone >( pZone );
if (!hZone)
if( !hZone )
return;
player.setActiveLand( static_cast< uint8_t >( param11 ), hZone->getWardNum() );
@ -677,7 +678,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
{
auto& housingMgr = Service< HousingMgr >::ref();
auto hZone = std::dynamic_pointer_cast< HousingZone >( pZone );
if (!hZone)
if( !hZone )
return;
auto plot = static_cast< uint8_t >( param12 & 0xFF );

View file

@ -206,7 +206,7 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player )
auto& parts = house->getHouseModels();
for( auto ii = 0; ii != parts.size(); ii++ )
for( auto ii = 0; ii != parts.size(); ++ii )
{
landData.patternIds[ ii ] = parts[ ii ].first;
landData.colors[ ii ] = parts[ ii ].second;
@ -245,7 +245,7 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId )
auto& parts = house->getHouseModels();
for( auto i = 0; i != parts.size(); i++ )
for( auto i = 0; i != parts.size(); ++i )
{
landData.patternIds[ i ] = parts[ i ].first;
landData.colors[ i ] = parts[ i ].second;