Skip to content

Commit

Permalink
More header cleaning, and a few compiler warnings squashed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Aug 5, 2017
1 parent 8e1d0b1 commit 6f24305
Show file tree
Hide file tree
Showing 23 changed files with 242 additions and 235 deletions.
9 changes: 7 additions & 2 deletions sdk/include/hxgrid/Interface/hxplatform.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#pragma once

#ifdef _XBOX
Expand All @@ -15,7 +14,13 @@

#else _WINDOWS_ANYWAY

// XXX: Perhaps requesting Windows 2000 functionality is a bit silly in 2016?
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0500
#endif

#include <windows.h>

Expand Down Expand Up @@ -125,4 +130,4 @@ void __inline MessageBeep(DWORD d)
}
#endif _XBOX

#endif __cplusplus
#endif __cplusplus
2 changes: 1 addition & 1 deletion src/Common/Compiler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#include "xr_impexp_macros.h"
#include "inlining_macros.h"
#include "xrCommon/inlining_macros.h"

#if defined(__GNUC__)
#define XR_ASSUME(expr) if (expr){} else __builtin_unreachable()
Expand Down
1 change: 1 addition & 0 deletions src/Common/PlatformWindows.inl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define DIRECTINPUT_VERSION 0x0800 //

#ifndef _WIN32_WINNT
// Request Windows XP functionality
#define _WIN32_WINNT 0x0501
#endif

Expand Down
4 changes: 4 additions & 0 deletions src/Layers/xrRender/ParticleEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ using namespace PS;
const u32 PS::uDT_STEP = 33;
const float PS::fDT_STEP = float(uDT_STEP) / 1000.f;

#ifdef _MSC_VER
#pragma warning(disable : 4701) // " potentially uninitialized local variable" (magnitude_sse does initialize it)
#endif

static void ApplyTexgen(const Fmatrix& mVP)
{
Fmatrix mTexgen;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/VertexCache.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#ifndef VERTEX_CACHE_H
#define VERTEX_CACHE_H
#include"Common/inlining_macros.h"
#include"xrCommon/inlining_macros.h"
#include"xrCore/_types.h"
#include"xrCore/_stl_extensions.h"

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__dsgraph_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class doug_lea_alloc
{
return (T*)g_render_allocator.malloc_impl(sizeof(T) * (u32)n);
}
void deallocate(pointer p, size_type n) const { g_render_allocator.free_impl((void*&)p); }
void deallocate(pointer p, size_type) const { g_render_allocator.free_impl((void*&)p); }
void deallocate(void* p, size_type n) const { g_render_allocator.free_impl(p); }
char* __charalloc(size_type n) { return (char*)allocate(n); }
void construct(pointer p, const T& _Val) { new(p) T(_Val); }
Expand Down
16 changes: 8 additions & 8 deletions src/Layers/xrRender/xrRender_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ class CCC_RestoreQuadIBData : public IConsole_Command
{
public:
CCC_RestoreQuadIBData(LPCSTR N) : IConsole_Command(N){};
virtual void Execute(LPCSTR args) { RCache.RestoreQuadIBData(); }
virtual void Execute(LPCSTR /*args*/) { RCache.RestoreQuadIBData(); }
};

class CCC_ModelPoolStat : public IConsole_Command
{
public:
CCC_ModelPoolStat(LPCSTR N) : IConsole_Command(N) { bEmptyArgsHandled = TRUE; };
virtual void Execute(LPCSTR args) { RImplementation.Models->dump(); }
virtual void Execute(LPCSTR /*args*/) { RImplementation.Models->dump(); }
};

class CCC_SSAO_Mode : public CCC_Token
Expand Down Expand Up @@ -383,7 +383,7 @@ class CCC_memory_stats : public IConsole_Command
protected:
public:
CCC_memory_stats(LPCSTR N) : IConsole_Command(N) { bEmptyArgsHandled = true; };
virtual void Execute(LPCSTR args)
virtual void Execute(LPCSTR /*args*/)
{
u32 m_base = 0;
u32 c_base = 0;
Expand Down Expand Up @@ -434,7 +434,7 @@ class CCC_BuildSSA : public IConsole_Command
{
public:
CCC_BuildSSA(LPCSTR N) : IConsole_Command(N) { bEmptyArgsHandled = TRUE; };
virtual void Execute(LPCSTR args)
virtual void Execute(LPCSTR /*args*/)
{
#if !defined(USE_DX10) && !defined(USE_DX11)
// TODO: DX10: Implement pixel calculator
Expand Down Expand Up @@ -470,7 +470,7 @@ class CCC_DofFar : public CCC_Float
}

// CCC_Dof should save all data as well as load from config
virtual void Save(IWriter* F) { ; }
virtual void Save(IWriter* /*F*/) { ; }
};

class CCC_DofNear : public CCC_Float
Expand Down Expand Up @@ -498,7 +498,7 @@ class CCC_DofNear : public CCC_Float
}

// CCC_Dof should save all data as well as load from config
virtual void Save(IWriter* F) { ; }
virtual void Save(IWriter* /*F*/) { ; }
};

class CCC_DofFocus : public CCC_Float
Expand Down Expand Up @@ -534,7 +534,7 @@ class CCC_DofFocus : public CCC_Float
}

// CCC_Dof should save all data as well as load from config
virtual void Save(IWriter* F) { ; }
virtual void Save(IWriter* /*F*/) { ; }
};

