Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce compile time by a few seconds #1118

Merged
merged 8 commits into from
Feb 15, 2024
5 changes: 0 additions & 5 deletions deps/baseconfig/src/always.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
#include "config.h"
#include "targetver.h"

#include "bittype.h"
#include "compiler.h"
#include "intrinsics.h"
#include "macros.h"
#include "platform.h"
#include "stringex.h"
#include "typeoperators.h"
#include "unichar.h"

#ifdef PLATFORM_WINDOWS
#include "utf.h"
#include <windef.h>
#define NAME_MAX FILENAME_MAX

Expand Down
2 changes: 2 additions & 0 deletions deps/baseconfig/src/unichar.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
#ifndef BASE_UNICHAR_H
#define BASE_UNICHAR_H

#include "macros.h"
#include <wchar.h>

#ifdef U_CHAR
Expand Down
12 changes: 10 additions & 2 deletions deps/captnlog/src/captainslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ void captainslog_free_varg_str(char *str);
#if __has_builtin(__builtin_debugtrap)
#define captainslog_debugtrap __builtin_debugtrap
#elif defined _WIN32 && !defined __WATCOMC__
#include <intrin.h>
#define captainslog_debugtrap __debugbreak
# if defined(_M_IX86)
// Avoids including <intrin.h> for faster compilation in MSVC.
trap_inline void captainslog_debugtrap(void)
{
__asm int 3
}
# else
# include <intrin.h>
# define captainslog_debugtrap __debugbreak
# endif
/* If we have GCC or compiler that tries to be compatible, use GCC inline assembly. */
#elif defined __GNUC__ || defined __clang__
#if defined(__i386__) || defined(__x86_64__)
Expand Down
8 changes: 8 additions & 0 deletions src/game/client/gui/wininstancedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,11 @@ WinInstanceData &WinInstanceData::operator=(const WinInstanceData &that)

return *this;
}

#ifdef GAME_DLL
#include <new>
WinInstanceData *WinInstanceData::Hook_Ctor()
{
return new (this) WinInstanceData;
}
#endif
2 changes: 1 addition & 1 deletion src/game/client/gui/wininstancedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class WinInstanceData
WinInstanceData &operator=(const WinInstanceData &that);

#ifdef GAME_DLL
WinInstanceData *Hook_Ctor() { return new (this) WinInstanceData; }
WinInstanceData *Hook_Ctor();
#endif

public:
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/system/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "ini.h"
#include "namekeygenerator.h"
#include <stdio.h>
#if defined PLATFORM_WINDOWS
#include <utf.h>
#endif

#ifndef GAME_DLL
ImageCollection *g_theMappedImageCollection = nullptr;
Expand Down
1 change: 0 additions & 1 deletion src/game/common/audio/audioeventinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
#pragma once

#include "asciistring.h"
#include "bitflags.h"
#include "ini.h"
#include "mempoolobj.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/common/audio/audiomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "filesystem.h"
#include "gamemusic.h"
#include "gamesounds.h"
#include "matrix3d.h"
#include "terrainlogic.h"
#include "w3dview.h"
#include <algorithm>
Expand Down
3 changes: 0 additions & 3 deletions src/game/common/bitflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,3 @@ const char *BitFlags<MODELCONDITION_COUNT>::s_bitNamesList[] = {
"DISGUISED",
nullptr,
};

// TODO Temp to force instantiation. Fixes issue with Parameter::Read_Parameter.
// template class BitFlags<KIND_OF_COUNT>;
1 change: 0 additions & 1 deletion src/game/common/bitflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
#pragma once

#include "always.h"
#include "asciistring.h"
#include "ini.h"
#include "xfer.h"
Expand Down
1 change: 0 additions & 1 deletion src/game/common/gamemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* LICENSE
*/
#include "gamemain.h"
#include "bitflags.h"
#include "disabledtypes.h"
#include "main.h"
#include "win32gameengine.h"
Expand Down
15 changes: 15 additions & 0 deletions src/game/common/system/asciistring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <captainslog.h>
#include <cctype>
#include <cstdio>
#if defined PLATFORM_WINDOWS
#include <utf.h>
#endif

Utf8String const Utf8String::s_emptyString(nullptr);

