瀏覽代碼

An neues Framework angepasst

Kolja Strohm 5 年之前
父節點
當前提交
83f11f1832

+ 0 - 16
SpielServer/HistorieSender.cpp

@@ -12,7 +12,6 @@ HistorieSender::HistorieSender( SpielServer *zSS )
 {
 	this->zSS = zSS;
 	beenden = 0;
-	ref = 1;
 }
 
 // Destruktor
@@ -94,19 +93,4 @@ void HistorieSender::thread()
 	}
 	d->release();
 	run = 0;
-}
-
-// Reference Counting
-HistorieSender *HistorieSender::getThis()
-{
-	ref++;
-	return this;
-}
-
-HistorieSender *HistorieSender::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
 }

+ 0 - 4
SpielServer/HistorieSender.h

@@ -17,7 +17,6 @@ class HistorieSender : public Thread
 private:
 	SpielServer *zSS;
 	bool beenden;
-	int ref;
 
 public:
 	// Konstruktor
@@ -27,9 +26,6 @@ public:
 	// nicht constant
 	void setEnde();
 	virtual void thread();
-	// Reference Counting
-	HistorieSender *getThis();
-	HistorieSender *release();
 };
 
 #endif

+ 0 - 3
SpielServer/SSKlientV.h

@@ -30,9 +30,6 @@ public:
     virtual void errorZuKlientSende( const char *nachricht ) = 0;
     // const
     virtual int getAccountId() const = 0;
-    // Reference Counting
-    virtual SSKlientV *getThis() = 0;
-    virtual SSKlientV *release() = 0;
 };
 
 #endif

+ 9 - 25
SpielServer/Spiel.cpp

@@ -16,7 +16,7 @@
 #define FreeLibrary              dlclose
 #endif
 
-typedef SpielKlasse*( *DllStart )( );
+typedef SpielKlasse *( *DllStart )( );
 
 // Inhalt der Spiel Klasse aus Spiel.h
 // Konstruktor
@@ -38,7 +38,6 @@ Spiel::Spiel( int id, SpielServer *ss )
     karte = 0;
     spielDll = 0;
     statistik = 0;
-    ref = 1;
 }
 
 // Destruktor
@@ -140,14 +139,14 @@ void Spiel::teamAusgleich()
 }
 
 // nicht constant
-void Spiel::setAccounts( int anzahl, Array< int > *zAccounts )
+void Spiel::setAccounts( int anzahl, Array< int > * zAccounts )
 {
     for( int i = 0; i < anzahl; i++ )
         accounts->set( zAccounts->hat( i ) ? zAccounts->get( i ) : 0, i );
     spielerAnzahl = anzahl;
 }
 
-void Spiel::setKlients( int anzahl, RCArray< SSKlient > *zKlients )
+void Spiel::setKlients( int anzahl, RCArray< SSKlient > * zKlients )
 {
     for( int i = 0; i < anzahl; i++ )
         klients->set( zKlients->get( i ), i );
@@ -156,13 +155,13 @@ void Spiel::setKlients( int anzahl, RCArray< SSKlient > *zKlients )
 void Spiel::setKarteId( int karteId )
 {
     karte = karteId;
-    KartenLeser *reader = new KartenLeser( id, karte, ss->getThis() );
+    KartenLeser *reader = new KartenLeser( id, karte, (SpielServer *)ss->getThis() );
     reader->ladeSpielerTeamStruktur( sts );
     reader->release();
     start();
 }
 
-bool Spiel::klientVerbunden( SSKlient *klient )
+bool Spiel::klientVerbunden( SSKlient * klient )
 {
     int accId = klient->getAccountId();
     bool ret = 0;
@@ -209,7 +208,7 @@ bool Spiel::klientWechseltTeam( int accountId, int team )
         {
             if( accounts->hat( i ) && accounts->get( i ) == accountId )
                 spielerNummern->set( 0, i );
-            SSKlient *tmp = klients->z( i );
+            SSKlient * tmp = klients->z( i );
             if( tmp )
                 tmp->erstellungSpielerTeam( accountId, 0 );
         }
@@ -239,7 +238,7 @@ bool Spiel::klientWechseltTeam( int accountId, int team )
             {
                 if( accounts->hat( j ) && accounts->get( j ) == accountId )
                     spielerNummern->set( i, j );
-                SSKlient *tmp = klients->z( j );
+                SSKlient * tmp = klients->z( j );
                 if( tmp )
                     tmp->erstellungSpielerTeam( accountId, i );
             }
@@ -262,7 +261,7 @@ bool Spiel::chatNachricht( char *nachricht )
     return 1;
 }
 
-bool Spiel::klientGetrennt( SSKlient *zKlient )
+bool Spiel::klientGetrennt( SSKlient * zKlient )
 {
     int accId = zKlient->getAccountId();
     bool ret = 0;
@@ -582,7 +581,7 @@ void Spiel::thread()
     tmp += id;
     spiel->setTempPfad( tmp );
     spiel->setAccounts( spielerAnzahl, accounts );
-    spiel->setKlients( spielerAnzahl, ( RCArray< SSKlientV >* )klients );
+    spiel->setKlients( spielerAnzahl, ( RCArray< SSKlientV > * )klients );
     spiel->setSpielerNummern( spielerAnzahl, spielerNummern );
     // auf klients warten
     while( 1 )
@@ -629,19 +628,4 @@ int Spiel::getSpielerNummer( int accountId ) const
             return spielerNummern->hat( i ) ? spielerNummern->get( i ) : 0;
     }
     return 0;
-}
-
-// Reference Counting
-Spiel *Spiel::getThis()
-{
-    ref++;
-    return this;
-}
-
-Spiel *Spiel::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
 }

