diff --git a/ext/ghoul b/ext/ghoul index 50fd88ff5d..e1c67aded5 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 50fd88ff5d18981246f58320e5963ff55da179e5 +Subproject commit e1c67aded51e7d0669d9fd036250c7129faed390 diff --git a/modules/newhorizons/util/hongkangparser.cpp b/modules/newhorizons/util/hongkangparser.cpp index 2a20c6733c..2d3ee0a2b5 100644 --- a/modules/newhorizons/util/hongkangparser.cpp +++ b/modules/newhorizons/util/hongkangparser.cpp @@ -82,7 +82,12 @@ HongKangParser::HongKangParser(std::string name, std::string fileName, void HongKangParser::findPlaybookSpecifiedTarget(std::string line, std::string& target) { //remembto add this lua later... - std::transform(line.begin(), line.end(), line.begin(), toupper); + std::transform( + line.begin(), + line.end(), + line.begin(), + [](char v) { return static_cast(toupper(v)); } + ); std::vector ptarg = _potentialTargets; for (const auto& p : ptarg) { // loop over all targets and determine from 4th col which target this instrument points to @@ -325,7 +330,6 @@ double HongKangParser::getMetFromET(double et) { } else { return _metRef - (referenceET - et); } - return 0.0; } } // namespace openspace diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index ea7e9ad77b..2a55f32db9 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -163,10 +163,19 @@ std::shared_ptr DownloadManager::downloadFile( std::shared_ptr future = std::make_shared(file.filename()); errno = 0; +#ifdef WIN32 + FILE* fp; + errno_t error = fopen_s(&fp, file.path().c_str(), "wb"); + ghoul_assert( + error == 0, + "Could not open/create file:" + file.path() + ". Errno: " + std::to_string(errno) + ); +#else FILE* fp = fopen(file.path().c_str(), "wb"); // write binary +#endif // WIN32 ghoul_assert( fp != nullptr, - "Could not open/create file:\n" + file.path() + " \nerrno: " + std::to_string(errno) + "Could not open/create file:" + file.path() + ". Errno: " + std::to_string(errno) ); //LDEBUG("Start downloading file: '" << url << "' into file '" << file.path() << "'"); diff --git a/src/interaction/interactionhandler_lua.inl b/src/interaction/interactionhandler_lua.inl index 3e5fefb8ad..2aa76be37b 100644 --- a/src/interaction/interactionhandler_lua.inl +++ b/src/interaction/interactionhandler_lua.inl @@ -258,7 +258,6 @@ int saveCameraStateToFile(lua_State* L) { int resetCameraDirection(lua_State* L) { using ghoul::lua::luaTypeToString; - const std::string _loggerCat = "lua.resetCameraDirection"; int nArguments = lua_gettop(L); if (nArguments != 0) { diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 3714c6576f..65824f46bd 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -323,7 +323,7 @@ bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio std::transform( command.begin(), command.end(), std::back_inserter(commandLowerCase), - ::tolower + [](char v) { return static_cast(tolower(v)); } ); std::string initialValueLowerCase; @@ -331,7 +331,7 @@ bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio _autoCompleteInfo.initialValue.begin(), _autoCompleteInfo.initialValue.end(), std::back_inserter(initialValueLowerCase), - ::tolower + [](char v) { return static_cast(tolower(v)); } ); bool correctCommand = diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index 1f8547f7cd..dc95269c01 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -621,11 +621,23 @@ void ParallelConnection::sendFunc(){ reinterpret_cast(&messageSizeOut), reinterpret_cast(&messageSizeOut) + sizeof(uint32_t)); - result = send(_clientSocket, header.data(), header.size(), 0); - result = send(_clientSocket, message.content.data(), message.content.size(), 0); + result = send( + _clientSocket, + header.data(), + static_cast(header.size()), + 0 + ); + result = send( + _clientSocket, + message.content.data(), + static_cast(message.content.size()), + 0 + ); if (result == SOCKET_ERROR) { - LERROR("Failed to send message.\nError: " << _ERRNO << " detected in connection, disconnecting."); + LERROR("Failed to send message.\nError: " << + _ERRNO << " detected in connection, disconnecting." + ); signalDisconnect(); } @@ -826,7 +838,12 @@ void ParallelConnection::listenCommunication() { // receive the payload messageBuffer.resize(messageSize); - nBytesRead = receiveData(_clientSocket, messageBuffer, messageSize, 0); + nBytesRead = receiveData( + _clientSocket, + messageBuffer, + static_cast(messageSize), + 0 + ); if (nBytesRead <= 0) { if (!_disconnect) { @@ -964,7 +981,7 @@ void ParallelConnection::setNConnections(size_t nConnections) { } int ParallelConnection::nConnections() { - return _nConnections; + return static_cast(_nConnections); } bool ParallelConnection::isHost() { diff --git a/src/properties/scalar/boolproperty.cpp b/src/properties/scalar/boolproperty.cpp index d61df03e23..ac5f7729cb 100644 --- a/src/properties/scalar/boolproperty.cpp +++ b/src/properties/scalar/boolproperty.cpp @@ -54,6 +54,9 @@ REGISTER_TEMPLATEPROPERTY_SOURCE(BoolProperty, bool, false, if (success) { return v; } + else { + throw ghoul::RuntimeError("Conversion error for string: " + value); + } }, [](std::string& outValue, bool inValue) -> bool { outValue = inValue ? "true" : "false"; diff --git a/src/properties/scalar/charproperty.cpp b/src/properties/scalar/charproperty.cpp index f266f1829e..b35f91368d 100644 --- a/src/properties/scalar/charproperty.cpp +++ b/src/properties/scalar/charproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/doubleproperty.cpp b/src/properties/scalar/doubleproperty.cpp index 535b3ba60c..73c4406d67 100644 --- a/src/properties/scalar/doubleproperty.cpp +++ b/src/properties/scalar/doubleproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/floatproperty.cpp b/src/properties/scalar/floatproperty.cpp index 5cc0f4c4f3..c7489c0f96 100644 --- a/src/properties/scalar/floatproperty.cpp +++ b/src/properties/scalar/floatproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/intproperty.cpp b/src/properties/scalar/intproperty.cpp index 52b85fbf74..b0f2a040be 100644 --- a/src/properties/scalar/intproperty.cpp +++ b/src/properties/scalar/intproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/longdoubleproperty.cpp b/src/properties/scalar/longdoubleproperty.cpp index be16d8ea79..17f88d073b 100644 --- a/src/properties/scalar/longdoubleproperty.cpp +++ b/src/properties/scalar/longdoubleproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/longlongproperty.cpp b/src/properties/scalar/longlongproperty.cpp index ea67efb837..68f5267426 100644 --- a/src/properties/scalar/longlongproperty.cpp +++ b/src/properties/scalar/longlongproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/longproperty.cpp b/src/properties/scalar/longproperty.cpp index fbf1ce7311..a1b15f221f 100644 --- a/src/properties/scalar/longproperty.cpp +++ b/src/properties/scalar/longproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/shortproperty.cpp b/src/properties/scalar/shortproperty.cpp index 33b31ca106..9dccb58213 100644 --- a/src/properties/scalar/shortproperty.cpp +++ b/src/properties/scalar/shortproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/signedcharproperty.cpp b/src/properties/scalar/signedcharproperty.cpp index fbe17b194c..a726448b60 100644 --- a/src/properties/scalar/signedcharproperty.cpp +++ b/src/properties/scalar/signedcharproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp index be8e9e674a..11bd35b6f6 100644 --- a/src/properties/scalar/ucharproperty.cpp +++ b/src/properties/scalar/ucharproperty.cpp @@ -37,10 +37,12 @@ namespace properties { #define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ [](lua_State* state, bool& success) -> TYPE { \ success = (lua_isnumber(state, -1) == 1); \ - if (success) \ + if (success) { \ return static_cast(lua_tonumber(state, -1)); \ - else \ + } \ + else { \ return DEFAULT_VALUE; \ + } \ } #define DEFAULT_TO_LUA_LAMBDA(TYPE) \ @@ -55,8 +57,12 @@ namespace properties { TYPE v; \ s >> v; \ success = !s.fail(); \ - if (success) \ + if (success) { \ return v; \ + } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/uintproperty.cpp b/src/properties/scalar/uintproperty.cpp index 3957fd5431..855846a113 100644 --- a/src/properties/scalar/uintproperty.cpp +++ b/src/properties/scalar/uintproperty.cpp @@ -37,10 +37,12 @@ namespace properties { #define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ [](lua_State* state, bool& success) -> TYPE { \ success = (lua_isnumber(state, -1) == 1); \ - if (success) \ + if (success) { \ return static_cast(lua_tonumber(state, -1)); \ - else \ + } \ + else { \ return DEFAULT_VALUE; \ + } \ } #define DEFAULT_TO_LUA_LAMBDA(TYPE) \ @@ -55,8 +57,12 @@ namespace properties { TYPE v; \ s >> v; \ success = !s.fail(); \ - if (success) \ + if (success) { \ return v; \ + } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/ulonglongproperty.cpp b/src/properties/scalar/ulonglongproperty.cpp index 363dc66cc5..e4aeda0818 100644 --- a/src/properties/scalar/ulonglongproperty.cpp +++ b/src/properties/scalar/ulonglongproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/ulongproperty.cpp b/src/properties/scalar/ulongproperty.cpp index 6cffb80d0d..299f66ac40 100644 --- a/src/properties/scalar/ulongproperty.cpp +++ b/src/properties/scalar/ulongproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/scalar/ushortproperty.cpp b/src/properties/scalar/ushortproperty.cpp index dd1f5e0a01..31ad9e860f 100644 --- a/src/properties/scalar/ushortproperty.cpp +++ b/src/properties/scalar/ushortproperty.cpp @@ -60,6 +60,9 @@ namespace properties { if (success) { \ return v; \ } \ + else { \ + throw ghoul::RuntimeError("Conversion error for string: " + value); \ + } \ } #define DEFAULT_TO_STRING_LAMBDA(TYPE) \ diff --git a/src/properties/vector/bvec2property.cpp b/src/properties/vector/bvec2property.cpp index a80ea44176..bdf37a9b8a 100644 --- a/src/properties/vector/bvec2property.cpp +++ b/src/properties/vector/bvec2property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/bvec3property.cpp b/src/properties/vector/bvec3property.cpp index 74e99f3e36..df3a292941 100644 --- a/src/properties/vector/bvec3property.cpp +++ b/src/properties/vector/bvec3property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/bvec4property.cpp b/src/properties/vector/bvec4property.cpp index 4c0da13839..67f393a69b 100644 --- a/src/properties/vector/bvec4property.cpp +++ b/src/properties/vector/bvec4property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/dvec2property.cpp b/src/properties/vector/dvec2property.cpp index 104a4789af..a12736e9f2 100644 --- a/src/properties/vector/dvec2property.cpp +++ b/src/properties/vector/dvec2property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/dvec3property.cpp b/src/properties/vector/dvec3property.cpp index 7a2c88925b..87eb71a50d 100644 --- a/src/properties/vector/dvec3property.cpp +++ b/src/properties/vector/dvec3property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/dvec4property.cpp b/src/properties/vector/dvec4property.cpp index 6b388a390d..c6eb3c91fd 100644 --- a/src/properties/vector/dvec4property.cpp +++ b/src/properties/vector/dvec4property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/ivec2property.cpp b/src/properties/vector/ivec2property.cpp index 4f62edee53..45d49bb45a 100644 --- a/src/properties/vector/ivec2property.cpp +++ b/src/properties/vector/ivec2property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/ivec3property.cpp b/src/properties/vector/ivec3property.cpp index fce00ab2dc..4f9dbff042 100644 --- a/src/properties/vector/ivec3property.cpp +++ b/src/properties/vector/ivec3property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/ivec4property.cpp b/src/properties/vector/ivec4property.cpp index 7beb3a4cb8..b2746cc16d 100644 --- a/src/properties/vector/ivec4property.cpp +++ b/src/properties/vector/ivec4property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/uvec2property.cpp b/src/properties/vector/uvec2property.cpp index d375eb0437..2e1f7c628d 100644 --- a/src/properties/vector/uvec2property.cpp +++ b/src/properties/vector/uvec2property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/uvec3property.cpp b/src/properties/vector/uvec3property.cpp index 62baf60b65..ddcc95a5ad 100644 --- a/src/properties/vector/uvec3property.cpp +++ b/src/properties/vector/uvec3property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/uvec4property.cpp b/src/properties/vector/uvec4property.cpp index b1e6cb3222..bae0536aa9 100644 --- a/src/properties/vector/uvec4property.cpp +++ b/src/properties/vector/uvec4property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/vec2property.cpp b/src/properties/vector/vec2property.cpp index c974e0333f..8e1b19a47e 100644 --- a/src/properties/vector/vec2property.cpp +++ b/src/properties/vector/vec2property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/vec3property.cpp b/src/properties/vector/vec3property.cpp index b4673383b1..034289cc60 100644 --- a/src/properties/vector/vec3property.cpp +++ b/src/properties/vector/vec3property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/properties/vector/vec4property.cpp b/src/properties/vector/vec4property.cpp index 1d61039d22..394332b1e0 100644 --- a/src/properties/vector/vec4property.cpp +++ b/src/properties/vector/vec4property.cpp @@ -40,8 +40,8 @@ namespace properties { __TYPE__ result; \ lua_pushnil(state); \ for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ + int hasNext = lua_next(state, -2); \ + if (hasNext != 1) { \ success = false; \ return __TYPE__(0); \ } \ @@ -85,8 +85,9 @@ namespace properties { success = false; \ return result; \ } \ - else \ + else { \ result[i] = v; \ + } \ } \ success = true; \ return result; \ @@ -95,8 +96,9 @@ namespace properties { #define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ [](std::string& outValue, __TYPE__ inValue) -> bool { \ outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ outValue += std::to_string(inValue[i]) + ","; \ + } \ outValue.pop_back(); \ outValue += "}"; \ return true; \ diff --git a/src/query/query.cpp b/src/query/query.cpp index 12bbc7ebd8..47c8e54ff8 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -99,7 +99,8 @@ properties::Property* property(const std::string& uri) { std::vector allProperties() { std::vector properties; - auto p = OsEng.globalPropertyOwner().propertiesRecursive(); + std::vector p = + OsEng.globalPropertyOwner().propertiesRecursive(); properties.insert( properties.end(), @@ -111,7 +112,7 @@ std::vector allProperties() { std::vector nodes = graph->allSceneGraphNodes(); for (SceneGraphNode* n : nodes) { - auto p = n->propertiesRecursive(); + std::vector props = n->propertiesRecursive(); properties.insert( properties.end(), p.begin(), diff --git a/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index a29a4fd69f..5fe15e627a 100644 --- a/src/rendering/abufferrenderer.cpp +++ b/src/rendering/abufferrenderer.cpp @@ -298,14 +298,14 @@ void ABufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurement float gamma = 1.0; glm::vec3 cameraPos = data.camera.position().vec3(); float maxComponent = std::max(std::max(std::abs(cameraPos.x), std::abs(cameraPos.y)), std::abs(cameraPos.z)); - float logDistance = std::log(glm::length(cameraPos / maxComponent) * maxComponent) / std::log(10); + float logDistance = std::log(glm::length(cameraPos / maxComponent) * maxComponent) / std::log(10.f); float minLogDist = 15; float maxLogDist = 20; float t = (logDistance - minLogDist) / (maxLogDist - minLogDist); t = glm::clamp(t, 0.0f, 1.0f); - gamma = 1.0 * (1 - t) + 2.2 * t; + gamma = 1.f * (1.f - t) + 2.2f * t; _resolveProgram->setUniform("gamma", gamma); @@ -503,7 +503,7 @@ void ABufferRenderer::updateRaycastData() { for (auto &raycaster : raycasters) { if (nextId > MaxRaycasters) { - int nIgnored = MaxRaycasters - raycasters.size(); + int nIgnored = MaxRaycasters - static_cast(raycasters.size()); LWARNING("ABufferRenderer does not support more than 32 raycasters. Ignoring " << nIgnored << " raycasters"); break; } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 85c0f40de3..d1cd2e6456 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -853,7 +853,7 @@ void RenderEngine::renderInformation() { const std::string& hostName = OsEng.parallelConnection().hostName(); std::string connectionInfo = ""; - int nClients = nConnections; + int nClients = static_cast(nConnections); if (status == ParallelConnection::Status::Host) { nClients--; if (nClients == 1) { @@ -963,7 +963,7 @@ void RenderEngine::renderInformation() { if (isCurrentPhase || showAllPhases) { // phases are sorted increasingly by start time, and will be popped // last-in-first-out from the stack, so add them in reversed order. - int indexLastPhase = phase->phases().size() - 1; + int indexLastPhase = static_cast(phase->phases().size()) - 1; for (int i = indexLastPhase; 0 <= i; --i) { S.push({ &phase->phases()[i], depth + 1 }); } @@ -985,11 +985,11 @@ void RenderEngine::renderInformation() { glm::dvec3 p = SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt); psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); - float a, b, c; + float a, b; glm::dvec3 radii; SpiceManager::ref().getValue("PLUTO", "RADII", radii); - a = radii.x; - b = radii.y; + a = static_cast(radii.x); + b = static_cast(radii.y); float radius = (a + b) / 2.f; float distToSurf = glm::length(nhPos.vec3()) - radius; diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index cc89ab046d..326ce45110 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -110,9 +110,9 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary , _sphericalPosition( "sphericalPosition", "Spherical coordinates", - glm::vec2(0.f, M_PI_2), - glm::vec2(-M_PI), - glm::vec2(M_PI) + glm::vec2(0.f, static_cast(M_PI_2)), + glm::vec2(-static_cast(M_PI)), + glm::vec2(static_cast(M_PI)) ) , _depth("depth", "Depth", 0.f, 0.f, 1.f) , _scale("scale", "Scale", 0.25f, 0.f, 2.f) @@ -241,7 +241,7 @@ glm::vec2 ScreenSpaceRenderable::toEuclidean(const glm::vec2& spherical, float r glm::vec2 ScreenSpaceRenderable::toSpherical(const glm::vec2& euclidean) { _radius = -sqrt(pow(euclidean[0],2)+pow(euclidean[1],2)+pow(PlaneDepth,2)); - float theta = atan2(-PlaneDepth,euclidean[0])-M_PI/2.0; + float theta = atan2(-PlaneDepth, euclidean[0]) - static_cast(M_PI_2); float phi = acos(euclidean[1]/_radius); return glm::vec2(theta, phi); diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 9d2c2b6d98..91b39784a5 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -130,8 +130,11 @@ int property_setValueRegex(lua_State* L) { lua_type(L, -1) ); } - catch (const std::regex_error& e) { - LERRORC("property_setValueRegex", "Malformed regular expression: '" << regex << "'"); + catch (const std::regex_error&) { + LERRORC( + "property_setValueRegex", + "Malformed regular expression: '" << regex << "'" + ); } return 0; diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 5206c28fa3..52bc463bb8 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -107,11 +107,14 @@ void ScriptEngine::addLibrary(LuaLibrary library) { LuaLibrary merged = *it; for (const LuaLibrary::Function& fun : library.functions) { - auto it = std::find_if(merged.functions.begin(), merged.functions.end(), + auto itf = std::find_if( + merged.functions.begin(), + merged.functions.end(), [&fun](const LuaLibrary::Function& function) { return fun.name == function.name; - }); - if (it != merged.functions.end()) { + } + ); + if (itf != merged.functions.end()) { // the function with the desired name is already present, but we don't // want to overwrite it LERROR("Lua function '" << fun.name << "' in library '" << library.name << diff --git a/src/scripting/scriptscheduler.cpp b/src/scripting/scriptscheduler.cpp index 974db87af5..c7b92be2bb 100644 --- a/src/scripting/scriptscheduler.cpp +++ b/src/scripting/scriptscheduler.cpp @@ -210,8 +210,8 @@ ScriptScheduler::progressTo(double newTime) ); // How many values did we pass over? - int n = std::distance(_timings.begin() + prevIndex, it); - _currentIndex = prevIndex + n; + ptrdiff_t n = std::distance(_timings.begin() + prevIndex, it); + _currentIndex = static_cast(prevIndex + n); // Update the new time _currentTime = newTime; @@ -232,16 +232,15 @@ ScriptScheduler::progressTo(double newTime) ); // How many values did we pass over? - int n = std::distance(it, _timings.begin() + prevIndex); - _currentIndex = prevIndex - n; + ptrdiff_t n = std::distance(it, _timings.begin() + prevIndex); + _currentIndex = static_cast(prevIndex - n); // Update the new time _currentTime = newTime; - int size = _timings.size(); return { - _backwardScripts.begin() + (size - prevIndex), - _backwardScripts.begin() + (size - _currentIndex) + _backwardScripts.begin() + (_timings.size() - prevIndex), + _backwardScripts.begin() + (_timings.size() - _currentIndex) }; } } diff --git a/src/util/blockplaneintersectiongeometry.cpp b/src/util/blockplaneintersectiongeometry.cpp index a3e5bcb2eb..b90c09d7c5 100644 --- a/src/util/blockplaneintersectiongeometry.cpp +++ b/src/util/blockplaneintersectiongeometry.cpp @@ -171,7 +171,7 @@ bool BlockPlaneIntersectionGeometry::initialize() { void BlockPlaneIntersectionGeometry::render() { glBindVertexArray(_vaoId); //glDisable(GL_CULL_FACE); - glDrawArrays(GL_TRIANGLE_FAN, 0, _vertices.size() / 3); + glDrawArrays(GL_TRIANGLE_FAN, 0, static_cast(_vertices.size() / 3)); //glEnable(GL_CULL_FACE); } diff --git a/src/util/boxgeometry.cpp b/src/util/boxgeometry.cpp index fbb795981c..0d37eff241 100644 --- a/src/util/boxgeometry.cpp +++ b/src/util/boxgeometry.cpp @@ -46,9 +46,9 @@ BoxGeometry::~BoxGeometry() { bool BoxGeometry::initialize() { // Initialize and upload to GPU - float x = _size.x * 0.5; - float y = _size.y * 0.5; - float z = _size.z * 0.5; + float x = _size.x * 0.5f; + float y = _size.y * 0.5f; + float z = _size.z * 0.5f; const GLfloat vertices[] = { -x, -y, z, // blue corner diff --git a/src/util/keys.cpp b/src/util/keys.cpp index 108f64fff8..056bd85bd9 100644 --- a/src/util/keys.cpp +++ b/src/util/keys.cpp @@ -75,7 +75,12 @@ KeyModifier operator|=(KeyModifier& lhs, KeyModifier rhs) { KeyWithModifier stringToKey(std::string str) { // key only uppercase - std::transform(str.begin(), str.end(), str.begin(), ::toupper); + std::transform( + str.begin(), + str.end(), + str.begin(), + [](char v) { return static_cast(toupper(v)); } + ); std::vector tokens = ghoul::tokenizeString(str, '+'); diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index b4ef33b833..0d7284a191 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -44,7 +44,12 @@ OpenSpaceModule::OpenSpaceModule(std::string name) void OpenSpaceModule::initialize() { std::string upperName = name(); - std::transform(upperName.begin(), upperName.end(), upperName.begin(), toupper); + std::transform( + upperName.begin(), + upperName.end(), + upperName.begin(), + [](char v) { return static_cast(toupper(v)); } + ); std::string moduleToken = ghoul::filesystem::FileSystem::TokenOpeningBraces + @@ -77,7 +82,12 @@ ghoul::systemcapabilities::Version OpenSpaceModule::requiredOpenGLVersion() cons std::string OpenSpaceModule::modulePath() const { std::string moduleName = name(); - std::transform(moduleName.begin(), moduleName.end(), moduleName.begin(), tolower); + std::transform( + moduleName.begin(), + moduleName.end(), + moduleName.begin(), + [](char v) { return static_cast(tolower(v)); } + ); if (FileSys.directoryExists("${MODULES}/" + moduleName)) { return absPath("${MODULES}/" + moduleName); diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 3dd60fb51b..5265e474d8 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -452,7 +452,7 @@ void SpiceManager::getValue(const std::string& body, const std::string& value, { ghoul_assert(!v.empty(), "Array for values has to be preallocaed"); - getValueInternal(body, value, v.size(), v.data()); + getValueInternal(body, value, static_cast(v.size()), v.data()); } double SpiceManager::spacecraftClockToET(const std::string& craft, double craftTicks) { diff --git a/src/util/spicemanager_lua.inl b/src/util/spicemanager_lua.inl index b820f3078c..b25cbf5f4a 100644 --- a/src/util/spicemanager_lua.inl +++ b/src/util/spicemanager_lua.inl @@ -81,6 +81,7 @@ int unloadKernel(lua_State* L) { if (isNumber) { unsigned int argument = static_cast(lua_tonumber(L, -1)); SpiceManager::ref().unloadKernel(argument); + return 0; } }