From 8557f2176dbd8f13878fe9cf866c1b066429b6ef Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 29 Aug 2018 22:46:00 +0200 Subject: [PATCH 01/24] rwcore: fix Visual Studio warnings --- rwcore/data/Clump.hpp | 2 +- rwcore/fonts/FontMap.cpp | 2 +- rwcore/fonts/Unicode.cpp | 20 ++++++++++---------- rwcore/gl/DrawBuffer.cpp | 4 ++-- rwcore/gl/GeometryBuffer.cpp | 3 --- rwcore/gl/GeometryBuffer.hpp | 16 ++++++++-------- rwcore/gl/TextureData.hpp | 2 +- rwcore/loaders/LoaderDFF.cpp | 4 ++-- rwcore/loaders/LoaderIMG.cpp | 18 ++++++++---------- rwcore/loaders/LoaderIMG.hpp | 7 +++---- rwcore/loaders/LoaderSDT.cpp | 16 +++++++++------- rwcore/loaders/LoaderSDT.hpp | 3 +-- rwcore/rw/casts.hpp | 6 +++--- 13 files changed, 49 insertions(+), 54 deletions(-) diff --git a/rwcore/data/Clump.hpp b/rwcore/data/Clump.hpp index 86347cb8..8dc8dbad 100644 --- a/rwcore/data/Clump.hpp +++ b/rwcore/data/Clump.hpp @@ -107,7 +107,7 @@ public: */ struct SubGeometry { - GLuint start = 0; + size_t start = 0; size_t material = 0; std::vector indices; size_t numIndices = 0; diff --git a/rwcore/fonts/FontMap.cpp b/rwcore/fonts/FontMap.cpp index fd1c3b5a..c8ba1eae 100644 --- a/rwcore/fonts/FontMap.cpp +++ b/rwcore/fonts/FontMap.cpp @@ -28,7 +28,7 @@ FontMap::FontMap(std::initializer_list(u); } const auto &p = m_from_unicode.find(u); if (p == m_from_unicode.end()) { diff --git a/rwcore/fonts/Unicode.cpp b/rwcore/fonts/Unicode.cpp index 790dd7df..993bad74 100644 --- a/rwcore/fonts/Unicode.cpp +++ b/rwcore/fonts/Unicode.cpp @@ -4,22 +4,22 @@ size_t unicode_to_utf8(unicode_t unicode, char c[4]) { if (unicode < 0x80) { // 7 bits - c[0] = unicode; + c[0] = static_cast(unicode); return 1; } else if (unicode < 0x800) { // 11 bits - c[0] = 0xc0 | (unicode >> 6); - c[1] = 0x80 | (unicode & 0x3f); + c[0] = static_cast(0xc0 | (unicode >> 6)); + c[1] = static_cast(0x80 | (unicode & 0x3f)); return 2; } else if (unicode < 0x10000) { // 16 bits - c[0] = 0xe0 | (unicode >> 12); - c[1] = 0x80 | ((unicode >> 6) & 0x3f); - c[2] = 0x80 | (unicode & 0x3f); + c[0] = static_cast(0xe0 | (unicode >> 12)); + c[1] = static_cast(0x80 | ((unicode >> 6) & 0x3f)); + c[2] = static_cast(0x80 | (unicode & 0x3f)); return 3; } else if (unicode < 0x110000) { // 21 bits - c[0] = 0xf0 | (unicode >> 18); - c[1] = 0x80 | ((unicode >> 12) & 0x3f); - c[2] = 0x80 | ((unicode >> 6) & 0x3f); - c[3] = 0x80 | (unicode & 0x3f); + c[0] = static_cast(0xf0 | (unicode >> 18)); + c[1] = static_cast(0x80 | ((unicode >> 12) & 0x3f)); + c[2] = static_cast(0x80 | ((unicode >> 6) & 0x3f)); + c[3] = static_cast(0x80 | (unicode & 0x3f)); return 4; } else { return unicode_to_utf8(UnicodeValue::UNICODE_REPLACEMENT_CHARACTER, c); diff --git a/rwcore/gl/DrawBuffer.cpp b/rwcore/gl/DrawBuffer.cpp index 346a58dd..b88cb2d5 100644 --- a/rwcore/gl/DrawBuffer.cpp +++ b/rwcore/gl/DrawBuffer.cpp @@ -29,7 +29,7 @@ void DrawBuffer::addGeometry(GeometryBuffer* gbuff) { for (const AttributeIndex& at : gbuff->getDataAttributes()) { GLuint vaoindex = semantic_to_attrib_array[at.sem]; glEnableVertexAttribArray(vaoindex); - glVertexAttribPointer(vaoindex, at.size, at.type, GL_TRUE, at.stride, - reinterpret_cast(at.offset)); + glVertexAttribPointer(vaoindex, static_cast(at.size), at.type, GL_TRUE, at.stride, + reinterpret_cast(at.offset)); } } diff --git a/rwcore/gl/GeometryBuffer.cpp b/rwcore/gl/GeometryBuffer.cpp index 59e02fc4..fc7acbca 100644 --- a/rwcore/gl/GeometryBuffer.cpp +++ b/rwcore/gl/GeometryBuffer.cpp @@ -1,8 +1,5 @@ #include "gl/GeometryBuffer.hpp" -GeometryBuffer::GeometryBuffer() : vbo(0), num(0) { -} - GeometryBuffer::~GeometryBuffer() { if (vbo != 0) { glDeleteBuffers(1, &vbo); diff --git a/rwcore/gl/GeometryBuffer.hpp b/rwcore/gl/GeometryBuffer.hpp index bd7a3f56..b16f898a 100644 --- a/rwcore/gl/GeometryBuffer.hpp +++ b/rwcore/gl/GeometryBuffer.hpp @@ -20,10 +20,10 @@ struct AttributeIndex { AttributeSemantic sem; GLsizei size; GLsizei stride; - GLsizei offset; + size_t offset; GLenum type; - AttributeIndex(AttributeSemantic s, GLsizei sz, GLsizei strd, GLsizei offs, + AttributeIndex(AttributeSemantic s, GLsizei sz, GLsizei strd, size_t offs, GLenum type = GL_FLOAT) : sem(s), size(sz), stride(strd), offset(offs), type(type) { } @@ -35,15 +35,15 @@ typedef std::vector AttributeList; * GeometryBuffer stores a set of vertex attribute data */ class GeometryBuffer { - GLuint vbo; - GLsizei num; + GLuint vbo = 0; + GLsizei num = 0; - AttributeList attributes; + AttributeList attributes{}; public: - GeometryBuffer(); + GeometryBuffer() = default; template - GeometryBuffer(const std::vector& data) : vbo(0), num(0) { + GeometryBuffer(const std::vector& data) { uploadVertices(data); } @@ -65,7 +65,7 @@ public: */ template void uploadVertices(const std::vector& data) { - uploadVertices(data.size(), data.size() * sizeof(T), data.data()); + uploadVertices(static_cast(data.size()), data.size() * sizeof(T), data.data()); // Assume T has a static method for attributes; attributes = T::vertex_attributes(); } diff --git a/rwcore/gl/TextureData.hpp b/rwcore/gl/TextureData.hpp index af96e5ee..467f4f78 100644 --- a/rwcore/gl/TextureData.hpp +++ b/rwcore/gl/TextureData.hpp @@ -2,8 +2,8 @@ #define _LIBRW_TEXTUREDATA_HPP_ #include #include -#include +#include #include #include diff --git a/rwcore/loaders/LoaderDFF.cpp b/rwcore/loaders/LoaderDFF.cpp index e3a040ff..599180b9 100644 --- a/rwcore/loaders/LoaderDFF.cpp +++ b/rwcore/loaders/LoaderDFF.cpp @@ -65,7 +65,7 @@ LoaderDFF::FrameList LoaderDFF::readFrameList(const RWBStream &stream) { FrameList framelist; framelist.reserve(numFrames); - for (size_t f = 0; f < numFrames; ++f) { + for (auto f = 0u; f < numFrames; ++f) { auto data = reinterpret_cast(headerPtr); headerPtr += sizeof(RWBSFrame); auto frame = @@ -259,7 +259,7 @@ GeometryPtr LoaderDFF::readGeometry(const RWBStream &stream) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geom->EBO); size_t icount = std::accumulate( - geom->subgeom.begin(), geom->subgeom.end(), 0u, + geom->subgeom.begin(), geom->subgeom.end(), size_t{0u}, [](size_t a, const SubGeometry &b) { return a + b.numIndices; }); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * icount, nullptr, GL_STATIC_DRAW); diff --git a/rwcore/loaders/LoaderIMG.cpp b/rwcore/loaders/LoaderIMG.cpp index f426c27b..34e73806 100644 --- a/rwcore/loaders/LoaderIMG.cpp +++ b/rwcore/loaders/LoaderIMG.cpp @@ -5,9 +5,6 @@ #include "rw/debug.hpp" -LoaderIMG::LoaderIMG() : m_version(GTAIIIVC), m_assetCount(0) { -} - bool LoaderIMG::load(const rwfs::path& filepath) { auto dirPath = filepath; dirPath.replace_extension(".dir"); @@ -18,12 +15,13 @@ bool LoaderIMG::load(const rwfs::path& filepath) { unsigned long fileSize = ftell(fp); fseek(fp, 0, SEEK_SET); - m_assetCount = fileSize / 32; - m_assets.resize(m_assetCount); + std::size_t expectedCount = fileSize / 32; + m_assets.resize(expectedCount); + std::size_t actualCount = fread(&m_assets[0], sizeof(LoaderIMGFile), + expectedCount, fp); - if ((m_assetCount = fread(&m_assets[0], sizeof(LoaderIMGFile), - m_assetCount, fp)) != fileSize / 32) { - m_assets.resize(m_assetCount); + if (expectedCount != actualCount) { + m_assets.resize(actualCount); RW_ERROR("Error reading records in IMG archive"); } @@ -102,6 +100,6 @@ const LoaderIMGFile& LoaderIMG::getAssetInfoByIndex(size_t index) const { return m_assets[index]; } -uint32_t LoaderIMG::getAssetCount() const { - return m_assetCount; +std::size_t LoaderIMG::getAssetCount() const { + return m_assets.size(); } diff --git a/rwcore/loaders/LoaderIMG.hpp b/rwcore/loaders/LoaderIMG.hpp index bfe70453..e3f45143 100644 --- a/rwcore/loaders/LoaderIMG.hpp +++ b/rwcore/loaders/LoaderIMG.hpp @@ -31,7 +31,7 @@ public: }; /// Construct - LoaderIMG(); + LoaderIMG() = default; /// Load the structure of the archive /// Omit the extension in filename so both .dir and .img are loaded when @@ -52,15 +52,14 @@ public: const LoaderIMGFile& getAssetInfoByIndex(size_t index) const; /// Returns the number of asset files in the archive - uint32_t getAssetCount() const; + std::size_t getAssetCount() const; Version getVersion() const { return m_version; } private: - Version m_version; ///< Version of this IMG archive - uint32_t m_assetCount; ///< Number of assets in the current archive + Version m_version = GTAIIIVC; ///< Version of this IMG archive rwfs::path m_archive; ///< Path to the archive being used (no extension) std::vector m_assets; ///< Asset info of the archive diff --git a/rwcore/loaders/LoaderSDT.cpp b/rwcore/loaders/LoaderSDT.cpp index 8517e67f..0cb42644 100644 --- a/rwcore/loaders/LoaderSDT.cpp +++ b/rwcore/loaders/LoaderSDT.cpp @@ -16,12 +16,14 @@ bool LoaderSDT::load(const rwfs::path& sdtPath, const rwfs::path& rawPath) { unsigned long fileSize = ftell(fp); fseek(fp, 0, SEEK_SET); - m_assetCount = fileSize / 20; - m_assets.resize(m_assetCount); + size_t expectedCount = fileSize / 20; + m_assets.resize(expectedCount); - if ((m_assetCount = fread(&m_assets[0], sizeof(LoaderSDTFile), - m_assetCount, fp)) != fileSize / 20) { - m_assets.resize(m_assetCount); + size_t actualCount = fread(&m_assets[0], sizeof(LoaderSDTFile), + expectedCount, fp); + + if (expectedCount != actualCount) { + m_assets.resize(actualCount); RW_ERROR("Error reading records in SDT archive"); } @@ -118,8 +120,8 @@ const LoaderSDTFile& LoaderSDT::getAssetInfoByIndex(size_t index) const { return m_assets[index]; } -uint32_t LoaderSDT::getAssetCount() const { - return m_assetCount; +size_t LoaderSDT::getAssetCount() const { + return m_assets.size(); } LoaderSDT::Version LoaderSDT::getVersion() const { diff --git a/rwcore/loaders/LoaderSDT.hpp b/rwcore/loaders/LoaderSDT.hpp index 8cd27264..d79c70e2 100644 --- a/rwcore/loaders/LoaderSDT.hpp +++ b/rwcore/loaders/LoaderSDT.hpp @@ -79,13 +79,12 @@ public: const LoaderSDTFile& getAssetInfoByIndex(size_t index) const; /// Returns the number of asset files in the archive - uint32_t getAssetCount() const; + size_t getAssetCount() const; Version getVersion() const; LoaderSDTFile assetInfo{}; private: Version m_version{GTAIIIVC}; ///< Version of this SDT archive - uint32_t m_assetCount{0}; ///< Number of assets in the current archive std::string m_archive; ///< Path to the archive being used (no extension) std::vector m_assets; ///< Asset info of the archive }; diff --git a/rwcore/rw/casts.hpp b/rwcore/rw/casts.hpp index 8bf67a09..1adc35f1 100644 --- a/rwcore/rw/casts.hpp +++ b/rwcore/rw/casts.hpp @@ -9,7 +9,7 @@ //Based on https://gist.github.com/socantre/3472964 template inline Dest bit_cast(Source const &source) { - Dest dest = Dest{}; + Dest dest; std::memcpy(&dest, &source, sizeof(Dest)); return dest; } @@ -18,10 +18,10 @@ template inline T lexical_cast(const S& s); template -inline T lexical_cast(const S& s, size_t base); +inline T lexical_cast(const S& s, int base); template <> -inline int lexical_cast(const std::string& source, size_t base) { +inline int lexical_cast(const std::string& source, int base) { char* end = nullptr; //for errors handling int result = std::strtol(source.c_str(), &end, base); RW_CHECK(end != source.c_str(), "Problem with conversion " << *end << " to int"); From 05896caac589ddc8735eac28c2e3a7dfdd30af94 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 29 Aug 2018 23:43:43 +0200 Subject: [PATCH 02/24] rwengine: fix Visual Studio warnings --- rwengine/src/ai/AIGraph.cpp | 6 +- rwengine/src/ai/CharacterController.cpp | 2 +- rwengine/src/ai/DefaultAIController.cpp | 4 +- rwengine/src/ai/TrafficDirector.cpp | 57 ++++++++----------- rwengine/src/ai/TrafficDirector.hpp | 4 +- rwengine/src/audio/Sound.hpp | 2 +- rwengine/src/audio/SoundBuffer.cpp | 3 +- rwengine/src/audio/SoundManager.cpp | 2 +- rwengine/src/audio/SoundSource.cpp | 2 +- rwengine/src/audio/SoundSource.hpp | 10 ++-- rwengine/src/data/Chase.cpp | 2 +- rwengine/src/data/VehicleGenerator.hpp | 2 +- rwengine/src/dynamics/CollisionInstance.cpp | 9 ++- rwengine/src/engine/GameWorld.cpp | 8 +-- rwengine/src/engine/Garage.cpp | 4 +- rwengine/src/engine/Garage.hpp | 8 +-- rwengine/src/engine/Payphone.cpp | 2 +- rwengine/src/engine/Payphone.hpp | 6 +- rwengine/src/engine/ScreenText.cpp | 2 +- rwengine/src/items/Weapon.cpp | 2 +- rwengine/src/objects/PickupObject.cpp | 6 +- rwengine/src/objects/PickupObject.hpp | 2 +- rwengine/src/objects/ProjectileObject.cpp | 2 +- rwengine/src/objects/VehicleObject.cpp | 4 +- rwengine/src/render/GameRenderer.cpp | 14 ++--- rwengine/src/render/ObjectRenderer.cpp | 4 +- rwengine/src/render/OpenGLRenderer.cpp | 5 +- rwengine/src/render/OpenGLRenderer.hpp | 2 +- rwengine/src/render/TextRenderer.cpp | 8 +-- rwengine/src/render/ViewFrustum.hpp | 4 +- rwengine/src/render/WaterRenderer.cpp | 10 ++-- rwengine/src/script/SCMFile.cpp | 2 +- rwengine/src/script/SCMFile.hpp | 2 +- rwengine/src/script/ScriptMachine.cpp | 2 +- rwengine/src/script/ScriptMachine.hpp | 5 +- rwengine/src/script/ScriptTypes.hpp | 2 +- .../src/script/modules/GTA3ModuleImpl.inl | 6 +- 37 files changed, 108 insertions(+), 109 deletions(-) diff --git a/rwengine/src/ai/AIGraph.cpp b/rwengine/src/ai/AIGraph.cpp index 730b4e22..63f911d4 100644 --- a/rwengine/src/ai/AIGraph.cpp +++ b/rwengine/src/ai/AIGraph.cpp @@ -19,11 +19,11 @@ AIGraph::~AIGraph() { void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotation, PathData& path) { - size_t startIndex = nodes.size(); + auto startIndex = static_cast(nodes.size()); std::vector pathNodes; pathNodes.reserve(path.nodes.size()); - for (size_t n = 0; n < path.nodes.size(); ++n) { + for (auto n = 0u; n < path.nodes.size(); ++n) { auto& node = path.nodes[n]; AIGraphNode* ainode = nullptr; glm::vec3 nodePosition = position + (rotation * node.position); @@ -71,7 +71,7 @@ void AIGraph::createPathNodes(const glm::vec3& position, RW_MESSAGE("Warning: Node outside of grid at coord " << gridcoord.x << " " << gridcoord.y); } - auto index = (gridcoord.x * WORLD_GRID_WIDTH) + gridcoord.y; + auto index = static_cast((gridcoord.x * WORLD_GRID_WIDTH) + gridcoord.y); gridNodes[index].push_back(ainode); } } diff --git a/rwengine/src/ai/CharacterController.cpp b/rwengine/src/ai/CharacterController.cpp index 395f25f7..3875c2db 100644 --- a/rwengine/src/ai/CharacterController.cpp +++ b/rwengine/src/ai/CharacterController.cpp @@ -336,7 +336,7 @@ bool Activities::DriveTo::update(CharacterObject *character, // Choose the next node randomly if(nextTargetNode == nullptr) { auto& random = character->engine->randomEngine; - int i = std::uniform_int_distribution<>(0, potentialNodes.size() - 1)(random); + auto i = std::uniform_int_distribution(0, potentialNodes.size() - 1)(random); nextTargetNode = potentialNodes.at(i); } diff --git a/rwengine/src/ai/DefaultAIController.cpp b/rwengine/src/ai/DefaultAIController.cpp index 33e55bb7..b4543093 100644 --- a/rwengine/src/ai/DefaultAIController.cpp +++ b/rwengine/src/ai/DefaultAIController.cpp @@ -67,7 +67,7 @@ void DefaultAIController::update(float dt) { auto lastTarget = targetNode; std::random_device rd; std::default_random_engine re(rd()); - std::uniform_int_distribution<> d( + std::uniform_int_distribution d( 0, lastTarget->connections.size() - 1); targetNode = lastTarget->connections.at(d(re)); setNextActivity(std::make_unique( @@ -156,7 +156,7 @@ void DefaultAIController::update(float dt) { // If we haven't found a node, choose one randomly if (!targetNode) { auto& random = getCharacter()->engine->randomEngine; - int nodeIndex = std::uniform_int_distribution<>(0, lastTargetNode->connections.size() - 1)(random); + size_t nodeIndex = std::uniform_int_distribution(0, lastTargetNode->connections.size() - 1)(random); targetNode = lastTargetNode->connections.at(nodeIndex); } diff --git a/rwengine/src/ai/TrafficDirector.cpp b/rwengine/src/ai/TrafficDirector.cpp index 4cee0a92..636d3956 100644 --- a/rwengine/src/ai/TrafficDirector.cpp +++ b/rwengine/src/ai/TrafficDirector.cpp @@ -97,12 +97,6 @@ std::vector TrafficDirector::populateNearby( auto& random = world->randomEngine; std::vector created; - int availablePeds = - maximumPedestrians - world->pedestrianPool.objects.size(); - - int availableCars = - maximumCars - world->vehiclePool.objects.size(); - /// @todo Check how "in player view" should be determined. // Don't check the frustum for things more than 1/2 of the radius away @@ -154,30 +148,30 @@ std::vector TrafficDirector::populateNearby( auto availablePedsNodes = findAvailableNodes(AIGraphNode::Pedestrian, camera, radius); // We have not reached the limit of spawned pedestrians - if (availablePeds > 0) { - int counter = availablePeds; + if (maximumPedestrians > world->pedestrianPool.objects.size()) { + const auto availablePeds = maximumPedestrians - world->pedestrianPool.objects.size(); + static const glm::vec3 kSpawnOffset{0.f, 0.f, 1.f}; + + size_t counter = availablePeds; // maxSpawn can be -1 for "as many as possible" if (maxSpawn > -1) { - counter = std::min(availablePeds, maxSpawn); + counter = std::min(availablePeds, static_cast(maxSpawn)); } for (AIGraphNode* spawn : availablePedsNodes) { if (spawn->type != AIGraphNode::Pedestrian) { continue; } - - if (counter > -1) { - if (counter <= 0) { - break; - } - counter--; + if (counter == 0) { + break; } + counter--; // Spawn a pedestrian from the available pool - const uint16_t pedId = peds[std::uniform_int_distribution<>( - 0, peds.size() - 1)(random)]; - auto ped = world->createPedestrian(pedId, spawn->position); - ped->applyOffset(); + const auto pedId = static_cast( + peds[std::uniform_int_distribution(0, peds.size() - 1)(random)]); + auto ped = world->createPedestrian(pedId, + spawn->position + kSpawnOffset); ped->setLifetime(GameObject::TrafficLifetime); ped->controller->setGoal(CharacterController::TrafficWander); created.push_back(ped); @@ -187,25 +181,24 @@ std::vector TrafficDirector::populateNearby( auto availableVehicleNodes = findAvailableNodes(AIGraphNode::Vehicle, camera, radius); // We have not reached the limit of spawned vehicles - if (availableCars > 0) { - int counter = availableCars; + if (maximumCars > world->vehiclePool.objects.size()) { + const auto availableCars = maximumCars - world->vehiclePool.objects.size(); + static const glm::vec3 kSpawnOffset{0.f, 0.f, 1.f}; + + size_t counter = availableCars; // maxSpawn can be -1 for "as many as possible" if (maxSpawn > -1) { - counter = std::min(availableCars, maxSpawn); + counter = std::min(availableCars, static_cast(maxSpawn)); } - for (AIGraphNode* spawn : availableVehicleNodes) { if (spawn->type != AIGraphNode::Vehicle) { continue; } - - if (counter > -1) { - if (counter <= 0) { - break; - } - counter--; + if (counter == 0) { + break; } + counter--; // Get the next node, to spawn in between AIGraphNode* next = spawn->connections.at(0); @@ -243,15 +236,15 @@ std::vector TrafficDirector::populateNearby( strafe * (2.5f + 5.f * static_cast(lane - 1)); // Spawn a vehicle from the available pool - const uint16_t carId = cars[std::uniform_int_distribution<>( - 0, cars.size() - 1)(random)]; + const auto carId = static_cast(cars[std::uniform_int_distribution( + 0, cars.size() - 1)(random)]); auto vehicle = world->createVehicle(carId, next->position + diff + laneOffset, orientation); vehicle->applyOffset(); vehicle->setLifetime(GameObject::TrafficLifetime); vehicle->setHandbraking(false); // Spawn a pedestrian and put it into the vehicle - int pedId = peds[std::uniform_int_distribution<>(0, peds.size() - 1)(random)]; + const auto pedId = peds[std::uniform_int_distribution(0, peds.size() - 1)(random)]; CharacterObject* character = world->createPedestrian(pedId, vehicle->getPosition()); character->setLifetime(GameObject::TrafficLifetime); character->setCurrentVehicle(vehicle, 0); diff --git a/rwengine/src/ai/TrafficDirector.hpp b/rwengine/src/ai/TrafficDirector.hpp index 76982289..db967ed8 100644 --- a/rwengine/src/ai/TrafficDirector.hpp +++ b/rwengine/src/ai/TrafficDirector.hpp @@ -39,8 +39,8 @@ private: GameWorld* world = nullptr; float pedDensity = 1.f; float carDensity = 1.f; - int maximumPedestrians = 20; - int maximumCars = 10; + size_t maximumPedestrians = 20; + size_t maximumCars = 10; }; #endif diff --git a/rwengine/src/audio/Sound.hpp b/rwengine/src/audio/Sound.hpp index 6fc05ac4..c5669488 100644 --- a/rwengine/src/audio/Sound.hpp +++ b/rwengine/src/audio/Sound.hpp @@ -70,7 +70,7 @@ struct Sound { buffer->setMaxDistance(maxDist); } - int getScriptObjectID() const { + size_t getScriptObjectID() const { return id; } }; diff --git a/rwengine/src/audio/SoundBuffer.cpp b/rwengine/src/audio/SoundBuffer.cpp index 2961d4d6..80f93843 100644 --- a/rwengine/src/audio/SoundBuffer.cpp +++ b/rwengine/src/audio/SoundBuffer.cpp @@ -24,7 +24,8 @@ bool SoundBuffer::bufferData(SoundSource& soundSource) { alCheck(alBufferData( buffer, soundSource.channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, - &soundSource.data.front(), soundSource.data.size() * sizeof(int16_t), + &soundSource.data.front(), + static_cast(soundSource.data.size() * sizeof(int16_t)), soundSource.sampleRate)); alCheck(alSourcei(source, AL_BUFFER, buffer)); diff --git a/rwengine/src/audio/SoundManager.cpp b/rwengine/src/audio/SoundManager.cpp index d0966093..4abf7b6c 100644 --- a/rwengine/src/audio/SoundManager.cpp +++ b/rwengine/src/audio/SoundManager.cpp @@ -226,7 +226,7 @@ void SoundManager::playSfx(size_t name, const glm::vec3& position, bool looping, buffer->second.setPitch(1.f); buffer->second.setGain(1.f); if (maxDist != -1) { - buffer->second.setMaxDistance(maxDist); + buffer->second.setMaxDistance(static_cast(maxDist)); } buffer->second.play(); } diff --git a/rwengine/src/audio/SoundSource.cpp b/rwengine/src/audio/SoundSource.cpp index dedfec30..804287e3 100644 --- a/rwengine/src/audio/SoundSource.cpp +++ b/rwengine/src/audio/SoundSource.cpp @@ -248,7 +248,7 @@ struct InputData { /// to buffer. static int read_packet(void* opaque, uint8_t* buf, int buf_size) { auto* input = reinterpret_cast(opaque); - buf_size = FFMIN(buf_size, input->size); + buf_size = std::min(buf_size, static_cast(input->size)); /* copy internal data to buf */ memcpy(buf, input->ptr, buf_size); input->ptr += buf_size; diff --git a/rwengine/src/audio/SoundSource.hpp b/rwengine/src/audio/SoundSource.hpp index c007a353..7f3334b5 100644 --- a/rwengine/src/audio/SoundSource.hpp +++ b/rwengine/src/audio/SoundSource.hpp @@ -1,8 +1,10 @@ #ifndef _RWENGINE_SOUND_SOURCE_HPP_ #define _RWENGINE_SOUND_SOURCE_HPP_ -#include #include +#include + +#include /// Opaque for raw sound, /// cooperate with ffmpeg @@ -16,14 +18,14 @@ public: void loadFromFile(const rwfs::path& filePath); /// Load sound from sdt file - void loadSfx(LoaderSDT& sdt, size_t index, bool asWave = true); + void loadSfx(LoaderSDT& sdt, std::size_t index, bool asWave = true); private: /// Raw data std::vector data; - size_t channels; - size_t sampleRate; + std::uint32_t channels; + std::uint32_t sampleRate; }; #endif diff --git a/rwengine/src/data/Chase.cpp b/rwengine/src/data/Chase.cpp index 8815966a..5d1dd9ee 100644 --- a/rwengine/src/data/Chase.cpp +++ b/rwengine/src/data/Chase.cpp @@ -96,7 +96,7 @@ void ChaseCoordinator::start() { void ChaseCoordinator::update(float dt) { chaseTime += dt; - size_t frameNum = chaseTime * KEYFRAMES_PER_SECOND; + auto frameNum = static_cast(chaseTime * KEYFRAMES_PER_SECOND); for (auto &it : chaseVehicles) { RW_CHECK(frameNum < it.second.keyframes.size(), "Vehicle out of chase keyframes"); diff --git a/rwengine/src/data/VehicleGenerator.hpp b/rwengine/src/data/VehicleGenerator.hpp index 4f600e46..a969e743 100644 --- a/rwengine/src/data/VehicleGenerator.hpp +++ b/rwengine/src/data/VehicleGenerator.hpp @@ -53,7 +53,7 @@ struct VehicleGenerator { , remainingSpawns(remainingSpawns_) { } - int getScriptObjectID() const { + size_t getScriptObjectID() const { return generatorID; } }; diff --git a/rwengine/src/dynamics/CollisionInstance.cpp b/rwengine/src/dynamics/CollisionInstance.cpp index 7edcb44c..3fcc22dc 100644 --- a/rwengine/src/dynamics/CollisionInstance.cpp +++ b/rwengine/src/dynamics/CollisionInstance.cpp @@ -95,9 +95,12 @@ bool CollisionInstance::createPhysicsBody(GameObject* object, auto& faces = collision->faces; if (!verts.empty() && !faces.empty()) { m_vertArray = std::make_unique( - faces.size(), reinterpret_cast(faces.data()), - sizeof(CollisionModel::Triangle), verts.size(), - reinterpret_cast(verts.data()), sizeof(glm::vec3)); + static_cast(faces.size()), + reinterpret_cast(faces.data()), + static_cast(sizeof(CollisionModel::Triangle)), + static_cast(verts.size()), + reinterpret_cast(verts.data()), + static_cast(sizeof(glm::vec3))); auto trishape = std::make_unique(m_vertArray.get(), false); trishape->setMargin(0.05f); diff --git a/rwengine/src/engine/GameWorld.cpp b/rwengine/src/engine/GameWorld.cpp index 4c02c163..4abe33e2 100644 --- a/rwengine/src/engine/GameWorld.cpp +++ b/rwengine/src/engine/GameWorld.cpp @@ -224,8 +224,8 @@ VehicleObject* GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos, auto palit = data->vehiclePalettes.find( vti->name); // modelname is conveniently lowercase (usually) if (palit != data->vehiclePalettes.end() && !palit->second.empty()) { - std::uniform_int_distribution uniform(0, palit->second.size() - 1); - int set = uniform(randomEngine); + std::uniform_int_distribution uniform(0, palit->second.size() - 1); + size_t set = uniform(randomEngine); prim = data->vehicleColours[palit->second[set].first]; sec = data->vehicleColours[palit->second[set].second]; } else { @@ -394,13 +394,13 @@ PickupObject* GameWorld::createPickup(const glm::vec3& pos, int id, int type) { Garage* GameWorld::createGarage(const glm::vec3 coord0, const glm::vec3 coord1, Garage::Type type) { - const int id = garages.size(); + const size_t id = garages.size(); garages.emplace_back(std::make_unique(this, id, coord0, coord1, type)); return garages.back().get(); } Payphone* GameWorld::createPayphone(const glm::vec2 coord) { - int id = payphones.size(); + const size_t id = payphones.size(); payphones.emplace_back(std::make_unique(this, id, coord)); return payphones.back().get(); } diff --git a/rwengine/src/engine/Garage.cpp b/rwengine/src/engine/Garage.cpp index 097c3676..13088e89 100644 --- a/rwengine/src/engine/Garage.cpp +++ b/rwengine/src/engine/Garage.cpp @@ -14,8 +14,8 @@ #include "objects/InstanceObject.hpp" #include "objects/VehicleObject.hpp" -Garage::Garage(GameWorld* engine_, const int id_, const glm::vec3 coord0, - const glm::vec3 coord1, const Type type_) +Garage::Garage(GameWorld* engine_, size_t id_, glm::vec3 coord0, + glm::vec3 coord1, Type type_) : engine(engine_), id(id_), type(type_) { min.x = std::min(coord0.x, coord1.x); min.y = std::min(coord0.y, coord1.y); diff --git a/rwengine/src/engine/Garage.hpp b/rwengine/src/engine/Garage.hpp index 1cfc263a..38b0b86c 100644 --- a/rwengine/src/engine/Garage.hpp +++ b/rwengine/src/engine/Garage.hpp @@ -72,9 +72,9 @@ public: enum class State { Closed, Closing, Opening, Opened }; GameWorld* engine; - int id; + size_t id; - int getScriptObjectID() const { + size_t getScriptObjectID() const { return id; } @@ -91,8 +91,8 @@ public: bool resprayDone = false; - Garage(GameWorld* engine_, const int id_, const glm::vec3 coord0, - const glm::vec3 coord1, const Type type_); + Garage(GameWorld* engine_, size_t id_, glm::vec3 coord0, + glm::vec3 coord1, Type type_); ~Garage() = default; void makeDoorSwing(); diff --git a/rwengine/src/engine/Payphone.cpp b/rwengine/src/engine/Payphone.cpp index f78d194f..4215566b 100644 --- a/rwengine/src/engine/Payphone.cpp +++ b/rwengine/src/engine/Payphone.cpp @@ -11,7 +11,7 @@ #include "objects/GameObject.hpp" #include "objects/InstanceObject.hpp" -Payphone::Payphone(GameWorld* engine_, const int id_, const glm::vec2 coord) +Payphone::Payphone(GameWorld* engine_, size_t id_, glm::vec2 coord) : engine(engine_), id(id_) { // Find payphone object, original game does this differently for (const auto& p : engine->instancePool.objects) { diff --git a/rwengine/src/engine/Payphone.hpp b/rwengine/src/engine/Payphone.hpp index bf243af8..7dc6d190 100644 --- a/rwengine/src/engine/Payphone.hpp +++ b/rwengine/src/engine/Payphone.hpp @@ -26,13 +26,13 @@ public: State state = State::Idle; - int id; + size_t id; - int getScriptObjectID() const { + size_t getScriptObjectID() const { return id; } - Payphone(GameWorld* engine_, const int id_, const glm::vec2 coord); + Payphone(GameWorld* engine_, size_t id_, glm::vec2 coord); ~Payphone() = default; // Makes a payphone ring diff --git a/rwengine/src/engine/ScreenText.cpp b/rwengine/src/engine/ScreenText.cpp index 84712892..be8cf122 100644 --- a/rwengine/src/engine/ScreenText.cpp +++ b/rwengine/src/engine/ScreenText.cpp @@ -5,7 +5,7 @@ #include "fonts/FontMapGta3.hpp" void ScreenText::tick(float dt) { - int millis = dt * 1000; + int millis = static_cast(dt * 1000); // Remove all the immedate text m_textQueues[static_cast(ScreenTextType::Immediate)].clear(); diff --git a/rwengine/src/items/Weapon.cpp b/rwengine/src/items/Weapon.cpp index bab82d53..4b9768fa 100644 --- a/rwengine/src/items/Weapon.cpp +++ b/rwengine/src/items/Weapon.cpp @@ -16,7 +16,7 @@ void Weapon::fireHitscan(WeaponData* weapon, CharacterObject* owner) { const auto& raydirection = owner->getLookDirection(); const auto rayend = owner->getPosition() + raydirection * weapon->hitRange; auto fireOrigin = glm::vec3(handMatrix[3]); - float dmg = weapon->damage; + float dmg = static_cast(weapon->damage); owner->engine->doWeaponScan({dmg, fireOrigin, rayend, weapon}); } diff --git a/rwengine/src/objects/PickupObject.cpp b/rwengine/src/objects/PickupObject.cpp index 6b3229bc..babafa00 100644 --- a/rwengine/src/objects/PickupObject.cpp +++ b/rwengine/src/objects/PickupObject.cpp @@ -191,9 +191,9 @@ void PickupObject::tick(float dt) { float time = engine->getGameTime(); float colourValue = 0.5f * (std::sin(time * 3.0664064f) * 0.3f + 0.3f); uint32_t* colour = &colours[m_colourId]; - float red = (*colour >> 16) & 0xFF; - float green = (*colour >> 8) & 0xFF; - float blue = *colour & 0xFF; + float red = static_cast((*colour >> 16) & 0xFF); + float green = static_cast((*colour >> 8) & 0xFF); + float blue = static_cast(*colour & 0xFF); m_corona.colour = glm::vec4(red / 255.f, green / 255.f, blue / 255.f, 1.f) * colourValue; diff --git a/rwengine/src/objects/PickupObject.hpp b/rwengine/src/objects/PickupObject.hpp index 38a7bbaf..dabc4368 100644 --- a/rwengine/src/objects/PickupObject.hpp +++ b/rwengine/src/objects/PickupObject.hpp @@ -17,7 +17,7 @@ class BaseModelInfo; class GameWorld; class CharacterObject; class VehicleObject; -class VisualFX; +struct VisualFX; /** * @brief The PickupObject class diff --git a/rwengine/src/objects/ProjectileObject.cpp b/rwengine/src/objects/ProjectileObject.cpp index b147e8ed..4b0d504c 100644 --- a/rwengine/src/objects/ProjectileObject.cpp +++ b/rwengine/src/objects/ProjectileObject.cpp @@ -55,7 +55,7 @@ void ProjectileObject::explode() { const float exp_size = 10.f; const float damageSize = 5.f; - const float damage = _info.weapon->damage; + const float damage = static_cast(_info.weapon->damage); for (auto& o : engine->allObjects) { if (o == this) continue; diff --git a/rwengine/src/objects/VehicleObject.cpp b/rwengine/src/objects/VehicleObject.cpp index 6f363acc..74bdba8d 100644 --- a/rwengine/src/objects/VehicleObject.cpp +++ b/rwengine/src/objects/VehicleObject.cpp @@ -1042,7 +1042,7 @@ float VehicleObject::isInFront(const glm::vec3& point) { normal = glm::normalize(normal); const glm::vec3 vecTemp(testPoint.x - v1.x, 0, testPoint.y - v1.y); - double distance = glm::dot(vecTemp, normal); + float distance = glm::dot(vecTemp, normal); return distance; } @@ -1073,7 +1073,7 @@ float VehicleObject::isOnSide(const glm::vec3& point) { normal = glm::normalize(normal); const glm::vec3 vecTemp(testPoint.x - v1.x, 0, testPoint.y - v1.y); - double distance = glm::dot(vecTemp, normal); + float distance = glm::dot(vecTemp, normal); return distance; } diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index cd0d8ce9..fe9ed972 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -144,12 +144,12 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data) skydomeIndBuff.resize(rows * segments * 6); for (size_t r = 0, i = 0; r < (rows - 1); ++r) { for (size_t s = 0; s < (segments - 1); ++s) { - skydomeIndBuff[i++] = r * segments + s; - skydomeIndBuff[i++] = r * segments + (s + 1); - skydomeIndBuff[i++] = (r + 1) * segments + (s + 1); - skydomeIndBuff[i++] = r * segments + s; - skydomeIndBuff[i++] = (r + 1) * segments + (s + 1); - skydomeIndBuff[i++] = (r + 1) * segments + s; + skydomeIndBuff[i++] = static_cast(r * segments + s); + skydomeIndBuff[i++] = static_cast(r * segments + (s + 1)); + skydomeIndBuff[i++] = static_cast((r + 1) * segments + (s + 1)); + skydomeIndBuff[i++] = static_cast(r * segments + s); + skydomeIndBuff[i++] = static_cast((r + 1) * segments + (s + 1)); + skydomeIndBuff[i++] = static_cast((r + 1) * segments + s); } } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skydomeIBO); @@ -325,7 +325,7 @@ RenderList GameRenderer::createObjectRenderList(const GameWorld *world) { // run in parallel with a good threading system. RenderList renderList; // Naive optimisation, assume 50% hitrate - renderList.reserve(world->allObjects.size() * 0.5f); + renderList.reserve(static_cast(world->allObjects.size() * 0.5f)); ObjectRenderer objectRenderer(_renderWorld, (cullOverride ? cullingCamera : _camera), diff --git a/rwengine/src/render/ObjectRenderer.cpp b/rwengine/src/render/ObjectRenderer.cpp index 4abc2d69..3c804052 100644 --- a/rwengine/src/render/ObjectRenderer.cpp +++ b/rwengine/src/render/ObjectRenderer.cpp @@ -277,9 +277,9 @@ void ObjectRenderer::renderVehicle(VehicleObject* vehicle, auto wheelatomic = woi->getDistanceAtomic(mindist); for (size_t w = 0; w < vehicle->info->wheels.size(); ++w) { - auto& wi = vehicle->physVehicle->getWheelInfo(w); + auto& wi = vehicle->physVehicle->getWheelInfo(static_cast(w)); // Construct our own matrix so we can use the local transform - vehicle->physVehicle->updateWheelTransform(w, false); + vehicle->physVehicle->updateWheelTransform(static_cast(w), false); bool isRhino = (vehicle->getVehicle()->vehiclename_ == "RHINO"); auto up = -wi.m_wheelDirectionCS; diff --git a/rwengine/src/render/OpenGLRenderer.cpp b/rwengine/src/render/OpenGLRenderer.cpp index c4942508..550bdc42 100644 --- a/rwengine/src/render/OpenGLRenderer.cpp +++ b/rwengine/src/render/OpenGLRenderer.cpp @@ -299,7 +299,8 @@ void OpenGLRenderer::draw(const glm::mat4& model, DrawBuffer* draw, const Renderer::DrawParameters& p) { setDrawState(model, draw, p); - glDrawElements(draw->getFaceType(), p.count, GL_UNSIGNED_INT, + glDrawElements(draw->getFaceType(), static_cast(p.count), + GL_UNSIGNED_INT, reinterpret_cast(sizeof(RenderIndex) * p.start)); } @@ -307,7 +308,7 @@ void OpenGLRenderer::drawArrays(const glm::mat4& model, DrawBuffer* draw, const Renderer::DrawParameters& p) { setDrawState(model, draw, p); - glDrawArrays(draw->getFaceType(), p.start, p.count); + glDrawArrays(draw->getFaceType(), static_cast(p.start), static_cast(p.count)); } void OpenGLRenderer::drawBatched(const RenderList& list) { diff --git a/rwengine/src/render/OpenGLRenderer.hpp b/rwengine/src/render/OpenGLRenderer.hpp index ce7a36b8..8b2faaff 100644 --- a/rwengine/src/render/OpenGLRenderer.hpp +++ b/rwengine/src/render/OpenGLRenderer.hpp @@ -85,7 +85,7 @@ public: /// Number of indices size_t count{}; /// Start index. - unsigned int start{}; + size_t start{}; /// Textures to use Textures textures{}; /// Blending mode diff --git a/rwengine/src/render/TextRenderer.cpp b/rwengine/src/render/TextRenderer.cpp index 49e911d4..6e8378bb 100644 --- a/rwengine/src/render/TextRenderer.cpp +++ b/rwengine/src/render/TextRenderer.cpp @@ -20,10 +20,10 @@ unsigned charToIndex(std::uint16_t g) { return g - 32; } -glm::vec4 indexToTexCoord(int index, const glm::u32vec2 &textureSize, const glm::u8vec2 &glyphOffset) { +static glm::vec4 indexToTexCoord(size_t index, const glm::u32vec2 &textureSize, const glm::u8vec2 &glyphOffset) { constexpr unsigned TEXTURE_COLUMNS = 16; - const float x = index % TEXTURE_COLUMNS; - const float y = index / TEXTURE_COLUMNS; + const float x = static_cast(index % TEXTURE_COLUMNS); + const float y = static_cast(index / TEXTURE_COLUMNS); // Add offset to avoid 'leakage' between adjacent glyphs float s = (x * glyphOffset.x + 0.5f) / textureSize.x; float t = (y * glyphOffset.y + 0.5f) / textureSize.y; @@ -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), - [](char x) { return std::isspace(x); }); + [](GameStringChar c) { return std::isspace(c); }); if (wend != std::end(text)) { auto word = std::distance(std::begin(text) + i, wend); if (lineLength + word >= ti.wrapX) { diff --git a/rwengine/src/render/ViewFrustum.hpp b/rwengine/src/render/ViewFrustum.hpp index 0bb4aa41..f3345dfa 100644 --- a/rwengine/src/render/ViewFrustum.hpp +++ b/rwengine/src/render/ViewFrustum.hpp @@ -32,9 +32,9 @@ public: } void update(const glm::mat4& proj) { - for (size_t i = 0; i < 6; ++i) { + for (auto i = 0u; i < 6; ++i) { float sign = (i % 2 == 0) ? 1.f : -1.f; - int r = i / 2; + auto r = i / 2; planes[i].normal.x = proj[0][3] + proj[0][r] * sign; planes[i].normal.y = proj[1][3] + proj[1][r] * sign; planes[i].normal.z = proj[2][3] + proj[2][r] * sign; diff --git a/rwengine/src/render/WaterRenderer.cpp b/rwengine/src/render/WaterRenderer.cpp index 3072e345..0992f7b7 100644 --- a/rwengine/src/render/WaterRenderer.cpp +++ b/rwengine/src/render/WaterRenderer.cpp @@ -49,7 +49,7 @@ WaterRenderer::WaterRenderer(GameRenderer* renderer) { } } - gridGeom.uploadVertices(grid.size(), sizeof(glm::vec2) * grid.size(), + gridGeom.uploadVertices(static_cast(grid.size()), sizeof(glm::vec2) * grid.size(), grid.data()); gridGeom.getDataAttributes().emplace_back(ATRS_Position, 2, 0, 0, GL_FLOAT); gridDraw.addGeometry(&gridGeom); @@ -58,15 +58,15 @@ WaterRenderer::WaterRenderer(GameRenderer* renderer) { void WaterRenderer::setWaterTable(const float* waterHeights, const unsigned int nHeights, const uint8_t* tiles, const unsigned int nTiles) { // Determine the dimensions of the input tiles - int edgeNum = sqrt(nTiles); + auto edgeNum = static_cast(sqrt(nTiles)); float tileSize = WATER_WORLD_SIZE / edgeNum; glm::vec2 wO{-WATER_WORLD_SIZE / 2.f, -WATER_WORLD_SIZE / 2.f}; std::vector vertexData; - for (int x = 0; x < edgeNum; x++) { + for (auto x = 0u; x < edgeNum; x++) { int xi = x * WATER_HQ_DATA_SIZE; - for (int y = 0; y < edgeNum; y++) { + for (auto y = 0u; y < edgeNum; y++) { if (tiles[xi + y] >= nHeights) continue; // Tiles with the magic value contain no water. @@ -87,7 +87,7 @@ void WaterRenderer::setWaterTable(const float* waterHeights, const unsigned int } } - maskGeom.uploadVertices(vertexData.size(), + maskGeom.uploadVertices(static_cast(vertexData.size()), sizeof(glm::vec3) * vertexData.size(), vertexData.data()); maskGeom.getDataAttributes().emplace_back(ATRS_Position, 3, 0, 0, GL_FLOAT); diff --git a/rwengine/src/script/SCMFile.cpp b/rwengine/src/script/SCMFile.cpp index 7ffb025b..04fafd19 100644 --- a/rwengine/src/script/SCMFile.cpp +++ b/rwengine/src/script/SCMFile.cpp @@ -3,7 +3,7 @@ #include #include -void SCMFile::loadFile(char *data, unsigned int size) { +void SCMFile::loadFile(char *data, size_t size) { _data = std::make_unique(size); std::copy(data, data + size, _data.get()); diff --git a/rwengine/src/script/SCMFile.hpp b/rwengine/src/script/SCMFile.hpp index 29d22cf8..dc711b3b 100644 --- a/rwengine/src/script/SCMFile.hpp +++ b/rwengine/src/script/SCMFile.hpp @@ -29,7 +29,7 @@ public: return _data.get(); } - void loadFile(char* data, unsigned int size); + void loadFile(char* data, size_t size); SCMByte* data() const { return _data.get(); diff --git a/rwengine/src/script/ScriptMachine.cpp b/rwengine/src/script/ScriptMachine.cpp index 10c029b8..3b4b9d9b 100644 --- a/rwengine/src/script/ScriptMachine.cpp +++ b/rwengine/src/script/ScriptMachine.cpp @@ -228,7 +228,7 @@ SCMByte* ScriptMachine::getGlobals() { void ScriptMachine::execute(float dt) { RW_PROFILE_SCOPEC(__func__, MP_ORANGERED); - int ms = dt * 1000.f; + int ms = static_cast(dt * 1000.f); for (auto t = _activeThreads.begin(); t != _activeThreads.end(); ++t) { auto& thread = *t; executeThread(thread, ms); diff --git a/rwengine/src/script/ScriptMachine.hpp b/rwengine/src/script/ScriptMachine.hpp index 91027d10..cd1c4c08 100644 --- a/rwengine/src/script/ScriptMachine.hpp +++ b/rwengine/src/script/ScriptMachine.hpp @@ -167,15 +167,14 @@ public: template typename std::enable_if::value, T>::type getRandomNumber(T min, T max) { - std::uniform_int_distribution<> dist(min, max); + std::uniform_int_distribution dist(min, max); return dist(randomNumberGen); } template typename std::enable_if::value, T>::type getRandomNumber(T min, T max) { - std::uniform_real_distribution<> dist(static_cast(min), - static_cast(max)); + std::uniform_real_distribution dist(min, max); return dist(randomNumberGen); } diff --git a/rwengine/src/script/ScriptTypes.hpp b/rwengine/src/script/ScriptTypes.hpp index c2d25a2f..0225d754 100644 --- a/rwengine/src/script/ScriptTypes.hpp +++ b/rwengine/src/script/ScriptTypes.hpp @@ -77,7 +77,7 @@ struct ScriptObjectType { T* operator=(T* object) { RW_CHECK(m_id != nullptr, "ScriptObjectType has pointer to null memory location"); - *m_id = object->getScriptObjectID(); + *m_id = static_cast(object->getScriptObjectID()); m_object = object; return object; } diff --git a/rwengine/src/script/modules/GTA3ModuleImpl.inl b/rwengine/src/script/modules/GTA3ModuleImpl.inl index 78136b2a..7bdd2a85 100644 --- a/rwengine/src/script/modules/GTA3ModuleImpl.inl +++ b/rwengine/src/script/modules/GTA3ModuleImpl.inl @@ -5456,7 +5456,7 @@ void opcode_01e8(const ScriptArguments& args, ScriptVec3 coord0, ScriptVec3 coor void opcode_01e9(const ScriptArguments& args, const ScriptVehicle vehicle, ScriptInt& numOfPassengers) { RW_UNUSED(args); - numOfPassengers = vehicle->seatOccupants.size(); + numOfPassengers = static_cast(vehicle->seatOccupants.size()); } /** @@ -5469,7 +5469,7 @@ void opcode_01e9(const ScriptArguments& args, const ScriptVehicle vehicle, void opcode_01ea(const ScriptArguments& args, const ScriptVehicle vehicle, ScriptInt& maxNumOfPassengers) { RW_UNUSED(args); - maxNumOfPassengers = vehicle->info->seats.size(); + maxNumOfPassengers = static_cast(vehicle->info->seats.size()); } /** @@ -7740,7 +7740,7 @@ void opcode_02dd(const ScriptArguments& args, const ScriptString areaName, Scrip } // Only return a result if we found a character - unsigned int candidateCount = candidates.size(); + const auto candidateCount = candidates.size(); if (candidateCount > 0) { // Return the handle for any random character in this zone and use lifetime for use by script // @todo verify if the lifetime is actually changed in the original game From 2a1163d391c285fbc96f977eed0f7b1ddcb0296a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 02:02:02 +0200 Subject: [PATCH 03/24] rwgame: fix Visual Studio warnings --- rwengine/src/render/TextRenderer.cpp | 2 +- rwgame/DrawUI.cpp | 16 ++++++++-------- rwgame/GameConfig.cpp | 6 ++++-- rwgame/GameWindow.cpp | 2 +- rwgame/MenuSystem.hpp | 4 ++-- rwgame/RWGame.cpp | 2 +- rwgame/main.cpp | 2 +- rwgame/states/DebugState.cpp | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/rwengine/src/render/TextRenderer.cpp b/rwengine/src/render/TextRenderer.cpp index 6e8378bb..5ded695f 100644 --- a/rwengine/src/render/TextRenderer.cpp +++ b/rwengine/src/render/TextRenderer.cpp @@ -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) { diff --git a/rwgame/DrawUI.cpp b/rwgame/DrawUI.cpp index cbacb079..abf6ec43 100644 --- a/rwgame/DrawUI.cpp +++ b/rwgame/DrawUI.cpp @@ -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( + 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(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(render->getRenderer()->getViewport().x - + (ui_outerMargin + ui_weaponSize)); float iconY = ui_outerMargin; - float wantedX = render->getRenderer()->getViewport().x - (ui_outerMargin); + float wantedX = static_cast(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(t.size); ti.font = t.font; ti.text = t.text; ti.wrapX = t.wrapX; diff --git a/rwgame/GameConfig.cpp b/rwgame/GameConfig.cpp index e2630d02..247f62ec 100644 --- a/rwgame/GameConfig.cpp +++ b/rwgame/GameConfig.cpp @@ -104,7 +104,7 @@ struct BoolTranslator { boost::optional 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 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(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()); diff --git a/rwgame/GameWindow.cpp b/rwgame/GameWindow.cpp index 1267f09b..c24e5fc0 100644 --- a/rwgame/GameWindow.cpp +++ b/rwgame/GameWindow.cpp @@ -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(w), static_cast(h), style); if (window == nullptr) { // Window creation failure is fatal std::string sdlErrorStr = SDL_GetError(); diff --git a/rwgame/MenuSystem.hpp b/rwgame/MenuSystem.hpp index a589ef66..a11e9be2 100644 --- a/rwgame/MenuSystem.hpp +++ b/rwgame/MenuSystem.hpp @@ -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(i); return; } else { c.y -= size; @@ -149,7 +149,7 @@ public: if (activeEntry >= static_cast(entries.size())) { activeEntry = 0; } else if (activeEntry < 0) { - activeEntry = entries.size() - 1; + activeEntry = static_cast(entries.size() - 1); } } diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 830c49ea..8b142d77 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -224,7 +224,7 @@ void RWGame::handleCheatInput(char symbol) { 5 //sniper rifle }; for (std::array::size_type i = 0; i < ammo.size(); i++) - player->addToInventory(i+1,ammo[i]); + player->addToInventory(static_cast(i+1),ammo[i]); state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats. }); diff --git a/rwgame/main.cpp b/rwgame/main.cpp index f9d04d1f..f0d4a253 100644 --- a/rwgame/main.cpp +++ b/rwgame/main.cpp @@ -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. diff --git a/rwgame/states/DebugState.cpp b/rwgame/states/DebugState.cpp index be0978e0..397bffc1 100644 --- a/rwgame/states/DebugState.cpp +++ b/rwgame/states/DebugState.cpp @@ -218,7 +218,7 @@ std::shared_ptr 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(i); }); } menu->offset = kDebugMenuOffset; From 089b49b77a9431762518009cbf1ba5742ca3211b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 02:19:38 +0200 Subject: [PATCH 04/24] rwviewer: fix Visual Studio warnings --- rwviewer/AnimationListModel.cpp | 2 +- rwviewer/AnimationListModel.hpp | 12 ++++++------ rwviewer/IMGArchiveModel.cpp | 2 +- rwviewer/IMGArchiveModel.hpp | 14 +++++++------- rwviewer/ItemListModel.cpp | 2 +- rwviewer/ItemListModel.hpp | 14 +++++++------- rwviewer/models/DFFFramesTreeModel.cpp | 4 ++-- rwviewer/models/ObjectListModel.cpp | 2 +- rwviewer/models/ObjectListModel.hpp | 14 +++++++------- rwviewer/models/TextModel.cpp | 6 +++--- rwviewer/models/TextModel.hpp | 2 +- rwviewer/views/TextViewer.cpp | 2 +- rwviewer/views/TextViewer.hpp | 2 +- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/rwviewer/AnimationListModel.cpp b/rwviewer/AnimationListModel.cpp index a6d8c4c9..82f18b05 100644 --- a/rwviewer/AnimationListModel.cpp +++ b/rwviewer/AnimationListModel.cpp @@ -25,7 +25,7 @@ QVariant AnimationListModel::headerData(int section, } int AnimationListModel::rowCount(const QModelIndex&) const { - return animations.size(); + return static_cast(animations.size()); } int AnimationListModel::columnCount(const QModelIndex&) const { diff --git a/rwviewer/AnimationListModel.hpp b/rwviewer/AnimationListModel.hpp index 1200ab2e..81323400 100644 --- a/rwviewer/AnimationListModel.hpp +++ b/rwviewer/AnimationListModel.hpp @@ -16,15 +16,15 @@ public: : QAbstractListModel(parent), animations(anims) { } - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, + int role = Qt::DisplayRole) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; const AnimationList& getAnimations() const { return animations; diff --git a/rwviewer/IMGArchiveModel.cpp b/rwviewer/IMGArchiveModel.cpp index dc272f86..8c7b752e 100644 --- a/rwviewer/IMGArchiveModel.cpp +++ b/rwviewer/IMGArchiveModel.cpp @@ -30,7 +30,7 @@ QVariant IMGArchiveModel::headerData(int section, Qt::Orientation orientation, } int IMGArchiveModel::rowCount(const QModelIndex&) const { - return archive.getAssetCount(); + return static_cast(archive.getAssetCount()); } int IMGArchiveModel::columnCount(const QModelIndex&) const { diff --git a/rwviewer/IMGArchiveModel.hpp b/rwviewer/IMGArchiveModel.hpp index 23411243..ed885dec 100644 --- a/rwviewer/IMGArchiveModel.hpp +++ b/rwviewer/IMGArchiveModel.hpp @@ -14,19 +14,19 @@ public: : QAbstractListModel(parent), archive(archive) { } - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, + int role = Qt::DisplayRole) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; const LoaderIMG& getArchive() const { return archive; } }; -#endif \ No newline at end of file +#endif diff --git a/rwviewer/ItemListModel.cpp b/rwviewer/ItemListModel.cpp index 1914bf4f..698b1a82 100644 --- a/rwviewer/ItemListModel.cpp +++ b/rwviewer/ItemListModel.cpp @@ -14,7 +14,7 @@ ItemListModel::ItemListModel(GameWorld *world, QObject *parent) } int ItemListModel::rowCount(const QModelIndex &) const { - return _world->data->modelinfo.size(); + return static_cast(_world->data->modelinfo.size()); } int ItemListModel::columnCount(const QModelIndex &) const { diff --git a/rwviewer/ItemListModel.hpp b/rwviewer/ItemListModel.hpp index 15e13181..1bcaafa9 100644 --- a/rwviewer/ItemListModel.hpp +++ b/rwviewer/ItemListModel.hpp @@ -19,17 +19,17 @@ public: qint16 getIDOf(unsigned int row) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, + int role = Qt::DisplayRole) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; - QModelIndex index(int row, int column, const QModelIndex& parent) const; + QModelIndex index(int row, int column, const QModelIndex& parent) const override; }; #endif // ITEMLISTMODEL_HPP diff --git a/rwviewer/models/DFFFramesTreeModel.cpp b/rwviewer/models/DFFFramesTreeModel.cpp index 02311d55..737664bb 100644 --- a/rwviewer/models/DFFFramesTreeModel.cpp +++ b/rwviewer/models/DFFFramesTreeModel.cpp @@ -13,7 +13,7 @@ int DFFFramesTreeModel::columnCount(const QModelIndex&) const { int DFFFramesTreeModel::rowCount(const QModelIndex& parent) const { ModelFrame* f = static_cast(parent.internalPointer()); if (f) { - return f->getChildren().size(); + return static_cast(f->getChildren().size()); } if (parent.row() == -1) { @@ -40,7 +40,7 @@ QModelIndex DFFFramesTreeModel::parent(const QModelIndex& child) const { if (cp->getParent()) { for (size_t i = 0; i < cp->getParent()->getChildren().size(); ++i) { if (cp->getParent()->getChildren()[i].get() == c->getParent()) { - return createIndex(i, 0, c->getParent()); + return createIndex(static_cast(i), 0, c->getParent()); } } } else { diff --git a/rwviewer/models/ObjectListModel.cpp b/rwviewer/models/ObjectListModel.cpp index 539b3d3c..bc502b68 100644 --- a/rwviewer/models/ObjectListModel.cpp +++ b/rwviewer/models/ObjectListModel.cpp @@ -5,7 +5,7 @@ ObjectListModel::ObjectListModel(GameData *dat, QObject *parent) } int ObjectListModel::rowCount(const QModelIndex &) const { - return _gameData->modelinfo.size(); + return static_cast(_gameData->modelinfo.size()); } int ObjectListModel::columnCount(const QModelIndex &) const { diff --git a/rwviewer/models/ObjectListModel.hpp b/rwviewer/models/ObjectListModel.hpp index 82115925..652b062f 100644 --- a/rwviewer/models/ObjectListModel.hpp +++ b/rwviewer/models/ObjectListModel.hpp @@ -17,17 +17,17 @@ public: return _gameData; } - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, + int role = Qt::DisplayRole) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; - QModelIndex index(int row, int column, const QModelIndex& parent) const; + QModelIndex index(int row, int column, const QModelIndex& parent) const override; }; #endif // _OBJECTLISTMODEL_HPP_ diff --git a/rwviewer/models/TextModel.cpp b/rwviewer/models/TextModel.cpp index 765a94c6..ab4b9f9c 100644 --- a/rwviewer/models/TextModel.cpp +++ b/rwviewer/models/TextModel.cpp @@ -8,18 +8,18 @@ TextModel::TextModel(QObject *parent) } -void TextModel::setData(const TextMapType &textMap) { +void TextModel::setMapData(const TextMapType &textMap) { beginResetModel(); m_textMap = textMap; endResetModel(); } int TextModel::rowCount(const QModelIndex &) const { - return m_textMap.keys.size(); + return static_cast(m_textMap.keys.size()); } int TextModel::columnCount(const QModelIndex &) const { - return m_textMap.languages.size(); + return static_cast(m_textMap.languages.size()); } const GameString &TextModel::lookupIndex(const QModelIndex &index) const { diff --git a/rwviewer/models/TextModel.hpp b/rwviewer/models/TextModel.hpp index e6ac9b12..8ecc10be 100644 --- a/rwviewer/models/TextModel.hpp +++ b/rwviewer/models/TextModel.hpp @@ -19,7 +19,7 @@ class TextModel : public QAbstractTableModel { Q_OBJECT public: TextModel(QObject *parent = nullptr); - void setData(const TextMapType &textMap); + void setMapData(const TextMapType &textMap); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/rwviewer/views/TextViewer.cpp b/rwviewer/views/TextViewer.cpp index 25b505ee..c7efa4f1 100644 --- a/rwviewer/views/TextViewer.cpp +++ b/rwviewer/views/TextViewer.cpp @@ -217,7 +217,7 @@ void TextViewer::worldChanged() { textMap.keys.resize(keys.size()); std::move(keys.begin(), keys.end(), textMap.keys.begin()); - textModel->setData(textMap); + textModel->setMapData(textMap); } std::vector TextViewer::getFontTextureNames() { diff --git a/rwviewer/views/TextViewer.hpp b/rwviewer/views/TextViewer.hpp index 38e9d117..5666184f 100644 --- a/rwviewer/views/TextViewer.hpp +++ b/rwviewer/views/TextViewer.hpp @@ -39,7 +39,7 @@ class TextViewer : public ViewerInterface { QLineEdit *hexLineEdit; QTextEdit *textEdit; - virtual void worldChanged() override; + void worldChanged() override; GameString currentGameString; font_t currentFont; From 2d595bede737ad95e246513548c1024a2be9bf1d Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 03:00:39 +0200 Subject: [PATCH 05/24] cmake: add all files to cmake --- rwengine/CMakeLists.txt | 4 +++ rwgame/CMakeLists.txt | 22 ++++++++----- rwviewer/CMakeLists.txt | 32 +++++++++---------- rwviewer/{ => models}/AnimationListModel.cpp | 0 rwviewer/{ => models}/AnimationListModel.hpp | 0 rwviewer/{ => models}/IMGArchiveModel.cpp | 0 rwviewer/{ => models}/IMGArchiveModel.hpp | 0 rwviewer/{ => models}/ItemListModel.cpp | 0 rwviewer/{ => models}/ItemListModel.hpp | 0 .../{ => widgets}/AnimationListWidget.cpp | 0 .../{ => widgets}/AnimationListWidget.hpp | 2 +- rwviewer/{ => widgets}/ItemListWidget.cpp | 0 rwviewer/{ => widgets}/ItemListWidget.hpp | 2 +- 13 files changed, 36 insertions(+), 26 deletions(-) rename rwviewer/{ => models}/AnimationListModel.cpp (100%) rename rwviewer/{ => models}/AnimationListModel.hpp (100%) rename rwviewer/{ => models}/IMGArchiveModel.cpp (100%) rename rwviewer/{ => models}/IMGArchiveModel.hpp (100%) rename rwviewer/{ => models}/ItemListModel.cpp (100%) rename rwviewer/{ => models}/ItemListModel.hpp (100%) rename rwviewer/{ => widgets}/AnimationListWidget.cpp (100%) rename rwviewer/{ => widgets}/AnimationListWidget.hpp (94%) rename rwviewer/{ => widgets}/ItemListWidget.cpp (100%) rename rwviewer/{ => widgets}/ItemListWidget.hpp (94%) diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index 07c132e7..24d0620a 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -41,8 +41,10 @@ set(RWENGINE_SOURCES src/data/PathData.hpp src/data/PedData.cpp src/data/PedData.hpp + src/data/VehicleGenerator.hpp src/data/WeaponData.hpp src/data/Weather.cpp + src/data/Weather.hpp src/data/ZoneData.hpp src/dynamics/CollisionInstance.cpp @@ -53,6 +55,7 @@ set(RWENGINE_SOURCES src/engine/Animator.hpp src/engine/GameData.cpp src/engine/GameData.hpp + src/engine/GameInputState.hpp src/engine/GameState.cpp src/engine/GameState.hpp src/engine/GameWorld.cpp @@ -136,6 +139,7 @@ set(RWENGINE_SOURCES src/script/ScriptTypes.hpp src/script/modules/GTA3Module.cpp src/script/modules/GTA3Module.hpp + src/script/modules/GTA3ModuleImpl.inl ) add_library(rwengine diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index 35e9837c..a1125c28 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -8,21 +8,28 @@ set(RWGAME_SOURCES GameBase.hpp GameBase.cpp + RWGame.hpp RWGame.cpp - + GameConfig.hpp GameConfig.cpp + GameWindow.hpp GameWindow.cpp + DrawUI.cpp + DrawUI.hpp + MenuSystem.hpp + MenuSystem.cpp + GameInput.hpp + GameInput.cpp + + game.hpp + WindowIcon.hpp + StateManager.hpp StateManager.cpp + State.hpp State.cpp - MenuSystem.hpp - MenuSystem.cpp - - GameInput.hpp - GameInput.cpp - states/LoadingState.hpp states/LoadingState.cpp states/IngameState.hpp @@ -36,7 +43,6 @@ set(RWGAME_SOURCES states/BenchmarkState.hpp states/BenchmarkState.cpp - DrawUI.cpp ) add_executable(rwgame diff --git a/rwviewer/CMakeLists.txt b/rwviewer/CMakeLists.txt index 9a8e28f4..5b4e3f1d 100644 --- a/rwviewer/CMakeLists.txt +++ b/rwviewer/CMakeLists.txt @@ -9,15 +9,20 @@ add_executable(rwviewer ViewerWindow.hpp ViewerWindow.cpp - + + models/AnimationListModel.hpp + models/AnimationListModel.cpp models/ObjectListModel.hpp models/ObjectListModel.cpp models/DFFFramesTreeModel.hpp models/DFFFramesTreeModel.cpp + models/IMGArchiveModel.hpp + models/IMGArchiveModel.cpp + models/ItemListModel.hpp + models/ItemListModel.cpp models/TextModel.hpp models/TextModel.cpp - views/ViewerInterface.hpp views/ObjectViewer.hpp views/ObjectViewer.cpp views/ModelViewer.hpp @@ -28,23 +33,18 @@ add_executable(rwviewer views/WorldViewer.cpp views/ViewerInterface.hpp views/ViewerInterface.cpp - - ViewerWidget.cpp + + QOpenGLContextWrapper.hpp + QOpenGLContextWrapper.cpp ViewerWidget.hpp - ItemListModel.hpp - ItemListModel.cpp - ItemListWidget.hpp - ItemListWidget.cpp - IMGArchiveModel.hpp - IMGArchiveModel.cpp + ViewerWidget.cpp + + widgets/AnimationListWidget.hpp + widgets/AnimationListWidget.cpp + widgets/ItemListWidget.hpp + widgets/ItemListWidget.cpp widgets/ModelFramesWidget.hpp widgets/ModelFramesWidget.cpp - AnimationListModel.hpp - AnimationListModel.cpp - AnimationListWidget.hpp - AnimationListWidget.cpp - QOpenGLContextWrapper.cpp - QOpenGLContextWrapper.hpp ) target_link_libraries(rwviewer diff --git a/rwviewer/AnimationListModel.cpp b/rwviewer/models/AnimationListModel.cpp similarity index 100% rename from rwviewer/AnimationListModel.cpp rename to rwviewer/models/AnimationListModel.cpp diff --git a/rwviewer/AnimationListModel.hpp b/rwviewer/models/AnimationListModel.hpp similarity index 100% rename from rwviewer/AnimationListModel.hpp rename to rwviewer/models/AnimationListModel.hpp diff --git a/rwviewer/IMGArchiveModel.cpp b/rwviewer/models/IMGArchiveModel.cpp similarity index 100% rename from rwviewer/IMGArchiveModel.cpp rename to rwviewer/models/IMGArchiveModel.cpp diff --git a/rwviewer/IMGArchiveModel.hpp b/rwviewer/models/IMGArchiveModel.hpp similarity index 100% rename from rwviewer/IMGArchiveModel.hpp rename to rwviewer/models/IMGArchiveModel.hpp diff --git a/rwviewer/ItemListModel.cpp b/rwviewer/models/ItemListModel.cpp similarity index 100% rename from rwviewer/ItemListModel.cpp rename to rwviewer/models/ItemListModel.cpp diff --git a/rwviewer/ItemListModel.hpp b/rwviewer/models/ItemListModel.hpp similarity index 100% rename from rwviewer/ItemListModel.hpp rename to rwviewer/models/ItemListModel.hpp diff --git a/rwviewer/AnimationListWidget.cpp b/rwviewer/widgets/AnimationListWidget.cpp similarity index 100% rename from rwviewer/AnimationListWidget.cpp rename to rwviewer/widgets/AnimationListWidget.cpp diff --git a/rwviewer/AnimationListWidget.hpp b/rwviewer/widgets/AnimationListWidget.hpp similarity index 94% rename from rwviewer/AnimationListWidget.hpp rename to rwviewer/widgets/AnimationListWidget.hpp index 59457561..c0e4dd02 100644 --- a/rwviewer/AnimationListWidget.hpp +++ b/rwviewer/widgets/AnimationListWidget.hpp @@ -5,7 +5,7 @@ #include #include #include -#include "AnimationListModel.hpp" +#include "models/AnimationListModel.hpp" class AnimationListWidget : public QDockWidget { Q_OBJECT diff --git a/rwviewer/ItemListWidget.cpp b/rwviewer/widgets/ItemListWidget.cpp similarity index 100% rename from rwviewer/ItemListWidget.cpp rename to rwviewer/widgets/ItemListWidget.cpp diff --git a/rwviewer/ItemListWidget.hpp b/rwviewer/widgets/ItemListWidget.hpp similarity index 94% rename from rwviewer/ItemListWidget.hpp rename to rwviewer/widgets/ItemListWidget.hpp index 79c1fe7f..c6d959f2 100644 --- a/rwviewer/ItemListWidget.hpp +++ b/rwviewer/widgets/ItemListWidget.hpp @@ -5,7 +5,7 @@ #include #include #include -#include "ItemListModel.hpp" +#include "models/ItemListModel.hpp" class ItemListWidget : public QDockWidget { Q_OBJECT From 0b5500cf07e6a44c4150ddd77357005e885e98dc Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 03:06:01 +0200 Subject: [PATCH 06/24] rwgame+rwviewer: no more "#pragma once" --- rwgame/DrawUI.hpp | 5 ++++- rwviewer/ViewerWindow.cpp | 2 +- rwviewer/models/AnimationListModel.hpp | 1 - rwviewer/models/DFFFramesTreeModel.hpp | 1 - rwviewer/models/IMGArchiveModel.hpp | 1 - rwviewer/views/ModelViewer.hpp | 1 - rwviewer/widgets/AnimationListWidget.hpp | 1 - rwviewer/widgets/ItemListWidget.hpp | 1 - rwviewer/widgets/ModelFramesWidget.hpp | 1 - 9 files changed, 5 insertions(+), 9 deletions(-) diff --git a/rwgame/DrawUI.hpp b/rwgame/DrawUI.hpp index 74f38af5..38f113f2 100644 --- a/rwgame/DrawUI.hpp +++ b/rwgame/DrawUI.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef _RWGAME_DRAWUI_HPP_ +#define _RWGAME_DRAWUI_HPP_ #include #include @@ -8,3 +9,5 @@ void drawHUD(ViewCamera& currentView, PlayerController* player, GameWorld* world, GameRenderer* render); void drawOnScreenText(GameWorld* world, GameRenderer* renderer); + +#endif diff --git a/rwviewer/ViewerWindow.cpp b/rwviewer/ViewerWindow.cpp index 92f230a6..8f17d632 100644 --- a/rwviewer/ViewerWindow.cpp +++ b/rwviewer/ViewerWindow.cpp @@ -167,7 +167,7 @@ void ViewerWindow::loadGame(const QString& path) { } void ViewerWindow::showObjectModel(uint16_t) { -#pragma message("implement me") + RW_MESSAGE("showObjectModel unimplemented"); // FIXME: unimplemented } void ViewerWindow::updateRecentGames() { diff --git a/rwviewer/models/AnimationListModel.hpp b/rwviewer/models/AnimationListModel.hpp index 81323400..e4c7f96a 100644 --- a/rwviewer/models/AnimationListModel.hpp +++ b/rwviewer/models/AnimationListModel.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _ANIMATIONLISTMODEL_HPP_ #define _ANIMATIONLISTMODEL_HPP_ #include diff --git a/rwviewer/models/DFFFramesTreeModel.hpp b/rwviewer/models/DFFFramesTreeModel.hpp index 3e764024..2237d43b 100644 --- a/rwviewer/models/DFFFramesTreeModel.hpp +++ b/rwviewer/models/DFFFramesTreeModel.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _DFFFRAMESTREEMODEL_HPP_ #define _DFFFRAMESTREEMODEL_HPP_ #include diff --git a/rwviewer/models/IMGArchiveModel.hpp b/rwviewer/models/IMGArchiveModel.hpp index ed885dec..350f9068 100644 --- a/rwviewer/models/IMGArchiveModel.hpp +++ b/rwviewer/models/IMGArchiveModel.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _IMGARCHIVEMODEL_HPP_ #define _IMGARCHIVEMODEL_HPP_ #include diff --git a/rwviewer/views/ModelViewer.hpp b/rwviewer/views/ModelViewer.hpp index 02acc42c..dc926c8d 100644 --- a/rwviewer/views/ModelViewer.hpp +++ b/rwviewer/views/ModelViewer.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _MODELVIEWER_HPP_ #define _MODELVIEWER_HPP_ #include diff --git a/rwviewer/widgets/AnimationListWidget.hpp b/rwviewer/widgets/AnimationListWidget.hpp index c0e4dd02..9546398b 100644 --- a/rwviewer/widgets/AnimationListWidget.hpp +++ b/rwviewer/widgets/AnimationListWidget.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _ANIMATIONLISTWIDGET_HPP_ #define _ANIMATIONLISTWIDGET_HPP_ #include diff --git a/rwviewer/widgets/ItemListWidget.hpp b/rwviewer/widgets/ItemListWidget.hpp index c6d959f2..a522649f 100644 --- a/rwviewer/widgets/ItemListWidget.hpp +++ b/rwviewer/widgets/ItemListWidget.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _ITEMLISTWIDGET_HPP_ #define _ITEMLISTWIDGET_HPP_ #include diff --git a/rwviewer/widgets/ModelFramesWidget.hpp b/rwviewer/widgets/ModelFramesWidget.hpp index 53bb0783..1f9487fb 100644 --- a/rwviewer/widgets/ModelFramesWidget.hpp +++ b/rwviewer/widgets/ModelFramesWidget.hpp @@ -1,4 +1,3 @@ -#pragma once #ifndef _MODELFRAMESWIDGET_HPP_ #define _MODELFRAMESWIDGET_HPP_ #include From cce05da98562daccbe9e8d9c461454961f780e6e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 03:39:04 +0200 Subject: [PATCH 07/24] tests: fix for xcode --- tests/test_LoaderIDE.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_LoaderIDE.cpp b/tests/test_LoaderIDE.cpp index 075a3a94..dc7cb27a 100644 --- a/tests/test_LoaderIDE.cpp +++ b/tests/test_LoaderIDE.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(objects_contains_modelID) { BOOST_AUTO_TEST_CASE(instance_data_is_correct) { loader.load(test_data_stream, {}); - ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {220}, 0); + ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {220.f}, 0); } BOOST_AUTO_TEST_CASE(vehicle_data_is_correct) { From 764fe2ecf47a734761906c4a8e4ed1a31ed64bbe Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 03:46:41 +0200 Subject: [PATCH 08/24] docker: install clang --- scripts/docker/arch_latest.docker | 1 + scripts/docker/conan_base.docker | 1 + scripts/docker/fedora_latest.docker | 4 +++- scripts/docker/ubuntu_latest.docker | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/docker/arch_latest.docker b/scripts/docker/arch_latest.docker index 40378719..8b9612b3 100644 --- a/scripts/docker/arch_latest.docker +++ b/scripts/docker/arch_latest.docker @@ -2,6 +2,7 @@ FROM base/archlinux RUN pacman -Syy --noconfirm \ core/gcc \ + extra/clang \ make \ extra/boost \ extra/cmake \ diff --git a/scripts/docker/conan_base.docker b/scripts/docker/conan_base.docker index 688ea9db..10a488fc 100644 --- a/scripts/docker/conan_base.docker +++ b/scripts/docker/conan_base.docker @@ -6,6 +6,7 @@ RUN apt-get update \ cmake \ gcc-8 \ g++-8 \ + clang-6.0 \ # scripts to install conan \ python3-pip \ python3-distutils \ diff --git a/scripts/docker/fedora_latest.docker b/scripts/docker/fedora_latest.docker index 4b2a92b7..a06ca519 100644 --- a/scripts/docker/fedora_latest.docker +++ b/scripts/docker/fedora_latest.docker @@ -7,7 +7,9 @@ RUN dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-re RUN dnf update -y \ && dnf install -y \ boost-devel \ - gcc gcc-c++ \ + gcc \ + gcc-c++ \ + clang \ boost-devel \ cmake \ make \ diff --git a/scripts/docker/ubuntu_latest.docker b/scripts/docker/ubuntu_latest.docker index 5fbfad23..776d1327 100644 --- a/scripts/docker/ubuntu_latest.docker +++ b/scripts/docker/ubuntu_latest.docker @@ -6,6 +6,7 @@ RUN apt-get update \ cmake \ gcc-7 \ g++-7 \ + clang-6.0 \ libavcodec-dev \ libavformat-dev \ libboost-filesystem-dev \ From 890deb217b79ec9cc0991274af8a06a3908f7425 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 03:53:21 +0200 Subject: [PATCH 09/24] ci: build openrw using clang on fedora --- .travis.yml | 7 ++++++- scripts/docker/docker_travis.sh | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49f06ba7..664dbe75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,25 +6,30 @@ git: matrix: include: - os: linux + compiler: gcc env: NAME="Ubuntu Linux (Latest)" NAME_SUFFIX="ubuntu" services: docker script: - scripts/docker/docker_travis.sh "ubuntu_latest.docker" - os: linux - env: NAME="Fedora Linux (Latest)" NAME_SUFFIX="fedora" + compiler: clang + env: NAME="Fedora Linux (Latest)" NAME_SUFFIX="fedora-llvm" services: docker script: - scripts/docker/docker_travis.sh "fedora_latest.docker" - os: linux + compiler: gcc env: NAME="Arch Linux (Latest)" NAME_SUFFIX="arch" DEBUG=1 services: docker script: - scripts/docker/docker_travis.sh "arch_latest.docker" - os: linux + compiler: gcc env: NAME="conan" NAME_SUFFIX="conan" USE_CONAN=1 script: - scripts/docker/docker_travis.sh "conan_base.docker" - os: osx + compiler: clang env: NAME="Apple macOS" NAME_SUFFIX="mac" osx_image: xcode9.4 install: diff --git a/scripts/docker/docker_travis.sh b/scripts/docker/docker_travis.sh index 34c5fca3..f572362f 100755 --- a/scripts/docker/docker_travis.sh +++ b/scripts/docker/docker_travis.sh @@ -18,8 +18,11 @@ docker=$1 TRAVIS_BRANCH=$TRAVIS_BRANCH \ USE_CONAN=$USE_CONAN \ ALSOFT_DRIVERS=null \ + CC=$CC \ + CXX=$CXX \ DEBUG=$DEBUG \ XDG_RUNTIME_DIR=/tmp # execute test -"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV" +"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c \ + "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV" From 7bea25e487f92099a7cbdce5732e2908bf0ab895 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 15:43:48 +0200 Subject: [PATCH 10/24] rwengine: some variables are only used in debug builds Fixes clang warnings about unused private fields: -Wunused-private-field --- rwengine/src/data/ModelData.hpp | 2 +- rwengine/src/render/OpenGLRenderer.hpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rwengine/src/data/ModelData.hpp b/rwengine/src/data/ModelData.hpp index 04760769..662e160f 100644 --- a/rwengine/src/data/ModelData.hpp +++ b/rwengine/src/data/ModelData.hpp @@ -273,7 +273,7 @@ private: std::array atomics_; float loddistances_[3] = {}; uint8_t numatomics_ = 0; - uint8_t alpha_ = 0; /// @todo ask aap why +// uint8_t alpha_ = 0; /// @todo ask aap why bool isbigbuilding_ = 0; uint8_t furthest_ = 0; diff --git a/rwengine/src/render/OpenGLRenderer.hpp b/rwengine/src/render/OpenGLRenderer.hpp index 8b2faaff..9f99eb0c 100644 --- a/rwengine/src/render/OpenGLRenderer.hpp +++ b/rwengine/src/render/OpenGLRenderer.hpp @@ -403,7 +403,7 @@ private: template void uploadUBO(Buffer& buffer, const T& data) { uploadUBOEntry(buffer, &data, sizeof(T)); -#ifdef RW_PROFILER +#ifdef RW_GRAPHICS_STATS if (currentDebugDepth > 0) { profileInfo[currentDebugDepth - 1].uploads++; } @@ -425,7 +425,9 @@ private: // Debug group profiling timers ProfileInfo profileInfo[MAX_DEBUG_DEPTH]; GLuint debugQuery; +#ifdef RW_GRAPHICS_STATS int currentDebugDepth = 0; +#endif }; /// @todo remove these from here From 32d3ab75083eae6e5325183ff1d0736f870adc74 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 30 Aug 2018 17:37:27 +0200 Subject: [PATCH 11/24] rwengine+tests: disable C4305 warning for bullet3 warning C4305: 'argument': truncation from 'double' to 'const btScalar' --- rwengine/src/ai/CharacterController.cpp | 7 +++++++ rwengine/src/dynamics/CollisionInstance.cpp | 7 +++++++ rwengine/src/dynamics/RaycastCallbacks.hpp | 6 ++++++ rwengine/src/engine/GameWorld.cpp | 6 ++++++ rwengine/src/engine/GameWorld.hpp | 7 +++++++ rwengine/src/engine/Garage.cpp | 7 +++++++ rwengine/src/objects/CharacterObject.cpp | 6 ++++++ rwengine/src/objects/InstanceObject.cpp | 6 ++++++ rwengine/src/objects/PickupObject.cpp | 13 +++++++++++-- rwengine/src/objects/ProjectileObject.cpp | 7 +++++++ rwengine/src/objects/VehicleObject.cpp | 7 +++++++ rwengine/src/objects/VehicleObject.hpp | 9 ++++++++- rwengine/src/render/DebugDraw.cpp | 7 +++++++ rwengine/src/render/DebugDraw.hpp | 6 ++++++ rwgame/RWGame.hpp | 6 ++++++ rwgame/states/IngameState.cpp | 7 +++++++ tests/test_Globals.hpp | 7 +++++++ 17 files changed, 118 insertions(+), 3 deletions(-) diff --git a/rwengine/src/ai/CharacterController.cpp b/rwengine/src/ai/CharacterController.cpp index 3875c2db..4af7785c 100644 --- a/rwengine/src/ai/CharacterController.cpp +++ b/rwengine/src/ai/CharacterController.cpp @@ -4,8 +4,15 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include diff --git a/rwengine/src/dynamics/CollisionInstance.cpp b/rwengine/src/dynamics/CollisionInstance.cpp index 3fcc22dc..b58f9043 100644 --- a/rwengine/src/dynamics/CollisionInstance.cpp +++ b/rwengine/src/dynamics/CollisionInstance.cpp @@ -4,7 +4,14 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include diff --git a/rwengine/src/dynamics/RaycastCallbacks.hpp b/rwengine/src/dynamics/RaycastCallbacks.hpp index 3936280c..0da38eee 100644 --- a/rwengine/src/dynamics/RaycastCallbacks.hpp +++ b/rwengine/src/dynamics/RaycastCallbacks.hpp @@ -1,7 +1,13 @@ #ifndef _RWENGINE_RAYCASTCALLBACKS_HPP_ #define _RWENGINE_RAYCASTCALLBACKS_HPP_ +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif /** * Implements raycast callback that ignores a specified btCollisionObject diff --git a/rwengine/src/engine/GameWorld.cpp b/rwengine/src/engine/GameWorld.cpp index 4abe33e2..c59746ca 100644 --- a/rwengine/src/engine/GameWorld.cpp +++ b/rwengine/src/engine/GameWorld.cpp @@ -1,7 +1,13 @@ #include "engine/GameWorld.hpp" +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include diff --git a/rwengine/src/engine/GameWorld.hpp b/rwengine/src/engine/GameWorld.hpp index 579cba81..a58d64d0 100644 --- a/rwengine/src/engine/GameWorld.hpp +++ b/rwengine/src/engine/GameWorld.hpp @@ -9,7 +9,14 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include diff --git a/rwengine/src/engine/Garage.cpp b/rwengine/src/engine/Garage.cpp index 13088e89..28974e3a 100644 --- a/rwengine/src/engine/Garage.cpp +++ b/rwengine/src/engine/Garage.cpp @@ -1,6 +1,13 @@ #include "Garage.hpp" +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include "dynamics/CollisionInstance.hpp" diff --git a/rwengine/src/objects/CharacterObject.cpp b/rwengine/src/objects/CharacterObject.cpp index 851a2ea1..8f962069 100644 --- a/rwengine/src/objects/CharacterObject.cpp +++ b/rwengine/src/objects/CharacterObject.cpp @@ -5,9 +5,15 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include diff --git a/rwengine/src/objects/InstanceObject.cpp b/rwengine/src/objects/InstanceObject.cpp index c87286e7..001559b4 100644 --- a/rwengine/src/objects/InstanceObject.cpp +++ b/rwengine/src/objects/InstanceObject.cpp @@ -3,8 +3,14 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include diff --git a/rwengine/src/objects/PickupObject.cpp b/rwengine/src/objects/PickupObject.cpp index babafa00..4a0d8d15 100644 --- a/rwengine/src/objects/PickupObject.cpp +++ b/rwengine/src/objects/PickupObject.cpp @@ -2,8 +2,15 @@ #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include "ai/PlayerController.hpp" @@ -402,9 +409,11 @@ bool CollectablePickup::onPlayerTouch() { auto text = ScreenText::format( engine->data->texts.text(gxtEntry), GameStringUtil::fromString( - std::to_string(state->playerInfo.hiddenPackagesCollected), FONT_PRICEDOWN), + std::to_string(state->playerInfo.hiddenPackagesCollected), + FONT_PRICEDOWN), GameStringUtil::fromString( - std::to_string(state->playerInfo.hiddenPackageCount), FONT_PRICEDOWN)); + std::to_string(state->playerInfo.hiddenPackageCount), + FONT_PRICEDOWN)); state->text.addText( ScreenTextEntry::makeHiddenPackageText(gxtEntry, text)); diff --git a/rwengine/src/objects/ProjectileObject.cpp b/rwengine/src/objects/ProjectileObject.cpp index 4b0d504c..43327010 100644 --- a/rwengine/src/objects/ProjectileObject.cpp +++ b/rwengine/src/objects/ProjectileObject.cpp @@ -1,7 +1,14 @@ #include "objects/ProjectileObject.hpp" +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include "data/WeaponData.hpp" diff --git a/rwengine/src/objects/VehicleObject.cpp b/rwengine/src/objects/VehicleObject.cpp index 74bdba8d..983e7a4b 100644 --- a/rwengine/src/objects/VehicleObject.cpp +++ b/rwengine/src/objects/VehicleObject.cpp @@ -5,8 +5,15 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include diff --git a/rwengine/src/objects/VehicleObject.hpp b/rwengine/src/objects/VehicleObject.hpp index 810406b6..56d4ae53 100644 --- a/rwengine/src/objects/VehicleObject.hpp +++ b/rwengine/src/objects/VehicleObject.hpp @@ -7,7 +7,15 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif +#include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include @@ -15,7 +23,6 @@ #include #include -#include class Atomic; class CharacterObject; diff --git a/rwengine/src/render/DebugDraw.cpp b/rwengine/src/render/DebugDraw.cpp index 171c995d..2c6256d5 100644 --- a/rwengine/src/render/DebugDraw.cpp +++ b/rwengine/src/render/DebugDraw.cpp @@ -3,7 +3,14 @@ #include #include + +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include #include diff --git a/rwengine/src/render/DebugDraw.hpp b/rwengine/src/render/DebugDraw.hpp index 12b7d3a3..4cf1ad6e 100644 --- a/rwengine/src/render/DebugDraw.hpp +++ b/rwengine/src/render/DebugDraw.hpp @@ -4,8 +4,14 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include #include diff --git a/rwgame/RWGame.hpp b/rwgame/RWGame.hpp index 8e95fbe3..c2b2f098 100644 --- a/rwgame/RWGame.hpp +++ b/rwgame/RWGame.hpp @@ -3,8 +3,14 @@ #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif // FIXME: should be in rwengine, deeply hidden #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif #include #include diff --git a/rwgame/states/IngameState.cpp b/rwgame/states/IngameState.cpp index 41c11f92..3f8caf44 100644 --- a/rwgame/states/IngameState.cpp +++ b/rwgame/states/IngameState.cpp @@ -21,7 +21,14 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + constexpr float kAutoLookTime = 2.f; constexpr float kAutolookMinVelocity = 0.2f; diff --git a/tests/test_Globals.hpp b/tests/test_Globals.hpp index 9b22a838..f33ccc71 100644 --- a/tests/test_Globals.hpp +++ b/tests/test_Globals.hpp @@ -1,7 +1,14 @@ #ifndef _TESTGLOBALS_HPP_ #define _TESTGLOBALS_HPP_ +#ifdef _MSC_VER +#pragma warning(disable : 4305) +#endif #include +#ifdef _MSC_VER +#pragma warning(default : 4305) +#endif + #include #include #include From 56bd77af4e9dee059f374b3ba32141f030c489f0 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 29 Aug 2018 15:51:09 +0200 Subject: [PATCH 12/24] cmake: enable parallel build on MSVC --- cmake_configure.cmake | 4 ++++ cmake_options.cmake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index e030c859..b466f73f 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -21,6 +21,10 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") "_SCL_SECURE_NO_WARNINGS" "_CRT_SECURE_NO_WARNINGS" ) + target_compile_options(rw_interface + INTERFACE + "/MP" + ) else() message(FATAL_ERROR "Unknown compiler ID: '${CMAKE_CXX_COMPILER_ID}'") endif() diff --git a/cmake_options.cmake b/cmake_options.cmake index 3d3fae67..2243b549 100644 --- a/cmake_options.cmake +++ b/cmake_options.cmake @@ -16,7 +16,7 @@ set(FILESYSTEM_LIBRARY "BOOST" CACHE STRING "Which filesystem library to use") set_property(CACHE FILESYSTEM_LIBRARY PROPERTY STRINGS "CXX17" "CXXTS" "BOOST") if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel") endif() option(CHECK_IWYU "Enable IncludeWhatYouUse (Analyze #includes in C and C++ source files)") From 564f6efeb5c92e3f30484b23d5bea6f098db0f40 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 29 Aug 2018 15:52:59 +0200 Subject: [PATCH 13/24] ctest+ci: enable parallel building --- cmake/ctest/build.ctest | 2 ++ cmake/ctest/configure_darwin.ctest | 1 + cmake/ctest/configure_linux.ctest | 7 +++++++ cmake/ctest/configure_windows.ctest | 1 + 4 files changed, 11 insertions(+) diff --git a/cmake/ctest/build.ctest b/cmake/ctest/build.ctest index 2b0f2ff3..4668357c 100644 --- a/cmake/ctest/build.ctest +++ b/cmake/ctest/build.ctest @@ -39,6 +39,7 @@ set(_ARGS_ONEVAL set(_ARGS_MULVAL CONFIGURE_EXTRA_OPTIONS + BUILD_EXTRA_FLAGS ) foreach(_ARG ${_ARGS_BOOL} ${_ARGS_ONEVAL} ${_ARGS_MULVAL}) @@ -186,6 +187,7 @@ ctest_configure( message(STATUS "Building...") ctest_build( CONFIGURATION "${_CTEST_BUILD_CONFIGURATION}" + FLAGS ${BUILD_EXTRA_FLAGS} NUMBER_ERRORS _NB_BUILD_ERRORS ) diff --git a/cmake/ctest/configure_darwin.ctest b/cmake/ctest/configure_darwin.ctest index 06f85549..00865283 100644 --- a/cmake/ctest/configure_darwin.ctest +++ b/cmake/ctest/configure_darwin.ctest @@ -5,6 +5,7 @@ else() set(DEBUG FALSE) endif() set(CONFIGURE_EXTRA_OPTIONS ";") +set(BUILD_EXTRA_FLAGS "") set(BUILD_TOOLS TRUE) set(BUILD_VIEWER TRUE) set(COVERAGE_COMMAND gcov) diff --git a/cmake/ctest/configure_linux.ctest b/cmake/ctest/configure_linux.ctest index 5f36959a..4dc0c3d3 100644 --- a/cmake/ctest/configure_linux.ctest +++ b/cmake/ctest/configure_linux.ctest @@ -5,6 +5,13 @@ else() set(DEBUG FALSE) endif() set(CONFIGURE_EXTRA_OPTIONS ";") +include(ProcessorCount) +ProcessorCount(CORES_COUNT) +set(BUILD_EXTRA_FLAGS "") +if(NOT CORES_COUNT EQUAL 0) + list(APPEND BUILD_EXTRA_FLAGS "-j${CORES_COUNT}") +endif() + set(BUILD_TOOLS TRUE) set(BUILD_VIEWER TRUE) set(COVERAGE_COMMAND gcov) diff --git a/cmake/ctest/configure_windows.ctest b/cmake/ctest/configure_windows.ctest index ff5c8ffa..e7cb76a7 100644 --- a/cmake/ctest/configure_windows.ctest +++ b/cmake/ctest/configure_windows.ctest @@ -23,6 +23,7 @@ else() endif() set(CONFIGURE_EXTRA_OPTIONS ";") +set(BUILD_EXTRA_FLAGS "") if(CONFIGURATION STREQUAL "Debug") set(DEBUG TRUE) From 0b8bc41fa75a44fa33b89ef36662474c5338d1f2 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 04:09:03 +0200 Subject: [PATCH 14/24] all: fix 'warning: missing braces around initializer' --- cmake_configure.cmake | 1 + rwcore/fonts/FontMapGta3.cpp | 10 +++++----- rwengine/src/ai/TrafficDirector.cpp | 6 ++++-- rwengine/src/objects/PickupObject.hpp | 5 +++-- rwengine/src/render/DebugDraw.cpp | 2 +- rwengine/src/render/GameRenderer.cpp | 10 +++++----- rwengine/src/render/MapRenderer.cpp | 4 ++-- rwengine/src/render/ObjectRenderer.cpp | 4 ++-- rwengine/src/render/TextRenderer.cpp | 14 +++++++------- rwengine/src/render/WaterRenderer.cpp | 4 ++-- rwgame/RWGame.cpp | 25 +++++++++++++------------ rwgame/states/DebugState.cpp | 6 +++--- rwviewer/ViewerWidget.cpp | 2 +- tests/test_LoaderIDE.cpp | 2 +- 14 files changed, 50 insertions(+), 45 deletions(-) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index b466f73f..1959d84c 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -13,6 +13,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang "-Wextra" "-Wdouble-promotion" "-Wpedantic" + "-Wmissing-braces" "$,-Wold-style-cast,>" ) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") diff --git a/rwcore/fonts/FontMapGta3.cpp b/rwcore/fonts/FontMapGta3.cpp index 6d3f5ebd..e3a28a7b 100644 --- a/rwcore/fonts/FontMapGta3.cpp +++ b/rwcore/fonts/FontMapGta3.cpp @@ -200,8 +200,8 @@ static const FontMap::gschar_unicode_map_t map_gta3_font_2_priv = { const FontMap fontmap_gta3_font_common({map_gta3_font_common}); -const std::array fontmaps_gta3_font = { - FontMap({map_gta3_font_common, map_gta3_font_0_priv}), - FontMap({map_gta3_font_common, map_gta3_font_1_priv}), - FontMap({map_gta3_font_common, map_gta3_font_2_priv}), -}; +const std::array fontmaps_gta3_font = {{ + FontMap{map_gta3_font_common, map_gta3_font_0_priv}, + FontMap{map_gta3_font_common, map_gta3_font_1_priv}, + FontMap{map_gta3_font_common, map_gta3_font_2_priv}, +}}; diff --git a/rwengine/src/ai/TrafficDirector.cpp b/rwengine/src/ai/TrafficDirector.cpp index 636d3956..e06cf078 100644 --- a/rwengine/src/ai/TrafficDirector.cpp +++ b/rwengine/src/ai/TrafficDirector.cpp @@ -142,8 +142,10 @@ std::vector TrafficDirector::populateNearby( peds.insert(peds.end(), group.cbegin(), group.cend()); // Vehicles for normal traffic @todo create correct vehicle list - static constexpr std::array cars = {90, 91, 92, 94, 95, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 116, 119, 128, 129, 130, 134, 135, 136, 138, 139, 144, 146}; + static constexpr std::array cars = {{ + 90, 91, 92, 94, 95, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 112, 116, 119, 128, 129, 130, 134, 135, 136, 138, 139, 144, 146 + }}; auto availablePedsNodes = findAvailableNodes(AIGraphNode::Pedestrian, camera, radius); diff --git a/rwengine/src/objects/PickupObject.hpp b/rwengine/src/objects/PickupObject.hpp index dabc4368..33ac6419 100644 --- a/rwengine/src/objects/PickupObject.hpp +++ b/rwengine/src/objects/PickupObject.hpp @@ -234,7 +234,7 @@ public: bool onPlayerTouch() override; }; -const static std::array bigNVeinyPickupsLocations = { +const static std::array bigNVeinyPickupsLocations = {{ glm::vec3(913.62219f, -155.13692f, 4.9699469f), glm::vec3(913.92401f, -124.12943f, 4.9692569f), glm::vec3(913.27899f, -93.524231f, 7.4325991f), @@ -340,7 +340,8 @@ const static std::array bigNVeinyPickupsLocations = { glm::vec3(1481.5685f, -701.30237f, 11.977908f), glm::vec3(1511.4004f, -696.83295f, 11.972709f), glm::vec3(1542.1796f, -695.61676f, 11.970441f), - glm::vec3(1570.3301f, -684.6239f, 11.969202f)}; + glm::vec3(1570.3301f, -684.6239f, 11.969202f), +}}; /** * @brief The BigNVeinyPickup class diff --git a/rwengine/src/render/DebugDraw.cpp b/rwengine/src/render/DebugDraw.cpp index 2c6256d5..5de26a95 100644 --- a/rwengine/src/render/DebugDraw.cpp +++ b/rwengine/src/render/DebugDraw.cpp @@ -68,7 +68,7 @@ void DebugDraw::flush(GameRenderer *renderer) { dbuff->addGeometry(lineBuff.get()); Renderer::DrawParameters dp; - dp.textures = {texture}; + dp.textures = {{texture}}; dp.ambient = 1.f; dp.colour = glm::u8vec4(255, 255, 255, 255); dp.start = 0; diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index fe9ed972..1e9a4d11 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -421,7 +421,7 @@ void GameRenderer::renderSplash(GameWorld* world, GLuint splashTexName, glm::u16 wdp.depthMode = DepthMode::OFF; wdp.blendMode = BlendMode::BLEND_ALPHA; wdp.count = ssRectGeom.getCount(); - wdp.textures = {splashTexName}; + wdp.textures = {{splashTexName}}; renderer->drawArrays(glm::mat4(1.0f), &ssRectDraw, wdp); } @@ -437,7 +437,7 @@ void GameRenderer::renderPostProcess() { Renderer::DrawParameters wdp; wdp.start = 0; wdp.count = ssRectGeom.getCount(); - wdp.textures = {fbTextures[0]}; + wdp.textures = {{fbTextures[0]}}; wdp.depthMode = DepthMode::OFF; renderer->drawArrays(glm::mat4(1.0f), &ssRectDraw, wdp); @@ -488,7 +488,7 @@ void GameRenderer::renderEffects(GameWorld* world) { glm::vec3(particle->size,1.0f)) * glm::inverse(lookMat); Renderer::DrawParameters dp; - dp.textures = {particle->texture->getName()}; + dp.textures = {{particle->texture->getName()}}; dp.ambient = 1.f; dp.colour = glm::u8vec4(particle->colour * 255.f); dp.start = 0; @@ -529,7 +529,7 @@ void GameRenderer::drawRect(const glm::vec4& colour, TextureData* texture, glm:: wdp.depthMode = DepthMode::OFF; wdp.blendMode = BlendMode::BLEND_ALPHA; wdp.count = ssRectGeom.getCount(); - wdp.textures = {texture ? texture->getName() : 0}; + wdp.textures = {{texture ? texture->getName() : 0}}; renderer->drawArrays(glm::mat4(1.0f), &ssRectDraw, wdp); } @@ -544,7 +544,7 @@ void GameRenderer::renderLetterbox() { wdp.depthMode = DepthMode::OFF; wdp.blendMode = BlendMode::BLEND_NONE; wdp.count = ssRectGeom.getCount(); - wdp.textures = {0}; + wdp.textures = {{0}}; renderer->drawArrays(glm::mat4(1.0f), &ssRectDraw, wdp); renderer->setUniform(ssRectProg.get(), "offset", glm::vec2{0.f, 1.f * (1.f - cinematicExperienceSize)}); diff --git a/rwengine/src/render/MapRenderer.cpp b/rwengine/src/render/MapRenderer.cpp index d7a73715..58bb061e 100644 --- a/rwengine/src/render/MapRenderer.cpp +++ b/rwengine/src/render/MapRenderer.cpp @@ -125,7 +125,7 @@ void MapRenderer::draw(GameWorld* world, const MapInfo& mi) { std::string num = (m < 10 ? "0" : ""); std::string name = "radar" + num + std::to_string(m); auto texture = world->data->findSlotTexture(name, name); - dp.textures = {texture->getName()}; + dp.textures = {{texture->getName()}}; dp.count = 4; @@ -152,7 +152,7 @@ void MapRenderer::draw(GameWorld* world, const MapInfo& mi) { glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ONE, GL_ZERO); TextureData::Handle radarDisc = data->findSlotTexture("hud", "radardisc"); - dp.textures = {radarDisc->getName()}; + dp.textures = {{radarDisc->getName()}}; glm::mat4 model{1.0f}; model = glm::translate(model, glm::vec3(mi.screenPosition, 0.0f)); diff --git a/rwengine/src/render/ObjectRenderer.cpp b/rwengine/src/render/ObjectRenderer.cpp index 3c804052..7646ec0f 100644 --- a/rwengine/src/render/ObjectRenderer.cpp +++ b/rwengine/src/render/ObjectRenderer.cpp @@ -51,7 +51,7 @@ void ObjectRenderer::renderGeometry(Geometry* geom, dp.colour = {255, 255, 255, 255}; dp.count = subgeom.numIndices; dp.start = subgeom.start; - dp.textures = {0}; + dp.textures = {{0}}; dp.visibility = 1.f; if (object && object->type() == GameObject::Instance) { @@ -69,7 +69,7 @@ void ObjectRenderer::renderGeometry(Geometry* geom, if (tex->isTransparent()) { isTransparent = true; } - dp.textures = {tex->getName()}; + dp.textures = {{tex->getName()}}; } } diff --git a/rwengine/src/render/TextRenderer.cpp b/rwengine/src/render/TextRenderer.cpp index 5ded695f..bcf7ec01 100644 --- a/rwengine/src/render/TextRenderer.cpp +++ b/rwengine/src/render/TextRenderer.cpp @@ -70,7 +70,7 @@ void main() constexpr size_t GLYPHS_NB = 193; using FontWidthLut = std::array; -constexpr std::array fontWidthsPager = { +constexpr std::array fontWidthsPager = {{ 3, 3, 6, 8, 6, 10, 8, 3, 5, 5, 7, 0, 3, 7, 3, 0, // 1 6, 4, 6, 6, 7, 6, 6, 6, 6, 6, 3, 0, 0, 0, 0, 6, // 2 0, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 5, 8, 7, 6, // 3 @@ -84,9 +84,9 @@ constexpr std::array fontWidthsPager = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 11 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 12 8, -}; +}}; -constexpr std::array fontWidthsPriceDown = { +constexpr std::array fontWidthsPriceDown = {{ 11, 13, 30, 27, 20, 24, 22, 12, 14, 14, 0, 26, 9, 14, 9, 26, // 1 20, 19, 20, 20, 22, 20, 20, 19, 20, 20, 13, 29, 24, 29, 24, 20, // 2 27, 20, 20, 20, 20, 20, 17, 20, 20, 10, 20, 20, 15, 30, 20, 20, // 3 @@ -100,9 +100,9 @@ constexpr std::array fontWidthsPriceDown = { 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, // 11 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, // 12 16, -}; +}}; -constexpr std::array fontWidthsArial = { +constexpr std::array fontWidthsArial = {{ 27, 25, 55, 43, 47, 65, 53, 19, 29, 31, 21, 45, 23, 35, 27, 29, // 1 47, 33, 45, 43, 49, 47, 47, 41, 47, 45, 25, 23, 53, 43, 53, 39, // 2 61, 53, 51, 47, 49, 45, 43, 49, 53, 23, 41, 53, 45, 59, 53, 51, // 3 @@ -116,7 +116,7 @@ constexpr std::array fontWidthsArial = { 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 11, 19, 19, // 11 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, // 12 19, -}; +}}; } @@ -350,7 +350,7 @@ void TextRenderer::renderText(const TextRenderer::TextInfo& ti, dp.blendMode = BlendMode::BLEND_ALPHA; dp.count = gb.getCount(); auto ftexture = renderer->getData()->findSlotTexture("fonts", fontMetaData.textureName); - dp.textures = {ftexture->getName()}; + dp.textures = {{ftexture->getName()}}; dp.depthMode = DepthMode::OFF; renderer->getRenderer()->drawArrays(glm::mat4(1.0f), &db, dp); diff --git a/rwengine/src/render/WaterRenderer.cpp b/rwengine/src/render/WaterRenderer.cpp index 0992f7b7..b9b5162f 100644 --- a/rwengine/src/render/WaterRenderer.cpp +++ b/rwengine/src/render/WaterRenderer.cpp @@ -112,7 +112,7 @@ void WaterRenderer::render(GameRenderer* renderer, GameWorld* world) { Renderer::DrawParameters wdp; wdp.start = 0; wdp.count = maskGeom.getCount(); - wdp.textures = {0}; + wdp.textures = {{0}}; glm::mat4 m(1.0); glEnable(GL_STENCIL_TEST); @@ -147,7 +147,7 @@ void WaterRenderer::render(GameRenderer* renderer, GameWorld* world) { r->setUniform(waterProg.get(), "inverseVP", ivp); wdp.count = gridGeom.getCount(); - wdp.textures = {waterTex->getName(), dataTexture}; + wdp.textures = {{waterTex->getName(), dataTexture}}; r->drawArrays(m, &gridDraw, wdp); diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 8b142d77..e0fa068e 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -211,18 +211,19 @@ void RWGame::handleCheatInput(char symbol) { }); checkForCheat("GUNSGUNSGUNS", [&] { - constexpr std::array ammo = {1, //baseball bat - 100,//pistol - 100,//uzi - 20, //shotgun - 5, //grenade - 5, //molotov - 5, //rocket launcher - 20, //flamethrower - 200,//ak47 - 200,//m16 - 5 //sniper rifle - }; + constexpr std::array ammo = {{ + 1, //baseball bat + 100,//pistol + 100,//uzi + 20, //shotgun + 5, //grenade + 5, //molotov + 5, //rocket launcher + 20, //flamethrower + 200,//ak47 + 200,//m16 + 5 //sniper rifle + }}; for (std::array::size_type i = 0; i < ammo.size(); i++) player->addToInventory(static_cast(i+1),ammo[i]); state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats. diff --git a/rwgame/states/DebugState.cpp b/rwgame/states/DebugState.cpp index 397bffc1..261e34b7 100644 --- a/rwgame/states/DebugState.cpp +++ b/rwgame/states/DebugState.cpp @@ -214,7 +214,7 @@ std::shared_ptr DebugState::createWeatherMenu() { Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}}, kDebugFont, kDebugEntryHeight); - const std::array w{"Sunny", "Cloudy", "Rainy", "Foggy"}; + const std::array w{{"Sunny", "Cloudy", "Rainy", "Foggy"}}; for (std::size_t i = 0; i < w.size(); ++i) { menu->lambda(w[i], @@ -230,7 +230,7 @@ std::shared_ptr DebugState::createMissionsMenu() { Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}}, kDebugFont, kDebugEntryHeightMissions); - const std::array w{ + const std::array w{{ "Intro Movie", "Hospital Info Scene", "Police Station Info Scene", @@ -311,7 +311,7 @@ std::shared_ptr DebugState::createMissionsMenu() { "Bullion Run", "Rumble", "The Exchange", - }; + }}; for (std::size_t i = 0; i < w.size(); ++i) { menu->lambda(w[i], [=] { diff --git a/rwviewer/ViewerWidget.cpp b/rwviewer/ViewerWidget.cpp index 6ba5ea20..c34e7a6a 100644 --- a/rwviewer/ViewerWidget.cpp +++ b/rwviewer/ViewerWidget.cpp @@ -183,7 +183,7 @@ void ViewerWidget::drawFrameWidget(ModelFrame* f, const glm::mat4& m) { dp.colour = {255, 255, 255, 255}; glLineWidth(1.f); } - dp.textures = {whiteTex}; + dp.textures = {{whiteTex}}; RW_CHECK(_renderer != nullptr, "GameRenderer is null"); if(_renderer != nullptr) { diff --git a/tests/test_LoaderIDE.cpp b/tests/test_LoaderIDE.cpp index dc7cb27a..fdaa6aba 100644 --- a/tests/test_LoaderIDE.cpp +++ b/tests/test_LoaderIDE.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(objects_contains_modelID) { BOOST_AUTO_TEST_CASE(instance_data_is_correct) { loader.load(test_data_stream, {}); - ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {220.f}, 0); + ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {{220.f}}, 0); } BOOST_AUTO_TEST_CASE(vehicle_data_is_correct) { From 9189a028604d63c7708cb3524419c0d61a0995ad Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 04:39:39 +0200 Subject: [PATCH 15/24] rwengine: remove unused private field --- rwengine/src/ai/PlayerController.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/rwengine/src/ai/PlayerController.hpp b/rwengine/src/ai/PlayerController.hpp index a523883a..23eb4b58 100644 --- a/rwengine/src/ai/PlayerController.hpp +++ b/rwengine/src/ai/PlayerController.hpp @@ -11,8 +11,6 @@ private: glm::vec3 direction{}; - glm::quat lastRotation = glm::vec3(0.f, 0.f, 0.f); - bool missionRestartRequired = false; bool adrenalineEffect = false; From f08dffdb4170c1dcedf865b54a2e70e9098afbd9 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 05:15:58 +0200 Subject: [PATCH 16/24] cmake: fix 'XXX.o has no symbols' --- cmake_configure.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index 1959d84c..7d29c624 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -201,4 +201,12 @@ function(openrw_target_apply_options) CHECK_ALL ) endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + set_property( + TARGET "${OPENRW_APPLY_TARGET}" + APPEND + PROPERTY STATIC_LIBRARY_FLAGS "-no_warning_for_no_symbols" + ) + endif() endfunction() From e873f826fc99a8468c81be0f2bdbbc3585b29c1e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 14:48:52 +0200 Subject: [PATCH 17/24] rwengine: remove errorTexture from Game- and ObjectRenderer --- rwengine/src/render/GameRenderer.cpp | 16 ++-------------- rwengine/src/render/GameRenderer.hpp | 7 ------- rwengine/src/render/ObjectRenderer.hpp | 7 ++----- rwviewer/ViewerWidget.cpp | 4 ++-- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index 1e9a4d11..d40732e9 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -25,12 +25,7 @@ #include "render/GameShaders.hpp" #include "render/VisualFX.hpp" -const size_t skydomeSegments = 8, skydomeRows = 10; -constexpr uint32_t kMissingTextureBytes[] = { - 0xFF0000FF, 0xFFFF00FF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF00FF, 0xFF0000FF, - 0xFFFF00FF, 0xFF0000FF, 0xFF0000FF, 0xFFFF00FF, 0xFF0000FF, 0xFFFF00FF, - 0xFFFF00FF, 0xFF0000FF, 0xFFFF00FF, 0xFF0000FF, -}; +constexpr size_t skydomeSegments = 8, skydomeRows = 10; /// @todo collapse all of these into "VertPNC" etc. struct ParticleVert { @@ -80,13 +75,6 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data) glGenVertexArrays(1, &vao); - glGenTextures(1, &m_missingTexture); - glBindTexture(GL_TEXTURE_2D, m_missingTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, - kMissingTextureBytes); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glGenFramebuffers(1, &framebufferName); glBindFramebuffer(GL_FRAMEBUFFER, framebufferName); glGenTextures(2, fbTextures); @@ -329,7 +317,7 @@ RenderList GameRenderer::createObjectRenderList(const GameWorld *world) { ObjectRenderer objectRenderer(_renderWorld, (cullOverride ? cullingCamera : _camera), - _renderAlpha, getMissingTexture()); + _renderAlpha); // World Objects for (auto object : world->allObjects) { diff --git a/rwengine/src/render/GameRenderer.hpp b/rwengine/src/render/GameRenderer.hpp index e2550bf0..d1888b74 100644 --- a/rwengine/src/render/GameRenderer.hpp +++ b/rwengine/src/render/GameRenderer.hpp @@ -59,9 +59,6 @@ class GameRenderer { GLuint fbRenderBuffers[1]; std::unique_ptr postProg; - /// Texture used to replace textures missing from the data - GLuint m_missingTexture; - GeometryBuffer particleGeom; DrawBuffer particleDraw; @@ -88,10 +85,6 @@ public: return data; } - GLuint getMissingTexture() const { - return m_missingTexture; - } - size_t getCulledCount() { return culled; } diff --git a/rwengine/src/render/ObjectRenderer.hpp b/rwengine/src/render/ObjectRenderer.hpp index 36cbec0c..0b15be52 100644 --- a/rwengine/src/render/ObjectRenderer.hpp +++ b/rwengine/src/render/ObjectRenderer.hpp @@ -35,11 +35,10 @@ struct Geometry; class ObjectRenderer { public: ObjectRenderer(GameWorld* world, const ViewCamera& camera, - float renderAlpha, GLuint errorTexture) + float renderAlpha) : m_world(world) , m_camera(camera) - , m_renderAlpha(renderAlpha) - , m_errorTexture(errorTexture) { + , m_renderAlpha(renderAlpha) { } /** @@ -69,12 +68,10 @@ public: * @param render */ void renderClump(Clump* model, const glm::mat4& worldtransform, GameObject* object, RenderList& render); - private: GameWorld* m_world; const ViewCamera& m_camera; float m_renderAlpha; - GLuint m_errorTexture; void renderInstance(InstanceObject* instance, RenderList& outList); void renderCharacter(CharacterObject* pedestrian, RenderList& outList); diff --git a/rwviewer/ViewerWidget.cpp b/rwviewer/ViewerWidget.cpp index c34e7a6a..b4337428 100644 --- a/rwviewer/ViewerWidget.cpp +++ b/rwviewer/ViewerWidget.cpp @@ -82,7 +82,7 @@ void ViewerWidget::drawModel(GameRenderer& r, ClumpPtr& model) { glm::vec4(0.f), 90.f, vc.frustum.far}); model->getFrame()->updateHierarchyTransform(); - ObjectRenderer _renderer(world(), vc, 1.f, 0); + ObjectRenderer _renderer(world(), vc, 1.f); RenderList renders; _renderer.renderClump(model.get(), glm::mat4(1.0f), nullptr, renders); r.getRenderer()->drawBatched(renders); @@ -103,7 +103,7 @@ void ViewerWidget::drawObject(GameRenderer &r, GameObject *object) { {proj, view, glm::vec4(0.15f), glm::vec4(0.7f), glm::vec4(1.f), glm::vec4(0.f), 90.f, vc.frustum.far}); - ObjectRenderer objectRenderer(world(), vc, 1.f, 0); + ObjectRenderer objectRenderer(world(), vc, 1.f); RenderList renders; objectRenderer.buildRenderList(object, renders); std::sort(renders.begin(), renders.end(), From fdaaef3923761735cf7303af36826d04269939c1 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 16:59:21 +0200 Subject: [PATCH 18/24] cmake: disable Visual Studio warning about missing PDB's during linking This warning displays while building OpenRW in Visual Studio 2017 IDE --- cmake_configure.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index 7d29c624..a2c16347 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -208,5 +208,11 @@ function(openrw_target_apply_options) APPEND PROPERTY STATIC_LIBRARY_FLAGS "-no_warning_for_no_symbols" ) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set_property( + TARGET "${OPENRW_APPLY_TARGET}" + APPEND + PROPERTY LINK_FLAGS "/ignore:4099" + ) endif() endfunction() From c73e5d514d1a1e9a4adc98ae83bfdb4fc00f03f1 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 1 Sep 2018 18:23:10 +0200 Subject: [PATCH 19/24] cmake+ci: install pdb's + enable on ci --- .appveyor.yml | 4 +--- cmake/ctest/build.ctest | 22 +++++++++++----------- cmake/ctest/configure_darwin.ctest | 6 +++--- cmake/ctest/configure_linux.ctest | 4 ++-- cmake/ctest/configure_windows.ctest | 8 +------- cmake_configure.cmake | 29 ++++++++++++++++++++++------- rwgame/CMakeLists.txt | 7 +++---- rwtools/rwfont/CMakeLists.txt | 5 +++-- rwviewer/CMakeLists.txt | 7 +++---- tests/CMakeLists.txt | 9 ++++----- 10 files changed, 53 insertions(+), 48 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 38a70e0b..3d4dbec2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,12 +17,10 @@ environment: USE_CONAN: 1 platform: -# - Win32 - x64 configuration: -# - Debug - - Release + - RelWithDebInfo matrix: fast_finish: false diff --git a/cmake/ctest/build.ctest b/cmake/ctest/build.ctest index 4668357c..f8c162a5 100644 --- a/cmake/ctest/build.ctest +++ b/cmake/ctest/build.ctest @@ -6,7 +6,7 @@ set(_ARGS_BOOL USE_CONAN - DEBUG + BUILD_TYPE CHECK_IWYU BUILD_TOOLS BUILD_VIEWER @@ -67,6 +67,12 @@ endif() message(STATUS "Starting test...") ctest_start("${MODEL_NAME}" ${_CTEST_START_EXTRA_ARGS}) +set(ALL_BUILD_TYPES Release Debug MinSizeRel RelWithDebInfo) +list(FIND ALL_BUILD_TYPES "${BUILD_TYPE}" BUILD_TYPE_INDEX) +if(BUILD_TYPE_INDEX EQUAL -1) + message(FATAL_ERROR "Unknown build type '${BUILD_TYPE}'") +endif() + if(USE_CONAN) find_program(CONAN_BIN NAMES conan @@ -109,7 +115,7 @@ if(USE_CONAN) endif() endif() - if(DEBUG) + if(BUILD_TYPE STREQUAL "Debug") set(CONAN_CONFIGURATION "Debug") else() set(CONAN_CONFIGURATION "Release") @@ -149,15 +155,9 @@ if(USE_CONAN) endif() # CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore) -if(DEBUG) - set(_CMAKE_BUILD_TYPE "Debug") - set(_CTEST_BUILD_CONFIGURATION "Debug") - set(CTEST_CONFIGURATION_TYPE "Debug") -else() - set(_CMAKE_BUILD_TYPE "Release") - set(_CTEST_BUILD_CONFIGURATION "Release") - set(CTEST_CONFIGURATION_TYPE "Release") -endif() +set(_CMAKE_BUILD_TYPE "${BUILD_TYPE}") +set(_CTEST_BUILD_CONFIGURATION "${BUILD_TYPE}") +set(CTEST_CONFIGURATION_TYPE "${BUILD_TYPE}") set(_CONFIGURE_OPTIONS "-DBUILD_TOOLS=${BUILD_TOOLS}" diff --git a/cmake/ctest/configure_darwin.ctest b/cmake/ctest/configure_darwin.ctest index 00865283..bb16d966 100644 --- a/cmake/ctest/configure_darwin.ctest +++ b/cmake/ctest/configure_darwin.ctest @@ -1,8 +1,8 @@ set(CMAKE_GENERATOR "Xcode") -if(ENV{DEBUG}) - set(DEBUG "$ENV{DEBUG}") +if($ENV{DEBUG}) + set(BUILD_TYPE "Debug") else() - set(DEBUG FALSE) + set(BUILD_TYPE "Release") endif() set(CONFIGURE_EXTRA_OPTIONS ";") set(BUILD_EXTRA_FLAGS "") diff --git a/cmake/ctest/configure_linux.ctest b/cmake/ctest/configure_linux.ctest index 4dc0c3d3..ca31df27 100644 --- a/cmake/ctest/configure_linux.ctest +++ b/cmake/ctest/configure_linux.ctest @@ -1,8 +1,8 @@ set(CMAKE_GENERATOR "Unix Makefiles") if($ENV{DEBUG}) - set(DEBUG "$ENV{DEBUG}") + set(BUILD_TYPE "Debug") else() - set(DEBUG FALSE) + set(BUILD_TYPE "Release") endif() set(CONFIGURE_EXTRA_OPTIONS ";") include(ProcessorCount) diff --git a/cmake/ctest/configure_windows.ctest b/cmake/ctest/configure_windows.ctest index e7cb76a7..a36cd8fe 100644 --- a/cmake/ctest/configure_windows.ctest +++ b/cmake/ctest/configure_windows.ctest @@ -25,13 +25,7 @@ endif() set(CONFIGURE_EXTRA_OPTIONS ";") set(BUILD_EXTRA_FLAGS "") -if(CONFIGURATION STREQUAL "Debug") - set(DEBUG TRUE) -elseif(CONFIGURATION STREQUAL "Release") - set(DEBUG FALSE) -else() - message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'") -endif() +set(BUILD_TYPE "${CONFIGURATION}") set(CONAN_ARCH "x86_64") diff --git a/cmake_configure.cmake b/cmake_configure.cmake index a2c16347..0ed510af 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -181,13 +181,11 @@ foreach(SAN ${ENABLE_SANITIZERS}) endif() endforeach() -include(CMakeParseArguments) - function(openrw_target_apply_options) set(IWYU_MAPPING "${PROJECT_SOURCE_DIR}/openrw_iwyu.imp") - cmake_parse_arguments("OPENRW_APPLY" "" "TARGET" "" ${ARGN}) + cmake_parse_arguments("ORW" "INSTALL;INSTALL_PDB" "TARGET" "" ${ARGN}) if(CHECK_IWYU) - iwyu_check(TARGET "${OPENRW_APPLY_TARGET}" + iwyu_check(TARGET "${ORW_TARGET}" EXTRA_OPTS "--mapping_file=${IWYU_MAPPING}" ) @@ -195,7 +193,7 @@ function(openrw_target_apply_options) if(CHECK_CLANGTIDY) clang_tidy_check_target( - TARGET "${OPENRW_APPLY_TARGET}" + TARGET "${ORW_TARGET}" FORMAT_STYLE "file" FIX "${CHECK_CLANGTIDY_FIX}" CHECK_ALL @@ -204,15 +202,32 @@ function(openrw_target_apply_options) if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set_property( - TARGET "${OPENRW_APPLY_TARGET}" + TARGET "${ORW_TARGET}" APPEND PROPERTY STATIC_LIBRARY_FLAGS "-no_warning_for_no_symbols" ) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set_property( - TARGET "${OPENRW_APPLY_TARGET}" + TARGET "${ORW_TARGET}" APPEND PROPERTY LINK_FLAGS "/ignore:4099" ) endif() + + if(ORW_INSTALL) + install( + TARGETS "${ORW_TARGET}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) + endif() + if(ORW_INSTALL_PDB) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + install(FILES "$<$,$>:$>" + DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + endif() + endif() + endfunction() diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index a1125c28..2b6a3fc2 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -61,8 +61,7 @@ target_link_libraries(rwgame SDL2::SDL2 ) -openrw_target_apply_options(TARGET rwgame) - -install(TARGETS rwgame - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +openrw_target_apply_options( + TARGET rwgame + INSTALL INSTALL_PDB ) diff --git a/rwtools/rwfont/CMakeLists.txt b/rwtools/rwfont/CMakeLists.txt index 35e9404b..7494258b 100644 --- a/rwtools/rwfont/CMakeLists.txt +++ b/rwtools/rwfont/CMakeLists.txt @@ -11,6 +11,7 @@ target_link_libraries(rwfontmap Qt5::Gui ) -install(TARGETS rwfontmap - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +openrw_target_apply_options( + TARGET rwfontmap + INSTALL INSTALL_PDB ) diff --git a/rwviewer/CMakeLists.txt b/rwviewer/CMakeLists.txt index 5b4e3f1d..0e4490b1 100644 --- a/rwviewer/CMakeLists.txt +++ b/rwviewer/CMakeLists.txt @@ -54,10 +54,9 @@ target_link_libraries(rwviewer Qt5::Widgets ) -openrw_target_apply_options(TARGET rwviewer) - -install(TARGETS rwviewer - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +openrw_target_apply_options( + TARGET rwviewer + INSTALL INSTALL_PDB ) if(USE_CONAN) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7d362e79..b91bdaf1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -76,7 +76,10 @@ target_link_libraries(rwtests Boost::filesystem ) -openrw_target_apply_options(TARGET rwtests) +openrw_target_apply_options( + TARGET rwtests + INSTALL INSTALL_PDB + ) if(SEPARATE_TEST_SUITES) foreach(TEST ${TESTS}) @@ -98,7 +101,3 @@ else() TIMEOUT 300 ) endif() - -install(TARGETS rwtests - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - ) From 0e519d7295bf2dbdc0310637e3d8819f22268807 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 23 Aug 2018 15:23:43 +0200 Subject: [PATCH 20/24] cmake: split cmake in interface + check interface External projects do not need boost, glm or bullet specific options. Though, we do want to enable sanitizers and coverage on them. --- cmake_configure.cmake | 26 +++++++++++++++----------- external/microprofile/CMakeLists.txt | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index 0ed510af..21136abe 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -1,6 +1,10 @@ add_library(rw_interface INTERFACE) add_library(openrw::interface ALIAS rw_interface) +add_library(rw_checks INTERFACE) +add_library(openrw::checks ALIAS rw_checks) +target_link_libraries(rw_interface INTERFACE rw_checks) + # target_compile_features(rw_interface INTERFACE cxx_std_14) is not supported by CMake 3.2 set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 14) @@ -17,7 +21,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang "$,-Wold-style-cast,>" ) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_definitions(rw_interface + target_compile_definitions(rw_checks INTERFACE "_SCL_SECURE_NO_WARNINGS" "_CRT_SECURE_NO_WARNINGS" @@ -147,13 +151,13 @@ if(TEST_COVERAGE) message("TEST_COVERAGE enabled. Enabling BUILD_TESTS.") set(BUILD_TESTS "ON") endif() - target_compile_options(rw_interface + target_compile_options(rw_checks INTERFACE "-O0" "-fprofile-arcs" "-ftest-coverage" ) - target_link_libraries(rw_interface + target_link_libraries(rw_checks INTERFACE gcov ) @@ -162,20 +166,20 @@ endif() foreach(SAN ${ENABLE_SANITIZERS}) if(SAN STREQUAL "address") message(STATUS "Address sanitizer enabled.") - target_compile_options(rw_interface INTERFACE "-fsanitize=address") - target_link_libraries(rw_interface INTERFACE "-fsanitize=address") + target_compile_options(rw_checks INTERFACE "-fsanitize=address") + target_link_libraries(rw_checks INTERFACE "-fsanitize=address") elseif(SAN STREQUAL "leak") message(STATUS "Leak sanitizer enabled.") - target_compile_options(rw_interface INTERFACE "-fsanitize=leak") - target_link_libraries(rw_interface INTERFACE "-fsanitize=leak") + target_compile_options(rw_checks INTERFACE "-fsanitize=leak") + target_link_libraries(rw_checks INTERFACE "-fsanitize=leak") elseif(SAN STREQUAL "thread") message(STATUS "Thread sanitizer enabled.") - target_compile_options(rw_interface INTERFACE "-fsanitize=thread") - target_link_libraries(rw_interface INTERFACE "-fsanitize=thread") + target_compile_options(rw_checks INTERFACE "-fsanitize=thread") + target_link_libraries(rw_checks INTERFACE "-fsanitize=thread") elseif(SAN STREQUAL "undefined") message(STATUS "Undefined behaviour sanitizer enabled.") - target_compile_options(rw_interface INTERFACE "-fsanitize=undefined") - target_link_libraries(rw_interface INTERFACE "-fsanitize=undefined") + target_compile_options(rw_checks INTERFACE "-fsanitize=undefined") + target_link_libraries(rw_checks INTERFACE "-fsanitize=undefined") else() message(FATAL_ERROR "Illegal sanitizer: ${SAN}") endif() diff --git a/external/microprofile/CMakeLists.txt b/external/microprofile/CMakeLists.txt index 3552df52..ab138f65 100644 --- a/external/microprofile/CMakeLists.txt +++ b/external/microprofile/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(Threads REQUIRED) target_link_libraries(microprofile PUBLIC Threads::Threads + openrw::checks ) add_library(microprofile::microprofile ALIAS microprofile) From 40575e79b69a3f60f996a42c1d2340a251a2dff2 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 15 Sep 2018 23:40:55 +0200 Subject: [PATCH 21/24] rwengine: pass const glm::vec's to constructors --- rwengine/src/engine/Garage.cpp | 4 ++-- rwengine/src/engine/Garage.hpp | 4 ++-- rwengine/src/engine/Payphone.cpp | 2 +- rwengine/src/engine/Payphone.hpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rwengine/src/engine/Garage.cpp b/rwengine/src/engine/Garage.cpp index 28974e3a..aa3dd222 100644 --- a/rwengine/src/engine/Garage.cpp +++ b/rwengine/src/engine/Garage.cpp @@ -21,8 +21,8 @@ #include "objects/InstanceObject.hpp" #include "objects/VehicleObject.hpp" -Garage::Garage(GameWorld* engine_, size_t id_, glm::vec3 coord0, - glm::vec3 coord1, Type type_) +Garage::Garage(GameWorld* engine_, size_t id_, const glm::vec3& coord0, + const glm::vec3& coord1, Type type_) : engine(engine_), id(id_), type(type_) { min.x = std::min(coord0.x, coord1.x); min.y = std::min(coord0.y, coord1.y); diff --git a/rwengine/src/engine/Garage.hpp b/rwengine/src/engine/Garage.hpp index 38b0b86c..6d29a6a0 100644 --- a/rwengine/src/engine/Garage.hpp +++ b/rwengine/src/engine/Garage.hpp @@ -91,8 +91,8 @@ public: bool resprayDone = false; - Garage(GameWorld* engine_, size_t id_, glm::vec3 coord0, - glm::vec3 coord1, Type type_); + Garage(GameWorld* engine_, size_t id_, const glm::vec3& coord0, + const glm::vec3& coord1, Type type_); ~Garage() = default; void makeDoorSwing(); diff --git a/rwengine/src/engine/Payphone.cpp b/rwengine/src/engine/Payphone.cpp index 4215566b..f459502a 100644 --- a/rwengine/src/engine/Payphone.cpp +++ b/rwengine/src/engine/Payphone.cpp @@ -11,7 +11,7 @@ #include "objects/GameObject.hpp" #include "objects/InstanceObject.hpp" -Payphone::Payphone(GameWorld* engine_, size_t id_, glm::vec2 coord) +Payphone::Payphone(GameWorld* engine_, size_t id_, const glm::vec2& coord) : engine(engine_), id(id_) { // Find payphone object, original game does this differently for (const auto& p : engine->instancePool.objects) { diff --git a/rwengine/src/engine/Payphone.hpp b/rwengine/src/engine/Payphone.hpp index 7dc6d190..5c49edf4 100644 --- a/rwengine/src/engine/Payphone.hpp +++ b/rwengine/src/engine/Payphone.hpp @@ -32,7 +32,7 @@ public: return id; } - Payphone(GameWorld* engine_, size_t id_, glm::vec2 coord); + Payphone(GameWorld* engine_, size_t id_, const glm::vec2& coord); ~Payphone() = default; // Makes a payphone ring @@ -46,4 +46,4 @@ public: void tick(float dt); }; -#endif \ No newline at end of file +#endif From d06d4fc264e3b5cae04ab5f638cba3261053a577 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 15 Sep 2018 23:41:57 +0200 Subject: [PATCH 22/24] rwengine: use applyOffset --- rwengine/src/ai/TrafficDirector.cpp | 6 ++---- rwengine/src/objects/PickupObject.hpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/rwengine/src/ai/TrafficDirector.cpp b/rwengine/src/ai/TrafficDirector.cpp index e06cf078..45dd3acf 100644 --- a/rwengine/src/ai/TrafficDirector.cpp +++ b/rwengine/src/ai/TrafficDirector.cpp @@ -152,7 +152,6 @@ std::vector TrafficDirector::populateNearby( // We have not reached the limit of spawned pedestrians if (maximumPedestrians > world->pedestrianPool.objects.size()) { const auto availablePeds = maximumPedestrians - world->pedestrianPool.objects.size(); - static const glm::vec3 kSpawnOffset{0.f, 0.f, 1.f}; size_t counter = availablePeds; // maxSpawn can be -1 for "as many as possible" @@ -172,8 +171,8 @@ std::vector TrafficDirector::populateNearby( // Spawn a pedestrian from the available pool const auto pedId = static_cast( peds[std::uniform_int_distribution(0, peds.size() - 1)(random)]); - auto ped = world->createPedestrian(pedId, - spawn->position + kSpawnOffset); + auto ped = world->createPedestrian(pedId, spawn->position); + ped->applyOffset(); ped->setLifetime(GameObject::TrafficLifetime); ped->controller->setGoal(CharacterController::TrafficWander); created.push_back(ped); @@ -185,7 +184,6 @@ std::vector TrafficDirector::populateNearby( // We have not reached the limit of spawned vehicles if (maximumCars > world->vehiclePool.objects.size()) { const auto availableCars = maximumCars - world->vehiclePool.objects.size(); - static const glm::vec3 kSpawnOffset{0.f, 0.f, 1.f}; size_t counter = availableCars; // maxSpawn can be -1 for "as many as possible" diff --git a/rwengine/src/objects/PickupObject.hpp b/rwengine/src/objects/PickupObject.hpp index 33ac6419..68f4c4f1 100644 --- a/rwengine/src/objects/PickupObject.hpp +++ b/rwengine/src/objects/PickupObject.hpp @@ -234,7 +234,7 @@ public: bool onPlayerTouch() override; }; -const static std::array bigNVeinyPickupsLocations = {{ +constexpr static std::array bigNVeinyPickupsLocations = {{ glm::vec3(913.62219f, -155.13692f, 4.9699469f), glm::vec3(913.92401f, -124.12943f, 4.9692569f), glm::vec3(913.27899f, -93.524231f, 7.4325991f), From d1cb0f143c2eb6494806941f6fbb75d2493b72eb Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 16 Sep 2018 00:28:17 +0200 Subject: [PATCH 23/24] cmake: detect glm version --- cmake/modules/FindGLM.cmake | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake index 03171b21..43e2e3fb 100644 --- a/cmake/modules/FindGLM.cmake +++ b/cmake/modules/FindGLM.cmake @@ -52,14 +52,24 @@ endif() find_path(GLM_INCLUDE_DIR "glm/glm.hpp" PATHS ${_glm_HEADER_SEARCH_DIRS}) +if(GLM_INCLUDE_DIR) + file(READ "${GLM_INCLUDE_DIR}/glm/detail/setup.hpp" _GLM_SETUP_HPP) + string(REGEX MATCH "GLM: version ([0-9a-zA-Z\.\-]+)" _GLM_VERSION "${_GLM_SETUP_HPP}") + if(NOT _GLM_VERSION) + message(AUTHOR_WARNING "Cannot detect GLM version: regex does not match") + endif() + set(GLM_VERSION "${CMAKE_MATCH_1}") +endif() + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLM DEFAULT_MSG - GLM_INCLUDE_DIR) +find_package_handle_standard_args(GLM + FOUND_VAR GLM_FOUND + REQUIRED_VARS GLM_INCLUDE_DIR + VERSION_VAR GLM_VERSION + ) if(GLM_FOUND) - set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - add_library(glm INTERFACE) - target_include_directories(glm SYSTEM - INTERFACE "${GLM_INCLUDE_DIR}") - add_library(glm::glm ALIAS glm) + add_library(glm::glm INTERFACE IMPORTED) + set_property(TARGET glm::glm + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GLM_INCLUDE_DIR}) endif() From 0923ecad8dbc36824bb92d8f9783344ffd40ce56 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 16 Sep 2018 00:49:10 +0200 Subject: [PATCH 24/24] cmake: disable SIMD for glm to enable constexpr for glm types --- cmake_configure.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_configure.cmake b/cmake_configure.cmake index 21136abe..139d803f 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -63,6 +63,7 @@ endif() target_compile_definitions(rw_interface INTERFACE "$<$:RW_DEBUG>" + "GLM_FORCE_PURE" "GLM_FORCE_RADIANS" "GLM_ENABLE_EXPERIMENTAL" "$<$:RW_VERBOSE_DEBUG_MESSAGES>"