+ 1 - 5
SpielServer/Spiel.h

@@ -18,7 +18,7 @@ class SpielServer; // SpielServer.h
 using namespace Framework;
 using namespace Network;
 
-class Spiel : private Thread
+class Spiel : public Thread
 {
 private:
 	SpielServer *ss;
@@ -36,7 +36,6 @@ private:
 	int spielerAnzahl;
 	int karte;
 	HINSTANCE spielDll;
-	int ref;
 
     int findFreeTeam();
     void teamAusgleich();
@@ -64,9 +63,6 @@ public:
 	// constant
 	int getId() const;
 	int getSpielerNummer( int accountId ) const;
-	// Reference Counting
-	Spiel *getThis();
-	Spiel *release();
 };
 
 #endif

+ 301 - 335
SpielServer/SpielErstellt.cpp

@@ -12,401 +12,367 @@
 // Inhalt der SpielErstellt Kasse aus SpielErstellt.h
 // Konstruktor
 SpielErstellt::SpielErstellt( int id, SpielServer *ss )
-: Thread()
+    : Thread()
 {
-	this->ss = ss;
-	this->id = id;
-	karte = ss->zDB()->getKarteVonErstelltemSpiel( id );
-	spielArt = ss->zDB()->getSpielArtId( karte );
-	accounts = new Array< int >();
-	spielerAnzahl = ss->zDB()->getSpielErstelltSpieler( id, accounts );
-	klients = new RCArray< SSKlient >();
-	status = new Array< int >();
-	verbunden = 0;
-	state = 0;
-	abbr = 0;
-	spielId = 0;
-	ref = 1;
+    this->ss = ss;
+    this->id = id;
+    karte = ss->zDB()->getKarteVonErstelltemSpiel( id );
+    spielArt = ss->zDB()->getSpielArtId( karte );
+    accounts = new Array< int >();
+    spielerAnzahl = ss->zDB()->getSpielErstelltSpieler( id, accounts );
+    klients = new RCArray< SSKlient >();
+    status = new Array< int >();
+    verbunden = 0;
+    state = 0;
+    abbr = 0;
+    spielId = 0;
 }
 
 // Destruktor
 SpielErstellt::~SpielErstellt()
 {
-	ss->release();
-	accounts->release();
-	klients->release();
-	status->release();
+    ss->release();
+    accounts->release();
+    klients->release();
+    status->release();
 }
 
 // nicht constant
 void SpielErstellt::abbruch()
 {
-	abbr = 1;
+    abbr = 1;
 }
 
 void SpielErstellt::sendeVerbindungsBefehl()
 {
-	unsigned short sPort = (unsigned short)ss->getPort();
-	char *sIp = ss->getIp();
-	unsigned char *sIp4 = new unsigned char[ 4 ];
-	Text *tmpT = new Text( sIp );
-	Text *ip1 = tmpT->getTeilText( 0, tmpT->positionVon( '.' ) );
-	Text *ip2 = tmpT->getTeilText( tmpT->positionVon( '.' ) + 1, tmpT->positionVon( '.', 1 ) );
-	Text *ip3 = tmpT->getTeilText( tmpT->positionVon( '.', 1 ) + 1, tmpT->positionVon( '.', 2 ) );
-	Text *ip4 = tmpT->getTeilText( tmpT->positionVon( '.', 2 ) + 1 );
-	sIp4[ 0 ] = (unsigned char)TextZuInt( ip1->getText(), 10 );
-	sIp4[ 1 ] = (unsigned char)TextZuInt( ip2->getText(), 10 );
-	sIp4[ 2 ] = (unsigned char)TextZuInt( ip3->getText(), 10 );
-	sIp4[ 3 ] = (unsigned char)TextZuInt( ip4->getText(), 10 );
-	ip1->release();
-	ip2->release();
-	ip3->release();
-	ip4->release();
-	tmpT->release();
-	for( int i = 0; i < spielerAnzahl; i++ )
-	{
-		int accId = accounts->hat( i ) ? accounts->get( i ) : 0;
-		int port = 0;
-		Text *ip = new Text( "" );
-		if( ss->zDB()->getChatServerPortIp( accId, &port, ip ) )
-		{
-			char ret = 0;
-			Klient *klient = new Klient();
-			unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
-			klient->setSendeKey( (char*)key, 20 );
-			klient->setEmpfangKey( (char*)key, 20 );
-			klient->verbinde( (unsigned short)port, ip->getText() );
-			klient->sendeEncrypted( "\5\x1D", 2 );
-			klient->getNachrichtEncrypted( &ret, 1 );
-			if( ret != 3 )
-			{
-				klient->sendeEncrypted( (char*)&accId, 4 );
-				klient->sendeEncrypted( (char*)&sPort, 2 );
-				klient->sendeEncrypted( (char*)sIp4, 4 );
-				klient->getNachrichtEncrypted( &ret, 1 );
-			}
-			if( ret == 3 )
-			{
-				unsigned char len = 0;
-				klient->getNachrichtEncrypted( (char*)&len, 1 );
-				char *err = new char[ len ];
-				klient->getNachrichtEncrypted( err, len );
-				delete[] err;
-			}
-			klient->sendeEncrypted( "\3", 1 );
-			klient->getNachrichtEncrypted( &ret, 1 );
-			ss->addEmpfangen( klient->getDownloadBytes( 1 ) );
-			ss->addGesendet( klient->getUploadBytes( 1 ) );
-			klient->trenne();
-			klient->release();
-		}
-		ip->release();
-	}
-	delete[] sIp4;
-	start();
+    unsigned short sPort = (unsigned short)ss->getPort();
+    char *sIp = ss->getIp();
+    unsigned char *sIp4 = new unsigned char[ 4 ];
+    Text *tmpT = new Text( sIp );
+    Text *ip1 = tmpT->getTeilText( 0, tmpT->positionVon( '.' ) );
+    Text *ip2 = tmpT->getTeilText( tmpT->positionVon( '.' ) + 1, tmpT->positionVon( '.', 1 ) );
+    Text *ip3 = tmpT->getTeilText( tmpT->positionVon( '.', 1 ) + 1, tmpT->positionVon( '.', 2 ) );
+    Text *ip4 = tmpT->getTeilText( tmpT->positionVon( '.', 2 ) + 1 );
+    sIp4[ 0 ] = (unsigned char)TextZuInt( ip1->getText(), 10 );
+    sIp4[ 1 ] = (unsigned char)TextZuInt( ip2->getText(), 10 );
+    sIp4[ 2 ] = (unsigned char)TextZuInt( ip3->getText(), 10 );
+    sIp4[ 3 ] = (unsigned char)TextZuInt( ip4->getText(), 10 );
+    ip1->release();
+    ip2->release();
+    ip3->release();
+    ip4->release();
+    tmpT->release();
+    for( int i = 0; i < spielerAnzahl; i++ )
+    {
+        int accId = accounts->hat( i ) ? accounts->get( i ) : 0;
+        int port = 0;
+        Text *ip = new Text( "" );
+        if( ss->zDB()->getChatServerPortIp( accId, &port, ip ) )
+        {
+            char ret = 0;
+            Klient *klient = new Klient();
+            unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
+            klient->setSendeKey( (char *)key, 20 );
+            klient->setEmpfangKey( (char *)key, 20 );
+            klient->verbinde( (unsigned short)port, ip->getText() );
+            klient->sendeEncrypted( "\5\x1D", 2 );
+            klient->getNachrichtEncrypted( &ret, 1 );
+            if( ret != 3 )
+            {
+                klient->sendeEncrypted( (char *)& accId, 4 );
+                klient->sendeEncrypted( (char *)& sPort, 2 );
+                klient->sendeEncrypted( (char *)sIp4, 4 );
+                klient->getNachrichtEncrypted( &ret, 1 );
+            }
+            if( ret == 3 )
+            {
+                unsigned char len = 0;
+                klient->getNachrichtEncrypted( (char *)& len, 1 );
+                char *err = new char[ len ];
+                klient->getNachrichtEncrypted( err, len );
+                delete[] err;
+            }
+            klient->sendeEncrypted( "\3", 1 );
+            klient->getNachrichtEncrypted( &ret, 1 );
+            ss->addEmpfangen( klient->getDownloadBytes( 1 ) );
+            ss->addGesendet( klient->getUploadBytes( 1 ) );
+            klient->trenne();
+            klient->release();
+        }
+        ip->release();
+    }
+    delete[] sIp4;
+    start();
 }
 
 bool SpielErstellt::klientVerbunden( SSKlient *klient )
 {
-	if( verbunden == spielerAnzahl )
-	{
-		klient->release();
-		return 0;
-	}
-	int accId = klient->getAccountId();
-	bool ret = 0;
-	for( int i = 0; i < spielerAnzahl; i++ )
-	{
-		if( accounts->hat( i ) && accounts->get( i ) == accId )
-		{
-			if( state == 1 )
-				klient->spielGefunden( karte );
-			klients->set( klient, i );
-			status->set( 1, i );
-			verbunden++;
-			klient->setSpielErstellt( this );
-			ret = 1;
-			break;
-		}
-	}
-	if( !ret )
-		klient->release();
-	return ret;
+    if( verbunden == spielerAnzahl )
+    {
+        klient->release();
+        return 0;
+    }
+    int accId = klient->getAccountId();
+    bool ret = 0;
+    for( int i = 0; i < spielerAnzahl; i++ )
+    {
+        if( accounts->hat( i ) && accounts->get( i ) == accId )
+        {
+            if( state == 1 )
+                klient->spielGefunden( karte );
+            klients->set( klient, i );
+            status->set( 1, i );
+            verbunden++;
+            klient->setSpielErstellt( this );
+            ret = 1;
+            break;
+        }
+    }
+    if( !ret )
+        klient->release();
+    return ret;
 }
 
 bool SpielErstellt::klientNimmtAn( int accountId )
 {
-	if( !verbunden || state != 1 )
-		return 0;
-	bool ret = 0;
-	for( int i = 0; i < spielerAnzahl; i++ )
-	{
-		if( accounts->hat( i ) && accounts->get( i ) == accountId )
-		{
-			status->set( 2, i );
-			ret = 1;
-			break;
-		}
-	}
-	return ret;
+    if( !verbunden || state != 1 )
+        return 0;
+    bool ret = 0;
+    for( int i = 0; i < spielerAnzahl; i++ )
+    {
+        if( accounts->hat( i ) && accounts->get( i ) == accountId )
+        {
+            status->set( 2, i );
+            ret = 1;
+            break;
+        }
+    }
+    return ret;
 }
 
 bool SpielErstellt::klientLehntAb( int accountId )
 {
-	if( !verbunden || state != 1 )
-		return 0;
-	bool ret = 0;
-	for( int i = 0; i < spielerAnzahl; i++ )
-	{
-		if( accounts->hat( i ) && accounts->get( i ) == accountId )
-		{
-			status->set( 3, i );
-			ret = 1;
-			break;
-		}
-	}
-	return ret;
+    if( !verbunden || state != 1 )
+        return 0;
+    bool ret = 0;
+    for( int i = 0; i < spielerAnzahl; i++ )
+    {
+        if( accounts->hat( i ) && accounts->get( i ) == accountId )
+        {
+            status->set( 3, i );
+            ret = 1;
+            break;
+        }
+    }
+    return ret;
 }
 
