Skip to content

Commit

Permalink
Fix almost all -Wall warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterkatze committed Mar 26, 2023
1 parent fa59b45 commit 1fdbcd5
Show file tree
Hide file tree
Showing 463 changed files with 3,172 additions and 2,420 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.16)
project(OpenXRay)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (CMAKE_VERBOSE_MAKEFILE)
set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)
Expand Down Expand Up @@ -303,13 +304,15 @@ set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}"
"-Wall"
#"-Werror"
#"-Wextra"
"-Wextra"
#"-pedantic"
"-Wno-unknown-pragmas"
"-Wno-strict-aliasing"
"-Wno-parentheses"
"-Wno-unused-label"
"-Wno-unused-parameter"
"-Wno-switch"
"-Wno-interference-size"
#"-Wno-padded"
#"-Wno-c++98-compat"
#"-Wno-c++98-compat-pedantic"
Expand Down
5 changes: 5 additions & 0 deletions Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
add_subdirectory(LuaJIT-proj)

add_subdirectory(luabind)
set_target_properties(xrLuabind PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:xrLuabind,INTERFACE_INCLUDE_DIRECTORIES>
)

if (USE_CXIMAGE)
add_subdirectory(cximage)
endif()
Expand Down
2 changes: 1 addition & 1 deletion Externals/cximage/ximage.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ typedef struct tagCxTextInfo
DWORD GetType() const;
const char* GetLastError();
static const TCHAR* GetVersion();
static const float GetVersionNumber();
static float GetVersionNumber();

DWORD GetFrameDelay() const;
void SetFrameDelay(DWORD d);
Expand Down
2 changes: 1 addition & 1 deletion Externals/cximage/ximainfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ DWORD CxImage::UnDump(const BYTE * src)
* - CCC = minor revision (letter)
* - DDDD = experimental revision
*/
const float CxImage::GetVersionNumber()
float CxImage::GetVersionNumber()
{
return 6.000000015f;
}
Expand Down
2 changes: 1 addition & 1 deletion Externals/libogg
Submodule libogg updated 1 files
+1 −0 CMakeLists.txt
2 changes: 1 addition & 1 deletion Externals/ode/include/ode/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ enum {
};

