1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 02:37:47 +00:00

Removing C style casts round 2

Replacing the stuff I did for warning removal during build from C style
casts to static_cast.
This commit is contained in:
Reyli 2024-06-24 00:39:45 -05:00
parent ed156c4286
commit 6111461aef
39 changed files with 99 additions and 99 deletions

View file

@ -10,7 +10,7 @@ namespace xiv::utils::zlib
void compress( const std::vector< char >& in, std::vector< char >& out )
{
// Fetching upper bound for out size
auto out_size = compressBound( (uLong)in.size() );
auto out_size = compressBound( static_cast<uLong>(in.size()) );
out.resize( out_size );
auto ret = compress2( reinterpret_cast<uint8_t*>(out.data()), &out_size,

View file

@ -89,7 +89,7 @@ std::string Sapphire::Common::Util::base64Encode( uint8_t const* bytes_to_encode
std::string Sapphire::Common::Util::base64Decode( std::string const& encoded_string )
{
int32_t in_len = (int32_t)encoded_string.size();
int32_t in_len = static_cast<int32_t>(encoded_string.size());
int32_t i = 0;
int32_t j = 0;
int32_t in_ = 0;

View file

@ -131,7 +131,7 @@ void Sapphire::Db::DbWorkerPool< T >::escapeString( std::string& str )
return;
char* buf = new char[str.size() * 2 + 1];
escapeString( buf, str.c_str(), (unsigned long)str.size() );
escapeString( buf, str.c_str(), static_cast<unsigned long>(str.size()) );
str = buf;
delete[] buf;
}

View file

@ -73,7 +73,7 @@ PacketParseResult Network::Packets::getPackets( const std::vector< uint8_t >& bu
std::vector< uint8_t > outBuf;
outBuf.resize( packetHeader.oodleDecompressedSize );
bool oodleSuccess = oodle->oodleDecode( inBuf, (uint32_t)bytesExpected, outBuf, packetHeader.oodleDecompressedSize );
bool oodleSuccess = oodle->oodleDecode( inBuf, static_cast<uint32_t>(bytesExpected), outBuf, packetHeader.oodleDecompressedSize );
if( !oodleSuccess )
{

View file

@ -65,14 +65,14 @@ void Network::Packets::PacketContainer::fillSendBuffer( std::vector< uint8_t >&
std::vector< uint8_t > outBuf;
outBuf.resize( m_ipcHdr.size );
auto compLen = oodle->oodleEncode(inBuf, (uint32_t)inBuf.size(), outBuf);
auto compLen = oodle->oodleEncode(inBuf, static_cast<uint32_t>(inBuf.size()), outBuf);
// Check if we compressed at all
if (compLen != m_ipcHdr.size) {
tempBuffer.resize(compLen);
memcpy(&inBuf[0], &outBuf[0], compLen);
m_ipcHdr.oodleDecompressedSize = m_ipcHdr.size;
m_ipcHdr.size = (uint32_t)compLen;
m_ipcHdr.size = static_cast<uint32_t>(compLen);
m_ipcHdr.compressionType = static_cast< uint8_t >(Packets::CompressionType::Oodle);
}
}

View file

@ -124,7 +124,7 @@ uint64_t Util::getTimeMs()
uint32_t Util::getTimeSeconds()
{
auto currClock = std::chrono::system_clock::now();
return (uint32_t)std::chrono::time_point_cast< std::chrono::seconds >( currClock ).time_since_epoch().count();
return static_cast<uint32_t>(std::chrono::time_point_cast< std::chrono::seconds >( currClock ).time_since_epoch().count());
}
uint64_t Util::getEorzeanTimeStamp()

View file

@ -470,7 +470,7 @@ void Lobby::GameConnection::handlePackets( const Network::Packets::FFXIVARR_PACK
BlowFish blowfish;
blowfish.initialize( m_encKey, 0x10 );
blowfish.Decode( ( uint8_t* ) ( &inPacket.data[ 0 ] ), ( uint8_t* ) ( &inPacket.data[ 0 ] ),
( (uint32_t)inPacket.data.size() ) - 0x10 );
( static_cast<uint32_t>(inPacket.data.size() ) - 0x10 ));
}
switch( inPacket.segHdr.type )

View file

@ -35,7 +35,7 @@ void LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry )
blowfish.Encode( m_dataBuf + m_header.size + 0x10, m_dataBuf + m_header.size + 0x10, (uint32_t)pEntry->getSize() - 0x10 );
}
m_header.size += (uint32_t)pEntry->getSize();
m_header.size += static_cast<uint32_t>(pEntry->getSize());
m_header.count++;
}

View file

@ -289,7 +289,7 @@ int Lobby::RestConnector::createCharacter( char* sId, std::string name, std::str
{
std::string json_string =
"{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name +
"\",\"infoJson\": \"" + Common::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), (uint32_t)infoJson.length() ) + "\"}";
"\",\"infoJson\": \"" + Common::Util::base64Encode( ( uint8_t* ) infoJson.c_str(), static_cast<uint32_t>(infoJson.length()) ) + "\"}";
HttpResponse r = requestApi( "createCharacter", json_string );

View file

@ -125,7 +125,7 @@ private:
{
if( player.giveQuestRewards( getId(), result.param3 ) )
{
player.setQuestUI8BH( getId(), (uint8_t)result.param3 );
player.setQuestUI8BH( getId(), static_cast<uint8_t>(result.param3) );
player.finishQuest( getId() );
}
}

View file

@ -77,11 +77,11 @@ struct DiscoveryMap : std::enable_shared_from_this< DiscoveryMap >
{
auto ogX = x, ogY = y;
int col = ( mapIndex % ( int ) ( ( float ) img.width / ( float ) tileWidth ) );
int row = (int)( mapIndex / ( ( float ) img.width / ( float ) tileWidth ) );
int row = static_cast<int>(( mapIndex / ( ( float ) img.width / ( float ) tileWidth ) ));
x = ( x / 2048.f ) * ( float ) tileWidth;
y = ( y / 2048.f ) * ( float ) tileWidth;
int tileX = (int)(( col * ( float ) tileWidth ) + x);
int tileY = (int)(( row * ( float ) tileWidth ) + y);
int tileX = static_cast<int>((col * (float)tileWidth) + x);
int tileY = static_cast<int>(( row * ( float ) tileWidth ) + y);
if( tileX < 0 || tileY < 0 || tileY > img.data.size() - 1 || tileX > img.data[ 0 ].size() - 1 )
{

View file

@ -70,12 +70,12 @@ enum class LgbEntryType :
struct InstanceObject
{
LgbEntryType type{};
uint32_t unknown{};
uint32_t nameOffset{};
vec3 translation{};
vec3 rotation{};
vec3 scale{};
LgbEntryType type;
uint32_t unknown;
uint32_t nameOffset;
vec3 translation;
vec3 rotation;
vec3 scale;
};
class LgbEntry
@ -221,10 +221,10 @@ public:
struct MapRangeData :
public InstanceObject
{
uint32_t type{};
uint16_t unknown2{};
uint16_t unknown3{};
uint8_t unknown4[0x10]{};
uint32_t type;
uint16_t unknown2;
uint16_t unknown3;
uint8_t unknown4[0x10];
};
struct LGB_MAP_RANGE_ENTRY :
@ -380,7 +380,7 @@ struct LGB_FILE
for( auto i = 0; i < header.groupCount; ++i )
{
const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) );
const auto group = LGB_GROUP( buf, this, (uint32_t)groupOffset );
const auto group = LGB_GROUP( buf, this, static_cast<uint32_t>(groupOffset) );
groups.push_back( group );
}
};