-bool SpielErstellt::klientGetrennt( SSKlient *zKlient )
+bool SpielErstellt::klientGetrennt( SSKlient * zKlient )
 {
-	if( !verbunden )
-		return 0;
-	int accId = zKlient->getAccountId();
-	bool ret = 0;
-	for( int i = 0; i < spielerAnzahl; i++ )
-	{
-		if( accounts->hat( i ) && accounts->get( i ) == accId )
-		{
-			if( status->hat( i ) && status->get( i ) != 0 )
-			{
-				zKlient->setSpielErstellt( 0 );
-				status->set( 0, i );
-				verbunden--;
-				klients->set( 0, i );
-				ret = 1;
-			}
-			break;
-		}
-	}
-	return ret;
+    if( !verbunden )
+        return 0;
+    int accId = zKlient->getAccountId();
+    bool ret = 0;
+    for( int i = 0; i < spielerAnzahl; i++ )
+    {
+        if( accounts->hat( i ) && accounts->get( i ) == accId )
+        {
+            if( status->hat( i ) && status->get( i ) != 0 )
+            {
+                zKlient->setSpielErstellt( 0 );
+                status->set( 0, i );
+                verbunden--;
+                klients->set( 0, i );
+                ret = 1;
+            }
+            break;
+        }
+    }
+    return ret;
 }
 
 void SpielErstellt::thread()
 {
-	state = 1;
-	double time = 0;
-	ZeitMesser *zeit = new ZeitMesser();
-	int nachrichtSenden = 1;
-	while( time < 10 )
-	{ // warten auf annahme von allen Spielern
-		if( abbr )
-			break;
-		zeit->messungStart();
-		Sleep( 100 );
-		bool br = 0;
-		bool st2 = 1;
-		for( int i = 0; i < spielerAnzahl; i++ )
-		{
-			if( status->hat( i ) && status->get( i ) == 3 )
-			{
-				br = 1;
-				for( int j = 0; j < spielerAnzahl; j++ )
-				{
-					if( j != i )
-						status->set( 2, j );
-				}
-				break;
-			}
-			if( st2 )
-				st2 = status->hat( i ) && status->get( i ) == 2;
-		}
-		if( st2 )
-			br = 1;
-		if( br )
-		{
-			zeit->messungEnde();
-			break;
-		}
-		char verbleibend = (char)( 10 - (char)time );
-		if( verbleibend < 0 )
-			verbleibend = 0;
-		if( time > nachrichtSenden )
-		{
-			for( int i = 0; i < spielerAnzahl; i++ )
-			{
-				if( status->hat( i ) && status->get( i ) != 0 )
-				{
-					SSKlient *tmp = klients->z( i );
-					if( tmp )
-						tmp->zeitVerbleibend( verbleibend );
-				}
-			}
-			nachrichtSenden++;
-		}
-		zeit->messungEnde();
-		time += zeit->getSekunden();
-	} // prüfen ob alle Spieler bereit sind
-	state = 2;
-	bool abbruch = verbunden != spielerAnzahl;
-	const char *err = "Ein Spieler konnte nicht erreicht werden.";
-	if( !abbruch )
-	{
-		for( int i = 0; i < spielerAnzahl; i++ )
-		{
-			if( !status->hat( i ) || status->get( i ) != 2 )
-			{
-				abbruch = 1;
-				err = "Ein Spieler ist noch nicht bereit.";
-				break;
-			}
-		}
-	}
-	if( abbr )
-	{
-		err = "Das Spiel wurde Wegen abwesenheit eines Spielers Abgebrochen.";
-		abbruch = 1;
-		for( int j = 0; j < spielerAnzahl; j++ )
-			status->set( 2, j );
-	}
-	if( abbruch )
-	{ // Es sind nicht alle bereit Vorgang abbrechen
-		for( int i = 0; i < spielerAnzahl; i++ )
-		{
-			if( status->hat( i ) && status->get( i ) != 0 )
-			{
-				SSKlient *tmp = klients->z( i );
-				if( tmp )
-					tmp->erstellungAbgebrochen( (char*)err );
-			}
-		}
-		Array< bool > *inWarteschlange = new Array< bool >();
-		RCArray< Zeit > *wZeit = new RCArray< Zeit >();
-		if( ss->zDB()->spielErstelltAbbruch( id, spielerAnzahl, accounts, status, inWarteschlange, wZeit ) ) // zurück in Warteschlange
-		{
-			for( int i = 0; i < spielerAnzahl; i++ )
-			{
-				if( inWarteschlange->hat( i ) && inWarteschlange->get( i ) )
-				{
-					SSKlient *tmp = klients->z( i );
-					if( tmp )
-					{
-						Zeit *zTmp = wZeit->z( i );
-						if( zTmp )
-							tmp->backInWarteschlange( (char)zTmp->zUhrzeit()->getStunde(), (char)zTmp->zUhrzeit()->getMinute(), (char)zTmp->zUhrzeit()->getSekunde() );
-					}
-				}
-			}
-		}
-		inWarteschlange->release();
-		wZeit->release();
-		for( int i = 0; i < spielerAnzahl; i++ )
-		{
-			SSKlient *tmp = klients->z( i );
-			if( tmp )
-				tmp->trenne();
-		}
-		zeit->release();
-		ss->removeSpielErstellt( id ); // delete this
-		return;
-	}
-	// alle Spieler sind bereit Vorgang fortsetzen
-	spielId = ss->zDB()->spielErstelltFortsetzen( id );
-	Spiel *weiter = new Spiel( spielId, ss->getThis() );
-	ss->addSpiel( weiter );
-	weiter->setAccounts( spielerAnzahl, accounts );
-	weiter->setKlients( spielerAnzahl, klients );
-	weiter->setKarteId( karte );
-	ss->removeSpielErstellt( id ); // delete this
-	zeit->release();
+    state = 1;
+    double time = 0;
+    ZeitMesser *zeit = new ZeitMesser();
+    int nachrichtSenden = 1;
+    while( time < 10 )
+    { // warten auf annahme von allen Spielern
+        if( abbr )
+            break;
+        zeit->messungStart();
+        Sleep( 100 );
+        bool br = 0;
+        bool st2 = 1;
+        for( int i = 0; i < spielerAnzahl; i++ )
+        {
+            if( status->hat( i ) && status->get( i ) == 3 )
+            {
+                br = 1;
+                for( int j = 0; j < spielerAnzahl; j++ )
+                {
+                    if( j != i )
+                        status->set( 2, j );
+                }
+                break;
+            }
+            if( st2 )
+                st2 = status->hat( i ) && status->get( i ) == 2;
+        }
+        if( st2 )
+            br = 1;
+        if( br )
+        {
+            zeit->messungEnde();
+            break;
+        }
+        char verbleibend = (char)( 10 - (char)time );
+        if( verbleibend < 0 )
+            verbleibend = 0;
+        if( time > nachrichtSenden )
+        {
+            for( int i = 0; i < spielerAnzahl; i++ )
+            {
+                if( status->hat( i ) && status->get( i ) != 0 )
+                {
+                    SSKlient *tmp = klients->z( i );
+                    if( tmp )
+                        tmp->zeitVerbleibend( verbleibend );
+                }
+            }
+            nachrichtSenden++;
+        }
+        zeit->messungEnde();
+        time += zeit->getSekunden();
+    } // prüfen ob alle Spieler bereit sind
+    state = 2;
+    bool abbruch = verbunden != spielerAnzahl;
+    const char *err = "Ein Spieler konnte nicht erreicht werden.";
+    if( !abbruch )
+    {
+        for( int i = 0; i < spielerAnzahl; i++ )
+        {
+            if( !status->hat( i ) || status->get( i ) != 2 )
+            {
+                abbruch = 1;
+                err = "Ein Spieler ist noch nicht bereit.";
+                break;
+            }
+        }
+    }
+    if( abbr )
+    {
+        err = "Das Spiel wurde Wegen abwesenheit eines Spielers Abgebrochen.";
+        abbruch = 1;
+        for( int j = 0; j < spielerAnzahl; j++ )
+            status->set( 2, j );
+    }
+    if( abbruch )
+    { // Es sind nicht alle bereit Vorgang abbrechen
+        for( int i = 0; i < spielerAnzahl; i++ )
+        {
+            if( status->hat( i ) && status->get( i ) != 0 )
+            {
+                SSKlient *tmp = klients->z( i );
+                if( tmp )
+                    tmp->erstellungAbgebrochen( (char *)err );
+            }
+        }
+        Array< bool > *inWarteschlange = new Array< bool >();
+        RCArray< Zeit > *wZeit = new RCArray< Zeit >();
+        if( ss->zDB()->spielErstelltAbbruch( id, spielerAnzahl, accounts, status, inWarteschlange, wZeit ) ) // zurück in Warteschlange
+        {
+            for( int i = 0; i < spielerAnzahl; i++ )
+            {
+                if( inWarteschlange->hat( i ) && inWarteschlange->get( i ) )
+                {
+                    SSKlient *tmp = klients->z( i );
+                    if( tmp )
+                    {
+                        Zeit *zTmp = wZeit->z( i );
+                        if( zTmp )
+                            tmp->backInWarteschlange( (char)zTmp->zUhrzeit()->getStunde(), (char)zTmp->zUhrzeit()->getMinute(), (char)zTmp->zUhrzeit()->getSekunde() );
+                    }
+                }
+            }
+        }
+        inWarteschlange->release();
+        wZeit->release();
+        for( int i = 0; i < spielerAnzahl; i++ )
+        {
+            SSKlient *tmp = klients->z( i );
+            if( tmp )
+                tmp->trenne();
+        }
+        zeit->release();
+        ss->removeSpielErstellt( id ); // delete this
+        return;
+    }
+    // alle Spieler sind bereit Vorgang fortsetzen
+    spielId = ss->zDB()->spielErstelltFortsetzen( id );
+    Spiel *weiter = new Spiel( spielId, (SpielServer *)ss->getThis() );
+    ss->addSpiel( weiter );
+    weiter->setAccounts( spielerAnzahl, accounts );
+    weiter->setKlients( spielerAnzahl, klients );
+    weiter->setKarteId( karte );
+    ss->removeSpielErstellt( id ); // delete this
+    zeit->release();
 }
 
 // constant
 int SpielErstellt::getId() const
 {
-	return id;
-}
-
-// Reference Counting
-SpielErstellt *SpielErstellt::getThis()
-{
-	ref++;
-	return this;
-}
-
-SpielErstellt *SpielErstellt::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
+    return id;
 }
 
 // Inhalt der SpielFinden Klasse aus SpielErstellt.h
 // Konstruktor