class CCC_Dof : public CCC_Vector3
Expand Down Expand Up @@ -570,7 +570,7 @@ class CCC_DumpResources : public IConsole_Command
{
public:
CCC_DumpResources(LPCSTR N) : IConsole_Command(N) { bEmptyArgsHandled = TRUE; };
virtual void Execute(LPCSTR args)
virtual void Execute(LPCSTR /*args*/)
{
RImplementation.Models->dump();
RImplementation.Resources->Dump(false);
Expand Down
2 changes: 1 addition & 1 deletion src/xrAICore/Navigation/graph_abstract_inline.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////////
// Module : graph_inline.h
// Module : graph_abstract_inline.h
// Created : 14.01.2004
// Modified : 19.02.2005
// Author : Dmitriy Iassenev
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions src/xrCommon/xalloc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#pragma once
#include "xrCore/xrMemory.h"

template <class T>
class xalloc
{
public:
typedef size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;

public:
template<class _Other>
struct rebind
{
typedef xalloc<_Other> other;
};

public:
pointer address(reference _Val) const { return &_Val; }
const_pointer address(const_reference _Val) const { return &_Val; }
xalloc() {}
xalloc(const xalloc<T>&) {}
template<class _Other>
xalloc(const xalloc<_Other>&) {}
template<class _Other>
xalloc<T>& operator=(const xalloc<_Other>&) { return *this; }
pointer allocate(size_type n, const void* p = nullptr) const { return xr_alloc<T>((u32)n); }
char* _charalloc(size_type n) { return (char*)allocate(n); }
void deallocate(pointer p, size_type n) const { xr_free(p); }
void deallocate(void* p, size_type n) const { xr_free(p); }
void construct(pointer p, const T& _Val) { std::_Construct(p, _Val); }
void destroy(pointer p) { std::_Destroy(p); }
size_type max_size() const
{
size_type _Count = (size_type)(-1)/sizeof(T);
return 0<_Count ? _Count : 1;
}
};

struct xr_allocator
{
template <typename T>
struct helper
{
typedef xalloc<T> result;
};

static void* alloc(const u32& n) { return xr_malloc((u32)n); }
template <typename T>
static void dealloc(T*& p) { xr_free(p); }
};

template <class _Ty, class _Other>
inline bool operator==(const xalloc<_Ty>&, const xalloc<_Other>&) { return true; }

template <class _Ty, class _Other>
inline bool operator!=(const xalloc<_Ty>&, const xalloc<_Other>&) { return false; }
88 changes: 88 additions & 0 deletions src/xrCommon/xr_vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once
#include <vector>
#include "xalloc.h"

#ifdef _M_AMD64
#define M_DONTDEFERCLEAR_EXT
#endif

#define M_DONTDEFERCLEAR_EXT // for mem-debug only

#define DEF_VECTOR(N, T)\
typedef xr_vector<T> N;\
typedef N::iterator N##_it;

#define DEFINE_VECTOR(T, N, I)\
typedef xr_vector<T> N;\
typedef N::iterator I;

// vector
template <typename T, typename allocator = xalloc<T>>
class xr_vector : public std::vector<T, allocator>
{
private:
typedef std::vector<T, allocator> inherited;

public:
typedef allocator allocator_type;

public:
xr_vector() : inherited() {}
xr_vector(size_t _count, const T& _value) : inherited(_count, _value) {}
explicit xr_vector(size_t _count) : inherited(_count) {}
u32 size() const { return (u32)inherited::size(); }

void clear_and_free() { inherited::clear(); }
void clear_not_free() { erase(begin(), end()); }
void clear_and_reserve()
{
if (capacity() <= size() + size()/4)
clear_not_free();
else
{
u32 old = size();
clear_and_free();
reserve(old);
}
}
#ifdef M_DONTDEFERCLEAR_EXT // defined (or not) by xalloc.h
void clear() { clear_and_free(); }
#else
void clear() { clear_not_free(); }
#endif
const_reference operator[](size_type _Pos) const
{
VERIFY2(_Pos<size(),
make_string("index is out of range: index requested[%d], size of container[%d]", _Pos, size()).c_str());
return *(begin()+_Pos);
}
reference operator[](size_type _Pos)
{
VERIFY2(_Pos<size(),
make_string("index is out of range: index requested[%d], size of container[%d]", _Pos, size()).c_str());
return *(begin()+_Pos);
}
};

// vector<bool>
template <>
class xr_vector<bool, xalloc<bool>> : public std::vector<bool, xalloc<bool>>
{
private:
typedef std::vector<bool, xalloc<bool>> inherited;

public:
u32 size() const { return (u32)inherited::size(); }
void clear() { erase(begin(), end()); }
};

template <typename allocator>
class xr_vector<bool, allocator> : public std::vector<bool, allocator>
{
private:
typedef std::vector<bool, allocator> inherited;

public:
u32 size() const { return (u32)inherited::size(); }
void clear() { erase(begin(), end()); }
};
2 changes: 1 addition & 1 deletion src/xrCore/_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "cpuid.h"
#include "xrCore_impexp.h"
#include "Common/inlining_macros.h"
#include "xrCommon/inlining_macros.h"
#ifdef _MSC_VER
#include <intrin.h> // __rdtsc
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/_quaternion.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __Q__
#define __Q__
#include "Common/inlining_macros.h"
#include "xrCommon/inlining_macros.h"
#include "_vector3d.h"

/***************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/_random.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _LOCAL_RAND
#define _LOCAL_RAND
#include "_types.h"
#include "Common/inlining_macros.h"
#include "xrCommon/inlining_macros.h"
#include "xrCore_impexp.h"

/*
Expand Down
Loading

0 comments on commit 6f24305

Please sign in to comment.