Browse Source

fix linux build

Kolja Strohm 2 weeks ago
parent
commit
e643f29caf
19 changed files with 206 additions and 173 deletions
  1. 1 1
      AbstractElement.cpp
  2. 50 21
      Assembly.cpp
  3. 4 0
      Assembly.h
  4. 8 8
      Console.cpp
  5. 3 2
      File.cpp
  6. 12 4
      Framework Linux.vcxproj
  7. 2 2
      Framework.vcxproj
  8. 4 4
      Global.cpp
  9. 3 5
      Globals.h
  10. 8 13
      JsonEditor.cpp
  11. 4 0
      Logging.cpp
  12. 10 5
      Mat4.h
  13. 1 1
      Random.cpp
  14. 5 5
      Reader.cpp
  15. 36 47
      Text.cpp
  16. 35 41
      UIMLView.cpp
  17. 1 1
      Window.cpp
  18. 9 9
      World2D.cpp
  19. 10 4
      World3D.cpp

+ 1 - 1
AbstractElement.cpp

@@ -72,7 +72,7 @@ ElementPathBuilder::ElementPathBuilder()
 
 Framework::ElementPathBuilder::ElementPathBuilder(
     const ElementPathBuilder& other)
-    : path(dynamic_cast<RCArray<Text>*>(path->getThis()))
+    : path(dynamic_cast<RCArray<Text>*>(other.path->getThis()))
 {}
 
 ElementPathBuilder::~ElementPathBuilder()

+ 50 - 21
Assembly.cpp

@@ -2,6 +2,10 @@
 
 #include "InMemoryBuffer.h"
 
+#ifndef WIN32
+#    include <sys/mman.h>
+#endif
+
 enum OperandSizeOverwrite
 {
     NO_PREFIX = 0,
@@ -244,13 +248,12 @@ public:
         char vexPP,
         char rmReg)
         : numArgs(0),
-          rexW(rexW),
-          rmReg(rmReg),
-          opcodeLength(opcodeLength),
-          operandSizeOverride(operandSizeOverride),
           vex(vex),
           vexL(vexL),
           vexPP(vexPP),
+          rexW(rexW),
+          rmReg(rmReg),
+          opcodeLength(opcodeLength),
           op1Encoding(UNDEFINED),
           op2Encoding(UNDEFINED),
           op3Encoding(UNDEFINED),
@@ -258,7 +261,8 @@ public:
           op1RW(NONE),
           op2RW(NONE),
           op3RW(NONE),
-          op4RW(NONE)
+          op4RW(NONE),
+          operandSizeOverride(operandSizeOverride)
     {
         this->opcode[0] = (char)(opcode & 0xFF);
         this->opcode[1] = (char)((opcode >> 8) & 0xFF);
@@ -764,7 +768,7 @@ public:
         memcpy(result.opcode, entry->opcode, 3);
         result.opcodeLength = entry->opcodeLength;
         result.operandSizeOverride = entry->operandSizeOverride;
-        for (int i = 0; i < args.size(); i++)
+        for (int i = 0; i < (int)args.size(); i++)
         {
             OperandEncoding encoding = UNDEFINED;
             switch (i)
@@ -808,6 +812,8 @@ public:
             case IMM64:
                 encodeIMM64(result, args[i], i + 1, err);
                 break;
+            default:
+                break;
             }
         }
         if (result.errIfNoRex && !result.needsRex)
@@ -997,7 +1003,7 @@ public:
             result.needsRex = true;
             result.exB = 1;
         }
-        result.modRM |= 0b11 << 6; // direct register access
+        result.modRM |= (char)(0b11 << 6); // direct register access
         if (arg->getPart() == Framework::Assembly::GPRegisterPart::HIGHER8)
         {
             if (reg == Framework::Assembly::RAX)
@@ -1053,7 +1059,7 @@ public:
             result.needsRex = true;
             result.exB = 1;
         }
-        result.modRM |= 0b11 << 6; // direct register access
+        result.modRM |= (char)(0b11 << 6); // direct register access
         result.modRM |= reg & 0b111;
     }
 
@@ -1121,7 +1127,7 @@ public:
                 }
                 else
                 {
-                    result.modRM |= 0b10 << 6; // 32 bit displacement
+                    result.modRM |= (char)(0b10 << 6); // 32 bit displacement
                     memcpy(result.disp, &offset, 4);
                 }
             }
@@ -1520,8 +1526,8 @@ isGPRegisterOrMemoryAccess(Framework::Assembly::MemoryBlockSize size)
 {
     return [size](const Framework::Assembly::OperationArgument& arg) {
         return isGPRegister(size)(arg)
-            || arg.asMemoryAccessArgument()
-                   && arg.asMemoryAccessArgument()->getBlockSize() == size;
+            || (arg.asMemoryAccessArgument()
+                && arg.asMemoryAccessArgument()->getBlockSize() == size);
     };
 }
 
@@ -7365,14 +7371,22 @@ Framework::Assembly::Instruction::getArguments() const
 Framework::Assembly::AssemblyBlock::AssemblyBlock()
     : inlineIndex(0),
       compiledCode(0)
+#ifndef WIN32
+      ,
+      compiledSize(0)
+#endif
 {}
 
 Framework::Assembly::AssemblyBlock::~AssemblyBlock()
 {
     if (compiledCode != 0)
     {
-        // Free the compiled code memory
+// Free the compiled code memory
+#ifdef WIN32
         VirtualFree(compiledCode, 0, MEM_RELEASE);
+#else
+        munmap(compiledCode, compiledSize);
+#endif
     }
 }
 
