1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

rwengine: fix Visual Studio warnings

This commit is contained in:
Anonymous Maarten 2018-08-29 23:43:43 +02:00
parent 8557f2176d
commit 05896caac5
37 changed files with 108 additions and 109 deletions

View File

@ -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<std::uint32_t>(nodes.size());
std::vector<AIGraphNode*> 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<std::size_t>((gridcoord.x * WORLD_GRID_WIDTH) + gridcoord.y);
gridNodes[index].push_back(ainode);
}
}

View File

@ -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<std::size_t>(0, potentialNodes.size() - 1)(random);
nextTargetNode = potentialNodes.at(i);
}

View File

@ -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<size_t> d(
0, lastTarget->connections.size() - 1);
targetNode = lastTarget->connections.at(d(re));
setNextActivity(std::make_unique<Activities::GoTo>(
@ -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<size_t>(0, lastTargetNode->connections.size() - 1)(random);
targetNode = lastTargetNode->connections.at(nodeIndex);
}

View File

@ -97,12 +97,6 @@ std::vector<GameObject*> TrafficDirector::populateNearby(
auto& random = world->randomEngine;
std::vector<GameObject*> 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<GameObject*> 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<size_t>(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<std::uint16_t>(
peds[std::uniform_int_distribution<size_t>(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<GameObject*> 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<size_t>(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<GameObject*> TrafficDirector::populateNearby(
strafe * (2.5f + 5.f * static_cast<float>(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<std::uint16_t>(cars[std::uniform_int_distribution<std::size_t>(
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<std::size_t>(0, peds.size() - 1)(random)];
CharacterObject* character = world->createPedestrian(pedId, vehicle->getPosition());
character->setLifetime(GameObject::TrafficLifetime);
character->setCurrentVehicle(vehicle, 0);

View File

@ -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

View File

@ -70,7 +70,7 @@ struct Sound {
buffer->setMaxDistance(maxDist);
}
int getScriptObjectID() const {
size_t getScriptObjectID() const {
return id;
}
};

View File

@ -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<ALsizei>(soundSource.data.size() * sizeof(int16_t)),
soundSource.sampleRate));
alCheck(alSourcei(source, AL_BUFFER, buffer));

View File

@ -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<float>(maxDist));
}
buffer->second.play();
}

View File

@ -248,7 +248,7 @@ struct InputData {
/// to buffer.
static int read_packet(void* opaque, uint8_t* buf, int buf_size) {
auto* input = reinterpret_cast<InputData*>(opaque);
buf_size = FFMIN(buf_size, input->size);
buf_size = std::min(buf_size, static_cast<int>(input->size));
/* copy internal data to buf */
memcpy(buf, input->ptr, buf_size);
input->ptr += buf_size;

View File

@ -1,8 +1,10 @@
#ifndef _RWENGINE_SOUND_SOURCE_HPP_
#define _RWENGINE_SOUND_SOURCE_HPP_
#include <rw/filesystem.hpp>
#include <loaders/LoaderSDT.hpp>
#include <rw/filesystem.hpp>
#include <cstdint>
/// 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<int16_t> data;
size_t channels;
size_t sampleRate;
std::uint32_t channels;
std::uint32_t sampleRate;
};
#endif

View File

@ -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<size_t>(chaseTime * KEYFRAMES_PER_SECOND);
for (auto &it : chaseVehicles) {
RW_CHECK(frameNum < it.second.keyframes.size(),
"Vehicle out of chase keyframes");

View File

@ -53,7 +53,7 @@ struct VehicleGenerator {
, remainingSpawns(remainingSpawns_) {
}
int getScriptObjectID() const {
size_t getScriptObjectID() const {
return generatorID;
}
};

View File

@ -95,9 +95,12 @@ bool CollisionInstance::createPhysicsBody(GameObject* object,
auto& faces = collision->faces;
if (!verts.empty() && !faces.empty()) {
m_vertArray = std::make_unique<btTriangleIndexVertexArray>(
faces.size(), reinterpret_cast<int*>(faces.data()),
sizeof(CollisionModel::Triangle), verts.size(),
reinterpret_cast<float*>(verts.data()), sizeof(glm::vec3));
static_cast<int>(faces.size()),
reinterpret_cast<int*>(faces.data()),
static_cast<int>(sizeof(CollisionModel::Triangle)),
static_cast<int>(verts.size()),
reinterpret_cast<float*>(verts.data()),
static_cast<int>(sizeof(glm::vec3)));
auto trishape =
std::make_unique<btBvhTriangleMeshShape>(m_vertArray.get(), false);
trishape->setMargin(0.05f);

View File

@ -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<int> uniform(0, palit->second.size() - 1);
int set = uniform(randomEngine);
std::uniform_int_distribution<size_t> 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<Garage>(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<Payphone>(this, id, coord));
return payphones.back().get();
}

View File

@ -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);

View File

@ -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();

View File

@ -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) {

View File

@ -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

View File

@ -5,7 +5,7 @@
#include "fonts/FontMapGta3.hpp"
void ScreenText::tick(float dt) {
int millis = dt * 1000;
int millis = static_cast<int>(dt * 1000);
// Remove all the immedate text
m_textQueues[static_cast<size_t>(ScreenTextType::Immediate)].clear();

View File

@ -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<float>(weapon->damage);
owner->engine->doWeaponScan({dmg, fireOrigin, rayend, weapon});
}

View File

@ -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<float>((*colour >> 16) & 0xFF);
float green = static_cast<float>((*colour >> 8) & 0xFF);
float blue = static_cast<float>(*colour & 0xFF);
m_corona.colour =
glm::vec4(red / 255.f, green / 255.f, blue / 255.f, 1.f) * colourValue;

View File

@ -17,7 +17,7 @@ class BaseModelInfo;
class GameWorld;
class CharacterObject;
class VehicleObject;
class VisualFX;
struct VisualFX;
/**
* @brief The PickupObject class

View File

@ -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<float>(_info.weapon->damage);
for (auto& o : engine->allObjects) {
if (o == this) continue;

View File

@ -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;
}

View File

@ -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<GLuint>(r * segments + s);
skydomeIndBuff[i++] = static_cast<GLuint>(r * segments + (s + 1));
skydomeIndBuff[i++] = static_cast<GLuint>((r + 1) * segments + (s + 1));
skydomeIndBuff[i++] = static_cast<GLuint>(r * segments + s);
skydomeIndBuff[i++] = static_cast<GLuint>((r + 1) * segments + (s + 1));
skydomeIndBuff[i++] = static_cast<GLuint>((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<size_t>(world->allObjects.size() * 0.5f));
ObjectRenderer objectRenderer(_renderWorld,
(cullOverride ? cullingCamera : _camera),

View File

@ -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<int>(w));
// Construct our own matrix so we can use the local transform
vehicle->physVehicle->updateWheelTransform(w, false);
vehicle->physVehicle->updateWheelTransform(static_cast<int>(w), false);
bool isRhino = (vehicle->getVehicle()->vehiclename_ == "RHINO");
auto up = -wi.m_wheelDirectionCS;

View File

@ -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<GLsizei>(p.count),
GL_UNSIGNED_INT,
reinterpret_cast<void*>(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<GLint>(p.start), static_cast<GLsizei>(p.count));
}
void OpenGLRenderer::drawBatched(const RenderList& list) {

View File

@ -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

View File

@ -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<float>(index % TEXTURE_COLUMNS);
const float y = static_cast<float>(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) {

View File

@ -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;

View File

@ -49,7 +49,7 @@ WaterRenderer::WaterRenderer(GameRenderer* renderer) {
}
}
gridGeom.uploadVertices(grid.size(), sizeof(glm::vec2) * grid.size(),
gridGeom.uploadVertices(static_cast<GLsizei>(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<unsigned int>(sqrt(nTiles));
float tileSize = WATER_WORLD_SIZE / edgeNum;
glm::vec2 wO{-WATER_WORLD_SIZE / 2.f, -WATER_WORLD_SIZE / 2.f};
std::vector<glm::vec3> 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<GLsizei>(vertexData.size()),
sizeof(glm::vec3) * vertexData.size(),
vertexData.data());
maskGeom.getDataAttributes().emplace_back(ATRS_Position, 3, 0, 0, GL_FLOAT);

View File

@ -3,7 +3,7 @@
#include <algorithm>
#include <cstddef>
void SCMFile::loadFile(char *data, unsigned int size) {
void SCMFile::loadFile(char *data, size_t size) {
_data = std::make_unique<SCMByte[]>(size);
std::copy(data, data + size, _data.get());

View File

@ -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();

View File

@ -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<int>(dt * 1000.f);
for (auto t = _activeThreads.begin(); t != _activeThreads.end(); ++t) {
auto& thread = *t;
executeThread(thread, ms);

View File

@ -167,15 +167,14 @@ public:
template <typename T>
typename std::enable_if<std::is_integral<T>::value, T>::type
getRandomNumber(T min, T max) {
std::uniform_int_distribution<> dist(min, max);
std::uniform_int_distribution<T> dist(min, max);
return dist(randomNumberGen);
}
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
getRandomNumber(T min, T max) {
std::uniform_real_distribution<> dist(static_cast<double>(min),
static_cast<double>(max));
std::uniform_real_distribution<T> dist(min, max);
return dist(randomNumberGen);
}

View File

@ -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<ScriptInt>(object->getScriptObjectID());
m_object = object;
return object;
}

View File

@ -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<int>(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<int>(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