View file

@ -493,7 +493,7 @@ int main( int argc, char* argv[] )
printf( "Built export struct for %s in %lu seconds \n",
zoneName.c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() ));
}
catch( std::exception& e )
{
@ -507,7 +507,7 @@ int main( int argc, char* argv[] )
std::cout << "\n\n\n";
printf( "Finished all tasks in %lu seconds\n",
(unsigned long)std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() ));
delete eData;
delete gameData;

View file

@ -52,7 +52,7 @@ public:
auto end = std::chrono::high_resolution_clock::now();
printf( "[Navmesh] Finished exporting %s in %lu ms\n", zone.name.c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
}
};

View file

@ -53,7 +53,7 @@ public:
printf( "[Obj] Finished exporting %s in %lu ms\n",
fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
return fileName;
}
@ -91,7 +91,7 @@ public:
auto end = std::chrono::high_resolution_clock::now();
printf( "[Obj] Finished exporting %s in %lu ms\n",
fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
return fileName;
}
@ -128,7 +128,7 @@ private:
std::to_string( mesh.indices[ i + 1 ] + indicesOffset + 1 ) << ' ' +
std::to_string( mesh.indices[ i + 2 ] + indicesOffset + 1 ) << '\n';
}
indicesOffset += (int)mesh.verts.size() / 3;
indicesOffset += static_cast<int>(mesh.verts.size()) / 3;
}
}
//of.flush();

