diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c44f463..f02c9f28b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(OC_CLONK_SOURCES src/C4FullScreen.h src/C4Game.cpp src/C4Game.h + src/C4Globals.cpp src/C4GraphicsSystem.cpp src/C4GraphicsSystem.h src/c4group/C4Components.h @@ -615,6 +616,8 @@ endif() if(MSVC_VERSION) # Suppress warnings about "non-secure" functions add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) + # Disable warning C4244: 'conversion' conversion from 'type1' to 'type2', possible loss of data + list(APPEND OC_CXX_FLAGS "/wd4244") endif() ############################################################################ diff --git a/Makefile.am b/Makefile.am index d3517c404..e6efaac5f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -142,6 +142,7 @@ src/C4FullScreen.cpp \ src/C4FullScreen.h \ src/C4Game.cpp \ src/C4Game.h \ +src/C4Globals.cpp \ src/C4GraphicsSystem.cpp \ src/C4GraphicsSystem.h \ src/c4group/C4LangStringTable.cpp \ @@ -400,8 +401,6 @@ src/platform/C4Video.cpp \ src/platform/C4Video.h \ src/platform/C4VideoPlayback.cpp \ src/platform/C4VideoPlayback.h \ -src/platform/Midi.cpp \ -src/platform/Midi.h \ src/platform/OpenURL.cpp \ src/platform/StdConfig.cpp \ src/platform/StdConfig.h \ diff --git a/src/C4Globals.cpp b/src/C4Globals.cpp new file mode 100644 index 000000000..da9bf7669 --- /dev/null +++ b/src/C4Globals.cpp @@ -0,0 +1,35 @@ +/* + * OpenClonk, http://www.openclonk.org + * + * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de + * + * Portions might be copyrighted by other authors who have contributed + * to OpenClonk. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * See isc_license.txt for full license and disclaimer. + * + * "Clonk" is a registered trademark of Matthes Bender. + * See clonk_trademark_license.txt for full license. + */ + +/* Global interdependent objects */ + +#include "C4Include.h" +#include "C4Application.h" +#include "C4Console.h" +#include "C4FullScreen.h" +#include "C4MouseControl.h" +#include "C4GameObjects.h" +#include "C4Game.h" +#include "C4Network2.h" + +C4Application Application; +C4Console Console; +C4FullScreen FullScreen; +C4MouseControl MouseControl; +C4GameObjects Objects; +C4Game Game; +C4Network2 Network; diff --git a/src/C4WinMain.cpp b/src/C4WinMain.cpp index 81849ef03..6d008a38f 100644 --- a/src/C4WinMain.cpp +++ b/src/C4WinMain.cpp @@ -26,19 +26,11 @@ #include #include -#include -#include #include #include #include #include "C4Network2.h" -C4Application Application; -C4Console Console; -C4FullScreen FullScreen; -C4Game Game; -C4Network2 Network; - #include "MacUtility.h" #ifdef _WIN32 @@ -148,6 +140,7 @@ int main() #ifdef WITH_DEVELOPER_MODE # include "c4x.xpm" # include +# include #endif #ifdef HAVE_EXECINFO_H diff --git a/src/c4group/C4LangStringTable.h b/src/c4group/C4LangStringTable.h index bfbed9a1f..bbe278ff8 100644 --- a/src/c4group/C4LangStringTable.h +++ b/src/c4group/C4LangStringTable.h @@ -24,6 +24,7 @@ #include #include +#include class C4LangStringTable : public C4ComponentHost { diff --git a/src/game/object/C4GameObjects.cpp b/src/game/object/C4GameObjects.cpp index d95c54ca6..134903a8f 100644 --- a/src/game/object/C4GameObjects.cpp +++ b/src/game/object/C4GameObjects.cpp @@ -1002,5 +1002,3 @@ void C4GameObjects::SetOCF() if (cLnk->Obj->Status) cLnk->Obj->SetOCF(); } - -C4GameObjects Objects; diff --git a/src/game/object/C4GameObjects.h b/src/game/object/C4GameObjects.h index 460849316..c3d16ec17 100644 --- a/src/game/object/C4GameObjects.h +++ b/src/game/object/C4GameObjects.h @@ -35,7 +35,8 @@ class C4GameObjects : public C4NotifyingObjectList ~C4GameObjects(); // destructor void Default(); void Init(int32_t iWidth, int32_t iHeight); - void Clear(bool fClearInactive = true); // clear objects + void Clear(bool fClearInactive); // clear objects + void Clear() { Clear(true); } // don't use default parameters so we get a correct vtbl entry public: C4LSectors Sectors; // section object lists diff --git a/src/game/object/C4Id.h b/src/game/object/C4Id.h index 601633ee4..f0ccec134 100644 --- a/src/game/object/C4Id.h +++ b/src/game/object/C4Id.h @@ -28,7 +28,7 @@ class C4ID { - uint32_t v; + union { uint32_t v; char s[4]; }; public: C4ID() {} C4ID(unsigned int i): v(i) {} diff --git a/src/game/object/C4ObjectList.h b/src/game/object/C4ObjectList.h index b68329232..b0445db7d 100644 --- a/src/game/object/C4ObjectList.h +++ b/src/game/object/C4ObjectList.h @@ -89,8 +89,8 @@ class C4ObjectList iterator begin(); const iterator end(); - void Default(); - void Clear(); + virtual void Default(); + virtual void Clear(); void Sort(); void Enumerate(); void Denumerate(); @@ -108,12 +108,12 @@ class C4ObjectList typedef int SortProc(C4Object *, C4Object *); - bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted = NULL); + virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted = NULL); bool AddSortCustom(C4Object *nObj, SortProc &pSortProc); - bool Remove(C4Object *pObj); + virtual bool Remove(C4Object *pObj); - bool AssignInfo(); - bool ValidateOwners(); + virtual bool AssignInfo(); + virtual bool ValidateOwners(); StdStrBuf GetNameList(C4DefList &rDefs, DWORD dwCategory=C4D_All); bool IsClear() const; bool DenumerateRead(); @@ -134,8 +134,8 @@ class C4ObjectList C4ID GetListID(int32_t dwCategory, int Index); - bool OrderObjectBefore(C4Object *pObj1, C4Object *pObj2); // order pObj1 before pObj2 - bool OrderObjectAfter(C4Object *pObj1, C4Object *pObj2); // order pObj1 after pObj2 + virtual bool OrderObjectBefore(C4Object *pObj1, C4Object *pObj2); // order pObj1 before pObj2 + virtual bool OrderObjectAfter(C4Object *pObj1, C4Object *pObj2); // order pObj1 after pObj2 bool ShiftContents(C4Object *pNewFirst); // cycle list so pNewFirst is at front diff --git a/src/gui/C4MouseControl.cpp b/src/gui/C4MouseControl.cpp index 3fe23de31..bc9b31b04 100644 --- a/src/gui/C4MouseControl.cpp +++ b/src/gui/C4MouseControl.cpp @@ -1409,5 +1409,3 @@ void C4MouseControl::StartConstructionDrag(C4ID id) CreateDragImage(DragID); Selection.Clear(); } - -C4MouseControl MouseControl; diff --git a/src/script/C4PropList.cpp b/src/script/C4PropList.cpp index 83faf9fec..d17f6215a 100644 --- a/src/script/C4PropList.cpp +++ b/src/script/C4PropList.cpp @@ -67,8 +67,14 @@ C4PropList::C4PropList(C4PropList * prototype): C4PropList::~C4PropList() { - assert(!FirstRef); - while (FirstRef) FirstRef->Set0(); + while (FirstRef) + { + // Manually kill references so DelRef doesn't destroy us again + FirstRef->Data = 0; FirstRef->Type = C4V_Any; + C4Value *ref = FirstRef; + FirstRef = FirstRef->NextRef; + ref->NextRef = NULL; + } ::Objects.PropLists.Remove(this); assert(!::Objects.ObjectNumber(this)); }