/* class numbers - each geometry object needs a unique number */
enum {
enum dClassNumber {
dSphereClass = 0,
dBoxClass,
dCapsuleClass,
Expand Down
20 changes: 7 additions & 13 deletions Externals/ode/include/ode/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ void dCloseODE();
/* standard classes */

/* class numbers */
extern GLOBAL_SHAREDLIB_SPEC int dSphereClass;
extern GLOBAL_SHAREDLIB_SPEC int dBoxClass;
extern GLOBAL_SHAREDLIB_SPEC int dCapsuleClass;
extern GLOBAL_SHAREDLIB_SPEC int dPlaneClass;
extern GLOBAL_SHAREDLIB_SPEC int dGeomGroupClass;
extern GLOBAL_SHAREDLIB_SPEC int dGeomTransformClass;
//extern GLOBAL_SHAREDLIB_SPEC int dSphereClassVariable;
//extern GLOBAL_SHAREDLIB_SPEC int dBoxClassVariable;
//extern GLOBAL_SHAREDLIB_SPEC int dCapsuleClassVariable;
//extern GLOBAL_SHAREDLIB_SPEC int dPlaneClassVariable;
//extern GLOBAL_SHAREDLIB_SPEC int dGeomGroupClassVariable;
//extern GLOBAL_SHAREDLIB_SPEC int dGeomTransformClassVariable;

/* constructors */
dGeomID dCreateSphere (dSpaceID space, dReal radius);
Expand Down Expand Up @@ -138,13 +138,7 @@ typedef dColliderFn * dGetColliderFnFn (int num);
typedef void dGeomDtorFn (dGeomID o);
typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);

typedef struct dGeomClass {
int bytes;
dGetColliderFnFn *collider;
dGetAABBFn *aabb;
dAABBTestFn *aabb_test;
dGeomDtorFn *dtor;
} dGeomClass;
struct dGeomClass;

int dCreateGeomClass (const dGeomClass *classptr);
void * dGeomGetClassData (dGeomID);
Expand Down
6 changes: 3 additions & 3 deletions Externals/ode/include/ode/space.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ typedef struct dGeomSpaceData {
} dGeomSpaceData;


dSpaceID dSimpleSpaceCreate (int dummy);
dSpaceID dHashSpaceCreate (int dummy);
dSpaceID dQuadTreeSpaceCreate (int dummy, dVector3 Center, dVector3 Extents, int Depth);
//dSpaceID dSimpleSpaceCreate (int dummy);
//dSpaceID dHashSpaceCreate (int dummy);
//dSpaceID dQuadTreeSpaceCreate (int dummy, dVector3 Center, dVector3 Extents, int Depth);

void dSpaceDestroy (dSpaceID);
void dSpaceAdd (dSpaceID, dGeomID);
Expand Down
2 changes: 1 addition & 1 deletion Externals/ode/ode/src/collision_quadtreespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ struct dxQuadTreeSpace : public dxSpace{
};

dxQuadTreeSpace::dxQuadTreeSpace(dSpaceID _space, dVector3 Center, dVector3 Extents, int Depth) : dxSpace(_space){
type = dQuadTreeSpaceClass;
type = dClassNumber::dQuadTreeSpaceClass;

int BlockCount = 0;
for (int i = 0; i <= Depth; i++){
Expand Down
4 changes: 2 additions & 2 deletions Externals/ode/ode/src/collision_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct dxSimpleSpace : public dxSpace {

dxSimpleSpace::dxSimpleSpace (dSpaceID _space) : dxSpace (_space)
{
type = dSimpleSpaceClass;
type = dClassNumber::dSimpleSpaceClass;
}


Expand Down Expand Up @@ -398,7 +398,7 @@ struct dxHashSpace : public dxSpace {

dxHashSpace::dxHashSpace (dSpaceID _space) : dxSpace (_space)
{
type = dHashSpaceClass;
type = dClassNumber::dHashSpaceClass;
global_minlevel = -3;
global_maxlevel = 10;
}
Expand Down
2 changes: 1 addition & 1 deletion Externals/ode/ode/src/collision_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct dxGeomTransform : public dxGeom {

dxGeomTransform::dxGeomTransform (dSpaceID space) : dxGeom (space,1)
{
type = dGeomTransformClass;
type = dClassNumber::dGeomTransformClass;
obj = 0;
cleanup = 0;
infomode = 0;
Expand Down
2 changes: 1 addition & 1 deletion Externals/ode/ode/src/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void dTimerReport (FILE *fout, int average)
t = total;
p = 100.0;
}
fprintf (fout,"%-*s %7.2fms %6.2f%%",maxl,event[i].description,
fprintf (fout,"%-*s %7.2fms %6.2f%%", static_cast<int>(maxl), event[i].description,
t*ccunit * 1000.0, p);
if (average && i < (num-1)) {
fprintf (fout," (avg %7.2fms %6.2f%%)",
Expand Down
2 changes: 1 addition & 1 deletion Externals/sse2neon
8 changes: 4 additions & 4 deletions src/Layers/xrRender/Blender_Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ void CBlender_Compile::PassSET_ablend_mode(BOOL bABlend, u32 abSRC, u32 abDST)
if (bABlend && D3DBLEND_ONE == abSRC && D3DBLEND_ZERO == abDST)
bABlend = FALSE;
RS.SetRS(D3DRS_ALPHABLENDENABLE, BC(bABlend));
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : D3DBLEND_ONE);
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : D3DBLEND_ZERO);
RS.SetRS(D3DRS_SRCBLEND, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
RS.SetRS(D3DRS_DESTBLEND, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));

#if defined(USE_DX11) || defined(USE_OGL)
// Since in our engine D3DRS_SEPARATEALPHABLENDENABLE state is
// always set to false and in DirectX 10 blend functions for
// color and alpha are always independent, assign blend options for
// alpha in DX11 identical to color.
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : D3DBLEND_ONE);
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : D3DBLEND_ZERO);
RS.SetRS(D3DRS_SRCBLENDALPHA, bABlend ? abSRC : static_cast<decltype(abSRC)>(D3DBLEND_ONE));
RS.SetRS(D3DRS_DESTBLENDALPHA, bABlend ? abDST : static_cast<decltype(abDST)>(D3DBLEND_ZERO));
#endif // !USE_DX9
}
void CBlender_Compile::PassSET_ablend_aref(BOOL bATest, u32 aRef)
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ u32 CBlender_Compile::i_Sampler(LPCSTR _name)
fix_texture_name(name);

// Find index
ref_constant C = ctable.get(name, ctable.dx9compatibility ? RC_sampler : u16(-1));
ref_constant C = ctable.get(name, ctable.dx9compatibility ? static_cast<u16>(RC_sampler) : u16(-1));
if (!C)
return u32(-1);

Expand Down
47 changes: 0 additions & 47 deletions src/Layers/xrRender/ShaderResourceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,6 @@ inline std::pair<char, GLuint> GLUseBinary(pcstr* buffer, size_t size, const GLe

return { 'p', program };
}

static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
const GLuint program = glCreateProgram();
R_ASSERT(program);
if (GLEW_VERSION_4_3)
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
// XXX: support caching for monolithic programs
//if (HW.ShaderBinarySupported)
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));

CHK_GL(glAttachShader(program, ps));
CHK_GL(glAttachShader(program, vs));
if (gs)
CHK_GL(glAttachShader(program, gs));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
CHK_GL(glLinkProgram(program));
CHK_GL(glDetachShader(program, ps));
CHK_GL(glDetachShader(program, vs));
if (gs)
CHK_GL(glDetachShader(program, gs));

GLint status{};
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
if (GLboolean(status) == GL_FALSE)
{
show_compile_errors(name, program, 0);
CHK_GL(glDeleteProgram(program));
return 0; // 0 means error
}
return program;
}

static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
GLuint pp;
CHK_GL(glGenProgramPipelines(1, &pp));
R_ASSERT(pp);
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
CHK_GL(glValidateProgramPipeline(pp));
return pp;
}
#endif

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__pixel_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ r_aabb_ssa r_pixel_calculator::calculate(dxRender_Visual* V)
#if defined(USE_DX9) || defined(USE_DX11)
using namespace DirectX;