View file

@ -70,12 +70,12 @@ enum class LgbEntryType :
struct InstanceObject
{
LgbEntryType type{};
uint32_t unknown{};
uint32_t nameOffset{};
vec3 translation{};
vec3 rotation{};
vec3 scale{};
LgbEntryType type;
uint32_t unknown;
uint32_t nameOffset;
vec3 translation;
vec3 rotation;
vec3 scale;
};
class LgbEntry
@ -379,7 +379,7 @@ struct LGB_FILE
for( auto i = 0; i < header.groupCount; ++i )
{
const auto groupOffset = baseOffset + *reinterpret_cast< int32_t* >( buf + ( baseOffset + i * 4 ) );
const auto group = LGB_GROUP( buf, this, (uint32_t)groupOffset );
const auto group = LGB_GROUP( buf, this, static_cast<uint32_t>(groupOffset) );
groups.push_back( group );
}
};

View file

@ -391,7 +391,7 @@ int main( int argc, char* argv[] )
mesh.indices[ indices++ ] = index.index[ 2 ];
// std::cout << std::to_string( index.unknown[0] )<< " " << std::to_string( index.unknown[1] )<< " " << std::to_string( index.unknown[2]) << std::endl;
}
max_index += (uint32_t)(entry.data.vertices.size() + entry.data.vertices_i16.size());
max_index += static_cast<uint32_t>((entry.data.vertices.size() + entry.data.vertices_i16.size()));
model.meshes[ meshCount++ ] = mesh;
}
exportedGroup.models[model.name] = model;
@ -522,7 +522,7 @@ int main( int argc, char* argv[] )
printf( "Built export struct for %s in %lu seconds \n",
zoneName.c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - entryStartTime ).count() ));
if( zoneCount++ % nJobs == 0 )
{
exportMgr.restart();
@ -541,7 +541,7 @@ int main( int argc, char* argv[] )
std::cout << "\n\n\n";
printf( "Finished all tasks in %lu seconds\n",
(unsigned long)std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::seconds >( std::chrono::high_resolution_clock::now() - startTime ).count() ));
delete eData;
delete gameData;

View file

@ -53,7 +53,7 @@ public:
auto end = std::chrono::high_resolution_clock::now();
printf( "[Navmesh] Finished exporting %s in %lu ms\n",
zone.name.c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
}
static void exportGroup( const std::string& zoneName, const ExportedGroup& group )
@ -91,7 +91,7 @@ public:
auto end = std::chrono::high_resolution_clock::now();
printf( "[Navmesh] Finished exporting %s in %lu ms\n",
fileName.c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
}
};
#endif // !OBJ_EXPORTER_H

