diff --git a/build/CMakeFiles/MCC.dir/apps/main.cpp.o b/build/CMakeFiles/MCC.dir/apps/main.cpp.o index 146c9f8c3c4df5f62c05664d8bfe50b5439754f1..cc4de1a6ae4d180f608acdcb437ebb36c088e09a 100644 Binary files a/build/CMakeFiles/MCC.dir/apps/main.cpp.o and b/build/CMakeFiles/MCC.dir/apps/main.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/apps/main.cpp.o.d b/build/CMakeFiles/MCC.dir/apps/main.cpp.o.d index d8b9f9d8a95ec5c9a2046a29101cc0c137526b65..52b4d7adeb94ae656223763a41a2f4eed9d2a9dd 100644 --- a/build/CMakeFiles/MCC.dir/apps/main.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/apps/main.cpp.o.d @@ -389,7 +389,14 @@ CMakeFiles/MCC.dir/apps/main.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ - /usr/include/SDL2/SDL_net.h \ + /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ + /usr/include/c++/13/bits/algorithmfwd.h \ + /usr/include/c++/13/bits/stl_heap.h \ + /usr/include/c++/13/bits/uniform_int_dist.h \ + /usr/include/c++/13/bits/stl_tempbuf.h \ + /usr/include/c++/13/pstl/glue_algorithm_defs.h \ + /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/iterator \ + /usr/include/c++/13/bits/stream_iterator.h /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/./../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/WorldManager.hpp \ @@ -398,13 +405,7 @@ CMakeFiles/MCC.dir/apps/main.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/Entity.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/Animation.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../utils/include/Timer.hpp \ - /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ - /usr/include/c++/13/bits/algorithmfwd.h \ - /usr/include/c++/13/bits/stl_heap.h \ - /usr/include/c++/13/bits/uniform_int_dist.h \ - /usr/include/c++/13/bits/stl_tempbuf.h \ - /usr/include/c++/13/pstl/glue_algorithm_defs.h \ - /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/memory \ + /usr/include/c++/13/memory \ /usr/include/c++/13/bits/stl_raw_storage_iter.h \ /usr/include/c++/13/bits/align.h /usr/include/c++/13/bits/unique_ptr.h \ /usr/include/c++/13/bits/shared_ptr.h \ @@ -450,7 +451,6 @@ CMakeFiles/MCC.dir/apps/main.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/apps/../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/CMakeFiles/MCC.dir/compiler_depend.internal b/build/CMakeFiles/MCC.dir/compiler_depend.internal index 21d9edfad700d249cc93c98498cf4f1858231e86..f43a8b37a25dd92945ec27d9d083169f7755f05b 100644 --- a/build/CMakeFiles/MCC.dir/compiler_depend.internal +++ b/build/CMakeFiles/MCC.dir/compiler_depend.internal @@ -4258,9 +4258,11 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o /usr/include/asm-generic/socket.h /usr/include/asm-generic/sockios.h /usr/include/assert.h + /usr/include/c++/13/algorithm /usr/include/c++/13/array /usr/include/c++/13/backward/binders.h /usr/include/c++/13/bit + /usr/include/c++/13/bits/algorithmfwd.h /usr/include/c++/13/bits/alloc_traits.h /usr/include/c++/13/bits/allocator.h /usr/include/c++/13/bits/basic_ios.h @@ -4305,23 +4307,28 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o /usr/include/c++/13/bits/specfun.h /usr/include/c++/13/bits/sstream.tcc /usr/include/c++/13/bits/std_abs.h + /usr/include/c++/13/bits/stl_algo.h /usr/include/c++/13/bits/stl_algobase.h /usr/include/c++/13/bits/stl_bvector.h /usr/include/c++/13/bits/stl_construct.h /usr/include/c++/13/bits/stl_function.h + /usr/include/c++/13/bits/stl_heap.h /usr/include/c++/13/bits/stl_iterator.h /usr/include/c++/13/bits/stl_iterator_base_funcs.h /usr/include/c++/13/bits/stl_iterator_base_types.h /usr/include/c++/13/bits/stl_map.h /usr/include/c++/13/bits/stl_multimap.h /usr/include/c++/13/bits/stl_pair.h + /usr/include/c++/13/bits/stl_tempbuf.h /usr/include/c++/13/bits/stl_tree.h /usr/include/c++/13/bits/stl_uninitialized.h /usr/include/c++/13/bits/stl_vector.h + /usr/include/c++/13/bits/stream_iterator.h /usr/include/c++/13/bits/streambuf.tcc /usr/include/c++/13/bits/streambuf_iterator.h /usr/include/c++/13/bits/string_view.tcc /usr/include/c++/13/bits/stringfwd.h + /usr/include/c++/13/bits/uniform_int_dist.h /usr/include/c++/13/bits/uses_allocator.h /usr/include/c++/13/bits/uses_allocator_args.h /usr/include/c++/13/bits/utility.h @@ -4353,11 +4360,14 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o /usr/include/c++/13/iosfwd /usr/include/c++/13/iostream /usr/include/c++/13/istream + /usr/include/c++/13/iterator /usr/include/c++/13/limits /usr/include/c++/13/map /usr/include/c++/13/math.h /usr/include/c++/13/new /usr/include/c++/13/ostream + /usr/include/c++/13/pstl/execution_defs.h + /usr/include/c++/13/pstl/glue_algorithm_defs.h /usr/include/c++/13/pstl/pstl_config.h /usr/include/c++/13/sstream /usr/include/c++/13/stdexcept diff --git a/build/CMakeFiles/MCC.dir/compiler_depend.make b/build/CMakeFiles/MCC.dir/compiler_depend.make index 7f56a1bf33a622c6917c0d2a0acb29826d55b12e..b8e54d8e0b01e11912bb55170d3b5b7009f003fb 100644 --- a/build/CMakeFiles/MCC.dir/compiler_depend.make +++ b/build/CMakeFiles/MCC.dir/compiler_depend.make @@ -4248,9 +4248,11 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o: /home/tompotioubuntu/Docume /usr/include/asm-generic/socket.h \ /usr/include/asm-generic/sockios.h \ /usr/include/assert.h \ + /usr/include/c++/13/algorithm \ /usr/include/c++/13/array \ /usr/include/c++/13/backward/binders.h \ /usr/include/c++/13/bit \ + /usr/include/c++/13/bits/algorithmfwd.h \ /usr/include/c++/13/bits/alloc_traits.h \ /usr/include/c++/13/bits/allocator.h \ /usr/include/c++/13/bits/basic_ios.h \ @@ -4295,23 +4297,28 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o: /home/tompotioubuntu/Docume /usr/include/c++/13/bits/specfun.h \ /usr/include/c++/13/bits/sstream.tcc \ /usr/include/c++/13/bits/std_abs.h \ + /usr/include/c++/13/bits/stl_algo.h \ /usr/include/c++/13/bits/stl_algobase.h \ /usr/include/c++/13/bits/stl_bvector.h \ /usr/include/c++/13/bits/stl_construct.h \ /usr/include/c++/13/bits/stl_function.h \ + /usr/include/c++/13/bits/stl_heap.h \ /usr/include/c++/13/bits/stl_iterator.h \ /usr/include/c++/13/bits/stl_iterator_base_funcs.h \ /usr/include/c++/13/bits/stl_iterator_base_types.h \ /usr/include/c++/13/bits/stl_map.h \ /usr/include/c++/13/bits/stl_multimap.h \ /usr/include/c++/13/bits/stl_pair.h \ + /usr/include/c++/13/bits/stl_tempbuf.h \ /usr/include/c++/13/bits/stl_tree.h \ /usr/include/c++/13/bits/stl_uninitialized.h \ /usr/include/c++/13/bits/stl_vector.h \ + /usr/include/c++/13/bits/stream_iterator.h \ /usr/include/c++/13/bits/streambuf.tcc \ /usr/include/c++/13/bits/streambuf_iterator.h \ /usr/include/c++/13/bits/string_view.tcc \ /usr/include/c++/13/bits/stringfwd.h \ + /usr/include/c++/13/bits/uniform_int_dist.h \ /usr/include/c++/13/bits/uses_allocator.h \ /usr/include/c++/13/bits/uses_allocator_args.h \ /usr/include/c++/13/bits/utility.h \ @@ -4343,11 +4350,14 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o: /home/tompotioubuntu/Docume /usr/include/c++/13/iosfwd \ /usr/include/c++/13/iostream \ /usr/include/c++/13/istream \ + /usr/include/c++/13/iterator \ /usr/include/c++/13/limits \ /usr/include/c++/13/map \ /usr/include/c++/13/math.h \ /usr/include/c++/13/new \ /usr/include/c++/13/ostream \ + /usr/include/c++/13/pstl/execution_defs.h \ + /usr/include/c++/13/pstl/glue_algorithm_defs.h \ /usr/include/c++/13/pstl/pstl_config.h \ /usr/include/c++/13/sstream \ /usr/include/c++/13/stdexcept \ diff --git a/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o b/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o index fd598442ec1d42362864902d3d9f08a95dbf3b6d..e037b80dd8d75647d5fa06474789506bc7821dcd 100644 Binary files a/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o and b/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o.d b/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o.d index 0110260aa98222d49c7243fc15603bf999827d42..7bb333205c203e52695cc7f56df28380f1a7bf10 100644 --- a/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/game/Game.cpp.o.d @@ -389,7 +389,14 @@ CMakeFiles/MCC.dir/src/game/Game.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ - /usr/include/SDL2/SDL_net.h \ + /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ + /usr/include/c++/13/bits/algorithmfwd.h \ + /usr/include/c++/13/bits/stl_heap.h \ + /usr/include/c++/13/bits/uniform_int_dist.h \ + /usr/include/c++/13/bits/stl_tempbuf.h \ + /usr/include/c++/13/pstl/glue_algorithm_defs.h \ + /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/iterator \ + /usr/include/c++/13/bits/stream_iterator.h /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/./../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/WorldManager.hpp \ @@ -398,13 +405,7 @@ CMakeFiles/MCC.dir/src/game/Game.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/Entity.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/Animation.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../utils/include/Timer.hpp \ - /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ - /usr/include/c++/13/bits/algorithmfwd.h \ - /usr/include/c++/13/bits/stl_heap.h \ - /usr/include/c++/13/bits/uniform_int_dist.h \ - /usr/include/c++/13/bits/stl_tempbuf.h \ - /usr/include/c++/13/pstl/glue_algorithm_defs.h \ - /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/memory \ + /usr/include/c++/13/memory \ /usr/include/c++/13/bits/stl_raw_storage_iter.h \ /usr/include/c++/13/bits/align.h /usr/include/c++/13/bits/unique_ptr.h \ /usr/include/c++/13/bits/shared_ptr.h \ @@ -450,7 +451,6 @@ CMakeFiles/MCC.dir/src/game/Game.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o b/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o index 6625938c83e2bf60959e53f8af14f0966af54651..b8921f8be15f6cffc96345be54816869062bcc93 100644 Binary files a/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o and b/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o.d b/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o.d index 6b4d1752d2434dd74a81f5553809b7c7ee6eaca3..67dfdd2d82960f7c977616bc44114b35b7eb9b9f 100644 --- a/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o.d @@ -412,6 +412,7 @@ CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ + /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ @@ -454,7 +455,6 @@ CMakeFiles/MCC.dir/src/game/GameEntities.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o b/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o index a9fe2732d4ef466949c4859190725b2bf80298dc..211489b66620ef150ffeea7e774bead6632589fa 100644 Binary files a/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o and b/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o.d b/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o.d index 09f9ba0e5703bb25afe50b54c384bfdc9a7114cd..9e7f23c7765a1b62239ba65ed9ba30927f9cec20 100644 --- a/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/game/Map.cpp.o.d @@ -389,7 +389,14 @@ CMakeFiles/MCC.dir/src/game/Map.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ - /usr/include/SDL2/SDL_net.h \ + /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ + /usr/include/c++/13/bits/algorithmfwd.h \ + /usr/include/c++/13/bits/stl_heap.h \ + /usr/include/c++/13/bits/uniform_int_dist.h \ + /usr/include/c++/13/bits/stl_tempbuf.h \ + /usr/include/c++/13/pstl/glue_algorithm_defs.h \ + /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/iterator \ + /usr/include/c++/13/bits/stream_iterator.h /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/./../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/WorldManager.hpp \ @@ -398,13 +405,7 @@ CMakeFiles/MCC.dir/src/game/Map.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/Entity.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/Animation.hpp \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../utils/include/Timer.hpp \ - /usr/include/c++/13/algorithm /usr/include/c++/13/bits/stl_algo.h \ - /usr/include/c++/13/bits/algorithmfwd.h \ - /usr/include/c++/13/bits/stl_heap.h \ - /usr/include/c++/13/bits/uniform_int_dist.h \ - /usr/include/c++/13/bits/stl_tempbuf.h \ - /usr/include/c++/13/pstl/glue_algorithm_defs.h \ - /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/memory \ + /usr/include/c++/13/memory \ /usr/include/c++/13/bits/stl_raw_storage_iter.h \ /usr/include/c++/13/bits/align.h /usr/include/c++/13/bits/unique_ptr.h \ /usr/include/c++/13/bits/shared_ptr.h \ @@ -450,7 +451,6 @@ CMakeFiles/MCC.dir/src/game/Map.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/game/../../include/game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o b/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o index fdfc49d0dc845bb23c4cbe9ebc2552941651f8fb..7bebee71455c7d8752e557fa8bdb92d6f8635b33 100644 Binary files a/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o and b/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o.d b/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o.d index 0bc9bc2cc22caa6a73f57a3e69239b882ebd1349..698b555b7fc2c020ca120ac43423711402e5afd8 100644 --- a/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o.d @@ -414,6 +414,7 @@ CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ + /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ @@ -450,7 +451,6 @@ CMakeFiles/MCC.dir/src/manager/MenuManager.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o b/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o index 31501f8dd819f6c49668395923000d817dbea90c..40508bfef0af0cf0d78ea56b42614e47b4bc10fa 100644 Binary files a/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o and b/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o.d b/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o.d index f0e1b51c9e8244b089f47f6685131b8b65e18b3e..766c38924b3ea7c04cd404215b907f4583bb706a 100644 --- a/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o.d @@ -191,7 +191,15 @@ CMakeFiles/MCC.dir/src/manager/NetworkManager.cpp.o: \ /usr/include/c++/13/bits/stl_uninitialized.h \ /usr/include/c++/13/bits/stl_vector.h \ /usr/include/c++/13/bits/stl_bvector.h \ - /usr/include/c++/13/bits/vector.tcc /usr/include/SDL2/SDL.h \ + /usr/include/c++/13/bits/vector.tcc /usr/include/c++/13/algorithm \ + /usr/include/c++/13/bits/stl_algo.h \ + /usr/include/c++/13/bits/algorithmfwd.h \ + /usr/include/c++/13/bits/stl_heap.h \ + /usr/include/c++/13/bits/uniform_int_dist.h \ + /usr/include/c++/13/bits/stl_tempbuf.h \ + /usr/include/c++/13/pstl/glue_algorithm_defs.h \ + /usr/include/c++/13/pstl/execution_defs.h /usr/include/c++/13/iterator \ + /usr/include/c++/13/bits/stream_iterator.h /usr/include/SDL2/SDL.h \ /usr/include/SDL2/SDL_main.h /usr/include/SDL2/SDL_stdinc.h \ /usr/include/SDL2/SDL_config.h \ /usr/include/x86_64-linux-gnu/SDL2/_real_SDL_config.h \ diff --git a/build/CMakeFiles/MCC.dir/src/manager/RenderManager.cpp.o b/build/CMakeFiles/MCC.dir/src/manager/RenderManager.cpp.o index a583020731d570c52dd6c4a3d4ddd1f0aaae5399..2c64f08c5229c62d337a0672fa05ca1eb38a2822 100644 Binary files a/build/CMakeFiles/MCC.dir/src/manager/RenderManager.cpp.o and b/build/CMakeFiles/MCC.dir/src/manager/RenderManager.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o b/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o index 07479044a76b934d8aa6c01e06e55ae375b13c3e..65a55d223d8d1938949433f64b5f07507f0b2008 100644 Binary files a/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o and b/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o differ diff --git a/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o.d b/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o.d index 2ce19347b816d49731b16e475c1ac9e9e1540075..3dcc85457382d4a39bf084023e9b74b9a44ae6d6 100644 --- a/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o.d +++ b/build/CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o.d @@ -411,6 +411,7 @@ CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o: \ /usr/include/linux/close_range.h /usr/include/c++/13/climits \ /usr/include/c++/13/cstdint /usr/include/c++/13/cstring \ /usr/include/c++/13/sstream /usr/include/c++/13/bits/sstream.tcc \ + /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /usr/include/SDL2/SDL_net.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../../libs/qrcodegen/include/qrcodegen.hpp \ /usr/include/c++/13/array /usr/include/c++/13/compare \ @@ -453,7 +454,6 @@ CMakeFiles/MCC.dir/src/manager/WorldManager.cpp.o: \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/internal/strfunc.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/internal/../stream.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/internal/../rapidjson.h \ - /usr/include/c++/13/iterator /usr/include/c++/13/bits/stream_iterator.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/writer.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/internal/dtoa.h \ /home/tompotioubuntu/Documents/Cours/L3/S2/Stage/Mythical_Conquests_Chronicles/src/manager/../../include/manager/../game/../../libs/RapidJson/include/rapidjson/internal/itoa.h \ diff --git a/build/MCC b/build/MCC index 6deec0706d920c72b0779ef708766ac8aa402fd3..7da839514ac9d9fd71ff903e3e36705374914000 100755 Binary files a/build/MCC and b/build/MCC differ diff --git a/include/game/Game.hpp b/include/game/Game.hpp index f3b430a5813221e06390b4624e73a2366ea84d27..56e88db24a6815b6bd312c732348124f02e638f3 100644 --- a/include/game/Game.hpp +++ b/include/game/Game.hpp @@ -60,7 +60,7 @@ class Game double fps; struct nk_context *ctx; - bool isRunning; + bool isRunning = true; bool resized; bool specialEffect = false; bool debugMode = false; @@ -74,7 +74,7 @@ class Game MenuManager* menuManager; WorldManager* worldManager; - State state; + State state = InMenu; Texture branches; }; diff --git a/include/game/GameEntities.hpp b/include/game/GameEntities.hpp index d4d8dae1bbc513c94796943fb3c2f5718aaeba7a..d377664026272dac2d5d29bf250a7352ee9b4edf 100644 --- a/include/game/GameEntities.hpp +++ b/include/game/GameEntities.hpp @@ -142,22 +142,21 @@ class Player : public Being void update(float deltaT) override; void onTouch(b2Contact* contact,float deltaT) override; void setAngle(float angle); - - EntityState getState(){return this->state;} - void BeginContact(b2Contact* contact,float deltaT) override; void EndContact(b2Contact* contact,float deltaT) override; + void getHit(STypeInstance* instance); void setState(EntityState state){this->state = state;} - + void setId(int id){this->id = id;} + + int getWidthArrow(){return widthArrow;} + int getHeightArrow(){return heightArrow;} bool applySkill(const PSkill& skill); bool isSkillFinished(); bool getInvicible(){return this->invicible;} float getAngle(); - + EntityState getState(){return this->state;} Texture getArrow(){return directionArrow;} - int getWidthArrow(){return widthArrow;} - int getHeightArrow(){return heightArrow;} - void getHit(STypeInstance* instance); + private: // Indique au joueur sur quelle animation il est placé actuellement. @@ -170,6 +169,7 @@ class Player : public Being Texture directionArrow; int widthArrow; int heightArrow; + int id; Vec2 vectCollide; float angle = 0; diff --git a/include/manager/ContactListener.hpp b/include/manager/ContactListener.hpp index 69c0ca0b875b1cd4a3f6c26a5c7a5da3f36ff62d..9318f5be03666f980138ab926a7014cba9b2d948 100644 --- a/include/manager/ContactListener.hpp +++ b/include/manager/ContactListener.hpp @@ -5,6 +5,7 @@ #include "stdio.h" #include "../../libs/Box2d/include/box2d/box2d.h" #include "../game/Entity.hpp" + class ContactListener : public b2ContactListener { public: diff --git a/include/manager/MenuManager.hpp b/include/manager/MenuManager.hpp index df22d6bae51f2053f4dd6f7235a44b682b7ceb1d..f52432b3f206d2b93e12b52c9d858b56596926a3 100644 --- a/include/manager/MenuManager.hpp +++ b/include/manager/MenuManager.hpp @@ -7,7 +7,6 @@ #include "../game/Game.hpp" #include "./NetworkManager.hpp" - class Game; class MenuManager : public IActor diff --git a/include/manager/NetworkManager.hpp b/include/manager/NetworkManager.hpp index 4823e3d319ff511bad682f209566d446f0d1d196..d12a7186133f4858c0d440cd178f1001c887ac30 100644 --- a/include/manager/NetworkManager.hpp +++ b/include/manager/NetworkManager.hpp @@ -14,6 +14,8 @@ #include <cstring> #include <sstream> #include <vector> +#include <algorithm> +#include <iterator> #include <SDL2/SDL.h> #include <SDL2/SDL_net.h> @@ -24,6 +26,18 @@ using namespace std; using namespace qrcodegen; + +struct Splayer { + TCPsocket playerSocket; + int id; + string name; + Splayer(TCPsocket socket, int id, const std::string& name) : playerSocket(socket), id(id), name(name) {} +}; + +/** + * @brief Classe qui s'occupe de l'aspect réseau du jeu. + * + */ class NetworkManager { public: @@ -34,10 +48,14 @@ class NetworkManager void startGameClient(); void joinServer(); void checkForNewPlayer(); + + void Client_SendDatas(char datas[]); + void Server_SendDatas(char datas[]); + + char* Client_ReceiveDatas(); + vector<char> Server_ReceiveDatas(); string generateQrCode(string address,int port); - string receiveDatasClient(); - string receiveDatasServer(); NetworkManager(){ if (SDLNet_Init() < 0) { @@ -49,8 +67,8 @@ class NetworkManager } ~NetworkManager(){ - for (TCPsocket sock : joueurs) { - SDLNet_TCP_Close(sock); + for (Splayer player : joueurs) { + SDLNet_TCP_Close(player.playerSocket); } SDLNet_TCP_Close(playerZeroSocket); SDLNet_Quit(); @@ -60,14 +78,20 @@ class NetworkManager static NetworkManager* instance; int applicationSocket; + int cpt = 0; + IPaddress ip; Uint16 PORT = 1234; TCPsocket playerZeroSocket; SDLNet_SocketSet playerZeroSetSocket; + std::vector<TCPsocket> joueursASupprimer; - std::vector<TCPsocket> joueurs; + std::vector<Splayer> joueurs; SDLNet_SocketSet setJoueurs; + + // Quantité maximale de données que l'on peut recevoir. + int maxlen = 512; }; #endif \ No newline at end of file diff --git a/include/manager/WorldManager.hpp b/include/manager/WorldManager.hpp index c3fc559217f2bff1d21437ea9e1162d5aa96657f..61cf5a2e321e11890f81fed7a3d4cf95e1c9eb72 100644 --- a/include/manager/WorldManager.hpp +++ b/include/manager/WorldManager.hpp @@ -67,7 +67,8 @@ class WorldManager : public IActor void initializePlayer(); void loadTest(); void loadLobby(); - + void sendMessage(); + void analyseDatas(char* datas); void fpsCounter(); void changePlayerState(EntityState state); void removeMoveInput(SDL_Keycode key); @@ -78,6 +79,9 @@ class WorldManager : public IActor void zoomOut(float deltaT); void updateCameraSize(); void updateCameraPosition(); + void updateInputStates(float deltaT); + void updateNetwork(); + void deleteEntities(); void updateEntities(float deltaT); void updatePlayerVelocity(); void updateGui(float deltaT); @@ -85,7 +89,6 @@ class WorldManager : public IActor void renderPlayers(); void renderEnemies(); void renderDirectionArrow(); - void deleteEntity(); void chatBox(); void server(); @@ -108,7 +111,6 @@ class WorldManager : public IActor Map* mapWorld; Camera* camera; BodyFactory* factory; - Player* playerZero; // Vélocité du joueur. Vec2* velocity; @@ -119,6 +121,7 @@ class WorldManager : public IActor vector<SDL_Keycode> inputs; vector<std::shared_ptr<Enemy>> enemies; + Player* playerZero; vector<Player> players; vector<std::shared_ptr<Projectile>> projectiles; vector<shared_ptr<Entity>> deletedCache; diff --git a/src/game/Game.cpp b/src/game/Game.cpp index eb0461bb8a7a813afffc8ad58db7d2f4bc6caf7f..8a77e62f94a5c93eaf00e394c8ae21905450a070 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -2,8 +2,10 @@ Game::Game(char gameTitle[], int width, int height, bool fullscreen) { - isRunning = true; - state = InMenu; + if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { + cerr << "Error initializing SDL: " << SDL_GetError() << endl; + exit(1); + } RenderManager& rm = RenderManager::getInstance("My Window", 800, 600,fullscreen); renderManager = &rm; @@ -16,8 +18,6 @@ Game::Game(char gameTitle[], int width, int height, bool fullscreen) actors[InMenu] = menuManager; actors[InGame] = worldManager; - SDL_Init(SDL_INIT_EVENTS); - branches = IMG_LoadTexture(renderManager->getRenderer(), "../assets/background/branches.png"); } @@ -26,9 +26,11 @@ Game::~Game(){ delete worldManager; delete menuManager; } + float* Game::getDeltaT(){ return &deltaT; } + void Game::gameLoop() { Uint32 previous = SDL_GetTicks(); @@ -36,23 +38,14 @@ void Game::gameLoop() while(isRunning) { - //cout << fps << endl; - // Récupère les inputs du joueur. - input(); - - // Mise à jour des données. update(); + tick(lag,previous); - // Fait le rendu du jeu. render(); } } -void Game::input() -{ - -} void Game::update() { @@ -68,13 +61,17 @@ void Game::render() { // Applique une couleur de fond de base. renderManager->draw_BackgroundColor(0,0,0,255); + renderManager->renderClear(); + // Sélectionne la méthode de rendu de l'acteur. actors[state]->render(); + // Petit effet sympa. if(specialEffect && state == InMenu){ renderManager->draw_BackgroundImage(branches); } + renderManager->renderPresent(); } @@ -85,6 +82,5 @@ void Game::tick(double& lag,Uint32& previous) previous = current; deltaT = elapsed * 0.001; fps = 1 / deltaT; - if (elapsed < 16) SDL_Delay(16 - elapsed); // ralenti un peu la boucle... - //cout << fps << endl; + if (elapsed < 16) SDL_Delay(16 - elapsed); } \ No newline at end of file diff --git a/src/manager/NetworkManager.cpp b/src/manager/NetworkManager.cpp index 49d67d8309a4d888c90f8a09dca530291e619ffe..08f749abc6817dcc8ab717737a7799786a2fdbec 100644 --- a/src/manager/NetworkManager.cpp +++ b/src/manager/NetworkManager.cpp @@ -56,29 +56,181 @@ void NetworkManager::startGameClient(){ */ void NetworkManager::checkForNewPlayer(){ TCPsocket joueur = SDLNet_TCP_Accept(playerZeroSocket); - if (joueur) - { - joueurs.push_back(joueur); - SDLNet_TCP_AddSocket(setJoueurs,joueur); - std::cout << "Un joueur vient de se connecter ! " << std::endl; + if (joueur) { + joueurs.emplace_back(joueur, cpt, ""); + SDLNet_TCP_AddSocket(setJoueurs, joueur); + std::cout << "Un joueur vient de se connecter ! " << std::endl; + + char datas[5]; // 4 caractères pour les deux entiers et + 1 pour '\0' la terminaison de chaîne + short int commande = -2; + short int id = cpt; + std::memcpy(datas, &commande, sizeof(short int)); + std::memcpy(datas + sizeof(short int), &id, sizeof(short int)); + datas[4] = '\0'; + if (SDLNet_TCP_Send(joueur, datas, 5) < 5) { + std::cerr << "Erreur lors de l'envoi des données au joueur " << cpt << " : " << SDLNet_GetError() << std::endl; + } + + // On prépare les données à envoyer aux autres joueurs. + commande = 0; + std::memcpy(datas, &commande, sizeof(short int)); + + // Notifier les autres joueurs qu'il y a un nouveau joueur avec son ID. + for (const auto& joueurExistant : joueurs) { + if (joueurExistant.playerSocket != joueur) { + if (SDLNet_TCP_Send(joueurExistant.playerSocket, datas, 3) < 3) { + std::cerr << "Erreur lors de l'envoi des données au joueur " << joueurExistant.id << " : " << SDLNet_GetError() << std::endl; + } + } + } + + cpt += 1; } } /** - * @brief Récupère les données envoyées par le serveur. - * - * @return string + * @brief Fonction réservée au client : envoie des données au serveur. + */ +void NetworkManager::Client_SendDatas(char datas[]){ + size_t dataLength = strlen(datas); + if (SDLNet_TCP_Send(playerZeroSocket, datas, dataLength) < dataLength) { + std::cerr << "Erreur lors de l'envoi des données : " << SDLNet_GetError() << std::endl; + } +} + +/** + * @brief Fonction réservée au serveur : envoie des données aux clients. */ -string NetworkManager::receiveDatasClient(){ - return nullptr; +void NetworkManager::Server_SendDatas(char datas[]){ + size_t dataLength = strlen(datas); + for(Splayer joueur : joueurs){ + if (SDLNet_TCP_Send(joueur.playerSocket, datas, dataLength) < dataLength) { + std::cerr << "Erreur lors de l'envoi des données : " << SDLNet_GetError() << std::endl; + break; + } + } } /** - * @brief Récupère les données envoyées par un joueur et les renvoie aux autres. + * @brief Récupère simplement les données envoyées par le serveur. + * Renvoie soit un tableau de caractères, soit '/0' soit nullptr. + * Si c'est nullptr, c'est qu'il y a eu une erreur. + * Si c'est vide, c'est qu'il n'y avait rien à récupérer. + * Et sinon renvoie le contenu des données. + */ +char* NetworkManager::Client_ReceiveDatas() { + // Je vérifie d'abord qu'il y a quelque chose à récupérer. + if (SDLNet_CheckSockets(playerZeroSetSocket, 0) == 1) { + char* datas = new char[maxlen]; + if (datas == nullptr) { + std::cerr << "Erreur d'allocation mémoire." << std::endl; + return nullptr; + } + + int nb_recus = SDLNet_TCP_Recv(playerZeroSocket, datas, maxlen); + if (nb_recus <= 0) { + if (nb_recus == 0) { + std::cout << "La connexion a été fermée proprement par le client." << std::endl; + } + else { + std::cerr << "Erreur lors de la réception des données : " << SDLNet_GetError() << std::endl; + } + delete[] datas; + return nullptr; + } + + // Alloue dynamiquement de la mémoire pour le résultat + char* result = new char[nb_recus + 1]; // +1 pour le caractère nul de fin de chaîne + if (result == nullptr) { + std::cerr << "Erreur d'allocation mémoire pour le résultat." << std::endl; + delete[] datas; + return nullptr; + } + std::memcpy(result, datas, nb_recus); + result[nb_recus] = '\0'; + delete[] datas; + return result; + } + + // S'il n'y a rien, on renvoie une chaîne de caractères vide + else { + char* vide = new char[1]; + vide[0] = '\0'; // Ajoute le caractère nul de fin de chaîne + return vide; + } +} + +/** + * @brief Récupère les données envoyées par un joueur et en même temps les renvoie aux autres. * */ -string NetworkManager::receiveDatasServer(){ - return nullptr; +vector<char> NetworkManager::Server_ReceiveDatas(){ + // Buffer avec tous les paquets reçus par les joueurs. + vector<char> datasbuffer; + + char* datas = new char[maxlen]; + if (datas == nullptr) { + std::cerr << "Erreur d'allocation mémoire." << std::endl; + return datasbuffer; + } + + if(SDLNet_CheckSockets(setJoueurs, 0) > 0){ + for (Splayer player : joueurs){ + const TCPsocket sock = player.playerSocket; + if(SDLNet_SocketReady(sock) != 0){ + int len = SDLNet_TCP_Recv(sock, datas, maxlen); + + // Récupère les données à renvoyer aux autres joueurs. + if (len > 0) { + char* result = new char[len]; + if (result == nullptr) { + std::cerr << "Erreur d'allocation mémoire pour le résultat." << std::endl; + continue; + } + + std::memcpy(result, datas, len); + result[len] = '\0'; + for (size_t j = 0; j < joueurs.size(); ++j) { + if (sock != joueurs[j].playerSocket) { + SDLNet_TCP_Send(joueurs[j].playerSocket, result, len); + } + } + datasbuffer.insert(datasbuffer.end(), datas, datas + sizeof(datas)); + delete[] result; + } + + else if (len <= 0) { + joueursASupprimer.push_back(sock); + } + } + } + + if(joueursASupprimer.size() > 0){ + for(TCPsocket sock : joueursASupprimer){ + std::cout << "Joueur déconnecté" << std::endl; + SDLNet_TCP_DelSocket(setJoueurs,sock); + SDLNet_TCP_Close(sock); + + // Application de l'diome erase-remove_if + joueurs.erase( + std::remove_if( + joueurs.begin(), + joueurs.end(), + [&](Splayer p) { + return p.playerSocket == sock; + } + ) + ); + + if(joueurs.size() == 0){ + cout << "Il n'y a plus de joueurs" << endl; + } + } + joueursASupprimer.clear(); + } + } + delete[] datas; + return datasbuffer; } /** diff --git a/src/manager/RenderManager.cpp b/src/manager/RenderManager.cpp index 96d0d6b8dc78d293ea0495ead190c77c3add1c36..b7a7d2706d3a3f39bf60f267c8ae7f4b08f0a21e 100644 --- a/src/manager/RenderManager.cpp +++ b/src/manager/RenderManager.cpp @@ -11,11 +11,6 @@ RenderManager::RenderManager(const char title[], int w, int h,bool fullscreen) : exit(1); } - if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { - cerr << "Error initializing SDL: " << SDL_GetError() << endl; - exit(1); - } - if(fullscreen){ windowflags |= SDL_WINDOW_FULLSCREEN; SDL_DisplayMode DM; diff --git a/src/manager/WorldManager.cpp b/src/manager/WorldManager.cpp index f76ac5db191cccf289f0044caa182830089319ec..758040768ca0cc24f61bd5e39a311f7e7190b194 100644 --- a/src/manager/WorldManager.cpp +++ b/src/manager/WorldManager.cpp @@ -1,6 +1,10 @@ #include "../../include/manager/WorldManager.hpp" #include <cmath> +/* + NB : Rajouter la possiblité de créer un pseudo quand on se connecte en ligne. +*/ + /** * @brief Construct a new World Manager:: World Manager object * C'est ici que l'on initialise les données constantes du monde. Comme les joueurs. @@ -9,15 +13,11 @@ */ WorldManager::WorldManager(Game* game) : game(game) { initializeDefaultDatas(); - initializePhysicalWorld(); - initializeCamera(); - + initializePlayer(); mapWorld = new Map(camera); - loadTest(); - // NB : Orienter en fonction de la souris. debounce[SDLK_g] = false; debounce[SDLK_1] = false; @@ -84,6 +84,58 @@ void WorldManager::initializePlayer(){ velocity = playerZero->getVelocity(); } +/** + * @brief Fonction update de WorlManager. + */ +void WorldManager::update(float deltaT) +{ + updateNetwork(); + updateInputStates(deltaT); + updatePlayerVelocity(); + updateEntities(deltaT); + updateCameraPosition(); + updateGui(deltaT); +} + +void WorldManager::render() +{ + // Si on zoom modifier le facteur de zoom. + if(zoomed){ + zoomed = false; + renderManager->setZoomFactor(zoomfactor); + updateCameraSize(); + } + + // Si on est en debugDraw. + if(debugMode){ + world->DebugDraw(); + } + + // Sinon afficher les assets du jeu. + else{ + mapWorld->render(); + renderPlayers(); + renderDirectionArrow(); + renderEnemies(); + renderProjectiles(); + } + + // Affiche un compteur de FPS à l'écran. + if(game->showingFPS()){ + fpsCounter(); + } + + // Affiche les widgets pour le serveur. + server(); + + // Affiche une petite chatBox quand on est connecté. + if(game->isOnline()){ + chatBox(); + } + + renderManager->renderGui(); +} + void WorldManager::getMouseAngle(){ SDL_GetMouseState((&xMouse), (&yMouse)); Vec2* positionJoueur = new Vec2(playerZero->getBody()->GetPosition()); @@ -95,7 +147,7 @@ void WorldManager::getMouseAngle(){ playerZero->setAngle(-1 * atan2(yMouseInMeter-positionJoueur->y, xMouseInMeter-positionJoueur->x)*180/M_PI); } -void WorldManager::deleteEntity(){ +void WorldManager::deleteEntities(){ int i = 0; vector<shared_ptr<Projectile>> deletedProjectile; vector<int>indexDelete; @@ -141,18 +193,11 @@ void WorldManager::deleteEntity(){ void WorldManager::makeProjectile(float x, float y,float vX,float vY,float angle){ entityFactory->makeProjectile(x,y,vX,vY,angle); } + /** - * @brief Fonction update de WorlManager. - * L'ordre est important. On traite les informations dans ce sens de précédence (nombre petit = plus prioritaire) : - * 1 - Inputs, - * 2 - Player States, - * 3 - Velocity, Camera, - * 4 - Entités, Monde, - * 5 - Gui - * @param deltaT + * @brief Met à jour les données liées aux inputs du joueur et de ses states. */ -void WorldManager::update(float deltaT) -{ +void WorldManager::updateInputStates(float deltaT){ // Si le joueur est en train d'attaquer, on ne récupère plus les inputs. EntityState currState = playerZero->getState(); if(currState == VSlashState || currState == HSlashState){ @@ -252,12 +297,14 @@ void WorldManager::update(float deltaT) */ /*calcul de l'angle d'attaque*/ - getMouseAngle(); - if(playerZero->getAngle() < 90 && playerZero->getAngle() > (-90)){ - playerZero->setSimpleLook(Right); - } - else{ - playerZero->setSimpleLook(Left); + if(canMove){ // Je teste canMove comme ça, si le joueur hover un wiget, on n'a pas besoin de recalculer l'angle. + getMouseAngle(); + if(playerZero->getAngle() < 90 && playerZero->getAngle() > (-90)){ + playerZero->setSimpleLook(Right); + } + else{ + playerZero->setSimpleLook(Left); + } } /* Mouvements. */ @@ -277,6 +324,7 @@ void WorldManager::update(float deltaT) velocity->x -= walkspeed * deltaT; break; } + // Si le joueur n'est pas déjà en train de courir. if(!(playerZero->getState() == RunningState)){ changePlayerState(WalkingState); @@ -316,66 +364,78 @@ void WorldManager::update(float deltaT) if(playerZero->getState() == RunningState){ *velocity = playerZero->getAcceleration() * (*velocity); } +} - /* [Autres sous fonctions Update() ] -------------------------------------------------------------------------- */ - deleteEntity(); - /* Vélocité et caméra */ - updatePlayerVelocity(); - /* Relatif au monde*/ - updateEntities(deltaT); - updateCameraPosition(); - - /* GUI */ - updateGui(deltaT); - +/** + * @brief Fonction qui gère la réception des paquets réseau et leur description. + */ +void WorldManager::updateNetwork(){ // Pour le moment on vérifie tout le temps s'il y a un joueur qui se connecte. - if(game->isOnline()){ - if(game->isHost()){ + if(game->isOnline()) + { + if(game->isHost())// Rajouter le test du fait que l'on soit dans le lobby (quand je l'aurai créé :) ). + { networkManager.checkForNewPlayer(); + for(char datas : networkManager.Server_ReceiveDatas()){ + analyseDatas(&datas); + } } - else{ - + else + { + char* datas = networkManager.Client_ReceiveDatas(); + analyseDatas(datas); + delete[] datas; } } } -void WorldManager::render() -{ - // Si on zoom modifier le facteur de zoom. - if(zoomed){ - zoomed = false; - renderManager->setZoomFactor(zoomfactor); - updateCameraSize(); - } - - // Si on est en debugDraw. - if(debugMode){ - world->DebugDraw(); - } - - // Sinon afficher les assets du jeu. - else{ - mapWorld->render(); - renderPlayers(); - renderDirectionArrow(); - renderEnemies(); - renderProjectiles(); - } - - // Affiche un compteur de FPS à l'écran. - if(game->showingFPS()){ - fpsCounter(); +void WorldManager::analyseDatas(char* datas){ + // On analyse les données reçues. + if(datas == nullptr){ + // Gérer l'erreur. } - - // Affiche les widgets pour le serveur. - server(); - - // Affiche une petite chatBox quand on est connecté. - if(game->isOnline()){ - chatBox(); + else + { + // On a reçu quelque chose. + if(datas[0] != '\0') + { + short int commande; + std::memcpy(&commande, datas, sizeof(short int)); + switch(commande) + { + // Donne un id au joueur. + case -2: + short int id; + std::memcpy(&id, datas + sizeof(short int), sizeof(short int)); + playerZero->setId(id); + break; + // Un joueur a quitté. + case -1: + // Gérer le cas pour supprimer un joueur. + break; + // Un nouveau joueur a rejoint la partie. + case 0: + // Gérer le cas pour créer un nouveau joueur. + break; + // On reçoit le message d'un autre joueur. + case 1: + { + short int senderId; + std::memcpy(&senderId, datas + sizeof(short int), sizeof(short int)); + std::string nomJoueur = "joueur" + std::to_string(senderId) + " : "; + std::string finalMessage = nomJoueur + std::string(datas + sizeof(short int) * 2); + messages.push_back(finalMessage); + } + break; + // Reçoit la modification de position d'un joueur. + case 2: + break; + // La commande doit être corrompue... + default: + break; + } + } } - - renderManager->renderGui(); } /** @@ -451,7 +511,7 @@ void WorldManager::server(){ * */ void WorldManager::chatBox(){ - if (nk_begin(ctx, "Chatbox", nk_rect(0, windowHeight - 300, 400, 300), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_TITLE)) { + if (nk_begin(ctx, "Chatbox", nk_rect(0, windowHeight - 300, 400, 300), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_MINIMIZABLE | NK_WINDOW_TITLE)) { nk_layout_row_dynamic(ctx, 150, 1); // Zone de texte défilante pour les messages if (nk_group_begin(ctx, "Messages", NK_WINDOW_BORDER)) { @@ -473,26 +533,32 @@ void WorldManager::chatBox(){ ){ if (input_buffer[0] != '\0') { messages.push_back(input_buffer); - //cout << messages.back() << endl; - input_buffer[0] = '\0'; // Réinitialiser le buffer d'entrée après envoi - } - } - /* - // Bouton pour envoyer les messages - nk_layout_row_dynamic(ctx, 30, 1); - if (nk_button_label(ctx, "Envoyer")) { - if (input_buffer[0] != '\0') { - messages.push_back(input_buffer); - //cout << messages.back() << endl; - input_buffer[0] = '\0'; // Réinitialiser le buffer d'entrée après envoi + // Avant de réinitialiser le buffer, envoie le message à l'hôte. + sendMessage(); + input_buffer[0] = '\0'; } } - */ } } nk_end(ctx); } +/** + * @brief S'occupe d'envoyer le message selon le format id suivi du message. + * [int][char] + */ +void WorldManager::sendMessage() { + short int commande = 1; + char datas[sizeof(short int) + sizeof(input_buffer)]; + std::memcpy(datas, &commande, sizeof(short int)); + std::memcpy(datas + sizeof(short int), input_buffer, sizeof(input_buffer)); + if(game->isHost()){ + networkManager.Server_SendDatas(datas); + }else{ + networkManager.Client_SendDatas(datas); + } +} + /** * @brief Dessine une petite flèche qui indique le regard du joueur. * @@ -706,6 +772,8 @@ void WorldManager::fpsCounter() } void WorldManager::updateEntities(float deltaT){ + deleteEntities(); + playerZero->update(deltaT); for(auto enemy : enemies){ enemy->update(deltaT); @@ -865,36 +933,4 @@ Vec2 WorldManager::centerTextureOnHitBox(Entity* entity, const Vec2& coordonnees int h1 = animation.getTextureHeight(); float dh = (h1 - h0) * 0.5; return Vec2(coordonnees.x - dw, coordonnees.y - dh); -} - -// Code pour afficher une flèche dessinée à la main. -/* -// Longueur de la flèche -float length = 50; -// Point de départ de la flèche - -float x1 = (playerZero->getBody()->GetPosition().x + playerZero->getWidth()/2) ; -float y1 = (playerZero->getBody()->GetPosition().y + playerZero->getHeight()/2) ; - -Vec2 premierPoint = zoomfactor * renderManager->convertPoint(camera,Vec2(x1,y1)); - -// Point de fin de la ligne (extrémité de la tige) -float x2 = premierPoint.x + length * cos(angle * M_PI / 180.0); -float y2 = premierPoint.y + length * sin(angle * M_PI / 180.0); -// printf("x:%f\n",length * cos(angle * M_PI / 180.0)); - -Vec2 deuxièmePoint(x2,y2); -// Dessiner la ligne (tige de la flèche) -//renderManager->DrawSegment(premierPoint,deuxièmePoint, {255,0,0,255}); -// Base du triangle (point d'intersection des deux côtés de la tête) -float base_x = x2 + length * 0.50 * cos((angle - 135) * M_PI / 180.0); -float base_y = y2 + length * 0.50 * sin((angle - 135) * M_PI / 180.0); -Vec2 baseCoordonnées(base_x,base_y); - -renderManager->DrawSegment(deuxièmePoint,baseCoordonnées, {0,255,0,255}); - -float deuxièmeCoté_x = x2 + length * 0.5 * cos((angle+135) * M_PI / 180.0); -float deuxièmeCoté_y = y2 + length * 0.5 * sin((angle+135) * M_PI / 180.0); -Vec2 deuxièmeCoté(deuxièmeCoté_x,deuxièmeCoté_y); -renderManager->DrawSegment(deuxièmePoint,deuxièmeCoté, {0,0,255,255}); -*/ \ No newline at end of file +} \ No newline at end of file