mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
commit
0df204b430
@ -20,8 +20,7 @@ public:
|
||||
* @brief The Activity struct interface
|
||||
*/
|
||||
struct Activity {
|
||||
virtual ~Activity() {
|
||||
}
|
||||
virtual ~Activity() = default;
|
||||
|
||||
virtual std::string name() const = 0;
|
||||
|
||||
@ -77,8 +76,7 @@ protected:
|
||||
public:
|
||||
CharacterController();
|
||||
|
||||
virtual ~CharacterController() {
|
||||
}
|
||||
virtual ~CharacterController() = default;
|
||||
|
||||
/**
|
||||
* Get the current Activity.
|
||||
|
@ -24,7 +24,7 @@ SoundManager::SoundManager() {
|
||||
SoundManager::~SoundManager() {
|
||||
// De-initialize OpenAL
|
||||
if (alContext) {
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcMakeContextCurrent(nullptr);
|
||||
alcDestroyContext(alContext);
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ SoundManager::~SoundManager() {
|
||||
}
|
||||
|
||||
bool SoundManager::initializeOpenAL() {
|
||||
alDevice = alcOpenDevice(NULL);
|
||||
alDevice = alcOpenDevice(nullptr);
|
||||
if (!alDevice) {
|
||||
RW_ERROR("Could not find OpenAL device!");
|
||||
return false;
|
||||
}
|
||||
|
||||
alContext = alcCreateContext(alDevice, NULL);
|
||||
alContext = alcCreateContext(alDevice, nullptr);
|
||||
if (!alContext) {
|
||||
RW_ERROR("Could not create OpenAL context!");
|
||||
return false;
|
||||
@ -102,7 +102,7 @@ void SoundManager::SoundSource::loadFromFile(const std::string& filename) {
|
||||
codecContext->codec = codec;
|
||||
|
||||
// Open the codec
|
||||
if (avcodec_open2(codecContext, codecContext->codec, NULL) != 0) {
|
||||
if (avcodec_open2(codecContext, codecContext->codec, nullptr) != 0) {
|
||||
av_frame_free(&frame);
|
||||
avformat_close_input(&formatContext);
|
||||
RW_ERROR("Couldn't open the audio codec context");
|
||||
|
@ -49,8 +49,7 @@ public:
|
||||
BaseModelInfo(ModelDataType type) : type_(type) {
|
||||
}
|
||||
|
||||
virtual ~BaseModelInfo() {
|
||||
}
|
||||
virtual ~BaseModelInfo() = default;
|
||||
|
||||
ModelID id() const {
|
||||
return modelid_;
|
||||
|
@ -38,9 +38,7 @@ GameData::GameData(Logger* log, const rwfs::path& path)
|
||||
});
|
||||
}
|
||||
|
||||
GameData::~GameData() {
|
||||
/// @todo don't leak models
|
||||
}
|
||||
GameData::~GameData() = default;
|
||||
|
||||
void GameData::load() {
|
||||
index.indexGameDirectory(datpath);
|
||||
|
@ -86,7 +86,7 @@ bool GameWorld::placeItems(const std::string& name) {
|
||||
|
||||
if (ipll.load(path)) {
|
||||
// Find the object.
|
||||
for (auto inst : ipll.m_instances) {
|
||||
for (const auto &inst : ipll.m_instances) {
|
||||
if (!createInstance(inst->id, inst->pos, inst->rot)) {
|
||||
logger->error("World", "No object data for instance " +
|
||||
std::to_string(inst->id) + " in " +
|
||||
|
@ -129,7 +129,7 @@ bool LoaderIDE::load(const std::string &filename, const PedStatsList &stats) {
|
||||
cars->level_ = std::atoi(buff.c_str());
|
||||
|
||||
getline(strstream, buff, ',');
|
||||
cars->componentrules_ = std::stoul(buff, 0, 16);
|
||||
cars->componentrules_ = std::stoul(buff, nullptr, 16);
|
||||
|
||||
switch (cars->vehicletype_) {
|
||||
case VehicleModelInfo::CAR:
|
||||
|
@ -27,8 +27,7 @@ struct AnimationKeyframe {
|
||||
, id(_id) {
|
||||
}
|
||||
|
||||
AnimationKeyframe() {
|
||||
}
|
||||
AnimationKeyframe() = default;
|
||||
};
|
||||
|
||||
struct AnimationBone {
|
||||
@ -72,7 +71,7 @@ class LoaderIFP {
|
||||
return reinterpret_cast<T*>(data + b);
|
||||
}
|
||||
template <class T>
|
||||
T* peek(char* data, size_t* ofs) {
|
||||
T* peek(char* data, const size_t* ofs) {
|
||||
return reinterpret_cast<T*>(data + *ofs);
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,7 @@ CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
|
||||
animator = new Animator(getClump());
|
||||
}
|
||||
|
||||
CutsceneObject::~CutsceneObject() {
|
||||
}
|
||||
CutsceneObject::~CutsceneObject() = default;
|
||||
|
||||
void CutsceneObject::tick(float dt) {
|
||||
animator->tick(dt);
|
||||
|
@ -43,8 +43,7 @@ InstanceObject::InstanceObject(GameWorld* engine, const glm::vec3& pos,
|
||||
}
|
||||
}
|
||||
|
||||
InstanceObject::~InstanceObject() {
|
||||
}
|
||||
InstanceObject::~InstanceObject() = default;
|
||||
|
||||
void InstanceObject::tick(float dt) {
|
||||
if (animator) animator->tick(dt);
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
btVehicleRaycasterResult& result) override {
|
||||
ClosestNotMeRayResultCallback rayCallback(
|
||||
_vehicle->collision->getBulletBody(), from, to);
|
||||
const void* res = 0;
|
||||
const void* res = nullptr;
|
||||
|
||||
_world->rayTest(from, to, rayCallback);
|
||||
|
||||
|
@ -53,16 +53,6 @@ struct ParticleVert {
|
||||
float r, g, b;
|
||||
};
|
||||
|
||||
GeometryBuffer particleGeom;
|
||||
DrawBuffer particleDraw;
|
||||
|
||||
std::vector<VertexP2> sspaceRect = {
|
||||
{-1.f, -1.f}, {1.f, -1.f}, {-1.f, 1.f}, {1.f, 1.f},
|
||||
};
|
||||
|
||||
GeometryBuffer ssRectGeom;
|
||||
DrawBuffer ssRectDraw;
|
||||
|
||||
GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
||||
: data(_data)
|
||||
, logger(log)
|
||||
@ -115,13 +105,13 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbTextures[0]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbTextures[1]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, 128, 128, 0, GL_RED, GL_FLOAT,
|
||||
NULL);
|
||||
nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
@ -705,10 +695,10 @@ void GameRenderer::setViewport(int w, int h) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbTextures[0]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
glBindTexture(GL_TEXTURE_2D, fbTextures[1]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, w, h, 0, GL_RED, GL_FLOAT,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, fbRenderBuffers[0]);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, w, h);
|
||||
|
@ -62,6 +62,16 @@ class GameRenderer {
|
||||
/// Texture used to replace textures missing from the data
|
||||
GLuint m_missingTexture;
|
||||
|
||||
GeometryBuffer particleGeom;
|
||||
DrawBuffer particleDraw;
|
||||
|
||||
std::vector<VertexP2> sspaceRect = {
|
||||
{-1.f, -1.f}, {1.f, -1.f}, {-1.f, 1.f}, {1.f, 1.f},
|
||||
};
|
||||
|
||||
GeometryBuffer ssRectGeom;
|
||||
DrawBuffer ssRectDraw;
|
||||
|
||||
public:
|
||||
GameRenderer(Logger* log, GameData* data);
|
||||
~GameRenderer();
|
||||
|
@ -16,7 +16,7 @@ constexpr GLuint kUBOIndexDraw = 2;
|
||||
|
||||
GLuint compileShader(GLenum type, const char* source) {
|
||||
GLuint shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
glShaderSource(shader, 1, &source, nullptr);
|
||||
glCompileShader(shader);
|
||||
|
||||
GLint status;
|
||||
@ -30,7 +30,7 @@ GLuint compileShader(GLenum type, const char* source) {
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
|
||||
if (len > 1) {
|
||||
GLchar* buffer = new GLchar[len];
|
||||
glGetShaderInfoLog(shader, len, NULL, buffer);
|
||||
glGetShaderInfoLog(shader, len, nullptr, buffer);
|
||||
|
||||
GLint sourceLen;
|
||||
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceLen);
|
||||
@ -79,7 +79,7 @@ GLuint compileProgram(const char* vertex, const char* fragment) {
|
||||
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
|
||||
if (len > 1) {
|
||||
GLchar* buffer = new GLchar[len];
|
||||
glGetProgramInfoLog(prog, len, NULL, buffer);
|
||||
glGetProgramInfoLog(prog, len, nullptr, buffer);
|
||||
|
||||
RW_ERROR("[OGL] Program InfoLog(" << prog << "):\n"
|
||||
<< buffer);
|
||||
@ -376,7 +376,7 @@ bool OpenGLRenderer::createUBO(Buffer &out, GLsizei size, GLsizei entrySize)
|
||||
{
|
||||
glGenBuffers(1, &out.name);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, out.name);
|
||||
glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_STREAM_DRAW);
|
||||
glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_STREAM_DRAW);
|
||||
|
||||
if (entrySize != size) {
|
||||
GLint UBOAlignment;
|
||||
@ -399,7 +399,7 @@ void OpenGLRenderer::uploadUBOEntry(Buffer &buffer, const void *data, size_t siz
|
||||
RW_ASSERT(size <= buffer.entrySize);
|
||||
if (buffer.currentEntry >= buffer.entryCount) {
|
||||
// Orphan the buffer, we don't want it anymore
|
||||
glBufferData(GL_UNIFORM_BUFFER, buffer.bufferSize, NULL,
|
||||
glBufferData(GL_UNIFORM_BUFFER, buffer.bufferSize, nullptr,
|
||||
GL_STREAM_DRAW);
|
||||
buffer.currentEntry = 0;
|
||||
}
|
||||
@ -469,5 +469,4 @@ const Renderer::ProfileInfo& OpenGLRenderer::popDebugGroup() {
|
||||
return profileInfo[0];
|
||||
}
|
||||
|
||||
Renderer::ShaderProgram::~ShaderProgram() {
|
||||
}
|
||||
Renderer::ShaderProgram::~ShaderProgram() = default;
|
||||
|
@ -33,8 +33,7 @@ struct VertexP2 {
|
||||
: position({_x, _y}) {
|
||||
}
|
||||
|
||||
VertexP2() {
|
||||
}
|
||||
VertexP2() = default;
|
||||
};
|
||||
|
||||
|
||||
@ -51,8 +50,7 @@ struct VertexP3 {
|
||||
: position({_x, _y, _z}) {
|
||||
}
|
||||
|
||||
VertexP3() {
|
||||
}
|
||||
VertexP3() = default;
|
||||
};
|
||||
|
||||
class Renderer {
|
||||
|
@ -71,8 +71,7 @@ struct TextVertex {
|
||||
, colour(_colour) {
|
||||
}
|
||||
|
||||
TextVertex() {
|
||||
}
|
||||
TextVertex() = default;
|
||||
|
||||
static const AttributeList vertex_attributes() {
|
||||
return {
|
||||
@ -132,8 +131,7 @@ TextRenderer::TextRenderer(GameRenderer* renderer) : renderer(renderer) {
|
||||
}
|
||||
}
|
||||
|
||||
TextRenderer::~TextRenderer() {
|
||||
}
|
||||
TextRenderer::~TextRenderer() = default;
|
||||
|
||||
void TextRenderer::setFontTexture(int index, const std::string& texture) {
|
||||
if (index < GAME_FONTS) {
|
||||
|
@ -6,15 +6,14 @@
|
||||
|
||||
class ViewCamera {
|
||||
public:
|
||||
ViewFrustum frustum;
|
||||
ViewFrustum frustum{0.1f, 5000.f, glm::radians(45.f), 1.f};
|
||||
|
||||
glm::vec3 position;
|
||||
glm::quat rotation;
|
||||
|
||||
ViewCamera(const glm::vec3& pos = {},
|
||||
const glm::quat& rot = {1.0f,0.0f,0.0f,0.0f})
|
||||
: frustum({0.1f, 5000.f, glm::radians(45.f), 1.f})
|
||||
, position(pos)
|
||||
const glm::quat& rot = {1.0f,0.0f,0.0f,0.0f})
|
||||
: position(pos)
|
||||
, rotation(rot) {
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,11 @@
|
||||
|
||||
#include <new>
|
||||
|
||||
VisualFX::LightData::~LightData() {
|
||||
}
|
||||
VisualFX::LightData::~LightData() = default;
|
||||
|
||||
VisualFX::ParticleData::~ParticleData() {
|
||||
}
|
||||
VisualFX::ParticleData::~ParticleData() = default;
|
||||
|
||||
VisualFX::TrailData::~TrailData() {
|
||||
}
|
||||
VisualFX::TrailData::~TrailData() = default;
|
||||
|
||||
VisualFX::VisualFX(VisualFX::EffectType type) : type(type) {
|
||||
switch (type) {
|
||||
|
@ -55,11 +55,10 @@ WaterRenderer::WaterRenderer(GameRenderer* renderer) : waterProg(nullptr) {
|
||||
gridDraw.addGeometry(&gridGeom);
|
||||
}
|
||||
|
||||
WaterRenderer::~WaterRenderer() {
|
||||
}
|
||||
WaterRenderer::~WaterRenderer() = default;
|
||||
|
||||
void WaterRenderer::setWaterTable(float* waterHeights, unsigned int nHeights,
|
||||
uint8_t* tiles, unsigned int nTiles) {
|
||||
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);
|
||||
float tileSize = WATER_WORLD_SIZE / edgeNum;
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
* This data is used to create the internal stencil mask for clipping
|
||||
* the water rendering.
|
||||
*/
|
||||
void setWaterTable(float* waterHeights, unsigned int nHeights,
|
||||
uint8_t* tiles, unsigned int nTiles);
|
||||
void setWaterTable(const float* waterHeights, const unsigned int nHeights,
|
||||
const uint8_t* tiles, const unsigned int nTiles);
|
||||
|
||||
void setDataTexture(GLuint fbBinding, GLuint dataTexture);
|
||||
|
||||
|
@ -26,8 +26,8 @@ class SCMFile;
|
||||
|
||||
|
||||
struct SCMException {
|
||||
virtual ~SCMException() {
|
||||
}
|
||||
virtual ~SCMException() = default;
|
||||
|
||||
virtual std::string what() const = 0;
|
||||
};
|
||||
|
||||
@ -119,7 +119,7 @@ struct SCMThread {
|
||||
class ScriptMachine {
|
||||
public:
|
||||
ScriptMachine(GameState* state, SCMFile* file, ScriptModule* ops);
|
||||
~ScriptMachine() { }
|
||||
~ScriptMachine() = default;
|
||||
|
||||
SCMFile* getFile() const {
|
||||
return file;
|
||||
|
@ -25,9 +25,9 @@ const glm::u8vec3 ui_moneyColour(89, 113, 147);
|
||||
const glm::u8vec3 ui_healthColour(187, 102, 47);
|
||||
const glm::u8vec3 ui_armourColour(123, 136, 93);
|
||||
const glm::u8vec3 ui_shadowColour(0, 0, 0);
|
||||
const float ui_mapSize = 150.f;
|
||||
const float ui_worldSizeMin = 200.f;
|
||||
const float ui_worldSizeMax = 300.f;
|
||||
constexpr float ui_mapSize = 150.f;
|
||||
constexpr float ui_worldSizeMin = 200.f;
|
||||
constexpr float ui_worldSizeMax = 300.f;
|
||||
|
||||
void drawMap(ViewCamera& currentView, PlayerController* player,
|
||||
GameWorld* world, GameRenderer* render) {
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include "RWGame.hpp"
|
||||
|
||||
// This serves as the "initial" camera position.
|
||||
ViewCamera defaultView({-250.f, -550.f, 75.f},
|
||||
const ViewCamera defaultView{{-250.f, -550.f, 75.f},
|
||||
glm::angleAxis(glm::radians(5.f),
|
||||
glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3(0.f, 1.f, 0.f))};
|
||||
|
||||
void State::handleEvent(const SDL_Event& e) {
|
||||
auto m = getCurrentMenu();
|
||||
|
@ -31,8 +31,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~State() {
|
||||
}
|
||||
virtual ~State() = default;
|
||||
|
||||
void enterMenu(const std::shared_ptr<Menu>& menu) {
|
||||
nextMenu = menu;
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, char* argv[]) {
|
||||
logger.error("exception", ex.what());
|
||||
|
||||
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, kErrorTitle,
|
||||
ex.what(), NULL) < 0) {
|
||||
ex.what(), nullptr) < 0) {
|
||||
SDL_Log("Failed to show message box\n");
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@
|
||||
|
||||
constexpr float kAutoLookTime = 2.f;
|
||||
constexpr float kAutolookMinVelocity = 0.2f;
|
||||
const float kInGameFOV = glm::half_pi<float>();
|
||||
const float kMaxRotationRate = glm::quarter_pi<float>();
|
||||
const float kCameraPitchLimit = glm::quarter_pi<float>() * 0.5f;
|
||||
const float kVehicleCameraPitch =
|
||||
constexpr float kInGameFOV = glm::half_pi<float>();
|
||||
constexpr float kMaxRotationRate = glm::quarter_pi<float>();
|
||||
constexpr float kCameraPitchLimit = glm::quarter_pi<float>() * 0.5f;
|
||||
constexpr float kVehicleCameraPitch =
|
||||
glm::half_pi<float>() - glm::quarter_pi<float>() * 0.25f;
|
||||
|
||||
IngameState::IngameState(RWGame* game, bool newgame, const std::string& save)
|
||||
|
@ -98,8 +98,7 @@ ModelFrame* Clump::findFrame(const std::string& name) const {
|
||||
return rootframe_->findDescendant(name);
|
||||
}
|
||||
|
||||
Clump::~Clump() {
|
||||
}
|
||||
Clump::~Clump() = default;
|
||||
|
||||
void Clump::recalculateMetrics() {
|
||||
boundingRadius = std::numeric_limits<float>::min();
|
||||
|
@ -135,8 +135,7 @@ struct GeometryVertex {
|
||||
, colour(_colour) {
|
||||
}
|
||||
|
||||
GeometryVertex() {
|
||||
}
|
||||
GeometryVertex() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -260,7 +260,7 @@ GeometryPtr LoaderDFF::readGeometry(const RWBStream &stream) {
|
||||
size_t icount = std::accumulate(
|
||||
geom->subgeom.begin(), geom->subgeom.end(), 0u,
|
||||
[](size_t a, const SubGeometry &b) { return a + b.numIndices; });
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * icount, 0,
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * icount, nullptr,
|
||||
GL_STATIC_DRAW);
|
||||
for (auto &sg : geom->subgeom) {
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, sg.start * sizeof(uint32_t),
|
||||
|
@ -113,7 +113,7 @@ char* LoaderSDT::loadToMemory(size_t index, bool asWave) {
|
||||
fclose(fp);
|
||||
return raw_data;
|
||||
} else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Writes the contents of assetname to filename
|
||||
|
Loading…
Reference in New Issue
Block a user