-SpielFinden::SpielFinden( SpielServer *ss )
-: Thread()
+SpielFinden::SpielFinden( SpielServer * ss )
+    : Thread()
 {
-	this->ss = ss;
-	end = 0;
-	spielServerId = 0;
-	ref = 1;
+    this->ss = ss;
+    end = 0;
+    spielServerId = 0;
 }
 
 // Destruktor
 SpielFinden::~SpielFinden()
 {
-	end = 1;
-	warteAufThread( 2000 );
+    end = 1;
+    warteAufThread( 2000 );
 }
 
 // nicht constant
 void SpielFinden::setEnde()
 {
-	end = 1;
+    end = 1;
 }
 
 void SpielFinden::setSpielServerId( int id )
 {
-	spielServerId = id;
+    spielServerId = id;
 }
 
 void SpielFinden::thread()
 {
-	end = 0;
-	while( !end )
-	{
-		for( int i = 0; i < 10 && !end; i++ )
-			Sleep( 1000 );
-		if( end )
-			break;
-		int ret = ss->zDB()->erstelleSpiel( spielServerId );
-		if( !ret )
-		{ // erfolg
-			int id = ss->zDB()->getSpielErstelltId( spielServerId );
-			SpielErstellt *erstellt = new SpielErstellt( id, ss->getThis() );
-			ss->addSpielErstellt( erstellt );
-			erstellt->sendeVerbindungsBefehl();
-			ss->zDB()->deleteSpielErstelltNext( spielServerId );
-		}
-	}
-	run = 0;
-	end = 0;
-}
-
-// constant
-
-// Reference Counting
-SpielFinden *SpielFinden::getThis()
-{
-	ref++;
-	return this;
-}
-
-SpielFinden *SpielFinden::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
+    end = 0;
+    while( !end )
+    {
+        for( int i = 0; i < 10 && !end; i++ )
+            Sleep( 1000 );
+        if( end )
+            break;
+        int ret = ss->zDB()->erstelleSpiel( spielServerId );
+        if( !ret )
+        { // erfolg
+            int id = ss->zDB()->getSpielErstelltId( spielServerId );
+            SpielErstellt *erstellt = new SpielErstellt( id, (SpielServer *)ss->getThis() );
+            ss->addSpielErstellt( erstellt );
+            erstellt->sendeVerbindungsBefehl();
+            ss->zDB()->deleteSpielErstelltNext( spielServerId );
+        }
+    }
+    run = 0;
+    end = 0;
 }

