Browse Source

moved from make to meson with ninja, refactoring
(client/server/commin/tests), several small bugs fixed due to compiler
warnings

Kajetan Johannes Hammerle 4 years ago
parent
commit
d5e4afcb4e
100 changed files with 257 additions and 1392 deletions
  1. 4 4
      .gitignore
  2. 0 474
      MainTest.cpp
  3. 0 263
      Makefile
  4. 15 14
      client/GameClient.cpp
  5. 12 11
      client/GameClient.h
  6. 3 7
      client/Main.cpp
  7. 1 2
      client/engine/Clock.cpp
  8. 0 0
      client/engine/Clock.h
  9. 3 2
      client/engine/DirectRenderer.cpp
  10. 4 4
      client/engine/DirectRenderer.h
  11. 4 3
      client/engine/KeyManager.cpp
  12. 3 2
      client/engine/KeyManager.h
  13. 7 6
      client/engine/Mesh.cpp
  14. 1 1
      client/engine/Mesh.h
  15. 4 3
      client/engine/MouseManager.cpp
  16. 3 2
      client/engine/MouseManager.h
  17. 5 4
      client/engine/Shader.cpp
  18. 4 4
      client/engine/Shader.h
  19. 2 3
      client/engine/Texture.cpp
  20. 2 0
      client/engine/Texture.h
  21. 2 2
      client/engine/Utils.cpp
  22. 0 0
      client/engine/Utils.h
  23. 2 1
      client/engine/Wrapper.cpp
  24. 14 12
      client/engine/Wrapper.h
  25. 2 2
      client/engine/shader/FramebufferRectangle.cpp
  26. 0 0
      client/engine/shader/FramebufferRectangle.h
  27. 4 4
      client/engine/shader/OverlayShader.cpp
  28. 3 3
      client/engine/shader/OverlayShader.h
  29. 4 4
      client/engine/shader/SSAOBlurShader.cpp
  30. 1 1
      client/engine/shader/SSAOBlurShader.h
  31. 5 4
      client/engine/shader/SSAOShader.cpp
  32. 1 1
      client/engine/shader/SSAOShader.h
  33. 2 1
      client/engine/shader/ShaderProgram.cpp
  34. 0 0
      client/engine/shader/ShaderProgram.h
  35. 4 4
      client/engine/shader/WorldPostShader.cpp
  36. 1 1
      client/engine/shader/WorldPostShader.h
  37. 3 3
      client/engine/shader/WorldShader.cpp
  38. 1 1
      client/engine/shader/WorldShader.h
  39. 5 4
      client/math/Camera3D.cpp
  40. 3 3
      client/math/Camera3D.h
  41. 2 1
      client/math/Matrix3D.cpp
  42. 0 0
      client/math/Matrix3D.h
  43. 3 3
      client/math/Matrix3DStack.cpp
  44. 1 1
      client/math/Matrix3DStack.h
  45. 3 2
      client/math/Plane3D.cpp
  46. 2 2
      client/math/Plane3D.h
  47. 1 1
      client/math/StackOverflow.cpp
  48. 0 0
      client/math/StackOverflow.h
  49. 1 1
      client/math/StackUnderflow.cpp
  50. 0 0
      client/math/StackUnderflow.h
  51. 2 1
      client/math/Vector3D.cpp
  52. 0 0
      client/math/Vector3D.h
  53. 3 2
      client/network/Client.cpp
  54. 2 1
      client/network/Client.h
  55. 1 2
      client/network/ClientListener.cpp
  56. 1 1
      client/network/ClientListener.h
  57. 2 1
      client/network/IClientListener.h
  58. 4 4
      client/rendering/ChunkRenderer.cpp
  59. 6 6
      client/rendering/ChunkRenderer.h
  60. 1 1
      client/rendering/ClientChunkProvider.cpp
  61. 1 1
      client/rendering/ClientChunkProvider.h
  62. 3 3
      client/rendering/block/BlockRenderer.cpp
  63. 2 1
      client/rendering/block/BlockRenderer.h
  64. 1 1
      client/rendering/block/BlockRenderers.cpp
  65. 2 2
      client/rendering/block/BlockRenderers.h
  66. 3 3
      client/rendering/entity/EntityRenderer.cpp
  67. 5 5
      client/rendering/entity/EntityRenderer.h
  68. 1 1
      client/rendering/gui/GUI.cpp
  69. 4 4
      client/rendering/gui/GUI.h
  70. 1 1
      client/rendering/gui/StartMenu.cpp
  71. 1 1
      client/rendering/gui/StartMenu.h
  72. 2 2
      common/block/Block.cpp
  73. 1 1
      common/block/Block.h
  74. 1 1
      common/block/BlockAir.cpp
  75. 1 1
      common/block/BlockAir.h
  76. 1 1
      common/block/Blocks.cpp
  77. 2 2
      common/block/Blocks.h
  78. 4 3
      common/stream/Stream.cpp
  79. 0 0
      common/stream/Stream.h
  80. 1 1
      common/utils/Face.cpp
  81. 2 3
      common/utils/Face.h
  82. 4 4
      common/world/Chunk.cpp
  83. 1 1
      common/world/Chunk.h
  84. 2 1
      common/world/IChunkListener.h
  85. 3 2
      common/world/IChunkProvider.h
  86. 5 5
      common/world/World.cpp
  87. 6 5
      common/world/World.h
  88. 0 348
      data/HashMap.h
  89. 0 98
      data/UnsortedArrayList.h
  90. 28 0
      meson.build
  91. 0 0
      resources/shader/fragment.fs
  92. 0 0
      resources/shader/overlayFragment.fs
  93. 0 0
      resources/shader/overlayVertex.vs
  94. 0 0
      resources/shader/ssaoBlurFragment.fs
  95. 0 0
      resources/shader/ssaoBlurVertex.vs
  96. 0 0
      resources/shader/ssaoFragment.fs
  97. 0 0
      resources/shader/ssaoVertex.vs
  98. 0 0
      resources/shader/worldFragment.fs
  99. 0 0
      resources/shader/worldPostFragment.fs
  100. 0 0
      resources/shader/worldPostVertex.vs

+ 4 - 4
.gitignore

@@ -1,8 +1,8 @@
 /nbproject
-game_client
-game_server
-*.o
+/build_server
+/build_client
+/build_tests
 LineCounter.jar
-test
 README
+specs
 start.sh

+ 0 - 474
MainTest.cpp

