Forráskód Böngészése

apply new code formatter

Kolja Strohm 2 éve
szülő
commit
563dae9468
112 módosított fájl, 9398 hozzáadás és 3862 törlés
  1. 9 9
      FactoryCraft/AddEntityUpdate.cpp
  2. 3 3
      FactoryCraft/AddEntityUpdate.h
  3. 152 104
      FactoryCraft/AddServerMenu.cpp
  4. 9 8
      FactoryCraft/AddServerMenu.h
  5. 39 58
      FactoryCraft/Area.cpp
  6. 14 13
      FactoryCraft/Area.h
  7. 181 157
      FactoryCraft/Block.cpp
  8. 34 27
      FactoryCraft/Block.h
  9. 13 12
      FactoryCraft/BlockType.cpp
  10. 10 10
      FactoryCraft/BlockType.h
  11. 260 226
      FactoryCraft/Chunk.cpp
  12. 24 24
      FactoryCraft/Chunk.h
  13. 3 3
      FactoryCraft/Constants.h
  14. 422 394
      FactoryCraft/CraftingGrid.cpp
  15. 44 32
      FactoryCraft/CraftingGrid.h
  16. 22 16
      FactoryCraft/CustomDX11API.cpp
  17. 7 5
      FactoryCraft/CustomDX11API.h
  18. 12 10
      FactoryCraft/Dialog.h
  19. 176 177
      FactoryCraft/Dimension.cpp
  20. 22 22
      FactoryCraft/Dimension.h
  21. 55 52
      FactoryCraft/DragController.h
  22. 2 3
      FactoryCraft/DragElement.h
  23. 508 431
      FactoryCraft/Entity.cpp
  24. 34 29
      FactoryCraft/Entity.h
  25. 5 5
      FactoryCraft/EntityRemovedUpdate.cpp
  26. 3 3
      FactoryCraft/EntityRemovedUpdate.h
  27. 32 30
      FactoryCraft/EntityType.cpp
  28. 6 6
      FactoryCraft/EntityType.h
  29. 19 18
      FactoryCraft/Equipment.cpp
  30. 23 16
      FactoryCraft/Equipment.h
  31. 34 29
      FactoryCraft/FactoryClient.h
  32. 154 147
      FactoryCraft/Game.cpp
  33. 14 14
      FactoryCraft/Game.h
  34. 143 116
      FactoryCraft/Initialisierung.cpp
  35. 24 11
      FactoryCraft/Initialisierung.h
  36. 376 340
      FactoryCraft/InventoryView.cpp
  37. 54 37
      FactoryCraft/InventoryView.h
  38. 144 129
      FactoryCraft/ItemBar.cpp
  39. 30 21
      FactoryCraft/ItemBar.h
  40. 526 516
      FactoryCraft/Load.cpp
  41. 5 4
      FactoryCraft/Load.h
  42. 54 53
      FactoryCraft/Main.cpp
  43. 9 9
      FactoryCraft/Menu.cpp
  44. 6 6
      FactoryCraft/Menu.h
  45. 31 28
      FactoryCraft/ModelInfo.cpp
  46. 7 7
      FactoryCraft/ModelInfo.h
  47. 122 116
      FactoryCraft/PlayerKam.cpp
  48. 12 12
      FactoryCraft/PlayerKam.h
  49. 4 4
      FactoryCraft/Registries.h
  50. 3 3
      FactoryCraft/StaticInitializerOrder.cpp
  51. 50 52
      FactoryCraft/StaticRegistry.h
  52. 16 13
      FactoryCraft/UIMLToolTip.cpp
  53. 251 233
      FactoryCraft/World.cpp
  54. 39 39
      FactoryCraft/World.h
  55. 17 15
      FactoryCraft/WorldUpdate.cpp
  56. 5 5
      FactoryCraft/WorldUpdate.h
  57. 30 0
      enc_temp_folder/107b1a479d1edc90e5af3d148a259357/Equipment.h
  58. 19 0
      enc_temp_folder/1143b7508c7358196f99bc3caaa0fd/ModelInfo.h
  59. 44 0
      enc_temp_folder/1e8437822bd13cd1a5e19507ca641b0/Block.h
  60. 396 0
      enc_temp_folder/21617dc069ecd3eaef31d6ce92fc56e5/InventoryView.cpp
  61. 466 0
      enc_temp_folder/2259c96ab2a3916f359853f36282337/Entity.cpp
  62. 14 0
      enc_temp_folder/2732994fb4435f576fdce2c1194fde8/AddEntityUpdate.h
  63. 31 0
      enc_temp_folder/29ba8b78dd7e83ca667f1499ba935536/Initialisierung.h
  64. 44 0
      enc_temp_folder/2e3f6cd4bfac3bffdfa7e916c1b6a19/EntityType.cpp
  65. 19 0
      enc_temp_folder/2fdfb0b658ed7fdeeb462a6c24ece4/AddServerMenu.h
  66. 37 0
      enc_temp_folder/3112d9feb6108e97e3d1601255838b8e/ItemBar.h
  67. 16 0
      enc_temp_folder/316083384fb252cde515408067a06dd5/Load.h
  68. 252 0
      enc_temp_folder/316650b8b86a35dbcc28e142c50b2ba/Dimension.cpp
  69. 68 0
      enc_temp_folder/33937a68c5128732d77739a9e125756/StaticRegistry.h
  70. 553 0
      enc_temp_folder/3a55cd8d8af5f8ea2a64d516d5bc5692/Load.cpp
  71. 32 0
      enc_temp_folder/3c2afc6a4b27a7caad432882b3711f1c/BlockType.cpp
  72. 11 0
      enc_temp_folder/417d9d558f3e8f5f14c5cf33fb5986a/DragElement.h
  73. 45 0
      enc_temp_folder/451246f3f099a7e663dcea31b22f288/ModelInfo.cpp
  74. 18 0
      enc_temp_folder/45ba55b34681a81f4c8590e163c81db8/CustomDX11API.h
  75. 21 0
      enc_temp_folder/4876b17b4f30766328b89d442a16e79/EntityType.h
  76. 22 0
      enc_temp_folder/4cf3c1a3eadd27e1b61e410a2f7b5b3/Menu.cpp
  77. 18 0
      enc_temp_folder/4d1a72a6f5157678fdc872365e12c1b/AddEntityUpdate.cpp
  78. 165 0
      enc_temp_folder/51501657c4a6cf4d357c29932b1dd6a/Initialisierung.cpp
  79. 277 0
      enc_temp_folder/52dda8697ab91ee9d2c9ac2061cdff7/Chunk.cpp
  80. 27 0
      enc_temp_folder/5795ce2e2f68bd624f1cc69f0f5c8da/BlockType.h
  81. 16 0
      enc_temp_folder/6bb73f40c164ba9b456ed65bee126b99/StaticInitializerOrder.cpp
  82. 62 0
      enc_temp_folder/6c14995eccfa6537b21468f668959267/DragController.h
  83. 14 0
      enc_temp_folder/72156073275f6358c87cd3cf596fcc4/EntityRemovedUpdate.cpp
  84. 46 0
      enc_temp_folder/731a4feda1e46a1d2df75b3f2592ee7/FactoryClient.h
  85. 31 0
      enc_temp_folder/7a1b7c013656d33b6d1375faeb4bd9/Game.h
  86. 338 0
      enc_temp_folder/8274a4e22fc21f2821b38041b42242/World.cpp
  87. 67 0
      enc_temp_folder/8726edde9d5ce1ea4fea362660bb528e/Main.cpp
  88. 154 0
      enc_temp_folder/89933bbcaa9a07595a67688884dbd2/PlayerKam.cpp
  89. 26 0
      enc_temp_folder/934b78f6f6df2e34ddbc8435a7aae/UIMLToolTip.cpp
  90. 33 0
      enc_temp_folder/973c14c36971b73cfeec68881d0683/Area.h
  91. 37 0
      enc_temp_folder/9fe4615ad7bd97e9947e71f0c09e7f2d/Chunk.h
  92. 115 0
      enc_temp_folder/a0fa8bd84ace35bac3eb2735544cd/AddServerMenu.cpp
  93. 209 0
      enc_temp_folder/a36e7559d0941b36cff6d7348813d2d2/Block.cpp
  94. 63 0
      enc_temp_folder/a64d52bdd16464cbf99c34b69d888f2/InventoryView.h
  95. 23 0
      enc_temp_folder/a860cdbf2c962163648b92d4fae0758f/PlayerKam.h
  96. 79 0
      enc_temp_folder/aedf935c6dd4db16dd4e3a49daa122/Area.cpp
  97. 53 0
      enc_temp_folder/b37db95da51546ad7e8cc1c82cf42/Equipment.cpp
  98. 14 0
      enc_temp_folder/b84b4e808b53ee53a977af8adca3bed/EntityRemovedUpdate.h
  99. 174 0
      enc_temp_folder/ba411bc21d64e1d04caa78589c762/Game.cpp
  100. 6 0
      enc_temp_folder/c5f2270d6bed8d7cbc360ea8541de2b/Constants.h
  101. 39 0
      enc_temp_folder/c8104cfdb4649a34402666be87bd5661/Dimension.h
  102. 35 0
      enc_temp_folder/c9cbefe684b7ad84345e9ec04d905b/CustomDX11API.cpp
  103. 19 0
      enc_temp_folder/d2cfdfdd6c2c64205fc6875e214b27b/Menu.h
  104. 19 0
      enc_temp_folder/d46158fac4ce94c9b95a6c8415891c65/WorldUpdate.h
  105. 20 0
      enc_temp_folder/d4e616c36a8b1e2a2abad0acef14d75e/Dialog.h
  106. 49 0
      enc_temp_folder/d96dc9ecf990a09e6658711cb19a4160/CraftingGrid.h
  107. 18 0
      enc_temp_folder/daab62b53a5e77ff5b74c75dfd9d368/Registries.h
  108. 26 0
      enc_temp_folder/db15399a5a58f3136329d834c5e88aa/WorldUpdate.cpp
  109. 447 0
      enc_temp_folder/eadbdf47d7cfcc5ecf485550d574c/CraftingGrid.cpp
  110. 56 0
      enc_temp_folder/eb39f2494bc1df93bab2e22e54d5/World.h
  111. 47 0
      enc_temp_folder/ef2be821964b97a79f24226c6ce03c60/Entity.h
  112. 165 0
      enc_temp_folder/f68e3c78e417e9bed1beacfd7bb406b/ItemBar.cpp

+ 9 - 9
FactoryCraft/AddEntityUpdate.cpp

@@ -1,18 +1,18 @@
 #include "AddEntityUpdate.h"
 #include "AddEntityUpdate.h"
-#include "StaticRegistry.h"
-#include "Registries.h"
-#include "Globals.h"
-#include "Entity.h"
 
 
+#include "Entity.h"
+#include "Globals.h"
+#include "Registries.h"
+#include "StaticRegistry.h"
 
 
 AddEntityUpdateType::AddEntityUpdateType()
 AddEntityUpdateType::AddEntityUpdateType()
-	: WorldUpdateType(ID)
+    : WorldUpdateType(ID)
 {}
 {}
 
 
 void AddEntityUpdateType::applyUpdate(Framework::StreamReader* zReader)
 void AddEntityUpdateType::applyUpdate(Framework::StreamReader* zReader)
 {
 {
-	int type;
-	zReader->lese((char*)&type, 4);
-	Entity* entity = entityTypes[type]->loadEntity(zReader);
-	World::INSTANCE->zDimension()->addEntity(entity);
+    int type;
+    zReader->lese((char*)&type, 4);
+    Entity* entity = entityTypes[type]->loadEntity(zReader);
+    World::INSTANCE->zDimension()->addEntity(entity);
 }
 }

+ 3 - 3
FactoryCraft/AddEntityUpdate.h

@@ -4,11 +4,11 @@
 
 
 class AddEntityUpdateType : public WorldUpdateType
 class AddEntityUpdateType : public WorldUpdateType
 {
 {
-	REGISTRABLE(AddEntityUpdateType)
+    REGISTRABLE(AddEntityUpdateType)
 
 
 protected:
 protected:
-	AddEntityUpdateType();
-	void applyUpdate(Framework::StreamReader* zReader) override;
+    AddEntityUpdateType();
+    void applyUpdate(Framework::StreamReader* zReader) override;
 };
 };
 
 
 REGISTER(AddEntityUpdateType, WorldUpdateType)
 REGISTER(AddEntityUpdateType, WorldUpdateType)

+ 152 - 104
FactoryCraft/AddServerMenu.cpp

@@ -1,115 +1,163 @@
 #include "AddServerMenu.h"
 #include "AddServerMenu.h"
-#include "Initialisierung.h"
+
 #include "Globals.h"
 #include "Globals.h"
+#include "Initialisierung.h"
 #include "ServerSelection.h"
 #include "ServerSelection.h"
 
 
 AddServerMenu::AddServerMenu(Bildschirm* zScreen)
 AddServerMenu::AddServerMenu(Bildschirm* zScreen)
-	: Menu(zScreen)
+    : Menu(zScreen)
 {
 {
-	Punkt center = zScreen->getBackBufferSize() / 2;
-	TextFeld* nameLabel = initTextFeld(center.x - 150, center.y - 50, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Name:");
-	elements.add(nameLabel);
-	name = initTextFeld(nameLabel->getPosition().x + nameLabel->getBreite(), nameLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
-	name->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
-		{
-			if (te.id == TE_Release && te.virtualKey == T_Tab)
-			{
-				name->removeStyle(Zeichnung::Style::Fokus);
-				address->addStyle(Zeichnung::Style::Fokus);
-			}
-			return te.virtualKey != T_Tab;
-		});
-	elements.add(name);
+    Punkt center = zScreen->getBackBufferSize() / 2;
+    TextFeld* nameLabel = initTextFeld(center.x - 150,
+        center.y - 50,
+        100,
+        20,
+        TextFeld::Style::Text | TextFeld::Style::VCenter,
+        "Name:");
+    elements.add(nameLabel);
+    name = initTextFeld(nameLabel->getPosition().x + nameLabel->getBreite(),
+        nameLabel->getPosition().y,
+        200,
+        20,
+        TextFeld::Style::TextFeld,
+        "");
+    name->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te) {
+        if (te.id == TE_Release && te.virtualKey == T_Tab)
+        {
+            name->removeStyle(Zeichnung::Style::Fokus);
+            address->addStyle(Zeichnung::Style::Fokus);
+        }
+        return te.virtualKey != T_Tab;
+    });
+    elements.add(name);
 
 
-	TextFeld* addressLabel = initTextFeld(center.x - 150, center.y - 25, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Server Address:");
-	elements.add(addressLabel);
-	address = initTextFeld(addressLabel->getPosition().x + addressLabel->getBreite(), addressLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
-	address->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
-		{
-			if (te.id == TE_Release && te.virtualKey == T_Tab)
-			{
-				address->removeStyle(Zeichnung::Style::Fokus);
-				sslPort->addStyle(Zeichnung::Style::Fokus);
-			}
-			return te.virtualKey != T_Tab;
-		});
-	elements.add(address);
+    TextFeld* addressLabel = initTextFeld(center.x - 150,
+        center.y - 25,
+        100,
+        20,
+        TextFeld::Style::Text | TextFeld::Style::VCenter,
+        "Server Address:");
+    elements.add(addressLabel);
+    address = initTextFeld(
+        addressLabel->getPosition().x + addressLabel->getBreite(),
+        addressLabel->getPosition().y,
+        200,
+        20,
+        TextFeld::Style::TextFeld,
+        "");
+    address->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te) {
+        if (te.id == TE_Release && te.virtualKey == T_Tab)
+        {
+            address->removeStyle(Zeichnung::Style::Fokus);
+            sslPort->addStyle(Zeichnung::Style::Fokus);
+        }
+        return te.virtualKey != T_Tab;
+    });
+    elements.add(address);
 
 
-	TextFeld* sslPortLabel = initTextFeld(center.x - 150, center.y, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "SSL Server Port:");
-	elements.add(sslPortLabel);
-	sslPort = initTextFeld(sslPortLabel->getPosition().x + sslPortLabel->getBreite(), sslPortLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
-	sslPort->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
-		{
-			if (te.id == TE_Release && te.virtualKey == T_Tab)
-			{
-				sslPort->removeStyle(Zeichnung::Style::Fokus);
-				port->addStyle(Zeichnung::Style::Fokus);
-			}
-			return te.virtualKey != T_Tab && _nurNummernTE(p, o, te);
-		});
-	elements.add(sslPort);
-	TextFeld* portLabel = initTextFeld(center.x - 150, center.y + 25, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Server Port:");
-	elements.add(portLabel);
-	port = initTextFeld(portLabel->getPosition().x + portLabel->getBreite(), portLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
-	port->setTastaturEreignis(_nurNummernTE);
-	elements.add(port);
+    TextFeld* sslPortLabel = initTextFeld(center.x - 150,
+        center.y,
+        100,
+        20,
+        TextFeld::Style::Text | TextFeld::Style::VCenter,
+        "SSL Server Port:");
+    elements.add(sslPortLabel);
+    sslPort = initTextFeld(
+        sslPortLabel->getPosition().x + sslPortLabel->getBreite(),
+        sslPortLabel->getPosition().y,
+        200,
+        20,
+        TextFeld::Style::TextFeld,
+        "");
+    sslPort->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te) {
+        if (te.id == TE_Release && te.virtualKey == T_Tab)
+        {
+            sslPort->removeStyle(Zeichnung::Style::Fokus);
+            port->addStyle(Zeichnung::Style::Fokus);
+        }
+        return te.virtualKey != T_Tab && _nurNummernTE(p, o, te);
+    });
+    elements.add(sslPort);
+    TextFeld* portLabel = initTextFeld(center.x - 150,
+        center.y + 25,
+        100,
+        20,
+        TextFeld::Style::Text | TextFeld::Style::VCenter,
+        "Server Port:");
+    elements.add(portLabel);
+    port = initTextFeld(portLabel->getPosition().x + portLabel->getBreite(),
+        portLabel->getPosition().y,
+        200,
+        20,
+        TextFeld::Style::TextFeld,
+        "");
+    port->setTastaturEreignis(_nurNummernTE);
+    elements.add(port);
 
 
-	add = initKnopf(center.x + 50, center.y + 50, 100, 20, Knopf::Style::Normal, "Add");
-	add->setMausEreignis([this](void* p, void* o, MausEreignis me)
-		{
-			if (me.id == ME_RLinks)
-			{
-				if (name->zText()->getLength() && address->zText()->getLength() && port->zText()->getLength())
-				{
-					if (!((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))->hasServer(name->zText()->getText()))
-					{
-						hide();
-						menuRegister->get("serverSelection")->show();
-						((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))->addServer(name->zText()->getText(), address->zText()->getText(), (unsigned short)(int)*sslPort->zText(), (unsigned short)(int)*port->zText());
-						name->zText()->setText("");
-						address->zText()->setText("");
-						port->zText()->setText("");
-						sslPort->zText()->setText("");
-						name->setAlphaFeldFarbe(0xFF3d3d3d);
-						address->setAlphaFeldFarbe(0xFF3d3d3d);
-						port->setAlphaFeldFarbe(0xFF3d3d3d);
-						sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
-					}
-					else
-						name->setAlphaFeldFarbe(0xFF3d0000);
-				}
-				else
-				{
-					if(!name->zText()->getLength())
-						name->setAlphaFeldFarbe(0xFF3d0000);
-					if (!address->zText()->getLength())
-						address->setAlphaFeldFarbe(0xFF3d0000);
-					if (!port->zText()->getLength())
-						port->setAlphaFeldFarbe(0xFF3d0000);
-					if (!sslPort->zText()->getLength())
-						sslPort->setAlphaFeldFarbe(0xFF3d0000);
-				}
-			}
-			return 1;
-		});
-	elements.add(add);
+    add = initKnopf(
+        center.x + 50, center.y + 50, 100, 20, Knopf::Style::Normal, "Add");
+    add->setMausEreignis([this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            if (name->zText()->getLength() && address->zText()->getLength()
+                && port->zText()->getLength())
+            {
+                if (!((ServerSelectionMenu*)(Menu*)menuRegister->get(
+                          "serverSelection"))
+                         ->hasServer(name->zText()->getText()))
+                {
+                    hide();
+                    menuRegister->get("serverSelection")->show();
+                    ((ServerSelectionMenu*)(Menu*)menuRegister->get(
+                         "serverSelection"))
+                        ->addServer(name->zText()->getText(),
+                            address->zText()->getText(),
+                            (unsigned short)(int)*sslPort->zText(),
+                            (unsigned short)(int)*port->zText());
+                    name->zText()->setText("");
+                    address->zText()->setText("");
+                    port->zText()->setText("");
+                    sslPort->zText()->setText("");
+                    name->setAlphaFeldFarbe(0xFF3d3d3d);
+                    address->setAlphaFeldFarbe(0xFF3d3d3d);
+                    port->setAlphaFeldFarbe(0xFF3d3d3d);
+                    sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
+                }
+                else
+                    name->setAlphaFeldFarbe(0xFF3d0000);
+            }
+            else
+            {
+                if (!name->zText()->getLength())
+                    name->setAlphaFeldFarbe(0xFF3d0000);
+                if (!address->zText()->getLength())
+                    address->setAlphaFeldFarbe(0xFF3d0000);
+                if (!port->zText()->getLength())
+                    port->setAlphaFeldFarbe(0xFF3d0000);
+                if (!sslPort->zText()->getLength())
+                    sslPort->setAlphaFeldFarbe(0xFF3d0000);
+            }
+        }
+        return 1;
+    });
+    elements.add(add);
 
 
-	abort = initKnopf(center.x - 150, center.y + 50, 100, 20, Knopf::Style::Normal, "Abort");
-	abort->setMausEreignis([this](void* p, void* o, MausEreignis me)
-		{
-			if (me.id == ME_RLinks)
-			{
-				hide();
-				menuRegister->get("serverSelection")->show();
-				name->zText()->setText("");
-				address->zText()->setText("");
-				port->zText()->setText("");
-				name->setAlphaFeldFarbe(0xFF3d3d3d);
-				address->setAlphaFeldFarbe(0xFF3d3d3d);
-				port->setAlphaFeldFarbe(0xFF3d3d3d);
-				sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
-			}
-			return 1;
-		});
-	elements.add(abort);
+    abort = initKnopf(
+        center.x - 150, center.y + 50, 100, 20, Knopf::Style::Normal, "Abort");
+    abort->setMausEreignis([this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            hide();
+            menuRegister->get("serverSelection")->show();
+            name->zText()->setText("");
+            address->zText()->setText("");
+            port->zText()->setText("");
+            name->setAlphaFeldFarbe(0xFF3d3d3d);
+            address->setAlphaFeldFarbe(0xFF3d3d3d);
+            port->setAlphaFeldFarbe(0xFF3d3d3d);
+            sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
+        }
+        return 1;
+    });
+    elements.add(abort);
 }
 }

+ 9 - 8
FactoryCraft/AddServerMenu.h

@@ -1,19 +1,20 @@
 #pragma once
 #pragma once
 
 
-#include <TextFeld.h>
 #include <Knopf.h>
 #include <Knopf.h>
+#include <TextFeld.h>
+
 #include "Menu.h"
 #include "Menu.h"
 
 
 class AddServerMenu : public Menu
 class AddServerMenu : public Menu
 {
 {
 private:
 private:
-	Framework::TextFeld* name;
-	Framework::TextFeld* address;
-	Framework::TextFeld* sslPort;
-	Framework::TextFeld* port;
-	Framework::Knopf* add;
-	Framework::Knopf* abort;
+    Framework::TextFeld* name;
+    Framework::TextFeld* address;
+    Framework::TextFeld* sslPort;
+    Framework::TextFeld* port;
+    Framework::Knopf* add;
+    Framework::Knopf* abort;
 
 
 public:
 public:
-	AddServerMenu(Framework::Bildschirm* zScreen);
+    AddServerMenu(Framework::Bildschirm* zScreen);
 };
 };

+ 39 - 58
FactoryCraft/Area.cpp

@@ -1,79 +1,60 @@
 #include "Area.h"
 #include "Area.h"
 
 
-
 Framework::Vec3<int> getDirection(Directions dir)
 Framework::Vec3<int> getDirection(Directions dir)
 {
 {
-	Framework::Vec3<int> result(0, 0, 0);
-	if ((dir | NORTH) == dir)
-		--result.y;
-	if ((dir | EAST) == dir)
-		++result.x;
-	if ((dir | SOUTH) == dir)
-		++result.y;
-	if ((dir | WEST) == dir)
-		--result.x;
-	if ((dir | TOP) == dir)
-		++result.z;
-	if ((dir | BOTTOM) == dir)
-		--result.z;
-	return result;
+    Framework::Vec3<int> result(0, 0, 0);
+    if ((dir | NORTH) == dir) --result.y;
+    if ((dir | EAST) == dir) ++result.x;
+    if ((dir | SOUTH) == dir) ++result.y;
+    if ((dir | WEST) == dir) --result.x;
+    if ((dir | TOP) == dir) ++result.z;
+    if ((dir | BOTTOM) == dir) --result.z;
+    return result;
 }
 }
 
 
 int getDirectionIndex(Direction dir)
 int getDirectionIndex(Direction dir)
 {
 {
-	if (dir == NORTH)
-		return 0;
-	if (dir == EAST)
-		return 1;
-	if (dir == SOUTH)
-		return 2;
-	if (dir == WEST)
-		return 3;
-	if (dir == TOP)
-		return 4;
-	if (dir == BOTTOM)
-		return 5;
-	assert(false);
-	return -1;
+    if (dir == NORTH) return 0;
+    if (dir == EAST) return 1;
+    if (dir == SOUTH) return 2;
+    if (dir == WEST) return 3;
+    if (dir == TOP) return 4;
+    if (dir == BOTTOM) return 5;
+    assert(false);
+    return -1;
 }
 }
 
 
 Direction getOppositeDirection(Direction dir)
 Direction getOppositeDirection(Direction dir)
 {
 {
-	if (dir == NORTH)
-		return SOUTH;
-	if (dir == EAST)
-		return WEST;
-	if (dir == SOUTH)
-		return NORTH;
-	if (dir == WEST)
-		return EAST;
-	if (dir == TOP)
-		return BOTTOM;
-	if (dir == BOTTOM)
-		return TOP;
-	assert(false);
-	return NO_DIRECTION;
+    if (dir == NORTH) return SOUTH;
+    if (dir == EAST) return WEST;
+    if (dir == SOUTH) return NORTH;
+    if (dir == WEST) return EAST;
+    if (dir == TOP) return BOTTOM;
+    if (dir == BOTTOM) return TOP;
+    assert(false);
+    return NO_DIRECTION;
 }
 }
 
 
 Direction getDirectionFromIndex(int index)
 Direction getDirectionFromIndex(int index)
 {
 {
-	return (Direction)(1 << index);
+    return (Direction)(1 << index);
 }
 }
 
 
 Directions getDirectionsFromVector(Framework::Vec3<float> dir)
 Directions getDirectionsFromVector(Framework::Vec3<float> dir)
 {
 {
-	Directions dirs = NO_DIRECTION;
-	if (dir.y < 0)
-		dirs |= NORTH;
-	else if (dir.y > 0)
-		dirs |= SOUTH;
-	if (dir.x < 0)
-		dirs |= WEST;
-	else if (dir.x > 0)
-		dirs |= EAST;
-	if (dir.z < 0)
-		dirs |= BOTTOM;
-	else if (dir.z > 0)
-		dirs |= TOP;
-	return dirs;
+    Directions dirs = NO_DIRECTION;
+    if (dir.y < 0)
+        dirs |= NORTH;
+    else if (dir.y > 0)
+        dirs |= SOUTH;
+    if (dir.x < 0)
+        dirs |= WEST;
+    else if (dir.x > 0)
+        dirs |= EAST;
+    if (dir.z < 0)
+        dirs |= BOTTOM;
+    else if (dir.z > 0)
+        dirs |= TOP;
+    return dirs;
 }
 }

+ 14 - 13
FactoryCraft/Area.h

@@ -4,24 +4,25 @@
 
 
 struct Area
 struct Area
 {
 {
-	int startX;
-	int startY;
-	int endX;
-	int endY;
-	int dimensionId;
+    int startX;
+    int startY;
+    int endX;
+    int endY;
+    int dimensionId;
 };
 };
 
 
 enum Direction
 enum Direction
 {
 {
-	NO_DIRECTION = 0,
-	NORTH = 1,
-	EAST = 2,
-	SOUTH = 4,
-	WEST = 8,
-	TOP = 16,
-	BOTTOM = 32,
-	INSIDE = 64
+    NO_DIRECTION = 0,
+    NORTH = 1,
+    EAST = 2,
+    SOUTH = 4,
+    WEST = 8,
+    TOP = 16,
+    BOTTOM = 32,
+    INSIDE = 64
 };
 };
+
 typedef int Directions;
 typedef int Directions;
 
 
 #define ANY_DIRECTION NORTH | EAST | SOUTH | WEST | TOP | BOTTOM
 #define ANY_DIRECTION NORTH | EAST | SOUTH | WEST | TOP | BOTTOM

+ 181 - 157
FactoryCraft/Block.cpp

@@ -1,209 +1,233 @@
-#include <Textur.h>
+#include "Block.h"
+
 #include <Shader.h>
 #include <Shader.h>
+#include <Textur.h>
 
 
-#include "Block.h"
-#include "Globals.h"
 #include "CustomDX11API.h"
 #include "CustomDX11API.h"
+#include "Globals.h"
 
 
-
-Block::Block(const BlockType* zType, Framework::Vec3<int> pos, Model3DData* model, Model3DTextur* texture, int maxHP)
-	: Model3D(),
-	zType(zType),
-	location(pos),
-	maxHP((float)maxHP)
+Block::Block(const BlockType* zType,
+    Framework::Vec3<int> pos,
+    Model3DData* model,
+    Model3DTextur* texture,
+    int maxHP)
+    : Model3D(),
+      zType(zType),
+      location(pos),
+      maxHP((float)maxHP)
 {
 {
-	transparent = 0;
-	hp = (float)maxHP;
-	memset(sideVisible, 0, 6);
-	Model3D::setPosition((Framework::Vec3<float>)pos + Framework::Vec3<float>{0.5f, 0.5f, 0.5f});
-	setModelDaten(model);
-	setModelTextur(texture);
-	breakTextur = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur("blocks.ltdb/crack.png", 0);
-	memset(lightData, 0, 6 * 6);
+    transparent = 0;
+    hp = (float)maxHP;
+    memset(sideVisible, 0, 6);
+    Model3D::setPosition(
+        (Framework::Vec3<float>)pos + Framework::Vec3<float>{0.5f, 0.5f, 0.5f});
+    setModelDaten(model);
+    setModelTextur(texture);
+    breakTextur
+        = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur(
+            "blocks.ltdb/crack.png", 0);
+    memset(lightData, 0, 6 * 6);
 }
 }
 
 
 Block::~Block()
 Block::~Block()
 {
 {
-	breakTextur->release();
+    breakTextur->release();
 }
 }
 
 
-void Block::beforeRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
+void Block::beforeRender(
+    GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
 {
 {
-	CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
-	if (cApi && model->getVertexAnzahl() == 24)
-	{
-		int count = 24;
-		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
-		zVertexShader->füllConstBuffer(lightBuffer, cApi->getVertexShaderLightBufferIndex() + 1, 24 * 4);
-	}
-	else
-	{
-		int count = 0;
-		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
-	}
+    CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
+    if (cApi && model->getVertexAnzahl() == 24)
+    {
+        int count = 24;
+        zVertexShader->füllConstBuffer(
+            (char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+        zVertexShader->füllConstBuffer(
+            lightBuffer, cApi->getVertexShaderLightBufferIndex() + 1, 24 * 4);
+    }
+    else
+    {
+        int count = 0;
+        zVertexShader->füllConstBuffer(
+            (char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+    }
 }
 }
 
 
-void Block::afterRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
+void Block::afterRender(
+    GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
 {
 {
-	CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
-	if (cApi && model->getVertexAnzahl() == 24)
-	{
-		int count = 0;
-		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
-	}
+    CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
+    if (cApi && model->getVertexAnzahl() == 24)
+    {
+        int count = 0;
+        zVertexShader->füllConstBuffer(
+            (char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+    }
 }
 }
 
 
 void Block::api(char* message)
 void Block::api(char* message)
 {
 {
-	// TODO: implement api
-	switch (message[0])
-	{
-	case 0: // hp change
-		hp = *(float*)(message + 1);
-		break;
-	}
+    // TODO: implement api
+    switch (message[0])
+    {
+    case 0: // hp change
+        hp = *(float*)(message + 1);
+        break;
+    }
 }
 }
 
 
 bool Block::isTransparent() const
 bool Block::isTransparent() const
 {
 {
-	return transparent;
+    return transparent;
 }
 }
 
 
 void Block::setLightData(Direction dir, unsigned char* data)
 void Block::setLightData(Direction dir, unsigned char* data)
 {
 {
-	memcpy(lightData + getDirectionIndex(dir) * 6, data, 6);
-	if (model->getVertexAnzahl() == 24)
-	{
-		float dayLightFactor = 1.0; // TODO: day (1.f) - night (0.1f) adjustment
-		const Vertex3D* verticies = model->zVertexBuffer();
-		for (int i = 0; i < 24; i++)
-		{ // TODO: calculate rotations
-			Directions dirs = getDirectionsFromVector(verticies[i].pos);
-			Vec3<unsigned char> light(0, 0, 0);
-			for (int d = 0; d < 6; d++)
-			{
-				if ((dirs | getDirectionFromIndex(d)) == dirs)
-				{
-					light = Vec3<unsigned char>(max((unsigned char)((float)lightData[d * 6] * dayLightFactor), light.x), max((unsigned char)((float)lightData[d * 6 + 1] * dayLightFactor), light.y), max((unsigned char)((float)lightData[d * 6 + 2] * dayLightFactor), light.z));
-					light = Vec3<float>(max(lightData[d * 6 + 3], light.x), max(lightData[d * 6 + 4], light.y), max(lightData[d * 6 + 5], light.z));
-				}
-			}
-			int l = ((((light.x << 8) | light.y) << 8) | light.z) << 8;
-			*(int*)(lightBuffer + i * 4) = l;
-		}
-	}
-	if (data[0] | data[1] | data[2] | data[3] | data[4] | data[5])
-		sideVisible[getDirectionIndex(dir)] = 1;
-	else
-		sideVisible[getDirectionIndex(dir)] = 0;
+    memcpy(lightData + getDirectionIndex(dir) * 6, data, 6);
+    if (model->getVertexAnzahl() == 24)
+    {
+        float dayLightFactor = 1.0; // TODO: day (1.f) - night (0.1f) adjustment
+        const Vertex3D* verticies = model->zVertexBuffer();
+        for (int i = 0; i < 24; i++)
+        { // TODO: calculate rotations
+            Directions dirs = getDirectionsFromVector(verticies[i].pos);
+            Vec3<unsigned char> light(0, 0, 0);
+            for (int d = 0; d < 6; d++)
+            {
+                if ((dirs | getDirectionFromIndex(d)) == dirs)
+                {
+                    light = Vec3<unsigned char>(
+                        max((unsigned char)((float)lightData[d * 6]
+                                            * dayLightFactor),
+                            light.x),
+                        max((unsigned char)((float)lightData[d * 6 + 1]
+                                            * dayLightFactor),
+                            light.y),
+                        max((unsigned char)((float)lightData[d * 6 + 2]
+                                            * dayLightFactor),
+                            light.z));
+                    light = Vec3<float>(max(lightData[d * 6 + 3], light.x),
+                        max(lightData[d * 6 + 4], light.y),
+                        max(lightData[d * 6 + 5], light.z));
+                }
+            }
+            int l = ((((light.x << 8) | light.y) << 8) | light.z) << 8;
+            *(int*)(lightBuffer + i * 4) = l;
+        }
+    }
+    if (data[0] | data[1] | data[2] | data[3] | data[4] | data[5])
+        sideVisible[getDirectionIndex(dir)] = 1;
+    else
+        sideVisible[getDirectionIndex(dir)] = 0;
 }
 }
 
 
 bool Block::isVisible() const
 bool Block::isVisible() const
 {
 {
-	return sideVisible[0] || sideVisible[1] || sideVisible[2] || sideVisible[3] || sideVisible[4] || sideVisible[5];
+    return sideVisible[0] || sideVisible[1] || sideVisible[2] || sideVisible[3]
+        || sideVisible[4] || sideVisible[5];
 }
 }
 
 
 Vec3<int> Block::getLocation() const
 Vec3<int> Block::getLocation() const
 {
 {
-	return location;
+    return location;
 }
 }
 
 
 const BlockType* Block::zBlockType() const
 const BlockType* Block::zBlockType() const
 {
 {
-	return zType;
+    return zType;
 }
 }
 
 
 Textur* Block::zEffectTextur()
 Textur* Block::zEffectTextur()
 {
 {
-	if (hp < maxHP)
-		return breakTextur;
-	return 0;
+    if (hp < maxHP) return breakTextur;
+    return 0;
 }
 }
 
 
 float Block::getEffectPercentage()
 float Block::getEffectPercentage()
 {
 {
-	return 1 - hp / maxHP;
+    return 1 - hp / maxHP;
 }
 }
 
 
 Text Block::printLightInfo()
 Text Block::printLightInfo()
 {
 {
-	Text result = "NORTH[0;-1;0](";
-	result += (int)lightData[0];
-	result += ",";
-	result += (int)lightData[1];
-	result += ",";
-	result += (int)lightData[2];
-	result += ";";
-	result += (int)lightData[3];
-	result += ",";
-	result += (int)lightData[4];
-	result += ",";
-	result += (int)lightData[5];
-	result += ")\n";
-	result += "EAST[1;0;0](";
-	result += (int)lightData[6];
-	result += ",";
-	result += (int)lightData[7];
-	result += ",";
-	result += (int)lightData[8];
-	result += ";";
-	result += (int)lightData[9];
-	result += ",";
-	result += (int)lightData[10];
-	result += ",";
-	result += (int)lightData[11];
-	result += ")\n";
-	result += "SOUTH[0;1;0](";
-	result += (int)lightData[12];
-	result += ",";
-	result += (int)lightData[13];
-	result += ",";
-	result += (int)lightData[14];
-	result += ";";
-	result += (int)lightData[15];
-	result += ",";
-	result += (int)lightData[16];
-	result += ",";
-	result += (int)lightData[17];
-	result += ")\n";
-	result += "WEST[-1;0;0](";
-	result += (int)lightData[18];
-	result += ",";
-	result += (int)lightData[19];
-	result += ",";
-	result += (int)lightData[20];
-	result += ";";
-	result += (int)lightData[21];
-	result += ",";
-	result += (int)lightData[22];
-	result += ",";
-	result += (int)lightData[23];
-	result += ")\n";
-	result += "TOP[0;0;1](";
-	result += (int)lightData[24];
-	result += ",";
-	result += (int)lightData[25];
-	result += ",";
-	result += (int)lightData[26];
-	result += ";";
-	result += (int)lightData[27];
-	result += ",";
-	result += (int)lightData[28];
-	result += ",";
-	result += (int)lightData[29];
-	result += ")\n";
-	result += "BOTTOM[0;0;-1](";
-	result += (int)lightData[30];
-	result += ",";
-	result += (int)lightData[31];
-	result += ",";
-	result += (int)lightData[32];
-	result += ";";
-	result += (int)lightData[33];
-	result += ",";
-	result += (int)lightData[34];
-	result += ",";
-	result += (int)lightData[35];
-	result += ")\n";
-	return result;
+    Text result = "NORTH[0;-1;0](";
+    result += (int)lightData[0];
+    result += ",";
+    result += (int)lightData[1];
+    result += ",";
+    result += (int)lightData[2];
+    result += ";";
+    result += (int)lightData[3];
+    result += ",";
+    result += (int)lightData[4];
+    result += ",";
+    result += (int)lightData[5];
+    result += ")\n";
+    result += "EAST[1;0;0](";
+    result += (int)lightData[6];
+    result += ",";
+    result += (int)lightData[7];
+    result += ",";
+    result += (int)lightData[8];
+    result += ";";
+    result += (int)lightData[9];
+    result += ",";
+    result += (int)lightData[10];
+    result += ",";
+    result += (int)lightData[11];
+    result += ")\n";
+    result += "SOUTH[0;1;0](";
+    result += (int)lightData[12];
+    result += ",";
+    result += (int)lightData[13];
+    result += ",";
+    result += (int)lightData[14];
+    result += ";";
+    result += (int)lightData[15];
+    result += ",";
+    result += (int)lightData[16];
+    result += ",";
+    result += (int)lightData[17];
+    result += ")\n";
+    result += "WEST[-1;0;0](";
+    result += (int)lightData[18];
+    result += ",";
+    result += (int)lightData[19];
+    result += ",";
+    result += (int)lightData[20];
+    result += ";";
+    result += (int)lightData[21];
+    result += ",";
+    result += (int)lightData[22];
+    result += ",";
+    result += (int)lightData[23];
+    result += ")\n";
+    result += "TOP[0;0;1](";
+    result += (int)lightData[24];
+    result += ",";
+    result += (int)lightData[25];
+    result += ",";
+    result += (int)lightData[26];
+    result += ";";
+    result += (int)lightData[27];
+    result += ",";
+    result += (int)lightData[28];
+    result += ",";
+    result += (int)lightData[29];
+    result += ")\n";
+    result += "BOTTOM[0;0;-1](";
+    result += (int)lightData[30];
+    result += ",";
+    result += (int)lightData[31];
+    result += ",";
+    result += (int)lightData[32];
+    result += ";";
+    result += (int)lightData[33];
+    result += ",";
+    result += (int)lightData[34];
+    result += ",";
+    result += (int)lightData[35];
+    result += ")\n";
+    return result;
 }
 }

+ 34 - 27
FactoryCraft/Block.h

@@ -2,9 +2,9 @@
 
 
 #include <Model3D.h>
 #include <Model3D.h>
 
 
+#include "Area.h"
 #include "BlockType.h"
 #include "BlockType.h"
 #include "Registries.h"
 #include "Registries.h"
-#include "Area.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
@@ -14,31 +14,38 @@ class Chunk;
 class Block : public Model3D
 class Block : public Model3D
 {
 {
 protected:
 protected:
-	bool transparent;
-	float hp;
-	float maxHP;
-	const BlockType* zType;
-	bool sideVisible[6];
-	Vec3<int> location;
-	Framework::Textur* breakTextur;
-	unsigned char lightData[6 * 6];
-	char lightBuffer[24 * 4];
-
-	void beforeRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
-	void afterRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
+    bool transparent;
+    float hp;
+    float maxHP;
+    const BlockType* zType;
+    bool sideVisible[6];
+    Vec3<int> location;
+    Framework::Textur* breakTextur;
+    unsigned char lightData[6 * 6];
+    char lightBuffer[24 * 4];
+
+    void beforeRender(
+        GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
+    void afterRender(
+        GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
+
 public:
 public:
-	Block(const BlockType* zType, Vec3<int> position, Model3DData* model, Model3DTextur* texture, int maxHp);
-	virtual ~Block();
-
-	void api(char* message);
-	bool isTransparent() const;
-	void setLightData(Direction dir, unsigned char* data);
-	bool isVisible() const;
-
-	Vec3<int> getLocation() const;
-	const BlockType* zBlockType() const;
-	Textur* zEffectTextur() override;
-	float getEffectPercentage() override;
-	friend Chunk;
-	Text printLightInfo();
+    Block(const BlockType* zType,
+        Vec3<int> position,
+        Model3DData* model,
+        Model3DTextur* texture,
+        int maxHp);
+    virtual ~Block();
+
+    void api(char* message);
+    bool isTransparent() const;
+    void setLightData(Direction dir, unsigned char* data);
+    bool isVisible() const;
+
+    Vec3<int> getLocation() const;
+    const BlockType* zBlockType() const;
+    Textur* zEffectTextur() override;
+    float getEffectPercentage() override;
+    friend Chunk;
+    Text printLightInfo();
 };
 };

+ 13 - 12
FactoryCraft/BlockType.cpp

@@ -1,32 +1,33 @@
 #include "BlockType.h"
 #include "BlockType.h"
-#include "Block.h"
 
 
+#include "Block.h"
 #include "Registries.h"
 #include "Registries.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
-BlockType::BlockType(int id, bool needsInstance, ModelInfo model, int initialMaxHP)
-	: ReferenceCounter(),
-	id(id),
-	needsInstance(needsInstance),
-	model(model),
-	initialMaxHP(initialMaxHP)
+BlockType::BlockType(
+    int id, bool needsInstance, ModelInfo model, int initialMaxHP)
+    : ReferenceCounter(),
+      id(id),
+      needsInstance(needsInstance),
+      model(model),
+      initialMaxHP(initialMaxHP)
 {}
 {}
 
 
-BlockType::~BlockType()
-{}
+BlockType::~BlockType() {}
 
 
 Block* BlockType::createBlock(Framework::Vec3<int> position)
 Block* BlockType::createBlock(Framework::Vec3<int> position)
 {
 {
-	return new Block(this, position, model.getModel(), model.getTexture(), initialMaxHP);
+    return new Block(
+        this, position, model.getModel(), model.getTexture(), initialMaxHP);
 }
 }
 
 
 int BlockType::getId() const
 int BlockType::getId() const
 {
 {
-	return id;
+    return id;
 }
 }
 
 
 bool BlockType::doesNeedInstance() const
 bool BlockType::doesNeedInstance() const
 {
 {
-	return needsInstance;
+    return needsInstance;
 }
 }

+ 10 - 10
FactoryCraft/BlockType.h

@@ -4,24 +4,24 @@
 #include <ReferenceCounter.h>
 #include <ReferenceCounter.h>
 #include <Vec3.h>
 #include <Vec3.h>
 
 
-#include "StaticRegistry.h"
 #include "ModelInfo.h"
 #include "ModelInfo.h"
+#include "StaticRegistry.h"
 
 
 class Block;
 class Block;
 
 
 class BlockType : public virtual Framework::ReferenceCounter
 class BlockType : public virtual Framework::ReferenceCounter
 {
 {
 private:
 private:
-	const int id;
-	bool needsInstance;
-	int initialMaxHP;
-	ModelInfo model;
+    const int id;
+    bool needsInstance;
+    int initialMaxHP;
+    ModelInfo model;
 
 
 public:
 public:
-	BlockType(int id, bool needsInstance, ModelInfo model, int initialMaxHP);
-	~BlockType();
-	Block* createBlock(Framework::Vec3<int> position);
-	bool doesNeedInstance() const;
+    BlockType(int id, bool needsInstance, ModelInfo model, int initialMaxHP);
+    ~BlockType();
+    Block* createBlock(Framework::Vec3<int> position);
+    bool doesNeedInstance() const;
 
 
-	int getId() const;
+    int getId() const;
 };
 };

+ 260 - 226
FactoryCraft/Chunk.cpp

@@ -1,277 +1,311 @@
 #include "Chunk.h"
 #include "Chunk.h"
+
 #include "Constants.h"
 #include "Constants.h"
 #include "Globals.h"
 #include "Globals.h"
-
 #include "Registries.h"
 #include "Registries.h"
 
 
-
 Chunk::Chunk(Framework::Punkt location)
 Chunk::Chunk(Framework::Punkt location)
-	: ReferenceCounter(),
-	location(location),
-	isLoading(0)
+    : ReferenceCounter(),
+      location(location),
+      isLoading(0)
 {}
 {}
 
 
 Chunk::Chunk(Framework::Punkt location, Framework::StreamReader* zReader)
 Chunk::Chunk(Framework::Punkt location, Framework::StreamReader* zReader)
-	: Chunk(location)
+    : Chunk(location)
 {
 {
-	load(zReader);
+    load(zReader);
 }
 }
 
 
 Chunk::~Chunk()
 Chunk::~Chunk()
 {
 {
-	char msg = 1; // remove observer
-	World::INSTANCE->zClient()->chunkAPIRequest(location, &msg, 1);
+    char msg = 1; // remove observer
+    World::INSTANCE->zClient()->chunkAPIRequest(location, &msg, 1);
 }
 }
 
 
 void Chunk::api(char* message)
 void Chunk::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 0: // set block
-	{
-		int index = *(int*)(message + 1);
-		int id = *(int*)(message + 5);
-		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
-		location.x += this->location.x - CHUNK_SIZE / 2;
-		location.y += this->location.y - CHUNK_SIZE / 2;
-		if (blockTypes[id]->doesNeedInstance())
-		{
-			Block* zB = blockTypes[id]->createBlock(location);
-			setBlock(zB);
-		}
-		else
-		{
-			Block* zB = zBlockAt(location);
-			if (zB)
-				removeBlock(zB);
-		}
-		break;
-	}
-	case 1: // update light
-	{
-		int index = *(int*)(message + 1);
-		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
-		for (int i = 0; i < 6; i++)
-		{
-			Framework::Vec3<int> pos = location + getDirection(getDirectionFromIndex(i));
-			if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
-			{
-				if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0 && pos.y < CHUNK_SIZE)
-				{
-					pos.x += this->location.x - CHUNK_SIZE / 2;
-					pos.y += this->location.y - CHUNK_SIZE / 2;
-					Block* zB = zBlockAt(pos);
-					if (zB)
-					{
-						bool visible = zB->isVisible();
-						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)(message + 5));
-						if (zB->isVisible() != visible)
-						{
-							vcs.lock();
-							if (zB->isVisible())
-								visibleBlocks.add(zB);
-							else
-							{
-								for (Framework::Iterator<Block*> iterator = visibleBlocks.begin(); iterator; iterator++)
-								{
-									if (zB == (Block*)iterator)
-									{
-										iterator.remove();
-										break;
-									}
-								}
-							}
-							vcs.unlock();
-						}
-					}
-				}
-				else
-				{
-					pos.x += this->location.x - CHUNK_SIZE / 2;
-					pos.y += this->location.y - CHUNK_SIZE / 2;
-					Block* zB = World::INSTANCE->zBlockAt(pos);
-					if (zB)
-					{
-						bool visible = zB->isVisible();
-						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)(message + 5));
-						if (zB->isVisible() != visible)
-						{
-							Chunk* c = World::INSTANCE->zChunk(World::INSTANCE->getChunkCenter(pos.x, pos.y));
-							c->vcs.lock();
-							if (zB->isVisible())
-								c->visibleBlocks.add(zB);
-							else
-							{
-								for (Framework::Iterator<Block*> iterator = c->visibleBlocks.begin(); iterator; iterator++)
-								{
-									if (zB == (Block*)iterator)
-									{
-										iterator.remove();
-										break;
-									}
-								}
-							}
-							c->vcs.unlock();
-						}
-					}
-				}
-			}
-		}
-	}
-	}
+    switch (message[0])
+    {
+    case 0: // set block
+        {
+            int index = *(int*)(message + 1);
+            int id = *(int*)(message + 5);
+            Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
+                (index / WORLD_HEIGHT) % CHUNK_SIZE,
+                index % WORLD_HEIGHT);
+            location.x += this->location.x - CHUNK_SIZE / 2;
+            location.y += this->location.y - CHUNK_SIZE / 2;
+            if (blockTypes[id]->doesNeedInstance())
+            {
+                Block* zB = blockTypes[id]->createBlock(location);
+                setBlock(zB);
+            }
+            else
+            {
+                Block* zB = zBlockAt(location);
+                if (zB) removeBlock(zB);
+            }
+            break;
+        }
+    case 1: // update light
+        {
+            int index = *(int*)(message + 1);
+            Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
+                (index / WORLD_HEIGHT) % CHUNK_SIZE,
+                index % WORLD_HEIGHT);
+            for (int i = 0; i < 6; i++)
+            {
+                Framework::Vec3<int> pos
+                    = location + getDirection(getDirectionFromIndex(i));
+                if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
+                {
+                    if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0
+                        && pos.y < CHUNK_SIZE)
+                    {
+                        pos.x += this->location.x - CHUNK_SIZE / 2;
+                        pos.y += this->location.y - CHUNK_SIZE / 2;
+                        Block* zB = zBlockAt(pos);
+                        if (zB)
+                        {
+                            bool visible = zB->isVisible();
+                            zB->setLightData(
+                                getOppositeDirection(getDirectionFromIndex(i)),
+                                (unsigned char*)(message + 5));
+                            if (zB->isVisible() != visible)
+                            {
+                                vcs.lock();
+                                if (zB->isVisible())
+                                    visibleBlocks.add(zB);
+                                else
+                                {
+                                    for (Framework::Iterator<Block*> iterator
+                                         = visibleBlocks.begin();
+                                         iterator;
+                                         iterator++)
+                                    {
+                                        if (zB == (Block*)iterator)
+                                        {
+                                            iterator.remove();
+                                            break;
+                                        }
+                                    }
+                                }
+                                vcs.unlock();
+                            }
+                        }
+                    }
+                    else
+                    {
+                        pos.x += this->location.x - CHUNK_SIZE / 2;
+                        pos.y += this->location.y - CHUNK_SIZE / 2;
+                        Block* zB = World::INSTANCE->zBlockAt(pos);
+                        if (zB)
+                        {
+                            bool visible = zB->isVisible();
+                            zB->setLightData(
+                                getOppositeDirection(getDirectionFromIndex(i)),
+                                (unsigned char*)(message + 5));
+                            if (zB->isVisible() != visible)
+                            {
+                                Chunk* c = World::INSTANCE->zChunk(
+                                    World::INSTANCE->getChunkCenter(
+                                        pos.x, pos.y));
+                                c->vcs.lock();
+                                if (zB->isVisible())
+                                    c->visibleBlocks.add(zB);
+                                else
+                                {
+                                    for (Framework::Iterator<Block*> iterator
+                                         = c->visibleBlocks.begin();
+                                         iterator;
+                                         iterator++)
+                                    {
+                                        if (zB == (Block*)iterator)
+                                        {
+                                            iterator.remove();
+                                            break;
+                                        }
+                                    }
+                                }
+                                c->vcs.unlock();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
 }
 }
 
 
 Block* Chunk::zBlockAt(Framework::Vec3<int> location)
 Block* Chunk::zBlockAt(Framework::Vec3<int> location)
 {
 {
-	cs.lock();
-	for (Block* b : blocks)
-	{
-		if (b->getLocation() == location)
-		{
-			cs.unlock();
-			return b;
-		}
-	}
-	cs.unlock();
-	return 0;
+    cs.lock();
+    for (Block* b : blocks)
+    {
+        if (b->getLocation() == location)
+        {
+            cs.unlock();
+            return b;
+        }
+    }
+    cs.unlock();
+    return 0;
 }
 }
 
 
 void Chunk::setBlock(Block* block)
 void Chunk::setBlock(Block* block)
 {
 {
-	cs.lock();
-	Framework::Vec3<int> pos = block->getLocation();
-	for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator; iterator++)
-	{
-		if (pos == iterator->getLocation())
-		{
-			vcs.lock();
-			for (Framework::Iterator<Block*> vi = visibleBlocks.begin(); vi; vi++)
-			{
-				if ((Block*)iterator == (Block*)vi)
-				{
-					iterator.remove();
-					break;
-				}
-			}
-			vcs.unlock();
-			iterator->release();
-			iterator.set(block);
-			break;
-		}
-	}
-	blocks.add(block);
-	cs.unlock();
+    cs.lock();
+    Framework::Vec3<int> pos = block->getLocation();
+    for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator;
+         iterator++)
+    {
+        if (pos == iterator->getLocation())
+        {
+            vcs.lock();
+            for (Framework::Iterator<Block*> vi = visibleBlocks.begin(); vi;
+                 vi++)
+            {
+                if ((Block*)iterator == (Block*)vi)
+                {
+                    iterator.remove();
+                    break;
+                }
+            }
+            vcs.unlock();
+            iterator->release();
+            iterator.set(block);
+            break;
+        }
+    }
+    blocks.add(block);
+    cs.unlock();
 }
 }
 
 
 void Chunk::removeBlock(Block* zBlock)
 void Chunk::removeBlock(Block* zBlock)
 {
 {
-	cs.lock();
-	vcs.lock();
-	for (Framework::Iterator<Block*> iterator = visibleBlocks.begin(); iterator; iterator++)
-	{
-		if (zBlock == (Block*)iterator)
-		{
-			iterator.remove();
-			break;
-		}
-	}
-	vcs.unlock();
-	for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator; iterator++)
-	{
-		if (zBlock == (Block*)iterator)
-		{
-			iterator.remove();
-			break;
-		}
-	}
-	cs.unlock();
+    cs.lock();
+    vcs.lock();
+    for (Framework::Iterator<Block*> iterator = visibleBlocks.begin(); iterator;
+         iterator++)
+    {
+        if (zBlock == (Block*)iterator)
+        {
+            iterator.remove();
+            break;
+        }
+    }
+    vcs.unlock();
+    for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator;
+         iterator++)
+    {
+        if (zBlock == (Block*)iterator)
+        {
+            iterator.remove();
+            break;
+        }
+    }
+    cs.unlock();
 }
 }
 
 
 void Chunk::load(Framework::StreamReader* zReader)
 void Chunk::load(Framework::StreamReader* zReader)
 {
 {
-	isLoading = 1;
-	Framework::Vec3<int> pos = { 0, 0, 0 };
-	unsigned short id;
-	zReader->lese((char*)&id, 2);
-	while (id)
-	{
-		int index;
-		zReader->lese((char*)&index, 4);
-		pos = Vec3<int>((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
-		if (blockTypes[id]->doesNeedInstance())
-			setBlock(blockTypes[id]->createBlock({ pos.x + location.x - CHUNK_SIZE / 2, pos.y + location.y - CHUNK_SIZE / 2, pos.z }));
-		zReader->lese((char*)&id, 2);
-	}
-	int index = 0;
-	// light
-	zReader->lese((char*)&index, 4);
-	char lightData[6];
-	while (index >= 0)
-	{
-		zReader->lese(lightData, 6);
-		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
-		for (int i = 0; i < 6; i++)
-		{
-			Framework::Vec3<int> pos = location + getDirection(getDirectionFromIndex(i));
-			if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
-			{
-				if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0 && pos.y < CHUNK_SIZE)
-				{
-					pos.x += this->location.x - CHUNK_SIZE / 2;
-					pos.y += this->location.y - CHUNK_SIZE / 2;
-					Block* zB = zBlockAt(pos);
-					if (zB)
-					{
-						bool visible = zB->isVisible();
-						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)lightData);
-						if (zB->isVisible() && !visible)
-							visibleBlocks.add(zB);
-					}
-				}
-				else
-				{
-					pos.x += this->location.x - CHUNK_SIZE / 2;
-					pos.y += this->location.y - CHUNK_SIZE / 2;
-					Block* zB = World::INSTANCE->zBlockAt(pos);
-					if (zB)
-					{
-						bool visible = zB->isVisible();
-						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)lightData);
-						if (zB->isVisible() && !visible)
-						{
-							Chunk* c = World::INSTANCE->zChunk(World::INSTANCE->getChunkCenter(pos.x, pos.y));
-							c->vcs.lock();
-							c->visibleBlocks.add(zB);
-							c->vcs.unlock();
-						}
-					}
-				}
-			}
-		}
-		zReader->lese((char*)&index, 4);
-	}
-	isLoading = 0;
+    isLoading = 1;
+    Framework::Vec3<int> pos = {0, 0, 0};
+    unsigned short id;
+    zReader->lese((char*)&id, 2);
+    while (id)
+    {
+        int index;
+        zReader->lese((char*)&index, 4);
+        pos = Vec3<int>((index / WORLD_HEIGHT) / CHUNK_SIZE,
+            (index / WORLD_HEIGHT) % CHUNK_SIZE,
+            index % WORLD_HEIGHT);
+        if (blockTypes[id]->doesNeedInstance())
+            setBlock(blockTypes[id]->createBlock(
+                {pos.x + location.x - CHUNK_SIZE / 2,
+                    pos.y + location.y - CHUNK_SIZE / 2,
+                    pos.z}));
+        zReader->lese((char*)&id, 2);
+    }
+    int index = 0;
+    // light
+    zReader->lese((char*)&index, 4);
+    char lightData[6];
+    while (index >= 0)
+    {
+        zReader->lese(lightData, 6);
+        Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
+            (index / WORLD_HEIGHT) % CHUNK_SIZE,
+            index % WORLD_HEIGHT);
+        for (int i = 0; i < 6; i++)
+        {
+            Framework::Vec3<int> pos
+                = location + getDirection(getDirectionFromIndex(i));
+            if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
+            {
+                if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0
+                    && pos.y < CHUNK_SIZE)
+                {
+                    pos.x += this->location.x - CHUNK_SIZE / 2;
+                    pos.y += this->location.y - CHUNK_SIZE / 2;
+                    Block* zB = zBlockAt(pos);
+                    if (zB)
+                    {
+                        bool visible = zB->isVisible();
+                        zB->setLightData(
+                            getOppositeDirection(getDirectionFromIndex(i)),
+                            (unsigned char*)lightData);
+                        if (zB->isVisible() && !visible) visibleBlocks.add(zB);
+                    }
+                }
+                else
+                {
+                    pos.x += this->location.x - CHUNK_SIZE / 2;
+                    pos.y += this->location.y - CHUNK_SIZE / 2;
+                    Block* zB = World::INSTANCE->zBlockAt(pos);
+                    if (zB)
+                    {
+                        bool visible = zB->isVisible();
+                        zB->setLightData(
+                            getOppositeDirection(getDirectionFromIndex(i)),
+                            (unsigned char*)lightData);
+                        if (zB->isVisible() && !visible)
+                        {
+                            Chunk* c = World::INSTANCE->zChunk(
+                                World::INSTANCE->getChunkCenter(pos.x, pos.y));
+                            c->vcs.lock();
+                            c->visibleBlocks.add(zB);
+                            c->vcs.unlock();
+                        }
+                    }
+                }
+            }
+        }
+        zReader->lese((char*)&index, 4);
+    }
+    isLoading = 0;
 }
 }
 
 
 Framework::Punkt Chunk::getCenter() const
 Framework::Punkt Chunk::getCenter() const
 {
 {
-	return location;
+    return location;
 }
 }
 
 
 Framework::Vec3<int> Chunk::getMin() const
 Framework::Vec3<int> Chunk::getMin() const
 {
 {
-	return { location.x - CHUNK_SIZE / 2, location.y - CHUNK_SIZE / 2, 0 };
+    return {location.x - CHUNK_SIZE / 2, location.y - CHUNK_SIZE / 2, 0};
 }
 }
 
 
 Framework::Vec3<int> Chunk::getMax() const
 Framework::Vec3<int> Chunk::getMax() const
 {
 {
-	return { location.x + CHUNK_SIZE / 2, location.y + CHUNK_SIZE / 2, WORLD_HEIGHT };
+    return {
+        location.x + CHUNK_SIZE / 2, location.y + CHUNK_SIZE / 2, WORLD_HEIGHT};
 }
 }
 
 
 void Chunk::forAll(std::function<void(Model3D*)> f)
 void Chunk::forAll(std::function<void(Model3D*)> f)
 {
 {
-	vcs.lock();
-	for (Block* b : visibleBlocks)
-		f(b);
-	vcs.unlock();
+    vcs.lock();
+    for (Block* b : visibleBlocks)
+        f(b);
+    vcs.unlock();
 }
 }

+ 24 - 24
FactoryCraft/Chunk.h

@@ -1,37 +1,37 @@
 #pragma once
 #pragma once
 
 
-#include <Punkt.h>
-#include <Model3DCollection.h>
-#include <Reader.h>
-#include <Model3D.h>
 #include <Array.h>
 #include <Array.h>
 #include <Critical.h>
 #include <Critical.h>
+#include <Model3D.h>
+#include <Model3DCollection.h>
+#include <Punkt.h>
+#include <Reader.h>
 
 
-#include "Block.h"
 #include "Area.h"
 #include "Area.h"
+#include "Block.h"
 
 
 class Chunk : public Framework::Model3DCollection
 class Chunk : public Framework::Model3DCollection
 {
 {
 private:
 private:
-	Framework::Punkt location;
-	// TODO: use native array for bedder performance?
-	Framework::RCArray<Block> blocks;
-	Framework::Array<Block*> visibleBlocks;
-	bool isLoading;
-	Framework::Critical cs;
-	Framework::Critical vcs;
+    Framework::Punkt location;
+    // TODO: use native array for bedder performance?
+    Framework::RCArray<Block> blocks;
+    Framework::Array<Block*> visibleBlocks;
+    bool isLoading;
+    Framework::Critical cs;
+    Framework::Critical vcs;
 
 
 public:
 public:
-	Chunk(Framework::Punkt location);
-	Chunk(Framework::Punkt location, Framework::StreamReader* zReader);
-	~Chunk();
-	void api(char* message);
-	Block* zBlockAt(Framework::Vec3<int> cLocation);
-	void setBlock(Block* block);
-	void removeBlock(Block* zBlock);
-	void load(Framework::StreamReader* zReader);
-	Framework::Punkt getCenter() const;
-	Framework::Vec3<int> getMin() const;
-	Framework::Vec3<int> getMax() const;
-	void forAll(std::function<void(Model3D*)> f) override;
+    Chunk(Framework::Punkt location);
+    Chunk(Framework::Punkt location, Framework::StreamReader* zReader);
+    ~Chunk();
+    void api(char* message);
+    Block* zBlockAt(Framework::Vec3<int> cLocation);
+    void setBlock(Block* block);
+    void removeBlock(Block* zBlock);
+    void load(Framework::StreamReader* zReader);
+    Framework::Punkt getCenter() const;
+    Framework::Vec3<int> getMin() const;
+    Framework::Vec3<int> getMax() const;
+    void forAll(std::function<void(Model3D*)> f) override;
 };
 };

+ 3 - 3
FactoryCraft/Constants.h

@@ -1,6 +1,6 @@
 #pragma once
 #pragma once
 
 
-#define CHUNK_SIZE 16
-#define WORLD_HEIGHT 500
+#define CHUNK_SIZE             16
+#define WORLD_HEIGHT           500
 #define CHUNK_VISIBILITY_RANGE 1
 #define CHUNK_VISIBILITY_RANGE 1
-#define MAX_VIEW_DISTANCE CHUNK_SIZE * CHUNK_VISIBILITY_RANGE
+#define MAX_VIEW_DISTANCE      CHUNK_SIZE* CHUNK_VISIBILITY_RANGE

+ 422 - 394
FactoryCraft/CraftingGrid.cpp

@@ -1,447 +1,475 @@
+#include "CraftingGrid.h"
+
 #include <XML.h>
 #include <XML.h>
 
 
-#include "CraftingGrid.h"
-#include "Globals.h"
 #include "DragController.h"
 #include "DragController.h"
 #include "Game.h"
 #include "Game.h"
+#include "Globals.h"
 #include "UIMLToolTip.h"
 #include "UIMLToolTip.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 CraftingGridElement::CraftingGridElement()
 CraftingGridElement::CraftingGridElement()
-	: UIMLElement()
+    : UIMLElement()
 {}
 {}
 
 
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 bool CraftingGridElement::isApplicableFor(Framework::XML::Element& element)
 bool CraftingGridElement::isApplicableFor(Framework::XML::Element& element)
 {
 {
-	return element.getName().istGleich("craftingGrid");
+    return element.getName().istGleich("craftingGrid");
 }
 }
 
 
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-Framework::Zeichnung* CraftingGridElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+Framework::Zeichnung* CraftingGridElement::parseElement(
+    Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
 {
 {
-	Text targetValue = element.getAttributeValue("target");
-	Vec3<int> blockPos(0, 0, 0);
-	Framework::Either<int, VecN<int, 4>> target((int)targetValue);
-	if (targetValue.hat(','))
-	{
-		Text* first = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
-		Text* second = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1, targetValue.positionVon(",", 1));
-		Text* third = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1, targetValue.positionVon(",", 2));
-		Text* forth = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
-		target = Framework::Either<int, VecN<int, 4>>(VecN<int, 4>({ (int)*first, (int)*second, (int)*third, (int)*forth }));
-		first->release();
-		second->release();
-		third->release();
-		forth->release();
-	}
-	return new CraftingGridView(element.getAttributeValue("id"), (int)element.getAttributeValue("rowSize"), (int)element.getAttributeValue("colSize"), (int)element.getAttributeValue("numOutputSlots"), target);
+    Text targetValue = element.getAttributeValue("target");
+    Vec3<int> blockPos(0, 0, 0);
+    Framework::Either<int, VecN<int, 4>> target((int)targetValue);
+    if (targetValue.hat(','))
+    {
+        Text* first
+            = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
+        Text* second
+            = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1,
+                targetValue.positionVon(",", 1));
+        Text* third
+            = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1,
+                targetValue.positionVon(",", 2));
+        Text* forth
+            = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
+        target = Framework::Either<int, VecN<int, 4>>(VecN<int, 4>(
+            {(int)*first, (int)*second, (int)*third, (int)*forth}));
+        first->release();
+        second->release();
+        third->release();
+        forth->release();
+    }
+    return new CraftingGridView(element.getAttributeValue("id"),
+        (int)element.getAttributeValue("rowSize"),
+        (int)element.getAttributeValue("colSize"),
+        (int)element.getAttributeValue("numOutputSlots"),
+        target);
 }
 }
 
 
 //! wendet die layout parameter zu einer Zeichnung an
 //! wendet die layout parameter zu einer Zeichnung an
-void CraftingGridElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+void CraftingGridElement::layout(Framework::XML::Element& element,
+    Framework::Zeichnung& z,
+    int pWidth,
+    int pHeight,
+    Framework::UIMLContainer& generalLayouter)
 {
 {
-	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+    UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
 }
 }
 
 
-
-CraftingGridView::CraftingGridView(Text id, int rowSize, int colSize, int numOutputSlots, Either<int, VecN<int, 4>> target)
-	: ZeichnungHintergrund(),
-	rowSize(rowSize),
-	colSize(colSize),
-	numOutputSlots(numOutputSlots),
-	target(target),
-	slots(0),
-	outputs(0),
-	id(id),
-	dragStartId(-1),
-	dragStopId(-1),
-	currentTooltipSlot(-1),
-	requestetTooltipSlot(-1)
+CraftingGridView::CraftingGridView(Text id,
+    int rowSize,
+    int colSize,
+    int numOutputSlots,
+    Either<int, VecN<int, 4>> target)
+    : ZeichnungHintergrund(),
+      rowSize(rowSize),
+      colSize(colSize),
+      numOutputSlots(numOutputSlots),
+      target(target),
+      slots(0),
+      outputs(0),
+      id(id),
+      dragStartId(-1),
+      dragStopId(-1),
+      currentTooltipSlot(-1),
+      requestetTooltipSlot(-1)
 {
 {
-	craft = uiFactory.createKnopf(uiFactory.initParam);
-	craft->setPosition(rowSize * 60, 10);
-	craft->setSize(40, 20);
-	craft->setText("Craft");
-	craft->setMausEreignis([this](void* p, void* o, MausEreignis me)
-		{
-			if (me.id == ME_RLinks)
-			{
-				char* msg = new char[2 + (this->target.isA() ? 4 : 16)];
-				msg[0] = 7; // request crafting
-				msg[1] = (char)this->target.isA();
-				if (msg[1])
-					*(int*)(msg + 2) = this->target.getA();
-				else
-				{
-					*(int*)(msg + 2) = this->target.getB()[0];
-					*(int*)(msg + 6) = this->target.getB()[1];
-					*(int*)(msg + 10) = this->target.getB()[2];
-					*(int*)(msg + 14) = this->target.getB()[3];
-				}
-				World::INSTANCE->zClient()->sendPlayerAction(msg, 2 + (this->target.isA() ? 4 : 16));
-				delete[] msg;
-			}
-			return 1;
-		});
-	setStyle(ZeichnungHintergrund::Style::Sichtbar | ZeichnungHintergrund::Style::Erlaubt);
-	char* msg = new char[id.getLength() + 12 + 3];
-	msg[0] = 0; // request inventory tooltip
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	msg[2 + id.getLength()] = (char)12;
-	memcpy(msg + 3 + id.getLength(), "CraftingGrid", 12);
-	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 12 + 3);
-	delete[] msg;
-	setNeedToolTipEvent([this](Zeichnung* z, Punkt p)
-		{
-			int slot = getSlotByLocalPos(p);
-			if (currentTooltipSlot != slot)
-			{
-				this->setToolTipZ(0);
-				currentTooltipSlot = -1;
-			}
-			else
-				return;
-			if (requestetTooltipSlot != slot)
-			{
-				requestetTooltipSlot = slot;
-				char* msg = new char[this->id.getLength() + 6];
-				msg[0] = 2; // request inventory tooltip
-				msg[1] = (char)this->id.getLength();
-				memcpy(msg + 2, this->id.getText(), this->id.getLength());
-				*(int*)(msg + 2 + this->id.getLength()) = slot;
-				World::INSTANCE->zClient()->inventoryAPIRequest(this->target, msg, this->id.getLength() + 6);
-			}
-		});
+    craft = uiFactory.createKnopf(uiFactory.initParam);
+    craft->setPosition(rowSize * 60, 10);
+    craft->setSize(40, 20);
+    craft->setText("Craft");
+    craft->setMausEreignis([this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            char* msg = new char[2 + (this->target.isA() ? 4 : 16)];
+            msg[0] = 7; // request crafting
+            msg[1] = (char)this->target.isA();
+            if (msg[1])
+                *(int*)(msg + 2) = this->target.getA();
+            else
+            {
+                *(int*)(msg + 2) = this->target.getB()[0];
+                *(int*)(msg + 6) = this->target.getB()[1];
+                *(int*)(msg + 10) = this->target.getB()[2];
+                *(int*)(msg + 14) = this->target.getB()[3];
+            }
+            World::INSTANCE->zClient()->sendPlayerAction(
+                msg, 2 + (this->target.isA() ? 4 : 16));
+            delete[] msg;
+        }
+        return 1;
+    });
+    setStyle(ZeichnungHintergrund::Style::Sichtbar
+             | ZeichnungHintergrund::Style::Erlaubt);
+    char* msg = new char[id.getLength() + 12 + 3];
+    msg[0] = 0; // request inventory tooltip
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    msg[2 + id.getLength()] = (char)12;
+    memcpy(msg + 3 + id.getLength(), "CraftingGrid", 12);
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        target, msg, id.getLength() + 12 + 3);
+    delete[] msg;
+    setNeedToolTipEvent([this](Zeichnung* z, Punkt p) {
+        int slot = getSlotByLocalPos(p);
+        if (currentTooltipSlot != slot)
+        {
+            this->setToolTipZ(0);
+            currentTooltipSlot = -1;
+        }
+        else
+            return;
+        if (requestetTooltipSlot != slot)
+        {
+            requestetTooltipSlot = slot;
+            char* msg = new char[this->id.getLength() + 6];
+            msg[0] = 2; // request inventory tooltip
+            msg[1] = (char)this->id.getLength();
+            memcpy(msg + 2, this->id.getText(), this->id.getLength());
+            *(int*)(msg + 2 + this->id.getLength()) = slot;
+            World::INSTANCE->zClient()->inventoryAPIRequest(
+                this->target, msg, this->id.getLength() + 6);
+        }
+    });
 }
 }
 
 
 CraftingGridView::~CraftingGridView()
 CraftingGridView::~CraftingGridView()
 {
 {
-	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-	if (controller->getCurrentDragContainer() == this)
-		controller->stopDrag();
-	if (slots)
-		slots->release();
-	if (outputs)
-		outputs->release();
-	char* msg = new char[id.getLength() + 2];
-	msg[0] = 1;
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 2);
-	delete[] msg;
-	craft->release();
+    DragController<InventoryDragSource, int>* controller
+        = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+    if (controller->getCurrentDragContainer() == this) controller->stopDrag();
+    if (slots) slots->release();
+    if (outputs) outputs->release();
+    char* msg = new char[id.getLength() + 2];
+    msg[0] = 1;
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        target, msg, id.getLength() + 2);
+    delete[] msg;
+    craft->release();
 }
 }
 
 
 int CraftingGridView::getSlotByLocalPos(Punkt pos)
 int CraftingGridView::getSlotByLocalPos(Punkt pos)
 {
 {
-	int x = 0;
-	int y = 0;
-	int rowCount = 0;
-	int slot = 0;
-	dragStopId = -1;
-	if (slots)
-	{
-		for (SlotInfo info : *slots)
-		{
-			if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
-				return info.id;
-			x += 60;
-			if (++rowCount >= rowSize)
-			{
-				y += 60;
-				x = 0;
-				rowCount = 0;
-			}
-			slot++;
-		}
-	}
-	return -1;
+    int x = 0;
+    int y = 0;
+    int rowCount = 0;
+    int slot = 0;
+    dragStopId = -1;
+    if (slots)
+    {
+        for (SlotInfo info : *slots)
+        {
+            if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
+                return info.id;
+            x += 60;
+            if (++rowCount >= rowSize)
+            {
+                y += 60;
+                x = 0;
+                rowCount = 0;
+            }
+            slot++;
+        }
+    }
+    return -1;
 }
 }
 
 
 void CraftingGridView::api(char* message)
 void CraftingGridView::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 0:
-		// send inventory content
-	{
-		Array<SlotInfo>* slots = new Array<SlotInfo>();
-		int count = *(int*)(++message);
-		for (int i = 0; i < count; i++)
-		{
-			SlotInfo info;
-			info.id = *(int*)(message += 4);
-			info.itemCount = *(int*)(message += 4);
-			if (info.itemCount > 0)
-			{
-				info.hp = *(float*)(message += 4);
-				info.maxHp = *(float*)(message += 4);
-				info.durability = *(float*)(message += 4);
-				info.maxDurability = *(float*)(message += 4);
-                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
-			}
-			slots->add(info);
-		}
-		postAction([this, slots]()
-			{
-				if (this->slots)
-					this->slots->release();
-				this->slots = slots;
-			});
-		break;
-	}
-	case 1: // set count of items
-	{
-		if (!slots)
-			return;
-		int id = *(int*)(message + 1);
-		int count = *(int*)(message + 5);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = count;
-				if (info.itemCount == 0)
-				{
-					DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-					if (controller && controller->getCurrentDragContainer() == this && controller->getCurrentDaragElement() == info.id)
-					{
-						controller->stopDrag();
-					}
-				}
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 2: // add new stack
-	{
-		if (!slots)
-			return;
-		int id = *(int*)(message + 1);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = *(int*)(message + 5);
-				info.hp = *(float*)(message + 9);
-				info.maxHp = *(float*)(message + 13);
-				info.durability = *(float*)(message + 17);
-				info.maxDurability = *(float*)(message + 21);
-                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 3: // receive tooltip uiml
-	{
-		int slotId = *(int*)(message + 1);
-		if (slotId == requestetTooltipSlot)
-		{
-			short len = *(short*)(message + 5);
-			char* uiml = new char[len + 1];
-			memcpy(uiml, message + 7, len);
-			uiml[len] = 0;
-			UIMLToolTip* tip = new UIMLToolTip();
-			tip->setUIML(uiml);
-			setToolTipZ(tip);
-			delete[] uiml;
-			currentTooltipSlot = slotId;
-			requestetTooltipSlot = -1;
-		}
-		break;
-	}
-	case 100: // set crafting result
-	{
-		Array<SlotInfo>* outputs = new Array<SlotInfo>();
-		int count = *(int*)(++message);
-		for (int i = 0; i < count; i++)
-		{
-			SlotInfo info;
-			info.id = i;
-			info.itemCount = *(int*)(message += 4);
-			if (info.itemCount > 0)
-			{
-				info.hp = *(float*)(message += 4);
-				info.maxHp = *(float*)(message += 4);
-				info.durability = *(float*)(message += 4);
-				info.maxDurability = *(float*)(message += 4);
-                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
-			}
-			outputs->add(info);
-		}
-		postAction([this, outputs]()
-			{
-				if (this->outputs)
-					this->outputs->release();
-				this->outputs = outputs;
-			});
-		break;
-	}
-	}
+    switch (message[0])
+    {
+    case 0:
+        // send inventory content
+        {
+            Array<SlotInfo>* slots = new Array<SlotInfo>();
+            int count = *(int*)(++message);
+            for (int i = 0; i < count; i++)
+            {
+                SlotInfo info;
+                info.id = *(int*)(message += 4);
+                info.itemCount = *(int*)(message += 4);
+                if (info.itemCount > 0)
+                {
+                    info.hp = *(float*)(message += 4);
+                    info.maxHp = *(float*)(message += 4);
+                    info.durability = *(float*)(message += 4);
+                    info.maxDurability = *(float*)(message += 4);
+                    info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+                }
+                slots->add(info);
+            }
+            postAction([this, slots]() {
+                if (this->slots) this->slots->release();
+                this->slots = slots;
+            });
+            break;
+        }
+    case 1: // set count of items
+        {
+            if (!slots) return;
+            int id = *(int*)(message + 1);
+            int count = *(int*)(message + 5);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = count;
+                    if (info.itemCount == 0)
+                    {
+                        DragController<InventoryDragSource, int>* controller
+                            = ((Game*)(Menu*)menuRegister->get("game"))
+                                  ->zInventoryDragController();
+                        if (controller
+                            && controller->getCurrentDragContainer() == this
+                            && controller->getCurrentDaragElement() == info.id)
+                        {
+                            controller->stopDrag();
+                        }
+                    }
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 2: // add new stack
+        {
+            if (!slots) return;
+            int id = *(int*)(message + 1);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = *(int*)(message + 5);
+                    info.hp = *(float*)(message + 9);
+                    info.maxHp = *(float*)(message + 13);
+                    info.durability = *(float*)(message + 17);
+                    info.maxDurability = *(float*)(message + 21);
+                    info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 3: // receive tooltip uiml
+        {
+            int slotId = *(int*)(message + 1);
+            if (slotId == requestetTooltipSlot)
+            {
+                short len = *(short*)(message + 5);
+                char* uiml = new char[len + 1];
+                memcpy(uiml, message + 7, len);
+                uiml[len] = 0;
+                UIMLToolTip* tip = new UIMLToolTip();
+                tip->setUIML(uiml);
+                setToolTipZ(tip);
+                delete[] uiml;
+                currentTooltipSlot = slotId;
+                requestetTooltipSlot = -1;
+            }
+            break;
+        }
+    case 100: // set crafting result
+        {
+            Array<SlotInfo>* outputs = new Array<SlotInfo>();
+            int count = *(int*)(++message);
+            for (int i = 0; i < count; i++)
+            {
+                SlotInfo info;
+                info.id = i;
+                info.itemCount = *(int*)(message += 4);
+                if (info.itemCount > 0)
+                {
+                    info.hp = *(float*)(message += 4);
+                    info.maxHp = *(float*)(message += 4);
+                    info.durability = *(float*)(message += 4);
+                    info.maxDurability = *(float*)(message += 4);
+                    info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+                }
+                outputs->add(info);
+            }
+            postAction([this, outputs]() {
+                if (this->outputs) this->outputs->release();
+                this->outputs = outputs;
+            });
+            break;
+        }
+    }
 }
 }
 
 
 bool CraftingGridView::tick(double tickVal)
 bool CraftingGridView::tick(double tickVal)
 {
 {
-	return ZeichnungHintergrund::tick(tickVal);
+    return ZeichnungHintergrund::tick(tickVal);
 }
 }
 
 
 void CraftingGridView::render(Bild& rObj)
 void CraftingGridView::render(Bild& rObj)
 {
 {
-	ZeichnungHintergrund::render(rObj);
-	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
-		return;
-	int numRows = 1;
-	if (slots)
-	{
-		int x = 0;
-		int y = 0;
-		int rowCount = 0;
-		int index = 0;
-		for (SlotInfo info : *slots)
-		{
-			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
-			x += 60;
-			if (++rowCount >= rowSize)
-			{
-				y += 60;
-				x = 0;
-				rowCount = 0;
-				if (index < slots->getEintragAnzahl() - 1)
-					numRows++;
-			}
-			index++;
-		}
-	}
-	craft->render(rObj);
-	rObj.fillRegion(rowSize * 60, gr.y / 2 - 5, 25, 10, 0xFF52525E);
-	rObj.drawDreieck(Punkt(rowSize * 60 + 25, gr.y / 2 - 15), Punkt(rowSize * 60 + 40, gr.y / 2), Punkt(rowSize * 60 + 25, gr.y / 2 + 15), 0xFF52525E);
-	if (outputs)
-	{
-		int x = rowSize * 60 + 50;
-		int y = 0;
-		int colCount = 0;
-		for (SlotInfo info : *outputs)
-		{
-			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
-			y += 60;
-			if (++colCount >= numRows)
-			{
-				x += 60;
-				y = 0;
-				colCount = 0;
-			}
-		}
-	}
-	rObj.releaseDrawOptions();
+    ZeichnungHintergrund::render(rObj);
+    if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return;
+    int numRows = 1;
+    if (slots)
+    {
+        int x = 0;
+        int y = 0;
+        int rowCount = 0;
+        int index = 0;
+        for (SlotInfo info : *slots)
+        {
+            info.render(
+                x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+            x += 60;
+            if (++rowCount >= rowSize)
+            {
+                y += 60;
+                x = 0;
+                rowCount = 0;
+                if (index < slots->getEintragAnzahl() - 1) numRows++;
+            }
+            index++;
+        }
+    }
+    craft->render(rObj);
+    rObj.fillRegion(rowSize * 60, gr.y / 2 - 5, 25, 10, 0xFF52525E);
+    rObj.drawDreieck(Punkt(rowSize * 60 + 25, gr.y / 2 - 15),
+        Punkt(rowSize * 60 + 40, gr.y / 2),
+        Punkt(rowSize * 60 + 25, gr.y / 2 + 15),
+        0xFF52525E);
+    if (outputs)
+    {
+        int x = rowSize * 60 + 50;
+        int y = 0;
+        int colCount = 0;
+        for (SlotInfo info : *outputs)
+        {
+            info.render(
+                x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+            y += 60;
+            if (++colCount >= numRows)
+            {
+                x += 60;
+                y = 0;
+                colCount = 0;
+            }
+        }
+    }
+    rObj.releaseDrawOptions();
 }
 }
 
 
 void CraftingGridView::doMausEreignis(MausEreignis& me, bool userRet)
 void CraftingGridView::doMausEreignis(MausEreignis& me, bool userRet)
 {
 {
-	if (!slots)
-		return;
-	if (me.id == ME_Bewegung)
-	{
-		if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
-		{
-			setToolTipZ(0);
-			currentTooltipSlot = -1;
-		}
-	}
-	craft->doPublicMausEreignis(me);
-	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-	int x = 0;
-	int y = 0;
-	int rowCount = 0;
-	int slot = 0;
-	dragStopId = -1;
-	for (SlotInfo info : *slots)
-	{
-		if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
-		{
-			if (me.id == ME_RLinks)
-			{
-				if (!controller->getCurrentDragContainer() && info.itemCount > 0)
-				{
-					controller->beginDrag(this, info.id, info.zItem, [this]()
-						{
-							dragStartId = -1;
-						});
-					dragStartId = info.id;
-				}
-				else if (controller->getCurrentDragContainer())
-				{
-					// request to transfer items from source to target slot
-					Framework::Either<int, Framework::VecN<int, 4>> source = controller->getCurrentDragContainer()->getInventoryTarget();
-					int len = 2 + (source.isA() ? 4 : 16) + 5 + (target.isA() ? 4 : 16) + 4;
-					char* msg = new char[len];
-					int index = 0;
-					msg[index++] = 6;
-					msg[index++] = (char)source.isA();
-					if (source.isA())
-					{
-						*(int*)(msg + index) = source.getA();
-						index += 4;
-					}
-					else
-					{
-						*(int*)(msg + index) = source.getB()[0];
-						*(int*)(msg + index + 4) = source.getB()[1];
-						*(int*)(msg + index + 8) = source.getB()[2];
-						*(int*)(msg + index + 12) = source.getB()[3];
-						index += 16;
-					}
-					*(int*)(msg + index) = controller->getCurrentDaragElement();
-					index += 4;
-					msg[index++] = target.isA();
-					if (target.isA())
-					{
-						*(int*)(msg + index) = target.getA();
-						index += 4;
-					}
-					else
-					{
-						*(int*)(msg + index) = target.getB()[0];
-						*(int*)(msg + index + 4) = target.getB()[1];
-						*(int*)(msg + index + 8) = target.getB()[2];
-						*(int*)(msg + index + 12) = target.getB()[3];
-						index += 16;
-					}
-					*(int*)(msg + index) = info.id;
-					World::INSTANCE->zClient()->sendPlayerAction(msg, len);
-					delete[] msg;
-				}
-			}
-			else
-			{
-				if (controller->getCurrentDragContainer() && (controller->getCurrentDragContainer() != this || controller->getCurrentDaragElement() != info.id))
-				{
-					dragStopId = info.id;
-				}
-			}
-			break;
-		}
-		x += 60;
-		if (++rowCount >= rowSize)
-		{
-			y += 60;
-			x = 0;
-			rowCount = 0;
-		}
-		slot++;
-	}
-	ZeichnungHintergrund::doMausEreignis(me, userRet);
+    if (!slots) return;
+    if (me.id == ME_Bewegung)
+    {
+        if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
+        {
+            setToolTipZ(0);
+            currentTooltipSlot = -1;
+        }
+    }
+    craft->doPublicMausEreignis(me);
+    DragController<InventoryDragSource, int>* controller
+        = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+    int x = 0;
+    int y = 0;
+    int rowCount = 0;
+    int slot = 0;
+    dragStopId = -1;
+    for (SlotInfo info : *slots)
+    {
+        if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
+        {
+            if (me.id == ME_RLinks)
+            {
+                if (!controller->getCurrentDragContainer()
+                    && info.itemCount > 0)
+                {
+                    controller->beginDrag(this, info.id, info.zItem, [this]() {
+                        dragStartId = -1;
+                    });
+                    dragStartId = info.id;
+                }
+                else if (controller->getCurrentDragContainer())
+                {
+                    // request to transfer items from source to target slot
+                    Framework::Either<int, Framework::VecN<int, 4>> source
+                        = controller->getCurrentDragContainer()
+                              ->getInventoryTarget();
+                    int len = 2 + (source.isA() ? 4 : 16) + 5
+                            + (target.isA() ? 4 : 16) + 4;
+                    char* msg = new char[len];
+                    int index = 0;
+                    msg[index++] = 6;
+                    msg[index++] = (char)source.isA();
+                    if (source.isA())
+                    {
+                        *(int*)(msg + index) = source.getA();
+                        index += 4;
+                    }
+                    else
+                    {
+                        *(int*)(msg + index) = source.getB()[0];
+                        *(int*)(msg + index + 4) = source.getB()[1];
+                        *(int*)(msg + index + 8) = source.getB()[2];
+                        *(int*)(msg + index + 12) = source.getB()[3];
+                        index += 16;
+                    }
+                    *(int*)(msg + index) = controller->getCurrentDaragElement();
+                    index += 4;
+                    msg[index++] = target.isA();
+                    if (target.isA())
+                    {
+                        *(int*)(msg + index) = target.getA();
+                        index += 4;
+                    }
+                    else
+                    {
+                        *(int*)(msg + index) = target.getB()[0];
+                        *(int*)(msg + index + 4) = target.getB()[1];
+                        *(int*)(msg + index + 8) = target.getB()[2];
+                        *(int*)(msg + index + 12) = target.getB()[3];
+                        index += 16;
+                    }
+                    *(int*)(msg + index) = info.id;
+                    World::INSTANCE->zClient()->sendPlayerAction(msg, len);
+                    delete[] msg;
+                }
+            }
+            else
+            {
+                if (controller->getCurrentDragContainer()
+                    && (controller->getCurrentDragContainer() != this
+                        || controller->getCurrentDaragElement() != info.id))
+                {
+                    dragStopId = info.id;
+                }
+            }
+            break;
+        }
+        x += 60;
+        if (++rowCount >= rowSize)
+        {
+            y += 60;
+            x = 0;
+            rowCount = 0;
+        }
+        slot++;
+    }
+    ZeichnungHintergrund::doMausEreignis(me, userRet);
 }
 }
 
 
-Framework::Either<int, Framework::VecN<int, 4>> CraftingGridView::getInventoryTarget() const
+Framework::Either<int, Framework::VecN<int, 4>>
+CraftingGridView::getInventoryTarget() const
 {
 {
-	return target;
+    return target;
 }
 }

+ 44 - 32
FactoryCraft/CraftingGrid.h

@@ -1,49 +1,61 @@
 #pragma once
 #pragma once
 
 
-#include <UIMLView.h>
 #include <Either.h>
 #include <Either.h>
+#include <UIMLView.h>
 #include <VecN.h>
 #include <VecN.h>
 
 
-#include "NetworkAPIProcessor.h"
 #include "InventoryView.h"
 #include "InventoryView.h"
-
+#include "NetworkAPIProcessor.h"
 
 
 class CraftingGridElement : public Framework::UIMLElement
 class CraftingGridElement : public Framework::UIMLElement
 {
 {
 public:
 public:
-	CraftingGridElement();
-	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
-	bool isApplicableFor(Framework::XML::Element& element) override;
-	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
-	//! wendet die layout parameter zu einer Zeichnung an
-	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+    CraftingGridElement();
+    //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
+    //! ist
+    bool isApplicableFor(Framework::XML::Element& element) override;
+    //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+    Framework::Zeichnung* parseElement(Framework::XML::Element& element,
+        Framework::UIMLContainer& generalFactory) override;
+    //! wendet die layout parameter zu einer Zeichnung an
+    void layout(Framework::XML::Element& element,
+        Framework::Zeichnung& z,
+        int pWidth,
+        int pHeight,
+        Framework::UIMLContainer& generalLayouter) override;
 };
 };
 
 
-class CraftingGridView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor, public InventoryDragSource
+class CraftingGridView : public Framework::ZeichnungHintergrund,
+                         public NetworkAPIProcessor,
+                         public InventoryDragSource
 {
 {
 private:
 private:
-	int rowSize;
-	int colSize;
-	int numOutputSlots;
-	// entity id or block position
-	Framework::Either<int, Framework::VecN<int, 4>> target;
-	Framework::Array<SlotInfo>* slots;
-	Framework::Array<SlotInfo>* outputs;
-	Framework::Text id;
-	int dragStartId;
-	int dragStopId;
-	Framework::Knopf* craft;
-	int currentTooltipSlot;
-	int requestetTooltipSlot;
-	int getSlotByLocalPos(Framework::Punkt pos);
+    int rowSize;
+    int colSize;
+    int numOutputSlots;
+    // entity id or block position
+    Framework::Either<int, Framework::VecN<int, 4>> target;
+    Framework::Array<SlotInfo>* slots;
+    Framework::Array<SlotInfo>* outputs;
+    Framework::Text id;
+    int dragStartId;
+    int dragStopId;
+    Framework::Knopf* craft;
+    int currentTooltipSlot;
+    int requestetTooltipSlot;
+    int getSlotByLocalPos(Framework::Punkt pos);
 
 
 public:
 public:
-	CraftingGridView(Framework::Text id, int rowSize, int colSize, int numOutputSlots, Framework::Either<int, Framework::VecN<int, 4>> target);
-	~CraftingGridView();
-	void api(char* message) override;
-	bool tick(double tickVal) override;
-	void render(Framework::Bild& rObj) override;
-	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
-	Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const override;
+    CraftingGridView(Framework::Text id,
+        int rowSize,
+        int colSize,
+        int numOutputSlots,
+        Framework::Either<int, Framework::VecN<int, 4>> target);
+    ~CraftingGridView();
+    void api(char* message) override;
+    bool tick(double tickVal) override;
+    void render(Framework::Bild& rObj) override;
+    void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+    Framework::Either<int, Framework::VecN<int, 4>>
+    getInventoryTarget() const override;
 };
 };

+ 22 - 16
FactoryCraft/CustomDX11API.cpp

@@ -1,35 +1,41 @@
-#include <Shader.h> 
-
 #include "CustomDX11API.h"
 #include "CustomDX11API.h"
 
 
+#include <Shader.h>
+
 #include "CustomUIDX11PixelShader.h"
 #include "CustomUIDX11PixelShader.h"
 #include "CustomUIDX11VertexShader.h"
 #include "CustomUIDX11VertexShader.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 CustomDX11API::CustomDX11API()
 CustomDX11API::CustomDX11API()
-	: DirectX11(),
-	vertexShaderLightBufferIndex(-1)
+    : DirectX11(),
+      vertexShaderLightBufferIndex(-1)
 {}
 {}
 
 
-Framework::DX11VertexShader* CustomDX11API::initializeVertexShader(unsigned char* byteCode, int size)
+Framework::DX11VertexShader* CustomDX11API::initializeVertexShader(
+    unsigned char* byteCode, int size)
 {
 {
-	DX11VertexShader* shader = DirectX11::initializeVertexShader((unsigned char*)CustomUIDX11VertexShader, sizeof(CustomUIDX11VertexShader));
-	vertexShaderLightBufferIndex = shader->getFirstUninitializedBufferIndex();
-	shader->erstelleConstBuffer(4, vertexShaderLightBufferIndex);
-	shader->erstelleConstBuffer(4 * 24, vertexShaderLightBufferIndex + 1);
-	int count = 0;
-	shader->füllConstBuffer((char*)&count, vertexShaderLightBufferIndex, 4);
-	return shader;
+    DX11VertexShader* shader = DirectX11::initializeVertexShader(
+        (unsigned char*)CustomUIDX11VertexShader,
+        sizeof(CustomUIDX11VertexShader));
+    vertexShaderLightBufferIndex = shader->getFirstUninitializedBufferIndex();
+    shader->erstelleConstBuffer(4, vertexShaderLightBufferIndex);
+    shader->erstelleConstBuffer(4 * 24, vertexShaderLightBufferIndex + 1);
+    int count = 0;
+    shader->füllConstBuffer((char*)&count, vertexShaderLightBufferIndex, 4);
+    return shader;
 }
 }
 
 
-Framework::DX11PixelShader* CustomDX11API::initializePixelShader(unsigned char* byteCode, int size)
+Framework::DX11PixelShader* CustomDX11API::initializePixelShader(
+    unsigned char* byteCode, int size)
 {
 {
-	DX11PixelShader* shader = DirectX11::initializePixelShader((unsigned char*)CustomUIDX11PixelShader, sizeof(CustomUIDX11PixelShader));
-	return shader;
+    DX11PixelShader* shader = DirectX11::initializePixelShader(
+        (unsigned char*)CustomUIDX11PixelShader,
+        sizeof(CustomUIDX11PixelShader));
+    return shader;
 }
 }
 
 
 int CustomDX11API::getVertexShaderLightBufferIndex() const
 int CustomDX11API::getVertexShaderLightBufferIndex() const
 {
 {
-	return vertexShaderLightBufferIndex;
+    return vertexShaderLightBufferIndex;
 }
 }

+ 7 - 5
FactoryCraft/CustomDX11API.h

@@ -5,14 +5,16 @@
 class CustomDX11API : public Framework::DirectX11
 class CustomDX11API : public Framework::DirectX11
 {
 {
 private:
 private:
-	int vertexShaderLightBufferIndex;
+    int vertexShaderLightBufferIndex;
 
 
 protected:
 protected:
-	Framework::DX11VertexShader* initializeVertexShader(unsigned char* byteCode, int size) override;
-	Framework::DX11PixelShader* initializePixelShader(unsigned char* byteCode, int size) override;
+    Framework::DX11VertexShader* initializeVertexShader(
+        unsigned char* byteCode, int size) override;
+    Framework::DX11PixelShader* initializePixelShader(
+        unsigned char* byteCode, int size) override;
 
 
 public:
 public:
-	CustomDX11API();
+    CustomDX11API();
 
 
-	int getVertexShaderLightBufferIndex() const;
+    int getVertexShaderLightBufferIndex() const;
 };
 };

+ 12 - 10
FactoryCraft/Dialog.h

@@ -1,20 +1,22 @@
 #pragma once
 #pragma once
 
 
-#include "NetworkAPIProcessor.h"
-
 #include <Fenster.h>
 #include <Fenster.h>
 #include <UIMLView.h>
 #include <UIMLView.h>
 
 
-class UIMLDialog : public Framework::Fenster, public NetworkAPIProcessor
+#include "NetworkAPIProcessor.h"
+
+class UIMLDialog : public Framework::Fenster,
+                   public NetworkAPIProcessor
 {
 {
 private:
 private:
-	Framework::UIMLView* view;
-	Framework::Text name;
-	std::function<void(UIMLDialog* self)> onClose;
+    Framework::UIMLView* view;
+    Framework::Text name;
+    std::function<void(UIMLDialog* self)> onClose;
 
 
 public:
 public:
-	UIMLDialog(Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose);
-	~UIMLDialog();
-	void api(char* message) override;
-	const Framework::Text& getName() const;
+    UIMLDialog(
+        Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose);
+    ~UIMLDialog();
+    void api(char* message) override;
+    const Framework::Text& getName() const;
 };
 };

+ 176 - 177
FactoryCraft/Dimension.cpp

@@ -1,4 +1,5 @@
 #include "Dimension.h"
 #include "Dimension.h"
+
 #include "Constants.h"
 #include "Constants.h"
 #include "Datei.h"
 #include "Datei.h"
 #include "Game.h"
 #include "Game.h"
@@ -8,245 +9,243 @@
 using namespace Framework;
 using namespace Framework;
 
 
 Dimension::Dimension()
 Dimension::Dimension()
-	: chunks(new Trie<Chunk>()),
-	entities(new RCArray<Entity>())
+    : chunks(new Trie<Chunk>()),
+      entities(new RCArray<Entity>())
 {}
 {}
 
 
 Dimension::~Dimension()
 Dimension::~Dimension()
 {
 {
-	entities->release();
-	chunks->release();
+    entities->release();
+    chunks->release();
 }
 }
 
 
 void Dimension::getAddrOf(Punkt cPos, char* addr) const
 void Dimension::getAddrOf(Punkt cPos, char* addr) const
 {
 {
-	*(int*)addr = cPos.x;
-	*((int*)addr + 1) = cPos.y;
+    *(int*)addr = cPos.x;
+    *((int*)addr + 1) = cPos.y;
 }
 }
 
 
 void Dimension::getAddrOfWorld(Punkt wPos, char* addr) const
 void Dimension::getAddrOfWorld(Punkt wPos, char* addr) const
 {
 {
-	if (wPos.x < 0)
-		wPos.x -= CHUNK_SIZE;
-	if (wPos.y < 0) // needed because otherwise would (-8, -8) have the same adress as (8, 8)
-		wPos.y -= CHUNK_SIZE;
-	wPos /= CHUNK_SIZE;
-	getAddrOf(wPos, addr);
+    if (wPos.x < 0) wPos.x -= CHUNK_SIZE;
+    if (wPos.y < 0) // needed because otherwise would (-8, -8) have the same
+                    // adress as (8, 8)
+        wPos.y -= CHUNK_SIZE;
+    wPos /= CHUNK_SIZE;
+    getAddrOf(wPos, addr);
 }
 }
 
 
 void Dimension::api(char* message)
 void Dimension::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 1: // chunck
-	{
-		int cX = *(int*)(message + 1);
-		int cY = *(int*)(message + 5);
-		Chunk* ch = zChunk(Punkt(cX, cY));
-		if (ch)
-			ch->api(message + 9);
-		break;
-	}
-	case 2: // entity
-	{
-		int eId = *(int*)(message + 1);
-		Entity* e = zEntity(eId);
-		if (e)
-			e->api(message + 5);
-		break;
-	}
-	case 3: // block
-	{
-		int px = *(int*)(message + 1);
-		int py = *(int*)(message + 5);
-		int pz = *(int*)(message + 9);
-		Block* b = zBlock(Framework::Vec3<int>(px, py, pz));
-		if (b)
-			b->api(message + 13);
-		break;
-	}
-	case 4: // add new chunck
-	{
-		Punkt center;
-		center.x = *(int*)(message + 1);
-		center.y = *(int*)(message + 5);
-		ByteArrayReader reader(message + 9, INT_MAX, 0);
-		std::cout << "downloading chunk " << center.x << ", " << center.y << "\n";
-		ZeitMesser zm;
-		zm.messungStart();
-		Chunk* chunk = new Chunk(center);
-		chunk->load(&reader);
-		zm.messungEnde();
-		std::cout << "chunk loading took " << zm.getSekunden() << " seconds\n";
-		setChunk(chunk, center);
-		World::INSTANCE->onChunkAdded(center);
-		break;
-	}
-	}
+    switch (message[0])
+    {
+    case 1: // chunck
+        {
+            int cX = *(int*)(message + 1);
+            int cY = *(int*)(message + 5);
+            Chunk* ch = zChunk(Punkt(cX, cY));
+            if (ch) ch->api(message + 9);
+            break;
+        }
+    case 2: // entity
+        {
+            int eId = *(int*)(message + 1);
+            Entity* e = zEntity(eId);
+            if (e) e->api(message + 5);
+            break;
+        }
+    case 3: // block
+        {
+            int px = *(int*)(message + 1);
+            int py = *(int*)(message + 5);
+            int pz = *(int*)(message + 9);
+            Block* b = zBlock(Framework::Vec3<int>(px, py, pz));
+            if (b) b->api(message + 13);
+            break;
+        }
+    case 4: // add new chunck
+        {
+            Punkt center;
+            center.x = *(int*)(message + 1);
+            center.y = *(int*)(message + 5);
+            ByteArrayReader reader(message + 9, INT_MAX, 0);
+            std::cout << "downloading chunk " << center.x << ", " << center.y
+                      << "\n";
+            ZeitMesser zm;
+            zm.messungStart();
+            Chunk* chunk = new Chunk(center);
+            chunk->load(&reader);
+            zm.messungEnde();
+            std::cout << "chunk loading took " << zm.getSekunden()
+                      << " seconds\n";
+            setChunk(chunk, center);
+            World::INSTANCE->onChunkAdded(center);
+            break;
+        }
+    }
 }
 }
 
 
 Chunk* Dimension::zChunk(Punkt wPos) const
 Chunk* Dimension::zChunk(Punkt wPos) const
 {
 {
-	char addr[8];
-	getAddrOfWorld(wPos, addr);
-	return chunks->z(addr, 8);
+    char addr[8];
+    getAddrOfWorld(wPos, addr);
+    return chunks->z(addr, 8);
 }
 }
 
 
 Block* Dimension::zBlock(Vec3<int> location)
 Block* Dimension::zBlock(Vec3<int> location)
 {
 {
-	Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
-	if (c)
-		return c->zBlockAt(location);
-	return 0;
+    Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
+    if (c) return c->zBlockAt(location);
+    return 0;
 }
 }
 
 
 Block* Dimension::getBlock(Vec3<int> location)
 Block* Dimension::getBlock(Vec3<int> location)
 {
 {
-	cs.lock();
-	Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
-	if (c)
-	{
-		Block* b = c->zBlockAt(location);
-		b = b ? dynamic_cast<Block*>(b->getThis()) : 0;
-		cs.unlock();
-		return b;
-	}
-	cs.unlock();
-	return 0;
+    cs.lock();
+    Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
+    if (c)
+    {
+        Block* b = c->zBlockAt(location);
+        b = b ? dynamic_cast<Block*>(b->getThis()) : 0;
+        cs.unlock();
+        return b;
+    }
+    cs.unlock();
+    return 0;
 }
 }
 
 
 void Dimension::addEntity(Entity* entity)
 void Dimension::addEntity(Entity* entity)
 {
 {
-	entities->add(entity);
-	World::INSTANCE->setVisibility(entity, 1);
+    entities->add(entity);
+    World::INSTANCE->setVisibility(entity, 1);
 }
 }
 
 
 void Dimension::setChunk(Chunk* chunk, Punkt center)
 void Dimension::setChunk(Chunk* chunk, Punkt center)
 {
 {
-	char addr[8];
-	getAddrOfWorld(center, addr);
-	Chunk* old = chunks->z(addr, 8);
-	cs.lock();
-	if (old)
-	{
-		World::INSTANCE->setVisibility(old, 0);
-		int index = 0;
-		for (auto iterator = chunkList.begin(); iterator; ++iterator, ++index)
-		{
-			if ((Chunk*)iterator == old)
-			{
-				if (chunk)
-					iterator.set(chunk);
-				else
-					chunkList.remove(index);
-				break;
-			}
-		}
-	}
-	else if (chunk)
-		chunkList.add(chunk);
-	chunks->set(addr, 8, chunk);
-	if (chunk)
-		chunk->getThis();
-	cs.unlock();
-	if (chunk)
-	{
-		World::INSTANCE->setVisibility(chunk, 1);
-		chunk->release();
-	}
+    char addr[8];
+    getAddrOfWorld(center, addr);
+    Chunk* old = chunks->z(addr, 8);
+    cs.lock();
+    if (old)
+    {
+        World::INSTANCE->setVisibility(old, 0);
+        int index = 0;
+        for (auto iterator = chunkList.begin(); iterator; ++iterator, ++index)
+        {
+            if ((Chunk*)iterator == old)
+            {
+                if (chunk)
+                    iterator.set(chunk);
+                else
+                    chunkList.remove(index);
+                break;
+            }
+        }
+    }
+    else if (chunk)
+        chunkList.add(chunk);
+    chunks->set(addr, 8, chunk);
+    if (chunk) chunk->getThis();
+    cs.unlock();
+    if (chunk)
+    {
+        World::INSTANCE->setVisibility(chunk, 1);
+        chunk->release();
+    }
 }
 }
 
 
 bool Dimension::hasChunck(int x, int y) const
 bool Dimension::hasChunck(int x, int y) const
 {
 {
-	return zChunk(Punkt(x, y));
+    return zChunk(Punkt(x, y));
 }
 }
 
 
 void Dimension::removeDistantChunks(Punkt wPos)
 void Dimension::removeDistantChunks(Punkt wPos)
 {
 {
-	Array<int> removed;
-	int index = 0;
-	for (Chunk* chunk : chunkList)
-	{
-		if ((chunk->getCenter() - wPos).getLength() > MAX_VIEW_DISTANCE * 2)
-			removed.add(index, 0);
-		index++;
-	}
-	for (int i : removed)
-	{
-		Chunk* chunk = chunkList.get(i);
-		World::INSTANCE->setVisibility(chunk, 0);
-		setChunk(0, chunk->getCenter());
-	}
+    Array<int> removed;
+    int index = 0;
+    for (Chunk* chunk : chunkList)
+    {
+        if ((chunk->getCenter() - wPos).getLength() > MAX_VIEW_DISTANCE * 2)
+            removed.add(index, 0);
+        index++;
+    }
+    for (int i : removed)
+    {
+        Chunk* chunk = chunkList.get(i);
+        World::INSTANCE->setVisibility(chunk, 0);
+        setChunk(0, chunk->getCenter());
+    }
 }
 }
 
 
 void Dimension::setBlock(Block* block)
 void Dimension::setBlock(Block* block)
 {
 {
-	cs.lock();
-	Chunk* c = zChunk(World::INSTANCE->getChunkCenter((int)floor(block->getPos().x), (int)floor(block->getPos().y)));
-	if (c)
-		c->setBlock(block);
-	else
-		block->release();
-	cs.unlock();
+    cs.lock();
+    Chunk* c = zChunk(World::INSTANCE->getChunkCenter(
+        (int)floor(block->getPos().x), (int)floor(block->getPos().y)));
+    if (c)
+        c->setBlock(block);
+    else
+        block->release();
+    cs.unlock();
 }
 }
 
 
 void Dimension::removeBlock(Block* zBlock)
 void Dimension::removeBlock(Block* zBlock)
 {
 {
-	cs.lock();
-	Chunk* c = zChunk(World::INSTANCE->getChunkCenter((int)floor(zBlock->getPos().x), (int)floor(zBlock->getPos().y)));
-	if (c)
-		c->removeBlock(zBlock);
-	cs.unlock();
+    cs.lock();
+    Chunk* c = zChunk(World::INSTANCE->getChunkCenter(
+        (int)floor(zBlock->getPos().x), (int)floor(zBlock->getPos().y)));
+    if (c) c->removeBlock(zBlock);
+    cs.unlock();
 }
 }
 
 
 Entity* Dimension::zEntity(int id)
 Entity* Dimension::zEntity(int id)
 {
 {
-	cs.lock();
-	for (Entity* e : *entities)
-	{
-		if (e->getId() == id)
-		{
-			cs.unlock();
-			return e;
-		}
-	}
-	cs.unlock();
-	return 0;
+    cs.lock();
+    for (Entity* e : *entities)
+    {
+        if (e->getId() == id)
+        {
+            cs.unlock();
+            return e;
+        }
+    }
+    cs.unlock();
+    return 0;
 }
 }
 
 
 Entity* Dimension::getEntity(int id)
 Entity* Dimension::getEntity(int id)
 {
 {
-	cs.lock();
-	for (Entity* e : *entities)
-	{
-		if (e->getId() == id)
-		{
-			Entity* result = dynamic_cast<Entity*>(e->getThis());
-			cs.unlock();
-			return result;
-		}
-	}
-	cs.unlock();
-	return 0;
+    cs.lock();
+    for (Entity* e : *entities)
+    {
+        if (e->getId() == id)
+        {
+            Entity* result = dynamic_cast<Entity*>(e->getThis());
+            cs.unlock();
+            return result;
+        }
+    }
+    cs.unlock();
+    return 0;
 }
 }
 
 
 void Dimension::removeEntity(int id)
 void Dimension::removeEntity(int id)
 {
 {
-	World::INSTANCE->lockWorld();
-	cs.lock();
-	int index = 0;
-	for (Entity* e : *entities)
-	{
-		if (e->getId() == id)
-		{
-			World::INSTANCE->setVisibility(e, 0);
-			entities->remove(index);
-			cs.unlock();
-			World::INSTANCE->unlockWorld();
-			return;
-		}
-		index++;
-	}
-	cs.unlock();
-	World::INSTANCE->unlockWorld();
+    World::INSTANCE->lockWorld();
+    cs.lock();
+    int index = 0;
+    for (Entity* e : *entities)
+    {
+        if (e->getId() == id)
+        {
+            World::INSTANCE->setVisibility(e, 0);
+            entities->remove(index);
+            cs.unlock();
+            World::INSTANCE->unlockWorld();
+            return;
+        }
+        index++;
+    }
+    cs.unlock();
+    World::INSTANCE->unlockWorld();
 }
 }

+ 22 - 22
FactoryCraft/Dimension.h

@@ -1,8 +1,8 @@
 #pragma once
 #pragma once
 
 
 #include <Array.h>
 #include <Array.h>
-#include <Trie.h>
 #include <Critical.h>
 #include <Critical.h>
+#include <Trie.h>
 
 
 #include "Chunk.h"
 #include "Chunk.h"
 #include "Entity.h"
 #include "Entity.h"
@@ -12,28 +12,28 @@ class World;
 class Dimension : public virtual Framework::ReferenceCounter
 class Dimension : public virtual Framework::ReferenceCounter
 {
 {
 private:
 private:
-	Framework::Trie<Chunk>* chunks;
-	Framework::Array<Chunk*> chunkList;
-	Framework::RCArray<Entity>* entities;
-	Framework::Critical cs;
-	void getAddrOf(Framework::Punkt cPos, char* addr) const;
-	void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
+    Framework::Trie<Chunk>* chunks;
+    Framework::Array<Chunk*> chunkList;
+    Framework::RCArray<Entity>* entities;
+    Framework::Critical cs;
+    void getAddrOf(Framework::Punkt cPos, char* addr) const;
+    void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
 
 
 public:
 public:
-	Dimension();
-	~Dimension();
+    Dimension();
+    ~Dimension();
 
 
-	void api(char* message);
-	Block* zBlock(Framework::Vec3<int> location);
-	Block* getBlock(Framework::Vec3<int> location);
-	void addEntity(Entity* entity);
-	void setChunk(Chunk* chunk, Framework::Punkt center);
-	bool hasChunck(int x, int y) const;
-	Chunk* zChunk(Framework::Punkt wPos) const;
-	void removeDistantChunks(Framework::Punkt wPos);
-	void setBlock(Block* block);
-	void removeBlock(Block* zBlock);
-	Entity* zEntity(int id);
-	Entity* getEntity(int id);
-	void removeEntity(int id);
+    void api(char* message);
+    Block* zBlock(Framework::Vec3<int> location);
+    Block* getBlock(Framework::Vec3<int> location);
+    void addEntity(Entity* entity);
+    void setChunk(Chunk* chunk, Framework::Punkt center);
+    bool hasChunck(int x, int y) const;
+    Chunk* zChunk(Framework::Punkt wPos) const;
+    void removeDistantChunks(Framework::Punkt wPos);
+    void setBlock(Block* block);
+    void removeBlock(Block* zBlock);
+    Entity* zEntity(int id);
+    Entity* getEntity(int id);
+    void removeEntity(int id);
 };
 };

+ 55 - 52
FactoryCraft/DragController.h

@@ -1,62 +1,65 @@
 #pragma once
 #pragma once
 
 
 #include <Zeichnung.h>
 #include <Zeichnung.h>
+
 #include "DragElement.h"
 #include "DragElement.h"
 
 
-template<typename Source, typename Element>
-class DragController : public Framework::ReferenceCounter
+template<typename Source, typename Element> class DragController
+    : public Framework::ReferenceCounter
 {
 {
 private:
 private:
-	Source* container;
-	Element currentElement;
-	DragElement* drag;
-	std::function<void()> onDragEnd;
+    Source* container;
+    Element currentElement;
+    DragElement* drag;
+    std::function<void()> onDragEnd;
 
 
 public:
 public:
-	DragController()
-		: ReferenceCounter()
-	{
-		container = 0;
-		currentElement = 0;
-		drag = new DragElement();
-	}
-
-	~DragController()
-	{
-		if (this->container)
-			stopDrag();
-		drag->release();
-	}
-
-	void beginDrag(Source* container, Element element, Framework::Bild* zDragDisplay, std::function<void()> onDragEnd)
-	{
-		if (this->container)
-			stopDrag();
-		((BildZ*)drag)->setBildZ(dynamic_cast<Bild*>(zDragDisplay->getThis()));
-		window->zBildschirm()->addMember(dynamic_cast<Zeichnung*>(drag->getThis()));
-		this->container = container;
-		this->currentElement = element;
-		this->onDragEnd = onDragEnd;
-	}
-
-	Source* getCurrentDragContainer() const
-	{
-		return container;
-	}
-
-	Element getCurrentDaragElement() const
-	{
-		return currentElement;
-	}
-
-	void stopDrag()
-	{
-		if (container)
-		{
-			window->zBildschirm()->removeMember(drag);
-			onDragEnd();
-			container = 0;
-			currentElement = 0;
-		}
-	}
+    DragController()
+        : ReferenceCounter()
+    {
+        container = 0;
+        currentElement = 0;
+        drag = new DragElement();
+    }
+
+    ~DragController()
+    {
+        if (this->container) stopDrag();
+        drag->release();
+    }
+
+    void beginDrag(Source* container,
+        Element element,
+        Framework::Bild* zDragDisplay,
+        std::function<void()> onDragEnd)
+    {
+        if (this->container) stopDrag();
+        ((BildZ*)drag)->setBildZ(dynamic_cast<Bild*>(zDragDisplay->getThis()));
+        window->zBildschirm()->addMember(
+            dynamic_cast<Zeichnung*>(drag->getThis()));
+        this->container = container;
+        this->currentElement = element;
+        this->onDragEnd = onDragEnd;
+    }
+
+    Source* getCurrentDragContainer() const
+    {
+        return container;
+    }
+
+    Element getCurrentDaragElement() const
+    {
+        return currentElement;
+    }
+
+    void stopDrag()
+    {
+        if (container)
+        {
+            window->zBildschirm()->removeMember(drag);
+            onDragEnd();
+            container = 0;
+            currentElement = 0;
+        }
+    }
 };
 };

+ 2 - 3
FactoryCraft/DragElement.h

@@ -2,10 +2,9 @@
 
 
 #include <Bild.h>
 #include <Bild.h>
 
 
-
 class DragElement : public Framework::BildZ
 class DragElement : public Framework::BildZ
 {
 {
 public:
 public:
-	DragElement();
-	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+    DragElement();
+    void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
 };
 };

+ 508 - 431
FactoryCraft/Entity.cpp

@@ -1,466 +1,543 @@
+#include "Entity.h"
+
 #include <Globals.h>
 #include <Globals.h>
 
 
-#include "Entity.h"
-#include "Globals.h"
 #include "Game.h"
 #include "Game.h"
+#include "Globals.h"
 
 
-
-Entity::Entity(const EntityType* zType, Framework::Model3DData* model, Framework::Model3DTextur* texture, int id, Framework::Vec3<float> position, float maxMovementSpeed)
-	: Model3D(), id(id), zType(zType),
-	playerControlled(0),
-	maxMovementSpeed(maxMovementSpeed),
-	lastFlags(0),
-	timeSinceSync(0),
-	speed(0, 0, 0)
+Entity::Entity(const EntityType* zType,
+    Framework::Model3DData* model,
+    Framework::Model3DTextur* texture,
+    int id,
+    Framework::Vec3<float> position,
+    float maxMovementSpeed)
+    : Model3D(),
+      id(id),
+      zType(zType),
+      playerControlled(0),
+      maxMovementSpeed(maxMovementSpeed),
+      lastFlags(0),
+      timeSinceSync(0),
+      speed(0, 0, 0)
 {
 {
-	pos = position;
-	setModelDaten(model);
-	setModelTextur(texture);
-	lastDirection = World::INSTANCE->zKamera()->getDirection();
-	currentFrame.duration = 0;
-	rend = 1;
+    pos = position;
+    setModelDaten(model);
+    setModelTextur(texture);
+    lastDirection = World::INSTANCE->zKamera()->getDirection();
+    currentFrame.duration = 0;
+    rend = 1;
 }
 }
 
 
-Entity::~Entity()
-{}
+Entity::~Entity() {}
 
 
 void Entity::api(char* message)
 void Entity::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 0:
-	{ // add movement frame
-		if (!playerControlled)
-		{
-			MovementFrame frame;
-			frame.direction.x = *(float*)(message += 1);
-			frame.direction.y = *(float*)(message += 4);
-			frame.direction.z = *(float*)(message += 4);
-			frame.targetPosition.x = *(float*)(message += 4);
-			frame.targetPosition.y = *(float*)(message += 4);
-			frame.targetPosition.z = *(float*)(message += 4);
-			frame.movementFlags = *(int*)(message += 4);
-			frame.duration = *(double*)(message += 4);
-			cs.lock();
-			movements.add(frame);
-			cs.unlock();
-		}
-		break;
-	}
-	case 1:
-	{ // position correction
-		if (playerControlled)
-		{
-			timeSinceSync = 0;
-			pos.x = *(float*)(message += 1);
-			pos.y = *(float*)(message += 4);
-			pos.z = *(float*)(message += 4);
-			lastDirection = World::INSTANCE->zKamera()->getDirection();
-			lastFlags = 0;
-		}
-		break;
-	}
-	}
+    switch (message[0])
+    {
+    case 0:
+        { // add movement frame
+            if (!playerControlled)
+            {
+                MovementFrame frame;
+                frame.direction.x = *(float*)(message += 1);
+                frame.direction.y = *(float*)(message += 4);
+                frame.direction.z = *(float*)(message += 4);
+                frame.targetPosition.x = *(float*)(message += 4);
+                frame.targetPosition.y = *(float*)(message += 4);
+                frame.targetPosition.z = *(float*)(message += 4);
+                frame.movementFlags = *(int*)(message += 4);
+                frame.duration = *(double*)(message += 4);
+                cs.lock();
+                movements.add(frame);
+                cs.unlock();
+            }
+            break;
+        }
+    case 1:
+        { // position correction
+            if (playerControlled)
+            {
+                timeSinceSync = 0;
+                pos.x = *(float*)(message += 1);
+                pos.y = *(float*)(message += 4);
+                pos.z = *(float*)(message += 4);
+                lastDirection = World::INSTANCE->zKamera()->getDirection();
+                lastFlags = 0;
+            }
+            break;
+        }
+    }
 }
 }
 
 
 bool Entity::tick(double time)
 bool Entity::tick(double time)
 {
 {
-	if (playerControlled && GetForegroundWindow() == window->getFensterHandle())
-	{
-		Vec3<float> direction = World::INSTANCE->zKamera()->getDirection();
-		Vec3<float> lastPos = pos;
-		int flags = 0;
-		speed = { 0, 0, speed.z };
-		if (GetKeyState('w') & 0x8000 || GetKeyState('W') & 0x8000)
-		{
-			flags |= 1;
-			speed += {direction.x, direction.y, 0};
-		}
-		if (GetKeyState('a') & 0x8000 || GetKeyState('A') & 0x8000)
-		{
-			flags |= 2;
-			Vec2<float> norm = { direction.x, direction.y };
-			norm.CCW90().normalize();
-			speed += {norm.x, norm.y, 0};
-		}
-		if (GetKeyState('s') & 0x8000 || GetKeyState('S') & 0x8000)
-		{
-			flags |= 4;
-			speed += {-direction.x, -direction.y, 0};
-		}
-		if (GetKeyState('d') & 0x8000 || GetKeyState('D') & 0x8000)
-		{
-			flags |= 8;
-			Vec2<float> norm = { direction.x, direction.y };
-			norm.CW90().normalize();
-			speed += {norm.x, norm.y, 0};
-		}
-		if (GetKeyState(T_Shift) & 0x8000)
-		{
-			flags |= 16;
-			speed.z = -maxMovementSpeed;
-		}
-		else if (GetKeyState(T_Space) & 0x8000)
-		{
-			flags |= 32;
-			speed.z = maxMovementSpeed;
-		}
-		else
-		{
-			speed.z = 0.f;
-		}
-		Vec2<float> norm = { speed.x, speed.y };
-		if (norm.getLengthSq() != 0)
-		{
-			norm.normalize();
-			speed.x = norm.x * maxMovementSpeed;
-			speed.y = norm.y * maxMovementSpeed;
-		}
-		// collision checking
-		Vec3<float> minP = model->getMinPos();
-		Vec3<float> maxP = model->getMaxPos();
-		Vec3<float> worldBoundingBox[8];
-		worldBoundingBox[0] = applyWorldTransformation(minP);
-		worldBoundingBox[1] = applyWorldTransformation({ minP.x, minP.y, maxP.z });
-		worldBoundingBox[2] = applyWorldTransformation({ minP.x, maxP.y, minP.z });
-		worldBoundingBox[3] = applyWorldTransformation({ maxP.x, minP.y, minP.z });
-		worldBoundingBox[4] = applyWorldTransformation({ maxP.x, minP.y, maxP.z });
-		worldBoundingBox[5] = applyWorldTransformation({ maxP.x, maxP.y, minP.z });
-		worldBoundingBox[6] = applyWorldTransformation({ minP.x, maxP.y, maxP.z });
-		worldBoundingBox[7] = applyWorldTransformation(maxP);
-		Vec3<float> worldBoundingBoxFloor[8];
-		for (int i = 0; i < 8; i++)
-		{
-			worldBoundingBoxFloor[i] = Vec3<float>(floor(worldBoundingBox[i].x), floor(worldBoundingBox[i].y), floor(worldBoundingBox[i].z));
-		}
-		Vec3<float> frameSpeed = speed * (float)time;
-		bool hasCollided = 0;
-		while (true)
-		{
-			float tf = 1.f;
-			int collType = 0;
-			int updateType = 0;
-			int updateI = 0;
-			if (frameSpeed.x > 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.x) >= abs(worldBoundingBoxFloor[i].x + 1.f - worldBoundingBox[i].x))
-					{
-						float xt = (worldBoundingBoxFloor[i].x + 1.f - worldBoundingBox[i].x) / frameSpeed.x;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
-						if (tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x + 1, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (xt < tf)
-								{
-									tf = xt;
-									collType = 1;
-									updateType = 0;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (xt < tf)
-								{
-									tf = xt;
-									collType = 0;
-									updateType = 1;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (frameSpeed.x < 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.x) >= abs(worldBoundingBoxFloor[i].x - worldBoundingBox[i].x))
-					{
-						float xt = (worldBoundingBoxFloor[i].x - worldBoundingBox[i].x) / frameSpeed.x;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
-						if (tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x - 1, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (xt < tf)
-								{
-									tf = xt;
-									collType = 1;
-									updateType = 0;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (xt < tf)
-								{
-									tf = xt;
-									collType = 0;
-									updateType = 1;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (frameSpeed.y > 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.y) >= abs(worldBoundingBoxFloor[i].y + 1.f - worldBoundingBox[i].y))
-					{
-						float yt = (worldBoundingBoxFloor[i].y + 1.f - worldBoundingBox[i].y) / frameSpeed.y;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
-						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y + 1, (int)worldBoundingBoxFloor[i].z });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (yt < tf)
-								{
-									tf = yt;
-									collType = 2;
-									updateType = 0;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (yt < tf)
-								{
-									tf = yt;
-									collType = 0;
-									updateType = 2;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (frameSpeed.y < 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.y) >= abs(worldBoundingBoxFloor[i].y - worldBoundingBox[i].y))
-					{
-						float yt = (worldBoundingBoxFloor[i].y - worldBoundingBox[i].y) / frameSpeed.y;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
-						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y - 1, (int)worldBoundingBoxFloor[i].z });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (yt < tf)
-								{
-									tf = yt;
-									collType = 2;
-									updateType = 0;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (yt < tf)
-								{
-									tf = yt;
-									collType = 0;
-									updateType = 2;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (frameSpeed.z > 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.z) >= abs(worldBoundingBoxFloor[i].z + 1.f - worldBoundingBox[i].z))
-					{
-						float zt = (worldBoundingBoxFloor[i].z + 1.f - worldBoundingBox[i].z) / frameSpeed.z;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
-						if (zt <= 1.f && tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z + 1 });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (zt < tf)
-								{
-									tf = zt;
-									collType = 3;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (zt < tf)
-								{
-									tf = zt;
-									collType = 0;
-									updateType = 3;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (frameSpeed.z < 0)
-			{
-				for (int i = 0; i < 8; i++)
-				{
-					if (abs(frameSpeed.z) >= abs(worldBoundingBoxFloor[i].z - worldBoundingBox[i].z))
-					{
-						float zt = (worldBoundingBoxFloor[i].z - worldBoundingBox[i].z) / frameSpeed.z;
-						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
-						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1)
-						{
-							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z - 1 });
-							if (b) // TODO: ignore passable blocks
-							{
-								if (zt < tf)
-								{
-									tf = zt;
-									collType = 3;
-									updateType = 0;
-								}
-								hasCollided = 1;
-							}
-							else
-							{
-								if (zt < tf)
-								{
-									tf = zt;
-									collType = 0;
-									updateType = 3;
-									updateI = i;
-								}
-							}
-						}
-					}
-				}
-			}
-			if (collType == 1)
-				frameSpeed.x = tf > 0.1f ? frameSpeed.x * (tf - 0.1f) : 0.f;
-			if (collType == 2)
-				frameSpeed.y = tf > 0.1f ? frameSpeed.y * (tf - 0.1f) : 0.f;
-			if (collType == 3)
-				frameSpeed.z = tf > 0.1f ? frameSpeed.z * (tf - 0.1f) : 0.f;
-			if (updateType == 1)
-			{
-				if ((int)worldBoundingBoxFloor[updateI].x < (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
-					worldBoundingBoxFloor[updateI].x++;
-				if ((int)worldBoundingBoxFloor[updateI].x > (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
-					worldBoundingBoxFloor[updateI].x--;
-			}
-			if (updateType == 2)
-			{
-				if ((int)worldBoundingBoxFloor[updateI].y < (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
-					worldBoundingBoxFloor[updateI].y++;
-				if ((int)worldBoundingBoxFloor[updateI].y > (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
-					worldBoundingBoxFloor[updateI].y--;
-			}
-			if (updateType == 3)
-			{
-				if ((int)worldBoundingBoxFloor[updateI].z < (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
-					worldBoundingBoxFloor[updateI].z++;
-				if ((int)worldBoundingBoxFloor[updateI].z > (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
-					worldBoundingBoxFloor[updateI].z--;
-			}
-			if (updateType || collType)
-				continue;
-			break;
-		}
-		pos += frameSpeed;
-		World::INSTANCE->zKamera()->setPosition(pos + Vec3<float>(0.f, 0.f, 1.5f));
-		Model3D* target = World::INSTANCE->getCurrentTarget();
-		Block* b = target ? dynamic_cast<Block*>(target) : 0;
-		((Game*)(Menu*)menuRegister->get("game"))->updatePosition(pos, b != 0, b ? b->getLocation() : Vec3<int>(0, 0, 0));
-		if(target)
-			target->release();
-		if (flags != lastFlags || direction != lastDirection || timeSinceSync >= 1 || hasCollided)
-		{
-			if (timeSinceSync > 0)
-			{
-				MovementFrame frame;
-				frame.direction = lastDirection;
-				frame.targetPosition = lastPos;
-				frame.movementFlags = lastFlags;
-				frame.duration = timeSinceSync;
-				World::INSTANCE->zClient()->sendPlayerMovement(frame);
-			}
-			lastFlags = flags;
-			lastDirection = direction;
-			timeSinceSync = 0;
-		}
-		timeSinceSync += time;
-		rend = 1;
-	}
-	else
-	{
-		double totalTime = time;
-		while (totalTime > 0)
-		{
-			if (currentFrame.duration <= 0)
-			{
-				if (movements.getEintragAnzahl() > 0)
-				{
-					currentFrame = movements.get(0);
-					cs.lock();
-					movements.remove(0);
-					cs.unlock();
-				}
-				else
-				{
-					break;
-				}
-			}
-			double t = min(currentFrame.duration, totalTime);
-			pos += (currentFrame.targetPosition - pos) * (float)(t / currentFrame.duration);
-			currentFrame.duration -= t;
-			totalTime -= t;
-			if (currentFrame.duration <= 0)
-			{
-				pos = currentFrame.targetPosition;
-			}
-			rend = 1;
-		}
-	}
-	return Model3D::tick(time);
+    if (playerControlled && GetForegroundWindow() == window->getFensterHandle())
+    {
+        Vec3<float> direction = World::INSTANCE->zKamera()->getDirection();
+        Vec3<float> lastPos = pos;
+        int flags = 0;
+        speed = {0, 0, speed.z};
+        if (GetKeyState('w') & 0x8000 || GetKeyState('W') & 0x8000)
+        {
+            flags |= 1;
+            speed += {direction.x, direction.y, 0};
+        }
+        if (GetKeyState('a') & 0x8000 || GetKeyState('A') & 0x8000)
+        {
+            flags |= 2;
+            Vec2<float> norm = {direction.x, direction.y};
+            norm.CCW90().normalize();
+            speed += {norm.x, norm.y, 0};
+        }
+        if (GetKeyState('s') & 0x8000 || GetKeyState('S') & 0x8000)
+        {
+            flags |= 4;
+            speed += {-direction.x, -direction.y, 0};
+        }
+        if (GetKeyState('d') & 0x8000 || GetKeyState('D') & 0x8000)
+        {
+            flags |= 8;
+            Vec2<float> norm = {direction.x, direction.y};
+            norm.CW90().normalize();
+            speed += {norm.x, norm.y, 0};
+        }
+        if (GetKeyState(T_Shift) & 0x8000)
+        {
+            flags |= 16;
+            speed.z = -maxMovementSpeed;
+        }
+        else if (GetKeyState(T_Space) & 0x8000)
+        {
+            flags |= 32;
+            speed.z = maxMovementSpeed;
+        }
+        else
+        {
+            speed.z = 0.f;
+        }
+        Vec2<float> norm = {speed.x, speed.y};
+        if (norm.getLengthSq() != 0)
+        {
+            norm.normalize();
+            speed.x = norm.x * maxMovementSpeed;
+            speed.y = norm.y * maxMovementSpeed;
+        }
+        // collision checking
+        Vec3<float> minP = model->getMinPos();
+        Vec3<float> maxP = model->getMaxPos();
+        Vec3<float> worldBoundingBox[8];
+        worldBoundingBox[0] = applyWorldTransformation(minP);
+        worldBoundingBox[1]
+            = applyWorldTransformation({minP.x, minP.y, maxP.z});
+        worldBoundingBox[2]
+            = applyWorldTransformation({minP.x, maxP.y, minP.z});
+        worldBoundingBox[3]
+            = applyWorldTransformation({maxP.x, minP.y, minP.z});
+        worldBoundingBox[4]
+            = applyWorldTransformation({maxP.x, minP.y, maxP.z});
+        worldBoundingBox[5]
+            = applyWorldTransformation({maxP.x, maxP.y, minP.z});
+        worldBoundingBox[6]
+            = applyWorldTransformation({minP.x, maxP.y, maxP.z});
+        worldBoundingBox[7] = applyWorldTransformation(maxP);
+        Vec3<float> worldBoundingBoxFloor[8];
+        for (int i = 0; i < 8; i++)
+        {
+            worldBoundingBoxFloor[i] = Vec3<float>(floor(worldBoundingBox[i].x),
+                floor(worldBoundingBox[i].y),
+                floor(worldBoundingBox[i].z));
+        }
+        Vec3<float> frameSpeed = speed * (float)time;
+        bool hasCollided = 0;
+        while (true)
+        {
+            float tf = 1.f;
+            int collType = 0;
+            int updateType = 0;
+            int updateI = 0;
+            if (frameSpeed.x > 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.x) >= abs(worldBoundingBoxFloor[i].x
+                                                 + 1.f - worldBoundingBox[i].x))
+                    {
+                        float xt = (worldBoundingBoxFloor[i].x + 1.f
+                                       - worldBoundingBox[i].x)
+                                 / frameSpeed.x;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
+                        if (tmp.y >= worldBoundingBoxFloor[i].y
+                            && tmp.y < worldBoundingBoxFloor[i].y + 1.f
+                            && tmp.z >= worldBoundingBoxFloor[i].z
+                            && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x + 1,
+                                    (int)worldBoundingBoxFloor[i].y,
+                                    (int)worldBoundingBoxFloor[i].z});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (xt < tf)
+                                {
+                                    tf = xt;
+                                    collType = 1;
+                                    updateType = 0;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (xt < tf)
+                                {
+                                    tf = xt;
+                                    collType = 0;
+                                    updateType = 1;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (frameSpeed.x < 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.x) >= abs(
+                            worldBoundingBoxFloor[i].x - worldBoundingBox[i].x))
+                    {
+                        float xt = (worldBoundingBoxFloor[i].x
+                                       - worldBoundingBox[i].x)
+                                 / frameSpeed.x;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
+                        if (tmp.y >= worldBoundingBoxFloor[i].y
+                            && tmp.y < worldBoundingBoxFloor[i].y + 1.f
+                            && tmp.z >= worldBoundingBoxFloor[i].z
+                            && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x - 1,
+                                    (int)worldBoundingBoxFloor[i].y,
+                                    (int)worldBoundingBoxFloor[i].z});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (xt < tf)
+                                {
+                                    tf = xt;
+                                    collType = 1;
+                                    updateType = 0;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (xt < tf)
+                                {
+                                    tf = xt;
+                                    collType = 0;
+                                    updateType = 1;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (frameSpeed.y > 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.y) >= abs(worldBoundingBoxFloor[i].y
+                                                 + 1.f - worldBoundingBox[i].y))
+                    {
+                        float yt = (worldBoundingBoxFloor[i].y + 1.f
+                                       - worldBoundingBox[i].y)
+                                 / frameSpeed.y;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
+                        if (tmp.x >= worldBoundingBoxFloor[i].x
+                            && tmp.x < worldBoundingBoxFloor[i].x + 1.f
+                            && tmp.z >= worldBoundingBoxFloor[i].z
+                            && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x,
+                                    (int)worldBoundingBoxFloor[i].y + 1,
+                                    (int)worldBoundingBoxFloor[i].z});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (yt < tf)
+                                {
+                                    tf = yt;
+                                    collType = 2;
+                                    updateType = 0;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (yt < tf)
+                                {
+                                    tf = yt;
+                                    collType = 0;
+                                    updateType = 2;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (frameSpeed.y < 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.y) >= abs(
+                            worldBoundingBoxFloor[i].y - worldBoundingBox[i].y))
+                    {
+                        float yt = (worldBoundingBoxFloor[i].y
+                                       - worldBoundingBox[i].y)
+                                 / frameSpeed.y;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
+                        if (tmp.x >= worldBoundingBoxFloor[i].x
+                            && tmp.x < worldBoundingBoxFloor[i].x + 1.f
+                            && tmp.z >= worldBoundingBoxFloor[i].z
+                            && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x,
+                                    (int)worldBoundingBoxFloor[i].y - 1,
+                                    (int)worldBoundingBoxFloor[i].z});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (yt < tf)
+                                {
+                                    tf = yt;
+                                    collType = 2;
+                                    updateType = 0;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (yt < tf)
+                                {
+                                    tf = yt;
+                                    collType = 0;
+                                    updateType = 2;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (frameSpeed.z > 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.z) >= abs(worldBoundingBoxFloor[i].z
+                                                 + 1.f - worldBoundingBox[i].z))
+                    {
+                        float zt = (worldBoundingBoxFloor[i].z + 1.f
+                                       - worldBoundingBox[i].z)
+                                 / frameSpeed.z;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
+                        if (zt <= 1.f && tmp.x >= worldBoundingBoxFloor[i].x
+                            && tmp.x < worldBoundingBoxFloor[i].x + 1.f
+                            && tmp.y >= worldBoundingBoxFloor[i].y
+                            && tmp.y < worldBoundingBoxFloor[i].y + 1.f)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x,
+                                    (int)worldBoundingBoxFloor[i].y,
+                                    (int)worldBoundingBoxFloor[i].z + 1});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (zt < tf)
+                                {
+                                    tf = zt;
+                                    collType = 3;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (zt < tf)
+                                {
+                                    tf = zt;
+                                    collType = 0;
+                                    updateType = 3;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (frameSpeed.z < 0)
+            {
+                for (int i = 0; i < 8; i++)
+                {
+                    if (abs(frameSpeed.z) >= abs(
+                            worldBoundingBoxFloor[i].z - worldBoundingBox[i].z))
+                    {
+                        float zt = (worldBoundingBoxFloor[i].z
+                                       - worldBoundingBox[i].z)
+                                 / frameSpeed.z;
+                        Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
+                        if (tmp.x >= worldBoundingBoxFloor[i].x
+                            && tmp.x < worldBoundingBoxFloor[i].x + 1.f
+                            && tmp.y >= worldBoundingBoxFloor[i].y
+                            && tmp.y < worldBoundingBoxFloor[i].y + 1)
+                        {
+                            Block* b = World::INSTANCE->zBlockAt(
+                                Vec3<int>{(int)worldBoundingBoxFloor[i].x,
+                                    (int)worldBoundingBoxFloor[i].y,
+                                    (int)worldBoundingBoxFloor[i].z - 1});
+                            if (b) // TODO: ignore passable blocks
+                            {
+                                if (zt < tf)
+                                {
+                                    tf = zt;
+                                    collType = 3;
+                                    updateType = 0;
+                                }
+                                hasCollided = 1;
+                            }
+                            else
+                            {
+                                if (zt < tf)
+                                {
+                                    tf = zt;
+                                    collType = 0;
+                                    updateType = 3;
+                                    updateI = i;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (collType == 1)
+                frameSpeed.x = tf > 0.1f ? frameSpeed.x * (tf - 0.1f) : 0.f;
+            if (collType == 2)
+                frameSpeed.y = tf > 0.1f ? frameSpeed.y * (tf - 0.1f) : 0.f;
+            if (collType == 3)
+                frameSpeed.z = tf > 0.1f ? frameSpeed.z * (tf - 0.1f) : 0.f;
+            if (updateType == 1)
+            {
+                if ((int)worldBoundingBoxFloor[updateI].x
+                    < (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
+                    worldBoundingBoxFloor[updateI].x++;
+                if ((int)worldBoundingBoxFloor[updateI].x
+                    > (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
+                    worldBoundingBoxFloor[updateI].x--;
+            }
+            if (updateType == 2)
+            {
+                if ((int)worldBoundingBoxFloor[updateI].y
+                    < (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
+                    worldBoundingBoxFloor[updateI].y++;
+                if ((int)worldBoundingBoxFloor[updateI].y
+                    > (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
+                    worldBoundingBoxFloor[updateI].y--;
+            }
+            if (updateType == 3)
+            {
+                if ((int)worldBoundingBoxFloor[updateI].z
+                    < (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
+                    worldBoundingBoxFloor[updateI].z++;
+                if ((int)worldBoundingBoxFloor[updateI].z
+                    > (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
+                    worldBoundingBoxFloor[updateI].z--;
+            }
+            if (updateType || collType) continue;
+            break;
+        }
+        pos += frameSpeed;
+        World::INSTANCE->zKamera()->setPosition(
+            pos + Vec3<float>(0.f, 0.f, 1.5f));
+        Model3D* target = World::INSTANCE->getCurrentTarget();
+        Block* b = target ? dynamic_cast<Block*>(target) : 0;
+        ((Game*)(Menu*)menuRegister->get("game"))
+            ->updatePosition(
+                pos, b != 0, b ? b->getLocation() : Vec3<int>(0, 0, 0));
+        if (target) target->release();
+        if (flags != lastFlags || direction != lastDirection
+            || timeSinceSync >= 1 || hasCollided)
+        {
+            if (timeSinceSync > 0)
+            {
+                MovementFrame frame;
+                frame.direction = lastDirection;
+                frame.targetPosition = lastPos;
+                frame.movementFlags = lastFlags;
+                frame.duration = timeSinceSync;
+                World::INSTANCE->zClient()->sendPlayerMovement(frame);
+            }
+            lastFlags = flags;
+            lastDirection = direction;
+            timeSinceSync = 0;
+        }
+        timeSinceSync += time;
+        rend = 1;
+    }
+    else
+    {
+        double totalTime = time;
+        while (totalTime > 0)
+        {
+            if (currentFrame.duration <= 0)
+            {
+                if (movements.getEintragAnzahl() > 0)
+                {
+                    currentFrame = movements.get(0);
+                    cs.lock();
+                    movements.remove(0);
+                    cs.unlock();
+                }
+                else
+                {
+                    break;
+                }
+            }
+            double t = min(currentFrame.duration, totalTime);
+            pos += (currentFrame.targetPosition - pos)
+                 * (float)(t / currentFrame.duration);
+            currentFrame.duration -= t;
+            totalTime -= t;
+            if (currentFrame.duration <= 0)
+            {
+                pos = currentFrame.targetPosition;
+            }
+            rend = 1;
+        }
+    }
+    return Model3D::tick(time);
 }
 }
 
 
 int Entity::getId() const
 int Entity::getId() const
 {
 {
-	return id;
+    return id;
 }
 }
 
 
 const EntityType* Entity::zEntityType() const
 const EntityType* Entity::zEntityType() const
 {
 {
-	return zType;
+    return zType;
 }
 }
 
 
 void Entity::lock()
 void Entity::lock()
 {
 {
-	cs.lock();
+    cs.lock();
 }
 }
 
 
 void Entity::unlock()
 void Entity::unlock()
 {
 {
-	cs.unlock();
+    cs.unlock();
 }
 }
 
 
 void Entity::setPlayerControlled()
 void Entity::setPlayerControlled()
 {
 {
-	playerControlled = 1;
-	World::INSTANCE->zKamera()->setPosition(pos + Vec3<float>(0.f, 0.f, 1.5f));
+    playerControlled = 1;
+    World::INSTANCE->zKamera()->setPosition(pos + Vec3<float>(0.f, 0.f, 1.5f));
 }
 }

+ 34 - 29
FactoryCraft/Entity.h

@@ -1,47 +1,52 @@
 #pragma once
 #pragma once
 
 
-#include <Model3D.h>
-#include <Either.h>
 #include <Critical.h>
 #include <Critical.h>
+#include <Either.h>
+#include <Model3D.h>
 
 
-#include "EntityType.h"
 #include "Area.h"
 #include "Area.h"
+#include "EntityType.h"
 
 
 class Block;
 class Block;
 
 
 struct MovementFrame
 struct MovementFrame
 {
 {
-	Framework::Vec3<float> direction;
-	Framework::Vec3<float> targetPosition;
-	int movementFlags;
-	double duration;
+    Framework::Vec3<float> direction;
+    Framework::Vec3<float> targetPosition;
+    int movementFlags;
+    double duration;
 };
 };
 
 
 class Entity : public Framework::Model3D
 class Entity : public Framework::Model3D
 {
 {
 private:
 private:
-	int id;
-	const EntityType* zType;
-	Framework::Critical cs;
-	bool playerControlled;
-	float maxMovementSpeed;
-	int lastFlags;
-	double timeSinceSync;
-	Framework::Vec3<float> lastDirection;
-	Framework::Array< MovementFrame > movements;
-	Framework::Vec3<float> speed;
-	MovementFrame currentFrame;
+    int id;
+    const EntityType* zType;
+    Framework::Critical cs;
+    bool playerControlled;
+    float maxMovementSpeed;
+    int lastFlags;
+    double timeSinceSync;
+    Framework::Vec3<float> lastDirection;
+    Framework::Array<MovementFrame> movements;
+    Framework::Vec3<float> speed;
+    MovementFrame currentFrame;
 
 
 public:
 public:
-	Entity(const EntityType* zType, Framework::Model3DData* model, Framework::Model3DTextur* texture, int id, Framework::Vec3<float> position, float maxMovementSpeed);
-	~Entity();
-
-	void api(char* message);
-	bool tick(double time) override;
-
-	int getId() const;
-	const EntityType* zEntityType() const;
-	void lock();
-	void unlock();
-	void setPlayerControlled();
+    Entity(const EntityType* zType,
+        Framework::Model3DData* model,
+        Framework::Model3DTextur* texture,
+        int id,
+        Framework::Vec3<float> position,
+        float maxMovementSpeed);
+    ~Entity();
+
+    void api(char* message);
+    bool tick(double time) override;
+
+    int getId() const;
+    const EntityType* zEntityType() const;
+    void lock();
+    void unlock();
+    void setPlayerControlled();
 };
 };

+ 5 - 5
FactoryCraft/EntityRemovedUpdate.cpp

@@ -1,14 +1,14 @@
 #include "EntityRemovedUpdate.h"
 #include "EntityRemovedUpdate.h"
-#include "Globals.h"
 
 
+#include "Globals.h"
 
 
 EntityRemovedUpdateType::EntityRemovedUpdateType()
 EntityRemovedUpdateType::EntityRemovedUpdateType()
-	: WorldUpdateType(ID)
+    : WorldUpdateType(ID)
 {}
 {}
 
 
 void EntityRemovedUpdateType::applyUpdate(Framework::StreamReader* zReader)
 void EntityRemovedUpdateType::applyUpdate(Framework::StreamReader* zReader)
 {
 {
-	int id;
-	zReader->lese((char*)&id, 4);
-	World::INSTANCE->removeEntity(id);
+    int id;
+    zReader->lese((char*)&id, 4);
+    World::INSTANCE->removeEntity(id);
 }
 }

+ 3 - 3
FactoryCraft/EntityRemovedUpdate.h

@@ -4,11 +4,11 @@
 
 
 class EntityRemovedUpdateType : WorldUpdateType
 class EntityRemovedUpdateType : WorldUpdateType
 {
 {
-	REGISTRABLE(EntityRemovedUpdateType)
+    REGISTRABLE(EntityRemovedUpdateType)
 
 
 protected:
 protected:
-	EntityRemovedUpdateType();
-	void applyUpdate(Framework::StreamReader* zReader) override;
+    EntityRemovedUpdateType();
+    void applyUpdate(Framework::StreamReader* zReader) override;
 };
 };
 
 
 REGISTER(EntityRemovedUpdateType, WorldUpdateType)
 REGISTER(EntityRemovedUpdateType, WorldUpdateType)

+ 32 - 30
FactoryCraft/EntityType.cpp

@@ -1,44 +1,46 @@
 #include "EntityType.h"
 #include "EntityType.h"
+
 #include "Entity.h"
 #include "Entity.h"
-#include "Registries.h"
 #include "Globals.h"
 #include "Globals.h"
-
+#include "Registries.h"
 
 
 EntityType::EntityType(int id, ModelInfo model)
 EntityType::EntityType(int id, ModelInfo model)
-	: id(id),
-	model(model)
+    : id(id),
+      model(model)
 {}
 {}
 
 
 Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
 Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
 {
 {
-	int id;
-	zReader->lese((char*)&id, 4);
-	Framework::Vec3<float> position;
-	zReader->lese((char*)&position.x, 4);
-	zReader->lese((char*)&position.y, 4);
-	zReader->lese((char*)&position.z, 4);
-	float maxSpeed;
-	zReader->lese((char*)&maxSpeed, 4);
-	bool specialModel = 0;
-	zReader->lese((char*)&specialModel, 1);
-	Entity* e;
-	if (specialModel)
-	{
-		ModelInfo model(zReader);
-		e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
-	}
-	else
-	{
-		e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
-	}
-	if (World::INSTANCE->zKamera()->getEntityId() == id)
-	{
-		e->setPlayerControlled();
-	}
-	return e;
+    int id;
+    zReader->lese((char*)&id, 4);
+    Framework::Vec3<float> position;
+    zReader->lese((char*)&position.x, 4);
+    zReader->lese((char*)&position.y, 4);
+    zReader->lese((char*)&position.z, 4);
+    float maxSpeed;
+    zReader->lese((char*)&maxSpeed, 4);
+    bool specialModel = 0;
+    zReader->lese((char*)&specialModel, 1);
+    Entity* e;
+    if (specialModel)
+    {
+        ModelInfo model(zReader);
+        e = new Entity(
+            this, model.getModel(), model.getTexture(), id, position, maxSpeed);
+    }
+    else
+    {
+        e = new Entity(
+            this, model.getModel(), model.getTexture(), id, position, maxSpeed);
+    }
+    if (World::INSTANCE->zKamera()->getEntityId() == id)
+    {
+        e->setPlayerControlled();
+    }
+    return e;
 }
 }
 
 
 int EntityType::getId() const
 int EntityType::getId() const
 {
 {
-	return id;
+    return id;
 }
 }

+ 6 - 6
FactoryCraft/EntityType.h

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
-#include <ReferenceCounter.h>
 #include <Reader.h>
 #include <Reader.h>
+#include <ReferenceCounter.h>
 #include <Vec3.h>
 #include <Vec3.h>
 
 
 #include "ModelInfo.h"
 #include "ModelInfo.h"
@@ -11,11 +11,11 @@ class Entity;
 class EntityType : public virtual Framework::ReferenceCounter
 class EntityType : public virtual Framework::ReferenceCounter
 {
 {
 private:
 private:
-	const int id;
-	ModelInfo model;
+    const int id;
+    ModelInfo model;
 
 
 public:
 public:
-	EntityType(int id, ModelInfo model);
-	Entity* loadEntity(Framework::StreamReader* zReader) const;
-	int getId() const;
+    EntityType(int id, ModelInfo model);
+    Entity* loadEntity(Framework::StreamReader* zReader) const;
+    int getId() const;
 };
 };

+ 19 - 18
FactoryCraft/Equipment.cpp

@@ -1,53 +1,54 @@
-#include <XML.h>
-
 #include "Equipment.h"
 #include "Equipment.h"
 
 
+#include <XML.h>
+
 using namespace Framework;
 using namespace Framework;
 
 
 EquipmentElement::EquipmentElement()
 EquipmentElement::EquipmentElement()
-	: UIMLElement()
+    : UIMLElement()
 {}
 {}
 
 
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 bool EquipmentElement::isApplicableFor(Framework::XML::Element& element)
 bool EquipmentElement::isApplicableFor(Framework::XML::Element& element)
 {
 {
-	return element.getName().istGleich("equipment");
+    return element.getName().istGleich("equipment");
 }
 }
 
 
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-Framework::Zeichnung* EquipmentElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+Framework::Zeichnung* EquipmentElement::parseElement(
+    Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
 {
 {
-	return new EquipmentView((int)element.getAttributeValue("entity"));
+    return new EquipmentView((int)element.getAttributeValue("entity"));
 }
 }
 
 
 //! wendet die layout parameter zu einer Zeichnung an
 //! wendet die layout parameter zu einer Zeichnung an
-void EquipmentElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+void EquipmentElement::layout(Framework::XML::Element& element,
+    Framework::Zeichnung& z,
+    int pWidth,
+    int pHeight,
+    Framework::UIMLContainer& generalLayouter)
 {
 {
-	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+    UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
 }
 }
 
 
-
 EquipmentView::EquipmentView(int entityId)
 EquipmentView::EquipmentView(int entityId)
-	: ZeichnungHintergrund(),
-	entityId(entityId)
+    : ZeichnungHintergrund(),
+      entityId(entityId)
 {}
 {}
 
 
-void EquipmentView::api(char* message)
-{
-
-}
+void EquipmentView::api(char* message) {}
 
 
 bool EquipmentView::tick(double tickVal)
 bool EquipmentView::tick(double tickVal)
 {
 {
-	return ZeichnungHintergrund::tick(tickVal);
+    return ZeichnungHintergrund::tick(tickVal);
 }
 }
 
 
 void EquipmentView::render(Bild& rObj)
 void EquipmentView::render(Bild& rObj)
 {
 {
-	ZeichnungHintergrund::render(rObj);
+    ZeichnungHintergrund::render(rObj);
 }
 }
 
 
 void EquipmentView::doMausEreignis(MausEreignis& me, bool userRet)
 void EquipmentView::doMausEreignis(MausEreignis& me, bool userRet)
 {
 {
-	ZeichnungHintergrund::doMausEreignis(me, userRet);
+    ZeichnungHintergrund::doMausEreignis(me, userRet);
 }
 }

+ 23 - 16
FactoryCraft/Equipment.h

@@ -1,30 +1,37 @@
 #pragma once
 #pragma once
 
 
-#include "NetworkAPIProcessor.h"
-
 #include <UIMLView.h>
 #include <UIMLView.h>
 
 
+#include "NetworkAPIProcessor.h"
+
 class EquipmentElement : public Framework::UIMLElement
 class EquipmentElement : public Framework::UIMLElement
 {
 {
 public:
 public:
-	EquipmentElement();
-	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
-	bool isApplicableFor(Framework::XML::Element& element) override;
-	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
-	//! wendet die layout parameter zu einer Zeichnung an
-	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+    EquipmentElement();
+    //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
+    //! ist
+    bool isApplicableFor(Framework::XML::Element& element) override;
+    //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+    Framework::Zeichnung* parseElement(Framework::XML::Element& element,
+        Framework::UIMLContainer& generalFactory) override;
+    //! wendet die layout parameter zu einer Zeichnung an
+    void layout(Framework::XML::Element& element,
+        Framework::Zeichnung& z,
+        int pWidth,
+        int pHeight,
+        Framework::UIMLContainer& generalLayouter) override;
 };
 };
 
 
-class EquipmentView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor
+class EquipmentView : public Framework::ZeichnungHintergrund,
+                      public NetworkAPIProcessor
 {
 {
 private:
 private:
-	int entityId;
+    int entityId;
 
 
 public:
 public:
-	EquipmentView(int entityId);
-	void api(char* message) override;
-	bool tick(double tickVal) override;
-	void render(Framework::Bild& rObj) override;
-	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+    EquipmentView(int entityId);
+    void api(char* message) override;
+    bool tick(double tickVal) override;
+    void render(Framework::Bild& rObj) override;
+    void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
 };
 };

+ 34 - 29
FactoryCraft/FactoryClient.h

@@ -1,46 +1,51 @@
 #pragma once
 #pragma once
 
 
-#include <Network.h>
+#include <Critical.h>
+#include <Either.h>
 #include <Klient.h>
 #include <Klient.h>
+#include <Network.h>
+#include <Punkt.h>
 #include <Text.h>
 #include <Text.h>
 #include <Thread.h>
 #include <Thread.h>
-#include <Critical.h>
 #include <VecN.h>
 #include <VecN.h>
-#include <Either.h>
-#include <Punkt.h>
 
 
 #include "Entity.h"
 #include "Entity.h"
 
 
 class FactoryClient : public Framework::ReferenceCounter
 class FactoryClient : public Framework::ReferenceCounter
 {
 {
 private:
 private:
-	Network::SSLKlient* client;
-	Network::Klient* foreground;
-	Network::Klient* background;
-	Network::NetworkReader* foregroundReader;
-	Network::NetworkReader* backgroundReader;
-	Framework::Critical cs;
-	Framework::Text ip;
-	int bgReaderUsage;
-	int fgReaderUsage;
+    Network::SSLKlient* client;
+    Network::Klient* foreground;
+    Network::Klient* background;
+    Network::NetworkReader* foregroundReader;
+    Network::NetworkReader* backgroundReader;
+    Framework::Critical cs;
+    Framework::Text ip;
+    int bgReaderUsage;
+    int fgReaderUsage;
 
 
-	void disconnect();
-	void loadServerInfo();
+    void disconnect();
+    void loadServerInfo();
 
 
 public:
 public:
-	FactoryClient();
-	~FactoryClient();
+    FactoryClient();
+    ~FactoryClient();
 
 
-	bool connect(Framework::Text ip, unsigned short sslPort);
-	int ping();
-	int status(Framework::Text name, Framework::Text secret);
-	int join(Framework::Text name, Framework::Text &secret, unsigned short port);
-	Network::NetworkReader* getNextForegroundMessage();
-	Network::NetworkReader* getNextBackgroundMessage();
-	void endMessageReading(bool bg);
-	void sendPlayerAction(char* data, unsigned short length);
-	void sendPlayerMovement(MovementFrame& frame);
-	void entityAPIRequest(int entityId, char* message, unsigned short length);
-	void chunkAPIRequest(Framework::Punkt center, char* message, unsigned short length);
-	void inventoryAPIRequest(Framework::Either<int, Framework::VecN<int, 4>> target, char* message, unsigned short length);
+    bool connect(Framework::Text ip, unsigned short sslPort);
+    int ping();
+    int status(Framework::Text name, Framework::Text secret);
+    int join(
+        Framework::Text name, Framework::Text& secret, unsigned short port);
+    Network::NetworkReader* getNextForegroundMessage();
+    Network::NetworkReader* getNextBackgroundMessage();
+    void endMessageReading(bool bg);
+    void sendPlayerAction(char* data, unsigned short length);
+    void sendPlayerMovement(MovementFrame& frame);
+    void entityAPIRequest(int entityId, char* message, unsigned short length);
+    void chunkAPIRequest(
+        Framework::Punkt center, char* message, unsigned short length);
+    void inventoryAPIRequest(
+        Framework::Either<int, Framework::VecN<int, 4>> target,
+        char* message,
+        unsigned short length);
 };
 };

+ 154 - 147
FactoryCraft/Game.cpp

@@ -1,174 +1,181 @@
 #include "Game.h"
 #include "Game.h"
-#include "Initialisierung.h"
-#include "Globals.h"
-#include "ItemBar.h"
 
 
 #include <AsynchronCall.h>
 #include <AsynchronCall.h>
 #include <Bildschirm.h>
 #include <Bildschirm.h>
 
 
+#include "Globals.h"
+#include "Initialisierung.h"
+#include "ItemBar.h"
+
 Game::Game(Bildschirm* zScreen)
 Game::Game(Bildschirm* zScreen)
-	: Menu(zScreen)
+    : Menu(zScreen)
 {
 {
-	inventoryDragController = new DragController<InventoryDragSource, int>();
-	logout = initKnopf(10, 10, 200, 20, Knopf::Style::Normal, "Verlassen");
-	logout->setMausEreignis([this, zScreen](void* p, void* o, MausEreignis me)
-		{
-			if (me.id == ME_RLinks)
-			{
-				logout->removeStyle(Knopf::Style::Erlaubt);
-				new AsynchronCall([this, zScreen]()
-					{
-						// TODO
-						/*if (World::INSTANCE->zClient()->leaveGame())
-						{
-							World::INSTANCE->release();
-							World::INSTANCE = 0;
-							zScreen->lock();
-							hide();
-							menuRegister->get("directConnect")->show();
-							zScreen->unlock();
-						}*/ 
-						logout->addStyle(Knopf::Style::Erlaubt);
-					});
-			}
-			return 1;
-		});
-	elements.add(logout);
-	debug = initTextFeld(10, 40, 500, 250, TextFeld::Style::Text | TextFeld::Style::Mehrzeilig, "");
-	elements.add(debug);
-	guiView = new UIMLView("<v/>", uiFactory);
-	guiView->addKnownElement(new ItemBarElement());
-	guiView->setStyle(UIMLView::Style::Sichtbar);
-	guiView->setSize(window->zBildschirm()->getBackBufferSize());
-	elements.add(guiView);
+    inventoryDragController = new DragController<InventoryDragSource, int>();
+    logout = initKnopf(10, 10, 200, 20, Knopf::Style::Normal, "Verlassen");
+    logout->setMausEreignis([this, zScreen](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            logout->removeStyle(Knopf::Style::Erlaubt);
+            new AsynchronCall([this, zScreen]() {
+                // TODO
+                /*if (World::INSTANCE->zClient()->leaveGame())
+                {
+                    World::INSTANCE->release();
+                    World::INSTANCE = 0;
+                    zScreen->lock();
+                    hide();
+                    menuRegister->get("directConnect")->show();
+                    zScreen->unlock();
+                }*/
+                logout->addStyle(Knopf::Style::Erlaubt);
+            });
+        }
+        return 1;
+    });
+    elements.add(logout);
+    debug = initTextFeld(10,
+        40,
+        500,
+        250,
+        TextFeld::Style::Text | TextFeld::Style::Mehrzeilig,
+        "");
+    elements.add(debug);
+    guiView = new UIMLView("<v/>", uiFactory);
+    guiView->addKnownElement(new ItemBarElement());
+    guiView->setStyle(UIMLView::Style::Sichtbar);
+    guiView->setSize(window->zBildschirm()->getBackBufferSize());
+    elements.add(guiView);
 }
 }
 
 
 Game::~Game()
 Game::~Game()
 {
 {
-	inventoryDragController->release();
+    inventoryDragController->release();
 }
 }
 
 
-void Game::updatePosition(Vec3<float> position, bool target, Vec3<int> targetPos)
+void Game::updatePosition(
+    Vec3<float> position, bool target, Vec3<int> targetPos)
 {
 {
-	Text txt = "Position: (";
-	txt.setPrecision(2);
-	txt += position.x;
-	txt += ", ";
-	txt += position.y;
-	txt += ", ";
-	txt += position.z;
-	txt += ")";
-	if (target)
-	{
-		txt += "\nTarget: (";
-		txt += targetPos.x;
-		txt += ", ";
-		txt += targetPos.y;
-		txt += ", ";
-		txt += targetPos.z;
-		txt += ")\n";
-		Block* b = World::INSTANCE->zBlockAt(targetPos);
-		if (b)
-		{
-			txt += "TargetLight: \n";
-			txt += b->printLightInfo();
-		}
-	}
-	debug->setText(txt);
+    Text txt = "Position: (";
+    txt.setPrecision(2);
+    txt += position.x;
+    txt += ", ";
+    txt += position.y;
+    txt += ", ";
+    txt += position.z;
+    txt += ")";
+    if (target)
+    {
+        txt += "\nTarget: (";
+        txt += targetPos.x;
+        txt += ", ";
+        txt += targetPos.y;
+        txt += ", ";
+        txt += targetPos.z;
+        txt += ")\n";
+        Block* b = World::INSTANCE->zBlockAt(targetPos);
+        if (b)
+        {
+            txt += "TargetLight: \n";
+            txt += b->printLightInfo();
+        }
+    }
+    debug->setText(txt);
 }
 }
 
 
 void Game::api(char* data)
 void Game::api(char* data)
 {
 {
-	switch (data[0])
-	{
-	case 0: // open dialog
-	{
-		bool exists = 0;
-		short len = *(short*)(data + 1);
-		char* dialogName = new char[len + 1];
-		memcpy(dialogName, data + 3, len);
-		dialogName[len] = 0;
-		for (UIMLDialog* dialog : dialogs)
-		{
-			if (dialog->getName().istGleich(dialogName))
-			{
-				exists = 1;
-				break;
-			}
-		}
-		delete[] dialogName;
-		if (!exists)
-		{
-			int uimlLen = *(int*)(data + 3 + len);
-			char* uiml = new char[uimlLen + 1];
-			memcpy(uiml, data + 7 + len, uimlLen);
-			uiml[uimlLen] = 0;
-			UIMLDialog* dialog = new UIMLDialog(uiml, [this](UIMLDialog* dialog)
-				{
-					logout->postAction([this, dialog]()
-						{
-							int index = 0;
-							for (UIMLDialog* d : dialogs)
-							{
-								if (d == dialog)
-								{
-									dialogs.remove(index);
-									window->zBildschirm()->removeMember(d);
-									World::INSTANCE->zKamera()->setControlEnabled(dialogs.getEintragAnzahl() == 0);
-									break;
-								}
-								index++;
-							}
-						});
-				});
-			dialogs.add(dialog);
-			World::INSTANCE->zKamera()->setControlEnabled(0);
-			window->zBildschirm()->addMember(dialog);
-			delete[]uiml;
-		}
-		break;
-	}
-	case 1:
-	{ // element message
-		for (UIMLDialog* dialog : dialogs)
-		{
-			dialog->api(data + 1);
-		}
-		short idLen = *(short*)(data + 1);
-		char* id = new char[idLen + 1];
-		memcpy(id, data + 3, idLen);
-		id[idLen] = 0;
-		NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(guiView->zZeichnungById(id));
-		if (processor)
-			processor->api(data + 3 + idLen);
-		delete[] id;
-		break;
-	}
-	case 2:
-	{ // set gui
-		int uimlLen = *(int*)(data + 1);
-		char* uiml = new char[uimlLen + 1];
-		memcpy(uiml, data + 5, uimlLen);
-		uiml[uimlLen] = 0;
-		guiView->setUIML(uiml);
-		guiView->layout();
-		delete[] uiml;
-	}
-	}
+    switch (data[0])
+    {
+    case 0: // open dialog
+        {
+            bool exists = 0;
+            short len = *(short*)(data + 1);
+            char* dialogName = new char[len + 1];
+            memcpy(dialogName, data + 3, len);
+            dialogName[len] = 0;
+            for (UIMLDialog* dialog : dialogs)
+            {
+                if (dialog->getName().istGleich(dialogName))
+                {
+                    exists = 1;
+                    break;
+                }
+            }
+            delete[] dialogName;
+            if (!exists)
+            {
+                int uimlLen = *(int*)(data + 3 + len);
+                char* uiml = new char[uimlLen + 1];
+                memcpy(uiml, data + 7 + len, uimlLen);
+                uiml[uimlLen] = 0;
+                UIMLDialog* dialog
+                    = new UIMLDialog(uiml, [this](UIMLDialog* dialog) {
+                          logout->postAction([this, dialog]() {
+                              int index = 0;
+                              for (UIMLDialog* d : dialogs)
+                              {
+                                  if (d == dialog)
+                                  {
+                                      dialogs.remove(index);
+                                      window->zBildschirm()->removeMember(d);
+                                      World::INSTANCE->zKamera()
+                                          ->setControlEnabled(
+                                              dialogs.getEintragAnzahl() == 0);
+                                      break;
+                                  }
+                                  index++;
+                              }
+                          });
+                      });
+                dialogs.add(dialog);
+                World::INSTANCE->zKamera()->setControlEnabled(0);
+                window->zBildschirm()->addMember(dialog);
+                delete[] uiml;
+            }
+            break;
+        }
+    case 1:
+        { // element message
+            for (UIMLDialog* dialog : dialogs)
+            {
+                dialog->api(data + 1);
+            }
+            short idLen = *(short*)(data + 1);
+            char* id = new char[idLen + 1];
+            memcpy(id, data + 3, idLen);
+            id[idLen] = 0;
+            NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(
+                guiView->zZeichnungById(id));
+            if (processor) processor->api(data + 3 + idLen);
+            delete[] id;
+            break;
+        }
+    case 2:
+        { // set gui
+            int uimlLen = *(int*)(data + 1);
+            char* uiml = new char[uimlLen + 1];
+            memcpy(uiml, data + 5, uimlLen);
+            uiml[uimlLen] = 0;
+            guiView->setUIML(uiml);
+            guiView->layout();
+            delete[] uiml;
+        }
+    }
 }
 }
 
 
 void Game::closeCurrentDialog()
 void Game::closeCurrentDialog()
 {
 {
-	if (dialogs.getEintragAnzahl() > 0)
-	{
-		UIMLDialog* d = dialogs.get(dialogs.getEintragAnzahl() - 1);
-		window->zBildschirm()->removeMember(d);
-		dialogs.remove(dialogs.getEintragAnzahl() - 1);
-		World::INSTANCE->zKamera()->setControlEnabled(dialogs.getEintragAnzahl() == 0);
-	}
+    if (dialogs.getEintragAnzahl() > 0)
+    {
+        UIMLDialog* d = dialogs.get(dialogs.getEintragAnzahl() - 1);
+        window->zBildschirm()->removeMember(d);
+        dialogs.remove(dialogs.getEintragAnzahl() - 1);
+        World::INSTANCE->zKamera()->setControlEnabled(
+            dialogs.getEintragAnzahl() == 0);
+    }
 }
 }
 
 
 DragController<InventoryDragSource, int>* Game::zInventoryDragController()
 DragController<InventoryDragSource, int>* Game::zInventoryDragController()
 {
 {
-	return inventoryDragController;
+    return inventoryDragController;
 }
 }

+ 14 - 14
FactoryCraft/Game.h

@@ -1,11 +1,11 @@
 #pragma once
 #pragma once
 
 
-#include <Knopf.h>
 #include <Bild.h>
 #include <Bild.h>
+#include <Knopf.h>
 
 
-#include "Menu.h"
 #include "Dialog.h"
 #include "Dialog.h"
 #include "DragController.h"
 #include "DragController.h"
+#include "Menu.h"
 
 
 class Player;
 class Player;
 class InventoryDragSource;
 class InventoryDragSource;
@@ -13,19 +13,19 @@ class InventoryDragSource;
 class Game : public Menu
 class Game : public Menu
 {
 {
 private:
 private:
-	Framework::Knopf* logout;
-	Framework::TextFeld* debug;
-	Framework::Array<UIMLDialog*> dialogs;
-	Framework::UIMLView* guiView;
-	DragController<InventoryDragSource, int>* inventoryDragController;
+    Framework::Knopf* logout;
+    Framework::TextFeld* debug;
+    Framework::Array<UIMLDialog*> dialogs;
+    Framework::UIMLView* guiView;
+    DragController<InventoryDragSource, int>* inventoryDragController;
 
 
 public:
 public:
-	// Konstruktor
-	Game(Bildschirm* zScreen);
-	~Game();
+    // Konstruktor
+    Game(Bildschirm* zScreen);
+    ~Game();
 
 
-	void updatePosition(Vec3<float> position, bool target, Vec3<int> targetPos);
-	void api(char* data);
-	void closeCurrentDialog();
-	DragController<InventoryDragSource, int>* zInventoryDragController();
+    void updatePosition(Vec3<float> position, bool target, Vec3<int> targetPos);
+    void api(char* data);
+    void closeCurrentDialog();
+    DragController<InventoryDragSource, int>* zInventoryDragController();
 };
 };

+ 143 - 116
FactoryCraft/Initialisierung.cpp

@@ -1,165 +1,192 @@
 #include "Initialisierung.h"
 #include "Initialisierung.h"
-#include <ToolTip.h>
+
 #include <Bildschirm.h>
 #include <Bildschirm.h>
-#include <MausEreignis.h>
 #include <DateiSystem.h>
 #include <DateiSystem.h>
 #include <Fenster.h>
 #include <Fenster.h>
 #include <Fortschritt.h>
 #include <Fortschritt.h>
 #include <Liste.h>
 #include <Liste.h>
+#include <MausEreignis.h>
+#include <ToolTip.h>
+
 #include "Globals.h"
 #include "Globals.h"
 
 
 Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel)
 Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel)
 {
 {
-	Knopf* ret = uiFactory.createKnopf(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	ret->setText(titel);
-	ret->setHintergrundFarbe(0xFF000000);
-	ret->setRahmenFarbe(0xFF2E6DA4);
-	ret->setSchriftFarbe(0xFFFFFFFF);
-	ret->setRahmenBreite(1);
-	ret->setAlphaFeldStrength(10);
-	ret->setAlphaFeldFarbe(0xFF337AB7);
-	return ret;
+    Knopf* ret = uiFactory.createKnopf(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    ret->setText(titel);
+    ret->setHintergrundFarbe(0xFF000000);
+    ret->setRahmenFarbe(0xFF2E6DA4);
+    ret->setSchriftFarbe(0xFFFFFFFF);
+    ret->setRahmenBreite(1);
+    ret->setAlphaFeldStrength(10);
+    ret->setAlphaFeldFarbe(0xFF337AB7);
+    return ret;
 }
 }
 
 
-KontrollKnopf* initKontrollKnopf(int x, int y, int br, int hö, __int64 style, char* txt)
+KontrollKnopf* initKontrollKnopf(
+    int x, int y, int br, int hö, __int64 style, char* txt)
 {
 {
-	KontrollKnopf* ret = uiFactory.createKontrollKnopf(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setText(txt);
-	ret->setSText(txt);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	return ret;
+    KontrollKnopf* ret = uiFactory.createKontrollKnopf(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setText(txt);
+    ret->setSText(txt);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    return ret;
 }
 }
 
 
 Fenster* initFenster(int x, int y, int br, int hö, __int64 style, char* titel)
 Fenster* initFenster(int x, int y, int br, int hö, __int64 style, char* titel)
 {
 {
-	Fenster* ret = uiFactory.createFenster(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	if (ret->hatStyle(Fenster::Style::Titel))
-	{
-		ret->setTitel(titel);
-	}
-	return ret;
+    Fenster* ret = uiFactory.createFenster(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    if (ret->hatStyle(Fenster::Style::Titel))
+    {
+        ret->setTitel(titel);
+    }
+    return ret;
 }
 }
 
 
 TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt)
 TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt)
 {
 {
-	TextFeld* ret = uiFactory.createTextFeld(uiFactory.initParam);
-	ret->setStyle(style);
-	ret->setText(txt);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	ret->setRahmenFarbe(0xFF6d6d6d);
-	ret->setHintergrundFarbe(0xFF000000);
-	ret->setAlphaFeldFarbe(0xFF3d3d3d);
-	ret->setAlphaFeldStrength(10);
-	return ret;
+    TextFeld* ret = uiFactory.createTextFeld(uiFactory.initParam);
+    ret->setStyle(style);
+    ret->setText(txt);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    ret->setRahmenFarbe(0xFF6d6d6d);
+    ret->setHintergrundFarbe(0xFF000000);
+    ret->setAlphaFeldFarbe(0xFF3d3d3d);
+    ret->setAlphaFeldStrength(10);
+    return ret;
 }
 }
 
 
 BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b)
 BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b)
 {
 {
-	BildZ* ret = uiFactory.createBildZ(uiFactory.initParam);
-	ret->setStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	if (b)
-		ret->setBildZ(b);
-	return ret;
+    BildZ* ret = uiFactory.createBildZ(uiFactory.initParam);
+    ret->setStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    if (b) ret->setBildZ(b);
+    return ret;
 }
 }
 
 
-AuswahlBox* initAuswahlBox(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values)
+AuswahlBox* initAuswahlBox(int x,
+    int y,
+    int br,
+    int hö,
+    __int64 style,
+    std::initializer_list<char*> values)
 {
 {
-	AuswahlBox* ret = uiFactory.createAuswahlBox(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	for (auto i = values.begin(); i != values.end(); i++)
-		ret->addEintrag(*i);
-	return ret;
+    AuswahlBox* ret = uiFactory.createAuswahlBox(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    for (auto i = values.begin(); i != values.end(); i++)
+        ret->addEintrag(*i);
+    return ret;
 }
 }
 
 
-ObjTabelle* initObjTabelle(int x, int y, int br, int hö, __int64 style, std::initializer_list< OBJTabelleSpalteIni > spalten, int überschriftHöhe)
+ObjTabelle* initObjTabelle(int x,
+    int y,
+    int br,
+    int hö,
+    __int64 style,
+    std::initializer_list<OBJTabelleSpalteIni> spalten,
+    int überschriftHöhe)
 {
 {
-	ObjTabelle* ret = uiFactory.createObjTabelle(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	for (auto i = spalten.begin(); i != spalten.end(); i++)
-	{
-		ret->addSpalte(i->name);
-		ret->setSpaltenBreite(i->name, i->breite);
-		if ((style | ObjTabelle::Style::SpaltenBreiteMin) == style)
-			ret->setMinSpaltenBreite(i->name, i->minBreite);
-		if ((style | ObjTabelle::Style::SpaltenBreiteMax) == style)
-			ret->setMaxSpaltenBreite(i->name, i->maxBreite);
-		if (überschriftHöhe)
-		{
-			if (ret->getZeilenNummer("Überschrift") < 0)
-			{
-				ret->addZeile(0, "Überschrift");
-				ret->setZeilenHeight(0, 20);
-			}
-			ret->setZeichnungZ(i->name, "Überschrift", initTextFeld(0, 0, i->breite, 20, TextFeld::Style::Text | TextFeld::Style::Center, i->name));
-		}
-	}
-	return ret;
+    ObjTabelle* ret = uiFactory.createObjTabelle(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    for (auto i = spalten.begin(); i != spalten.end(); i++)
+    {
+        ret->addSpalte(i->name);
+        ret->setSpaltenBreite(i->name, i->breite);
+        if ((style | ObjTabelle::Style::SpaltenBreiteMin) == style)
+            ret->setMinSpaltenBreite(i->name, i->minBreite);
+        if ((style | ObjTabelle::Style::SpaltenBreiteMax) == style)
+            ret->setMaxSpaltenBreite(i->name, i->maxBreite);
+        if (überschriftHöhe)
+        {
+            if (ret->getZeilenNummer("Überschrift") < 0)
+            {
+                ret->addZeile(0, "Überschrift");
+                ret->setZeilenHeight(0, 20);
+            }
+            ret->setZeichnungZ(i->name,
+                "Überschrift",
+                initTextFeld(0,
+                    0,
+                    i->breite,
+                    20,
+                    TextFeld::Style::Text | TextFeld::Style::Center,
+                    i->name));
+        }
+    }
+    return ret;
 }
 }
 
 
-LDiag* initLinienDiagramm(int x, int y, int br, int hö, __int64 style, DiagDaten* data)
+LDiag* initLinienDiagramm(
+    int x, int y, int br, int hö, __int64 style, DiagDaten* data)
 {
 {
-	LDiag* ret = uiFactory.createLDiag(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	if (data)
-		ret->setDiagDatenZ(data);
-	return ret;
+    LDiag* ret = uiFactory.createLDiag(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    if (data) ret->setDiagDatenZ(data);
+    return ret;
 }
 }
 
 
-AuswahlListe* initAuswahlListe(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values)
+AuswahlListe* initAuswahlListe(int x,
+    int y,
+    int br,
+    int hö,
+    __int64 style,
+    std::initializer_list<char*> values)
 {
 {
-	AuswahlListe* ret = uiFactory.createAuswahlListe(uiFactory.initParam);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	ret->addStyle(style);
-	for (auto i = values.begin(); i != values.end(); i++)
-		ret->addEintrag(*i);
-	ret->update();
-	return ret;
+    AuswahlListe* ret = uiFactory.createAuswahlListe(uiFactory.initParam);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    ret->addStyle(style);
+    for (auto i = values.begin(); i != values.end(); i++)
+        ret->addEintrag(*i);
+    ret->update();
+    return ret;
 }
 }
 
 
-ZeichnungHintergrund* initZeichnungHintergrund(int x, int y, int br, int hö, __int64 style, int farbe)
+ZeichnungHintergrund* initZeichnungHintergrund(
+    int x, int y, int br, int hö, __int64 style, int farbe)
 {
 {
-	ZeichnungHintergrund* ret = new ZeichnungHintergrund();
-	ret->setStyle(style);
-	ret->setHintergrundFarbe(farbe);
-	if (ret->hatStyle(ZeichnungHintergrund::Style::Rahmen))
-	{
-		ret->setRahmenBreite(1);
-		ret->setRahmenFarbe(0xFF00FF00);
-	}
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	return ret;
+    ZeichnungHintergrund* ret = new ZeichnungHintergrund();
+    ret->setStyle(style);
+    ret->setHintergrundFarbe(farbe);
+    if (ret->hatStyle(ZeichnungHintergrund::Style::Rahmen))
+    {
+        ret->setRahmenBreite(1);
+        ret->setRahmenFarbe(0xFF00FF00);
+    }
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    return ret;
 }
 }
 
 
 void initToolTip(Zeichnung* obj, const char* txt)
 void initToolTip(Zeichnung* obj, const char* txt)
 {
 {
-	obj->setToolTipText(txt, uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
-	obj->zToolTip()->addStyle(TextFeld::Style::Mehrzeilig);
+    obj->setToolTipText(
+        txt, uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
+    obj->zToolTip()->addStyle(TextFeld::Style::Mehrzeilig);
 }
 }
 
 
 FBalken* initFBalken(int x, int y, int br, int hö, __int64 style)
 FBalken* initFBalken(int x, int y, int br, int hö, __int64 style)
 {
 {
-	FBalken* ret = uiFactory.createFBalken(uiFactory.initParam);
-	ret->addStyle(style);
-	ret->setPosition(x, y);
-	ret->setSize(br, hö);
-	return ret;
+    FBalken* ret = uiFactory.createFBalken(uiFactory.initParam);
+    ret->addStyle(style);
+    ret->setPosition(x, y);
+    ret->setSize(br, hö);
+    return ret;
 }
 }

+ 24 - 11
FactoryCraft/Initialisierung.h

@@ -1,31 +1,44 @@
 #ifndef Initialisierung_H
 #ifndef Initialisierung_H
 #define Initialisierung_H
 #define Initialisierung_H
 
 
-#include <Knopf.h>
-#include <Bild.h>
 #include <AuswahlBox.h>
 #include <AuswahlBox.h>
-#include <Tabelle.h>
+#include <Bild.h>
 #include <Diagramm.h>
 #include <Diagramm.h>
 #include <Fortschritt.h>
 #include <Fortschritt.h>
 #include <initializer_list>
 #include <initializer_list>
+#include <Knopf.h>
+#include <Tabelle.h>
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 struct OBJTabelleSpalteIni
 struct OBJTabelleSpalteIni
 {
 {
-	char* name;
-	int breite;
-	int minBreite;
-	int maxBreite;
+    char* name;
+    int breite;
+    int minBreite;
+    int maxBreite;
 };
 };
 
 
 Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel);
 Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel);
-KontrollKnopf* initKontrollKnopf(int x, int y, int br, int hö, __int64 style, char* txt);
+KontrollKnopf* initKontrollKnopf(
+    int x, int y, int br, int hö, __int64 style, char* txt);
 TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt);
 TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt);
 BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b);
 BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b);
-AuswahlBox* initAuswahlBox(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values);
-ObjTabelle* initObjTabelle(int x, int y, int br, int hö, __int64 style, std::initializer_list< OBJTabelleSpalteIni > spalten, int überschriftHöhe);
-LDiag* initLinienDiagramm(int x, int y, int br, int hö, __int64 style, DiagDaten* data);
+AuswahlBox* initAuswahlBox(int x,
+    int y,
+    int br,
+    int hö,
+    __int64 style,
+    std::initializer_list<char*> values);
+ObjTabelle* initObjTabelle(int x,
+    int y,
+    int br,
+    int hö,
+    __int64 style,
+    std::initializer_list<OBJTabelleSpalteIni> spalten,
+    int überschriftHöhe);
+LDiag* initLinienDiagramm(
+    int x, int y, int br, int hö, __int64 style, DiagDaten* data);
 FBalken* initFBalken(int x, int y, int br, int hö, __int64 style);
 FBalken* initFBalken(int x, int y, int br, int hö, __int64 style);
 
 
 #endif
 #endif

+ 376 - 340
FactoryCraft/InventoryView.cpp

@@ -1,396 +1,432 @@
-#include <XML.h>
+#include "InventoryView.h"
+
 #include <Bild.h>
 #include <Bild.h>
+#include <XML.h>
 
 
-#include "InventoryView.h"
-#include "Globals.h"
 #include "DragController.h"
 #include "DragController.h"
-#include "Globals.h"
 #include "Game.h"
 #include "Game.h"
+#include "Globals.h"
 #include "UIMLToolTip.h"
 #include "UIMLToolTip.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 InventoryElement::InventoryElement()
 InventoryElement::InventoryElement()
-	: UIMLElement()
+    : UIMLElement()
 {}
 {}
 
 
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 bool InventoryElement::isApplicableFor(Framework::XML::Element& element)
 bool InventoryElement::isApplicableFor(Framework::XML::Element& element)
 {
 {
-	return element.getName().istGleich("inventory");
+    return element.getName().istGleich("inventory");
 }
 }
 
 
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-Framework::Zeichnung* InventoryElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+Framework::Zeichnung* InventoryElement::parseElement(
+    Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
 {
 {
-	Text targetValue = element.getAttributeValue("target");
-	Vec3<int> blockPos(0, 0, 0);
-	Framework::Either<int, VecN<int, 4>> target((int)targetValue);
-	if (targetValue.hat(','))
-	{
-		Text* first = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
-		Text* second = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1, targetValue.positionVon(",", 1));
-		Text* third = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1, targetValue.positionVon(",", 2));
-		Text* forth = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
-		target = Framework::Either<int, VecN<int, 4>>(Framework::VecN<int, 4>({ (int)*first, (int)*second, (int)*third, (int)*forth }));
-		first->release();
-		second->release();
-		third->release();
-		forth->release();
-	}
-	return new InventoryView(element.getAttributeValue("id"), target, (int)element.getAttributeValue("rowSize"), element.getAttributeValue("slotNameFilter"));
+    Text targetValue = element.getAttributeValue("target");
+    Vec3<int> blockPos(0, 0, 0);
+    Framework::Either<int, VecN<int, 4>> target((int)targetValue);
+    if (targetValue.hat(','))
+    {
+        Text* first
+            = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
+        Text* second
+            = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1,
+                targetValue.positionVon(",", 1));
+        Text* third
+            = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1,
+                targetValue.positionVon(",", 2));
+        Text* forth
+            = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
+        target = Framework::Either<int, VecN<int, 4>>(Framework::VecN<int, 4>(
+            {(int)*first, (int)*second, (int)*third, (int)*forth}));
+        first->release();
+        second->release();
+        third->release();
+        forth->release();
+    }
+    return new InventoryView(element.getAttributeValue("id"),
+        target,
+        (int)element.getAttributeValue("rowSize"),
+        element.getAttributeValue("slotNameFilter"));
 }
 }
 
 
 //! wendet die layout parameter zu einer Zeichnung an
 //! wendet die layout parameter zu einer Zeichnung an
-void InventoryElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+void InventoryElement::layout(Framework::XML::Element& element,
+    Framework::Zeichnung& z,
+    int pWidth,
+    int pHeight,
+    Framework::UIMLContainer& generalLayouter)
 {
 {
-	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+    UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
 }
 }
 
 
-
-void SlotInfo::render(int x, int y, Framework::Bild& rObj, bool selected, bool lightBackground)
+void SlotInfo::render(
+    int x, int y, Framework::Bild& rObj, bool selected, bool lightBackground)
 {
 {
-	TextRenderer tr;
-	tr.setSchriftZ(dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
-	tr.setSchriftSize(12);
-	rObj.fillRegion(x, y, 52, 52, selected ? 0xFFFFFFFF : 0xFF52525E);
-	rObj.fillRegion(x + 1, y + 1, 50, 50, lightBackground ? 0xFF42424E : 0xFF222222);
-	if (itemCount > 0)
-	{
-		rObj.alphaBild(x + 1, y + 1, 50, 50, *zItem);
-		if (hp < maxHp)
-		{
-			rObj.fillRegion(x + 1, y + 47, 50, 2, 0xFF000000);
-			rObj.fillRegion(x + 1, y + 47, (int)((hp / maxHp) * 50), 2, 0xFFFFFF00);
-		}
-		if (durability < maxDurability)
-		{
-			rObj.fillRegion(x + 1, y + 49, 50, 2, 0xFF000000);
-			rObj.fillRegion(x + 1, y + 49, (int)((durability / maxDurability) * 50), 2, 0xFF00FF00);
-		}
-		const char* units[] = { "", "K", "M", "G", "T", "P" };
-		int i = 0;
-		for (; i < 6 && itemCount > 1024; i++)
-			itemCount = itemCount / 1024;
-		Text count = itemCount;
-		count += units[i];
-		tr.renderText(x + 45 - tr.getTextBreite(count), y + 45 - tr.getTextHeight(count), count, rObj, 0xFFFFFFFF);
-	}
+    TextRenderer tr;
+    tr.setSchriftZ(
+        dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
+    tr.setSchriftSize(12);
+    rObj.fillRegion(x, y, 52, 52, selected ? 0xFFFFFFFF : 0xFF52525E);
+    rObj.fillRegion(
+        x + 1, y + 1, 50, 50, lightBackground ? 0xFF42424E : 0xFF222222);
+    if (itemCount > 0)
+    {
+        rObj.alphaBild(x + 1, y + 1, 50, 50, *zItem);
+        if (hp < maxHp)
+        {
+            rObj.fillRegion(x + 1, y + 47, 50, 2, 0xFF000000);
+            rObj.fillRegion(
+                x + 1, y + 47, (int)((hp / maxHp) * 50), 2, 0xFFFFFF00);
+        }
+        if (durability < maxDurability)
+        {
+            rObj.fillRegion(x + 1, y + 49, 50, 2, 0xFF000000);
+            rObj.fillRegion(x + 1,
+                y + 49,
+                (int)((durability / maxDurability) * 50),
+                2,
+                0xFF00FF00);
+        }
+        const char* units[] = {"", "K", "M", "G", "T", "P"};
+        int i = 0;
+        for (; i < 6 && itemCount > 1024; i++)
+            itemCount = itemCount / 1024;
+        Text count = itemCount;
+        count += units[i];
+        tr.renderText(x + 45 - tr.getTextBreite(count),
+            y + 45 - tr.getTextHeight(count),
+            count,
+            rObj,
+            0xFFFFFFFF);
+    }
 }
 }
 
 
-
-InventoryView::InventoryView(Text id, Either<int, VecN<int, 4>> target, int rowSize, Text slotNameFilter)
-	: ZeichnungHintergrund(),
-	rowSize(rowSize),
-	target(target),
-	slotNameFilter(slotNameFilter),
-	id(id),
-	slots(0),
-	dragStartId(-1),
-	dragStopId(-1),
-	currentTooltipSlot(-1),
-	requestetTooltipSlot(-1)
+InventoryView::InventoryView(
+    Text id, Either<int, VecN<int, 4>> target, int rowSize, Text slotNameFilter)
+    : ZeichnungHintergrund(),
+      rowSize(rowSize),
+      target(target),
+      slotNameFilter(slotNameFilter),
+      id(id),
+      slots(0),
+      dragStartId(-1),
+      dragStopId(-1),
+      currentTooltipSlot(-1),
+      requestetTooltipSlot(-1)
 {
 {
-	setStyle(ZeichnungHintergrund::Style::Sichtbar | ZeichnungHintergrund::Style::Erlaubt);
-	char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
-	msg[0] = 0;
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
-	memcpy(msg + 3 + id.getLength(), slotNameFilter.getText(), slotNameFilter.getLength());
-	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + slotNameFilter.getLength() + 3);
-	delete[] msg;
-	setNeedToolTipEvent([this](Zeichnung* z, Punkt p)
-		{
-			int slot = getSlotByLocalPos(p);
-			if (currentTooltipSlot != slot)
-			{
-				this->setToolTipZ(0);
-				currentTooltipSlot = -1;
-			}
-			else
-				return;
-			if (requestetTooltipSlot != slot)
-			{
-				requestetTooltipSlot = slot;
-				char* msg = new char[this->id.getLength() + 6];
-				msg[0] = 2; // request inventory tooltip
-				msg[1] = (char)this->id.getLength();
-				memcpy(msg + 2, this->id.getText(), this->id.getLength());
-				*(int*)(msg + 2 + this->id.getLength()) = slot;
-				World::INSTANCE->zClient()->inventoryAPIRequest(this->target, msg, this->id.getLength() + 6);
-			}
-		});
+    setStyle(ZeichnungHintergrund::Style::Sichtbar
+             | ZeichnungHintergrund::Style::Erlaubt);
+    char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
+    msg[0] = 0;
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+    memcpy(msg + 3 + id.getLength(),
+        slotNameFilter.getText(),
+        slotNameFilter.getLength());
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        target, msg, id.getLength() + slotNameFilter.getLength() + 3);
+    delete[] msg;
+    setNeedToolTipEvent([this](Zeichnung* z, Punkt p) {
+        int slot = getSlotByLocalPos(p);
+        if (currentTooltipSlot != slot)
+        {
+            this->setToolTipZ(0);
+            currentTooltipSlot = -1;
+        }
+        else
+            return;
+        if (requestetTooltipSlot != slot)
+        {
+            requestetTooltipSlot = slot;
+            char* msg = new char[this->id.getLength() + 6];
+            msg[0] = 2; // request inventory tooltip
+            msg[1] = (char)this->id.getLength();
+            memcpy(msg + 2, this->id.getText(), this->id.getLength());
+            *(int*)(msg + 2 + this->id.getLength()) = slot;
+            World::INSTANCE->zClient()->inventoryAPIRequest(
+                this->target, msg, this->id.getLength() + 6);
+        }
+    });
 }
 }
 
 
 InventoryView::~InventoryView()
 InventoryView::~InventoryView()
 {
 {
-	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-	if (controller->getCurrentDragContainer() == this)
-		controller->stopDrag();
-	if (slots)
-		slots->release();
-	char* msg = new char[id.getLength() + 2];
-	msg[0] = 1;
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 2);
-	delete[] msg;
+    DragController<InventoryDragSource, int>* controller
+        = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+    if (controller->getCurrentDragContainer() == this) controller->stopDrag();
+    if (slots) slots->release();
+    char* msg = new char[id.getLength() + 2];
+    msg[0] = 1;
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        target, msg, id.getLength() + 2);
+    delete[] msg;
 }
 }
 
 
 int InventoryView::getSlotByLocalPos(Punkt pos)
 int InventoryView::getSlotByLocalPos(Punkt pos)
 {
 {
-	int x = 0;
-	int y = 0;
-	int rowCount = 0;
-	int slot = 0;
-	dragStopId = -1;
-	if (slots)
-	{
-		for (SlotInfo &info : *slots)
-		{
-			if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
-				return info.id;
-			x += 60;
-			if (++rowCount >= rowSize)
-			{
-				y += 60;
-				x = 0;
-				rowCount = 0;
-			}
-			slot++;
-		}
-	}
-	return -1;
+    int x = 0;
+    int y = 0;
+    int rowCount = 0;
+    int slot = 0;
+    dragStopId = -1;
+    if (slots)
+    {
+        for (SlotInfo& info : *slots)
+        {
+            if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
+                return info.id;
+            x += 60;
+            if (++rowCount >= rowSize)
+            {
+                y += 60;
+                x = 0;
+                rowCount = 0;
+            }
+            slot++;
+        }
+    }
+    return -1;
 }
 }
 
 
 void InventoryView::api(char* message)
 void InventoryView::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 0:
-		// send inventory content
-	{
-		Array<SlotInfo>* slots = new Array<SlotInfo>();
-		int count = *(int*)(++message);
-		for (int i = 0; i < count; i++)
-		{
-			SlotInfo info;
-			info.id = *(int*)(message += 4);
-			info.itemCount = *(int*)(message += 4);
-			if (info.itemCount > 0)
-			{
-				info.hp = *(float*)(message += 4);
-				info.maxHp = *(float*)(message += 4);
-				info.durability = *(float*)(message += 4);
-				info.maxDurability = *(float*)(message += 4);
-                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
-			}
-			slots->add(info);
-		}
-		postAction([this, slots]()
-			{
-				if (this->slots)
-					this->slots->release();
-				this->slots = slots;
-			});
-		break;
-	}
-	case 1: // set count of items
-	{
-		if (!slots)
-			return;
-		int id = *(int*)(message + 1);
-		int count = *(int*)(message + 5);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = count;
-				if (info.itemCount == 0)
-				{
-					DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-					if (controller && controller->getCurrentDragContainer() == this && controller->getCurrentDaragElement() == info.id)
-					{
-						controller->stopDrag();
-					}
-				}
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 2: // add new stack
-	{
-		if (!slots)
-			return;
-		int id = *(int*)(message + 1);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = *(int*)(message + 5);
-				info.hp = *(float*)(message + 9);
-				info.maxHp = *(float*)(message + 13);
-				info.durability = *(float*)(message + 17);
-				info.maxDurability = *(float*)(message + 21);
-                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 3: // receive tooltip uiml
-	{
-		int slotId = *(int*)(message + 1);
-		if (slotId == requestetTooltipSlot)
-		{
-			short len = *(short*)(message + 5);
-			char* uiml = new char[len + 1];
-			memcpy(uiml, message + 7, len);
-			uiml[len] = 0;
-			UIMLToolTip* tip = new UIMLToolTip();
-			tip->setUIML(uiml);
-			setToolTipZ(tip);
-			delete[] uiml;
-			currentTooltipSlot = slotId;
-			requestetTooltipSlot = -1;
-		}
-	}
-	}
+    switch (message[0])
+    {
+    case 0:
+        // send inventory content
+        {
+            Array<SlotInfo>* slots = new Array<SlotInfo>();
+            int count = *(int*)(++message);
+            for (int i = 0; i < count; i++)
+            {
+                SlotInfo info;
+                info.id = *(int*)(message += 4);
+                info.itemCount = *(int*)(message += 4);
+                if (info.itemCount > 0)
+                {
+                    info.hp = *(float*)(message += 4);
+                    info.maxHp = *(float*)(message += 4);
+                    info.durability = *(float*)(message += 4);
+                    info.maxDurability = *(float*)(message += 4);
+                    info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+                }
+                slots->add(info);
+            }
+            postAction([this, slots]() {
+                if (this->slots) this->slots->release();
+                this->slots = slots;
+            });
+            break;
+        }
+    case 1: // set count of items
+        {
+            if (!slots) return;
+            int id = *(int*)(message + 1);
+            int count = *(int*)(message + 5);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = count;
+                    if (info.itemCount == 0)
+                    {
+                        DragController<InventoryDragSource, int>* controller
+                            = ((Game*)(Menu*)menuRegister->get("game"))
+                                  ->zInventoryDragController();
+                        if (controller
+                            && controller->getCurrentDragContainer() == this
+                            && controller->getCurrentDaragElement() == info.id)
+                        {
+                            controller->stopDrag();
+                        }
+                    }
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 2: // add new stack
+        {
+            if (!slots) return;
+            int id = *(int*)(message + 1);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = *(int*)(message + 5);
+                    info.hp = *(float*)(message + 9);
+                    info.maxHp = *(float*)(message + 13);
+                    info.durability = *(float*)(message + 17);
+                    info.maxDurability = *(float*)(message + 21);
+                    info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 3: // receive tooltip uiml
+        {
+            int slotId = *(int*)(message + 1);
+            if (slotId == requestetTooltipSlot)
+            {
+                short len = *(short*)(message + 5);
+                char* uiml = new char[len + 1];
+                memcpy(uiml, message + 7, len);
+                uiml[len] = 0;
+                UIMLToolTip* tip = new UIMLToolTip();
+                tip->setUIML(uiml);
+                setToolTipZ(tip);
+                delete[] uiml;
+                currentTooltipSlot = slotId;
+                requestetTooltipSlot = -1;
+            }
+        }
+    }
 }
 }
 
 
 bool InventoryView::tick(double tickVal)
 bool InventoryView::tick(double tickVal)
 {
 {
-	return ZeichnungHintergrund::tick(tickVal);
+    return ZeichnungHintergrund::tick(tickVal);
 }
 }
 
 
 void InventoryView::render(Bild& rObj)
 void InventoryView::render(Bild& rObj)
 {
 {
-	ZeichnungHintergrund::render(rObj);
-	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
-		return;
-	if (slots)
-	{
-		int x = 0;
-		int y = 0;
-		int rowCount = 0;
-		for (SlotInfo info : *slots)
-		{
-			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
-			x += 60;
-			if (++rowCount >= rowSize)
-			{
-				y += 60;
-				x = 0;
-				rowCount = 0;
-			}
-		}
-	}
-	rObj.releaseDrawOptions();
+    ZeichnungHintergrund::render(rObj);
+    if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return;
+    if (slots)
+    {
+        int x = 0;
+        int y = 0;
+        int rowCount = 0;
+        for (SlotInfo info : *slots)
+        {
+            info.render(
+                x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+            x += 60;
+            if (++rowCount >= rowSize)
+            {
+                y += 60;
+                x = 0;
+                rowCount = 0;
+            }
+        }
+    }
+    rObj.releaseDrawOptions();
 }
 }
 
 
 void InventoryView::doMausEreignis(MausEreignis& me, bool userRet)
 void InventoryView::doMausEreignis(MausEreignis& me, bool userRet)
 {
 {
-	if (!slots)
-		return;
-	if (me.id == ME_Bewegung)
-	{
-		if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
-		{
-			setToolTipZ(0);
-			currentTooltipSlot = -1;
-		}
-	}
-	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
-	int x = 0;
-	int y = 0;
-	int rowCount = 0;
-	int slot = 0;
-	dragStopId = -1;
-	for (SlotInfo info : *slots)
-	{
-		if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
-		{
-			if (me.id == ME_RLinks)
-			{
-				if (!controller->getCurrentDragContainer() && info.itemCount > 0)
-				{
-					controller->beginDrag(this, info.id, info.zItem, [this]()
-						{
-							dragStartId = -1;
-						});
-					dragStartId = info.id;
-				}
-				else if (controller->getCurrentDragContainer())
-				{
-					// request to transfer items from source to target slot
-					Framework::Either<int, Framework::VecN<int, 4>> source = controller->getCurrentDragContainer()->getInventoryTarget();
-					int len = 2 + (source.isA() ? 4 : 16) + 5 + (target.isA() ? 4 : 16) + 4;
-					char* msg = new char[len];
-					int index = 0;
-					msg[index++] = 6;
-					msg[index++] = (char)source.isA();
-					if (source.isA())
-					{
-						*(int*)(msg + index) = source.getA();
-						index += 4;
-					}
-					else
-					{
-						*(int*)(msg + index) = source.getB()[0];
-						*(int*)(msg + index + 4) = source.getB()[1];
-						*(int*)(msg + index + 8) = source.getB()[2];
-						*(int*)(msg + index + 12) = source.getB()[3];
-						index += 16;
-					}
-					*(int*)(msg + index) = controller->getCurrentDaragElement();
-					index += 4;
-					msg[index++] = target.isA();
-					if (target.isA())
-					{
-						*(int*)(msg + index) = target.getA();
-						index += 4;
-					}
-					else
-					{
-						*(int*)(msg + index) = target.getB()[0];
-						*(int*)(msg + index + 4) = target.getB()[1];
-						*(int*)(msg + index + 8) = target.getB()[2];
-						*(int*)(msg + index + 12) = target.getB()[3];
-						index += 16;
-					}
-					*(int*)(msg + index) = info.id;
-					World::INSTANCE->zClient()->sendPlayerAction(msg, len);
-					delete[] msg;
-				}
-			}
-			else
-			{
-				if (controller->getCurrentDragContainer() && (controller->getCurrentDragContainer() != this || controller->getCurrentDaragElement() != info.id))
-				{
-					dragStopId = info.id;
-				}
-			}
-			break;
-		}
-		x += 60;
-		if (++rowCount >= rowSize)
-		{
-			y += 60;
-			x = 0;
-			rowCount = 0;
-		}
-		slot++;
-	}
-	ZeichnungHintergrund::doMausEreignis(me, userRet);
+    if (!slots) return;
+    if (me.id == ME_Bewegung)
+    {
+        if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
+        {
+            setToolTipZ(0);
+            currentTooltipSlot = -1;
+        }
+    }
+    DragController<InventoryDragSource, int>* controller
+        = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+    int x = 0;
+    int y = 0;
+    int rowCount = 0;
+    int slot = 0;
+    dragStopId = -1;
+    for (SlotInfo info : *slots)
+    {
+        if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
+        {
+            if (me.id == ME_RLinks)
+            {
+                if (!controller->getCurrentDragContainer()
+                    && info.itemCount > 0)
+                {
+                    controller->beginDrag(this, info.id, info.zItem, [this]() {
+                        dragStartId = -1;
+                    });
+                    dragStartId = info.id;
+                }
+                else if (controller->getCurrentDragContainer())
+                {
+                    // request to transfer items from source to target slot
+                    Framework::Either<int, Framework::VecN<int, 4>> source
+                        = controller->getCurrentDragContainer()
+                              ->getInventoryTarget();
+                    int len = 2 + (source.isA() ? 4 : 16) + 5
+                            + (target.isA() ? 4 : 16) + 4;
+                    char* msg = new char[len];
+                    int index = 0;
+                    msg[index++] = 6;
+                    msg[index++] = (char)source.isA();
+                    if (source.isA())
+                    {
+                        *(int*)(msg + index) = source.getA();
+                        index += 4;
+                    }
+                    else
+                    {
+                        *(int*)(msg + index) = source.getB()[0];
+                        *(int*)(msg + index + 4) = source.getB()[1];
+                        *(int*)(msg + index + 8) = source.getB()[2];
+                        *(int*)(msg + index + 12) = source.getB()[3];
+                        index += 16;
+                    }
+                    *(int*)(msg + index) = controller->getCurrentDaragElement();
+                    index += 4;
+                    msg[index++] = target.isA();
+                    if (target.isA())
+                    {
+                        *(int*)(msg + index) = target.getA();
+                        index += 4;
+                    }
+                    else
+                    {
+                        *(int*)(msg + index) = target.getB()[0];
+                        *(int*)(msg + index + 4) = target.getB()[1];
+                        *(int*)(msg + index + 8) = target.getB()[2];
+                        *(int*)(msg + index + 12) = target.getB()[3];
+                        index += 16;
+                    }
+                    *(int*)(msg + index) = info.id;
+                    World::INSTANCE->zClient()->sendPlayerAction(msg, len);
+                    delete[] msg;
+                }
+            }
+            else
+            {
+                if (controller->getCurrentDragContainer()
+                    && (controller->getCurrentDragContainer() != this
+                        || controller->getCurrentDaragElement() != info.id))
+                {
+                    dragStopId = info.id;
+                }
+            }
+            break;
+        }
+        x += 60;
+        if (++rowCount >= rowSize)
+        {
+            y += 60;
+            x = 0;
+            rowCount = 0;
+        }
+        slot++;
+    }
+    ZeichnungHintergrund::doMausEreignis(me, userRet);
 }
 }
 
 
-Framework::Either<int, Framework::VecN<int, 4>> InventoryView::getInventoryTarget() const
+Framework::Either<int, Framework::VecN<int, 4>>
+InventoryView::getInventoryTarget() const
 {
 {
-	return target;
+    return target;
 }
 }

+ 54 - 37
FactoryCraft/InventoryView.h

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
-#include <UIMLView.h>
 #include <Either.h>
 #include <Either.h>
+#include <UIMLView.h>
 #include <VecN.h>
 #include <VecN.h>
 
 
 #include "NetworkAPIProcessor.h"
 #include "NetworkAPIProcessor.h"
@@ -9,55 +9,72 @@
 class InventoryElement : public Framework::UIMLElement
 class InventoryElement : public Framework::UIMLElement
 {
 {
 public:
 public:
-	InventoryElement();
-	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
-	bool isApplicableFor(Framework::XML::Element& element) override;
-	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
-	//! wendet die layout parameter zu einer Zeichnung an
-	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+    InventoryElement();
+    //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
+    //! ist
+    bool isApplicableFor(Framework::XML::Element& element) override;
+    //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+    Framework::Zeichnung* parseElement(Framework::XML::Element& element,
+        Framework::UIMLContainer& generalFactory) override;
+    //! wendet die layout parameter zu einer Zeichnung an
+    void layout(Framework::XML::Element& element,
+        Framework::Zeichnung& z,
+        int pWidth,
+        int pHeight,
+        Framework::UIMLContainer& generalLayouter) override;
 };
 };
 
 
 struct SlotInfo
 struct SlotInfo
 {
 {
-	int id;
-	int itemCount;
-	float hp;
-	float maxHp;
-	float durability;
-	float maxDurability;
-	Framework::Bild* zItem;
-
-	void render(int x, int y, Framework::Bild& rObj, bool selected, bool lightBackground);
+    int id;
+    int itemCount;
+    float hp;
+    float maxHp;
+    float durability;
+    float maxDurability;
+    Framework::Bild* zItem;
+
+    void render(int x,
+        int y,
+        Framework::Bild& rObj,
+        bool selected,
+        bool lightBackground);
 };
 };
 
 
 class InventoryDragSource
 class InventoryDragSource
 {
 {
 public:
 public:
-	virtual Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const = 0;
+    virtual Framework::Either<int, Framework::VecN<int, 4>>
+    getInventoryTarget() const = 0;
 };
 };
 
 
-class InventoryView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor, public InventoryDragSource
+class InventoryView : public Framework::ZeichnungHintergrund,
+                      public NetworkAPIProcessor,
+                      public InventoryDragSource
 {
 {
 private:
 private:
-	int rowSize;
-	// entity id or block position
-	Framework::Either<int, Framework::VecN<int, 4>> target;
-	Framework::Text slotNameFilter;
-	Framework::Text id;
-	Framework::Array<SlotInfo>* slots;
-	int dragStartId;
-	int dragStopId;
-	int currentTooltipSlot;
-	int requestetTooltipSlot;
-	int getSlotByLocalPos(Framework::Punkt pos);
+    int rowSize;
+    // entity id or block position
+    Framework::Either<int, Framework::VecN<int, 4>> target;
+    Framework::Text slotNameFilter;
+    Framework::Text id;
+    Framework::Array<SlotInfo>* slots;
+    int dragStartId;
+    int dragStopId;
+    int currentTooltipSlot;
+    int requestetTooltipSlot;
+    int getSlotByLocalPos(Framework::Punkt pos);
 
 
 public:
 public:
-	InventoryView(Framework::Text id, Framework::Either<int, Framework::VecN<int, 4>> target, int rowSize, Framework::Text slotNameFilter);
-	~InventoryView();
-	void api(char* message) override;
-	bool tick(double tickVal) override;
-	void render(Framework::Bild& rObj) override;
-	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
-	Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const override;
+    InventoryView(Framework::Text id,
+        Framework::Either<int, Framework::VecN<int, 4>> target,
+        int rowSize,
+        Framework::Text slotNameFilter);
+    ~InventoryView();
+    void api(char* message) override;
+    bool tick(double tickVal) override;
+    void render(Framework::Bild& rObj) override;
+    void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+    Framework::Either<int, Framework::VecN<int, 4>>
+    getInventoryTarget() const override;
 };
 };

+ 144 - 129
FactoryCraft/ItemBar.cpp

@@ -1,165 +1,180 @@
-#include <XML.h>
+#include "ItemBar.h"
+
 #include <Bild.h>
 #include <Bild.h>
+#include <XML.h>
 
 
-#include "ItemBar.h"
 #include "Globals.h"
 #include "Globals.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 ItemBarElement::ItemBarElement()
 ItemBarElement::ItemBarElement()
-	: UIMLElement()
+    : UIMLElement()
 {}
 {}
 
 
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
 bool ItemBarElement::isApplicableFor(Framework::XML::Element& element)
 bool ItemBarElement::isApplicableFor(Framework::XML::Element& element)
 {
 {
-	return element.getName().istGleich("itemBar");
+    return element.getName().istGleich("itemBar");
 }
 }
 
 
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
 //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-Framework::Zeichnung* ItemBarElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+Framework::Zeichnung* ItemBarElement::parseElement(
+    Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
 {
 {
-	return new ItemBarView(element.getAttributeValue("id"), (int)element.getAttributeValue("rowSize"), (int)element.getAttributeValue("target"), element.getAttributeValue("slotNameFilter"));
+    return new ItemBarView(element.getAttributeValue("id"),
+        (int)element.getAttributeValue("rowSize"),
+        (int)element.getAttributeValue("target"),
+        element.getAttributeValue("slotNameFilter"));
 }
 }
 
 
 //! wendet die layout parameter zu einer Zeichnung an
 //! wendet die layout parameter zu einer Zeichnung an
-void ItemBarElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+void ItemBarElement::layout(Framework::XML::Element& element,
+    Framework::Zeichnung& z,
+    int pWidth,
+    int pHeight,
+    Framework::UIMLContainer& generalLayouter)
 {
 {
-	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+    UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
 }
 }
 
 
-
-ItemBarView::ItemBarView(Framework::Text id, int rowSize, int targetEntity, Framework::Text slotNameFilter)
-	: ZeichnungHintergrund(),
-	id(id),
-	rowSize(rowSize),
-	targetEntity(targetEntity),
-	slotNameFilter(slotNameFilter),
-	slots(0),
-	leftHandPos(0)
+ItemBarView::ItemBarView(Framework::Text id,
+    int rowSize,
+    int targetEntity,
+    Framework::Text slotNameFilter)
+    : ZeichnungHintergrund(),
+      id(id),
+      rowSize(rowSize),
+      targetEntity(targetEntity),
+      slotNameFilter(slotNameFilter),
+      slots(0),
+      leftHandPos(0)
 {
 {
-	char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
-	msg[0] = 0;
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
-	memcpy(msg + 3 + id.getLength(), slotNameFilter.getText(), slotNameFilter.getLength());
-	World::INSTANCE->zClient()->inventoryAPIRequest(targetEntity, msg, id.getLength() + slotNameFilter.getLength() + 3);
-	delete[] msg;
+    char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
+    msg[0] = 0;
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+    memcpy(msg + 3 + id.getLength(),
+        slotNameFilter.getText(),
+        slotNameFilter.getLength());
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        targetEntity, msg, id.getLength() + slotNameFilter.getLength() + 3);
+    delete[] msg;
 }
 }
 
 
 ItemBarView::~ItemBarView()
 ItemBarView::~ItemBarView()
 {
 {
-	if (slots)
-		slots->release();
-	char* msg = new char[id.getLength() + 2];
-	msg[0] = 1;
-	msg[1] = (char)id.getLength();
-	memcpy(msg + 2, id.getText(), id.getLength());
-	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
-	World::INSTANCE->zClient()->inventoryAPIRequest(targetEntity, msg, id.getLength() + 2);
-	delete[] msg;
+    if (slots) slots->release();
+    char* msg = new char[id.getLength() + 2];
+    msg[0] = 1;
+    msg[1] = (char)id.getLength();
+    memcpy(msg + 2, id.getText(), id.getLength());
+    msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+    World::INSTANCE->zClient()->inventoryAPIRequest(
+        targetEntity, msg, id.getLength() + 2);
+    delete[] msg;
 }
 }
 
 
 void ItemBarView::api(char* message)
 void ItemBarView::api(char* message)
 {
 {
-	switch (message[0])
-	{
-	case 0:
-		// send inventory content
-	{
-		Array<SlotInfo>* slots = new Array<SlotInfo>();
-		int count = *(int*)(++message);
-		for (int i = 0; i < count; i++)
-		{
-			SlotInfo info;
-			info.id = *(int*)(message += 4);
-			info.itemCount = *(int*)(message += 4);
-			if (info.itemCount > 0)
-			{
-				info.hp = *(float*)(message += 4);
-				info.maxHp = *(float*)(message += 4);
-				info.durability = *(float*)(message += 4);
-				info.maxDurability = *(float*)(message += 4);
-                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
-			}
-			slots->add(info);
-		}
-		postAction([this, slots]()
-			{
-				if (this->slots)
-					this->slots->release();
-				this->slots = slots;
-			});
-		break;
-	}
-	case 1: // set count of items
-	{
-		int id = *(int*)(message + 1);
-		int count = *(int*)(message + 5);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = count;
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 2: // add new stack
-	{
-		int id = *(int*)(message + 1);
-		for (int i = 0; i < slots->getEintragAnzahl(); i++)
-		{
-			if (slots->get(i).id == id)
-			{
-				SlotInfo info = slots->get(i);
-				info.itemCount = *(int*)(message + 5);
-				info.hp = *(float*)(message + 9);
-				info.maxHp = *(float*)(message + 13);
-				info.durability = *(float*)(message + 17);
-				info.maxDurability = *(float*)(message + 21);
-                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
-				slots->set(info, i);
-				break;
-			}
-		}
-		break;
-	}
-	case 3: // set selected slot
-	{
-		leftHandPos = *(int*)(message + 1);
-		break;
-	}
-	}
+    switch (message[0])
+    {
+    case 0:
+        // send inventory content
+        {
+            Array<SlotInfo>* slots = new Array<SlotInfo>();
+            int count = *(int*)(++message);
+            for (int i = 0; i < count; i++)
+            {
+                SlotInfo info;
+                info.id = *(int*)(message += 4);
+                info.itemCount = *(int*)(message += 4);
+                if (info.itemCount > 0)
+                {
+                    info.hp = *(float*)(message += 4);
+                    info.maxHp = *(float*)(message += 4);
+                    info.durability = *(float*)(message += 4);
+                    info.maxDurability = *(float*)(message += 4);
+                    info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+                }
+                slots->add(info);
+            }
+            postAction([this, slots]() {
+                if (this->slots) this->slots->release();
+                this->slots = slots;
+            });
+            break;
+        }
+    case 1: // set count of items
+        {
+            int id = *(int*)(message + 1);
+            int count = *(int*)(message + 5);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = count;
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 2: // add new stack
+        {
+            int id = *(int*)(message + 1);
+            for (int i = 0; i < slots->getEintragAnzahl(); i++)
+            {
+                if (slots->get(i).id == id)
+                {
+                    SlotInfo info = slots->get(i);
+                    info.itemCount = *(int*)(message + 5);
+                    info.hp = *(float*)(message + 9);
+                    info.maxHp = *(float*)(message + 13);
+                    info.durability = *(float*)(message + 17);
+                    info.maxDurability = *(float*)(message + 21);
+                    info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+                    slots->set(info, i);
+                    break;
+                }
+            }
+            break;
+        }
+    case 3: // set selected slot
+        {
+            leftHandPos = *(int*)(message + 1);
+            break;
+        }
+    }
 }
 }
 
 
 void ItemBarView::render(Bild& rObj)
 void ItemBarView::render(Bild& rObj)
 {
 {
-	ZeichnungHintergrund::render(rObj);
-	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
-		return;
-	if (slots)
-	{
-		int x = 0;
-		int y = 0;
-		int rowCount = 0;
-		int index = 0;
-		for (SlotInfo info : *slots)
-		{
-			info.render(x, y, rObj, index == leftHandPos, index == (leftHandPos + 1) % slots->getEintragAnzahl());
-			x += 60;
-			if (++rowCount >= rowSize)
-			{
-				y += 60;
-				x = 0;
-				rowCount = 0;
-			}
-			index++;
-		}
-	}
-	rObj.releaseDrawOptions();
+    ZeichnungHintergrund::render(rObj);
+    if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return;
+    if (slots)
+    {
+        int x = 0;
+        int y = 0;
+        int rowCount = 0;
+        int index = 0;
+        for (SlotInfo info : *slots)
+        {
+            info.render(x,
+                y,
+                rObj,
+                index == leftHandPos,
+                index == (leftHandPos + 1) % slots->getEintragAnzahl());
+            x += 60;
+            if (++rowCount >= rowSize)
+            {
+                y += 60;
+                x = 0;
+                rowCount = 0;
+            }
+            index++;
+        }
+    }
+    rObj.releaseDrawOptions();
 }
 }

+ 30 - 21
FactoryCraft/ItemBar.h

@@ -1,37 +1,46 @@
 #pragma once
 #pragma once
 
 
-#include <UIMLView.h>
 #include <Either.h>
 #include <Either.h>
+#include <UIMLView.h>
 
 
-#include "NetworkAPIProcessor.h"
 #include "InventoryView.h"
 #include "InventoryView.h"
-
+#include "NetworkAPIProcessor.h"
 
 
 class ItemBarElement : public Framework::UIMLElement
 class ItemBarElement : public Framework::UIMLElement
 {
 {
 public:
 public:
-	ItemBarElement();
-	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
-	bool isApplicableFor(Framework::XML::Element& element) override;
-	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
-	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
-	//! wendet die layout parameter zu einer Zeichnung an
-	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+    ItemBarElement();
+    //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
+    //! ist
+    bool isApplicableFor(Framework::XML::Element& element) override;
+    //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+    Framework::Zeichnung* parseElement(Framework::XML::Element& element,
+        Framework::UIMLContainer& generalFactory) override;
+    //! wendet die layout parameter zu einer Zeichnung an
+    void layout(Framework::XML::Element& element,
+        Framework::Zeichnung& z,
+        int pWidth,
+        int pHeight,
+        Framework::UIMLContainer& generalLayouter) override;
 };
 };
 
 
-class ItemBarView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor
+class ItemBarView : public Framework::ZeichnungHintergrund,
+                    public NetworkAPIProcessor
 {
 {
 private:
 private:
-	Framework::Text id;
-	int rowSize;
-	int targetEntity;
-	Framework::Text slotNameFilter;
-	Framework::Array<SlotInfo>* slots;
-	int leftHandPos;
+    Framework::Text id;
+    int rowSize;
+    int targetEntity;
+    Framework::Text slotNameFilter;
+    Framework::Array<SlotInfo>* slots;
+    int leftHandPos;
 
 
 public:
 public:
-	ItemBarView(Framework::Text id, int rowSize, int targetEntity, Framework::Text slotNameFilter);
-	~ItemBarView();
-	void api(char* message) override;
-	void render(Framework::Bild& rObj) override;
+    ItemBarView(Framework::Text id,
+        int rowSize,
+        int targetEntity,
+        Framework::Text slotNameFilter);
+    ~ItemBarView();
+    void api(char* message) override;
+    void render(Framework::Bild& rObj) override;
 };
 };

+ 526 - 516
FactoryCraft/Load.cpp

@@ -1,553 +1,563 @@
+#include "Load.h"
+
+#include <Array.h>
 #include <AsynchronCall.h>
 #include <AsynchronCall.h>
 #include <Datei.h>
 #include <Datei.h>
-#include <Array.h>
 #include <DateiSystem.h>
 #include <DateiSystem.h>
-#include <Text.h>
-#include <Textur.h>
 #include <GraphicsApi.h>
 #include <GraphicsApi.h>
 #include <M3Datei.h>
 #include <M3Datei.h>
+#include <Text.h>
+#include <Textur.h>
 
 
-#include "Load.h"
-#include "Initialisierung.h"
 #include "Globals.h"
 #include "Globals.h"
+#include "Initialisierung.h"
 #include "ServerSelection.h"
 #include "ServerSelection.h"
 
 
 void createDefaultCube(Bildschirm* zScreen)
 void createDefaultCube(Bildschirm* zScreen)
 {
 {
-	Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
-	data->setAmbientFactor(0.f);
-	data->setDiffusFactor(1.f);
-	data->setSpecularFactor(0.f);
-	float size = 1;
-	float left, right, top, bottom;
-	// Calculate the screen coordinates of the left side of the bitmap.
-	left = (float)((-size / 2.0));
-	// Calculate the screen coordinates of the right side of the bitmap.
-	right = left + (float)size;
-	// Calculate the screen coordinates of the top of the bitmap.
-	top = (float)(size / 2.0);
-	// Calculate the screen coordinates of the bottom of the bitmap.
-	bottom = top - (float)size;
-	float front = -size / 2;
-	float back = front + size;
+    Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
+    data->setAmbientFactor(0.f);
+    data->setDiffusFactor(1.f);
+    data->setSpecularFactor(0.f);
+    float size = 1;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    left = (float)((-size / 2.0));
+    // Calculate the screen coordinates of the right side of the bitmap.
+    right = left + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -size / 2;
+    float back = front + size;
 
 
-	Vertex3D* vertecies = new Vertex3D[24];
-	for (int i = 0; i < 24; i++)
-		vertecies[i].knochenId = 0;
-	// front side
-	vertecies[0].pos = Vec3<float >(left, front, top);
-	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[1].pos = Vec3<float >(right, front, top);
-	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[2].pos = Vec3<float >(left, front, bottom);
-	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[3].pos = Vec3<float >(right, front, bottom);
-	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
-	// back side
-	vertecies[4].pos = Vec3<float >(right, back, top);
-	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[5].pos = Vec3<float >(left, back, top);
-	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[6].pos = Vec3<float >(right, back, bottom);
-	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[7].pos = Vec3<float >(left, back, bottom);
-	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
-	// left side
-	vertecies[8].pos = Vec3<float >(left, back, top);
-	vertecies[8].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[9].pos = Vec3<float >(left, front, top);
-	vertecies[9].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[10].pos = Vec3<float >(left, back, bottom);
-	vertecies[10].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[11].pos = Vec3<float >(left, front, bottom);
-	vertecies[11].tPos = Vec2< float >(1.f, 1.f);
-	// right side
-	vertecies[12].pos = Vec3<float >(right, front, top);
-	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[13].pos = Vec3<float >(right, back, top);
-	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[14].pos = Vec3<float >(right, front, bottom);
-	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[15].pos = Vec3<float >(right, back, bottom);
-	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
-	// top side
-	vertecies[16].pos = Vec3<float >(left, back, top);
-	vertecies[16].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[17].pos = Vec3<float >(right, back, top);
-	vertecies[17].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[18].pos = Vec3<float >(left, front, top);
-	vertecies[18].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[19].pos = Vec3<float >(right, front, top);
-	vertecies[19].tPos = Vec2< float >(1.f, 1.f);
-	// botom side
-	vertecies[20].pos = Vec3<float >(left, front, bottom);
-	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[21].pos = Vec3<float >(right, front, bottom);
-	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[22].pos = Vec3<float >(left, back, bottom);
-	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[23].pos = Vec3<float >(right, back, bottom);
-	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    // front side
+    vertecies[0].pos = Vec3<float>(left, front, top);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, front, top);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, front, bottom);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, front, bottom);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    // back side
+    vertecies[4].pos = Vec3<float>(right, back, top);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(left, back, top);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(right, back, bottom);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(left, back, bottom);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
+    // left side
+    vertecies[8].pos = Vec3<float>(left, back, top);
+    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[9].pos = Vec3<float>(left, front, top);
+    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, back, bottom);
+    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[11].pos = Vec3<float>(left, front, bottom);
+    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
+    // right side
+    vertecies[12].pos = Vec3<float>(right, front, top);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, back, top);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(right, front, bottom);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, back, bottom);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
+    // top side
+    vertecies[16].pos = Vec3<float>(left, back, top);
+    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[17].pos = Vec3<float>(right, back, top);
+    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[18].pos = Vec3<float>(left, front, top);
+    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[19].pos = Vec3<float>(right, front, top);
+    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
+    // botom side
+    vertecies[20].pos = Vec3<float>(left, front, bottom);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, front, bottom);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, back, bottom);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, back, bottom);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
 
 
-	data->setVertecies(vertecies, 24);
-	// the order of the polygons has to be NORTH (front), EAST (left), SOUTH (back), WEST (right), TOP, BOTTOM according to the Area definition
-	// front side
-	Polygon3D* p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0;
-	p->indexList[1] = 2;
-	p->indexList[2] = 1;
-	p->indexList[3] = 1;
-	p->indexList[4] = 2;
-	p->indexList[5] = 3;
-	data->addPolygon(p);
-	// left side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 8;
-	p->indexList[1] = 2 + 8;
-	p->indexList[2] = 1 + 8;
-	p->indexList[3] = 1 + 8;
-	p->indexList[4] = 2 + 8;
-	p->indexList[5] = 3 + 8;
-	data->addPolygon(p);
-	// back side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 4;
-	p->indexList[1] = 2 + 4;
-	p->indexList[2] = 1 + 4;
-	p->indexList[3] = 1 + 4;
-	p->indexList[4] = 2 + 4;
-	p->indexList[5] = 3 + 4;
-	data->addPolygon(p);
-	// right side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 12;
-	p->indexList[1] = 2 + 12;
-	p->indexList[2] = 1 + 12;
-	p->indexList[3] = 1 + 12;
-	p->indexList[4] = 2 + 12;
-	p->indexList[5] = 3 + 12;
-	data->addPolygon(p);
-	// top side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 16;
-	p->indexList[1] = 2 + 16;
-	p->indexList[2] = 1 + 16;
-	p->indexList[3] = 1 + 16;
-	p->indexList[4] = 2 + 16;
-	p->indexList[5] = 3 + 16;
-	data->addPolygon(p);
-	// botom side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 20;
-	p->indexList[1] = 2 + 20;
-	p->indexList[2] = 1 + 20;
-	p->indexList[3] = 1 + 20;
-	p->indexList[4] = 2 + 20;
-	p->indexList[5] = 3 + 20;
-	data->addPolygon(p);
-	data->calculateNormals();
-	data->release();
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
+    // (back), WEST (right), TOP, BOTTOM according to the Area definition front
+    // side
+    Polygon3D* p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 2;
+    p->indexList[2] = 1;
+    p->indexList[3] = 1;
+    p->indexList[4] = 2;
+    p->indexList[5] = 3;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 2 + 8;
+    p->indexList[2] = 1 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 2 + 8;
+    p->indexList[5] = 3 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 4;
+    p->indexList[1] = 2 + 4;
+    p->indexList[2] = 1 + 4;
+    p->indexList[3] = 1 + 4;
+    p->indexList[4] = 2 + 4;
+    p->indexList[5] = 3 + 4;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 12;
+    p->indexList[1] = 2 + 12;
+    p->indexList[2] = 1 + 12;
+    p->indexList[3] = 1 + 12;
+    p->indexList[4] = 2 + 12;
+    p->indexList[5] = 3 + 12;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 16;
+    p->indexList[1] = 2 + 16;
+    p->indexList[2] = 1 + 16;
+    p->indexList[3] = 1 + 16;
+    p->indexList[4] = 2 + 16;
+    p->indexList[5] = 3 + 16;
+    data->addPolygon(p);
+    // botom side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 20;
+    p->indexList[1] = 2 + 20;
+    p->indexList[2] = 1 + 20;
+    p->indexList[3] = 1 + 20;
+    p->indexList[4] = 2 + 20;
+    p->indexList[5] = 3 + 20;
+    data->addPolygon(p);
+    data->calculateNormals();
+    data->release();
 }
 }
 
 
 void createCubeItem(Bildschirm* zScreen)
 void createCubeItem(Bildschirm* zScreen)
 {
 {
-	Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel("itemCube");
-	data->setAmbientFactor(0.8f);
-	data->setDiffusFactor(0.1f);
-	data->setSpecularFactor(0.1f);
-	float size = 0.2f;
-	float left, right, top, bottom;
-	// Calculate the screen coordinates of the left side of the bitmap.
-	left = (float)((-size / 2.0));
-	// Calculate the screen coordinates of the right side of the bitmap.
-	right = left + (float)size;
-	// Calculate the screen coordinates of the top of the bitmap.
-	top = (float)(size / 2.0);
-	// Calculate the screen coordinates of the bottom of the bitmap.
-	bottom = top - (float)size;
-	float front = -size / 2;
-	float back = front + size;
+    Framework::Model3DData* data
+        = window->zBildschirm()->zGraphicsApi()->createModel("itemCube");
+    data->setAmbientFactor(0.8f);
+    data->setDiffusFactor(0.1f);
+    data->setSpecularFactor(0.1f);
+    float size = 0.2f;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    left = (float)((-size / 2.0));
+    // Calculate the screen coordinates of the right side of the bitmap.
+    right = left + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -size / 2;
+    float back = front + size;
 
 
-	Vertex3D* vertecies = new Vertex3D[24];
-	for (int i = 0; i < 24; i++)
-		vertecies[i].knochenId = 0;
-	// front side
-	vertecies[0].pos = Vec3<float >(left, front, top);
-	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[1].pos = Vec3<float >(right, front, top);
-	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[2].pos = Vec3<float >(left, front, bottom);
-	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[3].pos = Vec3<float >(right, front, bottom);
-	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
-	// back side
-	vertecies[4].pos = Vec3<float >(right, back, top);
-	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[5].pos = Vec3<float >(left, back, top);
-	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[6].pos = Vec3<float >(right, back, bottom);
-	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[7].pos = Vec3<float >(left, back, bottom);
-	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
-	// left side
-	vertecies[8].pos = Vec3<float >(left, back, top);
-	vertecies[8].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[9].pos = Vec3<float >(left, front, top);
-	vertecies[9].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[10].pos = Vec3<float >(left, back, bottom);
-	vertecies[10].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[11].pos = Vec3<float >(left, front, bottom);
-	vertecies[11].tPos = Vec2< float >(1.f, 1.f);
-	// right side
-	vertecies[12].pos = Vec3<float >(right, front, top);
-	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[13].pos = Vec3<float >(right, back, top);
-	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[14].pos = Vec3<float >(right, front, bottom);
-	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[15].pos = Vec3<float >(right, back, bottom);
-	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
-	// top side
-	vertecies[16].pos = Vec3<float >(left, back, top);
-	vertecies[16].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[17].pos = Vec3<float >(right, back, top);
-	vertecies[17].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[18].pos = Vec3<float >(left, front, top);
-	vertecies[18].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[19].pos = Vec3<float >(right, front, top);
-	vertecies[19].tPos = Vec2< float >(1.f, 1.f);
-	// botom side
-	vertecies[20].pos = Vec3<float >(left, front, bottom);
-	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[21].pos = Vec3<float >(right, front, bottom);
-	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[22].pos = Vec3<float >(left, back, bottom);
-	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[23].pos = Vec3<float >(right, back, bottom);
-	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    // front side
+    vertecies[0].pos = Vec3<float>(left, front, top);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, front, top);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, front, bottom);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, front, bottom);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    // back side
+    vertecies[4].pos = Vec3<float>(right, back, top);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(left, back, top);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(right, back, bottom);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(left, back, bottom);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
+    // left side
+    vertecies[8].pos = Vec3<float>(left, back, top);
+    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[9].pos = Vec3<float>(left, front, top);
+    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, back, bottom);
+    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[11].pos = Vec3<float>(left, front, bottom);
+    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
+    // right side
+    vertecies[12].pos = Vec3<float>(right, front, top);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, back, top);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(right, front, bottom);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, back, bottom);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
+    // top side
+    vertecies[16].pos = Vec3<float>(left, back, top);
+    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[17].pos = Vec3<float>(right, back, top);
+    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[18].pos = Vec3<float>(left, front, top);
+    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[19].pos = Vec3<float>(right, front, top);
+    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
+    // botom side
+    vertecies[20].pos = Vec3<float>(left, front, bottom);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, front, bottom);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, back, bottom);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, back, bottom);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
 
 
-	data->setVertecies(vertecies, 24);
-	// the order of the polygons has to be NORTH (front), EAST (left), SOUTH (back), WEST (right), TOP, BOTTOM according to the Area definition
-	// front side
-	Polygon3D* p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0;
-	p->indexList[1] = 2;
-	p->indexList[2] = 1;
-	p->indexList[3] = 1;
-	p->indexList[4] = 2;
-	p->indexList[5] = 3;
-	data->addPolygon(p);
-	// left side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 8;
-	p->indexList[1] = 2 + 8;
-	p->indexList[2] = 1 + 8;
-	p->indexList[3] = 1 + 8;
-	p->indexList[4] = 2 + 8;
-	p->indexList[5] = 3 + 8;
-	data->addPolygon(p);
-	// back side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 4;
-	p->indexList[1] = 2 + 4;
-	p->indexList[2] = 1 + 4;
-	p->indexList[3] = 1 + 4;
-	p->indexList[4] = 2 + 4;
-	p->indexList[5] = 3 + 4;
-	data->addPolygon(p);
-	// right side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 12;
-	p->indexList[1] = 2 + 12;
-	p->indexList[2] = 1 + 12;
-	p->indexList[3] = 1 + 12;
-	p->indexList[4] = 2 + 12;
-	p->indexList[5] = 3 + 12;
-	data->addPolygon(p);
-	// top side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 16;
-	p->indexList[1] = 2 + 16;
-	p->indexList[2] = 1 + 16;
-	p->indexList[3] = 1 + 16;
-	p->indexList[4] = 2 + 16;
-	p->indexList[5] = 3 + 16;
-	data->addPolygon(p);
-	// botom side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 20;
-	p->indexList[1] = 2 + 20;
-	p->indexList[2] = 1 + 20;
-	p->indexList[3] = 1 + 20;
-	p->indexList[4] = 2 + 20;
-	p->indexList[5] = 3 + 20;
-	data->addPolygon(p);
-	data->calculateNormals();
-	data->release();
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
+    // (back), WEST (right), TOP, BOTTOM according to the Area definition front
+    // side
+    Polygon3D* p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 2;
+    p->indexList[2] = 1;
+    p->indexList[3] = 1;
+    p->indexList[4] = 2;
+    p->indexList[5] = 3;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 2 + 8;
+    p->indexList[2] = 1 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 2 + 8;
+    p->indexList[5] = 3 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 4;
+    p->indexList[1] = 2 + 4;
+    p->indexList[2] = 1 + 4;
+    p->indexList[3] = 1 + 4;
+    p->indexList[4] = 2 + 4;
+    p->indexList[5] = 3 + 4;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 12;
+    p->indexList[1] = 2 + 12;
+    p->indexList[2] = 1 + 12;
+    p->indexList[3] = 1 + 12;
+    p->indexList[4] = 2 + 12;
+    p->indexList[5] = 3 + 12;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 16;
+    p->indexList[1] = 2 + 16;
+    p->indexList[2] = 1 + 16;
+    p->indexList[3] = 1 + 16;
+    p->indexList[4] = 2 + 16;
+    p->indexList[5] = 3 + 16;
+    data->addPolygon(p);
+    // botom side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 20;
+    p->indexList[1] = 2 + 20;
+    p->indexList[2] = 1 + 20;
+    p->indexList[3] = 1 + 20;
+    p->indexList[4] = 2 + 20;
+    p->indexList[5] = 3 + 20;
+    data->addPolygon(p);
+    data->calculateNormals();
+    data->release();
 }
 }
 
 
 void createPlayer(Bildschirm* zScreen)
 void createPlayer(Bildschirm* zScreen)
 {
 {
-	Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel("player");
-	data->setAmbientFactor(0.8f);
-	data->setDiffusFactor(0.1f);
-	data->setSpecularFactor(0.1f);
-	float size = 0.8f;
-	float left, right, top, bottom;
-	// Calculate the screen coordinates of the left side of the bitmap.
-	left = (float)((size / 2.0) * -1);
-	// Calculate the screen coordinates of the right side of the bitmap.
-	right = left + (float)size;
-	// Calculate the screen coordinates of the top of the bitmap.
-	top = (float)(size / 2.0);
-	// Calculate the screen coordinates of the bottom of the bitmap.
-	bottom = top - (float)size;
-	float front = -1.5f / 2;
-	float back = front + 1.5f;
+    Framework::Model3DData* data
+        = window->zBildschirm()->zGraphicsApi()->createModel("player");
+    data->setAmbientFactor(0.8f);
+    data->setDiffusFactor(0.1f);
+    data->setSpecularFactor(0.1f);
+    float size = 0.8f;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    left = (float)((size / 2.0) * -1);
+    // Calculate the screen coordinates of the right side of the bitmap.
+    right = left + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -1.5f / 2;
+    float back = front + 1.5f;
 
 
-	Vertex3D* vertecies = new Vertex3D[24];
-	for (int i = 0; i < 24; i++)
-		vertecies[i].knochenId = 0;
-	vertecies[0].pos = Vec3<float >(left, top, front);
-	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[1].pos = Vec3<float >(right, top, front);
-	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[2].pos = Vec3<float >(left, bottom, front);
-	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[3].pos = Vec3<float >(right, bottom, front);
-	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
-	vertecies[4].pos = Vec3<float >(left, top, back);
-	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[5].pos = Vec3<float >(right, top, back);
-	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[6].pos = Vec3<float >(left, bottom, back);
-	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[7].pos = Vec3<float >(right, bottom, back);
-	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    vertecies[0].pos = Vec3<float>(left, top, front);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, top, front);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, bottom, front);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, bottom, front);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[4].pos = Vec3<float>(left, top, back);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(right, top, back);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(left, bottom, back);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(right, bottom, back);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
 
 
-	vertecies[8].pos = Vec3<float >(left, top, front);
-	vertecies[8].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[9].pos = Vec3<float >(right, top, front);
-	vertecies[9].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[10].pos = Vec3<float >(left, bottom, front);
-	vertecies[10].tPos = Vec2< float >(1.f, 1.f);
-	vertecies[11].pos = Vec3<float >(right, bottom, front);
-	vertecies[11].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[12].pos = Vec3<float >(left, top, back);
-	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[13].pos = Vec3<float >(right, top, back);
-	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[14].pos = Vec3<float >(left, bottom, back);
-	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[15].pos = Vec3<float >(right, bottom, back);
-	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
+    vertecies[8].pos = Vec3<float>(left, top, front);
+    vertecies[8].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[9].pos = Vec3<float>(right, top, front);
+    vertecies[9].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, bottom, front);
+    vertecies[10].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[11].pos = Vec3<float>(right, bottom, front);
+    vertecies[11].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[12].pos = Vec3<float>(left, top, back);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, top, back);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(left, bottom, back);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, bottom, back);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
 
 
-	vertecies[16].pos = Vec3<float >(left, top, front);
-	vertecies[16].tPos = Vec2< float >(0.f, 1.f);
-	vertecies[17].pos = Vec3<float >(right, top, front);
-	vertecies[17].tPos = Vec2< float >(1.f, 1.f);
-	vertecies[18].pos = Vec3<float >(left, bottom, front);
-	vertecies[18].tPos = Vec2< float >(0.f, 0.f);
-	vertecies[19].pos = Vec3<float >(right, bottom, front);
-	vertecies[19].tPos = Vec2< float >(1.f, 0.f);
-	vertecies[20].pos = Vec3<float >(left, top, back);
-	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
-	vertecies[21].pos = Vec3<float >(right, top, back);
-	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
-	vertecies[22].pos = Vec3<float >(left, bottom, back);
-	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
-	vertecies[23].pos = Vec3<float >(right, bottom, back);
-	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+    vertecies[16].pos = Vec3<float>(left, top, front);
+    vertecies[16].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[17].pos = Vec3<float>(right, top, front);
+    vertecies[17].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[18].pos = Vec3<float>(left, bottom, front);
+    vertecies[18].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[19].pos = Vec3<float>(right, bottom, front);
+    vertecies[19].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[20].pos = Vec3<float>(left, top, back);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, top, back);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, bottom, back);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, bottom, back);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
 
 
-	data->setVertecies(vertecies, 24);
-	// the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM according to the Area definition
-	// down side
-	Polygon3D* p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 6 + 16;
-	p->indexList[1] = 2 + 16;
-	p->indexList[2] = 3 + 16;
-	p->indexList[3] = 6 + 16;
-	p->indexList[4] = 3 + 16;
-	p->indexList[5] = 7 + 16;
-	data->addPolygon(p);
-	// right side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 1 + 8;
-	p->indexList[1] = 7 + 8;
-	p->indexList[2] = 3 + 8;
-	p->indexList[3] = 1 + 8;
-	p->indexList[4] = 5 + 8;
-	p->indexList[5] = 7 + 8;
-	data->addPolygon(p);
-	// top side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 4 + 16;
-	p->indexList[1] = 1 + 16;
-	p->indexList[2] = 0 + 16;
-	p->indexList[3] = 4 + 16;
-	p->indexList[4] = 5 + 16;
-	p->indexList[5] = 1 + 16;
-	data->addPolygon(p);
-	// left side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0 + 8;
-	p->indexList[1] = 2 + 8;
-	p->indexList[2] = 6 + 8;
-	p->indexList[3] = 0 + 8;
-	p->indexList[4] = 6 + 8;
-	p->indexList[5] = 4 + 8;
-	data->addPolygon(p);
-	// back side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 4;
-	p->indexList[1] = 6;
-	p->indexList[2] = 7;
-	p->indexList[3] = 4;
-	p->indexList[4] = 7;
-	p->indexList[5] = 5;
-	data->addPolygon(p);
-	// front side
-	p = new Polygon3D();
-	p->indexAnz = 6;
-	p->indexList = new int[p->indexAnz];
-	p->indexList[0] = 0;
-	p->indexList[1] = 3;
-	p->indexList[2] = 2;
-	p->indexList[3] = 0;
-	p->indexList[4] = 1;
-	p->indexList[5] = 3;
-	data->addPolygon(p);
-	data->calculateNormals();
-	data->release();
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM
+    // according to the Area definition down side
+    Polygon3D* p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 6 + 16;
+    p->indexList[1] = 2 + 16;
+    p->indexList[2] = 3 + 16;
+    p->indexList[3] = 6 + 16;
+    p->indexList[4] = 3 + 16;
+    p->indexList[5] = 7 + 16;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 1 + 8;
+    p->indexList[1] = 7 + 8;
+    p->indexList[2] = 3 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 5 + 8;
+    p->indexList[5] = 7 + 8;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 4 + 16;
+    p->indexList[1] = 1 + 16;
+    p->indexList[2] = 0 + 16;
+    p->indexList[3] = 4 + 16;
+    p->indexList[4] = 5 + 16;
+    p->indexList[5] = 1 + 16;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 2 + 8;
+    p->indexList[2] = 6 + 8;
+    p->indexList[3] = 0 + 8;
+    p->indexList[4] = 6 + 8;
+    p->indexList[5] = 4 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 4;
+    p->indexList[1] = 6;
+    p->indexList[2] = 7;
+    p->indexList[3] = 4;
+    p->indexList[4] = 7;
+    p->indexList[5] = 5;
+    data->addPolygon(p);
+    // front side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 3;
+    p->indexList[2] = 2;
+    p->indexList[3] = 0;
+    p->indexList[4] = 1;
+    p->indexList[5] = 3;
+    data->addPolygon(p);
+    data->calculateNormals();
+    data->release();
 }
 }
 
 
 void createModels(Bildschirm* zScreen)
 void createModels(Bildschirm* zScreen)
 {
 {
-	createDefaultCube(zScreen);
-	createCubeItem(zScreen);
-	createPlayer(zScreen);
+    createDefaultCube(zScreen);
+    createCubeItem(zScreen);
+    createPlayer(zScreen);
 }
 }
 
 
-
 LoadMenu::LoadMenu(Bildschirm* zScreen)
 LoadMenu::LoadMenu(Bildschirm* zScreen)
-	: Menu(zScreen)
+    : Menu(zScreen)
 {
 {
-	Punkt center = zScreen->getBackBufferSize() / 2;
-	step = initFBalken(center.x - 100, center.y + 25, 200, 30, FBalken::Style::normal);
-	stage = initFBalken(center.x - 100, center.y - 15, 200, 30, FBalken::Style::normal);
-	all = initFBalken(center.x - 100, center.y - 55, 200, 30, FBalken::Style::normal);
-	elements.add(step);
-	elements.add(stage);
-	elements.add(all);
+    Punkt center = zScreen->getBackBufferSize() / 2;
+    step = initFBalken(
+        center.x - 100, center.y + 25, 200, 30, FBalken::Style::normal);
+    stage = initFBalken(
+        center.x - 100, center.y - 15, 200, 30, FBalken::Style::normal);
+    all = initFBalken(
+        center.x - 100, center.y - 55, 200, 30, FBalken::Style::normal);
+    elements.add(step);
+    elements.add(stage);
+    elements.add(all);
 
 
-	new AsynchronCall("Load Menu", [this, zScreen]()
-		{
-			Sleep(1000);
-			all->setAktionAnzahl(2);
-			all->reset();
-			// loading textures
-			Datei texturF;
-			texturF.setDatei("data/textures");
-			RCArray<Text>* files = texturF.getDateiListe();
-			if (files)
-			{
-				int count = 0;
-				for (Text* fileName : *files)
-				{
-					LTDBDatei dat;
-					dat.setDatei(new Text(Text("data/textures/") + *fileName));
-					dat.leseDaten(0);
-					count += dat.getBildAnzahl();
-				}
-				stage->setAktionAnzahl(count);
-				stage->reset();
-				for (Text* fileName : *files)
-				{
-					LTDBDatei dat;
-					dat.setDatei(new Text(Text("data/textures/") + *fileName));
-					dat.leseDaten(0);
-					for (Text* name : *dat.zBildListe())
-					{
-						step->reset();
-						Bild* b = dat.laden(step, new Text(*name));
-						zScreen->zGraphicsApi()->createOrGetTextur(*fileName + "/" + *name, b)->release();
-						stage->aktionPlus();
-					}
-				}
-				files->release();
-			}
-			all->aktionPlus();
-			// loading models
-			stage->setAktionAnzahl(1);
-			Datei modelF;
-			modelF.setDatei("data/models");
-			files = modelF.getDateiListe();
-			if (files)
-			{
-				int count = 0;
-				for (Text* fileName : *files)
-				{
-					M3Datei dat(Text("data/models/") + *fileName);
-					dat.leseDaten();
-					count += dat.getModelAnzahl();
-				}
-				stage->setAktionAnzahl(count + 1);
-				stage->reset();
-				for (Text* fileName : *files)
-				{
-					M3Datei dat(Text("data/models/") + *fileName);
-					dat.leseDaten();
-					for (int i = 0; i < dat.getModelAnzahl(); i++)
-					{
-						step->reset();
-						Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(), zScreen->zGraphicsApi(), *fileName + "/" + *dat.zModelName(i));
-						d->release();
-						stage->aktionPlus();
-					}
-				}
-				files->release();
-			}
-			createModels(zScreen);
-			stage->aktionPlus();
-			all->aktionPlus();
-			stage->reset();
-			zScreen->lock();
-			hide();
-			menuRegister->get("serverSelection")->show();
-			zScreen->unlock();
-		});
+    new AsynchronCall("Load Menu", [this, zScreen]() {
+        Sleep(1000);
+        all->setAktionAnzahl(2);
+        all->reset();
+        // loading textures
+        Datei texturF;
+        texturF.setDatei("data/textures");
+        RCArray<Text>* files = texturF.getDateiListe();
+        if (files)
+        {
+            int count = 0;
+            for (Text* fileName : *files)
+            {
+                LTDBDatei dat;
+                dat.setDatei(new Text(Text("data/textures/") + *fileName));
+                dat.leseDaten(0);
+                count += dat.getBildAnzahl();
+            }
+            stage->setAktionAnzahl(count);
+            stage->reset();
+            for (Text* fileName : *files)
+            {
+                LTDBDatei dat;
+                dat.setDatei(new Text(Text("data/textures/") + *fileName));
+                dat.leseDaten(0);
+                for (Text* name : *dat.zBildListe())
+                {
+                    step->reset();
+                    Bild* b = dat.laden(step, new Text(*name));
+                    zScreen->zGraphicsApi()
+                        ->createOrGetTextur(*fileName + "/" + *name, b)
+                        ->release();
+                    stage->aktionPlus();
+                }
+            }
+            files->release();
+        }
+        all->aktionPlus();
+        // loading models
+        stage->setAktionAnzahl(1);
+        Datei modelF;
+        modelF.setDatei("data/models");
+        files = modelF.getDateiListe();
+        if (files)
+        {
+            int count = 0;
+            for (Text* fileName : *files)
+            {
+                M3Datei dat(Text("data/models/") + *fileName);
+                dat.leseDaten();
+                count += dat.getModelAnzahl();
+            }
+            stage->setAktionAnzahl(count + 1);
+            stage->reset();
+            for (Text* fileName : *files)
+            {
+                M3Datei dat(Text("data/models/") + *fileName);
+                dat.leseDaten();
+                for (int i = 0; i < dat.getModelAnzahl(); i++)
+                {
+                    step->reset();
+                    Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(),
+                        zScreen->zGraphicsApi(),
+                        *fileName + "/" + *dat.zModelName(i));
+                    d->release();
+                    stage->aktionPlus();
+                }
+            }
+            files->release();
+        }
+        createModels(zScreen);
+        stage->aktionPlus();
+        all->aktionPlus();
+        stage->reset();
+        zScreen->lock();
+        hide();
+        menuRegister->get("serverSelection")->show();
+        zScreen->unlock();
+    });
 }
 }

+ 5 - 4
FactoryCraft/Load.h

@@ -1,16 +1,17 @@
 #pragma once
 #pragma once
 
 
 #include <Fortschritt.h>
 #include <Fortschritt.h>
+
 #include "Menu.h"
 #include "Menu.h"
 #undef LoadMenu
 #undef LoadMenu
 
 
 class LoadMenu : public Menu
 class LoadMenu : public Menu
 {
 {
 private:
 private:
-	FBalken* step;
-	FBalken* stage;
-	FBalken* all;
+    FBalken* step;
+    FBalken* stage;
+    FBalken* all;
 
 
 public:
 public:
-	LoadMenu(Bildschirm* zScreen);
+    LoadMenu(Bildschirm* zScreen);
 };
 };

+ 54 - 53
FactoryCraft/Main.cpp

@@ -1,67 +1,68 @@
-#include <main.h>
-#include <Network.h>
-#include <HttpRequest.h>
-#include <JSON.h>
-#include <Fenster.h>
 #include <Bildschirm.h>
 #include <Bildschirm.h>
+#include <Datei.h>
+#include <DateiSystem.h>
+#include <Fenster.h>
 #include <GraphicsApi.h>
 #include <GraphicsApi.h>
+#include <HttpRequest.h>
+#include <JSON.h>
+#include <main.h>
+#include <Network.h>
 #include <RenderThread.h>
 #include <RenderThread.h>
-#include <Datei.h>
 #include <Schrift.h>
 #include <Schrift.h>
-#include <DateiSystem.h>
-#include "Globals.h"
-#include "CustomDX11API.h"
 
 
+#include "CustomDX11API.h"
+#include "Globals.h"
 
 
 int KSGStart Framework::Start(Framework::Startparam p)
 int KSGStart Framework::Start(Framework::Startparam p)
 {
 {
-	Network::Start(20);
-	initVariables();
-	setDebugDX(1);
+    Network::Start(20);
+    initVariables();
+    setDebugDX(1);
 
 
-	Datei d;
-	d.setDatei("data/schriften");
-	auto list = d.getDateiListe();
-	for (Text* fontFile : *list)
-	{
-		LTDSDatei dat;
-		dat.setPfad(new Text(Text("data/schriften/").operator+(fontFile->getText())));
-		dat.leseDaten();
-		Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
-		fontRegister->put(*name, RCPointer<Schrift>::of(dat.ladeSchrift()));
-		name->release();
-	}
-	list->release();
+    Datei d;
+    d.setDatei("data/schriften");
+    auto list = d.getDateiListe();
+    for (Text* fontFile : *list)
+    {
+        LTDSDatei dat;
+        dat.setPfad(
+            new Text(Text("data/schriften/").operator+(fontFile->getText())));
+        dat.leseDaten();
+        Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
+        fontRegister->put(*name, RCPointer<Schrift>::of(dat.ladeSchrift()));
+        name->release();
+    }
+    list->release();
 
 
-	WFenster window;
-	::window = &window;
-	WNDCLASS wc = Framework::F_Normal(p.hinst);
-	wc.lpszClassName = "Factory Craft";
-	window.erstellen(WS_POPUPWINDOW, wc);
-	Monitor m = Framework::getMonitor(0);
-	window.setBounds(Punkt(m.x, m.y), Punkt(m.breite, m.height));
-	window.setAnzeigeModus(SW_SHOWNORMAL);
-	window.setVSchließAktion([&window](void* p, void* f)
-		{
-			StopNachrichtenSchleife(window.getFensterHandle());
-		});
-	window.setMausAktion(_ret1ME);
-	window.setTastaturAktion(_ret1TE);
-	Bildschirm3D screen(dynamic_cast<WFenster*>(window.getThis()), new CustomDX11API());
-	window.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
-	screen.setFillFarbe(0);
+    WFenster window;
+    ::window = &window;
+    WNDCLASS wc = Framework::F_Normal(p.hinst);
+    wc.lpszClassName = "Factory Craft";
+    window.erstellen(WS_POPUPWINDOW, wc);
+    Monitor m = Framework::getMonitor(0);
+    window.setBounds(Punkt(m.x, m.y), Punkt(m.breite, m.height));
+    window.setAnzeigeModus(SW_SHOWNORMAL);
+    window.setVSchließAktion([&window](void* p, void* f) {
+        StopNachrichtenSchleife(window.getFensterHandle());
+    });
+    window.setMausAktion(_ret1ME);
+    window.setTastaturAktion(_ret1TE);
+    Bildschirm3D screen(
+        dynamic_cast<WFenster*>(window.getThis()), new CustomDX11API());
+    window.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+    screen.setFillFarbe(0);
 
 
-	uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
-	initMenus();
+    uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
+    initMenus();
 
 
-	RenderTh rTh;
-	rTh.setMaxFps(120);
-	rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+    RenderTh rTh;
+    rTh.setMaxFps(120);
+    rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
 
 
-	rTh.beginn();
-	StartNachrichtenSchleife();
-	rTh.beenden();
-	releaseVariables();
-	Network::Exit();
-	return 0;
+    rTh.beginn();
+    StartNachrichtenSchleife();
+    rTh.beenden();
+    releaseVariables();
+    Network::Exit();
+    return 0;
 }
 }

+ 9 - 9
FactoryCraft/Menu.cpp

@@ -1,22 +1,22 @@
 #include "Menu.h"
 #include "Menu.h"
+
 #include <AsynchronCall.h>
 #include <AsynchronCall.h>
 
 
 Menu::Menu(Bildschirm* zScreen)
 Menu::Menu(Bildschirm* zScreen)
-	: ReferenceCounter(),
-	zScreen(zScreen)
+    : ReferenceCounter(),
+      zScreen(zScreen)
 {}
 {}
 
 
 void Menu::show()
 void Menu::show()
 {
 {
-	for (auto member : elements)
-		zScreen->addMember(dynamic_cast<Zeichnung*>(member->getThis()));
+    for (auto member : elements)
+        zScreen->addMember(dynamic_cast<Zeichnung*>(member->getThis()));
 }
 }
 
 
 void Menu::hide()
 void Menu::hide()
 {
 {
-	new AsynchronCall([this]()
-		{
-			for (auto member : elements)
-				zScreen->removeMember(dynamic_cast<Zeichnung*>(member->getThis()));
-		});
+    new AsynchronCall([this]() {
+        for (auto member : elements)
+            zScreen->removeMember(dynamic_cast<Zeichnung*>(member->getThis()));
+    });
 }
 }

+ 6 - 6
FactoryCraft/Menu.h

@@ -1,19 +1,19 @@
 #pragma once
 #pragma once
 #include <Array.h>
 #include <Array.h>
-#include <Zeichnung.h>
 #include <Bildschirm.h>
 #include <Bildschirm.h>
+#include <Zeichnung.h>
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 class Menu : public ReferenceCounter
 class Menu : public ReferenceCounter
 {
 {
 protected:
 protected:
-	RCArray<Zeichnung> elements;
-	Bildschirm* zScreen;
+    RCArray<Zeichnung> elements;
+    Bildschirm* zScreen;
 
 
 public:
 public:
-	Menu(Bildschirm* zScreen);
+    Menu(Bildschirm* zScreen);
 
 
-	void show();
-	void hide();
+    void show();
+    void hide();
 };
 };

+ 31 - 28
FactoryCraft/ModelInfo.cpp

@@ -1,45 +1,48 @@
+#include "ModelInfo.h"
+
 #include <Textur.h>
 #include <Textur.h>
 
 
-#include "ModelInfo.h"
 #include "Globals.h"
 #include "Globals.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 ModelInfo::ModelInfo(Framework::StreamReader* reader)
 ModelInfo::ModelInfo(Framework::StreamReader* reader)
 {
 {
-	char len;
-	reader->lese(&len, 1);
-	char* path = new char[len + 1];
-	reader->lese(path, len);
-	path[len] = 0;
-	modelPath = path;
-	delete[] path;
-	short count;
-	reader->lese((char*)&count, 2);
-	for (int i = 0; i < count; i++)
-	{
-		reader->lese(&len, 1);
-		path = new char[len + 1];
-		reader->lese(path, len);
-		path[len] = 0;
-		texturPaths.add(new Text(path));
-		delete[] path;
-	}
+    char len;
+    reader->lese(&len, 1);
+    char* path = new char[len + 1];
+    reader->lese(path, len);
+    path[len] = 0;
+    modelPath = path;
+    delete[] path;
+    short count;
+    reader->lese((char*)&count, 2);
+    for (int i = 0; i < count; i++)
+    {
+        reader->lese(&len, 1);
+        path = new char[len + 1];
+        reader->lese(path, len);
+        path[len] = 0;
+        texturPaths.add(new Text(path));
+        delete[] path;
+    }
 }
 }
 
 
 Framework::Model3DData* ModelInfo::getModel() const
 Framework::Model3DData* ModelInfo::getModel() const
 {
 {
-	return uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(modelPath);
+    return uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(modelPath);
 }
 }
 
 
 Framework::Model3DTextur* ModelInfo::getTexture() const
 Framework::Model3DTextur* ModelInfo::getTexture() const
 {
 {
-	Model3DTextur* textur = new Model3DTextur();
-	int index = 0;
-	for (Text* texturPath : texturPaths)
-	{
-		Textur* tex = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur(texturPath->getText(), 0);
-		textur->setPolygonTextur(index++, tex);
-	}
-	return textur;
+    Model3DTextur* textur = new Model3DTextur();
+    int index = 0;
+    for (Text* texturPath : texturPaths)
+    {
+        Textur* tex
+            = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur(
+                texturPath->getText(), 0);
+        textur->setPolygonTextur(index++, tex);
+    }
+    return textur;
 }
 }

+ 7 - 7
FactoryCraft/ModelInfo.h

@@ -1,19 +1,19 @@
 #pragma once
 #pragma once
 
 
-#include <Text.h>
 #include <Array.h>
 #include <Array.h>
-#include <Reader.h>
 #include <Model3D.h>
 #include <Model3D.h>
+#include <Reader.h>
+#include <Text.h>
 
 
 class ModelInfo
 class ModelInfo
 {
 {
 private:
 private:
-	Framework::Text modelPath;
-	Framework::RCArray<Framework::Text> texturPaths;
+    Framework::Text modelPath;
+    Framework::RCArray<Framework::Text> texturPaths;
 
 
 public:
 public:
-	ModelInfo(Framework::StreamReader* reader);
+    ModelInfo(Framework::StreamReader* reader);
 
 
-	Framework::Model3DData* getModel() const;
-	Framework::Model3DTextur* getTexture() const;
+    Framework::Model3DData* getModel() const;
+    Framework::Model3DTextur* getTexture() const;
 };
 };

+ 122 - 116
FactoryCraft/PlayerKam.cpp

@@ -1,154 +1,160 @@
-#include <Globals.h>
 #include "PlayerKam.h"
 #include "PlayerKam.h"
-#include "Globals.h"
-#include "Game.h"
 
 
+#include <Globals.h>
+
+#include "Game.h"
+#include "Globals.h"
 
 
 PlayerKam::PlayerKam(Framework::Bildschirm3D* zScreen)
 PlayerKam::PlayerKam(Framework::Bildschirm3D* zScreen)
-	: Kam3D()
+    : Kam3D()
 {
 {
-	kameraControll = 0;
-	setBildschirmPosition(0, 0);
-	setBildschirmSize(zScreen->getBackBufferSize());
-	setStyle(Kam3D::Style::Tick | Kam3D::Style::Movable | Kam3D::Style::Rotatable);
-	setRotation({ (float)PI / 2.f, 0, 0 });
-	entityId = -1;
+    kameraControll = 0;
+    setBildschirmPosition(0, 0);
+    setBildschirmSize(zScreen->getBackBufferSize());
+    setStyle(
+        Kam3D::Style::Tick | Kam3D::Style::Movable | Kam3D::Style::Rotatable);
+    setRotation({(float)PI / 2.f, 0, 0});
+    entityId = -1;
 }
 }
 
 
 void PlayerKam::setDirection(Framework::Vec3<float> direction)
 void PlayerKam::setDirection(Framework::Vec3<float> direction)
 {
 {
-	if (direction.getLengthSq() > 0)
-	{
-		float rotZ = std::atan2(direction.y, direction.x) + (float)PI / 2;
-		setRotation({ getRotation().x, getRotation().y, rotZ });
-	}
+    if (direction.getLengthSq() > 0)
+    {
+        float rotZ = std::atan2(direction.y, direction.x) + (float)PI / 2;
+        setRotation({getRotation().x, getRotation().y, rotZ});
+    }
 }
 }
 
 
 void PlayerKam::doTastaturEreignis(Framework::TastaturEreignis& te)
 void PlayerKam::doTastaturEreignis(Framework::TastaturEreignis& te)
 {
 {
-	if (te.id == TE_Press)
-	{
-		if (te.taste[0] >= '0' && te.taste[0] <= '9')
-		{
-			char action[5];
-			action[0] = 3;
-			*(int*)(action + 1) = te.taste[0] - '1';
-			if (*(int*)(action + 1) < 0)
-				*(int*)(action + 1) = 9;
-			World::INSTANCE->zClient()->sendPlayerAction(action, 5);
-		}
-	}
-	if (te.id == TE_Release)
-	{
-		if (te.virtualKey == T_Esc)
-		{
-			bool oldControl = kameraControll;
-			kameraControll = 0;
-			setShowCursor(true);
-			if (!oldControl)
-				((Game*)(Menu*)menuRegister->get("game"))->closeCurrentDialog();
-		}
-		if (te.virtualKey == T_Tab)
-		{
-			char action = 4;
-			World::INSTANCE->zClient()->sendPlayerAction(&action, 1);
-		}
-	}
+    if (te.id == TE_Press)
+    {
+        if (te.taste[0] >= '0' && te.taste[0] <= '9')
+        {
+            char action[5];
+            action[0] = 3;
+            *(int*)(action + 1) = te.taste[0] - '1';
+            if (*(int*)(action + 1) < 0) *(int*)(action + 1) = 9;
+            World::INSTANCE->zClient()->sendPlayerAction(action, 5);
+        }
+    }
+    if (te.id == TE_Release)
+    {
+        if (te.virtualKey == T_Esc)
+        {
+            bool oldControl = kameraControll;
+            kameraControll = 0;
+            setShowCursor(true);
+            if (!oldControl)
+                ((Game*)(Menu*)menuRegister->get("game"))->closeCurrentDialog();
+        }
+        if (te.virtualKey == T_Tab)
+        {
+            char action = 4;
+            World::INSTANCE->zClient()->sendPlayerAction(&action, 1);
+        }
+    }
 }
 }
 
 
 void PlayerKam::doMausEreignis(Framework::MausEreignis& me)
 void PlayerKam::doMausEreignis(Framework::MausEreignis& me)
 {
 {
-	if (me.verarbeitet)
-	{
-		kameraControll = 0;
-		setShowCursor(true);
-	}
-	else
-	{
-		if (!kameraControll)
-		{
-			if (me.id == ME_PLinks)
-				setControlEnabled(1);
-		}
-		else
-		{
-			if (kameraControll)
-			{
-				if (me.id == ME_PLinks)
-				{
-					char action[2] = { 1, 8 };
-					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
-				}
-				if (me.id == ME_RLinks)
-				{
-					char action[2] = { 0, 8 };
-					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
-				}
-				if (me.id == ME_PRechts)
-				{
-					char action[2] = { 1, 9 };
-					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
-				}
-				if (me.id == ME_RRechts)
-				{
-					char action[2] = { 0, 9 };
-					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
-				}
-			}
-
-		}
-		me.verarbeitet = 1;
-	}
+    if (me.verarbeitet)
+    {
+        kameraControll = 0;
+        setShowCursor(true);
+    }
+    else
+    {
+        if (!kameraControll)
+        {
+            if (me.id == ME_PLinks) setControlEnabled(1);
+        }
+        else
+        {
+            if (kameraControll)
+            {
+                if (me.id == ME_PLinks)
+                {
+                    char action[2] = {1, 8};
+                    World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+                }
+                if (me.id == ME_RLinks)
+                {
+                    char action[2] = {0, 8};
+                    World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+                }
+                if (me.id == ME_PRechts)
+                {
+                    char action[2] = {1, 9};
+                    World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+                }
+                if (me.id == ME_RRechts)
+                {
+                    char action[2] = {0, 9};
+                    World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+                }
+            }
+        }
+        me.verarbeitet = 1;
+    }
 }
 }
 
 
 bool PlayerKam::tick(double time)
 bool PlayerKam::tick(double time)
 {
 {
-	__int64 style = 0;
-	if (hatStyle(Style::Movable))
-		style |= Style::Movable;
-	if (hatStyle(Style::Rotatable))
-		style |= Style::Rotatable;
-	if (hatStyle(Style::Zoomable))
-		style |= Style::Zoomable;
-	removeStyle(Style::Movable | Style::Rotatable | Style::Zoomable);
-	bool result = Kam3D::tick(time);
-	addStyle(style);
-	if (kameraControll)
-	{
-		Punkt dir = window->getGröße() / 2 - (getMausPos() - window->getPosition());
-		setRotation({ min(max(getRotation().x - dir.y * (float)time * 0.2f, 0.1f), 2.5f), getRotation().y, getRotation().z - dir.x * (float)time * 0.2f });
-		if (getRotation().z > 2 * PI)
-			setRotation({ getRotation().x, getRotation().y, getRotation().z - 2.f * (float)PI });
-		if (getRotation().z < -2 * PI)
-			setRotation({ getRotation().x, getRotation().y, getRotation().z + 2.f * (float)PI });
-		SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2, window->getPosition().y + window->getKörperGröße().y / 2);
-		setShowCursor(false);
-		setMausPos(window->getPosition() + window->getGröße() / 2);
-	}
-	return result;
+    __int64 style = 0;
+    if (hatStyle(Style::Movable)) style |= Style::Movable;
+    if (hatStyle(Style::Rotatable)) style |= Style::Rotatable;
+    if (hatStyle(Style::Zoomable)) style |= Style::Zoomable;
+    removeStyle(Style::Movable | Style::Rotatable | Style::Zoomable);
+    bool result = Kam3D::tick(time);
+    addStyle(style);
+    if (kameraControll)
+    {
+        Punkt dir
+            = window->getGröße() / 2 - (getMausPos() - window->getPosition());
+        setRotation(
+            {min(max(getRotation().x - dir.y * (float)time * 0.2f, 0.1f), 2.5f),
+                getRotation().y,
+                getRotation().z - dir.x * (float)time * 0.2f});
+        if (getRotation().z > 2 * PI)
+            setRotation({getRotation().x,
+                getRotation().y,
+                getRotation().z - 2.f * (float)PI});
+        if (getRotation().z < -2 * PI)
+            setRotation({getRotation().x,
+                getRotation().y,
+                getRotation().z + 2.f * (float)PI});
+        SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2,
+            window->getPosition().y + window->getKörperGröße().y / 2);
+        setShowCursor(false);
+        setMausPos(window->getPosition() + window->getGröße() / 2);
+    }
+    return result;
 }
 }
 
 
 void PlayerKam::setEntityId(int id)
 void PlayerKam::setEntityId(int id)
 {
 {
-	entityId = id;
+    entityId = id;
 }
 }
 
 
 void PlayerKam::setControlEnabled(bool enabled)
 void PlayerKam::setControlEnabled(bool enabled)
 {
 {
-	kameraControll = enabled;
-	setShowCursor(!kameraControll);
-	if (kameraControll)
-	{
-		SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2, window->getPosition().y + window->getKörperGröße().y / 2);
-	}
+    kameraControll = enabled;
+    setShowCursor(!kameraControll);
+    if (kameraControll)
+    {
+        SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2,
+            window->getPosition().y + window->getKörperGröße().y / 2);
+    }
 }
 }
 
 
 int PlayerKam::getEntityId() const
 int PlayerKam::getEntityId() const
 {
 {
-	return entityId;
+    return entityId;
 }
 }
 
 
 Framework::Vec3<float> PlayerKam::getDirection() const
 Framework::Vec3<float> PlayerKam::getDirection() const
 {
 {
-	return getWorldDirection(getScreenPos() + getScreenSize() / 2);
+    return getWorldDirection(getScreenPos() + getScreenSize() / 2);
 }
 }

+ 12 - 12
FactoryCraft/PlayerKam.h

@@ -1,23 +1,23 @@
 #pragma once
 #pragma once
+#include <Bildschirm.h>
 #include <Kam3D.h>
 #include <Kam3D.h>
 #include <TastaturEreignis.h>
 #include <TastaturEreignis.h>
-#include <Bildschirm.h>
 #include <Zeit.h>
 #include <Zeit.h>
 
 
 class PlayerKam : public Framework::Kam3D
 class PlayerKam : public Framework::Kam3D
 {
 {
 private:
 private:
-	bool kameraControll;
-	int entityId;
+    bool kameraControll;
+    int entityId;
 
 
 public:
 public:
-	PlayerKam(Framework::Bildschirm3D* zScreen);
-	void setDirection(Framework::Vec3<float> direction);
-	void doTastaturEreignis(Framework::TastaturEreignis& te) override;
-	void doMausEreignis(Framework::MausEreignis& me) override;
-	bool tick(double time) override;
-	void setEntityId(int id);
-	void setControlEnabled(bool enabled);
-	int getEntityId() const;
-	Framework::Vec3<float> getDirection() const;
+    PlayerKam(Framework::Bildschirm3D* zScreen);
+    void setDirection(Framework::Vec3<float> direction);
+    void doTastaturEreignis(Framework::TastaturEreignis& te) override;
+    void doMausEreignis(Framework::MausEreignis& me) override;
+    bool tick(double time) override;
+    void setEntityId(int id);
+    void setControlEnabled(bool enabled);
+    int getEntityId() const;
+    Framework::Vec3<float> getDirection() const;
 };
 };

+ 4 - 4
FactoryCraft/Registries.h

@@ -1,13 +1,13 @@
 #pragma once
 #pragma once
 
 
-#include "StaticRegistry.h"
-#include "WorldUpdate.h"
 #include "BlockType.h"
 #include "BlockType.h"
-#include "ItemType.h"
 #include "EntityType.h"
 #include "EntityType.h"
+#include "ItemType.h"
+#include "StaticRegistry.h"
+#include "WorldUpdate.h"
 
 
 #ifndef _REGISTRY
 #ifndef _REGISTRY
-#define _REGISTRY extern
+#    define _REGISTRY extern
 #endif
 #endif
 
 
 #define STATIC_REGISTRY(Type) Type##Registry
 #define STATIC_REGISTRY(Type) Type##Registry

+ 3 - 3
FactoryCraft/StaticInitializerOrder.cpp

@@ -5,9 +5,9 @@
 int count_WorldUpdateType = 0;
 int count_WorldUpdateType = 0;
 
 
 #undef REGISTER
 #undef REGISTER
-#define REGISTER(c, typ)               \
-const int c::ID = count_##typ++;       \
-const c *c::INSTANCE = new c(); 
+#define REGISTER(c, typ)             \
+    const int c::ID = count_##typ++; \
+    const c* c::INSTANCE = new c();
 
 
 // order of includes determines the ids
 // order of includes determines the ids
 
 

+ 50 - 52
FactoryCraft/StaticRegistry.h

@@ -1,68 +1,66 @@
 #pragma once
 #pragma once
 
 
-#define REGISTRABLE( c )          \
-public:                           \
-    static const c *INSTANCE;     \
-    static const int ID;          \
-                                  \
+#define REGISTRABLE(c)        \
+                              \
+public:                       \
+    static const c* INSTANCE; \
+    static const int ID;      \
+                              \
 private:
 private:
 
 
 #define REGISTER(c, typ)
 #define REGISTER(c, typ)
 
 
-
-template<typename T>
-class StaticRegistry
+template<typename T> class StaticRegistry
 {
 {
 private:
 private:
-	T** registry;
-	int count;
+    T** registry;
+    int count;
 
 
 public:
 public:
-	StaticRegistry()
-	{
-		count = 1;
-		registry = new T * [count];
-		memset(registry, 0, sizeof(T*) * count);
-	}
+    StaticRegistry()
+    {
+        count = 1;
+        registry = new T*[count];
+        memset(registry, 0, sizeof(T*) * count);
+    }
 
 
-	~StaticRegistry()
-	{
-		for (int index = 0; index < count; index++)
-		{
-			if (registry[index])
-			{
-				registry[index]->release();
-				registry[index] = 0;
-			}
-		}
-		delete[]registry;
-	}
+    ~StaticRegistry()
+    {
+        for (int index = 0; index < count; index++)
+        {
+            if (registry[index])
+            {
+                registry[index]->release();
+                registry[index] = 0;
+            }
+        }
+        delete[] registry;
+    }
 
 
-	void registerT(T* type, int id)
-	{
-		if (id >= count)
-		{
-			T** temp = new T * [id + 1];
-			memcpy(temp, registry, sizeof(T*) * count);
-			memset(temp + count, 0, sizeof(T*) * (id + 1 - count));
-			delete[]registry;
-			registry = temp;
-			count = id + 1;
-		}
-		registry[id] = type;
-	}
+    void registerT(T* type, int id)
+    {
+        if (id >= count)
+        {
+            T** temp = new T*[id + 1];
+            memcpy(temp, registry, sizeof(T*) * count);
+            memset(temp + count, 0, sizeof(T*) * (id + 1 - count));
+            delete[] registry;
+            registry = temp;
+            count = id + 1;
+        }
+        registry[id] = type;
+    }
 
 
-	T* zElement(int id)
-	{
-		if (id < 0 || id >= count)
-			return 0;
-		return registry[id];
-	}
+    T* zElement(int id)
+    {
+        if (id < 0 || id >= count) return 0;
+        return registry[id];
+    }
 
 
-	int getCount() const
-	{
-		return count;
-	}
+    int getCount() const
+    {
+        return count;
+    }
 
 
-	friend T;
+    friend T;
 };
 };

+ 16 - 13
FactoryCraft/UIMLToolTip.cpp

@@ -1,26 +1,29 @@
 #include "UIMLToolTip.h"
 #include "UIMLToolTip.h"
+
 #include "Globals.h"
 #include "Globals.h"
 
 
 using namespace Framework;
 using namespace Framework;
 
 
 UIMLToolTip::UIMLToolTip()
 UIMLToolTip::UIMLToolTip()
-	: ToolTip(window->zBildschirm())
+    : ToolTip(window->zBildschirm())
 {
 {
-	view = new UIMLView("", uiFactory);
-	addMember(view);
-	view->setStyle(UIMLView::Style::Sichtbar);
-	addStyle(ZeichnungHintergrund::Style::Hintergrund | ZeichnungHintergrund::Style::HAlpha | ZeichnungHintergrund::Style::Rahmen | ZeichnungHintergrund::Style::Sichtbar);
-	setHintergrundFarbe(0xA0000000);
-	setRahmenFarbe(0xFFFFFFFF);
-	setRahmenBreite(1);
+    view = new UIMLView("", uiFactory);
+    addMember(view);
+    view->setStyle(UIMLView::Style::Sichtbar);
+    addStyle(ZeichnungHintergrund::Style::Hintergrund
+             | ZeichnungHintergrund::Style::HAlpha
+             | ZeichnungHintergrund::Style::Rahmen
+             | ZeichnungHintergrund::Style::Sichtbar);
+    setHintergrundFarbe(0xA0000000);
+    setRahmenFarbe(0xFFFFFFFF);
+    setRahmenBreite(1);
 }
 }
 
 
-UIMLToolTip::~UIMLToolTip()
-{}
+UIMLToolTip::~UIMLToolTip() {}
 
 
 void UIMLToolTip::setUIML(const char* uiml)
 void UIMLToolTip::setUIML(const char* uiml)
 {
 {
-	view->setUIML(uiml);
-	view->layout();
-	view->setSize(view->calculateContentSize());
+    view->setUIML(uiml);
+    view->layout();
+    view->setSize(view->calculateContentSize());
 }
 }

+ 251 - 233
FactoryCraft/World.cpp

@@ -1,14 +1,16 @@
-#include <Network.h>
-#include <Welt3D.h>
+#include "World.h"
+
+#include <AsynchronCall.h>
 #include <GraphicsApi.h>
 #include <GraphicsApi.h>
 #include <iostream>
 #include <iostream>
-#include "World.h"
-#include "Globals.h"
-#include "WorldUpdate.h"
+#include <Network.h>
+#include <Welt3D.h>
+
 #include "Constants.h"
 #include "Constants.h"
-#include "Registries.h"
 #include "Game.h"
 #include "Game.h"
-#include <AsynchronCall.h>
+#include "Globals.h"
+#include "Registries.h"
+#include "WorldUpdate.h"
 
 
 using namespace Network;
 using namespace Network;
 using namespace Framework;
 using namespace Framework;
@@ -16,323 +18,339 @@ using namespace Framework;
 World* World::INSTANCE = 0;
 World* World::INSTANCE = 0;
 
 
 World::World(Bildschirm3D* zScreen, FactoryClient* client)
 World::World(Bildschirm3D* zScreen, FactoryClient* client)
-	: Thread(),
-	client(client)
+    : Thread(),
+      client(client)
 {
 {
-	renderedWorld = new Welt3D();
-	renderedWorld->addDiffuseLight(DiffuseLight{ Vec3<float>(0.5f, 0.5f, -1.f), Vec3<float>(1.f, 1.f, 1.f) });
-	currentDimension = new Dimension();
-	zScreenPtr = zScreen;
-	kam = new PlayerKam(zScreen);
-	kam->setWelt(renderedWorld);
-	zScreen->addKamera(kam);
-	firstMessage = 1;
-	ownEntityId = -1;
-	currentTarget = 0;
-	start();
+    renderedWorld = new Welt3D();
+    renderedWorld->addDiffuseLight(DiffuseLight{
+        Vec3<float>(0.5f, 0.5f, -1.f), Vec3<float>(1.f, 1.f, 1.f)});
+    currentDimension = new Dimension();
+    zScreenPtr = zScreen;
+    kam = new PlayerKam(zScreen);
+    kam->setWelt(renderedWorld);
+    zScreen->addKamera(kam);
+    firstMessage = 1;
+    ownEntityId = -1;
+    currentTarget = 0;
+    start();
 }
 }
 
 
 World::~World()
 World::~World()
 {
 {
-	zScreenPtr->removeKamera(kam);
-	currentDimension->release();
-	if (currentTarget)
-		currentTarget->release();
-	client->release();
+    zScreenPtr->removeKamera(kam);
+    currentDimension->release();
+    if (currentTarget) currentTarget->release();
+    client->release();
 }
 }
 
 
 void World::update(bool background)
 void World::update(bool background)
 {
 {
-	NetworkReader* serverMessageReader = 0;
-	unsigned char type = 0;
-	while (background ? serverMessageReader = client->getNextBackgroundMessage() : serverMessageReader = client->getNextForegroundMessage())
-	{
-		serverMessageReader->lese((char*)&type, 1);
-		if (type == 2) // WORLD UPDATE
-		{
-			int id = 0;
-			serverMessageReader->lese((char*)&id, 4);
-			STATIC_REGISTRY(WorldUpdateType).zElement(id)->applyUpdateAndCheck(serverMessageReader);
-		}
-		if (type == 3) // API MESSAGE
-		{
-			int length;
-			serverMessageReader->lese((char*)&length, 4);
-			char* data = new char[length];
-			serverMessageReader->lese(data, length);
-			switch (data[0])
-			{
-			case 1: // dimension message
-			{
-				currentDimension->api(data + 1);
-				break;
-			}
-			case 2: // gui message
-				((Game*)(Menu*)menuRegister->get("game"))->api(data + 1);
-				break;
-			case 3: // set target
-			{
-				switch (data[1])
-				{
-				case 0:
-					setTarget(0);
-					break;
-				case 1:
-					setTarget(zEntity(*(int*)(data + 2)));
-					break;
-				case 2:
-					setTarget(zBlockAt(Vec3<int>(*(int*)(data + 2), *(int*)(data + 6), *(int*)(data + 10))));
-					break;
-				}
-				break;
-			}
-			}
-			delete[] data;
-			// TODO: process messages
-		}
-		if (type == 4) // POSITION UPDATE
-		{
-			int old = ownEntityId;
-			serverMessageReader->lese((char*)&ownEntityId, 4);
-			kam->setEntityId(ownEntityId);
-			Entity* p = zEntity(ownEntityId);
-			if (p)
-				p->setPlayerControlled();
-			if (old != ownEntityId)
-				client->sendPlayerAction("\5", 1);
-		}
-		client->endMessageReading(background);
-	}
-	client->endMessageReading(background);
-	Entity* player = getCurrentPlayerEntity();
-	if (player)
-	{
-		renderedWorld->lock();
-		currentDimension->removeDistantChunks({ (int)player->getPos().x, (int)player->getPos().y });
-		Punkt currentChunk = getChunkCenter((int)player->getX(), (int)player->getY());
-		for (int x = 0; x <= CHUNK_VISIBILITY_RANGE; x++)
-		{
-			for (int y = 0; y <= CHUNK_VISIBILITY_RANGE; y++)
-			{
-				std::function<void(Punkt)> requestChunk = [this](Punkt center)
-				{
-					Chunk* zC = currentDimension->zChunk(center);
-					if (!zC)
-					{
-						char msg[1];
-						msg[0] = 0; // add observer and request chaunk data
-						Punkt pos = center;
-						subLock.lock();
-						bool found = 0;
-						for (Punkt p : subscriptions)
-						{
-							if (p == pos)
-							{
-								found = 1;
-								break;
-							}
-						}
-						if (!found)
-						{
-							client->chunkAPIRequest(pos, msg, 1);
-							subscriptions.add(pos);
-						}
-						subLock.unlock();
-					}
-				};
-				requestChunk(currentChunk + Punkt(x * CHUNK_SIZE, y * CHUNK_SIZE));
-				if (y > 0)
-					requestChunk(currentChunk + Punkt(x * CHUNK_SIZE, -y * CHUNK_SIZE));
-				if (x > 0)
-				{
-					requestChunk(currentChunk + Punkt(-x * CHUNK_SIZE, y * CHUNK_SIZE));
-					if (y > 0)
-						requestChunk(currentChunk + Punkt(-x * CHUNK_SIZE, -y * CHUNK_SIZE));
-				}
-			}
-		}
-		renderedWorld->unlock();
-	}
+    NetworkReader* serverMessageReader = 0;
+    unsigned char type = 0;
+    while (background
+               ? serverMessageReader = client->getNextBackgroundMessage()
+               : serverMessageReader = client->getNextForegroundMessage())
+    {
+        serverMessageReader->lese((char*)&type, 1);
+        if (type == 2) // WORLD UPDATE
+        {
+            int id = 0;
+            serverMessageReader->lese((char*)&id, 4);
+            STATIC_REGISTRY(WorldUpdateType)
+                .zElement(id)
+                ->applyUpdateAndCheck(serverMessageReader);
+        }
+        if (type == 3) // API MESSAGE
+        {
+            int length;
+            serverMessageReader->lese((char*)&length, 4);
+            char* data = new char[length];
+            serverMessageReader->lese(data, length);
+            switch (data[0])
+            {
+            case 1: // dimension message
+                {
+                    currentDimension->api(data + 1);
+                    break;
+                }
+            case 2: // gui message
+                ((Game*)(Menu*)menuRegister->get("game"))->api(data + 1);
+                break;
+            case 3: // set target
+                {
+                    switch (data[1])
+                    {
+                    case 0:
+                        setTarget(0);
+                        break;
+                    case 1:
+                        setTarget(zEntity(*(int*)(data + 2)));
+                        break;
+                    case 2:
+                        setTarget(zBlockAt(Vec3<int>(*(int*)(data + 2),
+                            *(int*)(data + 6),
+                            *(int*)(data + 10))));
+                        break;
+                    }
+                    break;
+                }
+            }
+            delete[] data;
+            // TODO: process messages
+        }
+        if (type == 4) // POSITION UPDATE
+        {
+            int old = ownEntityId;
+            serverMessageReader->lese((char*)&ownEntityId, 4);
+            kam->setEntityId(ownEntityId);
+            Entity* p = zEntity(ownEntityId);
+            if (p) p->setPlayerControlled();
+            if (old != ownEntityId) client->sendPlayerAction("\5", 1);
+        }
+        client->endMessageReading(background);
+    }
+    client->endMessageReading(background);
+    Entity* player = getCurrentPlayerEntity();
+    if (player)
+    {
+        renderedWorld->lock();
+        currentDimension->removeDistantChunks(
+            {(int)player->getPos().x, (int)player->getPos().y});
+        Punkt currentChunk
+            = getChunkCenter((int)player->getX(), (int)player->getY());
+        for (int x = 0; x <= CHUNK_VISIBILITY_RANGE; x++)
+        {
+            for (int y = 0; y <= CHUNK_VISIBILITY_RANGE; y++)
+            {
+                std::function<void(Punkt)> requestChunk = [this](Punkt center) {
+                    Chunk* zC = currentDimension->zChunk(center);
+                    if (!zC)
+                    {
+                        char msg[1];
+                        msg[0] = 0; // add observer and request chaunk data
+                        Punkt pos = center;
+                        subLock.lock();
+                        bool found = 0;
+                        for (Punkt p : subscriptions)
+                        {
+                            if (p == pos)
+                            {
+                                found = 1;
+                                break;
+                            }
+                        }
+                        if (!found)
+                        {
+                            client->chunkAPIRequest(pos, msg, 1);
+                            subscriptions.add(pos);
+                        }
+                        subLock.unlock();
+                    }
+                };
+                requestChunk(
+                    currentChunk + Punkt(x * CHUNK_SIZE, y * CHUNK_SIZE));
+                if (y > 0)
+                    requestChunk(
+                        currentChunk + Punkt(x * CHUNK_SIZE, -y * CHUNK_SIZE));
+                if (x > 0)
+                {
+                    requestChunk(
+                        currentChunk + Punkt(-x * CHUNK_SIZE, y * CHUNK_SIZE));
+                    if (y > 0)
+                        requestChunk(currentChunk
+                                     + Punkt(-x * CHUNK_SIZE, -y * CHUNK_SIZE));
+                }
+            }
+        }
+        renderedWorld->unlock();
+    }
 }
 }
 
 
 void World::setChunk(Chunk* chunk)
 void World::setChunk(Chunk* chunk)
 {
 {
-	zScreenPtr->lock();
-	renderedWorld->lock();
-	currentDimension->setChunk(chunk, chunk->getCenter());
-	renderedWorld->unlock();
-	zScreenPtr->unlock();
+    zScreenPtr->lock();
+    renderedWorld->lock();
+    currentDimension->setChunk(chunk, chunk->getCenter());
+    renderedWorld->unlock();
+    zScreenPtr->unlock();
 }
 }
 
 
 void World::thread()
 void World::thread()
 {
 {
-	new AsynchronCall("World Update", [this]()
-		{
-			while (true)
-			{
-				zScreenPtr->lock();
-				if (World::INSTANCE != this)
-				{
-					zScreenPtr->unlock();
-					return;
-				}
-				zScreenPtr->unlock();
-				update(0);
-				Sleep(10);
-			}
-		});
-	while (true)
-	{
-		zScreenPtr->lock();
-		if (World::INSTANCE != this)
-		{
-			zScreenPtr->unlock();
-			return;
-		}
-		zScreenPtr->unlock();
-		update(1);
-		Sleep(10);
-	}
+    new AsynchronCall("World Update", [this]() {
+        while (true)
+        {
+            zScreenPtr->lock();
+            if (World::INSTANCE != this)
+            {
+                zScreenPtr->unlock();
+                return;
+            }
+            zScreenPtr->unlock();
+            update(0);
+            Sleep(10);
+        }
+    });
+    while (true)
+    {
+        zScreenPtr->lock();
+        if (World::INSTANCE != this)
+        {
+            zScreenPtr->unlock();
+            return;
+        }
+        zScreenPtr->unlock();
+        update(1);
+        Sleep(10);
+    }
 }
 }
 
 
 Block* World::zBlockAt(Framework::Vec3<int> location) const
 Block* World::zBlockAt(Framework::Vec3<int> location) const
 {
 {
-	return currentDimension->zBlock(location);
-	return 0;
+    return currentDimension->zBlock(location);
+    return 0;
 }
 }
 
 
 Block* World::getBlockAt(Framework::Vec3<int> location) const
 Block* World::getBlockAt(Framework::Vec3<int> location) const
 {
 {
-	return currentDimension->getBlock(location);
-	return 0;
+    return currentDimension->getBlock(location);
+    return 0;
 }
 }
 
 
 Dimension* World::zDimension() const
 Dimension* World::zDimension() const
 {
 {
-	return currentDimension;
+    return currentDimension;
 }
 }
 
 
 void World::setVisibility(Chunk* zChunk, bool visible)
 void World::setVisibility(Chunk* zChunk, bool visible)
 {
 {
-	renderedWorld->lock();
-	if (visible)
-		renderedWorld->addCollection(dynamic_cast<Framework::Model3DCollection*>(zChunk->getThis()));
-	else
-		renderedWorld->removeCollection(zChunk);
-	renderedWorld->unlock();
+    renderedWorld->lock();
+    if (visible)
+        renderedWorld->addCollection(
+            dynamic_cast<Framework::Model3DCollection*>(zChunk->getThis()));
+    else
+        renderedWorld->removeCollection(zChunk);
+    renderedWorld->unlock();
 }
 }
 
 
 void World::setVisibility(Entity* zEntity, bool visible)
 void World::setVisibility(Entity* zEntity, bool visible)
 {
 {
-	renderedWorld->lock();
-	if (visible)
-		renderedWorld->addZeichnung(dynamic_cast<Framework::Model3D*>(zEntity->getThis()));
-	else
-		renderedWorld->removeZeichnung(zEntity);
-	renderedWorld->unlock();
+    renderedWorld->lock();
+    if (visible)
+        renderedWorld->addZeichnung(
+            dynamic_cast<Framework::Model3D*>(zEntity->getThis()));
+    else
+        renderedWorld->removeZeichnung(zEntity);
+    renderedWorld->unlock();
 }
 }
 
 
 Framework::Punkt World::getChunkCenter(int x, int y) const
 Framework::Punkt World::getChunkCenter(int x, int y) const
 {
 {
-	return Punkt(((x < 0 ? x + 1 : x) / CHUNK_SIZE) * CHUNK_SIZE + (x < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2, ((y < 0 ? y + 1 : y) / CHUNK_SIZE) * CHUNK_SIZE + (y < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2);
+    return Punkt(((x < 0 ? x + 1 : x) / CHUNK_SIZE) * CHUNK_SIZE
+                     + (x < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2,
+        ((y < 0 ? y + 1 : y) / CHUNK_SIZE) * CHUNK_SIZE
+            + (y < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2);
 }
 }
 
 
 Entity* World::zEntity(int id) const
 Entity* World::zEntity(int id) const
 {
 {
-	Entity* e = currentDimension->zEntity(id);
-	if (e)
-		return e;
-	return 0;
+    Entity* e = currentDimension->zEntity(id);
+    if (e) return e;
+    return 0;
 }
 }
 
 
 Entity* World::getEntity(int id) const
 Entity* World::getEntity(int id) const
 {
 {
-	Entity* e = currentDimension->getEntity(id);
-	if (e)
-		return e;
-	return 0;
+    Entity* e = currentDimension->getEntity(id);
+    if (e) return e;
+    return 0;
 }
 }
 
 
 void World::removeEntity(int id)
 void World::removeEntity(int id)
 {
 {
-	currentDimension->removeEntity(id);
+    currentDimension->removeEntity(id);
 }
 }
 
 
 PlayerKam* World::zKamera() const
 PlayerKam* World::zKamera() const
 {
 {
-	return kam;
+    return kam;
 }
 }
 
 
 int World::getCurrentPlayerId() const
 int World::getCurrentPlayerId() const
 {
 {
-	return ownEntityId;
+    return ownEntityId;
 }
 }
 
 
 Entity* World::getCurrentPlayerEntity() const
 Entity* World::getCurrentPlayerEntity() const
 {
 {
-	return zEntity(ownEntityId);
+    return zEntity(ownEntityId);
 }
 }
 
 
 void World::setTarget(Framework::Model3D* zTarget)
 void World::setTarget(Framework::Model3D* zTarget)
 {
 {
-	if (zTarget != currentTarget)
-	{
-		targetLock.lock();
-		if (currentTarget)
-		{
-			currentTarget->setAmbientFactor(currentTarget->getAmbientFactor() - 0.2f);
-			currentTarget->release();
-			currentTarget = 0;
-		}
-		if (zTarget)
-		{
-			currentTarget = dynamic_cast<Framework::Model3D*>(zTarget->getThis());
-			if (currentTarget)
-				currentTarget->setAmbientFactor(currentTarget->getAmbientFactor() + 0.2f);
-		}
-		targetLock.unlock();
-	}
+    if (zTarget != currentTarget)
+    {
+        targetLock.lock();
+        if (currentTarget)
+        {
+            currentTarget->setAmbientFactor(
+                currentTarget->getAmbientFactor() - 0.2f);
+            currentTarget->release();
+            currentTarget = 0;
+        }
+        if (zTarget)
+        {
+            currentTarget
+                = dynamic_cast<Framework::Model3D*>(zTarget->getThis());
+            if (currentTarget)
+                currentTarget->setAmbientFactor(
+                    currentTarget->getAmbientFactor() + 0.2f);
+        }
+        targetLock.unlock();
+    }
 }
 }
 
 
 void World::lockWorld()
 void World::lockWorld()
 {
 {
-	renderedWorld->lock();
+    renderedWorld->lock();
 }
 }
 
 
 void World::unlockWorld()
 void World::unlockWorld()
 {
 {
-	renderedWorld->unlock();
+    renderedWorld->unlock();
 }
 }
 
 
 void World::onChunkAdded(Punkt pos)
 void World::onChunkAdded(Punkt pos)
 {
 {
-	subLock.lock();
-	int index = 0;
-	for (Punkt p : subscriptions)
-	{
-		if (p == pos)
-		{
-			subscriptions.remove(index);
-			break;
-		}
-		index++;
-	}
-	subLock.unlock();
+    subLock.lock();
+    int index = 0;
+    for (Punkt p : subscriptions)
+    {
+        if (p == pos)
+        {
+            subscriptions.remove(index);
+            break;
+        }
+        index++;
+    }
+    subLock.unlock();
 }
 }
 
 
 Framework::Model3D* World::getCurrentTarget() const
 Framework::Model3D* World::getCurrentTarget() const
 {
 {
-	while (targetLock.isLocked())
-		Sleep(1);
-	return currentTarget ? dynamic_cast<Framework::Model3D*>(currentTarget->getThis()) : 0;
+    while (targetLock.isLocked())
+        Sleep(1);
+    return currentTarget
+             ? dynamic_cast<Framework::Model3D*>(currentTarget->getThis())
+             : 0;
 }
 }
 
 
 Chunk* World::zChunk(Punkt center)
 Chunk* World::zChunk(Punkt center)
 {
 {
-	return currentDimension->zChunk(center);
+    return currentDimension->zChunk(center);
 }
 }
 
 
 FactoryClient* World::zClient() const
 FactoryClient* World::zClient() const
 {
 {
-	return client;
+    return client;
 }
 }

+ 39 - 39
FactoryCraft/World.h

@@ -1,56 +1,56 @@
 #pragma once
 #pragma once
 
 
-#include <Welt3D.h>
 #include <Bildschirm.h>
 #include <Bildschirm.h>
 #include <Kam3D.h>
 #include <Kam3D.h>
 #include <Thread.h>
 #include <Thread.h>
+#include <Welt3D.h>
 
 
 #include "Dimension.h"
 #include "Dimension.h"
-#include "PlayerKam.h"
 #include "FactoryClient.h"
 #include "FactoryClient.h"
+#include "PlayerKam.h"
 
 
 class World : public Framework::Thread
 class World : public Framework::Thread
 {
 {
 public:
 public:
-	static World* INSTANCE;
-	
+    static World* INSTANCE;
+
 private:
 private:
-	Dimension* currentDimension;
-	Framework::Welt3D* renderedWorld;
-	Framework::Bildschirm3D* zScreenPtr;
-	PlayerKam* kam;
-	bool firstMessage;
-	int ownEntityId;
-	Framework::Model3D* currentTarget;
-	Array<Punkt> subscriptions;
-	FactoryClient* client;
-	Critical subLock;
-	Critical targetLock;
+    Dimension* currentDimension;
+    Framework::Welt3D* renderedWorld;
+    Framework::Bildschirm3D* zScreenPtr;
+    PlayerKam* kam;
+    bool firstMessage;
+    int ownEntityId;
+    Framework::Model3D* currentTarget;
+    Array<Punkt> subscriptions;
+    FactoryClient* client;
+    Critical subLock;
+    Critical targetLock;
 
 
 public:
 public:
-	World(Framework::Bildschirm3D* zScreen, FactoryClient* client);
-	~World();
-	void update(bool background);
-	void setChunk(Chunk* chunk);
-	void thread() override;
+    World(Framework::Bildschirm3D* zScreen, FactoryClient* client);
+    ~World();
+    void update(bool background);
+    void setChunk(Chunk* chunk);
+    void thread() override;
 
 
-	Block* zBlockAt(Framework::Vec3<int> location) const;
-	Block* getBlockAt(Framework::Vec3<int> location) const;
-	Dimension* zDimension() const;
-	void setVisibility(Chunk* zChunk, bool visible);
-	void setVisibility(Entity* zEntity, bool visible);
-	Framework::Punkt getChunkCenter(int x, int y) const;
-	Entity* zEntity(int id) const;
-	Entity* getEntity(int id) const;
-	void removeEntity(int id);
-	PlayerKam* zKamera() const;
-	int getCurrentPlayerId() const;
-	Entity* getCurrentPlayerEntity() const;
-	void setTarget(Framework::Model3D* zTarget);
-	void lockWorld();
-	void unlockWorld();
-	void onChunkAdded(Punkt pos);
-	Chunk* zChunk(Punkt center);
-	Framework::Model3D* getCurrentTarget() const;
-	FactoryClient* zClient() const;
+    Block* zBlockAt(Framework::Vec3<int> location) const;
+    Block* getBlockAt(Framework::Vec3<int> location) const;
+    Dimension* zDimension() const;
+    void setVisibility(Chunk* zChunk, bool visible);
+    void setVisibility(Entity* zEntity, bool visible);
+    Framework::Punkt getChunkCenter(int x, int y) const;
+    Entity* zEntity(int id) const;
+    Entity* getEntity(int id) const;
+    void removeEntity(int id);
+    PlayerKam* zKamera() const;
+    int getCurrentPlayerId() const;
+    Entity* getCurrentPlayerEntity() const;
+    void setTarget(Framework::Model3D* zTarget);
+    void lockWorld();
+    void unlockWorld();
+    void onChunkAdded(Punkt pos);
+    Chunk* zChunk(Punkt center);
+    Framework::Model3D* getCurrentTarget() const;
+    FactoryClient* zClient() const;
 };
 };

+ 17 - 15
FactoryCraft/WorldUpdate.cpp

@@ -1,26 +1,28 @@
 #include "WorldUpdate.h"
 #include "WorldUpdate.h"
 
 
-#include "Registries.h"
 #include <Text.h>
 #include <Text.h>
 
 
+#include "Registries.h"
+
 WorldUpdateType::WorldUpdateType(int id)
 WorldUpdateType::WorldUpdateType(int id)
-	: ReferenceCounter(),
-	id(id)
+    : ReferenceCounter(),
+      id(id)
 {
 {
-	STATIC_REGISTRY(WorldUpdateType).registerT(this, id);
+    STATIC_REGISTRY(WorldUpdateType).registerT(this, id);
 }
 }
 
 
 void WorldUpdateType::applyUpdateAndCheck(Framework::StreamReader* zReader)
 void WorldUpdateType::applyUpdateAndCheck(Framework::StreamReader* zReader)
 {
 {
-	this->applyUpdate(zReader);
-	int id;
-	zReader->lese((char*)&id, 4);
-	if (id != this->id)
-	{
-		Framework::Text* t = new Framework::Text("asynchony after world update of type ");
-		t->append(this->id);
-		t->append(". ID received from server was: ");
-		t->append(id);
-		throw t->getText();
-	}
+    this->applyUpdate(zReader);
+    int id;
+    zReader->lese((char*)&id, 4);
+    if (id != this->id)
+    {
+        Framework::Text* t
+            = new Framework::Text("asynchony after world update of type ");
+        t->append(this->id);
+        t->append(". ID received from server was: ");
+        t->append(id);
+        throw t->getText();
+    }
 }
 }

+ 5 - 5
FactoryCraft/WorldUpdate.h

@@ -1,19 +1,19 @@
 #pragma once
 #pragma once
 
 
-#include <ReferenceCounter.h>
 #include <Reader.h>
 #include <Reader.h>
+#include <ReferenceCounter.h>
 
 
 #include "StaticRegistry.h"
 #include "StaticRegistry.h"
 
 
 class WorldUpdateType : public Framework::ReferenceCounter
 class WorldUpdateType : public Framework::ReferenceCounter
 {
 {
 private:
 private:
-	int id;
+    int id;
 
 
 protected:
 protected:
-	WorldUpdateType(int id);
-	virtual void applyUpdate(Framework::StreamReader* zReader) = 0;
+    WorldUpdateType(int id);
+    virtual void applyUpdate(Framework::StreamReader* zReader) = 0;
 
 
 public:
 public:
-	void applyUpdateAndCheck(Framework::StreamReader* zReader);
+    void applyUpdateAndCheck(Framework::StreamReader* zReader);
 };
 };

+ 30 - 0
enc_temp_folder/107b1a479d1edc90e5af3d148a259357/Equipment.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "NetworkAPIProcessor.h"
+
+#include <UIMLView.h>
+
+class EquipmentElement : public Framework::UIMLElement
+{
+public:
+	EquipmentElement();
+	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+	bool isApplicableFor(Framework::XML::Element& element) override;
+	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
+	//! wendet die layout parameter zu einer Zeichnung an
+	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+};
+
+class EquipmentView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor
+{
+private:
+	int entityId;
+
+public:
+	EquipmentView(int entityId);
+	void api(char* message) override;
+	bool tick(double tickVal) override;
+	void render(Framework::Bild& rObj) override;
+	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+};

+ 19 - 0
enc_temp_folder/1143b7508c7358196f99bc3caaa0fd/ModelInfo.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include <Text.h>
+#include <Array.h>
+#include <Reader.h>
+#include <Model3D.h>
+
+class ModelInfo
+{
+private:
+	Framework::Text modelPath;
+	Framework::RCArray<Framework::Text> texturPaths;
+
+public:
+	ModelInfo(Framework::StreamReader* reader);
+
+	Framework::Model3DData* getModel() const;
+	Framework::Model3DTextur* getTexture() const;
+};

+ 44 - 0
enc_temp_folder/1e8437822bd13cd1a5e19507ca641b0/Block.h

@@ -0,0 +1,44 @@
+#pragma once
+
+#include <Model3D.h>
+
+#include "BlockType.h"
+#include "Registries.h"
+#include "Area.h"
+
+using namespace Framework;
+
+class BasicBlockItemType;
+class Chunk;
+
+class Block : public Model3D
+{
+protected:
+	bool transparent;
+	float hp;
+	float maxHP;
+	const BlockType* zType;
+	bool sideVisible[6];
+	Vec3<int> location;
+	Framework::Textur* breakTextur;
+	unsigned char lightData[6 * 6];
+	char lightBuffer[24 * 4];
+
+	void beforeRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
+	void afterRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;
+public:
+	Block(const BlockType* zType, Vec3<int> position, Model3DData* model, Model3DTextur* texture, int maxHp);
+	virtual ~Block();
+
+	void api(char* message);
+	bool isTransparent() const;
+	void setLightData(Direction dir, unsigned char* data);
+	bool isVisible() const;
+
+	Vec3<int> getLocation() const;
+	const BlockType* zBlockType() const;
+	Textur* zEffectTextur() override;
+	float getEffectPercentage() override;
+	friend Chunk;
+	Text printLightInfo();
+};

+ 396 - 0
enc_temp_folder/21617dc069ecd3eaef31d6ce92fc56e5/InventoryView.cpp

@@ -0,0 +1,396 @@
+#include <XML.h>
+#include <Bild.h>
+
+#include "InventoryView.h"
+#include "Globals.h"
+#include "DragController.h"
+#include "Globals.h"
+#include "Game.h"
+#include "UIMLToolTip.h"
+
+using namespace Framework;
+
+InventoryElement::InventoryElement()
+	: UIMLElement()
+{}
+
+//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+bool InventoryElement::isApplicableFor(Framework::XML::Element& element)
+{
+	return element.getName().istGleich("inventory");
+}
+
+//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+Framework::Zeichnung* InventoryElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+{
+	Text targetValue = element.getAttributeValue("target");
+	Vec3<int> blockPos(0, 0, 0);
+	Framework::Either<int, VecN<int, 4>> target((int)targetValue);
+	if (targetValue.hat(','))
+	{
+		Text* first = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
+		Text* second = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1, targetValue.positionVon(",", 1));
+		Text* third = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1, targetValue.positionVon(",", 2));
+		Text* forth = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
+		target = Framework::Either<int, VecN<int, 4>>(Framework::VecN<int, 4>({ (int)*first, (int)*second, (int)*third, (int)*forth }));
+		first->release();
+		second->release();
+		third->release();
+		forth->release();
+	}
+	return new InventoryView(element.getAttributeValue("id"), target, (int)element.getAttributeValue("rowSize"), element.getAttributeValue("slotNameFilter"));
+}
+
+//! wendet die layout parameter zu einer Zeichnung an
+void InventoryElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+{
+	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+}
+
+
+void SlotInfo::render(int x, int y, Framework::Bild& rObj, bool selected, bool lightBackground)
+{
+	TextRenderer tr;
+	tr.setSchriftZ(dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
+	tr.setSchriftSize(12);
+	rObj.fillRegion(x, y, 52, 52, selected ? 0xFFFFFFFF : 0xFF52525E);
+	rObj.fillRegion(x + 1, y + 1, 50, 50, lightBackground ? 0xFF42424E : 0xFF222222);
+	if (itemCount > 0)
+	{
+		rObj.alphaBild(x + 1, y + 1, 50, 50, *zItem);
+		if (hp < maxHp)
+		{
+			rObj.fillRegion(x + 1, y + 47, 50, 2, 0xFF000000);
+			rObj.fillRegion(x + 1, y + 47, (int)((hp / maxHp) * 50), 2, 0xFFFFFF00);
+		}
+		if (durability < maxDurability)
+		{
+			rObj.fillRegion(x + 1, y + 49, 50, 2, 0xFF000000);
+			rObj.fillRegion(x + 1, y + 49, (int)((durability / maxDurability) * 50), 2, 0xFF00FF00);
+		}
+		const char* units[] = { "", "K", "M", "G", "T", "P" };
+		int i = 0;
+		for (; i < 6 && itemCount > 1024; i++)
+			itemCount = itemCount / 1024;
+		Text count = itemCount;
+		count += units[i];
+		tr.renderText(x + 45 - tr.getTextBreite(count), y + 45 - tr.getTextHeight(count), count, rObj, 0xFFFFFFFF);
+	}
+}
+
+
+InventoryView::InventoryView(Text id, Either<int, VecN<int, 4>> target, int rowSize, Text slotNameFilter)
+	: ZeichnungHintergrund(),
+	rowSize(rowSize),
+	target(target),
+	slotNameFilter(slotNameFilter),
+	id(id),
+	slots(0),
+	dragStartId(-1),
+	dragStopId(-1),
+	currentTooltipSlot(-1),
+	requestetTooltipSlot(-1)
+{
+	setStyle(ZeichnungHintergrund::Style::Sichtbar | ZeichnungHintergrund::Style::Erlaubt);
+	char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
+	msg[0] = 0;
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+	memcpy(msg + 3 + id.getLength(), slotNameFilter.getText(), slotNameFilter.getLength());
+	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + slotNameFilter.getLength() + 3);
+	delete[] msg;
+	setNeedToolTipEvent([this](Zeichnung* z, Punkt p)
+		{
+			int slot = getSlotByLocalPos(p);
+			if (currentTooltipSlot != slot)
+			{
+				this->setToolTipZ(0);
+				currentTooltipSlot = -1;
+			}
+			else
+				return;
+			if (requestetTooltipSlot != slot)
+			{
+				requestetTooltipSlot = slot;
+				char* msg = new char[this->id.getLength() + 6];
+				msg[0] = 2; // request inventory tooltip
+				msg[1] = (char)this->id.getLength();
+				memcpy(msg + 2, this->id.getText(), this->id.getLength());
+				*(int*)(msg + 2 + this->id.getLength()) = slot;
+				World::INSTANCE->zClient()->inventoryAPIRequest(this->target, msg, this->id.getLength() + 6);
+			}
+		});
+}
+
+InventoryView::~InventoryView()
+{
+	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+	if (controller->getCurrentDragContainer() == this)
+		controller->stopDrag();
+	if (slots)
+		slots->release();
+	char* msg = new char[id.getLength() + 2];
+	msg[0] = 1;
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 2);
+	delete[] msg;
+}
+
+int InventoryView::getSlotByLocalPos(Punkt pos)
+{
+	int x = 0;
+	int y = 0;
+	int rowCount = 0;
+	int slot = 0;
+	dragStopId = -1;
+	if (slots)
+	{
+		for (SlotInfo &info : *slots)
+		{
+			if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
+				return info.id;
+			x += 60;
+			if (++rowCount >= rowSize)
+			{
+				y += 60;
+				x = 0;
+				rowCount = 0;
+			}
+			slot++;
+		}
+	}
+	return -1;
+}
+
+void InventoryView::api(char* message)
+{
+	switch (message[0])
+	{
+	case 0:
+		// send inventory content
+	{
+		Array<SlotInfo>* slots = new Array<SlotInfo>();
+		int count = *(int*)(++message);
+		for (int i = 0; i < count; i++)
+		{
+			SlotInfo info;
+			info.id = *(int*)(message += 4);
+			info.itemCount = *(int*)(message += 4);
+			if (info.itemCount > 0)
+			{
+				info.hp = *(float*)(message += 4);
+				info.maxHp = *(float*)(message += 4);
+				info.durability = *(float*)(message += 4);
+				info.maxDurability = *(float*)(message += 4);
+                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+			}
+			slots->add(info);
+		}
+		postAction([this, slots]()
+			{
+				if (this->slots)
+					this->slots->release();
+				this->slots = slots;
+			});
+		break;
+	}
+	case 1: // set count of items
+	{
+		if (!slots)
+			return;
+		int id = *(int*)(message + 1);
+		int count = *(int*)(message + 5);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = count;
+				if (info.itemCount == 0)
+				{
+					DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+					if (controller && controller->getCurrentDragContainer() == this && controller->getCurrentDaragElement() == info.id)
+					{
+						controller->stopDrag();
+					}
+				}
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 2: // add new stack
+	{
+		if (!slots)
+			return;
+		int id = *(int*)(message + 1);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = *(int*)(message + 5);
+				info.hp = *(float*)(message + 9);
+				info.maxHp = *(float*)(message + 13);
+				info.durability = *(float*)(message + 17);
+				info.maxDurability = *(float*)(message + 21);
+                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 3: // receive tooltip uiml
+	{
+		int slotId = *(int*)(message + 1);
+		if (slotId == requestetTooltipSlot)
+		{
+			short len = *(short*)(message + 5);
+			char* uiml = new char[len + 1];
+			memcpy(uiml, message + 7, len);
+			uiml[len] = 0;
+			UIMLToolTip* tip = new UIMLToolTip();
+			tip->setUIML(uiml);
+			setToolTipZ(tip);
+			delete[] uiml;
+			currentTooltipSlot = slotId;
+			requestetTooltipSlot = -1;
+		}
+	}
+	}
+}
+
+bool InventoryView::tick(double tickVal)
+{
+	return ZeichnungHintergrund::tick(tickVal);
+}
+
+void InventoryView::render(Bild& rObj)
+{
+	ZeichnungHintergrund::render(rObj);
+	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
+		return;
+	if (slots)
+	{
+		int x = 0;
+		int y = 0;
+		int rowCount = 0;
+		for (SlotInfo info : *slots)
+		{
+			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+			x += 60;
+			if (++rowCount >= rowSize)
+			{
+				y += 60;
+				x = 0;
+				rowCount = 0;
+			}
+		}
+	}
+	rObj.releaseDrawOptions();
+}
+
+void InventoryView::doMausEreignis(MausEreignis& me, bool userRet)
+{
+	if (!slots)
+		return;
+	if (me.id == ME_Bewegung)
+	{
+		if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
+		{
+			setToolTipZ(0);
+			currentTooltipSlot = -1;
+		}
+	}
+	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+	int x = 0;
+	int y = 0;
+	int rowCount = 0;
+	int slot = 0;
+	dragStopId = -1;
+	for (SlotInfo info : *slots)
+	{
+		if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
+		{
+			if (me.id == ME_RLinks)
+			{
+				if (!controller->getCurrentDragContainer() && info.itemCount > 0)
+				{
+					controller->beginDrag(this, info.id, info.zItem, [this]()
+						{
+							dragStartId = -1;
+						});
+					dragStartId = info.id;
+				}
+				else if (controller->getCurrentDragContainer())
+				{
+					// request to transfer items from source to target slot
+					Framework::Either<int, Framework::VecN<int, 4>> source = controller->getCurrentDragContainer()->getInventoryTarget();
+					int len = 2 + (source.isA() ? 4 : 16) + 5 + (target.isA() ? 4 : 16) + 4;
+					char* msg = new char[len];
+					int index = 0;
+					msg[index++] = 6;
+					msg[index++] = (char)source.isA();
+					if (source.isA())
+					{
+						*(int*)(msg + index) = source.getA();
+						index += 4;
+					}
+					else
+					{
+						*(int*)(msg + index) = source.getB()[0];
+						*(int*)(msg + index + 4) = source.getB()[1];
+						*(int*)(msg + index + 8) = source.getB()[2];
+						*(int*)(msg + index + 12) = source.getB()[3];
+						index += 16;
+					}
+					*(int*)(msg + index) = controller->getCurrentDaragElement();
+					index += 4;
+					msg[index++] = target.isA();
+					if (target.isA())
+					{
+						*(int*)(msg + index) = target.getA();
+						index += 4;
+					}
+					else
+					{
+						*(int*)(msg + index) = target.getB()[0];
+						*(int*)(msg + index + 4) = target.getB()[1];
+						*(int*)(msg + index + 8) = target.getB()[2];
+						*(int*)(msg + index + 12) = target.getB()[3];
+						index += 16;
+					}
+					*(int*)(msg + index) = info.id;
+					World::INSTANCE->zClient()->sendPlayerAction(msg, len);
+					delete[] msg;
+				}
+			}
+			else
+			{
+				if (controller->getCurrentDragContainer() && (controller->getCurrentDragContainer() != this || controller->getCurrentDaragElement() != info.id))
+				{
+					dragStopId = info.id;
+				}
+			}
+			break;
+		}
+		x += 60;
+		if (++rowCount >= rowSize)
+		{
+			y += 60;
+			x = 0;
+			rowCount = 0;
+		}
+		slot++;
+	}
+	ZeichnungHintergrund::doMausEreignis(me, userRet);
+}
+
+Framework::Either<int, Framework::VecN<int, 4>> InventoryView::getInventoryTarget() const
+{
+	return target;
+}

+ 466 - 0
enc_temp_folder/2259c96ab2a3916f359853f36282337/Entity.cpp

@@ -0,0 +1,466 @@
+#include <Globals.h>
+
+#include "Entity.h"
+#include "Globals.h"
+#include "Game.h"
+
+
+Entity::Entity(const EntityType* zType, Framework::Model3DData* model, Framework::Model3DTextur* texture, int id, Framework::Vec3<float> position, float maxMovementSpeed)
+	: Model3D(), id(id), zType(zType),
+	playerControlled(0),
+	maxMovementSpeed(maxMovementSpeed),
+	lastFlags(0),
+	timeSinceSync(0),
+	speed(0, 0, 0)
+{
+	pos = position;
+	setModelDaten(model);
+	setModelTextur(texture);
+	lastDirection = World::INSTANCE->zKamera()->getDirection();
+	currentFrame.duration = 0;
+	rend = 1;
+}
+
+Entity::~Entity()
+{}
+
+void Entity::api(char* message)
+{
+	switch (message[0])
+	{
+	case 0:
+	{ // add movement frame
+		if (!playerControlled)
+		{
+			MovementFrame frame;
+			frame.direction.x = *(float*)(message += 1);
+			frame.direction.y = *(float*)(message += 4);
+			frame.direction.z = *(float*)(message += 4);
+			frame.targetPosition.x = *(float*)(message += 4);
+			frame.targetPosition.y = *(float*)(message += 4);
+			frame.targetPosition.z = *(float*)(message += 4);
+			frame.movementFlags = *(int*)(message += 4);
+			frame.duration = *(double*)(message += 4);
+			cs.lock();
+			movements.add(frame);
+			cs.unlock();
+		}
+		break;
+	}
+	case 1:
+	{ // position correction
+		if (playerControlled)
+		{
+			timeSinceSync = 0;
+			pos.x = *(float*)(message += 1);
+			pos.y = *(float*)(message += 4);
+			pos.z = *(float*)(message += 4);
+			lastDirection = World::INSTANCE->zKamera()->getDirection();
+			lastFlags = 0;
+		}
+		break;
+	}
+	}
+}
+
+bool Entity::tick(double time)
+{
+	if (playerControlled && GetForegroundWindow() == window->getFensterHandle())
+	{
+		Vec3<float> direction = World::INSTANCE->zKamera()->getDirection();
+		Vec3<float> lastPos = pos;
+		int flags = 0;
+		speed = { 0, 0, speed.z };
+		if (GetKeyState('w') & 0x8000 || GetKeyState('W') & 0x8000)
+		{
+			flags |= 1;
+			speed += {direction.x, direction.y, 0};
+		}
+		if (GetKeyState('a') & 0x8000 || GetKeyState('A') & 0x8000)
+		{
+			flags |= 2;
+			Vec2<float> norm = { direction.x, direction.y };
+			norm.CCW90().normalize();
+			speed += {norm.x, norm.y, 0};
+		}
+		if (GetKeyState('s') & 0x8000 || GetKeyState('S') & 0x8000)
+		{
+			flags |= 4;
+			speed += {-direction.x, -direction.y, 0};
+		}
+		if (GetKeyState('d') & 0x8000 || GetKeyState('D') & 0x8000)
+		{
+			flags |= 8;
+			Vec2<float> norm = { direction.x, direction.y };
+			norm.CW90().normalize();
+			speed += {norm.x, norm.y, 0};
+		}
+		if (GetKeyState(T_Shift) & 0x8000)
+		{
+			flags |= 16;
+			speed.z = -maxMovementSpeed;
+		}
+		else if (GetKeyState(T_Space) & 0x8000)
+		{
+			flags |= 32;
+			speed.z = maxMovementSpeed;
+		}
+		else
+		{
+			speed.z = 0.f;
+		}
+		Vec2<float> norm = { speed.x, speed.y };
+		if (norm.getLengthSq() != 0)
+		{
+			norm.normalize();
+			speed.x = norm.x * maxMovementSpeed;
+			speed.y = norm.y * maxMovementSpeed;
+		}
+		// collision checking
+		Vec3<float> minP = model->getMinPos();
+		Vec3<float> maxP = model->getMaxPos();
+		Vec3<float> worldBoundingBox[8];
+		worldBoundingBox[0] = applyWorldTransformation(minP);
+		worldBoundingBox[1] = applyWorldTransformation({ minP.x, minP.y, maxP.z });
+		worldBoundingBox[2] = applyWorldTransformation({ minP.x, maxP.y, minP.z });
+		worldBoundingBox[3] = applyWorldTransformation({ maxP.x, minP.y, minP.z });
+		worldBoundingBox[4] = applyWorldTransformation({ maxP.x, minP.y, maxP.z });
+		worldBoundingBox[5] = applyWorldTransformation({ maxP.x, maxP.y, minP.z });
+		worldBoundingBox[6] = applyWorldTransformation({ minP.x, maxP.y, maxP.z });
+		worldBoundingBox[7] = applyWorldTransformation(maxP);
+		Vec3<float> worldBoundingBoxFloor[8];
+		for (int i = 0; i < 8; i++)
+		{
+			worldBoundingBoxFloor[i] = Vec3<float>(floor(worldBoundingBox[i].x), floor(worldBoundingBox[i].y), floor(worldBoundingBox[i].z));
+		}
+		Vec3<float> frameSpeed = speed * (float)time;
+		bool hasCollided = 0;
+		while (true)
+		{
+			float tf = 1.f;
+			int collType = 0;
+			int updateType = 0;
+			int updateI = 0;
+			if (frameSpeed.x > 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.x) >= abs(worldBoundingBoxFloor[i].x + 1.f - worldBoundingBox[i].x))
+					{
+						float xt = (worldBoundingBoxFloor[i].x + 1.f - worldBoundingBox[i].x) / frameSpeed.x;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
+						if (tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x + 1, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (xt < tf)
+								{
+									tf = xt;
+									collType = 1;
+									updateType = 0;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (xt < tf)
+								{
+									tf = xt;
+									collType = 0;
+									updateType = 1;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (frameSpeed.x < 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.x) >= abs(worldBoundingBoxFloor[i].x - worldBoundingBox[i].x))
+					{
+						float xt = (worldBoundingBoxFloor[i].x - worldBoundingBox[i].x) / frameSpeed.x;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * xt;
+						if (tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x - 1, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (xt < tf)
+								{
+									tf = xt;
+									collType = 1;
+									updateType = 0;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (xt < tf)
+								{
+									tf = xt;
+									collType = 0;
+									updateType = 1;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (frameSpeed.y > 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.y) >= abs(worldBoundingBoxFloor[i].y + 1.f - worldBoundingBox[i].y))
+					{
+						float yt = (worldBoundingBoxFloor[i].y + 1.f - worldBoundingBox[i].y) / frameSpeed.y;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
+						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y + 1, (int)worldBoundingBoxFloor[i].z });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (yt < tf)
+								{
+									tf = yt;
+									collType = 2;
+									updateType = 0;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (yt < tf)
+								{
+									tf = yt;
+									collType = 0;
+									updateType = 2;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (frameSpeed.y < 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.y) >= abs(worldBoundingBoxFloor[i].y - worldBoundingBox[i].y))
+					{
+						float yt = (worldBoundingBoxFloor[i].y - worldBoundingBox[i].y) / frameSpeed.y;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * yt;
+						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.z >= worldBoundingBoxFloor[i].z && tmp.z < worldBoundingBoxFloor[i].z + 1.f)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y - 1, (int)worldBoundingBoxFloor[i].z });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (yt < tf)
+								{
+									tf = yt;
+									collType = 2;
+									updateType = 0;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (yt < tf)
+								{
+									tf = yt;
+									collType = 0;
+									updateType = 2;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (frameSpeed.z > 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.z) >= abs(worldBoundingBoxFloor[i].z + 1.f - worldBoundingBox[i].z))
+					{
+						float zt = (worldBoundingBoxFloor[i].z + 1.f - worldBoundingBox[i].z) / frameSpeed.z;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
+						if (zt <= 1.f && tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1.f)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z + 1 });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (zt < tf)
+								{
+									tf = zt;
+									collType = 3;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (zt < tf)
+								{
+									tf = zt;
+									collType = 0;
+									updateType = 3;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (frameSpeed.z < 0)
+			{
+				for (int i = 0; i < 8; i++)
+				{
+					if (abs(frameSpeed.z) >= abs(worldBoundingBoxFloor[i].z - worldBoundingBox[i].z))
+					{
+						float zt = (worldBoundingBoxFloor[i].z - worldBoundingBox[i].z) / frameSpeed.z;
+						Vec3<float> tmp = worldBoundingBox[i] + frameSpeed * zt;
+						if (tmp.x >= worldBoundingBoxFloor[i].x && tmp.x < worldBoundingBoxFloor[i].x + 1.f && tmp.y >= worldBoundingBoxFloor[i].y && tmp.y < worldBoundingBoxFloor[i].y + 1)
+						{
+							Block* b = World::INSTANCE->zBlockAt(Vec3<int>{ (int)worldBoundingBoxFloor[i].x, (int)worldBoundingBoxFloor[i].y, (int)worldBoundingBoxFloor[i].z - 1 });
+							if (b) // TODO: ignore passable blocks
+							{
+								if (zt < tf)
+								{
+									tf = zt;
+									collType = 3;
+									updateType = 0;
+								}
+								hasCollided = 1;
+							}
+							else
+							{
+								if (zt < tf)
+								{
+									tf = zt;
+									collType = 0;
+									updateType = 3;
+									updateI = i;
+								}
+							}
+						}
+					}
+				}
+			}
+			if (collType == 1)
+				frameSpeed.x = tf > 0.1f ? frameSpeed.x * (tf - 0.1f) : 0.f;
+			if (collType == 2)
+				frameSpeed.y = tf > 0.1f ? frameSpeed.y * (tf - 0.1f) : 0.f;
+			if (collType == 3)
+				frameSpeed.z = tf > 0.1f ? frameSpeed.z * (tf - 0.1f) : 0.f;
+			if (updateType == 1)
+			{
+				if ((int)worldBoundingBoxFloor[updateI].x < (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
+					worldBoundingBoxFloor[updateI].x++;
+				if ((int)worldBoundingBoxFloor[updateI].x > (int)floor(worldBoundingBox[updateI].x + frameSpeed.x))
+					worldBoundingBoxFloor[updateI].x--;
+			}
+			if (updateType == 2)
+			{
+				if ((int)worldBoundingBoxFloor[updateI].y < (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
+					worldBoundingBoxFloor[updateI].y++;
+				if ((int)worldBoundingBoxFloor[updateI].y > (int)floor(worldBoundingBox[updateI].y + frameSpeed.y))
+					worldBoundingBoxFloor[updateI].y--;
+			}
+			if (updateType == 3)
+			{
+				if ((int)worldBoundingBoxFloor[updateI].z < (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
+					worldBoundingBoxFloor[updateI].z++;
+				if ((int)worldBoundingBoxFloor[updateI].z > (int)floor(worldBoundingBox[updateI].z + frameSpeed.z))
+					worldBoundingBoxFloor[updateI].z--;
+			}
+			if (updateType || collType)
+				continue;
+			break;
+		}
+		pos += frameSpeed;
+		World::INSTANCE->zKamera()->setPosition(pos + Vec3<float>(0.f, 0.f, 1.5f));
+		Model3D* target = World::INSTANCE->getCurrentTarget();
+		Block* b = target ? dynamic_cast<Block*>(target) : 0;
+		((Game*)(Menu*)menuRegister->get("game"))->updatePosition(pos, b != 0, b ? b->getLocation() : Vec3<int>(0, 0, 0));
+		if(target)
+			target->release();
+		if (flags != lastFlags || direction != lastDirection || timeSinceSync >= 1 || hasCollided)
+		{
+			if (timeSinceSync > 0)
+			{
+				MovementFrame frame;
+				frame.direction = lastDirection;
+				frame.targetPosition = lastPos;
+				frame.movementFlags = lastFlags;
+				frame.duration = timeSinceSync;
+				World::INSTANCE->zClient()->sendPlayerMovement(frame);
+			}
+			lastFlags = flags;
+			lastDirection = direction;
+			timeSinceSync = 0;
+		}
+		timeSinceSync += time;
+		rend = 1;
+	}
+	else
+	{
+		double totalTime = time;
+		while (totalTime > 0)
+		{
+			if (currentFrame.duration <= 0)
+			{
+				if (movements.getEintragAnzahl() > 0)
+				{
+					currentFrame = movements.get(0);
+					cs.lock();
+					movements.remove(0);
+					cs.unlock();
+				}
+				else
+				{
+					break;
+				}
+			}
+			double t = min(currentFrame.duration, totalTime);
+			pos += (currentFrame.targetPosition - pos) * (float)(t / currentFrame.duration);
+			currentFrame.duration -= t;
+			totalTime -= t;
+			if (currentFrame.duration <= 0)
+			{
+				pos = currentFrame.targetPosition;
+			}
+			rend = 1;
+		}
+	}
+	return Model3D::tick(time);
+}
+
+int Entity::getId() const
+{
+	return id;
+}
+
+const EntityType* Entity::zEntityType() const
+{
+	return zType;
+}
+
+void Entity::lock()
+{
+	cs.lock();
+}
+
+void Entity::unlock()
+{
+	cs.unlock();
+}
+
+void Entity::setPlayerControlled()
+{
+	playerControlled = 1;
+	World::INSTANCE->zKamera()->setPosition(pos + Vec3<float>(0.f, 0.f, 1.5f));
+}

+ 14 - 0
enc_temp_folder/2732994fb4435f576fdce2c1194fde8/AddEntityUpdate.h

@@ -0,0 +1,14 @@
+#pragma once
+
+#include "WorldUpdate.h"
+
+class AddEntityUpdateType : public WorldUpdateType
+{
+	REGISTRABLE(AddEntityUpdateType)
+
+protected:
+	AddEntityUpdateType();
+	void applyUpdate(Framework::StreamReader* zReader) override;
+};
+
+REGISTER(AddEntityUpdateType, WorldUpdateType)

+ 31 - 0
enc_temp_folder/29ba8b78dd7e83ca667f1499ba935536/Initialisierung.h

@@ -0,0 +1,31 @@
+#ifndef Initialisierung_H
+#define Initialisierung_H
+
+#include <Knopf.h>
+#include <Bild.h>
+#include <AuswahlBox.h>
+#include <Tabelle.h>
+#include <Diagramm.h>
+#include <Fortschritt.h>
+#include <initializer_list>
+
+using namespace Framework;
+
+struct OBJTabelleSpalteIni
+{
+	char* name;
+	int breite;
+	int minBreite;
+	int maxBreite;
+};
+
+Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel);
+KontrollKnopf* initKontrollKnopf(int x, int y, int br, int hö, __int64 style, char* txt);
+TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt);
+BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b);
+AuswahlBox* initAuswahlBox(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values);
+ObjTabelle* initObjTabelle(int x, int y, int br, int hö, __int64 style, std::initializer_list< OBJTabelleSpalteIni > spalten, int überschriftHöhe);
+LDiag* initLinienDiagramm(int x, int y, int br, int hö, __int64 style, DiagDaten* data);
+FBalken* initFBalken(int x, int y, int br, int hö, __int64 style);
+
+#endif

+ 44 - 0
enc_temp_folder/2e3f6cd4bfac3bffdfa7e916c1b6a19/EntityType.cpp

@@ -0,0 +1,44 @@
+#include "EntityType.h"
+#include "Entity.h"
+#include "Registries.h"
+#include "Globals.h"
+
+
+EntityType::EntityType(int id, ModelInfo model)
+	: id(id),
+	model(model)
+{}
+
+Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
+{
+	int id;
+	zReader->lese((char*)&id, 4);
+	Framework::Vec3<float> position;
+	zReader->lese((char*)&position.x, 4);
+	zReader->lese((char*)&position.y, 4);
+	zReader->lese((char*)&position.z, 4);
+	float maxSpeed;
+	zReader->lese((char*)&maxSpeed, 4);
+	bool specialModel = 0;
+	zReader->lese((char*)&specialModel, 1);
+	Entity* e;
+	if (specialModel)
+	{
+		ModelInfo model(zReader);
+		e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
+	}
+	else
+	{
+		e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
+	}
+	if (World::INSTANCE->zKamera()->getEntityId() == id)
+	{
+		e->setPlayerControlled();
+	}
+	return e;
+}
+
+int EntityType::getId() const
+{
+	return id;
+}

+ 19 - 0
enc_temp_folder/2fdfb0b658ed7fdeeb462a6c24ece4/AddServerMenu.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include <TextFeld.h>
+#include <Knopf.h>
+#include "Menu.h"
+
+class AddServerMenu : public Menu
+{
+private:
+	Framework::TextFeld* name;
+	Framework::TextFeld* address;
+	Framework::TextFeld* sslPort;
+	Framework::TextFeld* port;
+	Framework::Knopf* add;
+	Framework::Knopf* abort;
+
+public:
+	AddServerMenu(Framework::Bildschirm* zScreen);
+};

+ 37 - 0
enc_temp_folder/3112d9feb6108e97e3d1601255838b8e/ItemBar.h

@@ -0,0 +1,37 @@
+#pragma once
+
+#include <UIMLView.h>
+#include <Either.h>
+
+#include "NetworkAPIProcessor.h"
+#include "InventoryView.h"
+
+
+class ItemBarElement : public Framework::UIMLElement
+{
+public:
+	ItemBarElement();
+	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+	bool isApplicableFor(Framework::XML::Element& element) override;
+	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
+	//! wendet die layout parameter zu einer Zeichnung an
+	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+};
+
+class ItemBarView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor
+{
+private:
+	Framework::Text id;
+	int rowSize;
+	int targetEntity;
+	Framework::Text slotNameFilter;
+	Framework::Array<SlotInfo>* slots;
+	int leftHandPos;
+
+public:
+	ItemBarView(Framework::Text id, int rowSize, int targetEntity, Framework::Text slotNameFilter);
+	~ItemBarView();
+	void api(char* message) override;
+	void render(Framework::Bild& rObj) override;
+};

+ 16 - 0
enc_temp_folder/316083384fb252cde515408067a06dd5/Load.h

@@ -0,0 +1,16 @@
+#pragma once
+
+#include <Fortschritt.h>
+#include "Menu.h"
+#undef LoadMenu
+
+class LoadMenu : public Menu
+{
+private:
+	FBalken* step;
+	FBalken* stage;
+	FBalken* all;
+
+public:
+	LoadMenu(Bildschirm* zScreen);
+};

+ 252 - 0
enc_temp_folder/316650b8b86a35dbcc28e142c50b2ba/Dimension.cpp

@@ -0,0 +1,252 @@
+#include "Dimension.h"
+#include "Constants.h"
+#include "Datei.h"
+#include "Game.h"
+#include "Globals.h"
+#include "World.h"
+
+using namespace Framework;
+
+Dimension::Dimension()
+	: chunks(new Trie<Chunk>()),
+	entities(new RCArray<Entity>())
+{}
+
+Dimension::~Dimension()
+{
+	entities->release();
+	chunks->release();
+}
+
+void Dimension::getAddrOf(Punkt cPos, char* addr) const
+{
+	*(int*)addr = cPos.x;
+	*((int*)addr + 1) = cPos.y;
+}
+
+void Dimension::getAddrOfWorld(Punkt wPos, char* addr) const
+{
+	if (wPos.x < 0)
+		wPos.x -= CHUNK_SIZE;
+	if (wPos.y < 0) // needed because otherwise would (-8, -8) have the same adress as (8, 8)
+		wPos.y -= CHUNK_SIZE;
+	wPos /= CHUNK_SIZE;
+	getAddrOf(wPos, addr);
+}
+
+void Dimension::api(char* message)
+{
+	switch (message[0])
+	{
+	case 1: // chunck
+	{
+		int cX = *(int*)(message + 1);
+		int cY = *(int*)(message + 5);
+		Chunk* ch = zChunk(Punkt(cX, cY));
+		if (ch)
+			ch->api(message + 9);
+		break;
+	}
+	case 2: // entity
+	{
+		int eId = *(int*)(message + 1);
+		Entity* e = zEntity(eId);
+		if (e)
+			e->api(message + 5);
+		break;
+	}
+	case 3: // block
+	{
+		int px = *(int*)(message + 1);
+		int py = *(int*)(message + 5);
+		int pz = *(int*)(message + 9);
+		Block* b = zBlock(Framework::Vec3<int>(px, py, pz));
+		if (b)
+			b->api(message + 13);
+		break;
+	}
+	case 4: // add new chunck
+	{
+		Punkt center;
+		center.x = *(int*)(message + 1);
+		center.y = *(int*)(message + 5);
+		ByteArrayReader reader(message + 9, INT_MAX, 0);
+		std::cout << "downloading chunk " << center.x << ", " << center.y << "\n";
+		ZeitMesser zm;
+		zm.messungStart();
+		Chunk* chunk = new Chunk(center);
+		chunk->load(&reader);
+		zm.messungEnde();
+		std::cout << "chunk loading took " << zm.getSekunden() << " seconds\n";
+		setChunk(chunk, center);
+		World::INSTANCE->onChunkAdded(center);
+		break;
+	}
+	}
+}
+
+Chunk* Dimension::zChunk(Punkt wPos) const
+{
+	char addr[8];
+	getAddrOfWorld(wPos, addr);
+	return chunks->z(addr, 8);
+}
+
+Block* Dimension::zBlock(Vec3<int> location)
+{
+	Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
+	if (c)
+		return c->zBlockAt(location);
+	return 0;
+}
+
+Block* Dimension::getBlock(Vec3<int> location)
+{
+	cs.lock();
+	Chunk* c = zChunk(World::INSTANCE->getChunkCenter(location.x, location.y));
+	if (c)
+	{
+		Block* b = c->zBlockAt(location);
+		b = b ? dynamic_cast<Block*>(b->getThis()) : 0;
+		cs.unlock();
+		return b;
+	}
+	cs.unlock();
+	return 0;
+}
+
+void Dimension::addEntity(Entity* entity)
+{
+	entities->add(entity);
+	World::INSTANCE->setVisibility(entity, 1);
+}
+
+void Dimension::setChunk(Chunk* chunk, Punkt center)
+{
+	char addr[8];
+	getAddrOfWorld(center, addr);
+	Chunk* old = chunks->z(addr, 8);
+	cs.lock();
+	if (old)
+	{
+		World::INSTANCE->setVisibility(old, 0);
+		int index = 0;
+		for (auto iterator = chunkList.begin(); iterator; ++iterator, ++index)
+		{
+			if ((Chunk*)iterator == old)
+			{
+				if (chunk)
+					iterator.set(chunk);
+				else
+					chunkList.remove(index);
+				break;
+			}
+		}
+	}
+	else if (chunk)
+		chunkList.add(chunk);
+	chunks->set(addr, 8, chunk);
+	if (chunk)
+		chunk->getThis();
+	cs.unlock();
+	if (chunk)
+	{
+		World::INSTANCE->setVisibility(chunk, 1);
+		chunk->release();
+	}
+}
+
+bool Dimension::hasChunck(int x, int y) const
+{
+	return zChunk(Punkt(x, y));
+}
+
+void Dimension::removeDistantChunks(Punkt wPos)
+{
+	Array<int> removed;
+	int index = 0;
+	for (Chunk* chunk : chunkList)
+	{
+		if ((chunk->getCenter() - wPos).getLength() > MAX_VIEW_DISTANCE * 2)
+			removed.add(index, 0);
+		index++;
+	}
+	for (int i : removed)
+	{
+		Chunk* chunk = chunkList.get(i);
+		World::INSTANCE->setVisibility(chunk, 0);
+		setChunk(0, chunk->getCenter());
+	}
+}
+
+void Dimension::setBlock(Block* block)
+{
+	cs.lock();
+	Chunk* c = zChunk(World::INSTANCE->getChunkCenter((int)floor(block->getPos().x), (int)floor(block->getPos().y)));
+	if (c)
+		c->setBlock(block);
+	else
+		block->release();
+	cs.unlock();
+}
+
+void Dimension::removeBlock(Block* zBlock)
+{
+	cs.lock();
+	Chunk* c = zChunk(World::INSTANCE->getChunkCenter((int)floor(zBlock->getPos().x), (int)floor(zBlock->getPos().y)));
+	if (c)
+		c->removeBlock(zBlock);
+	cs.unlock();
+}
+
+Entity* Dimension::zEntity(int id)
+{
+	cs.lock();
+	for (Entity* e : *entities)
+	{
+		if (e->getId() == id)
+		{
+			cs.unlock();
+			return e;
+		}
+	}
+	cs.unlock();
+	return 0;
+}
+
+Entity* Dimension::getEntity(int id)
+{
+	cs.lock();
+	for (Entity* e : *entities)
+	{
+		if (e->getId() == id)
+		{
+			Entity* result = dynamic_cast<Entity*>(e->getThis());
+			cs.unlock();
+			return result;
+		}
+	}
+	cs.unlock();
+	return 0;
+}
+
+void Dimension::removeEntity(int id)
+{
+	World::INSTANCE->lockWorld();
+	cs.lock();
+	int index = 0;
+	for (Entity* e : *entities)
+	{
+		if (e->getId() == id)
+		{
+			World::INSTANCE->setVisibility(e, 0);
+			entities->remove(index);
+			cs.unlock();
+			World::INSTANCE->unlockWorld();
+			return;
+		}
+		index++;
+	}
+	cs.unlock();
+	World::INSTANCE->unlockWorld();
+}

+ 68 - 0
enc_temp_folder/33937a68c5128732d77739a9e125756/StaticRegistry.h

@@ -0,0 +1,68 @@
+#pragma once
+
+#define REGISTRABLE( c )          \
+public:                           \
+    static const c *INSTANCE;     \
+    static const int ID;          \
+                                  \
+private:
+
+#define REGISTER(c, typ)
+
+
+template<typename T>
+class StaticRegistry
+{
+private:
+	T** registry;
+	int count;
+
+public:
+	StaticRegistry()
+	{
+		count = 1;
+		registry = new T * [count];
+		memset(registry, 0, sizeof(T*) * count);
+	}
+
+	~StaticRegistry()
+	{
+		for (int index = 0; index < count; index++)
+		{
+			if (registry[index])
+			{
+				registry[index]->release();
+				registry[index] = 0;
+			}
+		}
+		delete[]registry;
+	}
+
+	void registerT(T* type, int id)
+	{
+		if (id >= count)
+		{
+			T** temp = new T * [id + 1];
+			memcpy(temp, registry, sizeof(T*) * count);
+			memset(temp + count, 0, sizeof(T*) * (id + 1 - count));
+			delete[]registry;
+			registry = temp;
+			count = id + 1;
+		}
+		registry[id] = type;
+	}
+
+	T* zElement(int id)
+	{
+		if (id < 0 || id >= count)
+			return 0;
+		return registry[id];
+	}
+
+	int getCount() const
+	{
+		return count;
+	}
+
+	friend T;
+};

+ 553 - 0
enc_temp_folder/3a55cd8d8af5f8ea2a64d516d5bc5692/Load.cpp

@@ -0,0 +1,553 @@
+#include <AsynchronCall.h>
+#include <Datei.h>
+#include <Array.h>
+#include <DateiSystem.h>
+#include <Text.h>
+#include <Textur.h>
+#include <GraphicsApi.h>
+#include <M3Datei.h>
+
+#include "Load.h"
+#include "Initialisierung.h"
+#include "Globals.h"
+#include "ServerSelection.h"
+
+void createDefaultCube(Bildschirm* zScreen)
+{
+	Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
+	data->setAmbientFactor(0.f);
+	data->setDiffusFactor(1.f);
+	data->setSpecularFactor(0.f);
+	float size = 1;
+	float left, right, top, bottom;
+	// Calculate the screen coordinates of the left side of the bitmap.
+	left = (float)((-size / 2.0));
+	// Calculate the screen coordinates of the right side of the bitmap.
+	right = left + (float)size;
+	// Calculate the screen coordinates of the top of the bitmap.
+	top = (float)(size / 2.0);
+	// Calculate the screen coordinates of the bottom of the bitmap.
+	bottom = top - (float)size;
+	float front = -size / 2;
+	float back = front + size;
+
+	Vertex3D* vertecies = new Vertex3D[24];
+	for (int i = 0; i < 24; i++)
+		vertecies[i].knochenId = 0;
+	// front side
+	vertecies[0].pos = Vec3<float >(left, front, top);
+	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[1].pos = Vec3<float >(right, front, top);
+	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[2].pos = Vec3<float >(left, front, bottom);
+	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[3].pos = Vec3<float >(right, front, bottom);
+	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
+	// back side
+	vertecies[4].pos = Vec3<float >(right, back, top);
+	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[5].pos = Vec3<float >(left, back, top);
+	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[6].pos = Vec3<float >(right, back, bottom);
+	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[7].pos = Vec3<float >(left, back, bottom);
+	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
+	// left side
+	vertecies[8].pos = Vec3<float >(left, back, top);
+	vertecies[8].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[9].pos = Vec3<float >(left, front, top);
+	vertecies[9].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[10].pos = Vec3<float >(left, back, bottom);
+	vertecies[10].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[11].pos = Vec3<float >(left, front, bottom);
+	vertecies[11].tPos = Vec2< float >(1.f, 1.f);
+	// right side
+	vertecies[12].pos = Vec3<float >(right, front, top);
+	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[13].pos = Vec3<float >(right, back, top);
+	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[14].pos = Vec3<float >(right, front, bottom);
+	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[15].pos = Vec3<float >(right, back, bottom);
+	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
+	// top side
+	vertecies[16].pos = Vec3<float >(left, back, top);
+	vertecies[16].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[17].pos = Vec3<float >(right, back, top);
+	vertecies[17].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[18].pos = Vec3<float >(left, front, top);
+	vertecies[18].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[19].pos = Vec3<float >(right, front, top);
+	vertecies[19].tPos = Vec2< float >(1.f, 1.f);
+	// botom side
+	vertecies[20].pos = Vec3<float >(left, front, bottom);
+	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[21].pos = Vec3<float >(right, front, bottom);
+	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[22].pos = Vec3<float >(left, back, bottom);
+	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[23].pos = Vec3<float >(right, back, bottom);
+	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+
+	data->setVertecies(vertecies, 24);
+	// the order of the polygons has to be NORTH (front), EAST (left), SOUTH (back), WEST (right), TOP, BOTTOM according to the Area definition
+	// front side
+	Polygon3D* p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0;
+	p->indexList[1] = 2;
+	p->indexList[2] = 1;
+	p->indexList[3] = 1;
+	p->indexList[4] = 2;
+	p->indexList[5] = 3;
+	data->addPolygon(p);
+	// left side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 8;
+	p->indexList[1] = 2 + 8;
+	p->indexList[2] = 1 + 8;
+	p->indexList[3] = 1 + 8;
+	p->indexList[4] = 2 + 8;
+	p->indexList[5] = 3 + 8;
+	data->addPolygon(p);
+	// back side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 4;
+	p->indexList[1] = 2 + 4;
+	p->indexList[2] = 1 + 4;
+	p->indexList[3] = 1 + 4;
+	p->indexList[4] = 2 + 4;
+	p->indexList[5] = 3 + 4;
+	data->addPolygon(p);
+	// right side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 12;
+	p->indexList[1] = 2 + 12;
+	p->indexList[2] = 1 + 12;
+	p->indexList[3] = 1 + 12;
+	p->indexList[4] = 2 + 12;
+	p->indexList[5] = 3 + 12;
+	data->addPolygon(p);
+	// top side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 16;
+	p->indexList[1] = 2 + 16;
+	p->indexList[2] = 1 + 16;
+	p->indexList[3] = 1 + 16;
+	p->indexList[4] = 2 + 16;
+	p->indexList[5] = 3 + 16;
+	data->addPolygon(p);
+	// botom side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 20;
+	p->indexList[1] = 2 + 20;
+	p->indexList[2] = 1 + 20;
+	p->indexList[3] = 1 + 20;
+	p->indexList[4] = 2 + 20;
+	p->indexList[5] = 3 + 20;
+	data->addPolygon(p);
+	data->calculateNormals();
+	data->release();
+}
+
+void createCubeItem(Bildschirm* zScreen)
+{
+	Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel("itemCube");
+	data->setAmbientFactor(0.8f);
+	data->setDiffusFactor(0.1f);
+	data->setSpecularFactor(0.1f);
+	float size = 0.2f;
+	float left, right, top, bottom;
+	// Calculate the screen coordinates of the left side of the bitmap.
+	left = (float)((-size / 2.0));
+	// Calculate the screen coordinates of the right side of the bitmap.
+	right = left + (float)size;
+	// Calculate the screen coordinates of the top of the bitmap.
+	top = (float)(size / 2.0);
+	// Calculate the screen coordinates of the bottom of the bitmap.
+	bottom = top - (float)size;
+	float front = -size / 2;
+	float back = front + size;
+
+	Vertex3D* vertecies = new Vertex3D[24];
+	for (int i = 0; i < 24; i++)
+		vertecies[i].knochenId = 0;
+	// front side
+	vertecies[0].pos = Vec3<float >(left, front, top);
+	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[1].pos = Vec3<float >(right, front, top);
+	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[2].pos = Vec3<float >(left, front, bottom);
+	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[3].pos = Vec3<float >(right, front, bottom);
+	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
+	// back side
+	vertecies[4].pos = Vec3<float >(right, back, top);
+	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[5].pos = Vec3<float >(left, back, top);
+	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[6].pos = Vec3<float >(right, back, bottom);
+	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[7].pos = Vec3<float >(left, back, bottom);
+	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
+	// left side
+	vertecies[8].pos = Vec3<float >(left, back, top);
+	vertecies[8].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[9].pos = Vec3<float >(left, front, top);
+	vertecies[9].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[10].pos = Vec3<float >(left, back, bottom);
+	vertecies[10].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[11].pos = Vec3<float >(left, front, bottom);
+	vertecies[11].tPos = Vec2< float >(1.f, 1.f);
+	// right side
+	vertecies[12].pos = Vec3<float >(right, front, top);
+	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[13].pos = Vec3<float >(right, back, top);
+	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[14].pos = Vec3<float >(right, front, bottom);
+	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[15].pos = Vec3<float >(right, back, bottom);
+	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
+	// top side
+	vertecies[16].pos = Vec3<float >(left, back, top);
+	vertecies[16].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[17].pos = Vec3<float >(right, back, top);
+	vertecies[17].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[18].pos = Vec3<float >(left, front, top);
+	vertecies[18].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[19].pos = Vec3<float >(right, front, top);
+	vertecies[19].tPos = Vec2< float >(1.f, 1.f);
+	// botom side
+	vertecies[20].pos = Vec3<float >(left, front, bottom);
+	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[21].pos = Vec3<float >(right, front, bottom);
+	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[22].pos = Vec3<float >(left, back, bottom);
+	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[23].pos = Vec3<float >(right, back, bottom);
+	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+
+	data->setVertecies(vertecies, 24);
+	// the order of the polygons has to be NORTH (front), EAST (left), SOUTH (back), WEST (right), TOP, BOTTOM according to the Area definition
+	// front side
+	Polygon3D* p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0;
+	p->indexList[1] = 2;
+	p->indexList[2] = 1;
+	p->indexList[3] = 1;
+	p->indexList[4] = 2;
+	p->indexList[5] = 3;
+	data->addPolygon(p);
+	// left side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 8;
+	p->indexList[1] = 2 + 8;
+	p->indexList[2] = 1 + 8;
+	p->indexList[3] = 1 + 8;
+	p->indexList[4] = 2 + 8;
+	p->indexList[5] = 3 + 8;
+	data->addPolygon(p);
+	// back side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 4;
+	p->indexList[1] = 2 + 4;
+	p->indexList[2] = 1 + 4;
+	p->indexList[3] = 1 + 4;
+	p->indexList[4] = 2 + 4;
+	p->indexList[5] = 3 + 4;
+	data->addPolygon(p);
+	// right side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 12;
+	p->indexList[1] = 2 + 12;
+	p->indexList[2] = 1 + 12;
+	p->indexList[3] = 1 + 12;
+	p->indexList[4] = 2 + 12;
+	p->indexList[5] = 3 + 12;
+	data->addPolygon(p);
+	// top side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 16;
+	p->indexList[1] = 2 + 16;
+	p->indexList[2] = 1 + 16;
+	p->indexList[3] = 1 + 16;
+	p->indexList[4] = 2 + 16;
+	p->indexList[5] = 3 + 16;
+	data->addPolygon(p);
+	// botom side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 20;
+	p->indexList[1] = 2 + 20;
+	p->indexList[2] = 1 + 20;
+	p->indexList[3] = 1 + 20;
+	p->indexList[4] = 2 + 20;
+	p->indexList[5] = 3 + 20;
+	data->addPolygon(p);
+	data->calculateNormals();
+	data->release();
+}
+
+void createPlayer(Bildschirm* zScreen)
+{
+	Framework::Model3DData* data = window->zBildschirm()->zGraphicsApi()->createModel("player");
+	data->setAmbientFactor(0.8f);
+	data->setDiffusFactor(0.1f);
+	data->setSpecularFactor(0.1f);
+	float size = 0.8f;
+	float left, right, top, bottom;
+	// Calculate the screen coordinates of the left side of the bitmap.
+	left = (float)((size / 2.0) * -1);
+	// Calculate the screen coordinates of the right side of the bitmap.
+	right = left + (float)size;
+	// Calculate the screen coordinates of the top of the bitmap.
+	top = (float)(size / 2.0);
+	// Calculate the screen coordinates of the bottom of the bitmap.
+	bottom = top - (float)size;
+	float front = -1.5f / 2;
+	float back = front + 1.5f;
+
+	Vertex3D* vertecies = new Vertex3D[24];
+	for (int i = 0; i < 24; i++)
+		vertecies[i].knochenId = 0;
+	vertecies[0].pos = Vec3<float >(left, top, front);
+	vertecies[0].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[1].pos = Vec3<float >(right, top, front);
+	vertecies[1].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[2].pos = Vec3<float >(left, bottom, front);
+	vertecies[2].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[3].pos = Vec3<float >(right, bottom, front);
+	vertecies[3].tPos = Vec2< float >(1.f, 1.f);
+	vertecies[4].pos = Vec3<float >(left, top, back);
+	vertecies[4].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[5].pos = Vec3<float >(right, top, back);
+	vertecies[5].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[6].pos = Vec3<float >(left, bottom, back);
+	vertecies[6].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[7].pos = Vec3<float >(right, bottom, back);
+	vertecies[7].tPos = Vec2< float >(1.0f, 1.0f);
+
+	vertecies[8].pos = Vec3<float >(left, top, front);
+	vertecies[8].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[9].pos = Vec3<float >(right, top, front);
+	vertecies[9].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[10].pos = Vec3<float >(left, bottom, front);
+	vertecies[10].tPos = Vec2< float >(1.f, 1.f);
+	vertecies[11].pos = Vec3<float >(right, bottom, front);
+	vertecies[11].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[12].pos = Vec3<float >(left, top, back);
+	vertecies[12].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[13].pos = Vec3<float >(right, top, back);
+	vertecies[13].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[14].pos = Vec3<float >(left, bottom, back);
+	vertecies[14].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[15].pos = Vec3<float >(right, bottom, back);
+	vertecies[15].tPos = Vec2< float >(1.0f, 1.0f);
+
+	vertecies[16].pos = Vec3<float >(left, top, front);
+	vertecies[16].tPos = Vec2< float >(0.f, 1.f);
+	vertecies[17].pos = Vec3<float >(right, top, front);
+	vertecies[17].tPos = Vec2< float >(1.f, 1.f);
+	vertecies[18].pos = Vec3<float >(left, bottom, front);
+	vertecies[18].tPos = Vec2< float >(0.f, 0.f);
+	vertecies[19].pos = Vec3<float >(right, bottom, front);
+	vertecies[19].tPos = Vec2< float >(1.f, 0.f);
+	vertecies[20].pos = Vec3<float >(left, top, back);
+	vertecies[20].tPos = Vec2< float >(0.0f, 0.0f);
+	vertecies[21].pos = Vec3<float >(right, top, back);
+	vertecies[21].tPos = Vec2< float >(1.0f, 0.0f);
+	vertecies[22].pos = Vec3<float >(left, bottom, back);
+	vertecies[22].tPos = Vec2< float >(0.0f, 1.0f);
+	vertecies[23].pos = Vec3<float >(right, bottom, back);
+	vertecies[23].tPos = Vec2< float >(1.0f, 1.0f);
+
+	data->setVertecies(vertecies, 24);
+	// the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM according to the Area definition
+	// down side
+	Polygon3D* p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 6 + 16;
+	p->indexList[1] = 2 + 16;
+	p->indexList[2] = 3 + 16;
+	p->indexList[3] = 6 + 16;
+	p->indexList[4] = 3 + 16;
+	p->indexList[5] = 7 + 16;
+	data->addPolygon(p);
+	// right side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 1 + 8;
+	p->indexList[1] = 7 + 8;
+	p->indexList[2] = 3 + 8;
+	p->indexList[3] = 1 + 8;
+	p->indexList[4] = 5 + 8;
+	p->indexList[5] = 7 + 8;
+	data->addPolygon(p);
+	// top side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 4 + 16;
+	p->indexList[1] = 1 + 16;
+	p->indexList[2] = 0 + 16;
+	p->indexList[3] = 4 + 16;
+	p->indexList[4] = 5 + 16;
+	p->indexList[5] = 1 + 16;
+	data->addPolygon(p);
+	// left side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0 + 8;
+	p->indexList[1] = 2 + 8;
+	p->indexList[2] = 6 + 8;
+	p->indexList[3] = 0 + 8;
+	p->indexList[4] = 6 + 8;
+	p->indexList[5] = 4 + 8;
+	data->addPolygon(p);
+	// back side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 4;
+	p->indexList[1] = 6;
+	p->indexList[2] = 7;
+	p->indexList[3] = 4;
+	p->indexList[4] = 7;
+	p->indexList[5] = 5;
+	data->addPolygon(p);
+	// front side
+	p = new Polygon3D();
+	p->indexAnz = 6;
+	p->indexList = new int[p->indexAnz];
+	p->indexList[0] = 0;
+	p->indexList[1] = 3;
+	p->indexList[2] = 2;
+	p->indexList[3] = 0;
+	p->indexList[4] = 1;
+	p->indexList[5] = 3;
+	data->addPolygon(p);
+	data->calculateNormals();
+	data->release();
+}
+
+void createModels(Bildschirm* zScreen)
+{
+	createDefaultCube(zScreen);
+	createCubeItem(zScreen);
+	createPlayer(zScreen);
+}
+
+
+LoadMenu::LoadMenu(Bildschirm* zScreen)
+	: Menu(zScreen)
+{
+	Punkt center = zScreen->getBackBufferSize() / 2;
+	step = initFBalken(center.x - 100, center.y + 25, 200, 30, FBalken::Style::normal);
+	stage = initFBalken(center.x - 100, center.y - 15, 200, 30, FBalken::Style::normal);
+	all = initFBalken(center.x - 100, center.y - 55, 200, 30, FBalken::Style::normal);
+	elements.add(step);
+	elements.add(stage);
+	elements.add(all);
+
+	new AsynchronCall("Load Menu", [this, zScreen]()
+		{
+			Sleep(1000);
+			all->setAktionAnzahl(2);
+			all->reset();
+			// loading textures
+			Datei texturF;
+			texturF.setDatei("data/textures");
+			RCArray<Text>* files = texturF.getDateiListe();
+			if (files)
+			{
+				int count = 0;
+				for (Text* fileName : *files)
+				{
+					LTDBDatei dat;
+					dat.setDatei(new Text(Text("data/textures/") + *fileName));
+					dat.leseDaten(0);
+					count += dat.getBildAnzahl();
+				}
+				stage->setAktionAnzahl(count);
+				stage->reset();
+				for (Text* fileName : *files)
+				{
+					LTDBDatei dat;
+					dat.setDatei(new Text(Text("data/textures/") + *fileName));
+					dat.leseDaten(0);
+					for (Text* name : *dat.zBildListe())
+					{
+						step->reset();
+						Bild* b = dat.laden(step, new Text(*name));
+						zScreen->zGraphicsApi()->createOrGetTextur(*fileName + "/" + *name, b)->release();
+						stage->aktionPlus();
+					}
+				}
+				files->release();
+			}
+			all->aktionPlus();
+			// loading models
+			stage->setAktionAnzahl(1);
+			Datei modelF;
+			modelF.setDatei("data/models");
+			files = modelF.getDateiListe();
+			if (files)
+			{
+				int count = 0;
+				for (Text* fileName : *files)
+				{
+					M3Datei dat(Text("data/models/") + *fileName);
+					dat.leseDaten();
+					count += dat.getModelAnzahl();
+				}
+				stage->setAktionAnzahl(count + 1);
+				stage->reset();
+				for (Text* fileName : *files)
+				{
+					M3Datei dat(Text("data/models/") + *fileName);
+					dat.leseDaten();
+					for (int i = 0; i < dat.getModelAnzahl(); i++)
+					{
+						step->reset();
+						Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(), zScreen->zGraphicsApi(), *fileName + "/" + *dat.zModelName(i));
+						d->release();
+						stage->aktionPlus();
+					}
+				}
+				files->release();
+			}
+			createModels(zScreen);
+			stage->aktionPlus();
+			all->aktionPlus();
+			stage->reset();
+			zScreen->lock();
+			hide();
+			menuRegister->get("serverSelection")->show();
+			zScreen->unlock();
+		});
+}

+ 32 - 0
enc_temp_folder/3c2afc6a4b27a7caad432882b3711f1c/BlockType.cpp

@@ -0,0 +1,32 @@
+#include "BlockType.h"
+#include "Block.h"
+
+#include "Registries.h"
+
+using namespace Framework;
+
+BlockType::BlockType(int id, bool needsInstance, ModelInfo model, int initialMaxHP)
+	: ReferenceCounter(),
+	id(id),
+	needsInstance(needsInstance),
+	model(model),
+	initialMaxHP(initialMaxHP)
+{}
+
+BlockType::~BlockType()
+{}
+
+Block* BlockType::createBlock(Framework::Vec3<int> position)
+{
+	return new Block(this, position, model.getModel(), model.getTexture(), initialMaxHP);
+}
+
+int BlockType::getId() const
+{
+	return id;
+}
+
+bool BlockType::doesNeedInstance() const
+{
+	return needsInstance;
+}

+ 11 - 0
enc_temp_folder/417d9d558f3e8f5f14c5cf33fb5986a/DragElement.h

@@ -0,0 +1,11 @@
+#pragma once
+
+#include <Bild.h>
+
+
+class DragElement : public Framework::BildZ
+{
+public:
+	DragElement();
+	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+};

+ 45 - 0
enc_temp_folder/451246f3f099a7e663dcea31b22f288/ModelInfo.cpp

@@ -0,0 +1,45 @@
+#include <Textur.h>
+
+#include "ModelInfo.h"
+#include "Globals.h"
+
+using namespace Framework;
+
+ModelInfo::ModelInfo(Framework::StreamReader* reader)
+{
+	char len;
+	reader->lese(&len, 1);
+	char* path = new char[len + 1];
+	reader->lese(path, len);
+	path[len] = 0;
+	modelPath = path;
+	delete[] path;
+	short count;
+	reader->lese((char*)&count, 2);
+	for (int i = 0; i < count; i++)
+	{
+		reader->lese(&len, 1);
+		path = new char[len + 1];
+		reader->lese(path, len);
+		path[len] = 0;
+		texturPaths.add(new Text(path));
+		delete[] path;
+	}
+}
+
+Framework::Model3DData* ModelInfo::getModel() const
+{
+	return uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(modelPath);
+}
+
+Framework::Model3DTextur* ModelInfo::getTexture() const
+{
+	Model3DTextur* textur = new Model3DTextur();
+	int index = 0;
+	for (Text* texturPath : texturPaths)
+	{
+		Textur* tex = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur(texturPath->getText(), 0);
+		textur->setPolygonTextur(index++, tex);
+	}
+	return textur;
+}

+ 18 - 0
enc_temp_folder/45ba55b34681a81f4c8590e163c81db8/CustomDX11API.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#include <GraphicsApi.h>
+
+class CustomDX11API : public Framework::DirectX11
+{
+private:
+	int vertexShaderLightBufferIndex;
+
+protected:
+	Framework::DX11VertexShader* initializeVertexShader(unsigned char* byteCode, int size) override;
+	Framework::DX11PixelShader* initializePixelShader(unsigned char* byteCode, int size) override;
+
+public:
+	CustomDX11API();
+
+	int getVertexShaderLightBufferIndex() const;
+};

+ 21 - 0
enc_temp_folder/4876b17b4f30766328b89d442a16e79/EntityType.h

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <ReferenceCounter.h>
+#include <Reader.h>
+#include <Vec3.h>
+
+#include "ModelInfo.h"
+
+class Entity;
+
+class EntityType : public virtual Framework::ReferenceCounter
+{
+private:
+	const int id;
+	ModelInfo model;
+
+public:
+	EntityType(int id, ModelInfo model);
+	Entity* loadEntity(Framework::StreamReader* zReader) const;
+	int getId() const;
+};

+ 22 - 0
enc_temp_folder/4cf3c1a3eadd27e1b61e410a2f7b5b3/Menu.cpp

@@ -0,0 +1,22 @@
+#include "Menu.h"
+#include <AsynchronCall.h>
+
+Menu::Menu(Bildschirm* zScreen)
+	: ReferenceCounter(),
+	zScreen(zScreen)
+{}
+
+void Menu::show()
+{
+	for (auto member : elements)
+		zScreen->addMember(dynamic_cast<Zeichnung*>(member->getThis()));
+}
+
+void Menu::hide()
+{
+	new AsynchronCall([this]()
+		{
+			for (auto member : elements)
+				zScreen->removeMember(dynamic_cast<Zeichnung*>(member->getThis()));
+		});
+}

+ 18 - 0
enc_temp_folder/4d1a72a6f5157678fdc872365e12c1b/AddEntityUpdate.cpp

@@ -0,0 +1,18 @@
+#include "AddEntityUpdate.h"
+#include "StaticRegistry.h"
+#include "Registries.h"
+#include "Globals.h"
+#include "Entity.h"
+
+
+AddEntityUpdateType::AddEntityUpdateType()
+	: WorldUpdateType(ID)
+{}
+
+void AddEntityUpdateType::applyUpdate(Framework::StreamReader* zReader)
+{
+	int type;
+	zReader->lese((char*)&type, 4);
+	Entity* entity = entityTypes[type]->loadEntity(zReader);
+	World::INSTANCE->zDimension()->addEntity(entity);
+}

+ 165 - 0
enc_temp_folder/51501657c4a6cf4d357c29932b1dd6a/Initialisierung.cpp

@@ -0,0 +1,165 @@
+#include "Initialisierung.h"
+#include <ToolTip.h>
+#include <Bildschirm.h>
+#include <MausEreignis.h>
+#include <DateiSystem.h>
+#include <Fenster.h>
+#include <Fortschritt.h>
+#include <Liste.h>
+#include "Globals.h"
+
+Knopf* initKnopf(int x, int y, int br, int hö, __int64 style, char* titel)
+{
+	Knopf* ret = uiFactory.createKnopf(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	ret->setText(titel);
+	ret->setHintergrundFarbe(0xFF000000);
+	ret->setRahmenFarbe(0xFF2E6DA4);
+	ret->setSchriftFarbe(0xFFFFFFFF);
+	ret->setRahmenBreite(1);
+	ret->setAlphaFeldStrength(10);
+	ret->setAlphaFeldFarbe(0xFF337AB7);
+	return ret;
+}
+
+KontrollKnopf* initKontrollKnopf(int x, int y, int br, int hö, __int64 style, char* txt)
+{
+	KontrollKnopf* ret = uiFactory.createKontrollKnopf(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setText(txt);
+	ret->setSText(txt);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	return ret;
+}
+
+Fenster* initFenster(int x, int y, int br, int hö, __int64 style, char* titel)
+{
+	Fenster* ret = uiFactory.createFenster(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	if (ret->hatStyle(Fenster::Style::Titel))
+	{
+		ret->setTitel(titel);
+	}
+	return ret;
+}
+
+TextFeld* initTextFeld(int x, int y, int br, int hö, __int64 style, char* txt)
+{
+	TextFeld* ret = uiFactory.createTextFeld(uiFactory.initParam);
+	ret->setStyle(style);
+	ret->setText(txt);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	ret->setRahmenFarbe(0xFF6d6d6d);
+	ret->setHintergrundFarbe(0xFF000000);
+	ret->setAlphaFeldFarbe(0xFF3d3d3d);
+	ret->setAlphaFeldStrength(10);
+	return ret;
+}
+
+BildZ* initBildZ(int x, int y, int br, int hö, __int64 style, Bild* b)
+{
+	BildZ* ret = uiFactory.createBildZ(uiFactory.initParam);
+	ret->setStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	if (b)
+		ret->setBildZ(b);
+	return ret;
+}
+
+AuswahlBox* initAuswahlBox(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values)
+{
+	AuswahlBox* ret = uiFactory.createAuswahlBox(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	for (auto i = values.begin(); i != values.end(); i++)
+		ret->addEintrag(*i);
+	return ret;
+}
+
+ObjTabelle* initObjTabelle(int x, int y, int br, int hö, __int64 style, std::initializer_list< OBJTabelleSpalteIni > spalten, int überschriftHöhe)
+{
+	ObjTabelle* ret = uiFactory.createObjTabelle(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	for (auto i = spalten.begin(); i != spalten.end(); i++)
+	{
+		ret->addSpalte(i->name);
+		ret->setSpaltenBreite(i->name, i->breite);
+		if ((style | ObjTabelle::Style::SpaltenBreiteMin) == style)
+			ret->setMinSpaltenBreite(i->name, i->minBreite);
+		if ((style | ObjTabelle::Style::SpaltenBreiteMax) == style)
+			ret->setMaxSpaltenBreite(i->name, i->maxBreite);
+		if (überschriftHöhe)
+		{
+			if (ret->getZeilenNummer("Überschrift") < 0)
+			{
+				ret->addZeile(0, "Überschrift");
+				ret->setZeilenHeight(0, 20);
+			}
+			ret->setZeichnungZ(i->name, "Überschrift", initTextFeld(0, 0, i->breite, 20, TextFeld::Style::Text | TextFeld::Style::Center, i->name));
+		}
+	}
+	return ret;
+}
+
+LDiag* initLinienDiagramm(int x, int y, int br, int hö, __int64 style, DiagDaten* data)
+{
+	LDiag* ret = uiFactory.createLDiag(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	if (data)
+		ret->setDiagDatenZ(data);
+	return ret;
+}
+
+AuswahlListe* initAuswahlListe(int x, int y, int br, int hö, __int64 style, std::initializer_list< char* > values)
+{
+	AuswahlListe* ret = uiFactory.createAuswahlListe(uiFactory.initParam);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	ret->addStyle(style);
+	for (auto i = values.begin(); i != values.end(); i++)
+		ret->addEintrag(*i);
+	ret->update();
+	return ret;
+}
+
+ZeichnungHintergrund* initZeichnungHintergrund(int x, int y, int br, int hö, __int64 style, int farbe)
+{
+	ZeichnungHintergrund* ret = new ZeichnungHintergrund();
+	ret->setStyle(style);
+	ret->setHintergrundFarbe(farbe);
+	if (ret->hatStyle(ZeichnungHintergrund::Style::Rahmen))
+	{
+		ret->setRahmenBreite(1);
+		ret->setRahmenFarbe(0xFF00FF00);
+	}
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	return ret;
+}
+
+void initToolTip(Zeichnung* obj, const char* txt)
+{
+	obj->setToolTipText(txt, uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
+	obj->zToolTip()->addStyle(TextFeld::Style::Mehrzeilig);
+}
+
+FBalken* initFBalken(int x, int y, int br, int hö, __int64 style)
+{
+	FBalken* ret = uiFactory.createFBalken(uiFactory.initParam);
+	ret->addStyle(style);
+	ret->setPosition(x, y);
+	ret->setSize(br, hö);
+	return ret;
+}

+ 277 - 0
enc_temp_folder/52dda8697ab91ee9d2c9ac2061cdff7/Chunk.cpp

@@ -0,0 +1,277 @@
+#include "Chunk.h"
+#include "Constants.h"
+#include "Globals.h"
+
+#include "Registries.h"
+
+
+Chunk::Chunk(Framework::Punkt location)
+	: ReferenceCounter(),
+	location(location),
+	isLoading(0)
+{}
+
+Chunk::Chunk(Framework::Punkt location, Framework::StreamReader* zReader)
+	: Chunk(location)
+{
+	load(zReader);
+}
+
+Chunk::~Chunk()
+{
+	char msg = 1; // remove observer
+	World::INSTANCE->zClient()->chunkAPIRequest(location, &msg, 1);
+}
+
+void Chunk::api(char* message)
+{
+	switch (message[0])
+	{
+	case 0: // set block
+	{
+		int index = *(int*)(message + 1);
+		int id = *(int*)(message + 5);
+		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
+		location.x += this->location.x - CHUNK_SIZE / 2;
+		location.y += this->location.y - CHUNK_SIZE / 2;
+		if (blockTypes[id]->doesNeedInstance())
+		{
+			Block* zB = blockTypes[id]->createBlock(location);
+			setBlock(zB);
+		}
+		else
+		{
+			Block* zB = zBlockAt(location);
+			if (zB)
+				removeBlock(zB);
+		}
+		break;
+	}
+	case 1: // update light
+	{
+		int index = *(int*)(message + 1);
+		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
+		for (int i = 0; i < 6; i++)
+		{
+			Framework::Vec3<int> pos = location + getDirection(getDirectionFromIndex(i));
+			if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
+			{
+				if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0 && pos.y < CHUNK_SIZE)
+				{
+					pos.x += this->location.x - CHUNK_SIZE / 2;
+					pos.y += this->location.y - CHUNK_SIZE / 2;
+					Block* zB = zBlockAt(pos);
+					if (zB)
+					{
+						bool visible = zB->isVisible();
+						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)(message + 5));
+						if (zB->isVisible() != visible)
+						{
+							vcs.lock();
+							if (zB->isVisible())
+								visibleBlocks.add(zB);
+							else
+							{
+								for (Framework::Iterator<Block*> iterator = visibleBlocks.begin(); iterator; iterator++)
+								{
+									if (zB == (Block*)iterator)
+									{
+										iterator.remove();
+										break;
+									}
+								}
+							}
+							vcs.unlock();
+						}
+					}
+				}
+				else
+				{
+					pos.x += this->location.x - CHUNK_SIZE / 2;
+					pos.y += this->location.y - CHUNK_SIZE / 2;
+					Block* zB = World::INSTANCE->zBlockAt(pos);
+					if (zB)
+					{
+						bool visible = zB->isVisible();
+						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)(message + 5));
+						if (zB->isVisible() != visible)
+						{
+							Chunk* c = World::INSTANCE->zChunk(World::INSTANCE->getChunkCenter(pos.x, pos.y));
+							c->vcs.lock();
+							if (zB->isVisible())
+								c->visibleBlocks.add(zB);
+							else
+							{
+								for (Framework::Iterator<Block*> iterator = c->visibleBlocks.begin(); iterator; iterator++)
+								{
+									if (zB == (Block*)iterator)
+									{
+										iterator.remove();
+										break;
+									}
+								}
+							}
+							c->vcs.unlock();
+						}
+					}
+				}
+			}
+		}
+	}
+	}
+}
+
+Block* Chunk::zBlockAt(Framework::Vec3<int> location)
+{
+	cs.lock();
+	for (Block* b : blocks)
+	{
+		if (b->getLocation() == location)
+		{
+			cs.unlock();
+			return b;
+		}
+	}
+	cs.unlock();
+	return 0;
+}
+
+void Chunk::setBlock(Block* block)
+{
+	cs.lock();
+	Framework::Vec3<int> pos = block->getLocation();
+	for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator; iterator++)
+	{
+		if (pos == iterator->getLocation())
+		{
+			vcs.lock();
+			for (Framework::Iterator<Block*> vi = visibleBlocks.begin(); vi; vi++)
+			{
+				if ((Block*)iterator == (Block*)vi)
+				{
+					iterator.remove();
+					break;
+				}
+			}
+			vcs.unlock();
+			iterator->release();
+			iterator.set(block);
+			break;
+		}
+	}
+	blocks.add(block);
+	cs.unlock();
+}
+
+void Chunk::removeBlock(Block* zBlock)
+{
+	cs.lock();
+	vcs.lock();
+	for (Framework::Iterator<Block*> iterator = visibleBlocks.begin(); iterator; iterator++)
+	{
+		if (zBlock == (Block*)iterator)
+		{
+			iterator.remove();
+			break;
+		}
+	}
+	vcs.unlock();
+	for (Framework::Iterator<Block*> iterator = blocks.begin(); iterator; iterator++)
+	{
+		if (zBlock == (Block*)iterator)
+		{
+			iterator.remove();
+			break;
+		}
+	}
+	cs.unlock();
+}
+
+void Chunk::load(Framework::StreamReader* zReader)
+{
+	isLoading = 1;
+	Framework::Vec3<int> pos = { 0, 0, 0 };
+	unsigned short id;
+	zReader->lese((char*)&id, 2);
+	while (id)
+	{
+		int index;
+		zReader->lese((char*)&index, 4);
+		pos = Vec3<int>((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
+		if (blockTypes[id]->doesNeedInstance())
+			setBlock(blockTypes[id]->createBlock({ pos.x + location.x - CHUNK_SIZE / 2, pos.y + location.y - CHUNK_SIZE / 2, pos.z }));
+		zReader->lese((char*)&id, 2);
+	}
+	int index = 0;
+	// light
+	zReader->lese((char*)&index, 4);
+	char lightData[6];
+	while (index >= 0)
+	{
+		zReader->lese(lightData, 6);
+		Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE, (index / WORLD_HEIGHT) % CHUNK_SIZE, index % WORLD_HEIGHT);
+		for (int i = 0; i < 6; i++)
+		{
+			Framework::Vec3<int> pos = location + getDirection(getDirectionFromIndex(i));
+			if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
+			{
+				if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0 && pos.y < CHUNK_SIZE)
+				{
+					pos.x += this->location.x - CHUNK_SIZE / 2;
+					pos.y += this->location.y - CHUNK_SIZE / 2;
+					Block* zB = zBlockAt(pos);
+					if (zB)
+					{
+						bool visible = zB->isVisible();
+						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)lightData);
+						if (zB->isVisible() && !visible)
+							visibleBlocks.add(zB);
+					}
+				}
+				else
+				{
+					pos.x += this->location.x - CHUNK_SIZE / 2;
+					pos.y += this->location.y - CHUNK_SIZE / 2;
+					Block* zB = World::INSTANCE->zBlockAt(pos);
+					if (zB)
+					{
+						bool visible = zB->isVisible();
+						zB->setLightData(getOppositeDirection(getDirectionFromIndex(i)), (unsigned char*)lightData);
+						if (zB->isVisible() && !visible)
+						{
+							Chunk* c = World::INSTANCE->zChunk(World::INSTANCE->getChunkCenter(pos.x, pos.y));
+							c->vcs.lock();
+							c->visibleBlocks.add(zB);
+							c->vcs.unlock();
+						}
+					}
+				}
+			}
+		}
+		zReader->lese((char*)&index, 4);
+	}
+	isLoading = 0;
+}
+
+Framework::Punkt Chunk::getCenter() const
+{
+	return location;
+}
+
+Framework::Vec3<int> Chunk::getMin() const
+{
+	return { location.x - CHUNK_SIZE / 2, location.y - CHUNK_SIZE / 2, 0 };
+}
+
+Framework::Vec3<int> Chunk::getMax() const
+{
+	return { location.x + CHUNK_SIZE / 2, location.y + CHUNK_SIZE / 2, WORLD_HEIGHT };
+}
+
+void Chunk::forAll(std::function<void(Model3D*)> f)
+{
+	vcs.lock();
+	for (Block* b : visibleBlocks)
+		f(b);
+	vcs.unlock();
+}

+ 27 - 0
enc_temp_folder/5795ce2e2f68bd624f1cc69f0f5c8da/BlockType.h

@@ -0,0 +1,27 @@
+#pragma once
+
+#include <Reader.h>
+#include <ReferenceCounter.h>
+#include <Vec3.h>
+
+#include "StaticRegistry.h"
+#include "ModelInfo.h"
+
+class Block;
+
+class BlockType : public virtual Framework::ReferenceCounter
+{
+private:
+	const int id;
+	bool needsInstance;
+	int initialMaxHP;
+	ModelInfo model;
+
+public:
+	BlockType(int id, bool needsInstance, ModelInfo model, int initialMaxHP);
+	~BlockType();
+	Block* createBlock(Framework::Vec3<int> position);
+	bool doesNeedInstance() const;
+
+	int getId() const;
+};

+ 16 - 0
enc_temp_folder/6bb73f40c164ba9b456ed65bee126b99/StaticInitializerOrder.cpp

@@ -0,0 +1,16 @@
+#define _REGISTRY
+
+#include "Registries.h"
+
+int count_WorldUpdateType = 0;
+
+#undef REGISTER
+#define REGISTER(c, typ)               \
+const int c::ID = count_##typ++;       \
+const c *c::INSTANCE = new c(); 
+
+// order of includes determines the ids
+
+// world updates
+#include "AddEntityUpdate.h"
+#include "EntityRemovedUpdate.h"

+ 62 - 0
enc_temp_folder/6c14995eccfa6537b21468f668959267/DragController.h

@@ -0,0 +1,62 @@
+#pragma once
+
+#include <Zeichnung.h>
+#include "DragElement.h"
+
+template<typename Source, typename Element>
+class DragController : public Framework::ReferenceCounter
+{
+private:
+	Source* container;
+	Element currentElement;
+	DragElement* drag;
+	std::function<void()> onDragEnd;
+
+public:
+	DragController()
+		: ReferenceCounter()
+	{
+		container = 0;
+		currentElement = 0;
+		drag = new DragElement();
+	}
+
+	~DragController()
+	{
+		if (this->container)
+			stopDrag();
+		drag->release();
+	}
+
+	void beginDrag(Source* container, Element element, Framework::Bild* zDragDisplay, std::function<void()> onDragEnd)
+	{
+		if (this->container)
+			stopDrag();
+		((BildZ*)drag)->setBildZ(dynamic_cast<Bild*>(zDragDisplay->getThis()));
+		window->zBildschirm()->addMember(dynamic_cast<Zeichnung*>(drag->getThis()));
+		this->container = container;
+		this->currentElement = element;
+		this->onDragEnd = onDragEnd;
+	}
+
+	Source* getCurrentDragContainer() const
+	{
+		return container;
+	}
+
+	Element getCurrentDaragElement() const
+	{
+		return currentElement;
+	}
+
+	void stopDrag()
+	{
+		if (container)
+		{
+			window->zBildschirm()->removeMember(drag);
+			onDragEnd();
+			container = 0;
+			currentElement = 0;
+		}
+	}
+};

+ 14 - 0
enc_temp_folder/72156073275f6358c87cd3cf596fcc4/EntityRemovedUpdate.cpp

@@ -0,0 +1,14 @@
+#include "EntityRemovedUpdate.h"
+#include "Globals.h"
+
+
+EntityRemovedUpdateType::EntityRemovedUpdateType()
+	: WorldUpdateType(ID)
+{}
+
+void EntityRemovedUpdateType::applyUpdate(Framework::StreamReader* zReader)
+{
+	int id;
+	zReader->lese((char*)&id, 4);
+	World::INSTANCE->removeEntity(id);
+}

+ 46 - 0
enc_temp_folder/731a4feda1e46a1d2df75b3f2592ee7/FactoryClient.h

@@ -0,0 +1,46 @@
+#pragma once
+
+#include <Network.h>
+#include <Klient.h>
+#include <Text.h>
+#include <Thread.h>
+#include <Critical.h>
+#include <VecN.h>
+#include <Either.h>
+#include <Punkt.h>
+
+#include "Entity.h"
+
+class FactoryClient : public Framework::ReferenceCounter
+{
+private:
+	Network::SSLKlient* client;
+	Network::Klient* foreground;
+	Network::Klient* background;
+	Network::NetworkReader* foregroundReader;
+	Network::NetworkReader* backgroundReader;
+	Framework::Critical cs;
+	Framework::Text ip;
+	int bgReaderUsage;
+	int fgReaderUsage;
+
+	void disconnect();
+	void loadServerInfo();
+
+public:
+	FactoryClient();
+	~FactoryClient();
+
+	bool connect(Framework::Text ip, unsigned short sslPort);
+	int ping();
+	int status(Framework::Text name, Framework::Text secret);
+	int join(Framework::Text name, Framework::Text &secret, unsigned short port);
+	Network::NetworkReader* getNextForegroundMessage();
+	Network::NetworkReader* getNextBackgroundMessage();
+	void endMessageReading(bool bg);
+	void sendPlayerAction(char* data, unsigned short length);
+	void sendPlayerMovement(MovementFrame& frame);
+	void entityAPIRequest(int entityId, char* message, unsigned short length);
+	void chunkAPIRequest(Framework::Punkt center, char* message, unsigned short length);
+	void inventoryAPIRequest(Framework::Either<int, Framework::VecN<int, 4>> target, char* message, unsigned short length);
+};

+ 31 - 0
enc_temp_folder/7a1b7c013656d33b6d1375faeb4bd9/Game.h

@@ -0,0 +1,31 @@
+#pragma once
+
+#include <Knopf.h>
+#include <Bild.h>
+
+#include "Menu.h"
+#include "Dialog.h"
+#include "DragController.h"
+
+class Player;
+class InventoryDragSource;
+
+class Game : public Menu
+{
+private:
+	Framework::Knopf* logout;
+	Framework::TextFeld* debug;
+	Framework::Array<UIMLDialog*> dialogs;
+	Framework::UIMLView* guiView;
+	DragController<InventoryDragSource, int>* inventoryDragController;
+
+public:
+	// Konstruktor
+	Game(Bildschirm* zScreen);
+	~Game();
+
+	void updatePosition(Vec3<float> position, bool target, Vec3<int> targetPos);
+	void api(char* data);
+	void closeCurrentDialog();
+	DragController<InventoryDragSource, int>* zInventoryDragController();
+};

+ 338 - 0
enc_temp_folder/8274a4e22fc21f2821b38041b42242/World.cpp

@@ -0,0 +1,338 @@
+#include <Network.h>
+#include <Welt3D.h>
+#include <GraphicsApi.h>
+#include <iostream>
+#include "World.h"
+#include "Globals.h"
+#include "WorldUpdate.h"
+#include "Constants.h"
+#include "Registries.h"
+#include "Game.h"
+#include <AsynchronCall.h>
+
+using namespace Network;
+using namespace Framework;
+
+World* World::INSTANCE = 0;
+
+World::World(Bildschirm3D* zScreen, FactoryClient* client)
+	: Thread(),
+	client(client)
+{
+	renderedWorld = new Welt3D();
+	renderedWorld->addDiffuseLight(DiffuseLight{ Vec3<float>(0.5f, 0.5f, -1.f), Vec3<float>(1.f, 1.f, 1.f) });
+	currentDimension = new Dimension();
+	zScreenPtr = zScreen;
+	kam = new PlayerKam(zScreen);
+	kam->setWelt(renderedWorld);
+	zScreen->addKamera(kam);
+	firstMessage = 1;
+	ownEntityId = -1;
+	currentTarget = 0;
+	start();
+}
+
+World::~World()
+{
+	zScreenPtr->removeKamera(kam);
+	currentDimension->release();
+	if (currentTarget)
+		currentTarget->release();
+	client->release();
+}
+
+void World::update(bool background)
+{
+	NetworkReader* serverMessageReader = 0;
+	unsigned char type = 0;
+	while (background ? serverMessageReader = client->getNextBackgroundMessage() : serverMessageReader = client->getNextForegroundMessage())
+	{
+		serverMessageReader->lese((char*)&type, 1);
+		if (type == 2) // WORLD UPDATE
+		{
+			int id = 0;
+			serverMessageReader->lese((char*)&id, 4);
+			STATIC_REGISTRY(WorldUpdateType).zElement(id)->applyUpdateAndCheck(serverMessageReader);
+		}
+		if (type == 3) // API MESSAGE
+		{
+			int length;
+			serverMessageReader->lese((char*)&length, 4);
+			char* data = new char[length];
+			serverMessageReader->lese(data, length);
+			switch (data[0])
+			{
+			case 1: // dimension message
+			{
+				currentDimension->api(data + 1);
+				break;
+			}
+			case 2: // gui message
+				((Game*)(Menu*)menuRegister->get("game"))->api(data + 1);
+				break;
+			case 3: // set target
+			{
+				switch (data[1])
+				{
+				case 0:
+					setTarget(0);
+					break;
+				case 1:
+					setTarget(zEntity(*(int*)(data + 2)));
+					break;
+				case 2:
+					setTarget(zBlockAt(Vec3<int>(*(int*)(data + 2), *(int*)(data + 6), *(int*)(data + 10))));
+					break;
+				}
+				break;
+			}
+			}
+			delete[] data;
+			// TODO: process messages
+		}
+		if (type == 4) // POSITION UPDATE
+		{
+			int old = ownEntityId;
+			serverMessageReader->lese((char*)&ownEntityId, 4);
+			kam->setEntityId(ownEntityId);
+			Entity* p = zEntity(ownEntityId);
+			if (p)
+				p->setPlayerControlled();
+			if (old != ownEntityId)
+				client->sendPlayerAction("\5", 1);
+		}
+		client->endMessageReading(background);
+	}
+	client->endMessageReading(background);
+	Entity* player = getCurrentPlayerEntity();
+	if (player)
+	{
+		renderedWorld->lock();
+		currentDimension->removeDistantChunks({ (int)player->getPos().x, (int)player->getPos().y });
+		Punkt currentChunk = getChunkCenter((int)player->getX(), (int)player->getY());
+		for (int x = 0; x <= CHUNK_VISIBILITY_RANGE; x++)
+		{
+			for (int y = 0; y <= CHUNK_VISIBILITY_RANGE; y++)
+			{
+				std::function<void(Punkt)> requestChunk = [this](Punkt center)
+				{
+					Chunk* zC = currentDimension->zChunk(center);
+					if (!zC)
+					{
+						char msg[1];
+						msg[0] = 0; // add observer and request chaunk data
+						Punkt pos = center;
+						subLock.lock();
+						bool found = 0;
+						for (Punkt p : subscriptions)
+						{
+							if (p == pos)
+							{
+								found = 1;
+								break;
+							}
+						}
+						if (!found)
+						{
+							client->chunkAPIRequest(pos, msg, 1);
+							subscriptions.add(pos);
+						}
+						subLock.unlock();
+					}
+				};
+				requestChunk(currentChunk + Punkt(x * CHUNK_SIZE, y * CHUNK_SIZE));
+				if (y > 0)
+					requestChunk(currentChunk + Punkt(x * CHUNK_SIZE, -y * CHUNK_SIZE));
+				if (x > 0)
+				{
+					requestChunk(currentChunk + Punkt(-x * CHUNK_SIZE, y * CHUNK_SIZE));
+					if (y > 0)
+						requestChunk(currentChunk + Punkt(-x * CHUNK_SIZE, -y * CHUNK_SIZE));
+				}
+			}
+		}
+		renderedWorld->unlock();
+	}
+}
+
+void World::setChunk(Chunk* chunk)
+{
+	zScreenPtr->lock();
+	renderedWorld->lock();
+	currentDimension->setChunk(chunk, chunk->getCenter());
+	renderedWorld->unlock();
+	zScreenPtr->unlock();
+}
+
+void World::thread()
+{
+	new AsynchronCall("World Update", [this]()
+		{
+			while (true)
+			{
+				zScreenPtr->lock();
+				if (World::INSTANCE != this)
+				{
+					zScreenPtr->unlock();
+					return;
+				}
+				zScreenPtr->unlock();
+				update(0);
+				Sleep(10);
+			}
+		});
+	while (true)
+	{
+		zScreenPtr->lock();
+		if (World::INSTANCE != this)
+		{
+			zScreenPtr->unlock();
+			return;
+		}
+		zScreenPtr->unlock();
+		update(1);
+		Sleep(10);
+	}
+}
+
+Block* World::zBlockAt(Framework::Vec3<int> location) const
+{
+	return currentDimension->zBlock(location);
+	return 0;
+}
+
+Block* World::getBlockAt(Framework::Vec3<int> location) const
+{
+	return currentDimension->getBlock(location);
+	return 0;
+}
+
+Dimension* World::zDimension() const
+{
+	return currentDimension;
+}
+
+void World::setVisibility(Chunk* zChunk, bool visible)
+{
+	renderedWorld->lock();
+	if (visible)
+		renderedWorld->addCollection(dynamic_cast<Framework::Model3DCollection*>(zChunk->getThis()));
+	else
+		renderedWorld->removeCollection(zChunk);
+	renderedWorld->unlock();
+}
+
+void World::setVisibility(Entity* zEntity, bool visible)
+{
+	renderedWorld->lock();
+	if (visible)
+		renderedWorld->addZeichnung(dynamic_cast<Framework::Model3D*>(zEntity->getThis()));
+	else
+		renderedWorld->removeZeichnung(zEntity);
+	renderedWorld->unlock();
+}
+
+Framework::Punkt World::getChunkCenter(int x, int y) const
+{
+	return Punkt(((x < 0 ? x + 1 : x) / CHUNK_SIZE) * CHUNK_SIZE + (x < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2, ((y < 0 ? y + 1 : y) / CHUNK_SIZE) * CHUNK_SIZE + (y < 0 ? -CHUNK_SIZE : CHUNK_SIZE) / 2);
+}
+
+Entity* World::zEntity(int id) const
+{
+	Entity* e = currentDimension->zEntity(id);
+	if (e)
+		return e;
+	return 0;
+}
+
+Entity* World::getEntity(int id) const
+{
+	Entity* e = currentDimension->getEntity(id);
+	if (e)
+		return e;
+	return 0;
+}
+
+void World::removeEntity(int id)
+{
+	currentDimension->removeEntity(id);
+}
+
+PlayerKam* World::zKamera() const
+{
+	return kam;
+}
+
+int World::getCurrentPlayerId() const
+{
+	return ownEntityId;
+}
+
+Entity* World::getCurrentPlayerEntity() const
+{
+	return zEntity(ownEntityId);
+}
+
+void World::setTarget(Framework::Model3D* zTarget)
+{
+	if (zTarget != currentTarget)
+	{
+		targetLock.lock();
+		if (currentTarget)
+		{
+			currentTarget->setAmbientFactor(currentTarget->getAmbientFactor() - 0.2f);
+			currentTarget->release();
+			currentTarget = 0;
+		}
+		if (zTarget)
+		{
+			currentTarget = dynamic_cast<Framework::Model3D*>(zTarget->getThis());
+			if (currentTarget)
+				currentTarget->setAmbientFactor(currentTarget->getAmbientFactor() + 0.2f);
+		}
+		targetLock.unlock();
+	}
+}
+
+void World::lockWorld()
+{
+	renderedWorld->lock();
+}
+
+void World::unlockWorld()
+{
+	renderedWorld->unlock();
+}
+
+void World::onChunkAdded(Punkt pos)
+{
+	subLock.lock();
+	int index = 0;
+	for (Punkt p : subscriptions)
+	{
+		if (p == pos)
+		{
+			subscriptions.remove(index);
+			break;
+		}
+		index++;
+	}
+	subLock.unlock();
+}
+
+Framework::Model3D* World::getCurrentTarget() const
+{
+	while (targetLock.isLocked())
+		Sleep(1);
+	return currentTarget ? dynamic_cast<Framework::Model3D*>(currentTarget->getThis()) : 0;
+}
+
+Chunk* World::zChunk(Punkt center)
+{
+	return currentDimension->zChunk(center);
+}
+
+FactoryClient* World::zClient() const
+{
+	return client;
+}

+ 67 - 0
enc_temp_folder/8726edde9d5ce1ea4fea362660bb528e/Main.cpp

@@ -0,0 +1,67 @@
+#include <main.h>
+#include <Network.h>
+#include <HttpRequest.h>
+#include <JSON.h>
+#include <Fenster.h>
+#include <Bildschirm.h>
+#include <GraphicsApi.h>
+#include <RenderThread.h>
+#include <Datei.h>
+#include <Schrift.h>
+#include <DateiSystem.h>
+#include "Globals.h"
+#include "CustomDX11API.h"
+
+
+int KSGStart Framework::Start(Framework::Startparam p)
+{
+	Network::Start(20);
+	initVariables();
+	setDebugDX(1);
+
+	Datei d;
+	d.setDatei("data/schriften");
+	auto list = d.getDateiListe();
+	for (Text* fontFile : *list)
+	{
+		LTDSDatei dat;
+		dat.setPfad(new Text(Text("data/schriften/").operator+(fontFile->getText())));
+		dat.leseDaten();
+		Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
+		fontRegister->put(*name, RCPointer<Schrift>::of(dat.ladeSchrift()));
+		name->release();
+	}
+	list->release();
+
+	WFenster window;
+	::window = &window;
+	WNDCLASS wc = Framework::F_Normal(p.hinst);
+	wc.lpszClassName = "Factory Craft";
+	window.erstellen(WS_POPUPWINDOW, wc);
+	Monitor m = Framework::getMonitor(0);
+	window.setBounds(Punkt(m.x, m.y), Punkt(m.breite, m.height));
+	window.setAnzeigeModus(SW_SHOWNORMAL);
+	window.setVSchließAktion([&window](void* p, void* f)
+		{
+			StopNachrichtenSchleife(window.getFensterHandle());
+		});
+	window.setMausAktion(_ret1ME);
+	window.setTastaturAktion(_ret1TE);
+	Bildschirm3D screen(dynamic_cast<WFenster*>(window.getThis()), new CustomDX11API());
+	window.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+	screen.setFillFarbe(0);
+
+	uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
+	initMenus();
+
+	RenderTh rTh;
+	rTh.setMaxFps(120);
+	rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+
+	rTh.beginn();
+	StartNachrichtenSchleife();
+	rTh.beenden();
+	releaseVariables();
+	Network::Exit();
+	return 0;
+}

+ 154 - 0
enc_temp_folder/89933bbcaa9a07595a67688884dbd2/PlayerKam.cpp

@@ -0,0 +1,154 @@
+#include <Globals.h>
+#include "PlayerKam.h"
+#include "Globals.h"
+#include "Game.h"
+
+
+PlayerKam::PlayerKam(Framework::Bildschirm3D* zScreen)
+	: Kam3D()
+{
+	kameraControll = 0;
+	setBildschirmPosition(0, 0);
+	setBildschirmSize(zScreen->getBackBufferSize());
+	setStyle(Kam3D::Style::Tick | Kam3D::Style::Movable | Kam3D::Style::Rotatable);
+	setRotation({ (float)PI / 2.f, 0, 0 });
+	entityId = -1;
+}
+
+void PlayerKam::setDirection(Framework::Vec3<float> direction)
+{
+	if (direction.getLengthSq() > 0)
+	{
+		float rotZ = std::atan2(direction.y, direction.x) + (float)PI / 2;
+		setRotation({ getRotation().x, getRotation().y, rotZ });
+	}
+}
+
+void PlayerKam::doTastaturEreignis(Framework::TastaturEreignis& te)
+{
+	if (te.id == TE_Press)
+	{
+		if (te.taste[0] >= '0' && te.taste[0] <= '9')
+		{
+			char action[5];
+			action[0] = 3;
+			*(int*)(action + 1) = te.taste[0] - '1';
+			if (*(int*)(action + 1) < 0)
+				*(int*)(action + 1) = 9;
+			World::INSTANCE->zClient()->sendPlayerAction(action, 5);
+		}
+	}
+	if (te.id == TE_Release)
+	{
+		if (te.virtualKey == T_Esc)
+		{
+			bool oldControl = kameraControll;
+			kameraControll = 0;
+			setShowCursor(true);
+			if (!oldControl)
+				((Game*)(Menu*)menuRegister->get("game"))->closeCurrentDialog();
+		}
+		if (te.virtualKey == T_Tab)
+		{
+			char action = 4;
+			World::INSTANCE->zClient()->sendPlayerAction(&action, 1);
+		}
+	}
+}
+
+void PlayerKam::doMausEreignis(Framework::MausEreignis& me)
+{
+	if (me.verarbeitet)
+	{
+		kameraControll = 0;
+		setShowCursor(true);
+	}
+	else
+	{
+		if (!kameraControll)
+		{
+			if (me.id == ME_PLinks)
+				setControlEnabled(1);
+		}
+		else
+		{
+			if (kameraControll)
+			{
+				if (me.id == ME_PLinks)
+				{
+					char action[2] = { 1, 8 };
+					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+				}
+				if (me.id == ME_RLinks)
+				{
+					char action[2] = { 0, 8 };
+					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+				}
+				if (me.id == ME_PRechts)
+				{
+					char action[2] = { 1, 9 };
+					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+				}
+				if (me.id == ME_RRechts)
+				{
+					char action[2] = { 0, 9 };
+					World::INSTANCE->zClient()->sendPlayerAction(action, 2);
+				}
+			}
+
+		}
+		me.verarbeitet = 1;
+	}
+}
+
+bool PlayerKam::tick(double time)
+{
+	__int64 style = 0;
+	if (hatStyle(Style::Movable))
+		style |= Style::Movable;
+	if (hatStyle(Style::Rotatable))
+		style |= Style::Rotatable;
+	if (hatStyle(Style::Zoomable))
+		style |= Style::Zoomable;
+	removeStyle(Style::Movable | Style::Rotatable | Style::Zoomable);
+	bool result = Kam3D::tick(time);
+	addStyle(style);
+	if (kameraControll)
+	{
+		Punkt dir = window->getGröße() / 2 - (getMausPos() - window->getPosition());
+		setRotation({ min(max(getRotation().x - dir.y * (float)time * 0.2f, 0.1f), 2.5f), getRotation().y, getRotation().z - dir.x * (float)time * 0.2f });
+		if (getRotation().z > 2 * PI)
+			setRotation({ getRotation().x, getRotation().y, getRotation().z - 2.f * (float)PI });
+		if (getRotation().z < -2 * PI)
+			setRotation({ getRotation().x, getRotation().y, getRotation().z + 2.f * (float)PI });
+		SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2, window->getPosition().y + window->getKörperGröße().y / 2);
+		setShowCursor(false);
+		setMausPos(window->getPosition() + window->getGröße() / 2);
+	}
+	return result;
+}
+
+void PlayerKam::setEntityId(int id)
+{
+	entityId = id;
+}
+
+void PlayerKam::setControlEnabled(bool enabled)
+{
+	kameraControll = enabled;
+	setShowCursor(!kameraControll);
+	if (kameraControll)
+	{
+		SetCursorPos(window->getPosition().x + window->getKörperGröße().x / 2, window->getPosition().y + window->getKörperGröße().y / 2);
+	}
+}
+
+int PlayerKam::getEntityId() const
+{
+	return entityId;
+}
+
+Framework::Vec3<float> PlayerKam::getDirection() const
+{
+	return getWorldDirection(getScreenPos() + getScreenSize() / 2);
+}

+ 26 - 0
enc_temp_folder/934b78f6f6df2e34ddbc8435a7aae/UIMLToolTip.cpp

@@ -0,0 +1,26 @@
+#include "UIMLToolTip.h"
+#include "Globals.h"
+
+using namespace Framework;
+
+UIMLToolTip::UIMLToolTip()
+	: ToolTip(window->zBildschirm())
+{
+	view = new UIMLView("", uiFactory);
+	addMember(view);
+	view->setStyle(UIMLView::Style::Sichtbar);
+	addStyle(ZeichnungHintergrund::Style::Hintergrund | ZeichnungHintergrund::Style::HAlpha | ZeichnungHintergrund::Style::Rahmen | ZeichnungHintergrund::Style::Sichtbar);
+	setHintergrundFarbe(0xA0000000);
+	setRahmenFarbe(0xFFFFFFFF);
+	setRahmenBreite(1);
+}
+
+UIMLToolTip::~UIMLToolTip()
+{}
+
+void UIMLToolTip::setUIML(const char* uiml)
+{
+	view->setUIML(uiml);
+	view->layout();
+	view->setSize(view->calculateContentSize());
+}

+ 33 - 0
enc_temp_folder/973c14c36971b73cfeec68881d0683/Area.h

@@ -0,0 +1,33 @@
+#pragma once
+
+#include <Vec3.h>
+
+struct Area
+{
+	int startX;
+	int startY;
+	int endX;
+	int endY;
+	int dimensionId;
+};
+
+enum Direction
+{
+	NO_DIRECTION = 0,
+	NORTH = 1,
+	EAST = 2,
+	SOUTH = 4,
+	WEST = 8,
+	TOP = 16,
+	BOTTOM = 32,
+	INSIDE = 64
+};
+typedef int Directions;
+
+#define ANY_DIRECTION NORTH | EAST | SOUTH | WEST | TOP | BOTTOM
+
+Framework::Vec3<int> getDirection(Directions dir);
+int getDirectionIndex(Direction dir);
+Direction getOppositeDirection(Direction dir);
+Direction getDirectionFromIndex(int index);
+Directions getDirectionsFromVector(Framework::Vec3<float> dir);

+ 37 - 0
enc_temp_folder/9fe4615ad7bd97e9947e71f0c09e7f2d/Chunk.h

@@ -0,0 +1,37 @@
+#pragma once
+
+#include <Punkt.h>
+#include <Model3DCollection.h>
+#include <Reader.h>
+#include <Model3D.h>
+#include <Array.h>
+#include <Critical.h>
+
+#include "Block.h"
+#include "Area.h"
+
+class Chunk : public Framework::Model3DCollection
+{
+private:
+	Framework::Punkt location;
+	// TODO: use native array for bedder performance?
+	Framework::RCArray<Block> blocks;
+	Framework::Array<Block*> visibleBlocks;
+	bool isLoading;
+	Framework::Critical cs;
+	Framework::Critical vcs;
+
+public:
+	Chunk(Framework::Punkt location);
+	Chunk(Framework::Punkt location, Framework::StreamReader* zReader);
+	~Chunk();
+	void api(char* message);
+	Block* zBlockAt(Framework::Vec3<int> cLocation);
+	void setBlock(Block* block);
+	void removeBlock(Block* zBlock);
+	void load(Framework::StreamReader* zReader);
+	Framework::Punkt getCenter() const;
+	Framework::Vec3<int> getMin() const;
+	Framework::Vec3<int> getMax() const;
+	void forAll(std::function<void(Model3D*)> f) override;
+};

+ 115 - 0
enc_temp_folder/a0fa8bd84ace35bac3eb2735544cd/AddServerMenu.cpp

@@ -0,0 +1,115 @@
+#include "AddServerMenu.h"
+#include "Initialisierung.h"
+#include "Globals.h"
+#include "ServerSelection.h"
+
+AddServerMenu::AddServerMenu(Bildschirm* zScreen)
+	: Menu(zScreen)
+{
+	Punkt center = zScreen->getBackBufferSize() / 2;
+	TextFeld* nameLabel = initTextFeld(center.x - 150, center.y - 50, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Name:");
+	elements.add(nameLabel);
+	name = initTextFeld(nameLabel->getPosition().x + nameLabel->getBreite(), nameLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
+	name->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
+		{
+			if (te.id == TE_Release && te.virtualKey == T_Tab)
+			{
+				name->removeStyle(Zeichnung::Style::Fokus);
+				address->addStyle(Zeichnung::Style::Fokus);
+			}
+			return te.virtualKey != T_Tab;
+		});
+	elements.add(name);
+
+	TextFeld* addressLabel = initTextFeld(center.x - 150, center.y - 25, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Server Address:");
+	elements.add(addressLabel);
+	address = initTextFeld(addressLabel->getPosition().x + addressLabel->getBreite(), addressLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
+	address->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
+		{
+			if (te.id == TE_Release && te.virtualKey == T_Tab)
+			{
+				address->removeStyle(Zeichnung::Style::Fokus);
+				sslPort->addStyle(Zeichnung::Style::Fokus);
+			}
+			return te.virtualKey != T_Tab;
+		});
+	elements.add(address);
+
+	TextFeld* sslPortLabel = initTextFeld(center.x - 150, center.y, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "SSL Server Port:");
+	elements.add(sslPortLabel);
+	sslPort = initTextFeld(sslPortLabel->getPosition().x + sslPortLabel->getBreite(), sslPortLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
+	sslPort->setTastaturEreignis([this](void* p, void* o, TastaturEreignis te)
+		{
+			if (te.id == TE_Release && te.virtualKey == T_Tab)
+			{
+				sslPort->removeStyle(Zeichnung::Style::Fokus);
+				port->addStyle(Zeichnung::Style::Fokus);
+			}
+			return te.virtualKey != T_Tab && _nurNummernTE(p, o, te);
+		});
+	elements.add(sslPort);
+	TextFeld* portLabel = initTextFeld(center.x - 150, center.y + 25, 100, 20, TextFeld::Style::Text | TextFeld::Style::VCenter, "Server Port:");
+	elements.add(portLabel);
+	port = initTextFeld(portLabel->getPosition().x + portLabel->getBreite(), portLabel->getPosition().y, 200, 20, TextFeld::Style::TextFeld, "");
+	port->setTastaturEreignis(_nurNummernTE);
+	elements.add(port);
+
+	add = initKnopf(center.x + 50, center.y + 50, 100, 20, Knopf::Style::Normal, "Add");
+	add->setMausEreignis([this](void* p, void* o, MausEreignis me)
+		{
+			if (me.id == ME_RLinks)
+			{
+				if (name->zText()->getLength() && address->zText()->getLength() && port->zText()->getLength())
+				{
+					if (!((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))->hasServer(name->zText()->getText()))
+					{
+						hide();
+						menuRegister->get("serverSelection")->show();
+						((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))->addServer(name->zText()->getText(), address->zText()->getText(), (unsigned short)(int)*sslPort->zText(), (unsigned short)(int)*port->zText());
+						name->zText()->setText("");
+						address->zText()->setText("");
+						port->zText()->setText("");
+						sslPort->zText()->setText("");
+						name->setAlphaFeldFarbe(0xFF3d3d3d);
+						address->setAlphaFeldFarbe(0xFF3d3d3d);
+						port->setAlphaFeldFarbe(0xFF3d3d3d);
+						sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
+					}
+					else
+						name->setAlphaFeldFarbe(0xFF3d0000);
+				}
+				else
+				{
+					if(!name->zText()->getLength())
+						name->setAlphaFeldFarbe(0xFF3d0000);
+					if (!address->zText()->getLength())
+						address->setAlphaFeldFarbe(0xFF3d0000);
+					if (!port->zText()->getLength())
+						port->setAlphaFeldFarbe(0xFF3d0000);
+					if (!sslPort->zText()->getLength())
+						sslPort->setAlphaFeldFarbe(0xFF3d0000);
+				}
+			}
+			return 1;
+		});
+	elements.add(add);
+
+	abort = initKnopf(center.x - 150, center.y + 50, 100, 20, Knopf::Style::Normal, "Abort");
+	abort->setMausEreignis([this](void* p, void* o, MausEreignis me)
+		{
+			if (me.id == ME_RLinks)
+			{
+				hide();
+				menuRegister->get("serverSelection")->show();
+				name->zText()->setText("");
+				address->zText()->setText("");
+				port->zText()->setText("");
+				name->setAlphaFeldFarbe(0xFF3d3d3d);
+				address->setAlphaFeldFarbe(0xFF3d3d3d);
+				port->setAlphaFeldFarbe(0xFF3d3d3d);
+				sslPort->setAlphaFeldFarbe(0xFF3d3d3d);
+			}
+			return 1;
+		});
+	elements.add(abort);
+}

+ 209 - 0
enc_temp_folder/a36e7559d0941b36cff6d7348813d2d2/Block.cpp

@@ -0,0 +1,209 @@
+#include <Textur.h>
+#include <Shader.h>
+
+#include "Block.h"
+#include "Globals.h"
+#include "CustomDX11API.h"
+
+
+Block::Block(const BlockType* zType, Framework::Vec3<int> pos, Model3DData* model, Model3DTextur* texture, int maxHP)
+	: Model3D(),
+	zType(zType),
+	location(pos),
+	maxHP((float)maxHP)
+{
+	transparent = 0;
+	hp = (float)maxHP;
+	memset(sideVisible, 0, 6);
+	Model3D::setPosition((Framework::Vec3<float>)pos + Framework::Vec3<float>{0.5f, 0.5f, 0.5f});
+	setModelDaten(model);
+	setModelTextur(texture);
+	breakTextur = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur("blocks.ltdb/crack.png", 0);
+	memset(lightData, 0, 6 * 6);
+}
+
+Block::~Block()
+{
+	breakTextur->release();
+}
+
+void Block::beforeRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
+{
+	CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
+	if (cApi && model->getVertexAnzahl() == 24)
+	{
+		int count = 24;
+		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+		zVertexShader->füllConstBuffer(lightBuffer, cApi->getVertexShaderLightBufferIndex() + 1, 24 * 4);
+	}
+	else
+	{
+		int count = 0;
+		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+	}
+}
+
+void Block::afterRender(GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader)
+{
+	CustomDX11API* cApi = dynamic_cast<CustomDX11API*>(api);
+	if (cApi && model->getVertexAnzahl() == 24)
+	{
+		int count = 0;
+		zVertexShader->füllConstBuffer((char*)&count, cApi->getVertexShaderLightBufferIndex(), 4);
+	}
+}
+
+void Block::api(char* message)
+{
+	// TODO: implement api
+	switch (message[0])
+	{
+	case 0: // hp change
+		hp = *(float*)(message + 1);
+		break;
+	}
+}
+
+bool Block::isTransparent() const
+{
+	return transparent;
+}
+
+void Block::setLightData(Direction dir, unsigned char* data)
+{
+	memcpy(lightData + getDirectionIndex(dir) * 6, data, 6);
+	if (model->getVertexAnzahl() == 24)
+	{
+		float dayLightFactor = 1.0; // TODO: day (1.f) - night (0.1f) adjustment
+		const Vertex3D* verticies = model->zVertexBuffer();
+		for (int i = 0; i < 24; i++)
+		{ // TODO: calculate rotations
+			Directions dirs = getDirectionsFromVector(verticies[i].pos);
+			Vec3<unsigned char> light(0, 0, 0);
+			for (int d = 0; d < 6; d++)
+			{
+				if ((dirs | getDirectionFromIndex(d)) == dirs)
+				{
+					light = Vec3<unsigned char>(max((unsigned char)((float)lightData[d * 6] * dayLightFactor), light.x), max((unsigned char)((float)lightData[d * 6 + 1] * dayLightFactor), light.y), max((unsigned char)((float)lightData[d * 6 + 2] * dayLightFactor), light.z));
+					light = Vec3<float>(max(lightData[d * 6 + 3], light.x), max(lightData[d * 6 + 4], light.y), max(lightData[d * 6 + 5], light.z));
+				}
+			}
+			int l = ((((light.x << 8) | light.y) << 8) | light.z) << 8;
+			*(int*)(lightBuffer + i * 4) = l;
+		}
+	}
+	if (data[0] | data[1] | data[2] | data[3] | data[4] | data[5])
+		sideVisible[getDirectionIndex(dir)] = 1;
+	else
+		sideVisible[getDirectionIndex(dir)] = 0;
+}
+
+bool Block::isVisible() const
+{
+	return sideVisible[0] || sideVisible[1] || sideVisible[2] || sideVisible[3] || sideVisible[4] || sideVisible[5];
+}
+
+Vec3<int> Block::getLocation() const
+{
+	return location;
+}
+
+const BlockType* Block::zBlockType() const
+{
+	return zType;
+}
+
+Textur* Block::zEffectTextur()
+{
+	if (hp < maxHP)
+		return breakTextur;
+	return 0;
+}
+
+float Block::getEffectPercentage()
+{
+	return 1 - hp / maxHP;
+}
+
+Text Block::printLightInfo()
+{
+	Text result = "NORTH[0;-1;0](";
+	result += (int)lightData[0];
+	result += ",";
+	result += (int)lightData[1];
+	result += ",";
+	result += (int)lightData[2];
+	result += ";";
+	result += (int)lightData[3];
+	result += ",";
+	result += (int)lightData[4];
+	result += ",";
+	result += (int)lightData[5];
+	result += ")\n";
+	result += "EAST[1;0;0](";
+	result += (int)lightData[6];
+	result += ",";
+	result += (int)lightData[7];
+	result += ",";
+	result += (int)lightData[8];
+	result += ";";
+	result += (int)lightData[9];
+	result += ",";
+	result += (int)lightData[10];
+	result += ",";
+	result += (int)lightData[11];
+	result += ")\n";
+	result += "SOUTH[0;1;0](";
+	result += (int)lightData[12];
+	result += ",";
+	result += (int)lightData[13];
+	result += ",";
+	result += (int)lightData[14];
+	result += ";";
+	result += (int)lightData[15];
+	result += ",";
+	result += (int)lightData[16];
+	result += ",";
+	result += (int)lightData[17];
+	result += ")\n";
+	result += "WEST[-1;0;0](";
+	result += (int)lightData[18];
+	result += ",";
+	result += (int)lightData[19];
+	result += ",";
+	result += (int)lightData[20];
+	result += ";";
+	result += (int)lightData[21];
+	result += ",";
+	result += (int)lightData[22];
+	result += ",";
+	result += (int)lightData[23];
+	result += ")\n";
+	result += "TOP[0;0;1](";
+	result += (int)lightData[24];
+	result += ",";
+	result += (int)lightData[25];
+	result += ",";
+	result += (int)lightData[26];
+	result += ";";
+	result += (int)lightData[27];
+	result += ",";
+	result += (int)lightData[28];
+	result += ",";
+	result += (int)lightData[29];
+	result += ")\n";
+	result += "BOTTOM[0;0;-1](";
+	result += (int)lightData[30];
+	result += ",";
+	result += (int)lightData[31];
+	result += ",";
+	result += (int)lightData[32];
+	result += ";";
+	result += (int)lightData[33];
+	result += ",";
+	result += (int)lightData[34];
+	result += ",";
+	result += (int)lightData[35];
+	result += ")\n";
+	return result;
+}

+ 63 - 0
enc_temp_folder/a64d52bdd16464cbf99c34b69d888f2/InventoryView.h

@@ -0,0 +1,63 @@
+#pragma once
+
+#include <UIMLView.h>
+#include <Either.h>
+#include <VecN.h>
+
+#include "NetworkAPIProcessor.h"
+
+class InventoryElement : public Framework::UIMLElement
+{
+public:
+	InventoryElement();
+	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+	bool isApplicableFor(Framework::XML::Element& element) override;
+	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
+	//! wendet die layout parameter zu einer Zeichnung an
+	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+};
+
+struct SlotInfo
+{
+	int id;
+	int itemCount;
+	float hp;
+	float maxHp;
+	float durability;
+	float maxDurability;
+	Framework::Bild* zItem;
+
+	void render(int x, int y, Framework::Bild& rObj, bool selected, bool lightBackground);
+};
+
+class InventoryDragSource
+{
+public:
+	virtual Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const = 0;
+};
+
+class InventoryView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor, public InventoryDragSource
+{
+private:
+	int rowSize;
+	// entity id or block position
+	Framework::Either<int, Framework::VecN<int, 4>> target;
+	Framework::Text slotNameFilter;
+	Framework::Text id;
+	Framework::Array<SlotInfo>* slots;
+	int dragStartId;
+	int dragStopId;
+	int currentTooltipSlot;
+	int requestetTooltipSlot;
+	int getSlotByLocalPos(Framework::Punkt pos);
+
+public:
+	InventoryView(Framework::Text id, Framework::Either<int, Framework::VecN<int, 4>> target, int rowSize, Framework::Text slotNameFilter);
+	~InventoryView();
+	void api(char* message) override;
+	bool tick(double tickVal) override;
+	void render(Framework::Bild& rObj) override;
+	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+	Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const override;
+};

+ 23 - 0
enc_temp_folder/a860cdbf2c962163648b92d4fae0758f/PlayerKam.h

@@ -0,0 +1,23 @@
+#pragma once
+#include <Kam3D.h>
+#include <TastaturEreignis.h>
+#include <Bildschirm.h>
+#include <Zeit.h>
+
+class PlayerKam : public Framework::Kam3D
+{
+private:
+	bool kameraControll;
+	int entityId;
+
+public:
+	PlayerKam(Framework::Bildschirm3D* zScreen);
+	void setDirection(Framework::Vec3<float> direction);
+	void doTastaturEreignis(Framework::TastaturEreignis& te) override;
+	void doMausEreignis(Framework::MausEreignis& me) override;
+	bool tick(double time) override;
+	void setEntityId(int id);
+	void setControlEnabled(bool enabled);
+	int getEntityId() const;
+	Framework::Vec3<float> getDirection() const;
+};

+ 79 - 0
enc_temp_folder/aedf935c6dd4db16dd4e3a49daa122/Area.cpp

@@ -0,0 +1,79 @@
+#include "Area.h"
+
+
+Framework::Vec3<int> getDirection(Directions dir)
+{
+	Framework::Vec3<int> result(0, 0, 0);
+	if ((dir | NORTH) == dir)
+		--result.y;
+	if ((dir | EAST) == dir)
+		++result.x;
+	if ((dir | SOUTH) == dir)
+		++result.y;
+	if ((dir | WEST) == dir)
+		--result.x;
+	if ((dir | TOP) == dir)
+		++result.z;
+	if ((dir | BOTTOM) == dir)
+		--result.z;
+	return result;
+}
+
+int getDirectionIndex(Direction dir)
+{
+	if (dir == NORTH)
+		return 0;
+	if (dir == EAST)
+		return 1;
+	if (dir == SOUTH)
+		return 2;
+	if (dir == WEST)
+		return 3;
+	if (dir == TOP)
+		return 4;
+	if (dir == BOTTOM)
+		return 5;
+	assert(false);
+	return -1;
+}
+
+Direction getOppositeDirection(Direction dir)
+{
+	if (dir == NORTH)
+		return SOUTH;
+	if (dir == EAST)
+		return WEST;
+	if (dir == SOUTH)
+		return NORTH;
+	if (dir == WEST)
+		return EAST;
+	if (dir == TOP)
+		return BOTTOM;
+	if (dir == BOTTOM)
+		return TOP;
+	assert(false);
+	return NO_DIRECTION;
+}
+
+Direction getDirectionFromIndex(int index)
+{
+	return (Direction)(1 << index);
+}
+
+Directions getDirectionsFromVector(Framework::Vec3<float> dir)
+{
+	Directions dirs = NO_DIRECTION;
+	if (dir.y < 0)
+		dirs |= NORTH;
+	else if (dir.y > 0)
+		dirs |= SOUTH;
+	if (dir.x < 0)
+		dirs |= WEST;
+	else if (dir.x > 0)
+		dirs |= EAST;
+	if (dir.z < 0)
+		dirs |= BOTTOM;
+	else if (dir.z > 0)
+		dirs |= TOP;
+	return dirs;
+}

+ 53 - 0
enc_temp_folder/b37db95da51546ad7e8cc1c82cf42/Equipment.cpp

@@ -0,0 +1,53 @@
+#include <XML.h>
+
+#include "Equipment.h"
+
+using namespace Framework;
+
+EquipmentElement::EquipmentElement()
+	: UIMLElement()
+{}
+
+//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+bool EquipmentElement::isApplicableFor(Framework::XML::Element& element)
+{
+	return element.getName().istGleich("equipment");
+}
+
+//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+Framework::Zeichnung* EquipmentElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+{
+	return new EquipmentView((int)element.getAttributeValue("entity"));
+}
+
+//! wendet die layout parameter zu einer Zeichnung an
+void EquipmentElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+{
+	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+}
+
+
+EquipmentView::EquipmentView(int entityId)
+	: ZeichnungHintergrund(),
+	entityId(entityId)
+{}
+
+void EquipmentView::api(char* message)
+{
+
+}
+
+bool EquipmentView::tick(double tickVal)
+{
+	return ZeichnungHintergrund::tick(tickVal);
+}
+
+void EquipmentView::render(Bild& rObj)
+{
+	ZeichnungHintergrund::render(rObj);
+}
+
+void EquipmentView::doMausEreignis(MausEreignis& me, bool userRet)
+{
+	ZeichnungHintergrund::doMausEreignis(me, userRet);
+}

+ 14 - 0
enc_temp_folder/b84b4e808b53ee53a977af8adca3bed/EntityRemovedUpdate.h

@@ -0,0 +1,14 @@
+#pragma once
+
+#include "WorldUpdate.h"
+
+class EntityRemovedUpdateType : WorldUpdateType
+{
+	REGISTRABLE(EntityRemovedUpdateType)
+
+protected:
+	EntityRemovedUpdateType();
+	void applyUpdate(Framework::StreamReader* zReader) override;
+};
+
+REGISTER(EntityRemovedUpdateType, WorldUpdateType)

+ 174 - 0
enc_temp_folder/ba411bc21d64e1d04caa78589c762/Game.cpp

@@ -0,0 +1,174 @@
+#include "Game.h"
+#include "Initialisierung.h"
+#include "Globals.h"
+#include "ItemBar.h"
+
+#include <AsynchronCall.h>
+#include <Bildschirm.h>
+
+Game::Game(Bildschirm* zScreen)
+	: Menu(zScreen)
+{
+	inventoryDragController = new DragController<InventoryDragSource, int>();
+	logout = initKnopf(10, 10, 200, 20, Knopf::Style::Normal, "Verlassen");
+	logout->setMausEreignis([this, zScreen](void* p, void* o, MausEreignis me)
+		{
+			if (me.id == ME_RLinks)
+			{
+				logout->removeStyle(Knopf::Style::Erlaubt);
+				new AsynchronCall([this, zScreen]()
+					{
+						// TODO
+						/*if (World::INSTANCE->zClient()->leaveGame())
+						{
+							World::INSTANCE->release();
+							World::INSTANCE = 0;
+							zScreen->lock();
+							hide();
+							menuRegister->get("directConnect")->show();
+							zScreen->unlock();
+						}*/ 
+						logout->addStyle(Knopf::Style::Erlaubt);
+					});
+			}
+			return 1;
+		});
+	elements.add(logout);
+	debug = initTextFeld(10, 40, 500, 250, TextFeld::Style::Text | TextFeld::Style::Mehrzeilig, "");
+	elements.add(debug);
+	guiView = new UIMLView("<v/>", uiFactory);
+	guiView->addKnownElement(new ItemBarElement());
+	guiView->setStyle(UIMLView::Style::Sichtbar);
+	guiView->setSize(window->zBildschirm()->getBackBufferSize());
+	elements.add(guiView);
+}
+
+Game::~Game()
+{
+	inventoryDragController->release();
+}
+
+void Game::updatePosition(Vec3<float> position, bool target, Vec3<int> targetPos)
+{
+	Text txt = "Position: (";
+	txt.setPrecision(2);
+	txt += position.x;
+	txt += ", ";
+	txt += position.y;
+	txt += ", ";
+	txt += position.z;
+	txt += ")";
+	if (target)
+	{
+		txt += "\nTarget: (";
+		txt += targetPos.x;
+		txt += ", ";
+		txt += targetPos.y;
+		txt += ", ";
+		txt += targetPos.z;
+		txt += ")\n";
+		Block* b = World::INSTANCE->zBlockAt(targetPos);
+		if (b)
+		{
+			txt += "TargetLight: \n";
+			txt += b->printLightInfo();
+		}
+	}
+	debug->setText(txt);
+}
+
+void Game::api(char* data)
+{
+	switch (data[0])
+	{
+	case 0: // open dialog
+	{
+		bool exists = 0;
+		short len = *(short*)(data + 1);
+		char* dialogName = new char[len + 1];
+		memcpy(dialogName, data + 3, len);
+		dialogName[len] = 0;
+		for (UIMLDialog* dialog : dialogs)
+		{
+			if (dialog->getName().istGleich(dialogName))
+			{
+				exists = 1;
+				break;
+			}
+		}
+		delete[] dialogName;
+		if (!exists)
+		{
+			int uimlLen = *(int*)(data + 3 + len);
+			char* uiml = new char[uimlLen + 1];
+			memcpy(uiml, data + 7 + len, uimlLen);
+			uiml[uimlLen] = 0;
+			UIMLDialog* dialog = new UIMLDialog(uiml, [this](UIMLDialog* dialog)
+				{
+					logout->postAction([this, dialog]()
+						{
+							int index = 0;
+							for (UIMLDialog* d : dialogs)
+							{
+								if (d == dialog)
+								{
+									dialogs.remove(index);
+									window->zBildschirm()->removeMember(d);
+									World::INSTANCE->zKamera()->setControlEnabled(dialogs.getEintragAnzahl() == 0);
+									break;
+								}
+								index++;
+							}
+						});
+				});
+			dialogs.add(dialog);
+			World::INSTANCE->zKamera()->setControlEnabled(0);
+			window->zBildschirm()->addMember(dialog);
+			delete[]uiml;
+		}
+		break;
+	}
+	case 1:
+	{ // element message
+		for (UIMLDialog* dialog : dialogs)
+		{
+			dialog->api(data + 1);
+		}
+		short idLen = *(short*)(data + 1);
+		char* id = new char[idLen + 1];
+		memcpy(id, data + 3, idLen);
+		id[idLen] = 0;
+		NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(guiView->zZeichnungById(id));
+		if (processor)
+			processor->api(data + 3 + idLen);
+		delete[] id;
+		break;
+	}
+	case 2:
+	{ // set gui
+		int uimlLen = *(int*)(data + 1);
+		char* uiml = new char[uimlLen + 1];
+		memcpy(uiml, data + 5, uimlLen);
+		uiml[uimlLen] = 0;
+		guiView->setUIML(uiml);
+		guiView->layout();
+		delete[] uiml;
+	}
+	}
+}
+
+void Game::closeCurrentDialog()
+{
+	if (dialogs.getEintragAnzahl() > 0)
+	{
+		UIMLDialog* d = dialogs.get(dialogs.getEintragAnzahl() - 1);
+		window->zBildschirm()->removeMember(d);
+		dialogs.remove(dialogs.getEintragAnzahl() - 1);
+		World::INSTANCE->zKamera()->setControlEnabled(dialogs.getEintragAnzahl() == 0);
+	}
+}
+
+DragController<InventoryDragSource, int>* Game::zInventoryDragController()
+{
+	return inventoryDragController;
+}

+ 6 - 0
enc_temp_folder/c5f2270d6bed8d7cbc360ea8541de2b/Constants.h

@@ -0,0 +1,6 @@
+#pragma once
+
+#define CHUNK_SIZE 16
+#define WORLD_HEIGHT 500
+#define CHUNK_VISIBILITY_RANGE 1
+#define MAX_VIEW_DISTANCE CHUNK_SIZE * CHUNK_VISIBILITY_RANGE

+ 39 - 0
enc_temp_folder/c8104cfdb4649a34402666be87bd5661/Dimension.h

@@ -0,0 +1,39 @@
+#pragma once
+
+#include <Array.h>
+#include <Trie.h>
+#include <Critical.h>
+
+#include "Chunk.h"
+#include "Entity.h"
+
+class World;
+
+class Dimension : public virtual Framework::ReferenceCounter
+{
+private:
+	Framework::Trie<Chunk>* chunks;
+	Framework::Array<Chunk*> chunkList;
+	Framework::RCArray<Entity>* entities;
+	Framework::Critical cs;
+	void getAddrOf(Framework::Punkt cPos, char* addr) const;
+	void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
+
+public:
+	Dimension();
+	~Dimension();
+
+	void api(char* message);
+	Block* zBlock(Framework::Vec3<int> location);
+	Block* getBlock(Framework::Vec3<int> location);
+	void addEntity(Entity* entity);
+	void setChunk(Chunk* chunk, Framework::Punkt center);
+	bool hasChunck(int x, int y) const;
+	Chunk* zChunk(Framework::Punkt wPos) const;
+	void removeDistantChunks(Framework::Punkt wPos);
+	void setBlock(Block* block);
+	void removeBlock(Block* zBlock);
+	Entity* zEntity(int id);
+	Entity* getEntity(int id);
+	void removeEntity(int id);
+};

+ 35 - 0
enc_temp_folder/c9cbefe684b7ad84345e9ec04d905b/CustomDX11API.cpp

@@ -0,0 +1,35 @@
+#include <Shader.h> 
+
+#include "CustomDX11API.h"
+
+#include "CustomUIDX11PixelShader.h"
+#include "CustomUIDX11VertexShader.h"
+
+using namespace Framework;
+
+CustomDX11API::CustomDX11API()
+	: DirectX11(),
+	vertexShaderLightBufferIndex(-1)
+{}
+
+Framework::DX11VertexShader* CustomDX11API::initializeVertexShader(unsigned char* byteCode, int size)
+{
+	DX11VertexShader* shader = DirectX11::initializeVertexShader((unsigned char*)CustomUIDX11VertexShader, sizeof(CustomUIDX11VertexShader));
+	vertexShaderLightBufferIndex = shader->getFirstUninitializedBufferIndex();
+	shader->erstelleConstBuffer(4, vertexShaderLightBufferIndex);
+	shader->erstelleConstBuffer(4 * 24, vertexShaderLightBufferIndex + 1);
+	int count = 0;
+	shader->füllConstBuffer((char*)&count, vertexShaderLightBufferIndex, 4);
+	return shader;
+}
+
+Framework::DX11PixelShader* CustomDX11API::initializePixelShader(unsigned char* byteCode, int size)
+{
+	DX11PixelShader* shader = DirectX11::initializePixelShader((unsigned char*)CustomUIDX11PixelShader, sizeof(CustomUIDX11PixelShader));
+	return shader;
+}
+
+int CustomDX11API::getVertexShaderLightBufferIndex() const
+{
+	return vertexShaderLightBufferIndex;
+}

+ 19 - 0
enc_temp_folder/d2cfdfdd6c2c64205fc6875e214b27b/Menu.h

@@ -0,0 +1,19 @@
+#pragma once
+#include <Array.h>
+#include <Zeichnung.h>
+#include <Bildschirm.h>
+
+using namespace Framework;
+
+class Menu : public ReferenceCounter
+{
+protected:
+	RCArray<Zeichnung> elements;
+	Bildschirm* zScreen;
+
+public:
+	Menu(Bildschirm* zScreen);
+
+	void show();
+	void hide();
+};

+ 19 - 0
enc_temp_folder/d46158fac4ce94c9b95a6c8415891c65/WorldUpdate.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include <ReferenceCounter.h>
+#include <Reader.h>
+
+#include "StaticRegistry.h"
+
+class WorldUpdateType : public Framework::ReferenceCounter
+{
+private:
+	int id;
+
+protected:
+	WorldUpdateType(int id);
+	virtual void applyUpdate(Framework::StreamReader* zReader) = 0;
+
+public:
+	void applyUpdateAndCheck(Framework::StreamReader* zReader);
+};

+ 20 - 0
enc_temp_folder/d4e616c36a8b1e2a2abad0acef14d75e/Dialog.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "NetworkAPIProcessor.h"
+
+#include <Fenster.h>
+#include <UIMLView.h>
+
+class UIMLDialog : public Framework::Fenster, public NetworkAPIProcessor
+{
+private:
+	Framework::UIMLView* view;
+	Framework::Text name;
+	std::function<void(UIMLDialog* self)> onClose;
+
+public:
+	UIMLDialog(Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose);
+	~UIMLDialog();
+	void api(char* message) override;
+	const Framework::Text& getName() const;
+};

+ 49 - 0
enc_temp_folder/d96dc9ecf990a09e6658711cb19a4160/CraftingGrid.h

@@ -0,0 +1,49 @@
+#pragma once
+
+#include <UIMLView.h>
+#include <Either.h>
+#include <VecN.h>
+
+#include "NetworkAPIProcessor.h"
+#include "InventoryView.h"
+
+
+class CraftingGridElement : public Framework::UIMLElement
+{
+public:
+	CraftingGridElement();
+	//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+	bool isApplicableFor(Framework::XML::Element& element) override;
+	//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+	Framework::Zeichnung* parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory) override;
+	//! wendet die layout parameter zu einer Zeichnung an
+	void layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter) override;
+};
+
+class CraftingGridView : public Framework::ZeichnungHintergrund, public NetworkAPIProcessor, public InventoryDragSource
+{
+private:
+	int rowSize;
+	int colSize;
+	int numOutputSlots;
+	// entity id or block position
+	Framework::Either<int, Framework::VecN<int, 4>> target;
+	Framework::Array<SlotInfo>* slots;
+	Framework::Array<SlotInfo>* outputs;
+	Framework::Text id;
+	int dragStartId;
+	int dragStopId;
+	Framework::Knopf* craft;
+	int currentTooltipSlot;
+	int requestetTooltipSlot;
+	int getSlotByLocalPos(Framework::Punkt pos);
+
+public:
+	CraftingGridView(Framework::Text id, int rowSize, int colSize, int numOutputSlots, Framework::Either<int, Framework::VecN<int, 4>> target);
+	~CraftingGridView();
+	void api(char* message) override;
+	bool tick(double tickVal) override;
+	void render(Framework::Bild& rObj) override;
+	void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+	Framework::Either<int, Framework::VecN<int, 4>> getInventoryTarget() const override;
+};

+ 18 - 0
enc_temp_folder/daab62b53a5e77ff5b74c75dfd9d368/Registries.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#include "StaticRegistry.h"
+#include "WorldUpdate.h"
+#include "BlockType.h"
+#include "ItemType.h"
+#include "EntityType.h"
+
+#ifndef _REGISTRY
+#define _REGISTRY extern
+#endif
+
+#define STATIC_REGISTRY(Type) Type##Registry
+
+_REGISTRY StaticRegistry<WorldUpdateType> WorldUpdateTypeRegistry;
+_REGISTRY StaticRegistry<BlockType> BlockTypeRegistry;
+_REGISTRY StaticRegistry<ItemType> ItemTypeRegistry;
+_REGISTRY StaticRegistry<EntityType> EntityTypeRegistry;

+ 26 - 0
enc_temp_folder/db15399a5a58f3136329d834c5e88aa/WorldUpdate.cpp

@@ -0,0 +1,26 @@
+#include "WorldUpdate.h"
+
+#include "Registries.h"
+#include <Text.h>
+
+WorldUpdateType::WorldUpdateType(int id)
+	: ReferenceCounter(),
+	id(id)
+{
+	STATIC_REGISTRY(WorldUpdateType).registerT(this, id);
+}
+
+void WorldUpdateType::applyUpdateAndCheck(Framework::StreamReader* zReader)
+{
+	this->applyUpdate(zReader);
+	int id;
+	zReader->lese((char*)&id, 4);
+	if (id != this->id)
+	{
+		Framework::Text* t = new Framework::Text("asynchony after world update of type ");
+		t->append(this->id);
+		t->append(". ID received from server was: ");
+		t->append(id);
+		throw t->getText();
+	}
+}

+ 447 - 0
enc_temp_folder/eadbdf47d7cfcc5ecf485550d574c/CraftingGrid.cpp

@@ -0,0 +1,447 @@
+#include <XML.h>
+
+#include "CraftingGrid.h"
+#include "Globals.h"
+#include "DragController.h"
+#include "Game.h"
+#include "UIMLToolTip.h"
+
+using namespace Framework;
+
+CraftingGridElement::CraftingGridElement()
+	: UIMLElement()
+{}
+
+//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+bool CraftingGridElement::isApplicableFor(Framework::XML::Element& element)
+{
+	return element.getName().istGleich("craftingGrid");
+}
+
+//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+Framework::Zeichnung* CraftingGridElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+{
+	Text targetValue = element.getAttributeValue("target");
+	Vec3<int> blockPos(0, 0, 0);
+	Framework::Either<int, VecN<int, 4>> target((int)targetValue);
+	if (targetValue.hat(','))
+	{
+		Text* first = targetValue.getTeilText(0, targetValue.positionVon(",", 0) + 1);
+		Text* second = targetValue.getTeilText(targetValue.positionVon(",", 0) + 1, targetValue.positionVon(",", 1));
+		Text* third = targetValue.getTeilText(targetValue.positionVon(",", 1) + 1, targetValue.positionVon(",", 2));
+		Text* forth = targetValue.getTeilText(targetValue.positionVon(",", 2) + 1);
+		target = Framework::Either<int, VecN<int, 4>>(VecN<int, 4>({ (int)*first, (int)*second, (int)*third, (int)*forth }));
+		first->release();
+		second->release();
+		third->release();
+		forth->release();
+	}
+	return new CraftingGridView(element.getAttributeValue("id"), (int)element.getAttributeValue("rowSize"), (int)element.getAttributeValue("colSize"), (int)element.getAttributeValue("numOutputSlots"), target);
+}
+
+//! wendet die layout parameter zu einer Zeichnung an
+void CraftingGridElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+{
+	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+}
+
+
+CraftingGridView::CraftingGridView(Text id, int rowSize, int colSize, int numOutputSlots, Either<int, VecN<int, 4>> target)
+	: ZeichnungHintergrund(),
+	rowSize(rowSize),
+	colSize(colSize),
+	numOutputSlots(numOutputSlots),
+	target(target),
+	slots(0),
+	outputs(0),
+	id(id),
+	dragStartId(-1),
+	dragStopId(-1),
+	currentTooltipSlot(-1),
+	requestetTooltipSlot(-1)
+{
+	craft = uiFactory.createKnopf(uiFactory.initParam);
+	craft->setPosition(rowSize * 60, 10);
+	craft->setSize(40, 20);
+	craft->setText("Craft");
+	craft->setMausEreignis([this](void* p, void* o, MausEreignis me)
+		{
+			if (me.id == ME_RLinks)
+			{
+				char* msg = new char[2 + (this->target.isA() ? 4 : 16)];
+				msg[0] = 7; // request crafting
+				msg[1] = (char)this->target.isA();
+				if (msg[1])
+					*(int*)(msg + 2) = this->target.getA();
+				else
+				{
+					*(int*)(msg + 2) = this->target.getB()[0];
+					*(int*)(msg + 6) = this->target.getB()[1];
+					*(int*)(msg + 10) = this->target.getB()[2];
+					*(int*)(msg + 14) = this->target.getB()[3];
+				}
+				World::INSTANCE->zClient()->sendPlayerAction(msg, 2 + (this->target.isA() ? 4 : 16));
+				delete[] msg;
+			}
+			return 1;
+		});
+	setStyle(ZeichnungHintergrund::Style::Sichtbar | ZeichnungHintergrund::Style::Erlaubt);
+	char* msg = new char[id.getLength() + 12 + 3];
+	msg[0] = 0; // request inventory tooltip
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	msg[2 + id.getLength()] = (char)12;
+	memcpy(msg + 3 + id.getLength(), "CraftingGrid", 12);
+	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 12 + 3);
+	delete[] msg;
+	setNeedToolTipEvent([this](Zeichnung* z, Punkt p)
+		{
+			int slot = getSlotByLocalPos(p);
+			if (currentTooltipSlot != slot)
+			{
+				this->setToolTipZ(0);
+				currentTooltipSlot = -1;
+			}
+			else
+				return;
+			if (requestetTooltipSlot != slot)
+			{
+				requestetTooltipSlot = slot;
+				char* msg = new char[this->id.getLength() + 6];
+				msg[0] = 2; // request inventory tooltip
+				msg[1] = (char)this->id.getLength();
+				memcpy(msg + 2, this->id.getText(), this->id.getLength());
+				*(int*)(msg + 2 + this->id.getLength()) = slot;
+				World::INSTANCE->zClient()->inventoryAPIRequest(this->target, msg, this->id.getLength() + 6);
+			}
+		});
+}
+
+CraftingGridView::~CraftingGridView()
+{
+	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+	if (controller->getCurrentDragContainer() == this)
+		controller->stopDrag();
+	if (slots)
+		slots->release();
+	if (outputs)
+		outputs->release();
+	char* msg = new char[id.getLength() + 2];
+	msg[0] = 1;
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	World::INSTANCE->zClient()->inventoryAPIRequest(target, msg, id.getLength() + 2);
+	delete[] msg;
+	craft->release();
+}
+
+int CraftingGridView::getSlotByLocalPos(Punkt pos)
+{
+	int x = 0;
+	int y = 0;
+	int rowCount = 0;
+	int slot = 0;
+	dragStopId = -1;
+	if (slots)
+	{
+		for (SlotInfo info : *slots)
+		{
+			if (pos.x >= x && pos.x < x + 50 && pos.y >= y && pos.y < y + 50)
+				return info.id;
+			x += 60;
+			if (++rowCount >= rowSize)
+			{
+				y += 60;
+				x = 0;
+				rowCount = 0;
+			}
+			slot++;
+		}
+	}
+	return -1;
+}
+
+void CraftingGridView::api(char* message)
+{
+	switch (message[0])
+	{
+	case 0:
+		// send inventory content
+	{
+		Array<SlotInfo>* slots = new Array<SlotInfo>();
+		int count = *(int*)(++message);
+		for (int i = 0; i < count; i++)
+		{
+			SlotInfo info;
+			info.id = *(int*)(message += 4);
+			info.itemCount = *(int*)(message += 4);
+			if (info.itemCount > 0)
+			{
+				info.hp = *(float*)(message += 4);
+				info.maxHp = *(float*)(message += 4);
+				info.durability = *(float*)(message += 4);
+				info.maxDurability = *(float*)(message += 4);
+                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+			}
+			slots->add(info);
+		}
+		postAction([this, slots]()
+			{
+				if (this->slots)
+					this->slots->release();
+				this->slots = slots;
+			});
+		break;
+	}
+	case 1: // set count of items
+	{
+		if (!slots)
+			return;
+		int id = *(int*)(message + 1);
+		int count = *(int*)(message + 5);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = count;
+				if (info.itemCount == 0)
+				{
+					DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+					if (controller && controller->getCurrentDragContainer() == this && controller->getCurrentDaragElement() == info.id)
+					{
+						controller->stopDrag();
+					}
+				}
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 2: // add new stack
+	{
+		if (!slots)
+			return;
+		int id = *(int*)(message + 1);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = *(int*)(message + 5);
+				info.hp = *(float*)(message + 9);
+				info.maxHp = *(float*)(message + 13);
+				info.durability = *(float*)(message + 17);
+				info.maxDurability = *(float*)(message + 21);
+                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 3: // receive tooltip uiml
+	{
+		int slotId = *(int*)(message + 1);
+		if (slotId == requestetTooltipSlot)
+		{
+			short len = *(short*)(message + 5);
+			char* uiml = new char[len + 1];
+			memcpy(uiml, message + 7, len);
+			uiml[len] = 0;
+			UIMLToolTip* tip = new UIMLToolTip();
+			tip->setUIML(uiml);
+			setToolTipZ(tip);
+			delete[] uiml;
+			currentTooltipSlot = slotId;
+			requestetTooltipSlot = -1;
+		}
+		break;
+	}
+	case 100: // set crafting result
+	{
+		Array<SlotInfo>* outputs = new Array<SlotInfo>();
+		int count = *(int*)(++message);
+		for (int i = 0; i < count; i++)
+		{
+			SlotInfo info;
+			info.id = i;
+			info.itemCount = *(int*)(message += 4);
+			if (info.itemCount > 0)
+			{
+				info.hp = *(float*)(message += 4);
+				info.maxHp = *(float*)(message += 4);
+				info.durability = *(float*)(message += 4);
+				info.maxDurability = *(float*)(message += 4);
+                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+			}
+			outputs->add(info);
+		}
+		postAction([this, outputs]()
+			{
+				if (this->outputs)
+					this->outputs->release();
+				this->outputs = outputs;
+			});
+		break;
+	}
+	}
+}
+
+bool CraftingGridView::tick(double tickVal)
+{
+	return ZeichnungHintergrund::tick(tickVal);
+}
+
+void CraftingGridView::render(Bild& rObj)
+{
+	ZeichnungHintergrund::render(rObj);
+	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
+		return;
+	int numRows = 1;
+	if (slots)
+	{
+		int x = 0;
+		int y = 0;
+		int rowCount = 0;
+		int index = 0;
+		for (SlotInfo info : *slots)
+		{
+			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+			x += 60;
+			if (++rowCount >= rowSize)
+			{
+				y += 60;
+				x = 0;
+				rowCount = 0;
+				if (index < slots->getEintragAnzahl() - 1)
+					numRows++;
+			}
+			index++;
+		}
+	}
+	craft->render(rObj);
+	rObj.fillRegion(rowSize * 60, gr.y / 2 - 5, 25, 10, 0xFF52525E);
+	rObj.drawDreieck(Punkt(rowSize * 60 + 25, gr.y / 2 - 15), Punkt(rowSize * 60 + 40, gr.y / 2), Punkt(rowSize * 60 + 25, gr.y / 2 + 15), 0xFF52525E);
+	if (outputs)
+	{
+		int x = rowSize * 60 + 50;
+		int y = 0;
+		int colCount = 0;
+		for (SlotInfo info : *outputs)
+		{
+			info.render(x, y, rObj, dragStartId == info.id, dragStopId == info.id);
+			y += 60;
+			if (++colCount >= numRows)
+			{
+				x += 60;
+				y = 0;
+				colCount = 0;
+			}
+		}
+	}
+	rObj.releaseDrawOptions();
+}
+
+void CraftingGridView::doMausEreignis(MausEreignis& me, bool userRet)
+{
+	if (!slots)
+		return;
+	if (me.id == ME_Bewegung)
+	{
+		if (getSlotByLocalPos(Punkt(me.mx, me.my)) != currentTooltipSlot)
+		{
+			setToolTipZ(0);
+			currentTooltipSlot = -1;
+		}
+	}
+	craft->doPublicMausEreignis(me);
+	DragController<InventoryDragSource, int>* controller = ((Game*)(Menu*)menuRegister->get("game"))->zInventoryDragController();
+	int x = 0;
+	int y = 0;
+	int rowCount = 0;
+	int slot = 0;
+	dragStopId = -1;
+	for (SlotInfo info : *slots)
+	{
+		if (me.mx >= x && me.mx < x + 50 && me.my >= y && me.my < y + 50)
+		{
+			if (me.id == ME_RLinks)
+			{
+				if (!controller->getCurrentDragContainer() && info.itemCount > 0)
+				{
+					controller->beginDrag(this, info.id, info.zItem, [this]()
+						{
+							dragStartId = -1;
+						});
+					dragStartId = info.id;
+				}
+				else if (controller->getCurrentDragContainer())
+				{
+					// request to transfer items from source to target slot
+					Framework::Either<int, Framework::VecN<int, 4>> source = controller->getCurrentDragContainer()->getInventoryTarget();
+					int len = 2 + (source.isA() ? 4 : 16) + 5 + (target.isA() ? 4 : 16) + 4;
+					char* msg = new char[len];
+					int index = 0;
+					msg[index++] = 6;
+					msg[index++] = (char)source.isA();
+					if (source.isA())
+					{
+						*(int*)(msg + index) = source.getA();
+						index += 4;
+					}
+					else
+					{
+						*(int*)(msg + index) = source.getB()[0];
+						*(int*)(msg + index + 4) = source.getB()[1];
+						*(int*)(msg + index + 8) = source.getB()[2];
+						*(int*)(msg + index + 12) = source.getB()[3];
+						index += 16;
+					}
+					*(int*)(msg + index) = controller->getCurrentDaragElement();
+					index += 4;
+					msg[index++] = target.isA();
+					if (target.isA())
+					{
+						*(int*)(msg + index) = target.getA();
+						index += 4;
+					}
+					else
+					{
+						*(int*)(msg + index) = target.getB()[0];
+						*(int*)(msg + index + 4) = target.getB()[1];
+						*(int*)(msg + index + 8) = target.getB()[2];
+						*(int*)(msg + index + 12) = target.getB()[3];
+						index += 16;
+					}
+					*(int*)(msg + index) = info.id;
+					World::INSTANCE->zClient()->sendPlayerAction(msg, len);
+					delete[] msg;
+				}
+			}
+			else
+			{
+				if (controller->getCurrentDragContainer() && (controller->getCurrentDragContainer() != this || controller->getCurrentDaragElement() != info.id))
+				{
+					dragStopId = info.id;
+				}
+			}
+			break;
+		}
+		x += 60;
+		if (++rowCount >= rowSize)
+		{
+			y += 60;
+			x = 0;
+			rowCount = 0;
+		}
+		slot++;
+	}
+	ZeichnungHintergrund::doMausEreignis(me, userRet);
+}
+
+Framework::Either<int, Framework::VecN<int, 4>> CraftingGridView::getInventoryTarget() const
+{
+	return target;
+}

+ 56 - 0
enc_temp_folder/eb39f2494bc1df93bab2e22e54d5/World.h

@@ -0,0 +1,56 @@
+#pragma once
+
+#include <Welt3D.h>
+#include <Bildschirm.h>
+#include <Kam3D.h>
+#include <Thread.h>
+
+#include "Dimension.h"
+#include "PlayerKam.h"
+#include "FactoryClient.h"
+
+class World : public Framework::Thread
+{
+public:
+	static World* INSTANCE;
+	
+private:
+	Dimension* currentDimension;
+	Framework::Welt3D* renderedWorld;
+	Framework::Bildschirm3D* zScreenPtr;
+	PlayerKam* kam;
+	bool firstMessage;
+	int ownEntityId;
+	Framework::Model3D* currentTarget;
+	Array<Punkt> subscriptions;
+	FactoryClient* client;
+	Critical subLock;
+	Critical targetLock;
+
+public:
+	World(Framework::Bildschirm3D* zScreen, FactoryClient* client);
+	~World();
+	void update(bool background);
+	void setChunk(Chunk* chunk);
+	void thread() override;
+
+	Block* zBlockAt(Framework::Vec3<int> location) const;
+	Block* getBlockAt(Framework::Vec3<int> location) const;
+	Dimension* zDimension() const;
+	void setVisibility(Chunk* zChunk, bool visible);
+	void setVisibility(Entity* zEntity, bool visible);
+	Framework::Punkt getChunkCenter(int x, int y) const;
+	Entity* zEntity(int id) const;
+	Entity* getEntity(int id) const;
+	void removeEntity(int id);
+	PlayerKam* zKamera() const;
+	int getCurrentPlayerId() const;
+	Entity* getCurrentPlayerEntity() const;
+	void setTarget(Framework::Model3D* zTarget);
+	void lockWorld();
+	void unlockWorld();
+	void onChunkAdded(Punkt pos);
+	Chunk* zChunk(Punkt center);
+	Framework::Model3D* getCurrentTarget() const;
+	FactoryClient* zClient() const;
+};

+ 47 - 0
enc_temp_folder/ef2be821964b97a79f24226c6ce03c60/Entity.h

@@ -0,0 +1,47 @@
+#pragma once
+
+#include <Model3D.h>
+#include <Either.h>
+#include <Critical.h>
+
+#include "EntityType.h"
+#include "Area.h"
+
+class Block;
+
+struct MovementFrame
+{
+	Framework::Vec3<float> direction;
+	Framework::Vec3<float> targetPosition;
+	int movementFlags;
+	double duration;
+};
+
+class Entity : public Framework::Model3D
+{
+private:
+	int id;
+	const EntityType* zType;
+	Framework::Critical cs;
+	bool playerControlled;
+	float maxMovementSpeed;
+	int lastFlags;
+	double timeSinceSync;
+	Framework::Vec3<float> lastDirection;
+	Framework::Array< MovementFrame > movements;
+	Framework::Vec3<float> speed;
+	MovementFrame currentFrame;
+
+public:
+	Entity(const EntityType* zType, Framework::Model3DData* model, Framework::Model3DTextur* texture, int id, Framework::Vec3<float> position, float maxMovementSpeed);
+	~Entity();
+
+	void api(char* message);
+	bool tick(double time) override;
+
+	int getId() const;
+	const EntityType* zEntityType() const;
+	void lock();
+	void unlock();
+	void setPlayerControlled();
+};

+ 165 - 0
enc_temp_folder/f68e3c78e417e9bed1beacfd7bb406b/ItemBar.cpp

@@ -0,0 +1,165 @@
+#include <XML.h>
+#include <Bild.h>
+
+#include "ItemBar.h"
+#include "Globals.h"
+
+using namespace Framework;
+
+ItemBarElement::ItemBarElement()
+	: UIMLElement()
+{}
+
+//! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig ist
+bool ItemBarElement::isApplicableFor(Framework::XML::Element& element)
+{
+	return element.getName().istGleich("itemBar");
+}
+
+//! erstellt eine neue Zeichnung zu einem gegebenen xml Element
+Framework::Zeichnung* ItemBarElement::parseElement(Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
+{
+	return new ItemBarView(element.getAttributeValue("id"), (int)element.getAttributeValue("rowSize"), (int)element.getAttributeValue("target"), element.getAttributeValue("slotNameFilter"));
+}
+
+//! wendet die layout parameter zu einer Zeichnung an
+void ItemBarElement::layout(Framework::XML::Element& element, Framework::Zeichnung& z, int pWidth, int pHeight, Framework::UIMLContainer& generalLayouter)
+{
+	UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
+}
+
+
+ItemBarView::ItemBarView(Framework::Text id, int rowSize, int targetEntity, Framework::Text slotNameFilter)
+	: ZeichnungHintergrund(),
+	id(id),
+	rowSize(rowSize),
+	targetEntity(targetEntity),
+	slotNameFilter(slotNameFilter),
+	slots(0),
+	leftHandPos(0)
+{
+	char* msg = new char[id.getLength() + slotNameFilter.getLength() + 3];
+	msg[0] = 0;
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+	memcpy(msg + 3 + id.getLength(), slotNameFilter.getText(), slotNameFilter.getLength());
+	World::INSTANCE->zClient()->inventoryAPIRequest(targetEntity, msg, id.getLength() + slotNameFilter.getLength() + 3);
+	delete[] msg;
+}
+
+ItemBarView::~ItemBarView()
+{
+	if (slots)
+		slots->release();
+	char* msg = new char[id.getLength() + 2];
+	msg[0] = 1;
+	msg[1] = (char)id.getLength();
+	memcpy(msg + 2, id.getText(), id.getLength());
+	msg[2 + id.getLength()] = (char)slotNameFilter.getLength();
+	World::INSTANCE->zClient()->inventoryAPIRequest(targetEntity, msg, id.getLength() + 2);
+	delete[] msg;
+}
+
+void ItemBarView::api(char* message)
+{
+	switch (message[0])
+	{
+	case 0:
+		// send inventory content
+	{
+		Array<SlotInfo>* slots = new Array<SlotInfo>();
+		int count = *(int*)(++message);
+		for (int i = 0; i < count; i++)
+		{
+			SlotInfo info;
+			info.id = *(int*)(message += 4);
+			info.itemCount = *(int*)(message += 4);
+			if (info.itemCount > 0)
+			{
+				info.hp = *(float*)(message += 4);
+				info.maxHp = *(float*)(message += 4);
+				info.durability = *(float*)(message += 4);
+				info.maxDurability = *(float*)(message += 4);
+                info.zItem = zItemType(*(int*)(message += 4))->zIcon();
+			}
+			slots->add(info);
+		}
+		postAction([this, slots]()
+			{
+				if (this->slots)
+					this->slots->release();
+				this->slots = slots;
+			});
+		break;
+	}
+	case 1: // set count of items
+	{
+		int id = *(int*)(message + 1);
+		int count = *(int*)(message + 5);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = count;
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 2: // add new stack
+	{
+		int id = *(int*)(message + 1);
+		for (int i = 0; i < slots->getEintragAnzahl(); i++)
+		{
+			if (slots->get(i).id == id)
+			{
+				SlotInfo info = slots->get(i);
+				info.itemCount = *(int*)(message + 5);
+				info.hp = *(float*)(message + 9);
+				info.maxHp = *(float*)(message + 13);
+				info.durability = *(float*)(message + 17);
+				info.maxDurability = *(float*)(message + 21);
+                info.zItem = zItemType(*(int*)(message + 25))->zIcon();
+				slots->set(info, i);
+				break;
+			}
+		}
+		break;
+	}
+	case 3: // set selected slot
+	{
+		leftHandPos = *(int*)(message + 1);
+		break;
+	}
+	}
+}
+
+void ItemBarView::render(Bild& rObj)
+{
+	ZeichnungHintergrund::render(rObj);
+	if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y))
+		return;
+	if (slots)
+	{
+		int x = 0;
+		int y = 0;
+		int rowCount = 0;
+		int index = 0;
+		for (SlotInfo info : *slots)
+		{
+			info.render(x, y, rObj, index == leftHandPos, index == (leftHandPos + 1) % slots->getEintragAnzahl());
+			x += 60;
+			if (++rowCount >= rowSize)
+			{
+				y += 60;
+				x = 0;
+				rowCount = 0;
+			}
+			index++;
+		}
+	}
+	rObj.releaseDrawOptions();
+}