@@ -7593,6 +7607,8 @@ void Framework::Assembly::AssemblyBlock::addCompare(
     case SINGLE_DOUBLE:
         op = COMISD;
         break;
+    default:
+        break;
     }
     if (op != NOP)
     {
@@ -7924,9 +7940,9 @@ void Framework::Assembly::AssemblyBlock::addPop(
 void Framework::Assembly::AssemblyBlock::addPush(
     FPRegister reg, FPDataType type, FPRegisterPart part)
 {
-    MemoryBlockSize size;
-    int bytes;
-    Operation moveOp;
+    MemoryBlockSize size = MemoryBlockSize::BYTE;
+    int bytes = 0;
+    Operation moveOp = NOP;
     switch (type)
     {
     case SINGLE_DOUBLE:
@@ -7969,9 +7985,9 @@ void Framework::Assembly::AssemblyBlock::addPop(
     FPDataType type,
     FPRegisterPart part)
 {
-    MemoryBlockSize size;
-    int bytes;
-    Operation moveOp;
+    MemoryBlockSize size = MemoryBlockSize::BYTE;
+    int bytes = 0;
+    Operation moveOp = NOP;
     switch (type)
     {
     case SINGLE_DOUBLE:
@@ -8322,7 +8338,6 @@ void* Framework::Assembly::AssemblyBlock::compile()
         return compiledCode;
     }
     InMemoryBuffer buffer;
-    int index = 0;
     // check non-volatile registers
     RCArray<Instruction> restoreInstructions;
     for (GPRegister nvReg : {RBX, RBP, RSI, RDI, R12, R13, R14, R15})
@@ -8400,15 +8415,29 @@ void* Framework::Assembly::AssemblyBlock::compile()
     Instruction retInstr(RET, {});
     retInstr.compile(&buffer, this);
     int totalSize = (int)buffer.getSize();
-    // Allocate executable memory
+// Allocate executable memory
+#ifdef WIN32
     compiledCode = VirtualAlloc(nullptr, totalSize, MEM_COMMIT, PAGE_READWRITE);
+#else
+    compiledSize = totalSize;
+    compiledCode = mmap(nullptr,
+        compiledSize,
+        PROT_READ | PROT_WRITE,
+        MAP_PRIVATE | MAP_ANONYMOUS,
+        -1,
+        0);
+#endif
     if (compiledCode == nullptr)
     {
         throw std::runtime_error("Failed to allocate executable memory.");
     }
     // Write the compiled code into the allocated memory
     buffer.read((char*)compiledCode, totalSize);
-    DWORD dummy;
+#ifdef WIN32
+    unsigned long dummy;
     VirtualProtect(compiledCode, totalSize, PAGE_EXECUTE_READ, &dummy);
+#else
+    mprotect(compiledCode, compiledSize, PROT_READ | PROT_EXEC);
+#endif
     return compiledCode;
 }

+ 4 - 0
Assembly.h

@@ -355,6 +355,7 @@ namespace Framework
         private:
 
         public:
+            DLLEXPORT virtual ~OperationArgument() = default;
             /**
              * checks if a register is used in this argument.
              *
@@ -691,6 +692,9 @@ namespace Framework
             RCArray<Instruction> instructions;
             int inlineIndex;
             void* compiledCode;
+#ifndef WIN32
+            int compiledSize;
+#endif
 
         public:
             DLLEXPORT AssemblyBlock();

+ 8 - 8
Console.cpp

@@ -3,6 +3,7 @@
 #include <iostream>
 
 #ifndef WIN32
+#    include <sys/ioctl.h>
 #    include <termios.h>
 #    include <unistd.h>
 #endif
@@ -416,8 +417,8 @@ int Framework::ConsoleProgressBar::print() const
 Framework::InputLine::InputLine()
     : StickyConsoleContent(),
       Thread(),
-      input(""),
       cursorPos(0),
+      input(""),
       suggestions(0)
 {}
 
@@ -717,19 +718,18 @@ void Framework::InputLine::applyAutocompletion()
              = lastArgFinished
                  ? 0
                  : (params.getEntryCount() > 0
-                         ? params.z(params.getEntryCount() - 1)->getLength()
-                         : name->getLength());
-             true;
-             i++)
+                           ? params.z(params.getEntryCount() - 1)->getLength()
+                           : name->getLength());
+            true;
+            i++)
         {
             if (i >= this->suggestions->getItems().z(0)->getLength())
             {
                 commonChar = false;
                 break;
             }
-            for (int j = 1;
-                 j < this->suggestions->getItems().getEntryCount();
-                 j++)
+            for (int j = 1; j < this->suggestions->getItems().getEntryCount();
+                j++)
             {
                 if (i >= this->suggestions->getItems().z(j)->getLength())
                 {

+ 3 - 2
File.cpp

@@ -334,7 +334,8 @@ bool File::setNextBit(bool bit) // write file bit by bit
 {
     if (!pfad || !stream) return 0;
     tmpWriteBPos++;
-    tmpWriteByte |= (char)(((char)bit << (7 - tmpWriteBPos)) & (1 << (7 - tmpWriteBPos)));
+    tmpWriteByte |= (char)(((char)bit << (7 - tmpWriteBPos))
+                           & (1 << (7 - tmpWriteBPos)));
     if (tmpWriteBPos == 7)
     {
         tmpWriteBPos = -1;
@@ -726,7 +727,7 @@ bool Framework::FileRemove(const char* pfad) // Deletes the specified file
         {
             Text* pf = new Text(pfa.getText());
             if (pf->getText()[pf->getLength() - 1] != '/') pf->append("/");
-            pf->append(liste->get(i));
+            pf->append(*liste->z(i));
             if (ret)
                 ret = FileRemove(pf);
             else

+ 12 - 4
Framework Linux.vcxproj

@@ -109,10 +109,13 @@
     <TargetExt>.so</TargetExt>
   </PropertyGroup>
   <ItemGroup>
+    <ClCompile Include="AbstractElement.cpp" />
     <ClCompile Include="AlphaField.cpp" />
     <ClCompile Include="Animation.cpp" />
     <ClCompile Include="Animation3D.cpp" />
+    <ClCompile Include="Assembly.cpp" />
     <ClCompile Include="AsynchronCall.cpp" />
+    <ClCompile Include="DataValidator.cpp" />
     <ClCompile Include="SelectionBox.cpp" />
     <ClCompile Include="Base64.cpp" />
     <ClCompile Include="Image.cpp" />
@@ -126,6 +129,7 @@
     <ClCompile Include="DLLRegister.cpp" />
     <ClCompile Include="DXBuffer.cpp" />
     <ClCompile Include="Errors.cpp" />
+    <ClCompile Include="Timer.cpp" />
     <ClCompile Include="Window.cpp" />
     <ClCompile Include="Progress.cpp" />
     <ClCompile Include="Global.cpp" />
@@ -153,7 +157,10 @@
     <ClCompile Include="Point.cpp" />
     <ClCompile Include="Border.cpp" />
     <ClCompile Include="Random.cpp" />
+    <ClInclude Include="AbstractElement.h" />
+    <ClInclude Include="Assembly.h" />
     <ClInclude Include="Console.h" />
+    <ClInclude Include="DataValidator.h" />
     <ClInclude Include="Iterator.h" />
     <ClInclude Include="JsonEditor.h" />
     <ClInclude Include="Logging.h" />
@@ -181,7 +188,6 @@
     <ClCompile Include="XML.cpp" />
     <ClCompile Include="Drawing.cpp" />
     <ClCompile Include="Drawing3D.cpp" />
-    <ClCompile Include="Time.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlphaField.h" />
@@ -202,6 +208,8 @@
     <ClInclude Include="FileSystem.h" />
     <ClInclude Include="Diagram.h" />
     <ClInclude Include="DLLRegister.h" />
+    <ClInclude Include="Stack.h" />
+    <ClInclude Include="Timer.h" />
     <ClInclude Include="TriangleList.h" />
     <ClInclude Include="DXBuffer.h" />
     <ClInclude Include="Plane3D.h" />
@@ -270,7 +278,6 @@
     <ClInclude Include="XML.h" />
     <ClInclude Include="Drawing.h" />
     <ClInclude Include="Drawing3D.h" />
-    <ClInclude Include="Time.h" />
   </ItemGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
@@ -278,7 +285,7 @@
       <AdditionalOptions>-fPIC -Wno-unknown-pragmas</AdditionalOptions>
       <PositionIndependentCode>true</PositionIndependentCode>
       <ObjectFileName>%(filename).o</ObjectFileName>
-      <CppLanguageStandard>c++20</CppLanguageStandard>
+      <CppLanguageStandard>c++23</CppLanguageStandard>
     </ClCompile>
     <Link>
       <AdditionalDependencies>$(StlAdditionalDependencies)</AdditionalDependencies>
@@ -302,7 +309,8 @@
     </Link>
     <ClCompile>
       <AdditionalOptions>-fPIC -Wno-unknown-pragmas</AdditionalOptions>
-      <CppLanguageStandard>c++20</CppLanguageStandard>
+      <CppLanguageStandard>c++23</CppLanguageStandard>
+      <ObjectFileName>%(filename).o</ObjectFileName>
     </ClCompile>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 2 - 2
Framework.vcxproj

@@ -121,7 +121,7 @@
       <PreprocessorDefinitions>_WIN32;WIN32;_DEBUG;_WINDOWS;_USRDLL;FRAMEWORK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <BrowseInformation>true</BrowseInformation>
-      <LanguageStandard>stdcpplatest</LanguageStandard>
+      <LanguageStandard>stdcpp23</LanguageStandard>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -179,7 +179,7 @@ copy "Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x32\framework.dll
       <PreprocessorDefinitions>_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;FRAMEWORK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <BrowseInformation>true</BrowseInformation>
-      <LanguageStandard>stdcpp20</LanguageStandard>
+      <LanguageStandard>stdcpp23</LanguageStandard>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>

+ 4 - 4
Global.cpp

@@ -4,21 +4,21 @@
 #    include <objidl.h>
 #endif
 
-#include "File.h"
 #include "DLLRegister.h"
-#include "Window.h"
+#include "File.h"
 #include "Globals.h"
 #include "Logging.h"
 #include "Model3DList.h"
 #include "TextureList.h"
 #include "Thread.h"
-#include "Time.h"
+#include "Timer.h"
+#include "Window.h"
 
 #ifdef WIN32
 #    include <GdiPlus.h>
 #    pragma comment(lib, "gdiplus.lib")
-#    include "Window.h"
 #    include "Mouse.h"
+#    include "Window.h"
 #endif
 
 void Framework::initFramework(HINSTANCE__* hInst)

+ 3 - 5
Globals.h

@@ -6,6 +6,7 @@
 
 #ifdef WIN32
 #    include "Mouse.h"
+#    include "Window.h"
 #endif
 
 #ifndef Global
@@ -19,8 +20,8 @@ namespace Framework
     class ThreadRegister; //! Thread.h
     class Thread;         //! Thread.h
     class Model3DList;    //! Model3DList.h
-    class TextureList;     //! TextureList.h
-    class File;          //! File.h
+    class TextureList;    //! TextureList.h
+    class File;           //! File.h
     class DLLRegister;    //! DLLRegister.h
 
     namespace Logging
@@ -29,9 +30,6 @@ namespace Framework
     }
 
 #ifdef WIN32
-    class Mouse;          //! Mouse.h
-    class NativeWindowArray; //! Window.h
-
     Global NativeWindowArray nativeWindows;
     Global bool MouseTrack;
     Global Mouse mousePointer;

+ 8 - 13
JsonEditor.cpp

@@ -1,11 +1,11 @@
 #include "JsonEditor.h"
 
-#include "Image.h"
+#include "Font.h"
 #include "Globals.h"
+#include "Image.h"
+#include "KeyboardEvent.h"
 #include "MouseEvent.h"
 #include "Regex.h"
-#include "Font.h"
-#include "KeyboardEvent.h"
 #include "TextField.h"
 
 using namespace Framework;
@@ -475,9 +475,9 @@ bool Framework::JSON::ParserState::next(
 EditableJsonElement::EditableJsonElement(Regex::Automata<char>* valueValidator)
     : ReferenceCounter(),
       content(),
-      valueValidator(valueValidator),
       valueStart(-1),
       keyStart(-1),
+      valueValidator(valueValidator),
       newLineCount(0)
 {
     children = 0;
@@ -2611,7 +2611,6 @@ void Framework::JSON::JsonEditor::doKeyboardEvent(KeyboardEvent& te)
                 {
                     selectionStart = {content, 0};
                     EditableJsonElement* element = content;
-                    bool first = true;
                     while (element->zMextSibling())
                     {
                         element = element->zMextSibling();
@@ -2683,8 +2682,7 @@ void Framework::JSON::JsonEditor::render(Image& rObj)
     errorDescription->removeStyle(TextField::Style::Visible);
     DrawableBackground::render(rObj);
     if (textRenderer->zFont() && content
-        && rObj.setDrawOptions(
-            pos + Point(getBorderWidth(), getBorderWidth()),
+        && rObj.setDrawOptions(pos + Point(getBorderWidth(), getBorderWidth()),
             Point(getInnerWidth(), getInnerHeight())))
     {
         if (!renderStart.line)
@@ -2897,10 +2895,8 @@ void Framework::JSON::JsonEditor::render(Image& rObj)
             {
                 if (pressed && pressedPos.x >= lineNumberWidth + 10
                     && pressedPos.x <= lineNumberWidth + 16
-                    && pressedPos.y
-                           >= y + textRenderer->getFontSize() / 2 - 4
-                    && pressedPos.y
-                           <= y + textRenderer->getFontSize() / 2 + 2)
+                    && pressedPos.y >= y + textRenderer->getFontSize() / 2 - 4
+                    && pressedPos.y <= y + textRenderer->getFontSize() / 2 + 2)
                 {
                     pressed = false;
                     current->setHidden(!current->isHidden());
@@ -3036,8 +3032,7 @@ void Framework::JSON::JsonEditor::render(Image& rObj)
         EditableJsonElement* resnderStopElement = current;
         renderStopLine = line;
         textRenderer->renderText(5,
-            y + textRenderer->getRowHeight()
-                + textRenderer->getLineSpacing(),
+            y + textRenderer->getRowHeight() + textRenderer->getLineSpacing(),
             Text("FPS: ") + Text(tps),
             rObj,
             0xFFFFFFFF);

+ 4 - 0
Logging.cpp

@@ -573,8 +573,12 @@ Framework::Logging::OutputDebugStringLoggingChannel::
 void Framework::Logging::OutputDebugStringLoggingChannel::writeMessage(
     const Text& msg) const
 {
+#ifdef WIN32
     OutputDebugStringA(msg.getText());
     OutputDebugStringA("\n");
+#else
+    std::cout << msg.getText() << std::endl;
+#endif
 }
 
 Framework::Logging::ConsoleHandlerLoggingChannel::ConsoleHandlerLoggingChannel(

+ 10 - 5
Mat4.h

@@ -13,13 +13,17 @@ namespace Framework
     class Mat4
     {
     public:
-        T elements[4][4]; //! The elements of the matrix
+        union
+        {
+            T elements[4][4];  //! The elements of the matrix
+            T allElements[16]; //! The elements of the matrix as a single array
+        };
 
         //! Copies all values from another matrix
         //! \param r The other matrix
         Mat4& operator=(const Mat4& r)
         {
-            memcpy(elements, r.elements, sizeof(elements));
+            memcpy(allElements, r.allElements, sizeof(allElements));
             return *this;
         }
 
@@ -27,7 +31,7 @@ namespace Framework
         //! \param r The factor
         Mat4& operator*=(const T r)
         {
-            for (T& e : elements)
+            for (T& e : allElements)
                 e *= r;
             return *this;
         }
@@ -377,8 +381,9 @@ namespace Framework
         //! \param openingAngle The opening angle of the camera in radians
         //! \param bildschirmXY The aspect ratio of the rectangle on the
         //! screen to draw in. (Width / Height) \param
-        //! minz The minimum distance to the camera from which drawing begins \param
-        //! maxZ The maximum distance to the camera beyond which drawing stops
+        //! minz The minimum distance to the camera from which drawing begins
+        //! \param maxZ The maximum distance to the camera beyond which drawing
+        //! stops
         static Mat4 projektion(
             float openingAngle, float bildschirmXY, float minZ, float maxZ)
         {

+ 1 - 1
Random.cpp

@@ -2,7 +2,7 @@
 
 #include <iostream>
 
-#include "Time.h"
+#include "Timer.h"
 
 using namespace Framework;
 

+ 5 - 5
Reader.cpp

@@ -28,8 +28,8 @@ ByteArrayReader::~ByteArrayReader()
 void ByteArrayReader::read(char* bytes, int len)
 {
     if (position < length)
-        memcpy(bytes, buffer + position, min(len, length - position));
-    position = min(position + len, length);
+        memcpy(bytes, buffer + position, MIN(len, length - position));
+    position = MIN(position + len, length);
 }
 
 //! Reads the next line of the resource
@@ -55,11 +55,11 @@ bool ByteArrayReader::isEnd() const
 
 //! Sets the position of the byte to be read next
 //! \param pos The index of the byte
-//! \param ende 1 if the index counts from the end of the resource. 0 if the index
-//! counts from the beginning of the resource
+//! \param ende 1 if the index counts from the end of the resource. 0 if the
+//! index counts from the beginning of the resource
 void ByteArrayReader::setReadPosition(__int64 pos, bool ende)
 {
-    position = ende ? max(length - (int)pos, 0) : min((int)pos, length);
+    position = ende ? MAX(length - (int)pos, 0) : MIN((int)pos, length);
 }
 
 //! Returns the index of the byte from the resource that would be read next

+ 36 - 47
Text.cpp

@@ -189,8 +189,8 @@ void Text::toLowerCase()
 
 // non-constant
 void Text::setSuchGrenzen(
-char gBeg, char gEnd) // for every search function, does not search between
-                      // the characters gBeg and gEnd
+    char gBeg, char gEnd) // for every search function, does not search between
+                          // the characters gBeg and gEnd
 {
     suchGBeg = gBeg;
     suchGEnd = gEnd;
@@ -243,7 +243,7 @@ void Text::appendHex(char num) // appends the number in hex to the text
     stream << std::setfill('0') << std::setw((int)sizeof(char) * 2) << std::hex
            << (int)num;
     std::string str = stream.str();
-    for (int i = length; i < length + sizeof(char) * 2; ++i)
+    for (int i = length; i < length + (int)sizeof(char) * 2; ++i)
         res[i] = str.c_str()[i - length];
     res[length + sizeof(char) * 2] = 0;
     setTextZ(res, length + sizeof(char) * 2);
@@ -258,7 +258,7 @@ void Framework::Text::appendHex(short num)
     stream << std::setfill('0') << std::setw((int)sizeof(short) * 2) << std::hex
            << num;
     std::string str = stream.str();
-    for (int i = length; i < length + sizeof(short) * 2; ++i)
+    for (int i = length; i < length + (int)sizeof(short) * 2; ++i)
         res[i] = str.c_str()[i - length];
     res[length + sizeof(short) * 2] = 0;
     setTextZ(res, length + sizeof(short) * 2);
@@ -273,7 +273,7 @@ void Text::appendHex(int num) // appends the number in hex to the text
     stream << std::setfill('0') << std::setw((int)sizeof(int) * 2) << std::hex
            << num;
     std::string str = stream.str();
-    for (int i = length; i < length + sizeof(int) * 2; ++i)
+    for (int i = length; i < length + (int)sizeof(int) * 2; ++i)
         res[i] = str.c_str()[i - length];
     res[length + sizeof(int) * 2] = 0;
     setTextZ(res, length + sizeof(int) * 2);
@@ -288,7 +288,7 @@ void Text::appendHex(__int64 num) // appends the number in hex to the text
     stream << std::setfill('0') << std::setw((int)sizeof(__int64) * 2)
            << std::hex << num;
     std::string str = stream.str();
-    for (int i = length; i < length + sizeof(__int64) * 2; ++i)
+    for (int i = length; i < length + (int)sizeof(__int64) * 2; ++i)
         res[i] = str.c_str()[i - length];
     res[length + sizeof(__int64) * 2] = 0;
     setTextZ(res, length + sizeof(__int64) * 2);
@@ -500,8 +500,7 @@ void Framework::Text::regexReplace(const char* regex,
     matcher->release();
 }
 
-void Text::replace(
-    int p1, int p2, const char* t) // replaces text from p1 to p2
+void Text::replace(int p1, int p2, const char* t) // replaces text from p1 to p2
 {
     replace(p1, p2, t, textLength(t)); // replace text
 }
@@ -575,9 +574,8 @@ void Framework::Text::replace(
         end[i] = begin[i] + len1;
         searchStart = end[i];
     }
-    int resl
-        = (length - (anz * len1)) + (anz * len2) + 1; // length of result
-    char* res = new char[resl];                       // create new text
+    int resl = (length - (anz * len1)) + (anz * len2) + 1; // length of result
+    char* res = new char[resl];                            // create new text
     int rep = 0;              // stores which t1 we are at
     int last = 0;             // fill position in txt
     int neu = 0;              // fill position in res
@@ -625,8 +623,7 @@ void Text::replace(const Text& t1, const Text& t2)
 
 void Text::replace(int index, char c1, char c2) // replaces the i-th c1 with c2
 {
-    if (c1 == '\0' || c2 == '\0'
-        || index < 0) // check for invalid argument
+    if (c1 == '\0' || c2 == '\0' || index < 0) // check for invalid argument
         return;
     if (!has(c1)) // check if c1 exists
         return;
@@ -646,13 +643,12 @@ void Text::replace(int index,
 void Framework::Text::replace(
     int index, const char* t1, int len1, const char* t2, int len2)
 {
-    if (len1 >= length || len1 <= 0
-        || index < 0) // check for invalid argument
+    if (len1 >= length || len1 <= 0 || index < 0) // check for invalid argument
         return;
     if (!has(t1)) // check if t1 exists
         return;
     int anz = countOf(t1, len1); // count of t1 in text
-    if (index >= anz)              // check if an i-th t1 exists
+    if (index >= anz)            // check if an i-th t1 exists
         return;
     int begin = positionOf(index, len1, t1);
     int end = begin + len1;
@@ -676,7 +672,7 @@ void Text::replace(int i, const Text& t1, const Text& t2)
 }
 
 void Text::fillText(
-char c, int len) // sets the text to as many c as len is large
+    char c, int len) // sets the text to as many c as len is large
 {
     char* res = new char[(__int64)len + 1];
     for (int i = 0; i < len; ++i)
@@ -722,7 +718,7 @@ void Text::remove(char c) // deletes every c
 {
     if (!has(c)) // check if c exists
         return;
-    int anz = countOf(c);                          // count of c
+    int anz = countOf(c);                            // count of c
     char* res = new char[(__int64)length - anz + 1]; // create new text
     int anz2 = 0;
     int suchGCount = 0;
@@ -790,7 +786,7 @@ void Text::remove(int index, char c)
     if (index < 0 || !has(c)) // check for invalid argument
         return;
     int anz = countOf(c); // count of c's
-    if (index >= anz)       // check if an i-th c exists
+    if (index >= anz)     // check if an i-th c exists
         return;
     int pos = positionOf(c, index); // position of the i-th c
     if (pos < 0) return;
@@ -811,11 +807,10 @@ void Text::remove(int index, const char* t) // deletes the i-th t
 
 void Framework::Text::remove(int index, const char* t, int len)
 {
-    if (index < 0 || !has(t, len)
-        || len <= 0) // check for invalid argument
+    if (index < 0 || !has(t, len) || len <= 0) // check for invalid argument
         return;
     int anz = countOf(t, len); // count of t's
-    if (index >= anz)            // check if an i-th t exists
+    if (index >= anz)          // check if an i-th t exists
         return;
     int pos = positionOf(index, len, t); // position of the i-th t
     if (pos < 0) return;
@@ -866,8 +861,7 @@ int Text::removeWhitespaceBefore(int pos)
     return length;
 }
 
-void Text::setPrecision(
-int p) // sets the number of decimal places for doubles
+void Text::setPrecision(int p) // sets the number of decimal places for doubles
 {
     precision = p;
 }
@@ -1066,8 +1060,7 @@ bool Text::isEqual(const char* t) const // checks if the text equals t
     return isEqual(t, textLength(t)); // check text
 }
 
-bool Text::isEqual(
-    const char* t, int len) const // checks if the text equals t
+bool Text::isEqual(const char* t, int len) const // checks if the text equals t
 {
     if (length != len) // check for invalid argument
         return 0;
@@ -1113,8 +1106,7 @@ int Text::countOf(char c) const // returns the count of c in the text
     return ret;
 }
 
-int Text::countOf(
-    const char* t) const // returns the count of t in the text
+int Text::countOf(const char* t) const // returns the count of t in the text
 {
     return countOf(t, textLength(t)); // check text
 }
@@ -1169,8 +1161,7 @@ int Text::positionOf(char c) const // returns the position of the first c
     return -1;
 }
 
-int Text::positionOf(
-const char* t) const // returns the position of the first t
+int Text::positionOf(const char* t) const // returns the position of the first t
 {
     return positionOf(textLength(t), t);
 }
@@ -1182,8 +1173,7 @@ int Framework::Text::positionOf(int len, const char* t) const
 
 int Text::positionOf(int searchStart, const char* t, int len) const
 {
-    if (len <= 0
-        || len > length - searchStart) // check for invalid argument
+    if (len <= 0 || len > length - searchStart) // check for invalid argument
         return -1;
     int suchGCount = 0;
     for (int i = searchStart; i + len <= length; ++i) // search
@@ -1294,8 +1284,7 @@ int Text::positionOf(const Text& t, int i) const
     return positionOf(i, t.getLength(), t); // check text
 }
 
-Text* Text::getTeilText(
-    int p1, int p2) const // returns the text from p1 to p2
+Text* Text::getTeilText(int p1, int p2) const // returns the text from p1 to p2
 {
     if (p1 > p2) // swap p1 and p2
     {
@@ -1520,7 +1509,8 @@ TextReader::~TextReader()
 
 // Sets the position of the byte to be read next
 //  pos: The index of the byte
-//  ende: 1 if the index counts from the end of the text. 0 if from the beginning
+//  ende: 1 if the index counts from the end of the text. 0 if from the
+//  beginning
 void TextReader::setReadPosition(__int64 pos, bool ende)
 {
     int l = txt->getLength();
@@ -1578,9 +1568,9 @@ __int64 TextReader::getSize() const
 
 // char* operationen
 int Framework::stringPositionOfChar(const char* string,
-char c,
-int num) // finds the position of the num-th c
-         // in string, -1 if not found
+    char c,
+    int num) // finds the position of the num-th c
+             // in string, -1 if not found
 {
     int gef = 0;
     int p = 0;
@@ -1599,9 +1589,9 @@ int num) // finds the position of the num-th c
 }
 
 int Framework::stringPositionOfString(const char* string,
-char* suche,
-int sBegPos) // finds the position of 'suche' in 'string' starting at
-             // position 'sBegPos', -1 if not found
+    char* suche,
+    int sBegPos) // finds the position of 'suche' in 'string' starting at
+                 // position 'sBegPos', -1 if not found
 {
     for (int i = 0; i < sBegPos; ++i)
     {
@@ -1624,7 +1614,7 @@ int sBegPos) // finds the position of 'suche' in 'string' starting at
 
 //---Other Functions---
 void Framework::TextKopieren(
-const char* txt) // copies the text to the clipboard
+    const char* txt) // copies the text to the clipboard
 {
 #ifdef WIN32
     int laen = textLength(txt) + 1;
@@ -1640,8 +1630,7 @@ const char* txt) // copies the text to the clipboard
 #endif
 }
 
-const char*
-Framework::TextInsert() // returns the text from the clipboard
+const char* Framework::TextInsert() // returns the text from the clipboard
 {
 #ifdef WIN32
     if (!OpenClipboard(0)) return "";
@@ -1694,7 +1683,7 @@ char Framework::smallOrBig(char c, bool gr)
                 return ';';
             case '.':
                 return ':';
-            case 'ß':
+            case SpecialCharacters::SZ:
                 return '?';
             case '-':
                 return '_';
@@ -1772,7 +1761,7 @@ char Framework::smallOrBig(char c, bool gr)
 }
 
 bool Framework::isWritable(
-unsigned char zeichen) // checks if zeichen is a printable character
+    unsigned char zeichen) // checks if zeichen is a printable character
 {
     if (zeichen > 32 && zeichen < 127) return 1;
     if (zeichen == 128 || zeichen == 181 || zeichen == 178 || zeichen == 179)
@@ -1790,7 +1779,7 @@ unsigned char zeichen) // checks if zeichen is a printable character
 }
 
 unsigned int Framework::TextZuInt(
-const char* c, int system) // converts c to int
+    const char* c, int system) // converts c to int
 {
     if (system == 16) return (unsigned int)strtoul(c, 0, system);
     return (unsigned int)strtol(c, 0, system);

+ 35 - 41
UIMLView.cpp

@@ -1,15 +1,15 @@
 #include "UIMLView.h"
 
-#include "Image.h"
-#include "Screen.h"
-#include "Window.h"
-#include "Button.h"
 #include "Border.h"
-#include "RCPointer.h"
+#include "Button.h"
 #include "Font.h"
+#include "Image.h"
+#include "RCPointer.h"
+#include "Screen.h"
 #include "Scroll.h"
 #include "Table.h"
 #include "TextField.h"
+#include "Window.h"
 #include "XML.h"
 
 using namespace Framework;
@@ -456,8 +456,7 @@ void UIMLTextField::layout(XML::Element& element,
                 .isEqual("center"));
     if (element.hasAttribute("text-align-vertical"))
         z.setStyle(TextField::Style::VCenter,
-            element.getAttributeValue("text-align-vertical")
-                .isEqual("center"));
+            element.getAttributeValue("text-align-vertical").isEqual("center"));
     if (element.hasAttribute("disabled"))
         z.removeStyle(TextField::Style::Editable);
     if (element.getAttributeValue("vScroll").isEqual("auto"))
@@ -564,8 +563,7 @@ void UIMLCheck::layout(XML::Element& element,
 {
     ((CheckBox*)&z)->setText(element.getText());
     ((CheckBox*)&z)->setSText(element.getText());
-    z.setStyle(
-        CheckBox::Style::Selected, element.hasAttribute("selected"));
+    z.setStyle(CheckBox::Style::Selected, element.hasAttribute("selected"));
     if (element.hasAttribute("font-size"))
         ((CheckBox*)&z)
             ->setSSize(
@@ -648,8 +646,7 @@ void UIMLText::layout(XML::Element& element,
                 .isEqual("center"));
     if (element.hasAttribute("text-align-vertical"))
         z.setStyle(TextField::Style::VCenter,
-            element.getAttributeValue("text-align-vertical")
-                .isEqual("center"));
+            element.getAttributeValue("text-align-vertical").isEqual("center"));
     if (element.hasAttribute("disabled"))
         z.removeStyle(TextField::Style::Editable);
     if (element.getAttributeValue("vScroll").isEqual("auto"))
@@ -746,8 +743,7 @@ void UIMLTextArea::layout(XML::Element& element,
                 .isEqual("center"));
     if (element.hasAttribute("text-align-vertical"))
         z.setStyle(TextField::Style::VCenter,
-            element.getAttributeValue("text-align-vertical")
-                .isEqual("center"));
+            element.getAttributeValue("text-align-vertical").isEqual("center"));
     if (element.hasAttribute("font-size"))
         if (element.getAttributeValue("vScroll").isEqual("auto"))
         {
@@ -1080,7 +1076,7 @@ UIMLView::UIMLView()
     members = new RCTrie<Drawable>();
     dom = 0;
     nextId = 0;
-    memset(&init, 0, sizeof(UIInit));
+    memset((void*)&init, 0, sizeof(UIInit));
     addKnownElement(new UIMLTextField());
     addKnownElement(new UIMLButton());
     addKnownElement(new UIMLCheck());
@@ -1160,8 +1156,8 @@ void UIMLView::doMouseEvent(MouseEvent& me, bool userRet)
     }
 }
 
-void Framework::UIMLView::setOnMemberMouseEvent(std::function<bool(
-        XML::Element& element, Drawable& member, MouseEvent me)>
+void Framework::UIMLView::setOnMemberMouseEvent(
+    std::function<bool(XML::Element& element, Drawable& member, MouseEvent me)>
         onEventAction)
 {
     onMemberMouseEvent = onEventAction;
@@ -1512,38 +1508,36 @@ Drawable* UIMLView::parseElement(
         {
             if (hasStyle(Style::GlobalMouseEvent))
             {
-                z->addMouseEvent(
-                    [this, z](void* p, void* o, MouseEvent me) {
-                        return dom->selectChildren()
-                            .selectAllElements()
-                            .whereAttributeEquals("id", getDrawableId(*z))
-                            .getFirstElement()
-                            .map<bool>([this, &me, z](
-                                           RCPointer<XML::Element> element) {
+                z->addMouseEvent([this, z](void* p, void* o, MouseEvent me) {
+                    return dom->selectChildren()
+                        .selectAllElements()
+                        .whereAttributeEquals("id", getDrawableId(*z))
+                        .getFirstElement()
+                        .map<bool>(
+                            [this, &me, z](RCPointer<XML::Element> element) {
                                 return onMemberMouseEvent
                                          ? onMemberMouseEvent(*element, *z, me)
                                          : 0;
                             })
-                            .orElse(0);
-                    });
+                        .orElse(0);
+                });
             }
             if (hasStyle(Style::GlobalTastaturEvent))
             {
-                z->addKeyboardEvent(
-                    [this, z](void* p, void* o, KeyboardEvent te) {
-                        return dom->selectChildren()
-                            .selectAllElements()
-                            .whereAttributeEquals("id", getDrawableId(*z))
-                            .getFirstElement()
-                            .map<bool>([this, &te, z](
-                                           RCPointer<XML::Element> element) {
-                                return onMemberKeyboardEvent
-                                         ? onMemberKeyboardEvent(
-                                               *element, *z, te)
-                                         : 0;
-                            })
-                            .orElse(0);
-                    });
+                z->addKeyboardEvent([this, z](
+                                        void* p, void* o, KeyboardEvent te) {
+                    return dom->selectChildren()
+                        .selectAllElements()
+                        .whereAttributeEquals("id", getDrawableId(*z))
+                        .getFirstElement()
+                        .map<bool>([this, &te, z](
+                                       RCPointer<XML::Element> element) {
+                            return onMemberKeyboardEvent
+                                     ? onMemberKeyboardEvent(*element, *z, te)
+                                     : 0;
+                        })
+                        .orElse(0);
+                });
             }
             members->set(
                 id, id.getLength(), dynamic_cast<Drawable*>(z->getThis()));

+ 1 - 1
Window.cpp

@@ -17,7 +17,7 @@
 #include <iostream>
 
 #include "Logging.h"
-#include "Time.h"
+#include "Timer.h"
 
 using namespace Framework;
 #ifdef WIN32

+ 9 - 9
World2D.cpp

@@ -98,10 +98,10 @@ bool Object2D::handleCollision(Object2D* obj)
             = getSpeed()
             + getWorldDir(getObjectPos(hp).rotation(rSpeed) - getObjectPos(hp));
         // Velocity of the other object with rotation
-        Vertex v2
-            = obj->getSpeed()
-            + getWorldDir(obj->getObjectPos(hp).rotation(obj->getRotationSpeed())
-                          - obj->getObjectPos(hp));
+        Vertex v2 = obj->getSpeed()
+                  + getWorldDir(
+                      obj->getObjectPos(hp).rotation(obj->getRotationSpeed())
+                      - obj->getObjectPos(hp));
         if ((hp - obj->getPosition()).getLengthSq()
                 > (hp + v1 * 0.03f - obj->getPosition()).getLengthSq()
             || (hp - getPosition()).getLengthSq()
@@ -110,8 +110,8 @@ bool Object2D::handleCollision(Object2D* obj)
             float m1 = getMass() * v1.getLength();      // area of object 1
             float m2 = obj->getMass() * v2.getLength(); // area of object 2
             if (m1 == 0 || m2 == 0)
-                return 0; // if an object has no mass, ignore the
-                          // collision
+                return 0;               // if an object has no mass, ignore the
+                                        // collision
             float nm1 = m1 / (m1 + m2); // coefficient for object 2
             float nm2 = m2 / (m1 + m2); // coefficient for object 1
             // rSpeed *= nm1; // adjust rotation speed (object 1)
@@ -156,8 +156,8 @@ bool Object2D::tick(const WorldInfo& info, double zeit)
     {
         rSpeed -= rSpeed
                 - (rSpeed / (1 + info.airResistance * getAirResistance()));
-        speed -= speed
-               - (speed / (1 + info.airResistance * getAirResistance()));
+        speed
+            -= speed - (speed / (1 + info.airResistance * getAirResistance()));
         zeit -= 1;
     }
     rSpeed
@@ -276,7 +276,7 @@ World2D::World2D()
     : ReferenceCounter()
 {
     objects = new RCArray<Object2D>();
-    memset(&info, 0, sizeof(WorldInfo));
+    memset((void*)&info, 0, sizeof(WorldInfo));
 }
 
 World2D::~World2D()

+ 10 - 4
World3D.cpp

@@ -1,11 +1,11 @@
 #include "World3D.h"
 
+#include "Drawing3D.h"
 #include "DXBuffer.h"
 #include "Globals.h"
 #include "GraphicsApi.h"
-#include "MouseEvent.h"
 #include "Model3D.h"
-#include "Drawing3D.h"
+#include "MouseEvent.h"
 
 using namespace Framework;
 
@@ -253,7 +253,10 @@ void Framework::World3D::copyLight(DXBuffer* zDiffuse, DXBuffer* zPoints) const
 void Framework::World3D::addDiffuseLight(DiffuseLight light)
 {
     DiffuseLight* tmp = new DiffuseLight[diffuseLightCount + 1];
-    memcpy(tmp, diffuseLights, sizeof(DiffuseLight) * diffuseLightCount);
+    for (int i = 0; i < diffuseLightCount; i++)
+    {
+        tmp[i] = diffuseLights[i];
+    }
     tmp[diffuseLightCount] = light;
     delete[] diffuseLights;
     diffuseLights = tmp;
@@ -265,7 +268,10 @@ void Framework::World3D::addDiffuseLight(DiffuseLight light)
 void Framework::World3D::addPointLight(PointLight light)
 {
     PointLight* tmp = new PointLight[pointLightCount + 1];
-    memcpy(tmp, pointLights, sizeof(PointLight) * pointLightCount);
+    for (int i = 0; i < pointLightCount; i++)
+    {
+        tmp[i] = pointLights[i];
+    }
     tmp[pointLightCount] = light;
     delete[] pointLights;
     pointLights = tmp;