Przeglądaj źródła

auf neusten stand bringen

Kolja Strohm 6 lat temu
rodzic
commit
f1ab0d4b14

BIN
Test/Framework.dll


+ 4 - 3
Test/Main.cpp

@@ -1,5 +1,3 @@
-#include <iostream>
-#include <Fenster.h>
 #include <Bildschirm.h>
 #include <RenderThread.h>
 #include <KSGScript.h>
@@ -20,6 +18,9 @@
 #include "DLLDateien.h"
 #include <Network.h>
 #include <Globals.h>
+#include <iostream>
+#include <string>
+#include <XML.h>
 
 struct HINSTANCE__;
 
@@ -57,7 +58,7 @@ void doStuff()
     API *api = new API( f );
 
     MiniGames *mGames = new MiniGames( schrift, dlls.getThis(), b, api );
-    b->addMember( mGames );
+    b->addMember( mGames->getThis() );
 
     b->update();
     RenderTh *r = new RenderTh();

+ 9 - 51
Test/Minigames.cpp

@@ -127,6 +127,7 @@ typedef MiniGameV *( *GetMiniGame )( );
 // Inhalt der MGLaden Klasse aus MiniGames.h
 // Konstruktor
 MGSuchen::MGSuchen( MiniGames *mGames )
+    : Thread()
 {
     this->mGames = mGames;
     start();
@@ -161,18 +162,18 @@ void MGSuchen::thread()
         list->release();
     }
     d->release();
-    delete this;
+    release();
 }
 
 
 // Inhalt der MGLaden Klasse aus MiniGameV.h
 // Konstruktor
 MGLaden::MGLaden( char *name, DLLDateien *zDLLs, API *api )
+    : Thread()
 {
     this->api = api;
     this->name = new Text( name );
     game = 0;
-    ref = 1;
     dLLs = zDLLs->getThis();
     start();
 }
@@ -197,27 +198,23 @@ void MGLaden::thread()
     if( !DateiExistiert( pfad->getThis() ) )
     {
         pfad->release();
-        run = 0;
         return;
     }
     pfad->append( "/mg.ini" );
     if( !DateiExistiert( pfad->getThis() ) )
     {
         pfad->release();
-        run = 0;
         return;
     }
     InitDatei *mgIni = new InitDatei( pfad );
     if( !mgIni->laden() )
     {
         mgIni->release();
-        run = 0;
         return;
     }
     if( !mgIni->wertExistiert( "DllPfad" ) )
     {
         mgIni->release();
-        run = 0;
         return;
     }
     Text *dllPfad = new Text( "data/Minigames/" );
@@ -228,28 +225,22 @@ void MGLaden::thread()
     if( !DateiExistiert( dllPfad->getThis() ) )
     {
         dllPfad->release();
-        run = 0;
         return;
     }
     HMODULE dll = dLLs->ladeDLL( name->getText(), dllPfad->getText() );
     dllPfad->release();
     if( !dll )
-    {
-        run = 0;
         return;
-    }
     GetMiniGame getMiniGame = (GetMiniGame)GetProcAddress( dll, "GetMiniGame" );
     if( !getMiniGame )
     {
         dLLs->releaseDLL( name->getText() );
-        run = 0;
         return;
     }
     game = getMiniGame();
     if( !game )
     {
         dLLs->releaseDLL( name->getText() );
-        run = 0;
         return;
     }
     game->setMinigameClientZ( new MSCWrapper() );
@@ -259,7 +250,6 @@ void MGLaden::thread()
         game = game->release();
         dLLs->releaseDLL( name->getText() );
     }
-    run = 0;
 }
 
 // constant
@@ -273,21 +263,6 @@ MiniGameV *MGLaden::zGame() const
     return game;
 }
 
-// Reference Counting
-MGLaden *MGLaden::getThis()
-{
-    ref++;
-    return this;
-}
-
-MGLaden *MGLaden::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
-}
-
 
 // Inhalt der MiniGames Klasse aus MiniGames.h
 // Konstruktor
@@ -295,7 +270,7 @@ MiniGames::MiniGames( Schrift *zSchrift, DLLDateien *zDLLs, Bildschirm *screen,
     : Zeichnung()
 {
     this->api = api;
-    this->screen = screen->getThis();
+    this->screen = screen;
     dLLs = zDLLs->getThis();
     schrift = zSchrift->getThis();
     bildschirmGröße = BildschirmGröße();
@@ -306,8 +281,7 @@ MiniGames::MiniGames( Schrift *zSchrift, DLLDateien *zDLLs, Bildschirm *screen,
     tickVal = 0;
     games = new RCArray< MiniGame >();
     mgl = 0;
-    ref = 1;
-    new MGSuchen( getThis() );
+    new MGSuchen( (MiniGames*)getThis() );
 }
 
 // Destruktor
@@ -320,7 +294,6 @@ MiniGames::~MiniGames()
     if( mgl )
         mgl->release();
     dLLs->release();
-    screen->release();
 }
 
 // nicht constant
@@ -366,7 +339,7 @@ void MiniGames::doMausEreignis( MausEreignis &me )
             if( !vera && me.verarbeitet && me.id == ME_RLinks )
             { // spiel starten
                 if( mgl )
-                    mgl = mgl->release();
+                    mgl = (MGLaden*)mgl->release();
                 mgl = new MGLaden( games->z( i )->zName()->getText(), dLLs, api );
             }
         }
