|
@@ -5,529 +5,529 @@
|
|
|
// Inhalt der SpielStatistik Klasse aus SpielStatistik.h
|
|
|
// Konstruktor
|
|
|
SpielStatistik::SpielStatistik()
|
|
|
- : ReferenceCounter()
|
|
|
+ : ReferenceCounter()
|
|
|
{
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
- addNachrichtF = 0;
|
|
|
- addChatF = 0;
|
|
|
- addFreundF = 0;
|
|
|
- accountAnsehenF = 0;
|
|
|
- istFreundF = 0;
|
|
|
- nachrichtParam = 0;
|
|
|
- bilder = 0;
|
|
|
- infoc = 0;
|
|
|
- spielc = 0;
|
|
|
- status = 0;
|
|
|
- gss = new Array< SSDGesamtSpieler * >();
|
|
|
- gts = new Array< SSDGesamtTeam * >();
|
|
|
- rs = new Array< SSDRunde * >();
|
|
|
- chat = 0;
|
|
|
- runde = 0;
|
|
|
- tabelle = 0;
|
|
|
- accountId = 0;
|
|
|
- rend = 0;
|
|
|
+ InitializeCriticalSection(&cs);
|
|
|
+ addNachrichtF = 0;
|
|
|
+ addChatF = 0;
|
|
|
+ addFreundF = 0;
|
|
|
+ accountAnsehenF = 0;
|
|
|
+ istFreundF = 0;
|
|
|
+ nachrichtParam = 0;
|
|
|
+ bilder = 0;
|
|
|
+ infoc = 0;
|
|
|
+ spielc = 0;
|
|
|
+ status = 0;
|
|
|
+ gss = new Array< SSDGesamtSpieler* >();
|
|
|
+ gts = new Array< SSDGesamtTeam* >();
|
|
|
+ rs = new Array< SSDRunde* >();
|
|
|
+ chat = 0;
|
|
|
+ runde = 0;
|
|
|
+ tabelle = 0;
|
|
|
+ accountId = 0;
|
|
|
+ rend = 0;
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
|
SpielStatistik::~SpielStatistik()
|
|
|
{
|
|
|
- if( chat )
|
|
|
- chat->release();
|
|
|
- if( runde )
|
|
|
- runde->release();
|
|
|
- if( tabelle )
|
|
|
- tabelle->release();
|
|
|
- if( infoc )
|
|
|
- infoc->release();
|
|
|
- if( spielc )
|
|
|
- spielc->release();
|
|
|
- int anz = gss->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( gss->hat( i ) )
|
|
|
- delete gss->get( i );
|
|
|
- }
|
|
|
- gss->release();
|
|
|
- anz = gts->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( gts->hat( i ) )
|
|
|
- delete gts->get( i );
|
|
|
- }
|
|
|
- gts->release();
|
|
|
- anz = rs->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( rs->hat( i ) )
|
|
|
- {
|
|
|
- int anz2 = rs->get( i )->spieler.getEintragAnzahl();
|
|
|
- for( int j = 0; j < anz2; j++ )
|
|
|
- {
|
|
|
- if( rs->get( i )->spieler.hat( j ) )
|
|
|
- delete rs->get( i )->spieler.get( j );
|
|
|
- }
|
|
|
- anz2 = rs->get( i )->teams.getEintragAnzahl();
|
|
|
- for( int j = 0; j < anz2; j++ )
|
|
|
- {
|
|
|
- if( rs->get( i )->teams.hat( j ) )
|
|
|
- delete rs->get( i )->teams.get( j );
|
|
|
- }
|
|
|
- delete rs->get( i );
|
|
|
- }
|
|
|
- }
|
|
|
- rs->release();
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
+ if (chat)
|
|
|
+ chat->release();
|
|
|
+ if (runde)
|
|
|
+ runde->release();
|
|
|
+ if (tabelle)
|
|
|
+ tabelle->release();
|
|
|
+ if (infoc)
|
|
|
+ infoc->release();
|
|
|
+ if (spielc)
|
|
|
+ spielc->release();
|
|
|
+ int anz = gss->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (gss->hat(i))
|
|
|
+ delete gss->get(i);
|
|
|
+ }
|
|
|
+ gss->release();
|
|
|
+ anz = gts->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (gts->hat(i))
|
|
|
+ delete gts->get(i);
|
|
|
+ }
|
|
|
+ gts->release();
|
|
|
+ anz = rs->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (rs->hat(i))
|
|
|
+ {
|
|
|
+ int anz2 = rs->get(i)->spieler.getEintragAnzahl();
|
|
|
+ for (int j = 0; j < anz2; j++)
|
|
|
+ {
|
|
|
+ if (rs->get(i)->spieler.hat(j))
|
|
|
+ delete rs->get(i)->spieler.get(j);
|
|
|
+ }
|
|
|
+ anz2 = rs->get(i)->teams.getEintragAnzahl();
|
|
|
+ for (int j = 0; j < anz2; j++)
|
|
|
+ {
|
|
|
+ if (rs->get(i)->teams.hat(j))
|
|
|
+ delete rs->get(i)->teams.get(j);
|
|
|
+ }
|
|
|
+ delete rs->get(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rs->release();
|
|
|
+ DeleteCriticalSection(&cs);
|
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
|
void SpielStatistik::lock()
|
|
|
{
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ EnterCriticalSection(&cs);
|
|
|
}
|
|
|
|
|
|
void SpielStatistik::unlock()
|
|
|
{
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ LeaveCriticalSection(&cs);
|
|
|
}
|
|
|
|
|
|
void SpielStatistik::bereit()
|
|
|
{
|
|
|
- char byte = 1;
|
|
|
- spielc->statistikNachricht( 1, &byte );
|
|
|
+ char byte = 1;
|
|
|
+ spielc->statistikNachricht(1, &byte);
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::setBilder( BilderV *b )
|
|
|
+void SpielStatistik::setBilder(BilderV* b)
|
|
|
{
|
|
|
- bilder = b;
|
|
|
+ bilder = b;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::setAccountId( int id )
|
|
|
+void SpielStatistik::setAccountId(int id)
|
|
|
{
|
|
|
- accountId = id;
|
|
|
+ accountId = id;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::setRückrufFunktionen( void( *addNachrichtF )( void *, Text *, Text *, Text *, Text * ),
|
|
|
- void( *addChatF )( void *, int ), void( *addFreundF )( void *, int ),
|
|
|
- void( *accountAnsehenF )( void *, int ), bool( *istFreundF )( void *, int ), void *nachrichtParam )
|
|
|
+void SpielStatistik::setRückrufFunktionen(void(*addNachrichtF)(void*, Text*, Text*, Text*, Text*),
|
|
|
+ void(*addChatF)(void*, int), void(*addFreundF)(void*, int),
|
|
|
+ void(*accountAnsehenF)(void*, int), bool(*istFreundF)(void*, int), void* nachrichtParam)
|
|
|
{
|
|
|
- this->addNachrichtF = addNachrichtF;
|
|
|
- this->addChatF = addChatF;
|
|
|
- this->addFreundF = addFreundF;
|
|
|
- this->accountAnsehenF = accountAnsehenF;
|
|
|
- this->istFreundF = istFreundF;
|
|
|
- this->nachrichtParam = nachrichtParam;
|
|
|
+ this->addNachrichtF = addNachrichtF;
|
|
|
+ this->addChatF = addChatF;
|
|
|
+ this->addFreundF = addFreundF;
|
|
|
+ this->accountAnsehenF = accountAnsehenF;
|
|
|
+ this->istFreundF = istFreundF;
|
|
|
+ this->nachrichtParam = nachrichtParam;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::setUIFactory( UIInit &factory )
|
|
|
+void SpielStatistik::setUIFactory(UIInit& factory)
|
|
|
{
|
|
|
- uiFactory = factory;
|
|
|
+ uiFactory = factory;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::setKlients( KSGClient::InformationServerClient *infoc, KSGClient::SpielServerClient *spielc )
|
|
|
+void SpielStatistik::setKlients(KSGClient::InformationServerClient* infoc, KSGClient::SpielServerClient* spielc)
|
|
|
{
|
|
|
- if( this->infoc )
|
|
|
- this->infoc->release();
|
|
|
- if( this->spielc )
|
|
|
- this->spielc->release();
|
|
|
- this->infoc = infoc;
|
|
|
- this->spielc = spielc;
|
|
|
+ if (this->infoc)
|
|
|
+ this->infoc->release();
|
|
|
+ if (this->spielc)
|
|
|
+ this->spielc->release();
|
|
|
+ this->infoc = infoc;
|
|
|
+ this->spielc = spielc;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::nachricht( int län, char *bytes )
|
|
|
+void SpielStatistik::nachricht(int län, const char* bytes)
|
|
|
{
|
|
|
- lock();
|
|
|
- char num = *bytes;
|
|
|
- bytes++;
|
|
|
- län--;
|
|
|
- switch( num )
|
|
|
- {
|
|
|
- case 1: // Ladevorgang abgeschlossen
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- chat = new StatistikChat( accountId, dynamic_cast<KSGClient::SpielServerClient *>( spielc->getThis() ), dynamic_cast<KSGClient::InformationServerClient *>( infoc->getThis() ), uiFactory, bilder, addNachrichtF, addChatF, addFreundF, accountAnsehenF, nachrichtParam );
|
|
|
- int anz = gss->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( gss->hat( i ) )
|
|
|
- {
|
|
|
- int acc = infoc->getAccountId( gss->get( i )->spielerName );
|
|
|
- if( acc )
|
|
|
- chat->addSpieler( acc, istFreundF( nachrichtParam, acc ) || acc == accountId );
|
|
|
- }
|
|
|
- }
|
|
|
- runde = new StatistikRunde( uiFactory, dynamic_cast<Array<SSDRunde *> *>( rs->getThis() ) );
|
|
|
- tabelle = new StatistikTabelle( dynamic_cast<Array<SSDGesamtSpieler *> *>( gss->getThis() ), dynamic_cast<Array<SSDGesamtTeam *> *>( gts->getThis() ), dynamic_cast<Array<SSDRunde *> *>( rs->getThis() ), uiFactory );
|
|
|
- status = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2: // Gesammt Spieler Statistik
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- SSDGesamtSpieler *ssdgs = new SSDGesamtSpieler();
|
|
|
- ssdgs->spielerNummer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- char snlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- char *txt = new char[ snlän + 1 ];
|
|
|
- txt[ snlän ] = 0;
|
|
|
- for( int i = 0; i < snlän; i++ )
|
|
|
- txt[ i ] = bytes[ i ];
|
|
|
- bytes += snlän;
|
|
|
- län -= snlän;
|
|
|
- ssdgs->spielerName = txt;
|
|
|
- delete[] txt;
|
|
|
- char tnlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- txt = new char[ tnlän + 1 ];
|
|
|
- txt[ tnlän ] = 0;
|
|
|
- for( int i = 0; i < tnlän; i++ )
|
|
|
- txt[ i ] = bytes[ i ];
|
|
|
- bytes += tnlän;
|
|
|
- län -= tnlän;
|
|
|
- ssdgs->teamName = txt;
|
|
|
- delete[] txt;
|
|
|
- ssdgs->spielerFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->teamFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->gewonneneRunden = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->punkte = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->linienLänge = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->zeitAmLeben = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->zeitTod = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->kills = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgs->tode = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- gss->add( ssdgs );
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3: // Gesammt Team Statistik
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- SSDGesamtTeam *ssdgt = new SSDGesamtTeam();
|
|
|
- ssdgt->teamNummer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- char tnlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- char *txt = new char[ tnlän + 1 ];
|
|
|
- txt[ tnlän ] = 0;
|
|
|
- for( int i = 0; i < tnlän; i++ )
|
|
|
- txt[ i ] = bytes[ i ];
|
|
|
- bytes += tnlän;
|
|
|
- län -= tnlän;
|
|
|
- ssdgt->teamName = txt;
|
|
|
- delete[] txt;
|
|
|
- ssdgt->teamFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgt->gewonneneRunden = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgt->punkte = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgt->linienLänge = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgt->kills = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdgt->tode = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- gts->add( ssdgt );
|
|
|
- }
|
|
|
- break;
|
|
|
- case 4: // Runde Statistik
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- SSDRunde *ssdr = new SSDRunde();
|
|
|
- ssdr->rundenNummer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdr->rundenDauer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdr->rundenSieger = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdr->spielfeldNutzung = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int breite = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int höhe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdr->rundenBild.neuBild( breite, höhe, 0 );
|
|
|
- rs->add( ssdr );
|
|
|
- }
|
|
|
- break;
|
|
|
- case 5: // Runde Bild
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- int runde = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int *buff = 0;
|
|
|
- int max = 0;
|
|
|
- int anz = rs->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( rs->hat( i ) && rs->get( i )->rundenNummer == runde )
|
|
|
- {
|
|
|
- buff = rs->get( i )->rundenBild.getBuffer();
|
|
|
- max = rs->get( i )->rundenBild.getBreite() * rs->get( i )->rundenBild.getHeight();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if( !buff )
|
|
|
- break;
|
|
|
- int index = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int plän = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- for( int i = 0; i < plän; i++ )
|
|
|
- {
|
|
|
- if( index + i >= max )
|
|
|
- break;
|
|
|
- buff[ index + i ] = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case 6: // Runde Spieler Statistik
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- int runde = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int anz = rs->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( rs->hat( i ) && rs->get( i )->rundenNummer == runde )
|
|
|
- {
|
|
|
- SSDRundeSpieler *ssdrs = new SSDRundeSpieler();
|
|
|
- ssdrs->spielerNummer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- char snlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- char *txt = new char[ snlän + 1 ];
|
|
|
- txt[ snlän ] = 0;
|
|
|
- for( int j = 0; j < snlän; j++ )
|
|
|
- txt[ j ] = bytes[ j ];
|
|
|
- bytes += snlän;
|
|
|
- län -= snlän;
|
|
|
- ssdrs->spielerName = txt;
|
|
|
- delete[] txt;
|
|
|
- char tnlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- txt = new char[ tnlän + 1 ];
|
|
|
- txt[ tnlän ] = 0;
|
|
|
- for( int j = 0; j < tnlän; j++ )
|
|
|
- txt[ j ] = bytes[ j ];
|
|
|
- bytes += tnlän;
|
|
|
- län -= tnlän;
|
|
|
- ssdrs->teamName = txt;
|
|
|
- delete[] txt;
|
|
|
- ssdrs->spielerFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrs->teamFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrs->linienLänge = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrs->kills = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrs->todesZeit = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- rs->get( i )->spieler.add( ssdrs );
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case 7: // Runde Team Statistik
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- int runde = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- int anz = rs->getEintragAnzahl();
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
- {
|
|
|
- if( rs->hat( i ) && rs->get( i )->rundenNummer == runde )
|
|
|
- {
|
|
|
- SSDRundeTeam *ssdrt = new SSDRundeTeam();
|
|
|
- ssdrt->teamNummer = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- char tnlän = *bytes;
|
|
|
- län--;
|
|
|
- bytes++;
|
|
|
- char *txt = new char[ tnlän + 1 ];
|
|
|
- txt[ tnlän ] = 0;
|
|
|
- for( int j = 0; j < tnlän; j++ )
|
|
|
- txt[ j ] = bytes[ j ];
|
|
|
- bytes += tnlän;
|
|
|
- län -= tnlän;
|
|
|
- ssdrt->teamName = txt;
|
|
|
- delete[] txt;
|
|
|
- ssdrt->teamFarbe = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrt->ergebnis = *bytes;
|
|
|
- bytes++;
|
|
|
- län--;
|
|
|
- ssdrt->linienLänge = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrt->kills = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- ssdrt->tode = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- rs->get( i )->teams.add( ssdrt );
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case 8: // Chat Nachricht
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- int vonAccount = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- char *txt = new char[ län + 1 ];
|
|
|
- txt[ län ] = 0;
|
|
|
- for( int i = 0; i < län; i++ )
|
|
|
- txt[ i ] = bytes[ i ];
|
|
|
- if( status == 1 )
|
|
|
- chat->addChatNachricht( vonAccount, txt );
|
|
|
- delete[] txt;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 9: // Spieler hat verlassen
|
|
|
- if( 1 )
|
|
|
- {
|
|
|
- int acc = *(int *)bytes;
|
|
|
- bytes += 4;
|
|
|
- län -= 4;
|
|
|
- if( status == 1 )
|
|
|
- chat->spielerOffline( acc );
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- // Fehler
|
|
|
- break;
|
|
|
- }
|
|
|
- if( län != 0 )
|
|
|
- {
|
|
|
- // Fehler
|
|
|
- }
|
|
|
- unlock();
|
|
|
+ lock();
|
|
|
+ char num = *bytes;
|
|
|
+ bytes++;
|
|
|
+ län--;
|
|
|
+ switch (num)
|
|
|
+ {
|
|
|
+ case 1: // Ladevorgang abgeschlossen
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ chat = new StatistikChat(accountId, dynamic_cast<KSGClient::SpielServerClient*>(spielc->getThis()), dynamic_cast<KSGClient::InformationServerClient*>(infoc->getThis()), uiFactory, bilder, addNachrichtF, addChatF, addFreundF, accountAnsehenF, nachrichtParam);
|
|
|
+ int anz = gss->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (gss->hat(i))
|
|
|
+ {
|
|
|
+ int acc = infoc->getAccountId(gss->get(i)->spielerName);
|
|
|
+ if (acc)
|
|
|
+ chat->addSpieler(acc, istFreundF(nachrichtParam, acc) || acc == accountId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ runde = new StatistikRunde(uiFactory, dynamic_cast<Array<SSDRunde*> *>(rs->getThis()));
|
|
|
+ tabelle = new StatistikTabelle(dynamic_cast<Array<SSDGesamtSpieler*> *>(gss->getThis()), dynamic_cast<Array<SSDGesamtTeam*> *>(gts->getThis()), dynamic_cast<Array<SSDRunde*> *>(rs->getThis()), uiFactory);
|
|
|
+ status = 1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2: // Gesammt Spieler Statistik
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ SSDGesamtSpieler* ssdgs = new SSDGesamtSpieler();
|
|
|
+ ssdgs->spielerNummer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ char snlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ char* txt = new char[snlän + 1];
|
|
|
+ txt[snlän] = 0;
|
|
|
+ for (int i = 0; i < snlän; i++)
|
|
|
+ txt[i] = bytes[i];
|
|
|
+ bytes += snlän;
|
|
|
+ län -= snlän;
|
|
|
+ ssdgs->spielerName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ char tnlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ txt = new char[tnlän + 1];
|
|
|
+ txt[tnlän] = 0;
|
|
|
+ for (int i = 0; i < tnlän; i++)
|
|
|
+ txt[i] = bytes[i];
|
|
|
+ bytes += tnlän;
|
|
|
+ län -= tnlän;
|
|
|
+ ssdgs->teamName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ ssdgs->spielerFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->teamFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->gewonneneRunden = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->punkte = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->linienLänge = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->zeitAmLeben = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->zeitTod = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->kills = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgs->tode = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ gss->add(ssdgs);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3: // Gesammt Team Statistik
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ SSDGesamtTeam* ssdgt = new SSDGesamtTeam();
|
|
|
+ ssdgt->teamNummer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ char tnlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ char* txt = new char[tnlän + 1];
|
|
|
+ txt[tnlän] = 0;
|
|
|
+ for (int i = 0; i < tnlän; i++)
|
|
|
+ txt[i] = bytes[i];
|
|
|
+ bytes += tnlän;
|
|
|
+ län -= tnlän;
|
|
|
+ ssdgt->teamName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ ssdgt->teamFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgt->gewonneneRunden = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgt->punkte = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgt->linienLänge = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgt->kills = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdgt->tode = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ gts->add(ssdgt);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4: // Runde Statistik
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ SSDRunde* ssdr = new SSDRunde();
|
|
|
+ ssdr->rundenNummer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdr->rundenDauer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdr->rundenSieger = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdr->spielfeldNutzung = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int breite = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int höhe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdr->rundenBild.neuBild(breite, höhe, 0);
|
|
|
+ rs->add(ssdr);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5: // Runde Bild
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ int runde = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int* buff = 0;
|
|
|
+ int max = 0;
|
|
|
+ int anz = rs->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (rs->hat(i) && rs->get(i)->rundenNummer == runde)
|
|
|
+ {
|
|
|
+ buff = rs->get(i)->rundenBild.getBuffer();
|
|
|
+ max = rs->get(i)->rundenBild.getBreite() * rs->get(i)->rundenBild.getHeight();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!buff)
|
|
|
+ break;
|
|
|
+ int index = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int plän = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ for (int i = 0; i < plän; i++)
|
|
|
+ {
|
|
|
+ if (index + i >= max)
|
|
|
+ break;
|
|
|
+ buff[index + i] = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6: // Runde Spieler Statistik
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ int runde = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int anz = rs->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (rs->hat(i) && rs->get(i)->rundenNummer == runde)
|
|
|
+ {
|
|
|
+ SSDRundeSpieler* ssdrs = new SSDRundeSpieler();
|
|
|
+ ssdrs->spielerNummer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ char snlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ char* txt = new char[snlän + 1];
|
|
|
+ txt[snlän] = 0;
|
|
|
+ for (int j = 0; j < snlän; j++)
|
|
|
+ txt[j] = bytes[j];
|
|
|
+ bytes += snlän;
|
|
|
+ län -= snlän;
|
|
|
+ ssdrs->spielerName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ char tnlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ txt = new char[tnlän + 1];
|
|
|
+ txt[tnlän] = 0;
|
|
|
+ for (int j = 0; j < tnlän; j++)
|
|
|
+ txt[j] = bytes[j];
|
|
|
+ bytes += tnlän;
|
|
|
+ län -= tnlän;
|
|
|
+ ssdrs->teamName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ ssdrs->spielerFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrs->teamFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrs->linienLänge = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrs->kills = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrs->todesZeit = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ rs->get(i)->spieler.add(ssdrs);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 7: // Runde Team Statistik
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ int runde = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ int anz = rs->getEintragAnzahl();
|
|
|
+ for (int i = 0; i < anz; i++)
|
|
|
+ {
|
|
|
+ if (rs->hat(i) && rs->get(i)->rundenNummer == runde)
|
|
|
+ {
|
|
|
+ SSDRundeTeam* ssdrt = new SSDRundeTeam();
|
|
|
+ ssdrt->teamNummer = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ char tnlän = *bytes;
|
|
|
+ län--;
|
|
|
+ bytes++;
|
|
|
+ char* txt = new char[tnlän + 1];
|
|
|
+ txt[tnlän] = 0;
|
|
|
+ for (int j = 0; j < tnlän; j++)
|
|
|
+ txt[j] = bytes[j];
|
|
|
+ bytes += tnlän;
|
|
|
+ län -= tnlän;
|
|
|
+ ssdrt->teamName = txt;
|
|
|
+ delete[] txt;
|
|
|
+ ssdrt->teamFarbe = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrt->ergebnis = *bytes;
|
|
|
+ bytes++;
|
|
|
+ län--;
|
|
|
+ ssdrt->linienLänge = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrt->kills = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ ssdrt->tode = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ rs->get(i)->teams.add(ssdrt);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 8: // Chat Nachricht
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ int vonAccount = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ char* txt = new char[län + 1];
|
|
|
+ txt[län] = 0;
|
|
|
+ for (int i = 0; i < län; i++)
|
|
|
+ txt[i] = bytes[i];
|
|
|
+ if (status == 1)
|
|
|
+ chat->addChatNachricht(vonAccount, txt);
|
|
|
+ delete[] txt;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 9: // Spieler hat verlassen
|
|
|
+ if (1)
|
|
|
+ {
|
|
|
+ int acc = *(int*)bytes;
|
|
|
+ bytes += 4;
|
|
|
+ län -= 4;
|
|
|
+ if (status == 1)
|
|
|
+ chat->spielerOffline(acc);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ // Fehler
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (län != 0)
|
|
|
+ {
|
|
|
+ // Fehler
|
|
|
+ }
|
|
|
+ unlock();
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::doPublicMausEreignis( MausEreignis &me )
|
|
|
+void SpielStatistik::doPublicMausEreignis(MausEreignis& me)
|
|
|
{
|
|
|
- if( !status )
|
|
|
- return;
|
|
|
- lock();
|
|
|
- if( status == 1 )
|
|
|
- {
|
|
|
- tabelle->doPublicMausEreignis( me );
|
|
|
- runde->doPublicMausEreignis( me );
|
|
|
- chat->doPublicMausEreignis( me );
|
|
|
- }
|
|
|
- unlock();
|
|
|
+ if (!status)
|
|
|
+ return;
|
|
|
+ lock();
|
|
|
+ if (status == 1)
|
|
|
+ {
|
|
|
+ tabelle->doPublicMausEreignis(me);
|
|
|
+ runde->doPublicMausEreignis(me);
|
|
|
+ chat->doPublicMausEreignis(me);
|
|
|
+ }
|
|
|
+ unlock();
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::doTastaturEreignis( TastaturEreignis &te )
|
|
|
+void SpielStatistik::doTastaturEreignis(TastaturEreignis& te)
|
|
|
{
|
|
|
- if( !status )
|
|
|
- return;
|
|
|
- lock();
|
|
|
- if( status == 1 )
|
|
|
- chat->doTastaturEreignis( te );
|
|
|
- unlock();
|
|
|
+ if (!status)
|
|
|
+ return;
|
|
|
+ lock();
|
|
|
+ if (status == 1)
|
|
|
+ chat->doTastaturEreignis(te);
|
|
|
+ unlock();
|
|
|
}
|
|
|
|
|
|
-bool SpielStatistik::tick( double zeit )
|
|
|
+bool SpielStatistik::tick(double zeit)
|
|
|
{
|
|
|
- if( !status )
|
|
|
- return 0;
|
|
|
- lock();
|
|
|
- if( status == 1 )
|
|
|
- {
|
|
|
- rend |= chat->tick( zeit );
|
|
|
- rend |= runde->tick( zeit );
|
|
|
- rend |= tabelle->tick( zeit );
|
|
|
- if( ( chat->hatVerlassen() || runde->mussVerlassen() ) && status == 1 )
|
|
|
- {
|
|
|
- spielc->trenne();
|
|
|
- status = 2;
|
|
|
- }
|
|
|
- runde->setRunde( tabelle->getRunde() );
|
|
|
- }
|
|
|
- bool ret = rend;
|
|
|
- rend = 0;
|
|
|
- unlock();
|
|
|
- return ret;
|
|
|
+ if (!status)
|
|
|
+ return 0;
|
|
|
+ lock();
|
|
|
+ if (status == 1)
|
|
|
+ {
|
|
|
+ rend |= chat->tick(zeit);
|
|
|
+ rend |= runde->tick(zeit);
|
|
|
+ rend |= tabelle->tick(zeit);
|
|
|
+ if ((chat->hatVerlassen() || runde->mussVerlassen()) && status == 1)
|
|
|
+ {
|
|
|
+ spielc->trenne();
|
|
|
+ status = 2;
|
|
|
+ }
|
|
|
+ runde->setRunde(tabelle->getRunde());
|
|
|
+ }
|
|
|
+ bool ret = rend;
|
|
|
+ rend = 0;
|
|
|
+ unlock();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
-void SpielStatistik::render( Bild &zRObj )
|
|
|
+void SpielStatistik::render(Bild& zRObj)
|
|
|
{
|
|
|
- if( !status )
|
|
|
- return;
|
|
|
- lock();
|
|
|
- chat->render( zRObj );
|
|
|
- runde->render( zRObj );
|
|
|
- tabelle->render( zRObj );
|
|
|
- unlock();
|
|
|
+ if (!status)
|
|
|
+ return;
|
|
|
+ lock();
|
|
|
+ chat->render(zRObj);
|
|
|
+ runde->render(zRObj);
|
|
|
+ tabelle->render(zRObj);
|
|
|
+ unlock();
|
|
|
}
|
|
|
|
|
|
void SpielStatistik::verlassen()
|
|
|
{
|
|
|
- if( spielc )
|
|
|
- spielc->trenne();
|
|
|
- status = 2;
|
|
|
+ if (spielc)
|
|
|
+ spielc->trenne();
|
|
|
+ status = 2;
|
|
|
}
|
|
|
|
|
|
// constant
|
|
|
int SpielStatistik::getStatus() const // 0 = laden, 1 = läuft, 2 = fortsetzen
|
|
|
{
|
|
|
- return status;
|
|
|
+ return status;
|
|
|
}
|