@@ -1,474 +0,0 @@
-#include <iostream>
-#include "data/UnsortedArrayList.h"
-#include "data/HashMap.h"
-#include "server/CommandUtils.h"
-
-using namespace std;
-
-// -----------------------------------------------------------------------------
-// test feedback
-// -----------------------------------------------------------------------------
-
-const char* RED = "\033[0;31m";
-const char* GREEN = "\033[0;32m";
-
-int tests = 0;
-int successTests = 0;
-
-void notifySuccess(string text)
-{
-    tests++;
-    successTests++;
-    cout << GREEN << tests << ". " << text << endl; 
-}
-
-void notifyFail(string text)
-{
-    tests++;
-    cout << RED << tests << ". " << text << endl;
-}
-
-void finalizeTest()
-{
-    cout << successTests << " / " << tests << " succeeded" << endl;
-    tests = 0;
-    successTests = 0;
-}
-
-// -----------------------------------------------------------------------------
-// checks
-// -----------------------------------------------------------------------------
-
-void checkEqual(int a, int b, string text)
-{
-    if(a == b)
-    {
-        notifySuccess(text);
-    }
-    else
-    {
-        notifyFail(text + " - expected '" + std::to_string(a) + "' got '" + std::to_string(b) + "'");
-    }
-}
-
-void checkEqual(string a, string b, string text)
-{
-    if(a == b)
-    {
-        notifySuccess(text);
-    }
-    else
-    {
-        notifyFail(text + " - expected '" + a + "' got '" + b + "'");
-    }
-}
-
-void checkBool(bool a, bool b, string text)
-{
-    if(a == b)
-    {
-        notifySuccess(text);
-    }
-    else
-    {
-        notifyFail(text + " - expected '" + std::to_string(a) + "' got '" + std::to_string(b) + "'");
-    }
-}
-
-void checkGreaterOrEqual(int a, int b, string text)
-{
-    if(a >= b)
-    {
-        notifySuccess(text);
-    }
-    else
-    {
-        notifyFail(text + " - expected " + std::to_string(a) + " >= " + std::to_string(b));
-    }
-}
-
-// -----------------------------------------------------------------------------
-// tests of UnsortedArrayList
-// -----------------------------------------------------------------------------
-
-void testUnsortedArrayList1(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(5);
-    list.add(10);
-    
-    checkEqual(3, list.getSize(), text);
-    checkEqual(1, list.get(0, -1), text);
-    checkEqual(5, list.get(1, -1), text);
-    checkEqual(10, list.get(2, -1), text);
-}
-
-void testUnsortedArrayList2(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(5);
-    list.add(10);
-    list.removeIndex(1);
-    
-    checkEqual(2, list.getSize(), text);
-    checkEqual(1, list.get(0, -1), text);
-    checkEqual(10, list.get(1, -1), text);
-}
-
-void testUnsortedArrayList3(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(5);
-    list.add(10);
-    list.removeIndex(0);
-    list.add(20);
-    
-    checkEqual(3, list.getSize(), text);
-    checkEqual(10, list.get(0, -1), text);
-    checkEqual(5, list.get(1, -1), text);
-    checkEqual(20, list.get(2, -1), text);
-}
-
-void testUnsortedArrayList4(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(5);
-    list.add(10);
-    list.removeIndex(-5);
-    list.removeIndex(5);
-    
-    checkEqual(3, list.getSize(), text);
-    checkEqual(1, list.get(0, -1), text);
-    checkEqual(5, list.get(1, -1), text);
-    checkEqual(10, list.get(2, -1), text);
-}
-
-void testUnsortedArrayList5(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(5);
-    list.add(1);
-    list.add(20);
-    list.remove(2);
-    
-    checkEqual(4, list.getSize(), text);
-    checkEqual(1, list.get(0, -1), text);
-    checkEqual(5, list.get(1, -1), text);
-    checkEqual(1, list.get(2, -1), text);
-    checkEqual(20, list.get(3, -1), text);
-}
-
-void testUnsortedArrayList6(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    int r = rand();
-    checkEqual(r, list.get(-100, r), text);
-    r = rand();
-    checkEqual(r, list.get(100, r), text);
-}
-
-void testUnsortedArrayList7(string text)
-{
-    UnsortedArrayList<int> list;
-    
-    list.add(1);
-    list.add(1);
-    list.add(5);
-    list.add(1);
-    list.add(20);
-    list.remove(1);
-    
-    checkEqual(2, list.getSize(), text);
-    checkEqual(20, list.get(0, -1), text);
-    checkEqual(5, list.get(1, -1), text);
-}
-
-void testUnsortedArrayList()
-{
-    testUnsortedArrayList1("add, size and get");
-    testUnsortedArrayList2("remove index");
-    testUnsortedArrayList3("add after remove index, move last to first");
-    testUnsortedArrayList4("remove of non existent element");
-    testUnsortedArrayList5("remove index of non existent index");
-    testUnsortedArrayList6("get returns error value");
-    testUnsortedArrayList7("remove deletes all occurencies");
-    finalizeTest();
-}
-
-// -----------------------------------------------------------------------------
-// tests of HashMap
-// -----------------------------------------------------------------------------
-
-unsigned int hashInt(int i)
-{
-    return i;
-}
-
-void testHashMap1(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    checkGreaterOrEqual(cap, 16, text);
-    HashMap<int, int> map2(cap, hashInt);
-    HashMap<int, int> map3(cap + 1, hashInt);
-    checkEqual(cap, map2.getCapacity(), text);
-    checkGreaterOrEqual(map3.getCapacity(), cap + 1, text);
-}
-
-void testHashMap2(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    
-    for(int i = 0; i < 5; i++)
-    {
-        map.put(i, i);
-    }
-    
-    checkEqual(5, map.getSize(), text);
-}
-
-void testHashMap3(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    if(cap < 0)
-    {
-        cap = 0;
-    }
-    cap += 3;
-    
-    for(int i = 0; i < cap; i++)
-    {
-        map.put(i, i);
-    }
-    
-    checkEqual(cap, map.getSize(), text);
-}
-
-void testHashMap4(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    for(int i = 0; i < 3; i++)
-    {
-        map.put(i, i + 20);
-    }
-    for(int i = 0; i < 3; i++)
-    {
-        checkEqual(i + 20, map.get(i, -1), text);
-    }
-}
-
-void testHashMap5(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    if(cap < 0)
-    {
-        cap = 0;
-    }
-    cap += 3;
-    for(int i = 0; i < cap; i++)
-    {
-        map.put(i, i + 20);
-    }
-    
-    checkBool(true, map.remove(cap / 2), text);
-    checkEqual(-1, map.get(cap / 2, -1), text);
-    checkEqual(cap - 1, map.getSize(), text);
-}
-
-void testHashMap6(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    if(cap < 0)
-    {
-        cap = 0;
-    }
-    cap += 3;
-    for(int i = 0; i < cap; i++)
-    {
-        map.put(i, i + 20);
-    }
-    checkBool(false, map.remove(cap + 5), text);
-    checkBool(false, map.remove(cap + 20), text);
-    checkBool(false, map.remove(cap + 25), text);
-    checkEqual(cap, map.getSize(), text);
-}
-
-void testHashMap7(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    for(int i = 0; i < 3; i++)
-    {
-        map.put(i, i + 20);
-    }
-    checkEqual(3, map.getSize(), text);
-    map.clear();
-    checkEqual(0, map.getSize(), text);
-    checkEqual(-1, map.get(0, -1), text);
-    checkEqual(-1, map.get(1, -1), text);
-    checkEqual(-1, map.get(2, -1), text);
-}
-
-void testHashMap8(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    for(int i = 0; i < 3; i++)
-    {
-        map.put(i, i + 20);
-    }
-    for(int i = 0; i < 3; i++)
-    {
-        map.put(i, i + 25);
-    }
-    for(int i = 0; i < 3; i++)
-    {
-        checkEqual(i + 25, map.get(i, -1), text);
-    }
-}
-
-void testHashMap9(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    if(cap < 0)
-    {
-        cap = 0;
-    }
-    cap += 3;
-    for(int i = 0; i < cap; i++)
-    {
-        map.put(i, i + 20);
-    }
-    
-    checkEqual(cap / 2 + 20, map.remove(cap / 2, -1), text);
-    checkEqual(cap - 1, map.getSize(), text);
-}
-
-void testHashMap10(string text)
-{
-    HashMap<int, int> map(16, hashInt);
-    int cap = map.getCapacity();
-    if(cap < 0)
-    {
-        cap = 0;
-    }
-    cap += 3;
-    for(int i = 0; i < cap; i++)
-    {
-        map.put(i, i + 20);
-    }
-    checkEqual(-1, map.remove(cap + 5, -1), text);
-    checkEqual(-1, map.remove(cap + 20, -1), text);
-    checkEqual(-1, map.remove(cap + 25, -1), text);
-    checkEqual(cap, map.getSize(), text);
-}
-
-void testHashMap()
-{
-    testHashMap1("capacity greater or equal than inital value");
-    testHashMap2("put increases size");
-    testHashMap3("put over capacity");
-    testHashMap4("get");
-    testHashMap5("remove of existent value");
-    testHashMap6("remove of non existent value");
-    testHashMap7("clear");
-    testHashMap8("put overwrites old value");
-    testHashMap9("remove with return value of existent value");
-    testHashMap10("remove with return value of non existent value");
-    finalizeTest();
-}
-
-// -----------------------------------------------------------------------------
-// tests of command parser
-// -----------------------------------------------------------------------------
-
-void checkCommandParser(string rawCommand, string command, vector<string>& args, string text)
-{
-    string parsedCommand;
-    vector<string> parsedArgs;
-    
-    CommandUtils::splitString(rawCommand, parsedCommand, parsedArgs);
-    
-    checkEqual(command, parsedCommand, text);
-    checkEqual(args.size(), parsedArgs.size(), text);
-    
-    for(int i = 0; i < args.size() && i < parsedArgs.size(); i++)
-    {
-        checkEqual(args[i], parsedArgs[i], text);
-    }
-}
-
-void testCommandParser()
-{
-    vector<string> args;
-    
-    args = {};
-    checkCommandParser("test", "test", args, "command without arguments");
-    
-    args = {"aaa"};
-    checkCommandParser("test aaa", "test", args, "command with one argument");
-    
-    args = {"aaa", "bbbb"};
-    checkCommandParser("test aaa bbbb", "test", args, "command with two arguments");
-    
-    args = {"aaa", "bbbb", "ccccc"};
-    checkCommandParser("test aaa bbbb ccccc", "test", args, "command with three arguments");
-    
-    args = {};
-    checkCommandParser("test    ", "test", args, "command with spaces");
-    
-    args = {"aaa", "bbbb"};
-    checkCommandParser("test  aaa   bbbb", "test", args, "command with arguments and spaces");
-    
-    args = {"aaa", "bbbb"};
-    checkCommandParser("test  aaa   bbbb", "test", args, "command with arguments and spaces");
-    
-    args = {"aaa bbbb"};
-    checkCommandParser("test \"aaa bbbb\"", "test", args, "command with one argument and quotation marks");
-    
-    args = {"aaa bbbb", "ccc"};
-    checkCommandParser("test \"aaa bbbb\" ccc", "test", args, "command with two arguments and quotation marks");
-    
-    args = {"ddd", "aaa bbbb", "ccc"};
-    checkCommandParser("test ddd \"aaa bbbb\" ccc", "test", args, "command with tree arguments and quotation marks");
-    
-    args = {};
-    checkCommandParser("test \"", "", args, "command syntax exception 1");
-    
-    args = {};
-    checkCommandParser("test aaa\"", "", args, "command syntax exception 2");
-    
-    args = {};
-    checkCommandParser("test aaa\"bbb\"", "", args, "command syntax exception 3");
-    
-    args = {};
-    checkCommandParser("test aaa \"bbb\"ccc", "", args, "command syntax exception 4");
-}
-
-// -----------------------------------------------------------------------------
-// main
-// -----------------------------------------------------------------------------
-
-int main(int argc, char** argv)
-{
-    testUnsortedArrayList();
-    testHashMap();
-    testCommandParser();
-    return 0;
-}
-
-
-

+ 0 - 263
Makefile

