diff --git a/src/core/include/scheduler.h b/src/core/include/scheduler.h index 02f7b1c4..d84f7901 100644 --- a/src/core/include/scheduler.h +++ b/src/core/include/scheduler.h @@ -24,7 +24,7 @@ public: void setEras(vector newEras) { eras = newEras; } void setCommandModeOptions(json::value newOptions); - int getFrameRate() { return frameRate; }; + int getFrameRate() { return static_cast(round(frameRate)); }; int getLoad(); bool getRestrictSpawns() { return restrictSpawns; } bool getRestrictToCoalition() { return restrictToCoalition; } diff --git a/src/core/include/unit.h b/src/core/include/unit.h index 73d8ca0b..5ba64e7c 100644 --- a/src/core/include/unit.h +++ b/src/core/include/unit.h @@ -220,7 +220,7 @@ protected: virtual void AIloop() = 0; void appendString(stringstream& ss, const unsigned char& datumIndex, const string& datumValue) { - const unsigned short size = datumValue.size(); + const unsigned short size = static_cast(datumValue.size()); ss.write((const char*)&datumIndex, sizeof(unsigned char)); ss.write((const char*)&size, sizeof(unsigned short)); ss << datumValue; @@ -245,7 +245,7 @@ protected: template void appendVector(stringstream& ss, const unsigned char& datumIndex, vector& datumValue) { - const unsigned short size = datumValue.size(); + const unsigned short size = static_cast(datumValue.size()); ss.write((const char*)&datumIndex, sizeof(unsigned char)); ss.write((const char*)&size, sizeof(unsigned short)); @@ -255,7 +255,7 @@ protected: template void appendList(stringstream& ss, const unsigned char& datumIndex, list& datumValue) { - const unsigned short size = datumValue.size(); + const unsigned short size = static_cast(datumValue.size());; ss.write((const char*)&datumIndex, sizeof(unsigned char)); ss.write((const char*)&size, sizeof(unsigned short)); diff --git a/src/core/include/weapon.h b/src/core/include/weapon.h index 5ca44170..31d65b84 100644 --- a/src/core/include/weapon.h +++ b/src/core/include/weapon.h @@ -59,7 +59,7 @@ protected: /********** Private methods **********/ void appendString(stringstream& ss, const unsigned char& datumIndex, const string& datumValue) { - const unsigned short size = datumValue.size(); + const unsigned short size = static_cast(datumValue.size()); ss.write((const char*)&datumIndex, sizeof(unsigned char)); ss.write((const char*)&size, sizeof(unsigned short)); ss << datumValue; diff --git a/src/core/src/groundunit.cpp b/src/core/src/groundunit.cpp index b8405bee..3bb2fc02 100644 --- a/src/core/src/groundunit.cpp +++ b/src/core/src/groundunit.cpp @@ -259,7 +259,7 @@ void GroundUnit::AIloop() } /* Wait an amout of time depending on the shots intensity */ - internalCounter = ((ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast(((ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL); } if (targetPosition == Coords(NULL)) @@ -267,7 +267,7 @@ void GroundUnit::AIloop() /* Fallback if something went wrong */ if (internalCounter == 0) - internalCounter = 20 / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast(20 / FRAMERATE_TIME_INTERVAL); internalCounter--; break; @@ -302,7 +302,7 @@ void GroundUnit::AIloop() } if (internalCounter == 0) - internalCounter = 20 / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast(20 / FRAMERATE_TIME_INTERVAL); internalCounter--; break; @@ -392,7 +392,7 @@ void GroundUnit::AIloop() scheduler->appendCommand(command); setHasTask(true); - internalCounter = (aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL); } /* Else, do miss on purpose */ else { @@ -414,13 +414,13 @@ void GroundUnit::AIloop() scheduler->appendCommand(command); setHasTask(true); setTargetPosition(Coords(aimLat, aimLng, target->getPosition().alt)); - internalCounter = (aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL); } else if (distance < aimMethodRange) { /* If the unit is closer than the aim method range, use the aim method range */ aimAtPoint(Coords(aimLat, aimLng, aimAlt)); setTargetPosition(Coords(aimLat, aimLng, target->getPosition().alt)); - internalCounter = (aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast((aimTime + (ShotsIntensity::HIGH - shotsIntensity) * shotsBaseInterval + 2) / FRAMERATE_TIME_INTERVAL); } else { /* Else just wake the unit up with an impossible command */ @@ -433,7 +433,7 @@ void GroundUnit::AIloop() setTargetPosition(Coords(NULL)); /* Don't wait too long before checking again */ - internalCounter = 5 / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast(5 / FRAMERATE_TIME_INTERVAL); } } missOnPurposeTarget = target; @@ -452,7 +452,7 @@ void GroundUnit::AIloop() if (databaseEntry.has_number_field(L"alertnessTimeConstant")) alertnessTimeConstant = databaseEntry[L"alertnessTimeConstant"].as_number().to_double(); } - internalCounter = (5 + RANDOM_ZERO_TO_ONE * alertnessTimeConstant * 0 /* TODO: remove to enable alertness again */) / FRAMERATE_TIME_INTERVAL; + internalCounter = static_cast((5 + RANDOM_ZERO_TO_ONE * alertnessTimeConstant * 0 /* TODO: remove to enable alertness again */) / FRAMERATE_TIME_INTERVAL); missOnPurposeTarget = nullptr; setTargetPosition(Coords(NULL)); } diff --git a/src/core/src/scheduler.cpp b/src/core/src/scheduler.cpp index 7947dee0..096b8c3f 100644 --- a/src/core/src/scheduler.cpp +++ b/src/core/src/scheduler.cpp @@ -62,7 +62,7 @@ void Scheduler::execute(lua_State* L) if (getFrameRate() + 3 > 0) fpsMultiplier = static_cast(max(1, 60 / (getFrameRate() + 3))); /* Multiplier between 1 and 20 */ - load = command->getLoad() * fpsMultiplier; + load = static_cast(command->getLoad() * fpsMultiplier); commands.remove(command); executedCommandsHashes.push_back(command->getHash()); command->executeCallback(); /* Execute the command callback (this is a lambda function that can be used to execute a function when the command is run) */ @@ -88,7 +88,7 @@ void Scheduler::setCommandModeOptions(json::value value) { setRedSpawnPoints(value[L"spawnPoints"][L"red"].as_number().to_int32()); } if (value.has_array_field(L"eras")) { - int length = value[L"eras"].as_array().size(); + int length = static_cast(value[L"eras"].as_array().size()); vector newEras; for (int idx = 0; idx < length; idx++) newEras.push_back(to_string(value[L"eras"].as_array().at(idx))); @@ -138,6 +138,8 @@ bool Scheduler::checkSpawnPoints(int spawnPoints, string coalition) return false; } } + + return false; } void Scheduler::handleRequest(string key, json::value value, string username, json::value& answer) @@ -260,7 +262,7 @@ void Scheduler::handleRequest(string key, json::value value, string username, js { unsigned int ID = value[L"ID"].as_integer(); unitsManager->acquireControl(ID); - unsigned int leaderID = value[L"targetID"].as_double(); + unsigned int leaderID = value[L"targetID"].as_integer(); double offsetX = value[L"offsetX"].as_double(); double offsetY = value[L"offsetY"].as_double(); double offsetZ = value[L"offsetZ"].as_double(); diff --git a/src/core/src/server.cpp b/src/core/src/server.cpp index b810db13..c3a609d6 100644 --- a/src/core/src/server.cpp +++ b/src/core/src/server.cpp @@ -89,7 +89,7 @@ void Server::handle_get(http_request request) try { time = stoull((*(query.find(L"time"))).second); } - catch (const std::exception& e) { + catch (...) { time = 0; } } diff --git a/src/dcstools/src/dcstools.cpp b/src/dcstools/src/dcstools.cpp index fc965c3e..ae655e68 100644 --- a/src/dcstools/src/dcstools.cpp +++ b/src/dcstools/src/dcstools.cpp @@ -82,7 +82,7 @@ void getAllUnits(lua_State* L, map& unitJSONs) lua_pushnil(L); while (lua_next(L, 2) != 0) { - unsigned int ID = lua_tonumber(L, -2); + unsigned int ID = static_cast(lua_tonumber(L, -2)); if (unitJSONs.find(ID) == unitJSONs.end()) unitJSONs[ID] = json::value::object(); luaTableToJSON(L, -1, unitJSONs[ID]); diff --git a/third-party/base64/include/base64.hpp b/third-party/base64/include/base64.hpp index 9e3d1565..c8600e93 100644 --- a/third-party/base64/include/base64.hpp +++ b/third-party/base64/include/base64.hpp @@ -18,7 +18,7 @@ namespace base64 { uint32_t bit_stream = 0; const std::string base64_chars = get_base64_chars(); std::string encoded; - encoded.reserve(ceil(4.0 / 3.0 * size)); + encoded.reserve(static_cast(ceil(4.0 / 3.0 * size))); int offset = 0; for (unsigned int idx = 0; idx < size; idx++) { unsigned char c = data[idx]; @@ -63,7 +63,7 @@ namespace base64 { auto num_val = base64_chars.find(c); if (num_val != std::string::npos) { offset = 18 - counter % 4 * 6; - bit_stream += num_val << offset; + bit_stream += static_cast(num_val << offset); if (offset == 12) { decoded += static_cast(bit_stream >> 16 & 0xff); }