mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 00:47:45 +00:00
Fixing some type alignments via casting
- static_cast for reasonable values - at least one stray float
This commit is contained in:
parent
9df21f92eb
commit
3b42b1df9b
9 changed files with 14 additions and 14 deletions
|
@ -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<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] = 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 );
|
||||
|
|
|
@ -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<size_t>( 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<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] {
|
||||
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<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();
|
||||
|
|
|
@ -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<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 ) )
|
||||
{
|
||||
|
|
|
@ -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<size_t>(content_length-num_additional_bytes)),
|
||||
[this, socket, request, timer]
|
||||
(const boost::system::error_code& ec, size_t /*bytes_transferred*/) {
|
||||
if(timer)
|
||||
|
|
|
@ -451,7 +451,7 @@ void Core::Entity::BattleNpc::onDeath()
|
|||
|
||||
|
||||
// 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();
|
||||
pPlayer->gainExp( exp );
|
||||
|
|
|
@ -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<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 = 2600 + ( level - 60 ) * 100;
|
||||
approxBaseHp = static_cast<float>( 2600 + ( level - 60 ) * 100 );
|
||||
else if ( level >= 50 )
|
||||
approxBaseHp = 1700 + ( ( level - 50 ) * ( 1700 * 1.04325f ) );
|
||||
else
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<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
|
||||
cost = cost > 999 ? 999 : cost;
|
||||
|
|
Loading…
Add table
Reference in a new issue