1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 08:57:44 +00:00

Fixing some type alignments via casting

- static_cast for reasonable values
- at least one stray float
This commit is contained in:
ShelbyZ 2017-10-19 16:18:16 -07:00
parent 9df21f92eb
commit 3b42b1df9b
9 changed files with 14 additions and 14 deletions

View file

@ -93,7 +93,7 @@ std::string Core::Util::base64_decode( std::string const& encoded_string ) {
char_array_4[i++] = encoded_string[in_]; in_++; char_array_4[i++] = encoded_string[in_]; in_++;
if( i == 4 ) { if( i == 4 ) {
for( i = 0; i < 4; i++ ) for( i = 0; i < 4; i++ )
char_array_4[i] = 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[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 ); 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; char_array_4[j] = 0;
for( j = 0; j < 4; j++ ) for( j = 0; j < 4; j++ )
char_array_4[j] = 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[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 ); char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 );

View file

@ -266,7 +266,7 @@ namespace SimpleWeb {
if( content_length>num_additional_bytes ) { if( content_length>num_additional_bytes ) {
auto timer = get_timeout_timer(); auto timer = get_timeout_timer();
boost::asio::async_read( *socket, response->content_buffer, boost::asio::async_read( *socket, response->content_buffer,
boost::asio::transfer_exactly( 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*/ ) { [this, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) {
if( timer ) if( timer )
timer->cancel(); timer->cancel();
@ -307,7 +307,7 @@ namespace SimpleWeb {
line.pop_back(); line.pop_back();
std::streamsize length = stol( line, 0, 16 ); std::streamsize length = stol( line, 0, 16 );
auto num_additional_bytes = static_cast<std::streamsize>( response->content_buffer.size() - bytes_transferred ); auto num_additional_bytes = response->content_buffer.size() - bytes_transferred;
auto post_process = [this, &response, &streambuf, length] { auto post_process = [this, &response, &streambuf, length] {
std::ostream stream( &streambuf ); std::ostream stream( &streambuf );
@ -332,7 +332,7 @@ namespace SimpleWeb {
if( ( 2 + length )>num_additional_bytes ) { if( ( 2 + length )>num_additional_bytes ) {
auto timer = get_timeout_timer(); auto timer = get_timeout_timer();
boost::asio::async_read( *socket, response->content_buffer, boost::asio::async_read( *socket, response->content_buffer,
boost::asio::transfer_exactly( 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*/ ) { [this, post_process, timer]( const boost::system::error_code& ec, size_t /*bytes_transferred*/ ) {
if( timer ) if( timer )
timer->cancel(); timer->cancel();

View file

@ -149,7 +149,7 @@ bool loadSettings( int32_t argc, char* argv[] )
params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 );
params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" );
server.config.port = std::stoul( m_pConfig->getValue<std::string>( "Settings.General.HttpPort", "80" ) ); server.config.port = static_cast<unsigned short>( std::stoul( m_pConfig->getValue<std::string>( "Settings.General.HttpPort", "80" ) ) );
if( !g_database.initialize( params ) ) if( !g_database.initialize( params ) )
{ {

View file

@ -282,7 +282,7 @@ namespace SimpleWeb {
//Set timeout on the following boost::asio::async-read or write function //Set timeout on the following boost::asio::async-read or write function
auto timer=this->get_timeout_timer(socket, config.timeout_content); auto timer=this->get_timeout_timer(socket, config.timeout_content);
boost::asio::async_read(*socket, request->streambuf, boost::asio::async_read(*socket, request->streambuf,
boost::asio::transfer_exactly(content_length-num_additional_bytes), boost::asio::transfer_exactly(static_cast<size_t>(content_length-num_additional_bytes)),
[this, socket, request, timer] [this, socket, request, timer]
(const boost::system::error_code& ec, size_t /*bytes_transferred*/) { (const boost::system::error_code& ec, size_t /*bytes_transferred*/) {
if(timer) if(timer)

View file

@ -451,7 +451,7 @@ void Core::Entity::BattleNpc::onDeath()
// todo: this is actually retarded, we need real rand() // todo: this is actually retarded, we need real rand()
srand( time( NULL ) ); srand( static_cast<unsigned int>( time( NULL ) ) );
auto pPlayer = pHateEntry->m_pActor->getAsPlayer(); auto pPlayer = pHateEntry->m_pActor->getAsPlayer();
pPlayer->gainExp( exp ); pPlayer->gainExp( exp );

View file

@ -38,7 +38,7 @@ float CalcBattle::calculateBaseStat( PlayerPtr pPlayer )
// SB Base Stat Formula (Aligned) // SB Base Stat Formula (Aligned)
if ( level > 60 ) if ( level > 60 )
{ {
base = ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8); base = static_cast<float>( ( ( ( level == 61 ) ? 224 : 220 ) + ( level - 61 ) * 8) );
} }
// HW Base Stat Formula (Aligned) // HW Base Stat Formula (Aligned)
else if ( level > 50 ) else if ( level > 50 )
@ -77,7 +77,7 @@ uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer )
// These values are not precise. // These values are not precise.
if ( level >= 60 ) if ( level >= 60 )
approxBaseHp = 2600 + ( level - 60 ) * 100; approxBaseHp = static_cast<float>( 2600 + ( level - 60 ) * 100 );
else if ( level >= 50 ) else if ( level >= 50 )
approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) ); approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) );
else else

View file

@ -345,7 +345,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
void Core::Entity::Player::forceZoneing( uint32_t zoneId ) 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() ); //performZoning( zoneId, Common::ZoneingType::None, getPos() );
} }

View file

@ -1147,7 +1147,7 @@ bool Core::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t optional
exp = questInfo->reward_exp_factor; 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; uint16_t optionalItemCount = questInfo->reward_item_optional.size() > 0 ? 1 : 0;
uint32_t gilReward = questInfo->reward_gil; uint32_t gilReward = questInfo->reward_gil;

View file

@ -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 ); 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 // 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 ) + 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; pow( fromAetheryte->map_coord_y - targetAetheryte->map_coord_y, 2 ) ) / 2 ) + 100 );
// cap at 999 gil // cap at 999 gil
cost = cost > 999 ? 999 : cost; cost = cost > 999 ? 999 : cost;