Expand Down Expand Up @@ -652,3 +655,15 @@ void Utf8String::Debug_Ignore_Leaks()
// TODO, does not seem to be implemented anywhere? It is called though...
}
#endif // GAME_DEBUG

#ifdef GAME_DLL
#include <new>
Utf8String *Utf8String::Hook_Ctor1(const char *s)
{
return new (this) Utf8String(s);
}
Utf8String *Utf8String::Hook_Ctor2(Utf8String const &string)
{
return new (this) Utf8String(string);
}
#endif // GAME_DLL
11 changes: 6 additions & 5 deletions src/game/common/system/asciistring.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
*/
#pragma once

#include "always.h"
#include "unichar.h"
#include <cstdarg>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <new>
#include <stdint.h>
#include <strings.h>

// Using STLPort seems to screw up some of the C++11 header inclusions.
Expand Down Expand Up @@ -188,9 +189,9 @@ class Utf8String
public:
static Utf8String const s_emptyString;

#ifdef GAME_DLL // This define is only set when building a hooking DLL.
Utf8String *Hook_Ctor1(const char *s) { return new (this) Utf8String(s); }
Utf8String *Hook_Ctor2(Utf8String const &string) { return new (this) Utf8String(string); }
#ifdef GAME_DLL
Utf8String *Hook_Ctor1(const char *s);
Utf8String *Hook_Ctor2(Utf8String const &string);
#endif

protected:
Expand Down
1 change: 1 addition & 0 deletions src/game/common/system/localfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define O_BINARY 0
#elif defined PLATFORM_WINDOWS
#include <io.h>
#include <utf.h>
// Wraps the wide string call with an adapter from utf8.
#undef open
#define open(filename, oflags, ...) _wopen(UTF8To16(filename), oflags, ##__VA_ARGS__)
Expand Down
3 changes: 3 additions & 0 deletions src/game/common/system/unicodestring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "memdynalloc.h"
#include <captainslog.h>
#include <stdio.h>
#if defined PLATFORM_WINDOWS
#include <utf.h>
#endif

#if !defined BUILD_WITH_ICU && defined PLATFORM_WINDOWS
#include <wctype.h>
Expand Down
2 changes: 1 addition & 1 deletion src/game/common/system/unicodestring.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
#pragma once

#include "always.h"
#include "critsection.h"
#include "unichar.h"
#include <cstdarg>
#include <cstddef>

Expand Down
2 changes: 1 addition & 1 deletion src/game/common/system/xfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* A full copy of the GNU General Public License can be found in
* LICENSE
*/
#include "xfer.h"
#include "bitflags.h"
#include "color.h"
#include "endiantype.h"
#include "gamestate.h"
#include "matrix3d.h"
Expand Down
19 changes: 14 additions & 5 deletions src/game/common/system/xfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@
#pragma once

#include "asciistring.h"
#include "color.h"
#include "coord.h"
#include "gametype.h"
#include "kindof.h"
#include "matrix3d.h"
#include "science.h"
#include "snapshot.h"
#include "unicodestring.h"
#include <list>
#include <vector>

template<int bits> class BitFlags;
class Coord3D;
class Coord2D;
class ICoord2D;
class ICoord3D;
class IRegion2D;
class IRegion3D;
class Matrix3D;
class Region2D;
class Region3D;
class RGBColor;
class RGBAColorReal;
class RGBAColorInt;
class Utf16String;
class SnapShot;