@@ -1,263 +0,0 @@
-VERSION = -std=c++14
-CFLAGS = $(shell pkg-config --cflags glfw3)
-LDFLAGS = $(shell pkg-config --static --libs glfw3) -lGL -lGLEW -lpng
-
-all: game_client game_server
-
-test_client: game_client
-	optirun ./game_client
-
-run_client: game_client
-	#vblank_mode=0 optirun ./game_client
-	optirun ./game_client
-
-game_client: MainClient.cpp\
-	Clock.o DirectRenderer.o KeyManager.o Mesh.o MouseManager.o Shader.o\
-	Texture.o Utils.o Wrapper.o ShaderProgram.o WorldShader.o FramebufferRectangle.o\
-	SSAOShader.o SSAOBlurShader.o WorldPostShader.o OverlayShader.o\
-	Matrix3D.o Matrix3DStack.o StackOverflow.o StackUnderflow.o Vector3D.o Plane3D.o Camera3D.o\
-	Client.o\
-	Block.o Blocks.o BlockAir.o\
-	Face.o GUI.o StartMenu.o\
-	Chunk.o World.o ChunkRenderer.o ClientChunkProvider.o BlockRenderer.o BlockRenderers.o EntityRenderer.o
-	g++ $(VERSION) -o $@ MainClient.cpp Clock.o DirectRenderer.o KeyManager.o Mesh.o MouseManager.o Shader.o\
-		Texture.o Utils.o Wrapper.o ShaderProgram.o WorldShader.o FramebufferRectangle.o\
-		SSAOShader.o SSAOBlurShader.o WorldPostShader.o OverlayShader.o\
-		Matrix3D.o Matrix3DStack.o StackOverflow.o StackUnderflow.o Vector3D.o Plane3D.o Camera3D.o\
-		Client.o\
-		Block.o Blocks.o BlockAir.o\
-		Face.o GUI.o StartMenu.o\
-		Chunk.o World.o ChunkRenderer.o ClientChunkProvider.o BlockRenderer.o BlockRenderers.o EntityRenderer.o $(LDFLAGS)
-
-# ------------------------------------------------------------------------------	
-# Engine
-# ------------------------------------------------------------------------------
-	
-Clock.o: engine/Clock.cpp engine/Clock.h
-	g++ $(VERSION) -c engine/Clock.cpp -o $@
-
-DirectRenderer.o: engine/DirectRenderer.cpp engine/DirectRenderer.h\
-	math/Matrix3D.h engine/Texture.h engine/Utils.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/DirectRenderer.cpp -o $@
-	
-KeyManager.o: engine/KeyManager.cpp engine/KeyManager.h
-	g++ $(VERSION) -c engine/KeyManager.cpp -o $@
-
-Mesh.o: engine/Mesh.cpp engine/Mesh.h
-	g++ $(VERSION) -c engine/Mesh.cpp -o $@
-
-MouseManager.o: engine/MouseManager.cpp engine/MouseManager.h
-	g++ $(VERSION) -c engine/MouseManager.cpp -o $@
-	
-Shader.o: engine/Shader.cpp engine/Shader.h\
-	math/Plane3D.h math/Vector3D.h math/Matrix3D.h math/Matrix3DStack.h\
-	engine/Utils.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/Shader.cpp -o $@
-	
-Texture.o: engine/Texture.cpp engine/Texture.h
-	g++ $(VERSION) -c engine/Texture.cpp -o $@
-
-Utils.o: engine/Utils.cpp engine/Utils.h
-	g++ $(VERSION) -c engine/Utils.cpp -o $@
-	
-Wrapper.o: engine/Wrapper.cpp engine/Wrapper.h\
-	engine/shader/ShaderProgram.h math/Vector3D.h math/Matrix3D.h\
-	engine/shader/WorldShader.h engine/Shader.h\
-	engine/shader/SSAOShader.h engine/shader/SSAOBlurShader.h\
-	engine/shader/FramebufferRectangle.h engine/shader/WorldPostShader.h\
-	engine/shader/OverlayShader.h engine/Mesh.h
-	g++ $(VERSION) -c engine/Wrapper.cpp -o $@
-	
-ShaderProgram.o: engine/shader/ShaderProgram.cpp engine/shader/ShaderProgram.h
-	g++ $(VERSION) -c engine/shader/ShaderProgram.cpp -o $@
-	
-WorldShader.o: engine/shader/WorldShader.cpp engine/shader/WorldShader.h\
-	engine/shader/ShaderProgram.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/WorldShader.cpp -o $@
-	
-FramebufferRectangle.o: engine/shader/FramebufferRectangle.cpp engine/shader/FramebufferRectangle.h\
-	engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/FramebufferRectangle.cpp -o $@
-	
-SSAOShader.o: engine/shader/SSAOShader.cpp engine/shader/SSAOShader.h\
-	engine/shader/ShaderProgram.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/SSAOShader.cpp -o $@
-	
-SSAOBlurShader.o: engine/shader/SSAOBlurShader.cpp engine/shader/SSAOBlurShader.h\
-	engine/shader/ShaderProgram.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/SSAOBlurShader.cpp -o $@
-	
-WorldPostShader.o: engine/shader/WorldPostShader.cpp engine/shader/WorldPostShader.h\
-	engine/shader/ShaderProgram.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/WorldPostShader.cpp -o $@
-	
-OverlayShader.o: engine/shader/OverlayShader.cpp engine/shader/OverlayShader.h\
-	engine/shader/ShaderProgram.h math/Matrix3D.h engine/Wrapper.h
-	g++ $(VERSION) -c engine/shader/OverlayShader.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# Client
-# ------------------------------------------------------------------------------
-	
-Client.o: client/Client.h client/Client.cpp\
-	engine/KeyManager.h engine/MouseManager.h engine/Clock.h\
-	engine/Shader.h engine/DirectRenderer.h\
-	client/rendering/gui/GUIs.h client/rendering/gui/GUI.h client/rendering/gui/StartMenu.h
-	g++ $(VERSION) -c client/Client.cpp -o $@
-	
-ChunkRenderer.o: client/rendering/ChunkRenderer.h client/rendering/ChunkRenderer.cpp world/IChunkListener.h\
-	client/rendering/block/BlockRenderers.h client/rendering/block/BlockRenderer.h\
-	engine/Mesh.h engine/Shader.h engine/Texture.h engine/DirectRenderer.h\
-	world/IChunkListener.h math/Camera3D.h
-	g++ $(VERSION) -c client/rendering/ChunkRenderer.cpp -o $@
-		
-ClientChunkProvider.o: client/rendering/ClientChunkProvider.h client/rendering/ClientChunkProvider.cpp world/IChunkProvider.h\
-	world/IChunkProvider.h
-	g++ $(VERSION) -c client/rendering/ClientChunkProvider.cpp -o $@
-	
-BlockRenderer.o: client/rendering/block/BlockRenderer.h client/rendering/block/BlockRenderer.cpp engine/Mesh.h utils/Face.h
-	g++ $(VERSION) -c client/rendering/block/BlockRenderer.cpp -o $@
-	
-BlockRenderers.o: client/rendering/block/BlockRenderers.h client/rendering/block/BlockRenderers.cpp block/Block.h client/rendering/block/BlockRenderer.h
-	g++ $(VERSION) -c client/rendering/block/BlockRenderers.cpp -o $@
-	
-EntityRenderer.o: client/rendering/entity/EntityRenderer.h client/rendering/entity/EntityRenderer.cpp\
-	engine/Shader.h math/Camera3D.h engine/DirectRenderer.h engine/Mesh.h\
-	engine/Texture.h engine/Utils.h
-	g++ $(VERSION) -c client/rendering/entity/EntityRenderer.cpp -o $@
-	
-GUI.o: client/rendering/gui/GUI.h client/rendering/gui/GUI.cpp\
-	engine/KeyManager.h engine/MouseManager.h engine/Shader.h engine/DirectRenderer.h
-	g++ $(VERSION) -c client/rendering/gui/GUI.cpp -o $@
-	
-StartMenu.o: client/rendering/gui/StartMenu.h client/rendering/gui/StartMenu.cpp\
-	client/rendering/gui/GUI.h
-	g++ $(VERSION) -c client/rendering/gui/StartMenu.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# Utils
-# ------------------------------------------------------------------------------
-	
-Face.o: utils/Face.h utils/Face.cpp
-	g++ $(VERSION) -c utils/Face.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# Block
-# ------------------------------------------------------------------------------
-	
-Block.o: block/Block.h block/Block.cpp utils/Face.h
-	g++ $(VERSION) -c block/Block.cpp -o $@
-	
-Blocks.o: block/Blocks.h block/Blocks.cpp block/Block.h block/BlockAir.h
-	g++ $(VERSION) -c block/Blocks.cpp -o $@
-	
-BlockAir.o: block/BlockAir.h block/BlockAir.cpp block/Block.h
-	g++ $(VERSION) -c block/BlockAir.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# World
-# ------------------------------------------------------------------------------
-	
-Chunk.o: world/Chunk.h world/Chunk.cpp\
-	block/Block.h block/Blocks.h
-	g++ $(VERSION) -c world/Chunk.cpp -o $@
-	
-World.o: world/World.h world/World.cpp\
-	world/Chunk.h world/IChunkProvider.h world/IChunkListener.h data/UnsortedArrayList.h
-	g++ $(VERSION) -c world/World.cpp -o $@
-
-# ------------------------------------------------------------------------------	
-# Math
-# ------------------------------------------------------------------------------
-
-Matrix3D.o: math/Matrix3D.h math/Matrix3D.cpp
-	g++ $(VERSION) -c math/Matrix3D.cpp -o $@
-	
-Matrix3DStack.o: math/Matrix3DStack.h math/Matrix3DStack.cpp\
-	math/Matrix3D.h math/StackOverflow.h math/StackUnderflow.h
-	g++ $(VERSION) -c math/Matrix3DStack.cpp -o $@
-	
-StackOverflow.o: math/StackOverflow.h math/StackOverflow.cpp
-	g++ $(VERSION) -c math/StackOverflow.cpp -o $@
-	
-StackUnderflow.o: math/StackUnderflow.h math/StackUnderflow.cpp
-	g++ $(VERSION) -c math/StackUnderflow.cpp -o $@
-	
-Vector3D.o: math/Vector3D.h math/Vector3D.cpp
-	g++ $(VERSION) -c math/Vector3D.cpp -o $@
-	
-Plane3D.o: math/Plane3D.h math/Plane3D.cpp\
-	math/Vector3D.h
-	g++ $(VERSION) -c math/Plane3D.cpp -o $@
-	
-Camera3D.o: math/Camera3D.h math/Camera3D.cpp\
-	math/Vector3D.h math/Matrix3D.h math/Plane3D.h math/Camera3D.h\
-	engine/Wrapper.h engine/Utils.h
-	g++ $(VERSION) -c math/Camera3D.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# server
-# ------------------------------------------------------------------------------
-	
-run_server: game_server
-	./game_server
-	
-game_server: MainServer.cpp GameServer.o Stream.o Server.o CommandManager.o\
-	BaseCommand.o TestCommand.o CommandUtils.o
-	g++ $(VERSION) -o $@ MainServer.cpp GameServer.o Stream.o Server.o\
-	    CommandManager.o BaseCommand.o TestCommand.o CommandUtils.o -lpthread
-	
-GameServer.o: server/GameServer.h server/GameServer.cpp network/server/Server.h\
-	server/CommandManager.h server/ICommandSource.h
-	g++ $(VERSION) -c server/GameServer.cpp -o $@
-	
-CommandManager.o: server/CommandManager.h server/CommandManager.cpp\
-	server/GameServer.h server/CommandUtils.h\
-	server/commands/BaseCommand.h server/commands/TestCommand.h 
-	g++ $(VERSION) -c server/CommandManager.cpp -o $@
-	
-CommandUtils.o: server/CommandUtils.h server/CommandUtils.cpp
-	g++ $(VERSION) -c server/CommandUtils.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# commands
-# ------------------------------------------------------------------------------
-	
-BaseCommand.o: server/commands/BaseCommand.h server/commands/BaseCommand.cpp\
-	server/GameServer.h server/ICommandSource.h
-	g++ $(VERSION) -c server/commands/BaseCommand.cpp -o $@
-	
-TestCommand.o: server/commands/TestCommand.h server/commands/TestCommand.cpp\
-	server/commands/BaseCommand.h
-	g++ $(VERSION) -c server/commands/TestCommand.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# network
-# ------------------------------------------------------------------------------
-	
-Server.o: network/server/Server.h network/server/Server.cpp\
-	network/server/IServerListener.h network/stream/Stream.h
-	g++ $(VERSION) -c network/server/Server.cpp -o $@
-	
-Stream.o: network/stream/Stream.h network/stream/Stream.cpp
-	g++ $(VERSION) -c network/stream/Stream.cpp -o $@
-	
-# ------------------------------------------------------------------------------	
-# tests
-# ------------------------------------------------------------------------------
-	
-run_tests: test
-	./test
-	
-test: MainTest.cpp data/UnsortedArrayList.h data/HashMap.h CommandUtils.o
-	g++ $(VERSION) -o $@ MainTest.cpp CommandUtils.o
-	
-# ------------------------------------------------------------------------------	
-# clean
-# ------------------------------------------------------------------------------
-	
-clean:
-	rm -f game_server game_client *.o test
-
-clean_o:
-	rm -f *.o

+ 15 - 14
client/Client.cpp → client/GameClient.cpp

@@ -1,14 +1,15 @@
-#include "Client.h"
 #include <iostream>
-#include "../block/Blocks.h"
-#include "../client/rendering/block/BlockRenderers.h"
-#include "rendering/entity/EntityRenderer.h"
 #include <cmath>
-#include "rendering/gui/StartMenu.h"
+
+#include "client/GameClient.h"
+#include "common/block/Blocks.h"
+#include "client/rendering/block/BlockRenderers.h"
+#include "client/rendering/entity/EntityRenderer.h"
+#include "client/rendering/gui/StartMenu.h"
 
 using namespace std;
 
-Client::Client()
+GameClient::GameClient()
 {    
     BlockRegistry::registerBlocks();
     BlockRenderers::init();
@@ -27,7 +28,7 @@ Client::Client()
     activeGUI = new StartMenu();
 }
 
