mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
rwgame: fix Visual Studio warnings
This commit is contained in:
parent
05896caac5
commit
2a1163d391
@ -284,7 +284,7 @@ void TextRenderer::renderText(const TextRenderer::TextInfo& ti,
|
||||
// will need to be wrapped
|
||||
if (ti.wrapX > 0 && coord.x > 0.f && !std::isspace(c)) {
|
||||
auto wend = std::find_if(std::begin(text) + i, std::end(text),
|
||||
[](GameStringChar c) { return std::isspace(c); });
|
||||
[](auto c) { return std::isspace(c); });
|
||||
if (wend != std::end(text)) {
|
||||
auto word = std::distance(std::begin(text) + i, wend);
|
||||
if (lineLength + word >= ti.wrapX) {
|
||||
|
@ -37,8 +37,8 @@ constexpr float ui_worldSizeMax = 300.f;
|
||||
|
||||
void drawScriptTimer(GameWorld* world, GameRenderer* render) {
|
||||
if (world->state->scriptTimerVariable) {
|
||||
float scriptTimerTextX =
|
||||
render->getRenderer()->getViewport().x - ui_outerMargin;
|
||||
float scriptTimerTextX = static_cast<float>(
|
||||
render->getRenderer()->getViewport().x - ui_outerMargin);
|
||||
float scriptTimerTextY = ui_scriptTimerHeight;
|
||||
|
||||
TextRenderer::TextInfo ti;
|
||||
@ -97,13 +97,13 @@ void drawMap(ViewCamera& currentView, PlayerController* player,
|
||||
|
||||
void drawPlayerInfo(PlayerController* player, GameWorld* world,
|
||||
GameRenderer* render) {
|
||||
float infoTextX = render->getRenderer()->getViewport().x -
|
||||
(ui_outerMargin + ui_weaponSize + ui_infoMargin);
|
||||
float infoTextX = static_cast<float>(render->getRenderer()->getViewport().x -
|
||||
(ui_outerMargin + ui_weaponSize + ui_infoMargin));
|
||||
float infoTextY = 0.f + ui_outerMargin;
|
||||
float iconX = render->getRenderer()->getViewport().x -
|
||||
(ui_outerMargin + ui_weaponSize);
|
||||
float iconX = static_cast<float>(render->getRenderer()->getViewport().x -
|
||||
(ui_outerMargin + ui_weaponSize));
|
||||
float iconY = ui_outerMargin;
|
||||
float wantedX = render->getRenderer()->getViewport().x - (ui_outerMargin);
|
||||
float wantedX = static_cast<float>(render->getRenderer()->getViewport().x - ui_outerMargin);
|
||||
float wantedY = ui_wantedLevelHeight;
|
||||
|
||||
TextRenderer::TextInfo ti;
|
||||
@ -292,7 +292,7 @@ void drawOnScreenText(GameWorld* world, GameRenderer* renderer) {
|
||||
|
||||
for (auto& l : alltext) {
|
||||
for (auto& t : l) {
|
||||
ti.size = t.size;
|
||||
ti.size = static_cast<float>(t.size);
|
||||
ti.font = t.font;
|
||||
ti.text = t.text;
|
||||
ti.wrapX = t.wrapX;
|
||||
|
@ -104,7 +104,7 @@ struct BoolTranslator {
|
||||
boost::optional<external_type> res;
|
||||
try {
|
||||
res = std::stoi(stripComments(str)) != 0;
|
||||
} catch (std::invalid_argument &e) {
|
||||
} catch (std::invalid_argument &) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -120,7 +120,7 @@ struct IntTranslator {
|
||||
boost::optional<external_type> res;
|
||||
try {
|
||||
res = std::stoi(stripComments(str));
|
||||
} catch (std::invalid_argument &e) {
|
||||
} catch (std::invalid_argument &) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -191,6 +191,7 @@ GameConfig::ParseResult GameConfig::parseConfig(GameConfig::ParseType srcType,
|
||||
try {
|
||||
sourceValue = srcTree.get<config_t>(key, translator);
|
||||
} catch (pt::ptree_bad_path &e) {
|
||||
RW_UNUSED(e);
|
||||
// Catches missing key-value pairs: fail when required
|
||||
if (!optional) {
|
||||
parseResult.failRequiredMissing(key);
|
||||
@ -199,6 +200,7 @@ GameConfig::ParseResult GameConfig::parseConfig(GameConfig::ParseType srcType,
|
||||
}
|
||||
sourceValue = defaultValue;
|
||||
} catch (pt::ptree_bad_data &e) {
|
||||
RW_UNUSED(e);
|
||||
// Catches illegal value data: always fail
|
||||
parseResult.failInvalidData(key);
|
||||
RW_MESSAGE(e.what());
|
||||
|
@ -15,7 +15,7 @@ void GameWindow::create(const std::string& title, size_t w, size_t h,
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
|
||||
window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED, w, h, style);
|
||||
SDL_WINDOWPOS_CENTERED, static_cast<int>(w), static_cast<int>(h), style);
|
||||
if (window == nullptr) {
|
||||
// Window creation failure is fatal
|
||||
std::string sdlErrorStr = SDL_GetError();
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
glm::vec2 c(x - offset.x, y - offset.y);
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (c.y > 0.f && c.y < size) {
|
||||
activeEntry = i;
|
||||
activeEntry = static_cast<int>(i);
|
||||
return;
|
||||
} else {
|
||||
c.y -= size;
|
||||
@ -149,7 +149,7 @@ public:
|
||||
if (activeEntry >= static_cast<int>(entries.size())) {
|
||||
activeEntry = 0;
|
||||
} else if (activeEntry < 0) {
|
||||
activeEntry = entries.size() - 1;
|
||||
activeEntry = static_cast<int>(entries.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ void RWGame::handleCheatInput(char symbol) {
|
||||
5 //sniper rifle
|
||||
};
|
||||
for (std::array<int, 11>::size_type i = 0; i < ammo.size(); i++)
|
||||
player->addToInventory(i+1,ammo[i]);
|
||||
player->addToInventory(static_cast<int>(i+1),ammo[i]);
|
||||
state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats.
|
||||
});
|
||||
|
||||
|
@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
|
||||
RWGame game(logger, argc, argv);
|
||||
|
||||
return game.run();
|
||||
} catch (std::invalid_argument& ex) {
|
||||
} catch (std::invalid_argument&) {
|
||||
// This exception is thrown when either an invalid command line option
|
||||
// or a --help is found. The RWGame constructor prints a usage message
|
||||
// in this case and then throws this exception.
|
||||
|
@ -218,7 +218,7 @@ std::shared_ptr<Menu> DebugState::createWeatherMenu() {
|
||||
|
||||
for (std::size_t i = 0; i < w.size(); ++i) {
|
||||
menu->lambda(w[i],
|
||||
[=] { game->getWorld()->state->basic.nextWeather = i; });
|
||||
[=] { game->getWorld()->state->basic.nextWeather = static_cast<std::uint16_t>(i); });
|
||||
}
|
||||
|
||||
menu->offset = kDebugMenuOffset;
|
||||
|
Loading…
Reference in New Issue
Block a user