mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-26 12:22:41 +01:00
Increase warnings to pedantic and fix rwlib/rwengine warnings
This commit is contained in:
parent
0057f76630
commit
d2f254731a
@ -4,7 +4,7 @@ project(OpenRW)
|
|||||||
|
|
||||||
# Global Build Configuration
|
# Global Build Configuration
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DRW_DEBUG=1")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DRW_DEBUG=1")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pthread -Wextra")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pthread -Wextra -Wpedantic")
|
||||||
|
|
||||||
# Optional components
|
# Optional components
|
||||||
SET(BUILD_SCRIPT_TOOL TRUE CACHE BOOL "Build script decompiler tool")
|
SET(BUILD_SCRIPT_TOOL TRUE CACHE BOOL "Build script decompiler tool")
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
struct Name {\
|
struct Name {\
|
||||||
static const char* VertexShader;\
|
static const char* VertexShader;\
|
||||||
static const char* FragmentShader;\
|
static const char* FragmentShader;\
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief collection of shaders to make managing them a little easier.
|
* @brief collection of shaders to make managing them a little easier.
|
||||||
@ -16,12 +16,12 @@ namespace GameShaders {
|
|||||||
/**
|
/**
|
||||||
* High Quality Projected-Grid water shader
|
* High Quality Projected-Grid water shader
|
||||||
*/
|
*/
|
||||||
SHADER_VF(WaterHQ)
|
SHADER_VF(WaterHQ);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple 3D masking shader
|
* Simple 3D masking shader
|
||||||
*/
|
*/
|
||||||
SHADER_VF(Mask3D)
|
SHADER_VF(Mask3D);
|
||||||
|
|
||||||
struct Sky {
|
struct Sky {
|
||||||
static const char* VertexShader;
|
static const char* VertexShader;
|
||||||
|
@ -59,8 +59,9 @@ std::string findPathRealCase(const std::string& base, const std::string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
#else
|
#else
|
||||||
// Is anything other than Windows likely to fall here?
|
// Is anything other than Windows likely to fall here?
|
||||||
|
@ -565,7 +565,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
|
|
||||||
BlockDword numScripts;
|
BlockDword numScripts;
|
||||||
READ_SIZE(numScripts)
|
READ_SIZE(numScripts)
|
||||||
Block0RunningScript scripts[numScripts];
|
std::vector<Block0RunningScript> scripts(numScripts);
|
||||||
for (size_t i = 0; i < numScripts; ++i)
|
for (size_t i = 0; i < numScripts; ++i)
|
||||||
{
|
{
|
||||||
READ_VALUE(scripts[i]);
|
READ_VALUE(scripts[i]);
|
||||||
@ -579,7 +579,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
BlockDword playerCount;
|
BlockDword playerCount;
|
||||||
READ_SIZE(playerCount)
|
READ_SIZE(playerCount)
|
||||||
|
|
||||||
Block1PlayerPed players[playerCount];
|
std::vector<Block1PlayerPed> players(playerCount);
|
||||||
for(unsigned int p = 0; p < playerCount; ++p) {
|
for(unsigned int p = 0; p < playerCount; ++p) {
|
||||||
Block1PlayerPed& ped = players[p];
|
Block1PlayerPed& ped = players[p];
|
||||||
READ_VALUE(ped.unknown0)
|
READ_VALUE(ped.unknown0)
|
||||||
@ -620,7 +620,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
READ_VALUE(garageData.GA_21lastTime)
|
READ_VALUE(garageData.GA_21lastTime)
|
||||||
READ_VALUE(garageData.cars)
|
READ_VALUE(garageData.cars)
|
||||||
|
|
||||||
StructGarage garages[garageData.garageCount];
|
std::vector<StructGarage> garages(garageData.garageCount);
|
||||||
for (size_t i = 0; i < garageData.garageCount; ++i)
|
for (size_t i = 0; i < garageData.garageCount; ++i)
|
||||||
{
|
{
|
||||||
READ_VALUE(garages[i]);
|
READ_VALUE(garages[i]);
|
||||||
@ -652,7 +652,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
READ_VALUE(vehicleCount)
|
READ_VALUE(vehicleCount)
|
||||||
READ_VALUE(boatCount)
|
READ_VALUE(boatCount)
|
||||||
|
|
||||||
Block3Vehicle vehicles[vehicleCount];
|
std::vector<Block3Vehicle> vehicles(vehicleCount);
|
||||||
for(size_t v = 0; v < vehicleCount; ++v) {
|
for(size_t v = 0; v < vehicleCount; ++v) {
|
||||||
Block3Vehicle& veh = vehicles[v];
|
Block3Vehicle& veh = vehicles[v];
|
||||||
READ_VALUE(veh.unknown1)
|
READ_VALUE(veh.unknown1)
|
||||||
@ -663,7 +663,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
std::cout << " v " << veh.modelId << " " << veh.state.position.x << " " << veh.state.position.y << " " << veh.state.position.z << std::endl;
|
std::cout << " v " << veh.modelId << " " << veh.state.position.x << " " << veh.state.position.y << " " << veh.state.position.z << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Block3Boat boats[boatCount];
|
std::vector<Block3Boat> boats(boatCount);
|
||||||
for(size_t v = 0; v < boatCount; ++v) {
|
for(size_t v = 0; v < boatCount; ++v) {
|
||||||
Block3Boat& veh = boats[v];
|
Block3Boat& veh = boats[v];
|
||||||
READ_VALUE(veh.unknown1)
|
READ_VALUE(veh.unknown1)
|
||||||
@ -684,7 +684,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
BlockDword objectCount;
|
BlockDword objectCount;
|
||||||
READ_VALUE(objectCount);
|
READ_VALUE(objectCount);
|
||||||
|
|
||||||
Block4Object objects[objectCount];
|
std::vector<Block4Object> objects(objectCount);
|
||||||
for(size_t o = 0; o < objectCount; ++o)
|
for(size_t o = 0; o < objectCount; ++o)
|
||||||
{
|
{
|
||||||
Block4Object &obj = objects[o];
|
Block4Object &obj = objects[o];
|
||||||
@ -772,7 +772,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
|
|
||||||
Block8Data phoneData;
|
Block8Data phoneData;
|
||||||
READ_VALUE(phoneData);
|
READ_VALUE(phoneData);
|
||||||
Block8Phone phones[phoneData.numPhones];
|
std::vector<Block8Phone> phones(phoneData.numPhones);
|
||||||
for (size_t p = 0; p < phoneData.numPhones; ++p) {
|
for (size_t p = 0; p < phoneData.numPhones; ++p) {
|
||||||
Block8Phone &phone = phones[p];
|
Block8Phone &phone = phones[p];
|
||||||
READ_VALUE(phone)
|
READ_VALUE(phone)
|
||||||
@ -922,7 +922,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
Block13Data carGeneratorData;
|
Block13Data carGeneratorData;
|
||||||
READ_VALUE(carGeneratorData);
|
READ_VALUE(carGeneratorData);
|
||||||
|
|
||||||
Block13CarGenerator carGenerators[carGeneratorData.generatorCount];
|
std::vector<Block13CarGenerator> carGenerators(carGeneratorData.generatorCount);
|
||||||
for(size_t g = 0; g < carGeneratorData.generatorCount; ++g) {
|
for(size_t g = 0; g < carGeneratorData.generatorCount; ++g) {
|
||||||
READ_VALUE(carGenerators[g])
|
READ_VALUE(carGenerators[g])
|
||||||
}
|
}
|
||||||
@ -943,7 +943,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
|
|
||||||
BlockDword particleCount;
|
BlockDword particleCount;
|
||||||
READ_VALUE(particleCount);
|
READ_VALUE(particleCount);
|
||||||
Block14Particle particles[particleCount];
|
std::vector<Block14Particle> particles(particleCount);
|
||||||
for(size_t p = 0; p < particleCount; ++p) {
|
for(size_t p = 0; p < particleCount; ++p) {
|
||||||
READ_VALUE(particles[p])
|
READ_VALUE(particles[p])
|
||||||
}
|
}
|
||||||
@ -963,7 +963,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
|||||||
BlockDword audioCount;
|
BlockDword audioCount;
|
||||||
READ_VALUE(audioCount)
|
READ_VALUE(audioCount)
|
||||||
|
|
||||||
Block15AudioObject audioObjects[audioCount];
|
std::vector<Block15AudioObject> audioObjects(audioCount);
|
||||||
for(size_t a = 0; a < audioCount; ++a) {
|
for(size_t a = 0; a < audioCount; ++a) {
|
||||||
READ_VALUE(audioObjects[a])
|
READ_VALUE(audioObjects[a])
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,8 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
|||||||
skyDbuff.setFaceType(GL_TRIANGLES);
|
skyDbuff.setFaceType(GL_TRIANGLES);
|
||||||
|
|
||||||
glGenBuffers(1, &skydomeIBO);
|
glGenBuffers(1, &skydomeIBO);
|
||||||
GLuint skydomeIndBuff[rows*segments*6];
|
std::vector<GLuint> skydomeIndBuff;
|
||||||
|
skydomeIndBuff.resize(rows*segments*6);
|
||||||
for( size_t r = 0, i = 0; r < (rows-1); ++r ) {
|
for( size_t r = 0, i = 0; r < (rows-1); ++r ) {
|
||||||
for( size_t s = 0; s < (segments-1); ++s ) {
|
for( size_t s = 0; s < (segments-1); ++s ) {
|
||||||
skydomeIndBuff[i++] = r * segments + s;
|
skydomeIndBuff[i++] = r * segments + s;
|
||||||
@ -171,7 +172,7 @@ GameRenderer::GameRenderer(Logger* log, GameData* _data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skydomeIBO);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skydomeIBO);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(skydomeIndBuff), skydomeIndBuff, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * skydomeIndBuff.size(), skydomeIndBuff.data(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace RW
|
|||||||
/// Loading the resource failed
|
/// Loading the resource failed
|
||||||
Failed = 2
|
Failed = 2
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T> class ResourceHandle
|
template<class T> class ResourceHandle
|
||||||
|
@ -25,7 +25,7 @@ TextureData::Handle getErrorTexture()
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, gErrorTextureData
|
GL_RGBA, GL_UNSIGNED_BYTE, gErrorTextureData
|
||||||
);
|
);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|
||||||
tex = TextureData::create(errTexName, {2, 2}, false);
|
tex = TextureData::create(errTexName, {2, 2}, false);
|
||||||
}
|
}
|
||||||
return tex;
|
return tex;
|
||||||
@ -42,7 +42,7 @@ void processPalette(uint32_t* fullColor, RW::BinaryStreamSection& rootSection)
|
|||||||
|
|
||||||
for(size_t j = 0; j < raster_size; ++j)
|
for(size_t j = 0; j < raster_size; ++j)
|
||||||
{
|
{
|
||||||
fullColor[j] = palette[coldata[j]];
|
*(fullColor++) = palette[coldata[j]];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -61,26 +61,26 @@ TextureData::Handle createTexture(RW::BSTextureNative& texNative, RW::BinaryStre
|
|||||||
texNative.rasterformat == RW::BSTextureNative::FORMAT_888;
|
texNative.rasterformat == RW::BSTextureNative::FORMAT_888;
|
||||||
// Export this value
|
// Export this value
|
||||||
bool transparent = !((texNative.rasterformat&RW::BSTextureNative::FORMAT_888) == RW::BSTextureNative::FORMAT_888);
|
bool transparent = !((texNative.rasterformat&RW::BSTextureNative::FORMAT_888) == RW::BSTextureNative::FORMAT_888);
|
||||||
|
|
||||||
if(! (isPal8 || isFulc)) {
|
if(! (isPal8 || isFulc)) {
|
||||||
std::cerr << "Unsuported raster format " << std::dec << texNative.rasterformat << std::endl;
|
std::cerr << "Unsuported raster format " << std::dec << texNative.rasterformat << std::endl;
|
||||||
return getErrorTexture();
|
return getErrorTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint textureName = 0;
|
GLuint textureName = 0;
|
||||||
|
|
||||||
if(isPal8)
|
if(isPal8)
|
||||||
{
|
{
|
||||||
uint32_t fullColor[texNative.width * texNative.height];
|
std::vector<uint32_t> fullColor(texNative.width * texNative.height);
|
||||||
|
|
||||||
processPalette(fullColor, rootSection);
|
processPalette(fullColor.data(), rootSection);
|
||||||
|
|
||||||
glGenTextures(1, &textureName);
|
glGenTextures(1, &textureName);
|
||||||
glBindTexture(GL_TEXTURE_2D, textureName);
|
glBindTexture(GL_TEXTURE_2D, textureName);
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D, 0, GL_RGBA,
|
GL_TEXTURE_2D, 0, GL_RGBA,
|
||||||
texNative.width, texNative.height, 0,
|
texNative.width, texNative.height, 0,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, fullColor
|
GL_RGBA, GL_UNSIGNED_BYTE, fullColor.data()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if(isFulc)
|
else if(isFulc)
|
||||||
@ -187,7 +187,7 @@ bool TextureLoader::loadFromMemory(FileHandle file, TextureArchive &inTextures)
|
|||||||
std::string alpha = std::string(texNative.alphaName);
|
std::string alpha = std::string(texNative.alphaName);
|
||||||
std::transform(name.begin(), name.end(), name.begin(), ::tolower );
|
std::transform(name.begin(), name.end(), name.begin(), ::tolower );
|
||||||
std::transform(alpha.begin(), alpha.end(), alpha.begin(), ::tolower );
|
std::transform(alpha.begin(), alpha.end(), alpha.begin(), ::tolower );
|
||||||
|
|
||||||
auto texture = createTexture(texNative, rootSection);
|
auto texture = createTexture(texNative, rootSection);
|
||||||
|
|
||||||
inTextures[{name, alpha}] = texture;
|
inTextures[{name, alpha}] = texture;
|
||||||
|
Loading…
Reference in New Issue
Block a user