-Client::~Client()
+GameClient::~GameClient()
 {
     if(activeGUI != nullptr)
     {
@@ -35,7 +36,7 @@ Client::~Client()
     }
 }
 
-void Client::tick()
+void GameClient::tick()
 {
     tps.update();
     
@@ -56,12 +57,12 @@ void Client::tick()
     }
 }
 
-void Client::render3DTick(float lag)
+void GameClient::render3DTick(float lag)
 {
     fps.update();
 }
 
-void Client::render2DTick(float lag)
+void GameClient::render2DTick(float lag)
 {
     if(activeGUI != nullptr)
     {
@@ -79,7 +80,7 @@ void Client::render2DTick(float lag)
     directRenderer.drawString(10, y, true, wusi);
 }
 
-void Client::onKeyEvent(int key, int scancode, int action, int mods)
+void GameClient::onKeyEvent(int key, int scancode, int action, int mods)
 {
     if(action == GLFW_PRESS)
     {
@@ -91,7 +92,7 @@ void Client::onKeyEvent(int key, int scancode, int action, int mods)
     }
 }
 
-double Client::transformMouse(double x)
+double GameClient::transformMouse(double x)
 {
     if(x >= -MOUSE_BORDER && x <= MOUSE_BORDER)
     {
@@ -113,7 +114,7 @@ double Client::transformMouse(double x)
     }
 }
 
-void Client::onMouseMove(double x, double y)
+void GameClient::onMouseMove(double x, double y)
 {
     if(mouseTrapped)
     {
@@ -124,7 +125,7 @@ void Client::onMouseMove(double x, double y)
     }
 }
 
-void Client::onMouseClick(int button, int action, int mods)
+void GameClient::onMouseClick(int button, int action, int mods)
 {
     if(action == GLFW_PRESS)
     {

+ 12 - 11
client/Client.h → client/GameClient.h

@@ -5,22 +5,23 @@
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
 
-#include "../engine/KeyManager.h"
-#include "../engine/MouseManager.h"
-#include "../engine/Clock.h"
-#include "../engine/Shader.h"
-#include "../engine/DirectRenderer.h"
-#include "../world/IChunkProvider.h"
-#include "rendering/gui/GUIs.h"
-#include "rendering/gui/GUI.h"
+#include "client/engine/KeyManager.h"
+#include "client/engine/MouseManager.h"
+#include "client/engine/Clock.h"
+#include "client/engine/Shader.h"
+#include "client/engine/DirectRenderer.h"
+#include "client/rendering/gui/GUIs.h"
+#include "client/rendering/gui/GUI.h"
+
+#include "common/world/IChunkProvider.h"
 
 using namespace std;
 
-class Client : public IClient
+class GameClient : public IClient
 {
 public:
-    Client();
-    virtual ~Client();
+    GameClient();
+    virtual ~GameClient();
     
     void tick() override;
     void render3DTick(float lag) override;

+ 3 - 7
MainClient.cpp → client/Main.cpp

@@ -1,9 +1,5 @@
-#include <iostream>
-
-#include "engine/Wrapper.h"
-#include "client/Client.h"
-
-using namespace std;
+#include "client/engine/Wrapper.h"
+#include "client/GameClient.h"
 
 int main(int argc, char** argv) 
 {
@@ -11,7 +7,7 @@ int main(int argc, char** argv)
     {
        return 0; 
     }
-    Client client;
+    GameClient client;
     Engine::start(&client);
     return 0;
 }

+ 1 - 2
engine/Clock.cpp → client/engine/Clock.cpp

@@ -1,5 +1,4 @@
-#include "Clock.h"
-#include <iostream>
+#include "client/engine/Clock.h"
 
 Clock::Clock()
 {

+ 0 - 0
engine/Clock.h → client/engine/Clock.h


+ 3 - 2
engine/DirectRenderer.cpp → client/engine/DirectRenderer.cpp

@@ -1,6 +1,7 @@
-#include "DirectRenderer.h"
 #include <cmath>
 
+#include "client/engine/DirectRenderer.h"
+
 DirectRenderer::DirectRenderer()
 {
     glGenVertexArrays(1, &vba);
@@ -232,4 +233,4 @@ void DirectRenderer::getStringSize(float& width, float& height, string& s)
     {
         width = currentWidth;
     }
-}
+}

+ 4 - 4
engine/DirectRenderer.h → client/engine/DirectRenderer.h

@@ -1,10 +1,10 @@
 #ifndef DIRECTRENDERER_H
 #define DIRECTRENDERER_H
 
-#include "Wrapper.h"
-#include "../math/Matrix3D.h"
-#include "Texture.h"
-#include "Utils.h"
+#include "client/engine/Wrapper.h"
+#include "client/math/Matrix3D.h"
+#include "client/engine/Texture.h"
+#include "client/engine/Utils.h"
 
 using namespace std;
 

+ 4 - 3
engine/KeyManager.cpp → client/engine/KeyManager.cpp

@@ -1,4 +1,4 @@
-#include "KeyManager.h"
+#include "client/engine/KeyManager.h"
 
 KeyManager::KeyManager()
 {
@@ -33,6 +33,7 @@ bool KeyManager::map(int mapping, int key)
 {
     bool b = isInRange(mapping) && isInRange(key);
     mappingArray[mapping * b] = b * key;
+    return b;
 }
 
 bool KeyManager::isInRange(int i)
@@ -52,14 +53,14 @@ void KeyManager::tick()
     }
 }
 
-bool KeyManager::press(int key)
+void KeyManager::press(int key)
 {
     int index = isInRange(key) * key;
     keyArray[index].down = true;
     keyArray[index].shouldRelease = false;
 }
 
-bool KeyManager::release(int key)
+void KeyManager::release(int key)
 {
     int index = isInRange(key) * key;
     keyArray[index].shouldRelease = true;

+ 3 - 2
engine/KeyManager.h → client/engine/KeyManager.h

@@ -15,8 +15,9 @@ public:
     bool map(int mapping, int key);
     
     void tick();
-    bool press(int key);
-    bool release(int key);
+    void press(int key);
+    void release(int key);
+    
 private:
     static const int NUMBER_OF_KEYS = GLFW_KEY_LAST + 1;
     

+ 7 - 6
engine/Mesh.cpp → client/engine/Mesh.cpp

@@ -1,7 +1,8 @@
-#include "Mesh.h"
 #include <cstring>
 #include <iostream>
 
+#include "client/engine/Mesh.h"
+
 using namespace std;
 
 Mesh::Mesh(int mode)
@@ -120,11 +121,11 @@ void Mesh::build(bool print)
     if(print)
     {
         cout << "______________" << vertices << " " << vertexSize << endl;
-        for(int i = 0; i < vertices; i++)
+        for(unsigned int i = 0; i < vertices; i++)
         {
             cout << "----------vert " << i << endl;
-            int index = i * vertexSize;
-            for(int j = 0; j < vertexSize; j++)
+            unsigned int index = i * vertexSize;
+            for(unsigned int j = 0; j < vertexSize; j++)
             {
                 cout << data[index + j] << " " << endl;
             }
@@ -150,9 +151,9 @@ void Mesh::draw()
     glDrawArrays(GL_TRIANGLES, 0, vertices);
 }
 
-void Mesh::draw(int start, int count)
+void Mesh::draw(unsigned int start, unsigned int count)
 {
-    if(vertices == 0 || start < 0 || start >= vertices || start + count > vertices)
+    if(vertices == 0 || start == 0 || start >= vertices || start + count > vertices)
     {
         return;
     }

+ 1 - 1
engine/Mesh.h → client/engine/Mesh.h

@@ -17,7 +17,7 @@ public:
     
     void build(bool print = false);
     void draw();
-    void draw(int start, int count);
+    void draw(unsigned int start, unsigned int count);
     
     static const int COLOR = 1;
     static const int TEXTURE = 2;

+ 4 - 3
engine/MouseManager.cpp → client/engine/MouseManager.cpp

@@ -1,4 +1,4 @@
-#include "MouseManager.h"
+#include "client/engine/MouseManager.h"
 
 MouseManager::MouseManager()
 {
@@ -33,6 +33,7 @@ bool MouseManager::map(int mapping, int mouse)
 {
     bool b = isInRange(mapping) && isInRange(mouse);
     mappingArray[mapping * b] = b * mouse;
+    return b;
 }
 
 bool MouseManager::isInRange(int i)
@@ -52,14 +53,14 @@ void MouseManager::tick()
     }
 }
 
-bool MouseManager::press(int mouse)
+void MouseManager::press(int mouse)
 {
     int index = isInRange(mouse) * mouse;
     mouseArray[index].down = true;
     mouseArray[index].shouldRelease = false;
 }
 
-bool MouseManager::release(int mouse)
+void MouseManager::release(int mouse)
 {
     int index = isInRange(mouse) * mouse;
     mouseArray[index].shouldRelease = true;

+ 3 - 2
engine/MouseManager.h → client/engine/MouseManager.h

@@ -15,8 +15,9 @@ public:
     bool map(int mapping, int key);
     
     void tick();
-    bool press(int button);
-    bool release(int button);
+    void press(int button);
+    void release(int button);
+    
 private:
     static const int NUMBER_OF_BUTTONS = GLFW_MOUSE_BUTTON_LAST + 1;
     

+ 5 - 4
engine/Shader.cpp → client/engine/Shader.cpp

@@ -1,7 +1,8 @@
-#include "Shader.h"
-#include "Utils.h"
 #include <cmath>
-#include "Wrapper.h"
+
+#include "client/engine/Shader.h"
+#include "client/engine/Utils.h"
+#include "client/engine/Wrapper.h"
 
 void Shader::pop()
 {
@@ -66,4 +67,4 @@ void Shader::rotateZ(float degrees)
 void Shader::updateModelMatrix()
 {
     Engine::setModelMatrix(model.get().getValues());
-}
+}

+ 4 - 4
engine/Shader.h → client/engine/Shader.h

@@ -1,10 +1,10 @@
 #ifndef CAMERA_H
 #define CAMERA_H
 
-#include "../math/Plane3D.h"
-#include "../math/Vector3D.h"
-#include "../math/Matrix3D.h"
-#include "../math/Matrix3DStack.h"
+#include "client/math/Plane3D.h"
+#include "client/math/Vector3D.h"
+#include "client/math/Matrix3D.h"
+#include "client/math/Matrix3DStack.h"
 
 class Shader
 {

+ 2 - 3
engine/Texture.cpp → client/engine/Texture.cpp

@@ -1,7 +1,6 @@
-#include "Texture.h"
 #include <png.h>
 
-using namespace std;
+#include "client/engine/Texture.h"
 
 Texture::Texture(const char* path)
 {
@@ -101,7 +100,7 @@ bool Texture::load(const char* path, FILE* file)
     
     // allocate and set row pointer to correct places in block
     rowPointers = (unsigned int**) png_malloc(png, height * (sizeof(unsigned int*)));
-    for(int i = 0; i < height; i++)
+    for(unsigned int i = 0; i < height; i++)
     {
         rowPointers[i] = (data + i * width);
     }

+ 2 - 0
engine/Texture.h → client/engine/Texture.h

@@ -5,6 +5,8 @@
 #include <GLFW/glfw3.h>
 #include <iostream>
 
+using namespace std;
+
 class Texture
 {
 public:

+ 2 - 2
engine/Utils.cpp → client/engine/Utils.cpp

@@ -1,6 +1,6 @@
-#include "Utils.h"
+#include "client/engine/Utils.h"
 
 float interpolate(float lag, float from, float to)
 {
     return from + lag * (to - from);
-}
+}

+ 0 - 0
engine/Utils.h → client/engine/Utils.h


+ 2 - 1
engine/Wrapper.cpp → client/engine/Wrapper.cpp

@@ -1,8 +1,9 @@
-#include "Wrapper.h"
 #include <cmath>
 #include <chrono>
 #include <thread>
 
+#include "client/engine/Wrapper.h"
+
 DummyClient DummyClient::dummy;
 
 IClient* Engine::client = &DummyClient::dummy;

+ 14 - 12
engine/Wrapper.h → client/engine/Wrapper.h

@@ -3,24 +3,26 @@
 
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
-#include "shader/ShaderProgram.h"
-#include "../math/Vector3D.h"
-#include "../math/Matrix3D.h"
-#include "shader/WorldShader.h"
-#include "shader/SSAOShader.h"
-#include "shader/SSAOBlurShader.h"
-#include "shader/FramebufferRectangle.h"
-#include "shader/WorldPostShader.h"
-#include "shader/OverlayShader.h"
-#include "Mesh.h"
-#include "../engine/Shader.h"
 #include <iostream>
 
+#include "client/engine/shader/ShaderProgram.h"
+#include "client/math/Vector3D.h"
+#include "client/math/Matrix3D.h"
+#include "client/engine/shader/WorldShader.h"
+#include "client/engine/shader/SSAOShader.h"
+#include "client/engine/shader/SSAOBlurShader.h"
+#include "client/engine/shader/FramebufferRectangle.h"
+#include "client/engine/shader/WorldPostShader.h"
+#include "client/engine/shader/OverlayShader.h"
+#include "client/engine/Mesh.h"
+#include "client/engine/Shader.h"
+
 using namespace std;
 
 class IClient
 {
 public:
+    virtual ~IClient() = default;
     virtual void tick() = 0;
     virtual void render3DTick(float lag) = 0;
     virtual void render2DTick(float lag) = 0;
@@ -122,4 +124,4 @@ private:
     static OverlayShader overlayShader;
 };
 
-#endif
+#endif

+ 2 - 2
engine/shader/FramebufferRectangle.cpp → client/engine/shader/FramebufferRectangle.cpp

@@ -1,5 +1,5 @@
-#include "FramebufferRectangle.h"
-#include "../Wrapper.h"
+#include "client/engine/shader/FramebufferRectangle.h"
+#include "client/engine/Wrapper.h"
 
 FramebufferRectangle::FramebufferRectangle()
 {

+ 0 - 0
engine/shader/FramebufferRectangle.h → client/engine/shader/FramebufferRectangle.h


+ 4 - 4
engine/shader/OverlayShader.cpp → client/engine/shader/OverlayShader.cpp

@@ -1,5 +1,5 @@
-#include "OverlayShader.h"
-#include "../Wrapper.h"
+#include "client/engine/shader/OverlayShader.h"
+#include "client/engine/Wrapper.h"
 
 OverlayShader::OverlayShader()
 {
@@ -11,7 +11,7 @@ OverlayShader::~OverlayShader()
 
 bool OverlayShader::init()
 {
-    program.compile("shader/overlayVertex.vs", "shader/overlayFragment.fs");
+    program.compile("resources/shader/overlayVertex.vs", "resources/shader/overlayFragment.fs");
     if(!program.isValid())
     {
         return false;
@@ -88,4 +88,4 @@ void OverlayShader::setUseTexture(bool use)
 void OverlayShader::setUseColor(bool use)
 {
     glUniform1i(unifUseColor, use);
-}
+}

+ 3 - 3
engine/shader/OverlayShader.h → client/engine/shader/OverlayShader.h

@@ -1,8 +1,8 @@
 #ifndef OVERLAYSHADER_H
 #define OVERLAYSHADER_H
 
-#include "ShaderProgram.h"
-#include "../../math/Matrix3D.h"
+#include "client/engine/shader/ShaderProgram.h"
+#include "client/math/Matrix3D.h"
 
 class OverlayShader
 {
@@ -31,4 +31,4 @@ private:
     GLint unifModelMatrix = 0;
 };
 
-#endif
+#endif

+ 4 - 4
engine/shader/SSAOBlurShader.cpp → client/engine/shader/SSAOBlurShader.cpp

@@ -1,5 +1,5 @@
-#include "SSAOBlurShader.h"
-#include "../Wrapper.h"
+#include "client/engine/shader/SSAOBlurShader.h"
+#include "client/engine/Wrapper.h"
 
 SSAOBlurShader::SSAOBlurShader()
 {
@@ -13,7 +13,7 @@ SSAOBlurShader::~SSAOBlurShader()
 
 bool SSAOBlurShader::init()
 {
-    program.compile("shader/ssaoBlurVertex.vs", "shader/ssaoBlurFragment.fs");
+    program.compile("resources/shader/ssaoBlurVertex.vs", "resources/shader/ssaoBlurFragment.fs");
     if(!program.isValid())
     {
         return false;
@@ -70,4 +70,4 @@ void SSAOBlurShader::bindTexture(unsigned int textureUnit)
 {
     glActiveTexture(GL_TEXTURE0 + textureUnit);
     glBindTexture(GL_TEXTURE_2D, texture);
-}
+}

+ 1 - 1
engine/shader/SSAOBlurShader.h → client/engine/shader/SSAOBlurShader.h

@@ -1,7 +1,7 @@
 #ifndef SSAOBLURSHADER_H
 #define SSAOBLURSHADER_H
 
-#include "ShaderProgram.h"
+#include "client/engine/shader/ShaderProgram.h"
 
 class SSAOBlurShader
 {

+ 5 - 4
engine/shader/SSAOShader.cpp → client/engine/shader/SSAOShader.cpp

@@ -1,7 +1,8 @@
-#include "SSAOShader.h"
-#include "../Wrapper.h"
 #include <random>
 
+#include "client/engine/shader/SSAOShader.h"
+#include "client/engine/Wrapper.h"
+
 SSAOShader::SSAOShader()
 {
 }
@@ -15,7 +16,7 @@ SSAOShader::~SSAOShader()
 
 bool SSAOShader::init()
 {
-    program.compile("shader/ssaoVertex.vs", "shader/ssaoFragment.fs");
+    program.compile("resources/shader/ssaoVertex.vs", "resources/shader/ssaoFragment.fs");
     if(!program.isValid())
     {
         return false;
@@ -132,4 +133,4 @@ void SSAOShader::setSampleRadius(float sampleRadius)
 float SSAOShader::getSampleRadius() const
 {
     return radius;
-}
+}

+ 1 - 1
engine/shader/SSAOShader.h → client/engine/shader/SSAOShader.h

@@ -1,7 +1,7 @@
 #ifndef SSAOSHADER_H
 #define SSAOSHADER_H
 
-#include "ShaderProgram.h"
+#include "client/engine/shader/ShaderProgram.h"
 
 class SSAOShader
 {

+ 2 - 1
engine/shader/ShaderProgram.cpp → client/engine/shader/ShaderProgram.cpp

@@ -1,7 +1,8 @@
-#include "ShaderProgram.h"
 #include <fstream>
 #include <cstring>
 
+#include "client/engine/shader/ShaderProgram.h"
+
 ShaderProgram::ShaderProgram()
 {
 }

+ 0 - 0
engine/shader/ShaderProgram.h → client/engine/shader/ShaderProgram.h


+ 4 - 4
engine/shader/WorldPostShader.cpp → client/engine/shader/WorldPostShader.cpp

@@ -1,5 +1,5 @@
-#include "WorldPostShader.h"
-#include "../Wrapper.h"
+#include "client/engine/shader/WorldPostShader.h"
+#include "client/engine/Wrapper.h"
 
 WorldPostShader::WorldPostShader()
 {
@@ -13,7 +13,7 @@ WorldPostShader::~WorldPostShader()
 
 bool WorldPostShader::init()
 {
-    program.compile("shader/worldPostVertex.vs", "shader/worldPostFragment.fs");
+    program.compile("resources/shader/worldPostVertex.vs", "resources/shader/worldPostFragment.fs");
     if(!program.isValid())
     {
         return false;
@@ -69,4 +69,4 @@ void WorldPostShader::bindTexture(unsigned int textureUnit)
 {
     glActiveTexture(GL_TEXTURE0 + textureUnit);
     glBindTexture(GL_TEXTURE_2D, texture);
-}
+}

+ 1 - 1
engine/shader/WorldPostShader.h → client/engine/shader/WorldPostShader.h

@@ -1,7 +1,7 @@
 #ifndef WORLDPOSTSHADER_H
 #define WORLDPOSTSHADER_H
 
-#include "ShaderProgram.h"
+#include "client/engine/shader/ShaderProgram.h"
 
 class WorldPostShader
 {

+ 3 - 3
engine/shader/WorldShader.cpp → client/engine/shader/WorldShader.cpp

@@ -1,5 +1,5 @@
-#include "WorldShader.h"
-#include "../Wrapper.h"
+#include "client/engine/shader/WorldShader.h"
+#include "client/engine/Wrapper.h"
 
 WorldShader::WorldShader()
 {
@@ -16,7 +16,7 @@ WorldShader::~WorldShader()
 
 bool WorldShader::init()
 {
-    program.compile("shader/worldVertex.vs", "shader/worldFragment.fs");
+    program.compile("resources/shader/worldVertex.vs", "resources/shader/worldFragment.fs");
     if(!program.isValid())
     {
         return false;

+ 1 - 1
engine/shader/WorldShader.h → client/engine/shader/WorldShader.h

@@ -1,7 +1,7 @@
 #ifndef WORLDSHADER_H
 #define WORLDSHADER_H
 
-#include "ShaderProgram.h"
+#include "client/engine/shader/ShaderProgram.h"
 
 class WorldShader
 {

+ 5 - 4
math/Camera3D.cpp → client/math/Camera3D.cpp

@@ -1,7 +1,8 @@
-#include "Camera3D.h"
-#include "../engine/Wrapper.h"
 #include <cmath>
-#include "../engine/Utils.h"
+
+#include "client/math/Camera3D.h"
+#include "client/engine/Wrapper.h"
+#include "client/engine/Utils.h"
 
 Camera3D::Camera3D()
 {
@@ -238,4 +239,4 @@ bool Camera3D::isInFrustum(float x, float y, float z, float x2, float y2, float
         }
     }
     return true;
-}
+}

+ 3 - 3
math/Camera3D.h → client/math/Camera3D.h

@@ -1,9 +1,9 @@
 #ifndef CAMERA3D_H
 #define CAMERA3D_H
 
-#include "Vector3D.h"
-#include "Matrix3D.h"
-#include "Plane3D.h"
+#include "client/math/Vector3D.h"
+#include "client/math/Matrix3D.h"
+#include "client/math/Plane3D.h"
 
 class Camera3D
 {

+ 2 - 1
math/Matrix3D.cpp → client/math/Matrix3D.cpp

@@ -1,7 +1,8 @@
-#include "Matrix3D.h"
 #include <cstring>
 #include <cmath>
 
+#include "client/math/Matrix3D.h"
+
 Matrix3D::Matrix3D()
 {
     setToIdentity();

+ 0 - 0
math/Matrix3D.h → client/math/Matrix3D.h


+ 3 - 3
math/Matrix3DStack.cpp → client/math/Matrix3DStack.cpp

@@ -1,6 +1,6 @@
-#include "Matrix3DStack.h"
-#include "StackOverflow.h"
-#include "StackUnderflow.h"
+#include "client/math/Matrix3DStack.h"
+#include "client/math/StackOverflow.h"
+#include "client/math/StackUnderflow.h"
 
 Matrix3DStack::Matrix3DStack()
 {

+ 1 - 1
math/Matrix3DStack.h → client/math/Matrix3DStack.h

@@ -1,7 +1,7 @@
 #ifndef MATRIX3DSTACK_H
 #define MATRIX3DSTACK_H
 
-#include "Matrix3D.h"
+#include "client/math/Matrix3D.h"
 
 class Matrix3DStack
 {

+ 3 - 2
math/Plane3D.cpp → client/math/Plane3D.cpp

@@ -1,6 +1,7 @@
-#include "Plane3D.h"
 #include <iostream>
 
+#include "client/math/Plane3D.h"
+
 using namespace std;
 
 Plane3D::Plane3D()
@@ -25,4 +26,4 @@ void Plane3D::set(const Vector3D& va, const Vector3D& vb, const Vector3D& vc)
 float Plane3D::getSignedDistance(float x, float y, float z) const
 {
     return x * a + y * b + z * c + d;
-}
+}

+ 2 - 2
math/Plane3D.h → client/math/Plane3D.h

@@ -1,7 +1,7 @@
 #ifndef PLANE3D_H
 #define PLANE3D_H
 
-#include "Vector3D.h"
+#include "client/math/Vector3D.h"
 
 class Plane3D
 {
@@ -18,4 +18,4 @@ private:
     float d = 1.0f;
 };
 
-#endif
+#endif

+ 1 - 1
math/StackOverflow.cpp → client/math/StackOverflow.cpp

@@ -1,4 +1,4 @@
-#include "StackOverflow.h"
+#include "client/math/StackOverflow.h"
 
 StackOverflow::StackOverflow()
 {

+ 0 - 0
math/StackOverflow.h → client/math/StackOverflow.h


+ 1 - 1
math/StackUnderflow.cpp → client/math/StackUnderflow.cpp

@@ -1,4 +1,4 @@
-#include "StackUnderflow.h"
+#include "client/math/StackUnderflow.h"
 
 StackUnderflow::StackUnderflow()
 {

+ 0 - 0
math/StackUnderflow.h → client/math/StackUnderflow.h


+ 2 - 1
math/Vector3D.cpp → client/math/Vector3D.cpp

@@ -1,6 +1,7 @@
-#include "Vector3D.h"
 #include <cmath>
 
+#include "client/math/Vector3D.h"
+
 Vector3D::Vector3D() : x(0), y(0), z(0)
 {
 }

+ 0 - 0
math/Vector3D.h → client/math/Vector3D.h


+ 3 - 2
network/client/Client.cpp → client/network/Client.cpp

@@ -1,4 +1,3 @@
-#include "Client.h"
 #include <iostream>
 #include <sys/socket.h>
 #include <arpa/inet.h>
@@ -6,7 +5,9 @@
 #include <stdexcept>
 #include <unistd.h>
 #include <poll.h>
-#include "../stream/Stream.h"
+
+#include "client/network/Client.h"
+#include "common/stream/Stream.h"
 
 Client::Client()
 {

+ 2 - 1
network/client/Client.h → client/network/Client.h

@@ -3,7 +3,8 @@
 
 #include <string>
 #include <thread>
-#include "IClientListener.h"
+
+#include "client/network/IClientListener.h"
 
 using namespace std;
 

+ 1 - 2
network/client/ClientListener.cpp → client/network/ClientListener.cpp

@@ -1,5 +1,4 @@
-#include "ClientListener.h"
-#include <iostream>
+#include "client/network/ClientListener.h"
 
 void ClientListener::onServerJoin(int serverSocket)
 {

+ 1 - 1
network/client/ClientListener.h → client/network/ClientListener.h

@@ -1,7 +1,7 @@
 #ifndef CLIENTLISTENER_H
 #define CLIENTLISTENER_H
 
-#include "IClientListener.h"
+#include "client/network/IClientListener.h"
 
 class ClientListener : public IClientListener
 {

+ 2 - 1
network/client/IClientListener.h → client/network/IClientListener.h

@@ -1,11 +1,12 @@
 #ifndef ICLIENTLISTENER_H
 #define ICLIENTLISTENER_H
 
-#include "../stream/Stream.h"
+#include "common/stream/Stream.h"
 
 class IClientListener
 {
 public:
+    virtual ~IClientListener() = default;
     virtual void onServerJoin(int serverSocket) = 0;
     virtual void onServerPackage(int serverSocket, Stream& in) = 0;
     virtual void onServerClose(int socket) = 0;

+ 4 - 4
client/rendering/ChunkRenderer.cpp

@@ -1,6 +1,6 @@
-#include "ChunkRenderer.h"
-#include "block/BlockRenderers.h"
-#include "block/BlockRenderer.h"
+#include "client/rendering/ChunkRenderer.h"
+#include "client/rendering/block/BlockRenderers.h"
+#include "client/rendering/block/BlockRenderer.h"
 
 ChunkRenderer::ChunkRenderer() : blockTexture("resources/textures.png")
 {
@@ -98,4 +98,4 @@ void ChunkRenderer::buildChunk(int partionY, Chunk& c, Chunk* north, Chunk* east
     }
     
     m.build();
-}
+}

+ 6 - 6
client/rendering/ChunkRenderer.h

@@ -1,12 +1,12 @@
 #ifndef CHUNKRENDERER_H
 #define CHUNKRENDERER_H
 
-#include "../../engine/Mesh.h"
-#include "../../engine/Shader.h"
-#include "../../engine/Texture.h"
-#include "../../engine/DirectRenderer.h"
-#include "../../world/IChunkListener.h"
-#include "../../math/Camera3D.h"
+#include "client/engine/Mesh.h"
+#include "client/engine/Shader.h"
+#include "client/engine/Texture.h"
+#include "client/engine/DirectRenderer.h"
+#include "common/world/IChunkListener.h"
+#include "client/math/Camera3D.h"
 
 class ChunkRenderer : public IChunkListener
 {

+ 1 - 1
client/rendering/ClientChunkProvider.cpp

@@ -1,4 +1,4 @@
-#include "ClientChunkProvider.h"
+#include "client/rendering/ClientChunkProvider.h"
 
 ClientChunkProvider::ClientChunkProvider()
 {

+ 1 - 1
client/rendering/ClientChunkProvider.h

@@ -1,7 +1,7 @@
 #ifndef CLIENTCHUNKPROVIDER_H
 #define CLIENTCHUNKPROVIDER_H
 
-#include "../../world/IChunkProvider.h"
+#include "common/world/IChunkProvider.h"
 
 class ClientChunkProvider : public IChunkProvider
 {

+ 3 - 3
client/rendering/block/BlockRenderer.cpp

@@ -1,5 +1,5 @@
-#include "BlockRenderer.h"
-#include "../../../utils/Face.h"
+#include "client/rendering/block/BlockRenderer.h"
+#include "common/utils/Face.h"
 
 BlockRenderer::BlockRenderer()
 {
@@ -168,4 +168,4 @@ void BlockRenderer::addToMesh(Mesh& m, int offsetX, int offsetY, int offsetZ, in
             m.addTexture(tri.p3texX, tri.p3texY);
         }
     }
-}
+}

+ 2 - 1
client/rendering/block/BlockRenderer.h

@@ -2,7 +2,8 @@
 #define BLOCKRENDERER_H
 
 #include <vector>
-#include "../../../engine/Mesh.h"
+
+#include "client/engine/Mesh.h"
 
 using namespace std;
 

+ 1 - 1
client/rendering/block/BlockRenderers.cpp

@@ -1,4 +1,4 @@
-#include "BlockRenderers.h"
+#include "client/rendering/block/BlockRenderers.h"
 
 const int BlockRenderers::RENDERER_AMOUNT = 4;
 BlockRenderer BlockRenderers::RENDERER[RENDERER_AMOUNT];

+ 2 - 2
client/rendering/block/BlockRenderers.h

@@ -1,8 +1,8 @@
 #ifndef BLOCKRENDERERS_H
 #define BLOCKRENDERERS_H
 
-#include "../../../block/Block.h"
-#include "BlockRenderer.h"
+#include "common/block/Block.h"
+#include "client/rendering/block/BlockRenderer.h"
 
 class BlockRenderers
 {

+ 3 - 3
client/rendering/entity/EntityRenderer.cpp

@@ -1,5 +1,5 @@
-#include "EntityRenderer.h"
-#include "../../../engine/Utils.h"
+#include "client/rendering/entity/EntityRenderer.h"
+#include "client/engine/Utils.h"
 
 EntityRenderer::EntityRenderer() : texture("resources/skin.png")
 {
@@ -130,4 +130,4 @@ void EntityRenderer::renderTick(Shader& shader, Camera3D camera, DirectRenderer&
     shader.updateModelMatrix(); 
     mesh.draw(180, 36);
     shader.pop();
-}
+}

+ 5 - 5
client/rendering/entity/EntityRenderer.h

@@ -1,11 +1,11 @@
 #ifndef ENTITYRENDERER_H
 #define ENTITYRENDERER_H
 
-#include "../../../engine/Shader.h"
-#include "../../../math/Camera3D.h"
-#include "../../../engine/DirectRenderer.h"
-#include "../../../engine/Mesh.h"
-#include "../../../engine/Texture.h"
+#include "client/engine/Shader.h"
+#include "client/math/Camera3D.h"
+#include "client/engine/DirectRenderer.h"
+#include "client/engine/Mesh.h"
+#include "client/engine/Texture.h"
 
 class EntityRenderer
 {

+ 1 - 1
client/rendering/gui/GUI.cpp

@@ -1,4 +1,4 @@
-#include "GUI.h"
+#include "client/rendering/gui/GUI.h"
 
 GUI::GUI()
 {

+ 4 - 4
client/rendering/gui/GUI.h

@@ -5,10 +5,10 @@
 #include <GL/glew.h>
 #include <GLFW/glfw3.h>
 
-#include "../../../engine/KeyManager.h"
-#include "../../../engine/MouseManager.h"
-#include "../../../engine/Shader.h"
-#include "../../../engine/DirectRenderer.h"
+#include "client/engine/KeyManager.h"
+#include "client/engine/MouseManager.h"
+#include "client/engine/Shader.h"
+#include "client/engine/DirectRenderer.h"
 
 class GUI
 {

+ 1 - 1
client/rendering/gui/StartMenu.cpp

@@ -1,4 +1,4 @@
-#include "StartMenu.h"
+#include "client/rendering/gui/StartMenu.h"
 
 StartMenu::StartMenu()
 {

+ 1 - 1
client/rendering/gui/StartMenu.h

@@ -1,7 +1,7 @@
 #ifndef STARTMENU_H
 #define STARTMENU_H
 
-#include "GUI.h"
+#include "client/rendering/gui/GUI.h"
 
 class StartMenu : public GUI
 {

+ 2 - 2
block/Block.cpp → common/block/Block.cpp

@@ -1,7 +1,7 @@
-#include "Block.h"
-
 #include <iostream>
 
+#include "common/block/Block.h"
+
 using namespace std;
 
 BlockId Block::idCounter = 0;

+ 1 - 1
block/Block.h → common/block/Block.h

@@ -1,7 +1,7 @@
 #ifndef BLOCK_H
 #define BLOCK_H
 
-#include "../utils/Face.h"
+#include "common/utils/Face.h"
 
 typedef unsigned short BlockId;
 

+ 1 - 1
block/BlockAir.cpp → common/block/BlockAir.cpp

@@ -1,4 +1,4 @@
-#include "BlockAir.h"
+#include "common/block/BlockAir.h"
 
 BlockAir::BlockAir()
 {

+ 1 - 1
block/BlockAir.h → common/block/BlockAir.h

@@ -1,7 +1,7 @@
 #ifndef BLOCKAIR_H
 #define BLOCKAIR_H
 
-#include "Block.h"
+#include "common/block/Block.h"
 
 class BlockAir : public Block
 {

+ 1 - 1
block/Blocks.cpp → common/block/Blocks.cpp

@@ -1,4 +1,4 @@
-#include "Blocks.h"
+#include "common/block/Blocks.h"
 
 const int BlockRegistry::BLOCK_AMOUNT = 4;
 const Block* BlockRegistry::BLOCKS[BLOCK_AMOUNT];

+ 2 - 2
block/Blocks.h → common/block/Blocks.h

@@ -1,8 +1,8 @@
 #ifndef BLOCKS_H
 #define BLOCKS_H
 
-#include "Block.h"
-#include "BlockAir.h"
+#include "common/block/Block.h"
+#include "common/block/BlockAir.h"
 
 class BlockRegistry
 {

+ 4 - 3
network/stream/Stream.cpp → common/stream/Stream.cpp

@@ -1,4 +1,4 @@
-#include "Stream.h"
+#include "common/stream/Stream.h"
 #include <stdexcept>
 #include <iostream>
 #include <cstring>
@@ -26,6 +26,7 @@ size_t Stream::getSize(size_t minSize)
     {
         throw runtime_error("size exceeds max possible size");
     }
+    return size;
 }
 
 bool Stream::hasData() const
@@ -172,7 +173,7 @@ void Stream::readSocket(int socket)
     readIndex = 0;
     
     size_t bufferOffset = 0;
-    size_t freeSpace = dataLength - writeIndex;
+    ssize_t freeSpace = dataLength - writeIndex;
     
     while(true)
     {
@@ -211,4 +212,4 @@ void Stream::sendToSocket(int socket)
         sendLength -= writtenLength;
         bufferOffset += writtenLength;
     }
-}
+}

+ 0 - 0
network/stream/Stream.h → common/stream/Stream.h


+ 1 - 1
utils/Face.cpp → common/utils/Face.cpp

@@ -1,4 +1,4 @@
-#include "Face.h"
+#include "common/utils/Face.h"
 
 Face Face::FACES[6] =
 {

+ 2 - 3
utils/Face.h → common/utils/Face.h

@@ -23,21 +23,20 @@ public:
     static Face& WEST;
     
     static int getCullData(bool up, bool down, bool north, bool south, bool east, bool west);
-
         
 private:
     Face(int index, int offsetX, int offsetY, int offsetZ, int cullBit, const char* name);
     
     static Face FACES[6];
     
+    int index;
+    
     int offsetX;
     int offsetY;
     int offsetZ;
     
     int cullBit;
     
-    int index;
-    
     const char* name;
 };
 

+ 4 - 4
world/Chunk.cpp → common/world/Chunk.cpp

@@ -1,10 +1,10 @@
-#include "Chunk.h"
 #include <cstdlib>
 #include <cmath>
-#include "../block/Blocks.h"
-
 #include <iostream>
 
+#include "common/world/Chunk.h"
+#include "common/block/Blocks.h"
+
 using namespace std;
 
 Chunk::Chunk(int chunkX, int chunkZ) : chunkX(chunkX), chunkZ(chunkZ)
@@ -95,4 +95,4 @@ void Chunk::clearDirtyFlag(int index)
     {
         dirty[index] = false;
     }
-}
+}

+ 1 - 1
world/Chunk.h → common/world/Chunk.h

@@ -1,7 +1,7 @@
 #ifndef CHUNK_H
 #define CHUNK_H
 
-#include "../block/Block.h"
+#include "common/block/Block.h"
 
 class Chunk
 {

+ 2 - 1
world/IChunkListener.h → common/world/IChunkListener.h

@@ -1,11 +1,12 @@
 #ifndef ICHUNKLISTENER_H
 #define ICHUNKLISTENER_H
 
-#include "Chunk.h"
+#include "common/world/Chunk.h"
 
 class IChunkListener
 {
 public:
+    virtual ~IChunkListener() = default;
     virtual void updateChunk(Chunk& c, Chunk* north, Chunk* east, Chunk* south, Chunk* west) = 0;
 };
 

+ 3 - 2
world/IChunkProvider.h → common/world/IChunkProvider.h

@@ -1,14 +1,15 @@
 #ifndef ICHUNKPROVIDER_H
 #define ICHUNKPROVIDER_H
 
-#include "Chunk.h"
+#include "common/world/Chunk.h"
 
 class IChunkProvider
 {
 public:
+    virtual ~IChunkProvider() = default;
     virtual Chunk* getChunk(int x, int z) = 0;
     virtual bool isChunkLoaded(int x, int z) const = 0;
     virtual void forEachLoadedChunk(void* data, void (*fun) (Chunk&, void*)) const = 0;
 };
 
-#endif
+#endif

+ 5 - 5
world/World.cpp → common/world/World.cpp

@@ -1,4 +1,4 @@
-#include "World.h"
+#include "common/world/World.h"
 
 World::World(IChunkProvider* chunks) : chunks(chunks)
 {
@@ -11,12 +11,12 @@ World::~World()
 
 void World::registerChunkListener(IChunkListener* listener)
 {
-    chunkListener.add(listener);
+    chunkListener.push_back(listener);
 }
 
 void World::removeChunkListener(IChunkListener* listener)
 {
-    chunkListener.remove(listener);
+    //chunkListener.remove(listener);
 }
 
 void World::updateDirtyChunks()
@@ -40,9 +40,9 @@ void World::updateChunk(Chunk& c)
     Chunk* south = chunks->getChunk(x - 1, z);
     Chunk* west = chunks->getChunk(x, z - 1);
     
-    for(int i = 0; i < chunkListener.getSize(); i++)
+    for(unsigned long i = 0; i < chunkListener.size(); i++)
     {
-        chunkListener.get(i, nullptr)->updateChunk(c, north, east, south, west);
+        chunkListener[i]->updateChunk(c, north, east, south, west);
     }
 }
 

+ 6 - 5
world/World.h → common/world/World.h

@@ -2,10 +2,11 @@
 #define WORLD_H
 
 #include <iostream>
-#include "Chunk.h"
-#include "IChunkProvider.h"
-#include "IChunkListener.h"
-#include "../data/UnsortedArrayList.h"
+#include <vector>
+
+#include "common/world/Chunk.h"
+#include "common/world/IChunkProvider.h"
+#include "common/world/IChunkListener.h"
 
 using namespace std;
 
@@ -22,7 +23,7 @@ public:
 private:
     void updateChunk(Chunk& c);
     
-    UnsortedArrayList<IChunkListener*> chunkListener;
+    vector<IChunkListener*> chunkListener;
     IChunkProvider* chunks;
 };
 

+ 0 - 348
data/HashMap.h

@@ -1,348 +0,0 @@
-#ifndef HASHMAP_H
-#define HASHMAP_H
-
-#include <iostream>
-
-constexpr static int NUMBER_OF_PRIMES = 26;
-constexpr static int PRIMES[26] = 
-{
-    17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719,
-    175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
-    44917381, 89834777, 179669557, 359339171, 718678369
-};
-
-template<class K, class V>
-class HashMap
-{
-public:
-    HashMap(int initialLoad, unsigned int (*hasher)(K)) : hasher(hasher)
-    {
-        primeIndex = getHigherPrimeIndex(initialLoad);
-        capacity = PRIMES[primeIndex];
-        resizeCap = (capacity >> 2) * 3;
-        
-        data = new Node*[capacity];
-        for(int i = 0; i < capacity; i++)
-        {
-            data[i] = nullptr;
-        }
-        entries = 0;
-    }
-    
-    ~HashMap()
-    {
-        for(int i = 0; i < capacity; i++)
-        {
-            Node* n = data[i];
-            while(n != nullptr)
-            {
-                Node* next = n->next;
-                delete n;
-                n = next;
-            }
-        }
-        delete[] data;
-    }
-    
-    int getCapacity() const
-    {
-        return capacity;
-    }
-    
-    int getSize() const
-    {
-        return entries;
-    }
-    
-    void put(K k, V v)
-    {
-        ensureCapacity();
-        unsigned int hash = hasher(k) % capacity;
-        if(data[hash] == nullptr)
-        {
-            data[hash] = new Node(k, v);
-            entries++;
-        }
-        else
-        {
-            Node* n = data[hash];
-            while(true)
-            {
-                if(n->k == k)
-                {
-                    n->v = v;
-                    break;
-                }
-                else if(n->next == nullptr)
-                {
-                    n->next = new Node(k, v);
-                    entries++;
-                    break;
-                }
-                n = n->next;
-            }
-        }
-    }
-    
-    V remove(K k, V notFound)
-    {
-        unsigned int hash = hasher(k) % capacity;
-        if(data[hash] == nullptr)
-        {
-            return notFound;
-        }
-        else
-        {
-            Node* n = data[hash];
-            if(n->k == k)
-            {
-                V v = n->v;
-                data[hash] = n->next;
-                delete n;
-                entries--;
-                return v;
-            }
-            
-            while(n->next != nullptr)
-            {
-                if(n->next->k == k)
-                {
-                    Node* n = n->next;
-                    n->next = n->next->next;
-                    V v = n->v;
-                    delete n;
-                    entries--;
-                    return v;
-                }
-            }
-            return notFound;
-        }
-    }
-    
-    bool remove(K k)
-    {
-        unsigned int hash = hasher(k) % capacity;
-        if(data[hash] == nullptr)
-        {
-            return false;
-        }
-        else
-        {
-            Node* n = data[hash];
-            if(n->k == k)
-            {
-                data[hash] = n->next;
-                delete n;
-                entries--;
-                return true;
-            }
-            
-            while(n->next != nullptr)
-            {
-                if(n->next->k == k)
-                {
-                    Node* n = n->next;
-                    n->next = n->next->next;
-                    delete n;
-                    entries--;
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-    
-    V get(K k, V error) const
-    {
-        unsigned int hash = hasher(k) % capacity;
-        if(data[hash] == nullptr)
-        {
-            return error;
-        }
-        else
-        {
-            for(Node* n = data[hash]; n != nullptr; n = n->next)
-            {
-                if(n->k == k)
-                {
-                    return n->v;
-                }
-            }
-            return error;
-        }
-    }
-    
-    void clear()
-    {
-        for(int i = 0; i < capacity; i++)
-        {
-            Node* n = data[i];
-            while(n != nullptr)
-            {
-                Node* next = n->next;
-                delete n;
-                n = next;
-            }
-            data[i] = nullptr;
-        }
-        entries = 0;
-    }
-    
-    void print() const
-    {
-        for(int i = 0; i < capacity; i++)
-        {
-            Node* n = data[i];
-            std::cout << i << ": ";
-            if(n != nullptr)
-            {
-                std::cout << "(" << n->k << " = " << n->v << ")";
-                while(n->next != nullptr)
-                {
-                    n = n->next;
-                    std::cout << " -> (" << n->k << " = " << n->v << ")";
-                }
-            }
-            std::cout << std::endl;
-        }
-    }
-    
-    void printStats() const
-    {
-        int fill = capacity;
-        int cells = capacity;
-        for(int i = 0; i < capacity; i++)
-        {
-            Node* n = data[i];
-            if(n != nullptr)
-            {
-                while(n->next != nullptr)
-                {
-                    fill++;
-                    n = n->next;
-                }
-            }
-        }
-        std::cout << (double) fill / cells << std::endl;
-    }
-    
-private:
-    class Node
-    {
-    public:
-        Node* next = nullptr;
-        K k;
-        V v;
-        
-        Node(K k, V v) : k(k), v(v) 
-        {
-        }
-    };  
-    
-    int getHigherPrimeIndex(int lower) const
-    {
-        int low = 0;
-        int high = NUMBER_OF_PRIMES - 1;
-        int mid;
-        while(true)
-        {
-            if(low == high)
-            {
-                return low;
-            }
-            mid = (high + low) >> 1;
-            if(PRIMES[mid] >= lower)
-            {
-                high = mid;
-            }
-            else
-            {
-                low = mid + 1;
-            }
-        }
-    }
-    
-    void ensureCapacity()
-    {
-        if(entries < resizeCap)
-        {
-            return;
-        }
-        
-        primeIndex++;
-        if(primeIndex >= NUMBER_OF_PRIMES)
-        {
-            return;
-        }
-        
-        int oldCapacity = capacity;
-        capacity = PRIMES[primeIndex];
-        
-        //std::cout << "resize from " << oldCapacity << " to " << capacity << std::endl; 
-        
-        resizeCap = (capacity >> 2) * 3;
-        
-        Node** newData = new Node*[capacity];
-        for(int i = 0; i < capacity; i++)
-        {
-            newData[i] = nullptr;
-        }
-        
-        for(int i = 0; i < oldCapacity; i++)
-        {
-            Node* old = data[i];
-            if(old != nullptr)
-            {
-                unsigned int hash = hasher(old->k) % capacity;
-                Node* n = newData[hash];
-                if(n == nullptr)
-                {
-                    newData[hash] = old;
-                }
-                else
-                {
-                    while(n->next != nullptr)
-                    {
-                        n = n->next;
-                    }
-                    n->next = old;
-                }
-                
-                while(old->next != nullptr)
-                {
-                    n = old->next;
-                    old->next = nullptr;
-                    hash = hasher(n->k) % capacity;
-                    Node* m = newData[hash];
-                    if(m == nullptr)
-                    {
-                        newData[hash] = n;
-                    }
-                    else
-                    {
-                        while(m->next != nullptr)
-                        {
-                            m = m->next;
-                        }
-                        m->next = n;
-                    }
-                    old = n;
-                }
-            }
-        }
-        
-        delete[] data;
-        data = newData;
-    }
-    
-    unsigned int (*hasher)(K); 
-    
-    int primeIndex;
-    int capacity;
-    int resizeCap;
-    
-    Node** data;
-    int entries;
-};
-
-#endif

+ 0 - 98
data/UnsortedArrayList.h

@@ -1,98 +0,0 @@
-#ifndef UNSORTEDARRAYLIST_H
-#define UNSORTEDARRAYLIST_H
-
-#include <cstring>
-#include <iostream>
-
-template<class E>
-class UnsortedArrayList
-{
-public:
-    UnsortedArrayList()
-    {
-        data = new E[capacity];
-    }
-    
-    virtual ~UnsortedArrayList()
-    {
-        delete[] data;
-    }
-    
-    int getSize() const
-    {
-        return size;
-    }
-    
-    void add(E e)
-    {
-        if(capacity <= size)
-        {
-            capacity *= 2;
-            E* newData = new E[capacity];
-            memcpy(newData, data, sizeof(E) * size);
-            delete[] data;
-            data = newData;
-        }
-        data[size] = e;
-        size++;
-    }
-    
-    void remove(E e)
-    {
-        int i = 0;
-        while(i < size)
-        {
-            if(e == data[i])
-            {
-                if(i == size - 1)
-                {
-                    memset(data + i, 0, sizeof(E));
-                }
-                else
-                {
-                    data[i] = data[size - 1];
-                    memset(data + size - 1, 0, sizeof(E));
-                }
-                size--;
-            }
-            else
-            {
-                i++;
-            }
-        }
-    }
-    
-    void removeIndex(int index)
-    {
-        if(index >= 0 && index < size)
-        {
-            if(size == 1 || index == size - 1)
-            {
-                memset(data + index, 0, sizeof(E));
-            }
-            else
-            {
-                data[index] = data[size - 1];
-                memset(data + size - 1, 0, sizeof(E));
-            }
-            size--;
-        }
-    }
-    
-    E get(int index, E error) const
-    {
-        if(index >= 0 && index < size)
-        {
-            return data[index];
-        }
-        return error;
-    }
-    
-private:
-    int size = 0;
-    int capacity = 1;
-    E* data;
-};
-
-#endif
-

+ 28 - 0
meson.build

@@ -0,0 +1,28 @@
+project('cubes plus plus', 'cpp')
+
+sourcesCommon = ['common/stream/Stream.cpp', 'common/utils/Face.cpp', 'common/block/Block.cpp', 'common/block/Blocks.cpp', 'common/block/BlockAir.cpp', 'common/world/Chunk.cpp', 'common/world/World.cpp']
+
+sourcesServer = ['server/Main.cpp', 'server/GameServer.cpp', 'server/network/Server.cpp', 'server/CommandManager.cpp', 'server/commands/BaseCommand.cpp', 'server/commands/TestCommand.cpp', 'server/CommandUtils.cpp']
+
+sourcesClient = ['client/Main.cpp', 'client/engine/Clock.cpp', 'client/engine/DirectRenderer.cpp', 'client/engine/KeyManager.cpp', 'client/engine/Mesh.cpp', 'client/engine/MouseManager.cpp', 'client/engine/Shader.cpp', 'client/engine/Texture.cpp', 'client/engine/Utils.cpp', 'client/engine/Wrapper.cpp', 'client/engine/shader/ShaderProgram.cpp', 'client/engine/shader/WorldShader.cpp', 'client/engine/shader/FramebufferRectangle.cpp', 'client/engine/shader/SSAOShader.cpp', 'client/engine/shader/SSAOBlurShader.cpp', 'client/engine/shader/WorldPostShader.cpp', 'client/engine/shader/OverlayShader.cpp', 'client/GameClient.cpp', 'client/rendering/ChunkRenderer.cpp', 'client/rendering/ClientChunkProvider.cpp', 'client/rendering/block/BlockRenderer.cpp', 'client/rendering/block/BlockRenderers.cpp', 'client/rendering/entity/EntityRenderer.cpp', 'client/rendering/gui/GUI.cpp', 'client/rendering/gui/StartMenu.cpp', 'client/math/Matrix3D.cpp', 'client/math/Matrix3DStack.cpp', 'client/math/StackOverflow.cpp', 'client/math/StackUnderflow.cpp', 'client/math/Vector3D.cpp', 'client/math/Plane3D.cpp', 'client/math/Camera3D.cpp', 'client/network/Client.cpp', 'client/network/ClientListener.cpp']
+
+sourcesTest = ['tests/Main.cpp', 'server/CommandUtils.cpp']
+
+threadDep = dependency('threads')
+glewDep = dependency('glew')
+glfwDep = dependency('glfw3')
+pngDep = dependency('libpng')
+
+executable('game_server', 
+    sources: sourcesCommon + sourcesServer,
+    dependencies : threadDep)
+    
+executable('game_tests', 
+    sources: sourcesTest)
+    
+executable('game_client', 
+    sources: sourcesCommon + sourcesClient,
+    dependencies : [threadDep, glewDep, glfwDep, pngDep])
+    
+
+	

+ 0 - 0
shader/fragment.fs → resources/shader/fragment.fs


+ 0 - 0
shader/overlayFragment.fs → resources/shader/overlayFragment.fs


+ 0 - 0
shader/overlayVertex.vs → resources/shader/overlayVertex.vs


+ 0 - 0
shader/ssaoBlurFragment.fs → resources/shader/ssaoBlurFragment.fs


+ 0 - 0
shader/ssaoBlurVertex.vs → resources/shader/ssaoBlurVertex.vs


+ 0 - 0
shader/ssaoFragment.fs → resources/shader/ssaoFragment.fs


+ 0 - 0
shader/ssaoVertex.vs → resources/shader/ssaoVertex.vs


+ 0 - 0
shader/worldFragment.fs → resources/shader/worldFragment.fs


+ 0 - 0
shader/worldPostFragment.fs → resources/shader/worldPostFragment.fs


+ 0 - 0
shader/worldPostVertex.vs → resources/shader/worldPostVertex.vs


Some files were not shown because too many files changed in this diff