+ 0 - 10
SpielServer/SpielErstellt.h

@@ -27,7 +27,6 @@ private:
 	int state;
 	bool abbr;
 	int spielId;
-	int ref;
 
 public:
 	// Konstruktor
@@ -44,9 +43,6 @@ public:
 	virtual void thread();
 	// constant
 	int getId() const;
-	// Reference Counting
-	SpielErstellt *getThis();
-	SpielErstellt *release();
 };
 
 class SpielFinden : public Thread
@@ -55,7 +51,6 @@ private:
 	SpielServer *ss;
 	bool end;
 	int spielServerId;
-	int ref;
 
 public:
 	// Konstruktor
@@ -66,11 +61,6 @@ public:
 	void setEnde();
 	void setSpielServerId( int id );
 	virtual void thread();
-	// constant
-
-	// Reference Counting
-	SpielFinden *getThis();
-	SpielFinden *release();
 };
 
 #endif

+ 2 - 34
SpielServer/SpielServer.cpp

@@ -37,7 +37,6 @@ SpielServer::SpielServer( InitDatei *zIni )
 	end = 0;
 	nichtPausiert = 0;
 	InitializeCriticalSection( &cs );
-	ref = 1;
     startSpielThread = new SpielFinden( this );
 	if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
 	{
@@ -105,7 +104,7 @@ void SpielServer::runn()
 		}
 		if( !klient )
 			continue;
