Fixed various compiler warnings for 64-bit windows compilation.

This commit is contained in:
hiker 2018-10-11 23:27:08 +11:00
parent b28d11cbcc
commit 17ab076858
12 changed files with 49 additions and 31 deletions

View File

@ -42,8 +42,14 @@
#ifdef _MSC_VER
#include <float.h>
/* windows with visual c */
#include <math.h> // For isnan etc, otherwise we get duplicated defines
#ifndef isnan
#define isnan(x) (_isnan(x))
#endif
#ifndef isinf
#define isinf(x) (!_finite(x))
#endif
/* disable warnings I don't care about */
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
#endif

View File

@ -709,7 +709,7 @@ static float ir_distance(struct ir_dot_t* dot) {
xd = dot[i2].x - dot[i1].x;
yd = dot[i2].y - dot[i1].y;
return sqrtf(xd * xd + yd * yd);
return sqrtf((float)(xd * xd + yd * yd));
}

View File

@ -192,7 +192,7 @@ int AchievementInfo::recursiveGoalCount(goalTree &parent)
if (parent.children.size() >= 2 &&
parent.type != "OR")
{
return parent.children.size();
return (int)parent.children.size();
}
else if (parent.children.size() == 1 &&
(parent.children[0].type == "AND" ||

View File

@ -49,7 +49,8 @@ AchievementsStatus::AchievementsStatus()
}
// Create one TrackStats instance for all existing tracks
const unsigned int track_amount = track_manager->getNumberOfTracks();
const unsigned int track_amount =
(unsigned int)track_manager->getNumberOfTracks();
for (unsigned int n = 0; n < track_amount; n++)
{

View File

@ -315,7 +315,7 @@ void PowerupManager::WeightsData::convertRankToSection(int rank, int *prev,
// The last kart always uses the data for the last section
if (rank == (int)m_num_karts)
{
*prev = *next = m_weights_for_section.size() - 1;
*prev = *next = (int)m_weights_for_section.size() - 1;
*weight = 1.0f;
return;
}
@ -343,7 +343,7 @@ void PowerupManager::WeightsData::convertRankToSection(int rank, int *prev,
// and the last to the last kart, leaving two inner points defining
// 3 sections, i.e. number_of_points - 3 + 1
// In both cases the number of sections is:
int num_sections = (m_weights_for_section.size() - first_section_index);
int num_sections = ((int)m_weights_for_section.size() - first_section_index);
float karts_per_fraction = (m_num_karts - first_section_index)
/ float(num_sections);
@ -407,7 +407,7 @@ int PowerupManager::WeightsData::getRandomItem(int rank, uint64_t random_number)
{
// E.g. for battle mode with only one entry
if(rank>(int)m_summed_weights_for_rank.size())
rank = m_summed_weights_for_rank.size()-1;
rank = (int)m_summed_weights_for_rank.size()-1;
else if (rank<0) rank = 0; // E.g. battle mode, which has rank -1
const std::vector<unsigned> &summed_weights = m_summed_weights_for_rank[rank];
// The last entry is the sum of all previous entries, i.e. the maximum

View File

@ -1779,13 +1779,12 @@ void SkiddingAI::handleSwitch(int item_skill, const std::vector<const Item *> &i
else if(item_skill == 5)
{
//First step : identify the best available item
int i;
int bad = 0;
int good = 0;
//Good will store 1 for nitro, big or small, 2 for item box
//Big nitro are usually hard to take for the AI
for(i=items_to_collect.size()-1; i>=0; i--)
for(int i=(int)items_to_collect.size()-1; i>=0; i--)
{
if (items_to_collect[i]->getType() == Item::ITEM_BONUS_BOX)
{
@ -1800,7 +1799,7 @@ void SkiddingAI::handleSwitch(int item_skill, const std::vector<const Item *> &i
}
//Bad will store 2 for bananas, 3 for bubble gum
for(i=items_to_avoid.size()-1; i>=0; i--)
for(int i=(int)items_to_avoid.size()-1; i>=0; i--)
{
if (items_to_avoid[i]->getType() == Item::ITEM_BUBBLEGUM)
{
@ -2215,7 +2214,7 @@ void SkiddingAI::handleNitroAndZipper(float max_safe_speed)
// just keep enough to help accelerating after an accident
if(race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
{
energy_reserve = std::min<int>(2, energy_reserve);
energy_reserve = std::min(2.0f, energy_reserve);
}
// Don't use nitro or zipper if we are braking

View File

@ -883,9 +883,9 @@ float Kart::getSpeedForTurnRadius(float radius) const
InterpolationArray turn_angle_at_speed = m_kart_properties->getTurnRadius();
// Convert the turn radius into turn angle
for(int i = 0; i < (int)turn_angle_at_speed.size(); i++)
turn_angle_at_speed.setY(i, sin( 1.0 / turn_angle_at_speed.getY(i)));
turn_angle_at_speed.setY(i, sin( 1.0f / turn_angle_at_speed.getY(i)));
float angle = sin(1.0 / radius);
float angle = sin(1.0f / radius);
return turn_angle_at_speed.getReverse(angle);
} // getSpeedForTurnRadius
@ -902,7 +902,7 @@ float Kart::getMaxSteerAngle(float speed) const
// across karts of different lengths sharing the same
// turn radius properties
for(int i = 0; i < (int)turn_angle_at_speed.size(); i++)
turn_angle_at_speed.setY(i, sin( 1.0 / turn_angle_at_speed.getY(i))
turn_angle_at_speed.setY(i, sin( 1.0f / turn_angle_at_speed.getY(i))
* m_kart_properties->getWheelBase());
return turn_angle_at_speed.get(speed);

View File

@ -512,10 +512,10 @@ void RaceManager::startNextRace()
} // not first race
// set boosted AI status for AI karts
int boosted_ai_count = std::min<int>(m_ai_kart_list.size(),
(m_kart_status.size()-2)/4 + 1);
int boosted_ai_count = std::min<int>((int)m_ai_kart_list.size(),
((int)(m_kart_status.size())-2)/4 + 1);
if (boosted_ai_count > 4) boosted_ai_count = 4;
int ai_count = m_ai_kart_list.size();
int ai_count = (int)m_ai_kart_list.size();
for (unsigned int i=0;i<m_kart_status.size();i++)
{
@ -1023,7 +1023,7 @@ void RaceManager::configGrandPrixResultFromNetwork(NetworkString& ns)
{ return m_tracks; }
virtual unsigned int
getNumberOfTracks(const bool includeLocked=false) const
{ return m_tracks.size(); }
{ return (unsigned int)m_tracks.size(); }
void addNetworkTrack(const std::string& t) { m_tracks.push_back(t); }
};

View File

@ -514,7 +514,10 @@ public:
* AI karts. */
unsigned int getNumberOfKarts() const {return m_num_karts; }
// ------------------------------------------------------------------------
unsigned int getNumberOfAIKarts() const {return m_ai_kart_list.size(); }
unsigned int getNumberOfAIKarts() const
{
return (unsigned int)m_ai_kart_list.size();
} // getNumberOfAIKarts
// ------------------------------------------------------------------------
unsigned int getNumNonGhostKarts() const { return m_num_karts - m_num_ghost_karts; }
// ------------------------------------------------------------------------

View File

@ -328,10 +328,12 @@ void ReplayPlay::loadFile(bool second_replay)
return;
}
Log::info("Replay", "Reading replay file '%s'.", getReplayFilename(replay_file_number).c_str());
Log::info("Replay", "Reading replay file '%s'.",
getReplayFilename(replay_file_number).c_str());
ReplayData &rd = m_replay_file_list[replay_index];
unsigned int num_kart = m_replay_file_list.at(replay_index).m_kart_list.size();
unsigned int num_kart = (unsigned int)m_replay_file_list.at(replay_index)
.m_kart_list.size();
unsigned int lines_to_skip = (rd.m_replay_version == 3) ? 7 : 10;
lines_to_skip += (rd.m_replay_version == 3) ? num_kart : 2*num_kart;
@ -358,13 +360,15 @@ void ReplayPlay::readKartData(FILE *fd, char *next_line, bool second_replay)
{
char s[1024];
int replay_index = second_replay ? m_second_replay_file : m_current_replay_file;
int replay_index = second_replay ? m_second_replay_file
: m_current_replay_file;
const unsigned int kart_num = m_ghost_karts.size();
const unsigned int kart_num = (unsigned int)m_ghost_karts.size();
unsigned int first_loaded_f_num = 0;
if (!second_replay && m_second_replay_enabled)
first_loaded_f_num = m_replay_file_list.at(m_second_replay_file).m_kart_list.size();
first_loaded_f_num = (unsigned int)m_replay_file_list.at(m_second_replay_file)
.m_kart_list.size();
ReplayData &rd = m_replay_file_list[replay_index];
m_ghost_karts.push_back(std::make_shared<GhostKart>

View File

@ -172,9 +172,11 @@ public:
const unsigned int getNumGhostKart() const
{
assert(m_replay_file_list.size() > 0);
unsigned int num = m_replay_file_list.at(m_current_replay_file)
unsigned int num =
(unsigned int)m_replay_file_list.at(m_current_replay_file)
.m_kart_list.size();
unsigned int second_file_num = m_replay_file_list.at(m_second_replay_file)
unsigned int second_file_num =
(unsigned int)m_replay_file_list.at(m_second_replay_file)
.m_kart_list.size();
num = (m_second_replay_enabled) ? num + second_file_num : num;
@ -186,7 +188,9 @@ public:
{
assert(m_replay_file_list.size() > 0);
unsigned int fkn = m_replay_file_list.at(m_current_replay_file).m_kart_list.size();
unsigned int fkn =
(unsigned int)m_replay_file_list.at(m_current_replay_file)
.m_kart_list.size();
if (n < fkn)
return m_replay_file_list.at(m_current_replay_file).m_kart_list.at(n);
else

3
src/states_screens/online/server_selection.cpp Normal file → Executable file
View File

@ -140,7 +140,8 @@ void ServerSelection::init()
m_searcher->clearListeners();
m_searcher->addListener(this);
m_icon_bank->setScale((float)getHeight() / 15.0f / 128.0f);
m_server_list_widget->setIcons(m_icon_bank, (float)getHeight() / 12.0f);
m_server_list_widget->setIcons(m_icon_bank,
int(getHeight() / 12.0f));
m_sort_desc = false;
/** Triggers the loading of the server list in the servers manager. */
refresh(true);