@@ -389,19 +362,19 @@ bool MiniGames::tick( double z )
     {
         if( !mgl->zGame() )
         {
-            mgl = mgl->release();
+            mgl = (MGLaden*)mgl->release();
         }
         else
         {
             mgl->zGame()->setSchriftZ( schrift->getThis() );
-            mgl->zGame()->setBildschirmZ( screen->getThis() );
+            mgl->zGame()->setBildschirmZ( screen );
         }
     }
     if( mgl && mgl->zGame() && !alpha2 )
     {
         rend |= mgl->zGame()->tick( z );
         if( mgl->zGame()->istEnde() )
-            mgl = mgl->release();
+            mgl = (MGLaden*)mgl->release();
     }
     if( alpha2 )
     {
@@ -453,19 +426,4 @@ void MiniGames::render( Bild &zRObj )
     zRObj.releaseDrawOptions();
     if( mgl && mgl->fertig() && mgl->zGame() )
         mgl->zGame()->render( zRObj );
-}
-
-// Reference Counting
-MiniGames *MiniGames::getThis()
-{
-    ref++;
-    return this;
-}
-
-MiniGames *MiniGames::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
 }

+ 1 - 9
Test/Minigames.h

@@ -27,14 +27,13 @@ public:
     void thread() override;
 };
 
-class MGLaden : private Thread
+class MGLaden : public Thread
 {
 private:
     Text * name;
     MiniGameV *game;
     DLLDateien *dLLs;
     API *api;
-    int ref;
 
 public:
     // Konstruktor
@@ -46,9 +45,6 @@ public:
     // constant
     bool fertig() const;
     MiniGameV *zGame() const;
-    // Reference Counting
-    MGLaden *getThis();
-    MGLaden *release();
 };
 
 class MiniGames : public Zeichnung
@@ -64,7 +60,6 @@ private:
     API *api;
     double tickVal;
     int alpha2;
-    int ref;
 
 public:
     // Konstruktor
@@ -77,9 +72,6 @@ public:
     void doTastaturEreignis( TastaturEreignis &te ) override;
     bool tick( double z ) override;
     void render( Bild &zRObj ) override;
-    // Reference Counting
-    MiniGames *getThis();
-    MiniGames *release();
 };
 
 class API : public MinigameAPI

+ 1 - 0
Test/Test.vcxproj

@@ -105,6 +105,7 @@
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
       <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <BasicRuntimeChecks>StackFrameRuntimeCheck</BasicRuntimeChecks>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>

BIN
Test/data/Minigames/DungeonGame/schriften/gravur.ltds


+ 30 - 0
Test/data/Minigames/DungeonGame/views/town.uiml

@@ -0,0 +1,30 @@
+<view>
+  <button id="back" width="150" height="26" align-top="start" align-right="end" margin="5">ZURÜCK</button>
+  <text id="title" width="75%" height="100" font-size="24" text-align="center">TOWN</text>
+  <text id="heroesTitle" align-left="start" align-top="title" margin="5" width="25%" height="26">YOUR HEROES</text>
+  <table id="heroes" align-left="start" align-top="heroesTitle" margin="5" width="25%" height="35%">
+    <tr>
+      <text width="100%">NAME</text>
+    </tr>
+  </table>
+  <text id="ownDungeonsTitle" align-left="start" align-top="heroes" margin-left="5" margin-top="5" width="25%" height="26">YOUR OWN DUNGEONS</text>
+  <table id="ownDungeons" align-left="start" align-top="ownDungeonsTitle" margin="5" width="25%" height="35%">
+    <tr>
+      <text width="100%">NAME</text>
+    </tr>
+  </table>
+  <text id="money" align-left="heroes" align-bottom="inventoryTitle" margin="5" width="25%" height="26"></text>
+  <text id="inventoryTitle" align-left="heroes" align-top="title" margin="5" width="25%" height="26">YOUR INVENTORY</text>
+  <table id="inventory" align-left="heroes" align-top="inventoryTitle" margin="5" width="25%" height="80%">
+    <tr>
+      <text width="100%">NAME</text>
+    </tr>
+  </table>
+  <text id="dungeonsTitle" align-left="inventory" align-top="title" margin="5" width="25%" height="26">ALL DUNGEONS</text>
+  <table id="dungeons" align-left="inventory" align-top="dungeonsTitle" margin="5" width="25%" height="80%">
+    <tr>
+      <text width="50%">NAME</text>
+      <text width="50%">OWNER</text>
+    </tr>
+  </table>
+</view>