-		SSAKlient *slHandle = new SSAKlient( klient, getThis() );
+		SSAKlient *slHandle = new SSAKlient( klient, (SpielServer *)getThis() );
 		slHandle->start();
 	}
 }
@@ -119,7 +118,7 @@ void SpielServer::thread()
 		if( !klient )
 			continue;
 		Framework::getThreadRegister()->cleanUpClosedThreads();
-		SSKlient *slHandle = new SSKlient( klient, getThis() );
+		SSKlient *slHandle = new SSKlient( klient, (SpielServer *)getThis() );
 		klientAnzahl2++;
 		slHandle->start();
 	}
@@ -650,21 +649,6 @@ int SpielServer::getPort() const
 	return TextZuInt( ini->zWert( "ServerPort" )->getText(), 10 );
 }
 
-// Reference Counting
-SpielServer *SpielServer::getThis()
-{
-	ref++;
-	return this;
-}
-
-SpielServer *SpielServer::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
-}
-
 
 // Inhalt der SSAKlient Klasse aus SpielServer.h
 // Konstruktor 
@@ -1050,7 +1034,6 @@ SSKlient::SSKlient( SKlient *klient, SpielServer *ss )
 	zErstellt = 0;
 	zSpiel = 0;
 	InitializeCriticalSection( &cs );
