Skip to content

Commit

Permalink
Misc header fixes.
Browse files Browse the repository at this point in the history
Add #pragma once, make headers more self-contained, a few ISO/POSIX
fixes (adding leading underscore to function names).
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Aug 5, 2017
1 parent 581908b commit 8dc6fdb
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/Common/inlining_macros.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#ifdef _MSC_VER
#pragma once
#endif
#ifndef INLINING_MACROS_H
#define INLINING_MACROS_H

Expand Down
2 changes: 0 additions & 2 deletions src/Common/xr_impexp_macros.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#ifdef _MSC_VER
#pragma once
#endif
#ifndef XR_IMPEXP_MACROS_H
#define XR_IMPEXP_MACROS_H

Expand Down
4 changes: 4 additions & 0 deletions src/Layers/xrRender/VertexCache.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once
#ifndef VERTEX_CACHE_H
#define VERTEX_CACHE_H
#include"Common/inlining_macros.h"
#include"xrCore/_types.h"
#include"xrCore/_stl_extensions.h"

class VertexCache
{
Expand Down
6 changes: 3 additions & 3 deletions src/utils/Shader_xrLC.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class Shader_xrLC_LIB
u32 GetID(LPCSTR name) const
{
for (auto it = library.begin(); it != library.end(); it++)
if (0 == stricmp(name, it->Name))
if (0 == _stricmp(name, it->Name))
return u32(it - library.begin());
return u32(-1);
}

Shader_xrLC* Get(LPCSTR name)
{
for (auto& shader : library)
if (0 == stricmp(name, shader.Name))
if (0 == _stricmp(name, shader.Name))
return &shader;
return nullptr;
}
Expand All @@ -117,7 +117,7 @@ class Shader_xrLC_LIB
void Remove(LPCSTR name)
{
for (auto it = library.begin(); it != library.end(); it++)
if (0 == stricmp(name, it->Name))
if (0 == _stricmp(name, it->Name))
{
library.erase(it);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/FS.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once
// FS.h: interface for the CFS class.
//
//////////////////////////////////////////////////////////////////////

#ifndef fsH
#define fsH
#include "_stl_extensions.h"

#define CFS_CompressMark (1ul << 31ul)
#define CFS_HeaderChunkID (666)
Expand Down
4 changes: 4 additions & 0 deletions src/xrCore/FTimer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once
#ifndef FTimerH
#define FTimerH
#include "xrCore_impexp.h"
#include "_stl_extensions.h"
#include "_math.h"
#include "log.h"

class CTimer_paused;

Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/Threading/Lock.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "xrCore/xrCore.h"
#include "xrCore/xrCore_impexp.h"

#include <mutex>
#include <atomic>
Expand Down
8 changes: 5 additions & 3 deletions src/xrCore/_color.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef __C__
#define __C__
#pragma once
#ifndef XRCORE_COLOR_H
#define XRCORE_COLOR_H
#include "vector.h" // clampr

// maps unsigned 8 bits/channel to D3DCOLOR
ICF u32 color_argb(u32 a, u32 r, u32 g, u32 b)
Expand Down Expand Up @@ -256,4 +258,4 @@ BOOL _valid(const _color<T>& c)
return _valid(c.r) && _valid(c.g) && _valid(c.b) && _valid(c.a);
}

#endif
#endif // XRCORE_COLOR_H
3 changes: 3 additions & 0 deletions src/xrCore/_plane.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once
#ifndef _PLANE
#define _PLANE
#include "_vector3d.h"
#include "_matrix.h"

template <class T>
class _plane
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/_rect.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#ifndef __FRECT
#define __FRECT
#include "_vector2.h"

template <class T>
struct _rect
Expand Down
5 changes: 3 additions & 2 deletions src/xrCore/_std_extensions.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef _STD_EXT_internal
#define _STD_EXT_internal

Expand Down Expand Up @@ -82,7 +83,7 @@ IC LPCSTR get_token_name(xr_token* tokens, int key)
IC int get_token_id(xr_token* tokens, LPCSTR key)
{
for (int k = 0; tokens[k].name; k++)
if (stricmp(tokens[k].name, key) == 0)
if (_stricmp(tokens[k].name, key) == 0)
return tokens[k].id;
return -1;
}
Expand Down Expand Up @@ -183,7 +184,7 @@ IC u32 xr_strlen(const char* S);
IC char* strext(const char* S) { return (char*)strrchr(S, '.'); }
IC u32 xr_strlen(const char* S) { return (u32)strlen(S); }
IC char* xr_strupr(char* S) { return _strupr(S); }
IC char* xr_strlwr(char* S) { return strlwr(S); }
IC char* xr_strlwr(char* S) { return _strlwr(S); }
#ifdef BREAK_AT_STRCMP
XRCORE_API int xr_strcmp(const char* S1, const char* S2);
#else
Expand Down
9 changes: 9 additions & 0 deletions src/xrCore/_vector2.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#pragma once
#ifndef __V2D__
#define __V2D__
#include "Common/inlining_macros.h"

#ifdef min
# undef min
#endif
#ifdef max
# undef max
#endif


template <class T>
struct _vector2
{
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/_vector3d.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef __V3D__
#define __V3D__
// XXX: review
Expand Down
6 changes: 6 additions & 0 deletions src/xrCore/log.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#pragma once
#ifndef logH
#define logH
#include "Common/Platform.hpp"
#include "xrCore_impexp.h"

class shared_str;
template <typename T, typename allocator> class xr_vector;

#define VPUSH(a) ((a).x), ((a).y), ((a).z)

Expand Down
3 changes: 3 additions & 0 deletions src/xrCore/memory_monitor.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef MEMORY_MONITOR_H
#define MEMORY_MONITOR_H

Expand All @@ -9,6 +10,8 @@

#ifdef USE_MEMORY_MONITOR

#include "xrCore_impexp.h"

namespace memory_monitor
{
XRCORE_API void flush_each_time(const bool& value);
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrMemory.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef xrMemoryH
#define xrMemoryH
#pragma once

#include "memory_monitor.h"

Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/xr_shared.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef xr_sharedH
#define xr_sharedH
#pragma once
#include "_stl_extensions.h"
#include "xrstring.h"

class XRCORE_API shared_value
{
Expand Down
6 changes: 5 additions & 1 deletion src/xrCore/xrsharedmem.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once
#ifndef xrsharedmemH
#define xrsharedmemH
#pragma once

#include "Threading/Lock.hpp"
#include "_stl_extensions.h"
#include "xrCore_impexp.h"

#pragma pack(push, 4)
//////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/IPhysicsGeometry.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef __IPHYSICS_GEOMETRY_H__
#define __IPHYSICS_GEOMETRY_H__

Expand Down
1 change: 1 addition & 0 deletions src/xrGame/alife_graph_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "alife_level_registry.h"

class CSE_ALifeCreatureActor;
class CSE_ALifeInventoryItem;

class CALifeGraphRegistry
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/inventory_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CInventoryOwner;
struct SHit;

class CSE_ALifeInventoryItem;
typedef CSE_ALifeInventoryItem::mask_num_items mask_inv_num_items;
typedef typename CSE_ALifeInventoryItem::mask_num_items mask_inv_num_items;

struct net_update_IItem
{
Expand Down
8 changes: 6 additions & 2 deletions src/xrPhysics/PHCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ enum EHitType;
};
static enum EEnvironment { peOnGround, peAtWall, peInAir };

class CPHCharacter : public CPHObject, public CPHSynchronize, public CPHDisablingTranslational, public IPhysicsElement
class CPHCharacter :
public CPHObject,
public CPHSynchronize,
public CPHDisablingTranslational,
public IPhysicsElement
#if 0
#ifdef DEBUG
,public pureRender
,public pureRender
#endif
#endif
{
Expand Down
1 change: 1 addition & 0 deletions src/xrServerEntities/xrServer_Objects_ALife.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CSE_ALifeObject;
class CALifeSmartTerrainTask;
#endif //#ifdef XRGAME_EXPORTS
class CALifeMonsterAbstract;
class CSE_ALifeInventoryItem;

struct SFillPropData
{
Expand Down
1 change: 1 addition & 0 deletions src/xrServerEntities/xrServer_Objects_ALife_Items.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
////////////////////////////////////////////////////////////////////////////
// Module : xrServer_Objects_ALife.h
// Created : 19.09.2002
Expand Down

0 comments on commit 8dc6fdb

Please sign in to comment.