View file

@ -53,7 +53,7 @@ public:
printf( "[Obj] Finished exporting %s in %lu ms\n",
fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
return fileName;
}
@ -91,7 +91,7 @@ public:
auto end = std::chrono::high_resolution_clock::now();
printf( "[Obj] Finished exporting %s in %lu ms\n",
fileName.substr( fileName.find( "pcb_export" ) - 1 ).c_str(),
(unsigned long)std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() );
static_cast<unsigned long>(std::chrono::duration_cast< std::chrono::milliseconds >( end - start ).count() ));
return fileName;
}
@ -128,7 +128,7 @@ private:
std::to_string( mesh.indices[ i + 1 ] + indicesOffset + 1 ) << ' ' +
std::to_string( mesh.indices[ i + 2 ] + indicesOffset + 1 ) << '\n';
}
indicesOffset += (int)mesh.verts.size() / 3;
indicesOffset += static_cast<int>(mesh.verts.size()) / 3;
}
}
//of.flush();

View file

@ -121,7 +121,7 @@ struct PCB_FILE
/* printf( "\tnum_v16: %i, num_indices: %i, num_vertices: %i\n\n",
block_entry.header.num_v16, block_entry.header.num_indices, block_entry.header.num_vertices );*/
int doffset = sizeof( block_entry.header ) + offset;
uint16_t block_size = (uint16_t)sizeof( block_entry.header ) +
uint16_t block_size = static_cast<uint16_t>(sizeof( block_entry.header )) +
block_entry.header.num_vertices * 3 * 4 +
block_entry.header.num_v16 * 6 +
block_entry.header.num_indices * 6;

View file

