Fix assertion and crash on game teardown (#37, #42)

Also, the build works on linux again. Whee!
Nicolas Hake 2009-11-25 16:04:32 +01:00
parent fdc3a7ee93
commit 1a933780d4
11 changed files with 60 additions and 26 deletions

View File

@ -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()
############################################################################

View File

@ -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 \

35
src/C4Globals.cpp 100644
View File

@ -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;

View File

@ -26,19 +26,11 @@
#include <C4Include.h>
#include <C4Application.h>
#include <C4Console.h>
#include <C4FullScreen.h>
#include <C4Log.h>
#include <C4Game.h>
#include <C4Version.h>
#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 <gtk/gtkmain.h>
# include <gtk/gtkwindow.h>
#endif
#ifdef HAVE_EXECINFO_H

View File

@ -24,6 +24,7 @@
#include <map>
#include <string>
#include <stdexcept>
class C4LangStringTable : public C4ComponentHost
{

View File

@ -1002,5 +1002,3 @@ void C4GameObjects::SetOCF()
if (cLnk->Obj->Status)
cLnk->Obj->SetOCF();
}
C4GameObjects Objects;

View File

@ -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

View File

@ -28,7 +28,7 @@
class C4ID
{
uint32_t v;
union { uint32_t v; char s[4]; };
public:
C4ID() {}
C4ID(unsigned int i): v(i) {}

View File

@ -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

View File

@ -1409,5 +1409,3 @@ void C4MouseControl::StartConstructionDrag(C4ID id)
CreateDragImage(DragID);
Selection.Clear();
}
C4MouseControl MouseControl;

View File

@ -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));
}