-	ref = 1;
 }
 
 // Destruktor 
@@ -1785,19 +1768,4 @@ int SSKlient::getKlientNummer() const
 SKlient *SSKlient::getKlient() const
 {
 	return empfangen->getThis();
-}
-
-// Reference Counting
-SSKlientV *SSKlient::getThis()
-{
-	ref++;
-	return this;
-}
-
-SSKlientV *SSKlient::release()
-{
-	ref--;
-	if( !ref )
-		delete this;
-	return 0;
 }

+ 0 - 8
SpielServer/SpielServer.h

@@ -48,7 +48,6 @@ private:
 	int empfangen;
 	int gesendet;
 	bool end;
-	int ref;
 
 public:
 	// Konstruktor 
@@ -91,9 +90,6 @@ public:
 	char *getLetzterFehler() const;
 	char *getIp() const;
 	int getPort() const;
-	// Reference Counting
-	SpielServer *getThis();
-	SpielServer *release();
 };
 
 class SSAKlient : public Thread
@@ -130,7 +126,6 @@ private:
 	SpielErstellt *zErstellt;
 	Spiel *zSpiel;
 	CRITICAL_SECTION cs;
-	int ref;
 
 public:
 	// Konstruktor 
@@ -172,9 +167,6 @@ public:
 	virtual int getAccountId() const;
 	int getKlientNummer() const;
 	SKlient *getKlient() const;
-	// Reference Counting
-	virtual SSKlientV *getThis();
-	virtual SSKlientV *release();
 };
 
 #endif