r_aabb_ssa result = {0};
r_aabb_ssa result = {};
float area = float(_sqr(rt_dimensions));

//
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glBufferUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void IterVertexDeclaration(const VertexElement* dxdecl, F&& callback)
if (desc.Stream == 0xFF)
break;

GLuint location = VertexUsageList[desc.Usage];
GLint location = VertexUsageList[desc.Usage];
GLint size = VertexSizeList[desc.Type];
GLenum type = VertexTypeList[desc.Type];
GLboolean normalized = VertexNormalizedList[desc.Type];
Expand Down
47 changes: 47 additions & 0 deletions src/Layers/xrRenderGL/glResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,53 @@ SPP* CResourceManager::_CreatePP(pcstr vs, pcstr ps, pcstr gs, pcstr hs, pcstr d
return pp;
}

static GLuint GLGeneratePipeline(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
GLuint pp;
CHK_GL(glGenProgramPipelines(1, &pp));
R_ASSERT(pp);
CHK_GL(glUseProgramStages(pp, GL_FRAGMENT_SHADER_BIT, ps));
CHK_GL(glUseProgramStages(pp, GL_VERTEX_SHADER_BIT, vs));
CHK_GL(glUseProgramStages(pp, GL_GEOMETRY_SHADER_BIT, gs));
CHK_GL(glValidateProgramPipeline(pp));
return pp;
}

static GLuint GLLinkMonolithicProgram(pcstr name, GLuint ps, GLuint vs, GLuint gs)
{
const GLuint program = glCreateProgram();
R_ASSERT(program);
if (GLEW_VERSION_4_3)
CHK_GL(glObjectLabel(GL_PROGRAM, program, -1, name));
// XXX: support caching for monolithic programs
//if (HW.ShaderBinarySupported)
// CHK_GL(glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, (GLint)GL_TRUE));

CHK_GL(glAttachShader(program, ps));
CHK_GL(glAttachShader(program, vs));
if (gs)
CHK_GL(glAttachShader(program, gs));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target"));
CHK_GL(glBindFragDataLocation(program, 0, "SV_Target0"));
CHK_GL(glBindFragDataLocation(program, 1, "SV_Target1"));
CHK_GL(glBindFragDataLocation(program, 2, "SV_Target2"));
CHK_GL(glLinkProgram(program));
CHK_GL(glDetachShader(program, ps));
CHK_GL(glDetachShader(program, vs));
if (gs)
CHK_GL(glDetachShader(program, gs));

GLint status{};
CHK_GL(glGetProgramiv(program, GL_LINK_STATUS, &status));
if (GLboolean(status) == GL_FALSE)
{
show_compile_errors(name, program, 0);
CHK_GL(glDeleteProgram(program));
return 0; // 0 means error
}
return program;
}