struct RealRange
{
Expand Down
1 change: 1 addition & 0 deletions src/game/common/system/xfercrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
#include "xfercrc.h"
#include "endiantype.h"
#include "snapshot.h"

// \brief Adds val to rotl m_crc
void XferCRC::Add_CRC(uint32_t val)
Expand Down
1 change: 1 addition & 0 deletions src/game/logic/object/helper/objectdefectionhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "objectdefectionhelper.h"
#include "audioeventrts.h"
#include "audiomanager.h"
#include "color.h"
#include "drawable.h"
#include "gamelogic.h"

Expand Down
1 change: 1 addition & 0 deletions src/game/logic/object/update/laserupdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once
#include "always.h"
#include "clientupdatemodule.h"
#include "coord.h"
#include "particlesysmanager.h"

class LaserUpdateModuleData : public ModuleData
Expand Down
1 change: 1 addition & 0 deletions src/game/logic/object/update/mobmemberslavedupdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "always.h"
#include "color.h"
#include "updatemodule.h"

class MobMemberSlavedUpdate : public UpdateModule, public SlavedUpdateInterface
Expand Down
1 change: 0 additions & 1 deletion src/game/logic/scriptengine/scriptparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once

#include "always.h"
#include "asciistring.h"
#include "bitflags.h"
#include "coord.h"
#include "datachunk.h"
Expand Down
1 change: 0 additions & 1 deletion src/game/logic/system/gamelogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once

#include "always.h"
#include "asciistring.h"
#include "bitflags.h"
#include "gametype.h"
#include "rtsutils.h"
Expand Down
3 changes: 3 additions & 0 deletions src/game/network/gamespy/thread/threadutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* LICENSE
*/
#include "threadutils.h"
#if defined PLATFORM_WINDOWS
#include <utf.h>
#endif

std::wstring MultiByteToWideCharSingleLine(const char *orig)
{
Expand Down
1 change: 1 addition & 0 deletions src/platform/w3dengine/client/drawable/draw/w3dropedraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
#pragma once
#include "always.h"
#include "color.h"
#include "w3dmodeldraw.h"

class Line3DClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
#pragma once
#include "always.h"
#include "color.h"
#include "w3dmodeldraw.h"

class Line3DClass;
Expand Down
12 changes: 12 additions & 0 deletions src/platform/w3dengine/client/w3droadbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,3 +2709,15 @@ void W3DRoadBuffer::Insert_Curve_Segment_At(int ndx1, int ndx2)
}
}
}

#ifdef GAME_DLL
#include <new>
W3DRoadBuffer *W3DRoadBuffer::Hook_Ctor()
{
return new (this) W3DRoadBuffer();
}
void W3DRoadBuffer::Hook_Dtor()
{
W3DRoadBuffer::~W3DRoadBuffer();
}
#endif
4 changes: 2 additions & 2 deletions src/platform/w3dengine/client/w3droadbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ class W3DRoadBuffer
int m_curNumRoadIndices;
bool m_dirty;
#ifdef GAME_DLL
W3DRoadBuffer *Hook_Ctor() { return new (this) W3DRoadBuffer(); }
void Hook_Dtor() { W3DRoadBuffer::~W3DRoadBuffer(); }
W3DRoadBuffer *Hook_Ctor();
void Hook_Dtor();
#endif
friend class BaseHeightMapRenderObjClass;
};
Expand Down
8 changes: 8 additions & 0 deletions src/platform/w3dengine/client/water/w3dwater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,3 +2419,11 @@ void WaterRenderObjClass::Setup_Jba_Water_Shader()
}
#endif
}

#ifdef GAME_DLL
#include <new>
WaterRenderObjClass *WaterRenderObjClass::Hook_Ctor()
{
return new (this) WaterRenderObjClass();
}
#endif
2 changes: 1 addition & 1 deletion src/platform/w3dengine/client/water/w3dwater.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class WaterRenderObjClass : public SnapShot, public RenderObjClass
WaterRenderObjClass();

#ifdef GAME_DLL
WaterRenderObjClass *Hook_Ctor() { return new (this) WaterRenderObjClass(); }
WaterRenderObjClass *Hook_Ctor();
#endif

virtual ~WaterRenderObjClass() override;
Expand Down
1 change: 1 addition & 0 deletions src/platform/w3dengine/common/win32localfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifdef PLATFORM_WINDOWS
#include <direct.h>
#include <io.h>
#include <utf.h>
#else
#include <dirent.h>
#include <sys/stat.h>
Expand Down
1 change: 1 addition & 0 deletions src/w3d/lib/cpudetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* LICENSE
*/
#include "cpudetect.h"
#include "intrinsics.h"
#include "systimer.h"
#include <cstdio>
#include <cstring>
Expand Down
1 change: 1 addition & 0 deletions src/w3d/lib/mpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* LICENSE
*/
#include "mpu.h"
#include "intrinsics.h"

unsigned long Get_CPU_Clock(unsigned long &high)
{
Expand Down
Loading
Loading