@ -329,7 +329,7 @@ int main( int argc, char** argv )
Logger::info( "Export in progress" );
uint32_t updateInterval = (uint32_t)rows.size() / 20;
uint32_t updateInterval = static_cast<uint32_t>(rows.size()) / 20;
uint32_t i = 0;
for( const auto& row : rows )
{
@ -386,7 +386,7 @@ int main( int argc, char** argv )
{
std::string entry( &section[ offset ] );
offset += (uint32_t)entry.size() + 1;
offset += static_cast<uint32_t>(entry.size()) + 1;
if( entry.size() > 3
&& entry.find_first_not_of( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-" ) ==

View file

@ -1572,9 +1572,9 @@ bool Sapphire::Entity::Player::hateListHasEntry( BNpcPtr pBNpc )
void Sapphire::Entity::Player::sendHateList()
{
auto hateListPacket = makeZonePacket< FFXIVIpcHateList >( getId() );
hateListPacket->data().numEntries = (uint32_t)m_actorIdTohateSlotMap.size();
hateListPacket->data().numEntries = static_cast<uint32_t>(m_actorIdTohateSlotMap.size());
auto hateRankPacket = makeZonePacket< FFXIVIpcHateRank >( getId() );
hateRankPacket->data().numEntries = (uint32_t)m_actorIdTohateSlotMap.size();
hateRankPacket->data().numEntries = static_cast<uint32_t>(m_actorIdTohateSlotMap.size());
auto it = m_actorIdTohateSlotMap.begin();
for( int32_t i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ )
{
@ -1759,7 +1759,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget )
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
Common::EffectEntry entry{};
entry.value = (int16_t)damage.first;
entry.value = static_cast<int16_t>(damage.first);
entry.effectType = Common::ActionEffectType::Damage;
entry.param0 = static_cast< uint8_t >( damage.second );
entry.param2 = 0x72;
@ -1774,7 +1774,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget )
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
Common::EffectEntry entry{};
entry.value = (int16_t)damage.first;
entry.value = static_cast<int16_t>(damage.first);
entry.effectType = Common::ActionEffectType::Damage;
entry.param0 = static_cast< uint8_t >( damage.second );
entry.param2 = 0x73;
@ -1785,7 +1785,7 @@ void Sapphire::Entity::Player::autoAttack( CharaPtr pTarget )
}
pTarget->takeDamage( (uint32_t)damage.first );
pTarget->takeDamage(static_cast<uint32_t>(damage.first) );
}

View file

@ -338,7 +338,7 @@ void Sapphire::Entity::Player::playScene16( uint32_t eventId, uint32_t scene, ui
eventPlay16->data().scene = scene;
eventPlay16->data().flags = flags;
eventPlay16->data().param3 = param3;
eventPlay16->data().paramSize = (uint8_t)paramList.size();
eventPlay16->data().paramSize = static_cast<uint8_t>(paramList.size());
int i = 0;
for( auto p : paramList )
{

View file

@ -1032,13 +1032,13 @@ Sapphire::ItemPtr Sapphire::Entity::Player::dropInventoryItem( Sapphire::Common:
{
auto& container = m_storageMap[ type ];
auto item = container->getItem( (uint8_t)slotId );
auto item = container->getItem( static_cast<uint8_t>(slotId) );
if( !item )
return nullptr;
// unlink item
container->removeItem((uint8_t)slotId, false );
updateContainer( type, (uint8_t)slotId, nullptr );
container->removeItem(static_cast<uint8_t>(slotId), false );
updateContainer( type, static_cast<uint8_t>(slotId), nullptr );
if( !silent )
{
@ -1079,7 +1079,7 @@ bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::Invento
for( uint16_t idx = 0; idx < container->getMaxSize(); idx++ )
{
auto item = container->getItem((uint8_t)idx );
auto item = container->getItem(static_cast<uint8_t>(idx) );
if( !item )
{
containerPair = std::make_pair( bagId, idx );
@ -1094,7 +1094,7 @@ bool Sapphire::Entity::Player::getFreeInventoryContainerSlot( Inventory::Invento
void Sapphire::Entity::Player::insertInventoryItem( Sapphire::Common::InventoryType type, uint16_t slot,
const Sapphire::ItemPtr item )
{
updateContainer( type, (uint8_t)slot, item );
updateContainer( type, static_cast<uint8_t>(slot), item );
auto slotUpdate = std::make_shared< UpdateInventorySlotPacket >( getId(), slot, type, *item );
queuePacket( slotUpdate );

View file

@ -72,7 +72,7 @@ int8_t Sapphire::ItemContainer::getFreeSlot()
ItemMap::iterator it = m_itemMap.find( slotId );
if( it == m_itemMap.end() ||
it->second == nullptr )
return (int8_t)slotId;
return static_cast<int8_t>(slotId);
}
return -1;
}

View file

@ -89,7 +89,7 @@ bool Sapphire::World::Manager::HousingMgr::init()
{
auto count = landSet.second.size();
houseCount += (uint32_t)count;
houseCount += static_cast<uint32_t>(count);
if( landSet.second.size() != 60 )
{
@ -810,7 +810,7 @@ void Sapphire::World::Manager::HousingMgr::requestEstateEditGuestAccess( Entity:
if( !hZone )
return;
auto land = hZone->getLand( (uint8_t)ident.landId );
auto land = hZone->getLand(static_cast<uint8_t>(ident.landId) );
if( !land )
return;
@ -1703,7 +1703,7 @@ void Sapphire::World::Manager::HousingMgr::editAppearance( bool isInterior, Sapp
updateHouseModels( land->getHouse() );
if( !isInterior )
{
terri->sendLandUpdate( (uint8_t)landIdent.landId );
terri->sendLandUpdate(static_cast<uint8_t>(landIdent.landId) );
}
}
@ -1759,11 +1759,11 @@ void Sapphire::World::Manager::HousingMgr::removeHouse( Entity::Player& player,
land->setStatus( HouseStatus::Sold );
land->updateLandDb();
terri->sendLandUpdate( (uint8_t)plot );
terri->sendLandUpdate(static_cast<uint8_t>(plot) );
player.setLandFlags( LandFlagsSlot::Private, 0, land->getLandIdent() );
terri->removeEstateEntranceEObj((uint8_t)plot );
terri->removeEstateEntranceEObj(static_cast<uint8_t>(plot) );
// missing reply for ClientTrigger RequestEstateHallRemoval
}

View file

@ -620,7 +620,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
if( mapData.size() <= 2 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -629,7 +629,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 4 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate4 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -638,7 +638,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 8 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate8 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -647,7 +647,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 16 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate16 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -656,7 +656,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 32 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate32 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -665,7 +665,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 64 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate64 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );
@ -674,7 +674,7 @@ void Sapphire::World::Manager::MapMgr::sendPackets( Entity::Player& player, Even
else if( mapData.size() <= 128 )
{
auto mapUpdatePacket = makeZonePacket< FFXIVIpcMapUpdate128 >( player.getId() );
mapUpdatePacket->data().entryCount = (uint8_t)mapData.size();
mapUpdatePacket->data().entryCount = static_cast<uint8_t>(mapData.size());
fillPacket( mapData, mapUpdatePacket->data().iconIds, mapUpdatePacket->data().levelIds, mapUpdatePacket->data().eventIds );

View file

@ -27,7 +27,7 @@ void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Sapphire:
if( terriMgr.isHousingTerritory( terriPos->getTargetZoneId() ) )
{
auto& housingMgr = Common::Service< HousingMgr >::ref();
auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), (uint8_t)param );
auto landSetId = housingMgr.toLandSetId( terriPos->getTargetZoneId(), static_cast<uint8_t>(param) );
auto housingZone = housingMgr.getHousingZoneByLandSetId( landSetId );

View file

@ -52,7 +52,7 @@ bool Sapphire::World::Manager::ShopMgr::purchaseGilShopItem( Entity::Player& pla
bool Sapphire::World::Manager::ShopMgr::shopSellItem( Sapphire::Entity::Player& player, uint32_t shopId, uint16_t containerId, uint16_t slotId )
{
auto item = player.getItemAt( containerId, (uint8_t)slotId );
auto item = player.getItemAt( containerId, static_cast<uint8_t>(slotId) );
if( item )
{
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();

View file

@ -475,7 +475,7 @@ Sapphire::TerritoryPtr Sapphire::World::Manager::TerritoryMgr::findOrCreateHousi
if( !parentZone )
return nullptr;
auto land = parentZone->getLand( (uint8_t)landIdent.landId );
auto land = parentZone->getLand(static_cast<uint8_t>(landIdent.landId) );
if( !land )
return nullptr;

View file

@ -205,7 +205,7 @@ float CalcStats::directHitProbability( const Chara& chara )
const auto& baseStats = chara.getStats();
auto level = chara.getLevel();
float dhRate = (float)chara.getStatValue( Common::BaseParam::DirectHitRate );
float dhRate = static_cast<float>(chara.getStatValue( Common::BaseParam::DirectHitRate ));
auto divVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] );
auto subVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::SUB ] );

View file

@ -573,7 +573,7 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara )
std::memset( &params, 0, sizeof( params ) );
params.height = 3.f;
params.maxAcceleration = 25.f;
params.maxSpeed = (float)std::pow( 2, chara.getRadius() * 0.35f ) + 1.f;
params.maxSpeed = static_cast<float>(std::pow( 2, chara.getRadius() * 0.35f )) + 1.f;
params.radius = ( chara.getRadius() ) * 0.75f;
params.collisionQueryRange = params.radius * 12.0f;
params.pathOptimizationRange = params.radius * 20.0f;

View file

@ -328,7 +328,7 @@ void Sapphire::Network::GameConnection::processOutQueue()
}
pRP.addPacket( pPacket );
totalSize += (int32_t)pPacket->getSize();
totalSize += static_cast<int32_t>(pPacket->getSize());
// todo: figure out a good max set size and make it configurable
if( totalSize > 10000 )

View file

@ -154,7 +154,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( const Packets::FFX
}
case ClientTriggerType::Examine:
{
uint32_t targetId = (uint32_t)p1u64;
uint32_t targetId = static_cast<uint32_t>(p1u64);
examineHandler( player, targetId );
break;
}

View file

@ -664,7 +664,7 @@ void Sapphire::Network::GameConnection::landRenameHandler( const Packets::FFXIVA
if( !pZone )
return;
auto pLand = pZone->getLand((uint8_t)packet.data().ident.landId );
auto pLand = pZone->getLand(static_cast<uint8_t>(packet.data().ident.landId) );
if( !pLand )
return;
@ -712,11 +712,11 @@ void Sapphire::Network::GameConnection::reqPlaceHousingItem( const Packets::FFXI
if( data.shouldPlaceItem == 1 )
{
housingMgr.reqPlaceHousingItem( player, data.landId, data.sourceInvContainerId, (uint8_t)data.sourceInvSlotId,
housingMgr.reqPlaceHousingItem( player, data.landId, data.sourceInvContainerId, static_cast<uint8_t>(data.sourceInvSlotId),
data.position, data.rotation );
}
else
housingMgr.reqPlaceItemInStore( player, data.landId, data.sourceInvContainerId, (uint8_t)data.sourceInvSlotId );
housingMgr.reqPlaceItemInStore( player, data.landId, data.sourceInvContainerId, static_cast<uint8_t>(data.sourceInvSlotId) );
}
@ -728,7 +728,7 @@ void Sapphire::Network::GameConnection::reqMoveHousingItem( const Packets::FFXIV
const auto packet = ZoneChannelPacket< Client::FFXIVIpcHousingUpdateObjectPosition >( inPacket );
const auto& data = packet.data();
housingMgr.reqMoveHousingItem( player, data.ident, (uint8_t)data.slot, data.pos, data.rotation );
housingMgr.reqMoveHousingItem( player, data.ident, static_cast<uint8_t>(data.slot), data.pos, data.rotation );
}
void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
@ -748,7 +748,7 @@ void Sapphire::Network::GameConnection::housingEditExterior( const Packets::FFXI
slotList.push_back( container != 0x270F ? static_cast< uint8_t >( packet.data().slot[i] ) : 0xFF );
}
housingMgr.editAppearance( false, player, terri->getLand( (uint8_t)packet.data().landId )->getLandIdent(), containerList, slotList, packet.data().removeFlag );
housingMgr.editAppearance( false, player, terri->getLand( static_cast<uint8_t>(packet.data().landId) )->getLandIdent(), containerList, slotList, packet.data().removeFlag );
}
void Sapphire::Network::GameConnection::housingEditInterior( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
@ -847,18 +847,18 @@ void Sapphire::Network::GameConnection::inventoryEquipRecommendedItemsHandler( c
if ( fromContainer == Common::GearSet0 )
continue;
const auto fromItem = fromSlot == -1 ? nullptr : player.getItemAt( fromContainer, (uint8_t)fromSlot );
const auto fromItem = fromSlot == -1 ? nullptr : player.getItemAt( fromContainer, static_cast<uint8_t>(fromSlot) );
const auto equippedItem = player.getItemAt( Common::GearSet0, slot );
if ( fromItem && equippedItem )
{
player.swapItem( fromContainer, (uint8_t)fromSlot, Common::GearSet0, slot, slot == 0 || slot == 13 );
player.swapItem( fromContainer, static_cast<uint8_t>(fromSlot), Common::GearSet0, slot, slot == 0 || slot == 13 );
player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), fromSlot, fromContainer, *equippedItem, 0 ) );
player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), slot, Common::GearSet0, *fromItem, 0 ) );
}
else if ( fromItem && !equippedItem )
{
player.moveItem( fromContainer, (uint8_t)fromSlot, Common::GearSet0, slot, slot == 0 || slot == 13 );
player.moveItem( fromContainer, static_cast<uint8_t>(fromSlot), Common::GearSet0, slot, slot == 0 || slot == 13 );
player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), fromSlot, fromContainer, 0 ) );
player.queuePacket( std::make_shared< UpdateInventorySlotPacket >( player.getId(), slot, Common::GearSet0, *fromItem, 0 ) );
}

View file

@ -32,7 +32,7 @@ namespace Sapphire::Network::Packets::Server
m_data.headRotation = headRotation;
m_data.animationType = animationType;
m_data.animationState = state;
m_data.animationSpeed = (uint8_t)animationSpeed;
m_data.animationSpeed = static_cast<uint8_t>(animationSpeed);
m_data.unknownRotation = unknownRotation;
m_data.posX = Common::Util::floatToUInt16( actor.getPos().x );
m_data.posY = Common::Util::floatToUInt16( actor.getPos().y );

View file

@ -164,7 +164,7 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac
{
// check if the actor is an eobj and call its script if we have one
auto zone = player.getCurrentTerritory();
if( auto eobj = zone->getEObj( (uint32_t)actorId ) )
if( auto eobj = zone->getEObj( static_cast<uint32_t>(actorId) ) )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventObjectScript >( eobj->getObjectId() );
if( script )

View file

@ -140,12 +140,12 @@ bool Sapphire::HousingZone::init()
land->setHouse( house );
}
land->init( entry.m_type, entry.m_size, entry.m_status, (uint32_t)entry.m_currentPrice, entry.m_ownerId, entry.m_houseId );
land->init( entry.m_type, entry.m_size, entry.m_status, static_cast<uint32_t>(entry.m_currentPrice), entry.m_ownerId, entry.m_houseId );
m_landPtrMap[ (unsigned char)entry.m_landId ] = land;
m_landPtrMap[ static_cast<unsigned char>(entry.m_landId) ] = land;
if( entry.m_houseId > 0 )
registerEstateEntranceEObj( (uint8_t)entry.m_landId );
registerEstateEntranceEObj( static_cast<uint8_t>(entry.m_landId) );
updateYardObjects( land->getLandIdent() );
}
@ -232,7 +232,7 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player )
for( auto i = 0; i != parts.size(); i++ )
{
landData.housePart[ i ] = parts[ i ].first;
landData.houseColour[ i ] = (uint8_t)parts[ i ].second;
landData.houseColour[ i ] = static_cast<uint8_t>(parts[ i ].second);
}
}
}
@ -269,7 +269,7 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId )
for( auto i = 0; i != parts.size(); i++ )
{
landData.housePart[ i ] = parts[ i ].first;
landData.houseColour[ i ] = (uint8_t)parts[ i ].second;
landData.houseColour[ i ] = static_cast<uint8_t>(parts[ i ].second);
}
}
@ -409,11 +409,11 @@ void Sapphire::HousingZone::updateYardObjectPos( Entity::Player& sourcePlayer, u
auto packet = makeZonePacket< Server::FFXIVIpcHousingObjectMove >( player.second->getId() );
packet->data().itemRotation = (uint16_t)item.getRot();
packet->data().itemRotation = static_cast<uint16_t>(item.getRot());
packet->data().pos = item.getPos();
packet->data().landId = (uint8_t)landId;
packet->data().objectArray = (uint8_t)slot;
packet->data().landId = static_cast<uint8_t>(landId);
packet->data().objectArray = static_cast<uint8_t>(slot);
player.second->queuePacket( packet );
}

View file

@ -474,7 +474,7 @@ bool Sapphire::Territory::update( uint64_t tickCount )
auto dt = std::difftime( tickCount, m_lastUpdate ) / 1000.f;
if( m_pNaviProvider )
m_pNaviProvider->updateCrowd( (float)dt );
m_pNaviProvider->updateCrowd( static_cast<float>(dt) );
updateSessions( tickCount, changedWeather );
onUpdate( tickCount );