bool CResourceManager::_LinkPP(SPass& pass)
{
auto& pp = *pass.pp;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void glState::UpdateRenderState(u32 name, u32 value)

void glState::UpdateSamplerState(u32 stage, u32 name, u32 value)
{
if (stage < 0 || stage >= CTexture::mtMaxCombinedShaderTextures)
if (stage >= CTexture::mtMaxCombinedShaderTextures)
return;

GLint currentFilter = (GLint)GL_NEAREST;
Expand Down
4 changes: 4 additions & 0 deletions src/Layers/xrRenderPC_GL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/src/Layers/xrRender
${CMAKE_SOURCE_DIR}/src/Include/xrRender
${CMAKE_SOURCE_DIR}/src/Layers/xrRender_R2
)

target_include_directories(${PROJECT_NAME}
SYSTEM PRIVATE
${CMAKE_SOURCE_DIR}/Externals/luabind
${CMAKE_SOURCE_DIR}/Externals/gli
${CMAKE_SOURCE_DIR}/Externals/gli/external
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/rgl_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class shader_sources_manager
// TODO: OGL: make ignore commented includes
void load_includes(IReader* file)
{
cpcstr sourceData = static_cast<cpcstr>(file->pointer());
const auto sourceData = const_cast<cpcstr>(static_cast<pstr>(file->pointer()));
const size_t dataLength = file->length();

// Copy source file data into a null-terminated buffer
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_rendertarget_phase_hdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void CRenderTarget::phase_hdao()

// set the cs shader output
u32 UAVInitialCounts = 1;
ID3D11UnorderedAccessView* uav[1] = {0};
ID3D11UnorderedAccessView* uav[1] = {};
ID3D11ShaderResourceView* srv[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// ID3D11ShaderResourceView* new_srv[2]={rt_ssao_temp1->pTexture->m_pSRView,rt_ssao_temp2->pTexture->m_pSRView};
// HW.pContext->CSSetShaderResources( 0, 2, new_srv );
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static bool must_enable_old_cascades()
R_ASSERT3(accumSunNear, "Can't open shader", "accum_sun_near.ps");
do
{
xr_string str(static_cast<cpcstr>(accumSunNear->pointer()), accumSunNear->length());
xr_string str(static_cast<cpstr>(accumSunNear->pointer()), accumSunNear->length());

pcstr begin = strstr(str.c_str(), "float4");
if (!begin)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mp_gpprof_server/gamespy_sake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void sake_processor::request_callback(
me->process_out_request(tmp_in, tmp_out);
me->m_current_offset += tmp_out->mNumRecords;
if ((tmp_out->mNumRecords == max_request_records) &&
(static_cast<std::size_t>(me->m_current_offset) < me->m_request_names.size()))
(static_cast<size_t>(me->m_current_offset) < me->m_request_names.size()))
{
me->fetch();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
GSIACResult __GSIACResult = GSIACWaiting;

// this makes the gamename available to all of the SDKs
char __GSIACGamename[64] = {0};
char __GSIACGamename[64] = {};

// this allows devs to do their own hostname resolution
char GSIACHostname[64] = {0};
char GSIACHostname[64] = {};

// used to keep state during the check
static struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ extern gsMemMgrContext gsMemMgrContextCurrent;

// Memtype Tag stack
#define MEM_TAG_STACK_MAX 10 // max stack depth
static gsi_u8 MemTagStack [MEM_TAG_STACK_MAX] = {0};
static gsi_u8 MemTagStack [MEM_TAG_STACK_MAX] = {};
static gsi_u32 MemTagStackIndex = 0;


Expand Down
Loading

0 comments on commit 1fdbcd5

Please sign in to comment.