mirror of
https://github.com/rwengine/openrw.git
synced 2024-10-06 17:17:20 +02:00
Remove old style cast
This commit is contained in:
parent
844d1f89b3
commit
d95d05e291
@ -21,7 +21,8 @@ std::unique_ptr<TextureArchive> TextureArchive::create(
|
|||||||
|
|
||||||
// Struct
|
// Struct
|
||||||
section = section->next;
|
section = section->next;
|
||||||
textureArchive->numTextures = ((uint16_t *)section->data)[0];
|
textureArchive->numTextures =
|
||||||
|
reinterpret_cast<uint16_t *>(section->data)[0];
|
||||||
|
|
||||||
for (size_t i = 0; i < textureArchive->numTextures; i++) {
|
for (size_t i = 0; i < textureArchive->numTextures; i++) {
|
||||||
section = section->next; // Texture Native
|
section = section->next; // Texture Native
|
||||||
|
@ -79,7 +79,7 @@ void AIGraph::createPathNodes(const glm::vec3& position,
|
|||||||
|
|
||||||
for (size_t pn = 0; pn < path.nodes.size(); ++pn) {
|
for (size_t pn = 0; pn < path.nodes.size(); ++pn) {
|
||||||
if (path.nodes[pn].next >= 0 &&
|
if (path.nodes[pn].next >= 0 &&
|
||||||
(unsigned)path.nodes[pn].next < pathNodes.size()) {
|
static_cast<unsigned>(path.nodes[pn].next) < pathNodes.size()) {
|
||||||
auto node = pathNodes[pn];
|
auto node = pathNodes[pn];
|
||||||
auto next = pathNodes[path.nodes[pn].next];
|
auto next = pathNodes[path.nodes[pn].next];
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ void AIGraph::gatherExternalNodesNear(const glm::vec3& center,
|
|||||||
for (int x = minGrid.x; x <= maxGrid.x; ++x) {
|
for (int x = minGrid.x; x <= maxGrid.x; ++x) {
|
||||||
for (int y = minGrid.y; y <= maxGrid.y; ++y) {
|
for (int y = minGrid.y; y <= maxGrid.y; ++y) {
|
||||||
int i = (x * WORLD_GRID_WIDTH) + y;
|
int i = (x * WORLD_GRID_WIDTH) + y;
|
||||||
if (i < 0 || i >= (int)gridNodes.size()) {
|
if (i < 0 || i >= static_cast<int>(gridNodes.size())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto& external = gridNodes[i];
|
auto& external = gridNodes[i];
|
||||||
|
@ -201,13 +201,17 @@ bool CharacterController::checkForObstacles()
|
|||||||
// Try to stop before pedestrians
|
// Try to stop before pedestrians
|
||||||
for (const auto &obj : character->engine->pedestrianPool.objects) {
|
for (const auto &obj : character->engine->pedestrianPool.objects) {
|
||||||
// Verify that the character isn't the driver and is walking
|
// Verify that the character isn't the driver and is walking
|
||||||
if (obj.second != character && ((CharacterObject*)obj.second)->getCurrentVehicle() == nullptr) {
|
if (obj.second != character &&
|
||||||
|
static_cast<CharacterObject *>(obj.second)->getCurrentVehicle() ==
|
||||||
|
nullptr) {
|
||||||
// Only check characters that are near our vehicle
|
// Only check characters that are near our vehicle
|
||||||
if (glm::distance(vehicle->getPosition(), obj.second->getPosition()) <= minColDist) {
|
if (glm::distance(vehicle->getPosition(),
|
||||||
|
obj.second->getPosition()) <= minColDist) {
|
||||||
// Check if the character is in front of us and in our way
|
// Check if the character is in front of us and in our way
|
||||||
if ( vehicle->isInFront(obj.second->getPosition()) > -3.f
|
if (vehicle->isInFront(obj.second->getPosition()) > -3.f &&
|
||||||
&& vehicle->isInFront(obj.second->getPosition()) < 10.f
|
vehicle->isInFront(obj.second->getPosition()) < 10.f &&
|
||||||
&& glm::abs(vehicle->isOnSide(obj.second->getPosition())) < 3.f ) {
|
glm::abs(vehicle->isOnSide(obj.second->getPosition())) <
|
||||||
|
3.f) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,38 +223,46 @@ bool CharacterController::checkForObstacles()
|
|||||||
// Verify that the vehicle isn't our vehicle
|
// Verify that the vehicle isn't our vehicle
|
||||||
if (obj.second != vehicle) {
|
if (obj.second != vehicle) {
|
||||||
// Only check vehicles that are near our vehicle
|
// Only check vehicles that are near our vehicle
|
||||||
if (glm::distance(vehicle->getPosition(), obj.second->getPosition()) <= minColDist) {
|
if (glm::distance(vehicle->getPosition(),
|
||||||
|
obj.second->getPosition()) <= minColDist) {
|
||||||
// Check if the vehicle is in front of us and in our way
|
// Check if the vehicle is in front of us and in our way
|
||||||
if ( vehicle->isInFront(obj.second->getPosition()) > 0.f
|
if (vehicle->isInFront(obj.second->getPosition()) > 0.f &&
|
||||||
&& vehicle->isInFront(obj.second->getPosition()) < 10.f
|
vehicle->isInFront(obj.second->getPosition()) < 10.f &&
|
||||||
&& glm::abs(vehicle->isOnSide(obj.second->getPosition())) < 2.5f ) {
|
glm::abs(vehicle->isOnSide(obj.second->getPosition())) <
|
||||||
|
2.5f) {
|
||||||
// Check if the road has more than one lane
|
// Check if the road has more than one lane
|
||||||
// @todo we don't know the direction of the road, so for now, choose the bigger value
|
// @todo we don't know the direction of the road, so for
|
||||||
int maxLanes = targetNode->rightLanes > targetNode->leftLanes ?
|
// now, choose the bigger value
|
||||||
targetNode->rightLanes : targetNode->leftLanes;
|
int maxLanes =
|
||||||
|
targetNode->rightLanes > targetNode->leftLanes
|
||||||
|
? targetNode->rightLanes
|
||||||
|
: targetNode->leftLanes;
|
||||||
if (maxLanes > 1) {
|
if (maxLanes > 1) {
|
||||||
// Change the lane, firstly check if there is an occupant
|
// Change the lane, firstly check if there is an
|
||||||
if (((VehicleObject *)obj.second)->getDriver() !=
|
// occupant
|
||||||
nullptr) {
|
if (static_cast<VehicleObject *>(obj.second)
|
||||||
// @todo for now we don't know the lane where the player is currently driving
|
->getDriver() != nullptr) {
|
||||||
// so just slow down, in the future calculate the lane
|
// @todo for now we don't know the lane where the
|
||||||
if (((VehicleObject *)obj.second)
|
// player is currently driving so just slow down, in
|
||||||
|
// the future calculate the lane
|
||||||
|
if (static_cast<VehicleObject *>(obj.second)
|
||||||
->getDriver()
|
->getDriver()
|
||||||
->isPlayer()) {
|
->isPlayer()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
int avoidLane =
|
||||||
int avoidLane = ((VehicleObject *)obj.second)
|
static_cast<VehicleObject *>(obj.second)
|
||||||
->getDriver()
|
->getDriver()
|
||||||
->controller->getLane();
|
->controller->getLane();
|
||||||
|
|
||||||
// @todo for now just two lanes
|
// @todo for now just two lanes
|
||||||
if (avoidLane == 1) character->controller->setLane(2);
|
if (avoidLane == 1)
|
||||||
else character->controller->setLane(1);
|
character->controller->setLane(2);
|
||||||
|
else
|
||||||
|
character->controller->setLane(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,7 +682,7 @@ bool Activities::UseItem::update(CharacterObject *character,
|
|||||||
|
|
||||||
if (state.bulletsClip == 0 && state.bulletsTotal > 0) {
|
if (state.bulletsClip == 0 && state.bulletsTotal > 0) {
|
||||||
state.bulletsClip +=
|
state.bulletsClip +=
|
||||||
std::min(int(state.bulletsTotal), weapon->clipSize);
|
std::min(static_cast<int>(state.bulletsTotal), weapon->clipSize);
|
||||||
state.bulletsTotal -= state.bulletsClip;
|
state.bulletsTotal -= state.bulletsClip;
|
||||||
}
|
}
|
||||||
bool hasammo = state.bulletsClip > 0;
|
bool hasammo = state.bulletsClip > 0;
|
||||||
|
@ -43,21 +43,27 @@ bool ChaseKeyframe::load(const std::string &filePath,
|
|||||||
|
|
||||||
for (size_t i = 0; i < recordCount; ++i) {
|
for (size_t i = 0; i < recordCount; ++i) {
|
||||||
ChaseEntryRecord rec;
|
ChaseEntryRecord rec;
|
||||||
chaseFile.read((char *)&rec, sizeof(ChaseEntryRecord));
|
chaseFile.read(reinterpret_cast<char *>(&rec),
|
||||||
|
sizeof(ChaseEntryRecord));
|
||||||
glm::vec3 velocity{
|
glm::vec3 velocity{
|
||||||
rec.velocity[0] / 16383.5f, rec.velocity[1] / 16383.5f,
|
rec.velocity[0] / 16383.5f,
|
||||||
|
rec.velocity[1] / 16383.5f,
|
||||||
rec.velocity[2] / 16383.5f,
|
rec.velocity[2] / 16383.5f,
|
||||||
};
|
};
|
||||||
glm::vec3 right{
|
glm::vec3 right{
|
||||||
rec.right[0] / 127.5f, rec.right[1] / 127.5f, rec.right[2] / 127.5f,
|
rec.right[0] / 127.5f,
|
||||||
|
rec.right[1] / 127.5f,
|
||||||
|
rec.right[2] / 127.5f,
|
||||||
};
|
};
|
||||||
glm::vec3 up{
|
glm::vec3 up{
|
||||||
rec.up[0] / 127.5f, rec.up[1] / 127.5f, rec.up[2] / 127.5f,
|
rec.up[0] / 127.5f,
|
||||||
|
rec.up[1] / 127.5f,
|
||||||
|
rec.up[2] / 127.5f,
|
||||||
};
|
};
|
||||||
glm::mat3 rotation(right, up, glm::cross(right, up));
|
glm::mat3 rotation(right, up, glm::cross(right, up));
|
||||||
frames.emplace_back(velocity, rec.steering, rec.driving, rec.braking,
|
frames.emplace_back(velocity, rec.steering, rec.driving, rec.braking,
|
||||||
!!rec.handbrake, rec.position,
|
!!rec.handbrake, rec.position,
|
||||||
glm::quat_cast(rotation));
|
glm::quat_cast(rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,10 +110,10 @@ bool CollisionInstance::createPhysicsBody(GameObject* object,
|
|||||||
auto& faces = collision->faces;
|
auto& faces = collision->faces;
|
||||||
if (!verts.empty() && !faces.empty()) {
|
if (!verts.empty() && !faces.empty()) {
|
||||||
m_vertArray = new btTriangleIndexVertexArray(
|
m_vertArray = new btTriangleIndexVertexArray(
|
||||||
faces.size(), (int*)faces.data(), sizeof(CollisionModel::Triangle),
|
faces.size(), reinterpret_cast<int*>(faces.data()), sizeof(CollisionModel::Triangle),
|
||||||
verts.size(), (float*)verts.data(), sizeof(glm::vec3));
|
verts.size(), reinterpret_cast<float*>(verts.data()), sizeof(glm::vec3));
|
||||||
btBvhTriangleMeshShape* trishape =
|
btBvhTriangleMeshShape* trishape =
|
||||||
new btBvhTriangleMeshShape(m_vertArray, false);
|
new btBvhTriangleMeshShape(m_vertArray, false);
|
||||||
trishape->setMargin(0.05f);
|
trishape->setMargin(0.05f);
|
||||||
cmpShape->addChildShape(t, trishape);
|
cmpShape->addChildShape(t, trishape);
|
||||||
|
|
||||||
|
@ -701,10 +701,10 @@ void GameData::loadSplash(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int GameData::getWaterIndexAt(const glm::vec3& ws) const {
|
int GameData::getWaterIndexAt(const glm::vec3& ws) const {
|
||||||
auto wX = (int)((ws.x + WATER_WORLD_SIZE / 2.f) /
|
auto wX = static_cast<int>((ws.x + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
auto wY = (int)((ws.y + WATER_WORLD_SIZE / 2.f) /
|
auto wY = static_cast<int>((ws.y + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
|
|
||||||
if (wX >= 0 && wX < WATER_HQ_DATA_SIZE && wY >= 0 &&
|
if (wX >= 0 && wX < WATER_HQ_DATA_SIZE && wY >= 0 &&
|
||||||
wY < WATER_HQ_DATA_SIZE) {
|
wY < WATER_HQ_DATA_SIZE) {
|
||||||
|
@ -351,7 +351,7 @@ PickupObject* GameWorld::createPickup(const glm::vec3& pos, int id, int type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PickupObject* pickup = nullptr;
|
PickupObject* pickup = nullptr;
|
||||||
auto pickuptype = (PickupObject::PickupType)type;
|
auto pickuptype = static_cast<PickupObject::PickupType>(type);
|
||||||
|
|
||||||
auto it = std::find_if(
|
auto it = std::find_if(
|
||||||
data->weaponData.begin(), data->weaponData.end(),
|
data->weaponData.begin(), data->weaponData.end(),
|
||||||
@ -839,7 +839,8 @@ VehicleObject* GameWorld::tryToSpawnVehicle(VehicleGenerator& gen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @todo take into account maxDelay as well
|
/// @todo take into account maxDelay as well
|
||||||
if (gen.lastSpawnTime + gen.minDelay > int(state->basic.timeMS)) {
|
if (gen.lastSpawnTime + gen.minDelay >
|
||||||
|
static_cast<int>(state->basic.timeMS)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,8 +1216,9 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
|
|||||||
// We keep track of the game time as a float for now
|
// We keep track of the game time as a float for now
|
||||||
state.gameTime = state.basic.timeMS / 1000.f;
|
state.gameTime = state.basic.timeMS / 1000.f;
|
||||||
|
|
||||||
state.scriptOnMissionFlag = (int32_t*)(state.script->getGlobals() +
|
state.scriptOnMissionFlag = reinterpret_cast<int32_t*>(
|
||||||
(size_t)scriptData.onMissionOffset);
|
state.script->getGlobals() +
|
||||||
|
static_cast<size_t>(scriptData.onMissionOffset));
|
||||||
|
|
||||||
auto& threads = state.script->getThreads();
|
auto& threads = state.script->getThreads();
|
||||||
for (size_t s = 0; s < numScripts; ++s) {
|
for (size_t s = 0; s < numScripts; ++s) {
|
||||||
|
@ -160,8 +160,8 @@ void GenericDATLoader::loadHandling(const std::string& name,
|
|||||||
char dt, et;
|
char dt, et;
|
||||||
ss >> dt;
|
ss >> dt;
|
||||||
ss >> et;
|
ss >> et;
|
||||||
info.driveType = (VehicleHandlingInfo::DriveType)dt;
|
info.driveType = static_cast<VehicleHandlingInfo::DriveType>(dt);
|
||||||
info.engineType = (VehicleHandlingInfo::EngineType)et;
|
info.engineType = static_cast<VehicleHandlingInfo::EngineType>(et);
|
||||||
ss >> info.brakeDeceleration;
|
ss >> info.brakeDeceleration;
|
||||||
ss >> info.brakeBias;
|
ss >> info.brakeBias;
|
||||||
ss >> info.ABS;
|
ss >> info.ABS;
|
||||||
|
@ -48,17 +48,17 @@ bool LoaderCOL::load(const std::string& path) {
|
|||||||
model->modelid = head.modelid;
|
model->modelid = head.modelid;
|
||||||
|
|
||||||
auto readFloat = [&]() {
|
auto readFloat = [&]() {
|
||||||
auto f = (float*)d;
|
auto f = reinterpret_cast<float*>(d);
|
||||||
d += sizeof(float);
|
d += sizeof(float);
|
||||||
return *f;
|
return *f;
|
||||||
};
|
};
|
||||||
auto readU8 = [&]() {
|
auto readU8 = [&]() {
|
||||||
auto f = (uint8_t*)d;
|
auto f = reinterpret_cast<uint8_t*>(d);
|
||||||
d += sizeof(uint8_t);
|
d += sizeof(uint8_t);
|
||||||
return *f;
|
return *f;
|
||||||
};
|
};
|
||||||
auto readU32 = [&]() {
|
auto readU32 = [&]() {
|
||||||
auto f = (uint32_t*)d;
|
auto f = reinterpret_cast<uint32_t*>(d);
|
||||||
d += sizeof(uint32_t);
|
d += sizeof(uint32_t);
|
||||||
return *f;
|
return *f;
|
||||||
};
|
};
|
||||||
|
@ -14,14 +14,14 @@ void LoaderGXT::load(GameTexts &texts, const FileHandle &file) {
|
|||||||
|
|
||||||
data += 4; // TKEY
|
data += 4; // TKEY
|
||||||
|
|
||||||
std::uint32_t blocksize = *(std::uint32_t *)data;
|
std::uint32_t blocksize = *reinterpret_cast<std::uint32_t *>(data);
|
||||||
|
|
||||||
data += 4;
|
data += 4;
|
||||||
|
|
||||||
auto tdata = data + blocksize + 8;
|
auto tdata = data + blocksize + 8;
|
||||||
|
|
||||||
for (size_t t = 0; t < blocksize / 12; ++t) {
|
for (size_t t = 0; t < blocksize / 12; ++t) {
|
||||||
size_t offset = *(std::uint32_t *)(data + (t * 12 + 0));
|
size_t offset = *reinterpret_cast<std::uint32_t *>(data + (t * 12 + 0));
|
||||||
std::string id(data + (t * 12 + 4));
|
std::string id(data + (t * 12 + 4));
|
||||||
|
|
||||||
GameStringChar *stringSrc =
|
GameStringChar *stringSrc =
|
||||||
|
@ -77,9 +77,9 @@ void InstanceObject::tickPhysics(float dt) {
|
|||||||
// Only certain objects should float on water
|
// Only certain objects should float on water
|
||||||
if (floating) {
|
if (floating) {
|
||||||
const glm::vec3& ws = getPosition();
|
const glm::vec3& ws = getPosition();
|
||||||
auto wX = (int)((ws.x + WATER_WORLD_SIZE / 2.f) /
|
auto wX = static_cast<int>((ws.x + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
auto wY = (int)((ws.y + WATER_WORLD_SIZE / 2.f) /
|
auto wY = static_cast<int>((ws.y + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
float vH = ws.z; // - _collisionHeight/2.f;
|
float vH = ws.z; // - _collisionHeight/2.f;
|
||||||
float wH = 0.f;
|
float wH = 0.f;
|
||||||
|
@ -38,13 +38,13 @@ public:
|
|||||||
btVehicleRaycasterResult& result) override {
|
btVehicleRaycasterResult& result) override {
|
||||||
ClosestNotMeRayResultCallback rayCallback(
|
ClosestNotMeRayResultCallback rayCallback(
|
||||||
_vehicle->collision->getBulletBody(), from, to);
|
_vehicle->collision->getBulletBody(), from, to);
|
||||||
const void* res = nullptr;
|
void* res = nullptr;
|
||||||
|
|
||||||
_world->rayTest(from, to, rayCallback);
|
_world->rayTest(from, to, rayCallback);
|
||||||
|
|
||||||
if (rayCallback.hasHit()) {
|
if (rayCallback.hasHit()) {
|
||||||
const btRigidBody* body =
|
btRigidBody* body = const_cast<btRigidBody*>(
|
||||||
btRigidBody::upcast(rayCallback.m_collisionObject);
|
btRigidBody::upcast(rayCallback.m_collisionObject));
|
||||||
|
|
||||||
if (body && body->hasContactResponse()) {
|
if (body && body->hasContactResponse()) {
|
||||||
result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
|
result.m_hitPointInWorld = rayCallback.m_hitPointWorld;
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (void*)res;
|
return reinterpret_cast<void*>(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -407,9 +407,9 @@ void VehicleObject::tickPhysics(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto& ws = getPosition();
|
const auto& ws = getPosition();
|
||||||
auto wX = (int)((ws.x + WATER_WORLD_SIZE / 2.f) /
|
auto wX = static_cast<int>((ws.x + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
auto wY = (int)((ws.y + WATER_WORLD_SIZE / 2.f) /
|
auto wY = static_cast<int>((ws.y + WATER_WORLD_SIZE / 2.f) /
|
||||||
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
(WATER_WORLD_SIZE / WATER_HQ_DATA_SIZE));
|
||||||
btVector3 bbmin, bbmax;
|
btVector3 bbmin, bbmax;
|
||||||
// This is in world space.
|
// This is in world space.
|
||||||
|
@ -129,8 +129,8 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
|||||||
|
|
||||||
size_t segments = skydomeSegments, rows = skydomeRows;
|
size_t segments = skydomeSegments, rows = skydomeRows;
|
||||||
|
|
||||||
float R = 1.f / (float)(rows - 1);
|
float R = 1.f / static_cast<float>(rows - 1);
|
||||||
float S = 1.f / (float)(segments - 1);
|
float S = 1.f / static_cast<float>(segments - 1);
|
||||||
std::vector<VertexP3> skydomeVerts;
|
std::vector<VertexP3> skydomeVerts;
|
||||||
skydomeVerts.resize(rows * segments);
|
skydomeVerts.resize(rows * segments);
|
||||||
for (size_t r = 0, i = 0; r < rows; ++r) {
|
for (size_t r = 0, i = 0; r < rows; ++r) {
|
||||||
|
@ -83,7 +83,7 @@ void MapRenderer::draw(GameWorld* world, const MapInfo& mi) {
|
|||||||
// World out the number of units per tile
|
// World out the number of units per tile
|
||||||
glm::vec2 worldSize(GAME_MAP_SIZE);
|
glm::vec2 worldSize(GAME_MAP_SIZE);
|
||||||
const int mapBlockLine = 8;
|
const int mapBlockLine = 8;
|
||||||
glm::vec2 tileSize = worldSize / (float)mapBlockLine;
|
glm::vec2 tileSize = worldSize / static_cast<float>(mapBlockLine);
|
||||||
// Determine the scale to show the right number of world units on the screen
|
// Determine the scale to show the right number of world units on the screen
|
||||||
float worldScale = mi.screenSize / mi.worldSize;
|
float worldScale = mi.screenSize / mi.worldSize;
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ GLuint compileProgram(const char* vertex, const char* fragment) {
|
|||||||
void Renderer::setViewport(const glm::ivec2& vp) {
|
void Renderer::setViewport(const glm::ivec2& vp) {
|
||||||
viewport = vp;
|
viewport = vp;
|
||||||
|
|
||||||
projection2D =
|
projection2D = glm::ortho(0.f, static_cast<float>(viewport.x),
|
||||||
glm::ortho(0.f, (float)viewport.x, (float)viewport.y, 0.f, -1.f, 1.f);
|
static_cast<float>(viewport.y), 0.f, -1.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::swap() {
|
void Renderer::swap() {
|
||||||
@ -303,7 +303,7 @@ void OpenGLRenderer::draw(const glm::mat4& model, DrawBuffer* draw,
|
|||||||
setDrawState(model, draw, p);
|
setDrawState(model, draw, p);
|
||||||
|
|
||||||
glDrawElements(draw->getFaceType(), p.count, GL_UNSIGNED_INT,
|
glDrawElements(draw->getFaceType(), p.count, GL_UNSIGNED_INT,
|
||||||
(void*)(sizeof(RenderIndex) * p.start));
|
reinterpret_cast<void*>(sizeof(RenderIndex) * p.start));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRenderer::drawArrays(const glm::mat4& model, DrawBuffer* draw,
|
void OpenGLRenderer::drawArrays(const glm::mat4& model, DrawBuffer* draw,
|
||||||
@ -353,7 +353,7 @@ void OpenGLRenderer::drawBatched(const RenderList& list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glDrawElements(draw.dbuff->getFaceType(), draw.drawInfo.count, GL_UNSIGNED_INT,
|
glDrawElements(draw.dbuff->getFaceType(), draw.drawInfo.count, GL_UNSIGNED_INT,
|
||||||
(void*) (sizeof(RenderIndex) * draw.drawInfo.start));
|
reinterpret_cast<void*>(sizeof(RenderIndex) * draw.drawInfo.start));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -19,8 +19,8 @@ int charToIndex(uint16_t g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glm::vec4 indexToCoord(int font, int index) {
|
glm::vec4 indexToCoord(int font, int index) {
|
||||||
float x = int(index % 16);
|
float x = static_cast<int>(index % 16);
|
||||||
float y = int(index / 16) + 0.01f;
|
float y = static_cast<int>(index / 16) + 0.01f;
|
||||||
float fontHeight = ((font == 0) ? 16.f : 13.f);
|
float fontHeight = ((font == 0) ? 16.f : 13.f);
|
||||||
glm::vec2 gsize(1.f / 16.f, 1.f / fontHeight);
|
glm::vec2 gsize(1.f / 16.f, 1.f / fontHeight);
|
||||||
return glm::vec4(x, y, x + 1, y + 0.98f) * glm::vec4(gsize, gsize);
|
return glm::vec4(x, y, x + 1, y + 0.98f) * glm::vec4(gsize, gsize);
|
||||||
|
@ -152,7 +152,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getGlobalOffset(ScriptInt& global) const {
|
uint32_t getGlobalOffset(ScriptInt& global) const {
|
||||||
return uint32_t((SCMByte*)(&global) - globalData.data());
|
return static_cast<uint32_t>(reinterpret_cast<SCMByte*>(&global) -
|
||||||
|
globalData.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getDebugFlag() const {
|
bool getDebugFlag() const {
|
||||||
|
@ -256,5 +256,5 @@ template <>
|
|||||||
ScriptObjectType<int> ScriptArguments::getScriptObject(unsigned int arg) const {
|
ScriptObjectType<int> ScriptArguments::getScriptObject(unsigned int arg) const {
|
||||||
auto& param = (*this)[arg];
|
auto& param = (*this)[arg];
|
||||||
RW_CHECK(param.isLvalue(), "Non lvalue passed as object");
|
RW_CHECK(param.isLvalue(), "Non lvalue passed as object");
|
||||||
return {param.handleValue(), (int*)nullptr};
|
return {param.handleValue(), static_cast<int*>(nullptr)};
|
||||||
}
|
}
|
||||||
|
@ -9940,15 +9940,15 @@ void opcode_0376(const ScriptArguments& args, ScriptVec3 coord,
|
|||||||
auto world = args.getWorld();
|
auto world = args.getWorld();
|
||||||
auto state = args.getState();
|
auto state = args.getState();
|
||||||
auto data = world->data;
|
auto data = world->data;
|
||||||
auto zone = data->findZoneAt(
|
auto zone =
|
||||||
world->getPlayer()->getCharacter()->getPosition());
|
data->findZoneAt(world->getPlayer()->getCharacter()->getPosition());
|
||||||
const bool day =
|
const bool day =
|
||||||
(state->basic.gameHour >= 8 && state->basic.gameHour <= 19);
|
(state->basic.gameHour >= 8 && state->basic.gameHour <= 19);
|
||||||
const int groupId =
|
const int groupId =
|
||||||
zone ? (day ? zone->pedGroupDay : zone->pedGroupNight) : 0;
|
zone ? (day ? zone->pedGroupDay : zone->pedGroupNight) : 0;
|
||||||
const auto& pedGroup = data->pedgroups.at(groupId);
|
const auto& pedGroup = data->pedgroups.at(groupId);
|
||||||
const auto model = pedGroup.at(
|
const auto model = pedGroup.at(args.getVM()->getRandomNumber(
|
||||||
args.getVM()->getRandomNumber((std::size_t)0, pedGroup.size() - 1));
|
static_cast<std::size_t>(0), pedGroup.size() - 1));
|
||||||
character = world->createPedestrian(model, coord + script::kSpawnOffset);
|
character = world->createPedestrian(model, coord + script::kSpawnOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11502,7 +11502,7 @@ void opcode_03e6(const ScriptArguments& args) {
|
|||||||
@arg arg1
|
@arg arg1
|
||||||
*/
|
*/
|
||||||
void opcode_03e7(const ScriptArguments& args, const ScriptHudFlash arg1) {
|
void opcode_03e7(const ScriptArguments& args, const ScriptHudFlash arg1) {
|
||||||
args.getState()->hudFlash = (HudFlash)arg1;
|
args.getState()->hudFlash = static_cast<HudFlash>(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +155,8 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world,
|
|||||||
.25f) { // UI: Blinking health indicator if health is low
|
.25f) { // UI: Blinking health indicator if health is low
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::setw(3) << std::setfill('0')
|
ss << std::setw(3) << std::setfill('0')
|
||||||
<< (int)player->getCharacter()->getCurrentState().health;
|
<< static_cast<int>(
|
||||||
|
player->getCharacter()->getCurrentState().health);
|
||||||
ti.text = GameSymbols::Heart + GameStringUtil::fromString(ss.str());
|
ti.text = GameSymbols::Heart + GameStringUtil::fromString(ss.str());
|
||||||
|
|
||||||
ti.baseColour = ui_shadowColour;
|
ti.baseColour = ui_shadowColour;
|
||||||
@ -171,7 +172,8 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world,
|
|||||||
if (player->getCharacter()->getCurrentState().armour > 0) {
|
if (player->getCharacter()->getCurrentState().armour > 0) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::setw(3) << std::setfill('0')
|
ss << std::setw(3) << std::setfill('0')
|
||||||
<< (int)player->getCharacter()->getCurrentState().armour;
|
<< static_cast<int>(
|
||||||
|
player->getCharacter()->getCurrentState().armour);
|
||||||
ti.text = GameSymbols::Armour + GameStringUtil::fromString(ss.str());
|
ti.text = GameSymbols::Armour + GameStringUtil::fromString(ss.str());
|
||||||
|
|
||||||
ti.baseColour = ui_shadowColour;
|
ti.baseColour = ui_shadowColour;
|
||||||
@ -309,8 +311,8 @@ void drawOnScreenText(GameWorld* world, GameRenderer* renderer) {
|
|||||||
|
|
||||||
// Check for the background type
|
// Check for the background type
|
||||||
if (t.colourBG.a == 0) {
|
if (t.colourBG.a == 0) {
|
||||||
glm::vec2 shadowPosition((int8_t)t.colourBG.x,
|
glm::vec2 shadowPosition(static_cast<int8_t>(t.colourBG.x),
|
||||||
(int8_t)t.colourBG.y);
|
static_cast<int8_t>(t.colourBG.y));
|
||||||
|
|
||||||
ti.baseColour = glm::vec3(0.f);
|
ti.baseColour = glm::vec3(0.f);
|
||||||
ti.screenPosition += shadowPosition;
|
ti.screenPosition += shadowPosition;
|
||||||
|
@ -46,10 +46,10 @@ void GameWindow::create(const std::string& title, size_t w, size_t h,
|
|||||||
bmask = 0x00ff0000;
|
bmask = 0x00ff0000;
|
||||||
amask = 0xff000000;
|
amask = 0xff000000;
|
||||||
#endif
|
#endif
|
||||||
icon = SDL_CreateRGBSurfaceFrom((void*)windowIconData,
|
icon = SDL_CreateRGBSurfaceFrom(
|
||||||
windowIconWidth, windowIconHeight,
|
static_cast<void*>(const_cast<unsigned char*>(windowIconData)),
|
||||||
32, windowIconWidth * (32 / 8),
|
windowIconWidth, windowIconHeight, 32, windowIconWidth * (32 / 8),
|
||||||
rmask, gmask, bmask, amask);
|
rmask, gmask, bmask, amask);
|
||||||
SDL_SetWindowIcon(window, icon);
|
SDL_SetWindowIcon(window, icon);
|
||||||
|
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
glm::vec2 basis(offset);
|
glm::vec2 basis(offset);
|
||||||
for (size_t i = 0; i < entries.size(); ++i) {
|
for (size_t i = 0; i < entries.size(); ++i) {
|
||||||
bool active = false;
|
bool active = false;
|
||||||
if (activeEntry >= 0 && i == (unsigned)activeEntry) {
|
if (activeEntry >= 0 && i == static_cast<unsigned>(activeEntry)) {
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
entries[i].draw(font, size, active, r, basis);
|
entries[i].draw(font, size, active, r, basis);
|
||||||
@ -138,14 +138,15 @@ public:
|
|||||||
|
|
||||||
// Activates the menu entry at the current active index.
|
// Activates the menu entry at the current active index.
|
||||||
void activate() {
|
void activate() {
|
||||||
if (activeEntry >= 0 && (unsigned)activeEntry < entries.size()) {
|
if (activeEntry >= 0 &&
|
||||||
|
static_cast<unsigned>(activeEntry) < entries.size()) {
|
||||||
entries[activeEntry].activate(0.f, 0.f);
|
entries[activeEntry].activate(0.f, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void move(int movement) {
|
void move(int movement) {
|
||||||
activeEntry += movement;
|
activeEntry += movement;
|
||||||
if (activeEntry >= int(entries.size())) {
|
if (activeEntry >= static_cast<int>(entries.size())) {
|
||||||
activeEntry = 0;
|
activeEntry = 0;
|
||||||
} else if (activeEntry < 0) {
|
} else if (activeEntry < 0) {
|
||||||
activeEntry = entries.size() - 1;
|
activeEntry = entries.size() - 1;
|
||||||
|
@ -301,8 +301,8 @@ void IngameState::handleEvent(const SDL_Event& event) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_c:
|
case SDLK_c:
|
||||||
camMode =
|
camMode = static_cast<CameraMode>(
|
||||||
CameraMode((camMode + (CameraMode)1) % CAMERA_MAX);
|
(camMode + static_cast<CameraMode>(1)) % CAMERA_MAX);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -435,7 +435,7 @@ const ViewCamera& IngameState::getCamera(float alpha) {
|
|||||||
lookTargetPosition += glm::vec3(0.f, 0.f, 0.5f);
|
lookTargetPosition += glm::vec3(0.f, 0.f, 0.5f);
|
||||||
|
|
||||||
if (target->type() == GameObject::Vehicle) {
|
if (target->type() == GameObject::Vehicle) {
|
||||||
auto vehicle = (VehicleObject*)target;
|
auto vehicle = static_cast<VehicleObject*>(target);
|
||||||
auto model = vehicle->getModel();
|
auto model = vehicle->getModel();
|
||||||
auto maxDist = model->getBoundingRadius() * 2.f;
|
auto maxDist = model->getBoundingRadius() * 2.f;
|
||||||
viewDistance = viewDistance + maxDist;
|
viewDistance = viewDistance + maxDist;
|
||||||
@ -510,7 +510,8 @@ GameObject* IngameState::getCameraTarget() const {
|
|||||||
|
|
||||||
// If the target is a character in a vehicle, make the vehicle the target
|
// If the target is a character in a vehicle, make the vehicle the target
|
||||||
if (target && target->type() == GameObject::Character) {
|
if (target && target->type() == GameObject::Character) {
|
||||||
auto vehicle = ((CharacterObject*)target)->getCurrentVehicle();
|
auto vehicle =
|
||||||
|
(static_cast<CharacterObject*>(target))->getCurrentVehicle();
|
||||||
if (vehicle) {
|
if (vehicle) {
|
||||||
target = vehicle;
|
target = vehicle;
|
||||||
}
|
}
|
||||||
|
@ -59,21 +59,22 @@ LoaderDFF::FrameList LoaderDFF::readFrameList(const RWBStream &stream) {
|
|||||||
|
|
||||||
char *headerPtr = listStream.getCursor();
|
char *headerPtr = listStream.getCursor();
|
||||||
|
|
||||||
unsigned int numFrames = *(std::uint32_t *)headerPtr;
|
unsigned int numFrames = *reinterpret_cast<std::uint32_t *>(headerPtr);
|
||||||
headerPtr += sizeof(std::uint32_t);
|
headerPtr += sizeof(std::uint32_t);
|
||||||
|
|
||||||
FrameList framelist;
|
FrameList framelist;
|
||||||
framelist.reserve(numFrames);
|
framelist.reserve(numFrames);
|
||||||
|
|
||||||
for (size_t f = 0; f < numFrames; ++f) {
|
for (size_t f = 0; f < numFrames; ++f) {
|
||||||
auto data = (RWBSFrame *)headerPtr;
|
auto data = reinterpret_cast<RWBSFrame *>(headerPtr);
|
||||||
headerPtr += sizeof(RWBSFrame);
|
headerPtr += sizeof(RWBSFrame);
|
||||||
auto frame =
|
auto frame =
|
||||||
std::make_shared<ModelFrame>(f, data->rotation, data->position);
|
std::make_shared<ModelFrame>(f, data->rotation, data->position);
|
||||||
|
|
||||||
RW_CHECK(data->index < int(framelist.size()),
|
RW_CHECK(data->index < static_cast<int>(framelist.size()),
|
||||||
"Frame parent out of bounds");
|
"Frame parent out of bounds");
|
||||||
if (data->index != -1 && data->index < int(framelist.size())) {
|
if (data->index != -1 &&
|
||||||
|
data->index < static_cast<int>(framelist.size())) {
|
||||||
framelist[data->index]->addChild(frame);
|
framelist[data->index]->addChild(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
QVariant AnimationListModel::data(const QModelIndex& index, int role) const {
|
QVariant AnimationListModel::data(const QModelIndex& index, int role) const {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (index.row() >= 0 && (unsigned)index.row() < animations.size()) {
|
if (index.row() >= 0 &&
|
||||||
|
static_cast<unsigned>(index.row()) < animations.size()) {
|
||||||
auto& f = animations.at(index.row());
|
auto& f = animations.at(index.row());
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
return QString(f.first.c_str());
|
return QString(f.first.c_str());
|
||||||
|
@ -35,7 +35,8 @@ void AnimationListWidget::setAnimations(const AnimationList& archive) {
|
|||||||
|
|
||||||
void AnimationListWidget::selectedIndexChanged(const QModelIndex& current) {
|
void AnimationListWidget::selectedIndexChanged(const QModelIndex& current) {
|
||||||
auto mts = filter->mapToSource(current);
|
auto mts = filter->mapToSource(current);
|
||||||
if (mts.row() >= 0 && (unsigned)mts.row() < model->getAnimations().size()) {
|
if (mts.row() >= 0 &&
|
||||||
|
static_cast<unsigned>(mts.row()) < model->getAnimations().size()) {
|
||||||
auto& f = model->getAnimations().at(mts.row());
|
auto& f = model->getAnimations().at(mts.row());
|
||||||
emit selectedAnimationChanged(f.second);
|
emit selectedAnimationChanged(f.second);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
QVariant IMGArchiveModel::data(const QModelIndex& index, int role) const {
|
QVariant IMGArchiveModel::data(const QModelIndex& index, int role) const {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (index.row() >= 0 &&
|
if (index.row() >= 0 &&
|
||||||
(unsigned)index.row() < archive.getAssetCount()) {
|
static_cast<unsigned>(index.row()) < archive.getAssetCount()) {
|
||||||
auto& f = archive.getAssetInfoByIndex(index.row());
|
auto& f = archive.getAssetInfoByIndex(index.row());
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
return QString(f.name);
|
return QString(f.name);
|
||||||
|
@ -72,7 +72,7 @@ bool DFFFramesTreeModel::setData(const QModelIndex& index,
|
|||||||
|
|
||||||
if (role == Qt::CheckStateRole) {
|
if (role == Qt::CheckStateRole) {
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
if ((Qt::CheckState)value.toInt() == Qt::Checked) {
|
if (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked) {
|
||||||
RW_UNIMPLEMENTED("Hiding Frames");
|
RW_UNIMPLEMENTED("Hiding Frames");
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ void ModelFramesWidget::updateInfoBox(ClumpPtr, ModelFrame* f) {
|
|||||||
|
|
||||||
void ModelFramesWidget::selectedModelChanged(const QModelIndex& n,
|
void ModelFramesWidget::selectedModelChanged(const QModelIndex& n,
|
||||||
const QModelIndex&) {
|
const QModelIndex&) {
|
||||||
updateInfoBox(gmodel, (ModelFrame*)n.internalPointer());
|
updateInfoBox(gmodel, static_cast<ModelFrame*>(n.internalPointer()));
|
||||||
selectedFrameChanged((ModelFrame*)n.internalPointer());
|
selectedFrameChanged(static_cast<ModelFrame*>(n.internalPointer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
||||||
|
@ -58,7 +58,7 @@ template <>
|
|||||||
struct print_log_value<GameString> {
|
struct print_log_value<GameString> {
|
||||||
void operator()(std::ostream& s, GameString const& v) {
|
void operator()(std::ostream& s, GameString const& v) {
|
||||||
for (GameString::size_type i = 0u; i < v.size(); ++i) {
|
for (GameString::size_type i = 0u; i < v.size(); ++i) {
|
||||||
s << (char)v[i];
|
s << static_cast<char>(v[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -18,13 +18,15 @@ BOOST_AUTO_TEST_CASE(TestStateUpdate) {
|
|||||||
|
|
||||||
// Check that the correct inputs report pressed
|
// Check that the correct inputs report pressed
|
||||||
for (int c = 0; c < GameInputState::_MaxControls; ++c) {
|
for (int c = 0; c < GameInputState::_MaxControls; ++c) {
|
||||||
switch ((GameInputState::Control)c) {
|
switch (static_cast<GameInputState::Control>(c)) {
|
||||||
case GameInputState::Jump:
|
case GameInputState::Jump:
|
||||||
case GameInputState::Handbrake:
|
case GameInputState::Handbrake:
|
||||||
BOOST_CHECK(state.pressed((GameInputState::Control)c));
|
BOOST_CHECK(
|
||||||
|
state.pressed(static_cast<GameInputState::Control>(c)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BOOST_CHECK(!state.pressed((GameInputState::Control)c));
|
BOOST_CHECK(!state.pressed(
|
||||||
|
static_cast<GameInputState::Control>(c)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE(iterate_stream_test) {
|
|||||||
auto innerCursor = inner.getCursor();
|
auto innerCursor = inner.getCursor();
|
||||||
|
|
||||||
// This is a value inside in the Clump's struct header section.
|
// This is a value inside in the Clump's struct header section.
|
||||||
BOOST_CHECK_EQUAL(*(std::uint32_t*)innerCursor, 0x10);
|
BOOST_CHECK_EQUAL(*reinterpret_cast<std::uint32_t*>(innerCursor), 0x10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user