From a28a6621dae0e16930121d069480f0ac6ac71311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Wed, 12 Aug 2009 22:03:50 +0200 Subject: [PATCH] shuffle the #includes around a bit This reduces the dependencies from src/lib to the rest of the code a bit. --- CMakeLists.txt | 2 +- Makefile.am | 2 +- config.h.in | 3 +++ src/C4Include.h | 1 - src/c4group/C4Update.h | 1 + src/{game => config}/C4Constants.h | 19 ++----------------- src/control/C4Teams.h | 2 ++ src/editor/C4ToolsDlg.h | 2 ++ src/game/landscape/C4Material.cpp | 13 +++++++------ src/game/landscape/C4Particles.h | 5 +++++ src/game/landscape/C4Region.h | 1 + src/game/landscape/C4Texture.h | 1 + src/game/object/C4Def.h | 3 ++- src/game/object/C4DefGraphics.h | 5 +++-- src/game/object/C4InfoCore.h | 1 + src/game/player/C4RankSystem.h | 2 ++ src/lib/C4InputValidation.cpp | 4 ++-- src/lib/C4InputValidation.h | 6 ++++++ src/lib/C4Log.cpp | 3 +++ src/lib/C4LogBuf.cpp | 2 +- src/lib/C4LogBuf.h | 2 ++ src/lib/C4NameList.cpp | 2 +- src/lib/C4NameList.h | 5 +++++ src/lib/C4RTF.H | 4 +++- src/lib/C4RTF.cpp | 3 +-- src/lib/C4Random.cpp | 2 +- src/lib/C4Random.h | 11 ++--------- src/lib/C4Rect.cpp | 4 +++- src/lib/C4Rect.h | 5 +++++ src/lib/C4Stat.cpp | 2 +- src/lib/Standard.h | 10 ++++++++-- src/platform/StdDDraw2.cpp | 1 + src/platform/StdDDraw2.h | 4 +--- src/platform/StdGL.cpp | 1 + 34 files changed, 81 insertions(+), 53 deletions(-) rename src/{game => config}/C4Constants.h (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a05c096d..27abe1179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ set(OC_CLONK_SOURCES src/config/C4Config.h src/config/C4ConfigShareware.cpp src/config/C4ConfigShareware.h + src/config/C4Constants.h src/config/C4SecurityCertificates.cpp src/config/C4SecurityCertificates.h src/control/C4Control.cpp @@ -73,7 +74,6 @@ set(OC_CLONK_SOURCES src/editor/C4PropertyDlg.h src/editor/C4ToolsDlg.cpp src/editor/C4ToolsDlg.h - src/game/C4Constants.h src/game/C4GameVersion.h src/game/C4Physics.h src/game/landscape/C4Landscape.cpp diff --git a/Makefile.am b/Makefile.am index df45ae279..045dab4a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -168,6 +168,7 @@ src/config/C4Config.cpp \ src/config/C4Config.h \ src/config/C4ConfigShareware.cpp \ src/config/C4ConfigShareware.h \ +src/config/C4Constants.h \ src/config/C4SecurityCertificates.cpp \ src/config/C4SecurityCertificates.h \ src/control/C4Control.cpp \ @@ -199,7 +200,6 @@ src/editor/C4PropertyDlg.cpp \ src/editor/C4PropertyDlg.h \ src/editor/C4ToolsDlg.cpp \ src/editor/C4ToolsDlg.h \ -src/game/C4Constants.h \ src/game/C4GameVersion.h \ src/game/C4Physics.h \ src/game/landscape/C4Landscape.cpp \ diff --git a/config.h.in b/config.h.in index ff10a830c..6af0a7450 100644 --- a/config.h.in +++ b/config.h.in @@ -141,6 +141,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/src/C4Include.h b/src/C4Include.h index 1b8518233..85d71bbd7 100644 --- a/src/C4Include.h +++ b/src/C4Include.h @@ -101,7 +101,6 @@ #include "C4Id.h" #include "C4Prototypes.h" -#include "C4Constants.h" #ifdef _WIN32 #include diff --git a/src/c4group/C4Update.h b/src/c4group/C4Update.h index 4a41da8f7..deb1a9254 100644 --- a/src/c4group/C4Update.h +++ b/src/c4group/C4Update.h @@ -22,6 +22,7 @@ #define INC_C4GroupEx #include "C4Group.h" +#include "C4InputValidation.h" const int C4UP_MaxUpGrpCnt = 50; diff --git a/src/game/C4Constants.h b/src/config/C4Constants.h similarity index 92% rename from src/game/C4Constants.h rename to src/config/C4Constants.h index cfa598f4e..306a13639 100644 --- a/src/game/C4Constants.h +++ b/src/config/C4Constants.h @@ -25,18 +25,11 @@ //============================= Main ===================================================== -const int C4MaxNameList = 10, - C4MaxName = 30, // player names, etc. - C4MaxLongName = 120, // scenario titles, etc. - may include markup - C4MaxComment = 256, // network game and player comments +const int C4MaxDefString = 100, C4MaxTitle = 512, C4MaxMessage = 256, - C4MaxServerName = 255, - - C4MaxVariable = 10, - C4ViewDelay = 100, C4RetireDelay = 60, @@ -64,19 +57,11 @@ const int C4MaxNameList = 10, const int C4M_MaxName = 15, C4M_MaxDefName = 2*C4M_MaxName+1, - C4M_ColsPerMat = 3, C4M_MaxTexIndex = 127; // last texture map index is reserved for diff const int C4S_MaxPlayer = 4; -const int C4D_MaxName = C4MaxName, - C4D_MaxVertex = 30, - C4D_MaxIDLen = C4D_MaxName; - -const int C4Px_MaxName = C4MaxName,// maximum length of a particle def name - C4Px_MaxParticle= 256, // maximum number of particles of one type - C4Px_BufSize = 128, // number of particles in one buffer - C4Px_MaxIDLen = 30; // maximum length of internal identifiers +const int C4D_MaxVertex = 30; const int C4SymbolSize = 35, C4SymbolBorder = 5, diff --git a/src/control/C4Teams.h b/src/control/C4Teams.h index 66bc49bef..8e2bfdaae 100644 --- a/src/control/C4Teams.h +++ b/src/control/C4Teams.h @@ -21,6 +21,8 @@ #ifndef INC_C4Teams #define INC_C4Teams +#include "C4InputValidation.h" + // class predec namespace C4GUI { class ComboBox_FillCB; }; diff --git a/src/editor/C4ToolsDlg.h b/src/editor/C4ToolsDlg.h index 53b1d48c6..b55506708 100644 --- a/src/editor/C4ToolsDlg.h +++ b/src/editor/C4ToolsDlg.h @@ -28,6 +28,8 @@ #include #endif +#include "C4Constants.h" + const int32_t C4TLS_Brush = 0, C4TLS_Line = 1, C4TLS_Rect = 2, diff --git a/src/game/landscape/C4Material.cpp b/src/game/landscape/C4Material.cpp index 9c289c80d..514a4205f 100644 --- a/src/game/landscape/C4Material.cpp +++ b/src/game/landscape/C4Material.cpp @@ -867,12 +867,13 @@ void C4MaterialMap::UpdateScriptPointers() int32_t PixCol2MatOld(BYTE pixc) - { - if (pixc < GBM) return MNone; - pixc &= 63; // Substract GBM, ignore IFT - if (pixc > ::MaterialMap.Num*C4M_ColsPerMat-1) return MNone; - return pixc / C4M_ColsPerMat; - } + { + const int C4M_ColsPerMat = 3; + if (pixc < GBM) return MNone; + pixc &= 63; // Substract GBM, ignore IFT + if (pixc > ::MaterialMap.Num*C4M_ColsPerMat-1) return MNone; + return pixc / C4M_ColsPerMat; + } int32_t PixCol2MatOld2(BYTE pixc) { diff --git a/src/game/landscape/C4Particles.h b/src/game/landscape/C4Particles.h index f86f418cb..91712f576 100644 --- a/src/game/landscape/C4Particles.h +++ b/src/game/landscape/C4Particles.h @@ -52,6 +52,11 @@ typedef void (*C4ParticleDrawProc)(C4Particle *, C4TargetFacet &, C4Object *); / #define ParticleSystem ::Particles +const int + C4Px_MaxParticle = 256, // maximum number of particles of one type + C4Px_BufSize = 128, // number of particles in one buffer + C4Px_MaxIDLen = 30; // maximum length of internal identifiers + // core for particle defs class C4ParticleDefCore { diff --git a/src/game/landscape/C4Region.h b/src/game/landscape/C4Region.h index c3472d23c..6362a5b00 100644 --- a/src/game/landscape/C4Region.h +++ b/src/game/landscape/C4Region.h @@ -23,6 +23,7 @@ #define INC_C4Region #include +#include const int C4RGN_MaxCaption=256; diff --git a/src/game/landscape/C4Texture.h b/src/game/landscape/C4Texture.h index 91122898f..63d5bda45 100644 --- a/src/game/landscape/C4Texture.h +++ b/src/game/landscape/C4Texture.h @@ -24,6 +24,7 @@ #define INC_C4Texture #include +#include class C4Texture { diff --git a/src/game/object/C4Def.h b/src/game/object/C4Def.h index 45b47dc85..3a988c39b 100644 --- a/src/game/object/C4Def.h +++ b/src/game/object/C4Def.h @@ -36,6 +36,7 @@ #include #include #include "C4LangStringTable.h" +#include "C4InputValidation.h" const int32_t C4D_None = 0, C4D_All = ~C4D_None, @@ -203,7 +204,7 @@ class C4Def: public C4PropList int32_t Timer; int32_t NoComponentMass; int32_t NoStabilize; - char STimerCall[C4D_MaxIDLen]; + char STimerCall[C4AUL_MAX_Identifier]; int32_t ClosedContainer; // if set, contained objects are not damaged by lava/acid etc. 1: Contained objects can't view out; 2: They can int32_t SilentCommands; // if set, no command failure messages are printed int32_t NoBurnDamage; // if set, the object won't take damage when burning diff --git a/src/game/object/C4DefGraphics.h b/src/game/object/C4DefGraphics.h index dd4db9f4a..8843630f9 100644 --- a/src/game/object/C4DefGraphics.h +++ b/src/game/object/C4DefGraphics.h @@ -22,8 +22,9 @@ #ifndef INC_C4DefGraphics #define INC_C4DefGraphics -#include -#include +#include "C4FacetEx.h" +#include "C4Surface.h" +#include "C4InputValidation.h" #define C4Portrait_None "none" #define C4Portrait_Random "random" diff --git a/src/game/object/C4InfoCore.h b/src/game/object/C4InfoCore.h index 2fb6dfd23..fdc4793c4 100644 --- a/src/game/object/C4InfoCore.h +++ b/src/game/object/C4InfoCore.h @@ -25,6 +25,7 @@ #include #include #include +#include "C4InputValidation.h" class C4RankSystem; diff --git a/src/game/player/C4RankSystem.h b/src/game/player/C4RankSystem.h index 8322cea83..bcf24fe57 100644 --- a/src/game/player/C4RankSystem.h +++ b/src/game/player/C4RankSystem.h @@ -22,6 +22,8 @@ #ifndef INC_C4RankSystem #define INC_C4RankSystem +#include "C4InputValidation.h" + class C4RankSystem { public: diff --git a/src/lib/C4InputValidation.cpp b/src/lib/C4InputValidation.cpp index 3ddd3e129..990da8bf9 100644 --- a/src/lib/C4InputValidation.cpp +++ b/src/lib/C4InputValidation.cpp @@ -18,10 +18,10 @@ */ // user input validation functions -#include +#include #include #include -#include +#include "StdMarkup.h" #include diff --git a/src/lib/C4InputValidation.h b/src/lib/C4InputValidation.h index 0f707c67f..121abdde0 100644 --- a/src/lib/C4InputValidation.h +++ b/src/lib/C4InputValidation.h @@ -21,6 +21,12 @@ #define INC_C4InputValidation #include "StdBuf.h" +#include "StdFile.h" +#include "StdAdaptors.h" + +const int C4MaxName = 30; // player names, etc. +const int C4MaxLongName = 120; // scenario titles, etc. - may include markup +const int C4MaxComment = 256; // network game and player comments namespace C4InVal { diff --git a/src/lib/C4Log.cpp b/src/lib/C4Log.cpp index 7b43619fc..bda0a59e5 100644 --- a/src/lib/C4Log.cpp +++ b/src/lib/C4Log.cpp @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #endif #if defined(HAVE_SHARE_H) || defined(_WIN32) diff --git a/src/lib/C4LogBuf.cpp b/src/lib/C4LogBuf.cpp index cf3eb6749..a23158301 100644 --- a/src/lib/C4LogBuf.cpp +++ b/src/lib/C4LogBuf.cpp @@ -17,7 +17,7 @@ */ // a buffer holding a log history -#include "C4Include.h" +#include "Standard.h" #include "C4LogBuf.h" C4LogBuffer::C4LogBuffer(int iSize, int iMaxLines, int iLBWidth, const char *szIndentChars, bool fDynamicGrow, bool fMarkup) diff --git a/src/lib/C4LogBuf.h b/src/lib/C4LogBuf.h index 4c67dc138..5e2814536 100644 --- a/src/lib/C4LogBuf.h +++ b/src/lib/C4LogBuf.h @@ -20,6 +20,8 @@ #ifndef INC_C4LogBuf #define INC_C4LogBuf +#include + // circular log buffer to holding line-wise log data class C4LogBuffer { diff --git a/src/lib/C4NameList.cpp b/src/lib/C4NameList.cpp index 83557275b..751c5b1b2 100644 --- a/src/lib/C4NameList.cpp +++ b/src/lib/C4NameList.cpp @@ -20,7 +20,7 @@ /* A static list of strings and integer values, i.e. for material amounts */ -#include +#include #include C4NameList::C4NameList() diff --git a/src/lib/C4NameList.h b/src/lib/C4NameList.h index bbee8f542..0d6230042 100644 --- a/src/lib/C4NameList.h +++ b/src/lib/C4NameList.h @@ -22,6 +22,11 @@ #ifndef INC_C4NameList #define INC_C4NameList +const int C4MaxNameList = 10; + +#include "C4Constants.h" +#include "C4InputValidation.h" + #include class C4NameList { diff --git a/src/lib/C4RTF.H b/src/lib/C4RTF.H index 81e8103fc..d3dbef0ec 100644 --- a/src/lib/C4RTF.H +++ b/src/lib/C4RTF.H @@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef INC_C4RTF #define INC_C4RTF +#include + class C4RTFFile { public: @@ -73,7 +75,7 @@ class C4RTFFile class ParserError { public: - StdStrBuf ErrorText; + StdCopyStrBuf ErrorText; ParserError(const char *szErr) { ErrorText.Copy(szErr); } }; diff --git a/src/lib/C4RTF.cpp b/src/lib/C4RTF.cpp index 65b7711f0..a1d3b94d0 100644 --- a/src/lib/C4RTF.cpp +++ b/src/lib/C4RTF.cpp @@ -19,9 +19,8 @@ */ // RTF file parsing functionality -#include "C4Include.h" +#include "Standard.h" #include "C4RTF.H" -#include "C4Config.h" #include diff --git a/src/lib/C4Random.cpp b/src/lib/C4Random.cpp index e56de64c9..9342b2d32 100644 --- a/src/lib/C4Random.cpp +++ b/src/lib/C4Random.cpp @@ -18,7 +18,7 @@ /* Buffered fast and network-safe random */ -#include +#include #include int RandomCount = 0; diff --git a/src/lib/C4Random.h b/src/lib/C4Random.h index d1473ee2a..9166ed10e 100644 --- a/src/lib/C4Random.h +++ b/src/lib/C4Random.h @@ -24,10 +24,10 @@ #ifndef INC_C4Random #define INC_C4Random - #ifdef DEBUGREC - #include +#include #endif +#include extern int RandomCount; extern unsigned int RandomHold; @@ -40,13 +40,6 @@ inline void FixedRandom(DWORD dwSeed) RandomCount=0; } -inline void Randomize() - { - FixedRandom((unsigned)time(NULL)); - // for SafeRandom - srand((unsigned)time(NULL)); - } - inline int Random(int iRange) { // next pseudorandom value diff --git a/src/lib/C4Rect.cpp b/src/lib/C4Rect.cpp index 752e8e4e8..dd36f8812 100644 --- a/src/lib/C4Rect.cpp +++ b/src/lib/C4Rect.cpp @@ -21,9 +21,11 @@ /* Basic classes for rectangles and vertex outlines */ -#include "C4Include.h" +#include "Standard.h" #include "C4Rect.h" #include "C4FacetEx.h" +#include "StdCompiler.h" +#include "StdAdaptors.h" void C4Rect::Default() { diff --git a/src/lib/C4Rect.h b/src/lib/C4Rect.h index 590e46321..3476371df 100644 --- a/src/lib/C4Rect.h +++ b/src/lib/C4Rect.h @@ -26,6 +26,11 @@ #define C4D_VertexCpyPos (C4D_MaxVertex/2) +#include + +struct FLOAT_RECT { float left,right,top,bottom; }; +class C4TargetFacet; + class C4Rect { public: diff --git a/src/lib/C4Stat.cpp b/src/lib/C4Stat.cpp index 137eca64a..752569bf9 100644 --- a/src/lib/C4Stat.cpp +++ b/src/lib/C4Stat.cpp @@ -18,7 +18,7 @@ */ // statistics -#include +#include #include // ** implemetation of C4MainStat diff --git a/src/lib/Standard.h b/src/lib/Standard.h index 06ea6af4d..01a478c16 100644 --- a/src/lib/Standard.h +++ b/src/lib/Standard.h @@ -299,8 +299,8 @@ BOOL SWildcardMatchEx(const char *szString, const char *szWildcard); // sprintf wrapper -#include -#include +#include +#include #ifdef _MSC_VER #define vsnprintf _vsnprintf @@ -336,5 +336,11 @@ template // open a weblink in an external browser bool OpenURL(const char *szURL); +class StdCompiler; + +#include +#include +#include + #endif // INC_STANDARD diff --git a/src/platform/StdDDraw2.cpp b/src/platform/StdDDraw2.cpp index 105c5dbab..28a84db20 100644 --- a/src/platform/StdDDraw2.cpp +++ b/src/platform/StdDDraw2.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "C4Rect.h" #include #include diff --git a/src/platform/StdDDraw2.h b/src/platform/StdDDraw2.h index afd2c567d..49d35f7f2 100644 --- a/src/platform/StdDDraw2.h +++ b/src/platform/StdDDraw2.h @@ -199,9 +199,7 @@ class CGammaControl friend class CStdGL; }; -// helper structs -struct FLOAT_RECT { float left,right,top,bottom; }; - +// helper struct struct ZoomData { float Zoom; diff --git a/src/platform/StdGL.cpp b/src/platform/StdGL.cpp index 85ce559bd..a11a03475 100644 --- a/src/platform/StdGL.cpp +++ b/src/platform/StdGL.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "C4Rect.h" #ifdef USE_GL