diff --git a/CMakeLists.txt b/CMakeLists.txt index dae43fd..74511d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_compile_options(/MP /W4) + add_compile_options(/MP /W4 /nologo) endif() include_directories(code/common code/vendors code/vendors/flecs) +include(cmake/FindRaylib.cmake) + add_subdirectory(code/modules) -add_subdirectory(code/common) add_subdirectory(code/vendors) add_subdirectory(code/game) diff --git a/code/game/FindRaylib.cmake b/cmake/FindRaylib.cmake similarity index 100% rename from code/game/FindRaylib.cmake rename to cmake/FindRaylib.cmake diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 99d594c..e682453 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -8,11 +8,6 @@ function(link_system_libs target_name) endif() endfunction() -macro(populate_pkt_srcs) - file(GLOB PKT_SRCS ../common/packets/*.h ../common/packets/*.c) -endmacro() - - macro(use_cxx11) if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/code/common/CMakeLists.txt b/code/common/CMakeLists.txt deleted file mode 100644 index f7201c9..0000000 --- a/code/common/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -file(GLOB SRCS *.h *.c packets/*.h world/*.h) -set(SRCS ${SRCS} - world/blocks.c - world/perlin.c - world/world.c - - world/worldgen/worldgen_test.c -) -include_directories(../modules . world) -add_library(eco2d-common STATIC ${SRCS}) \ No newline at end of file diff --git a/code/common/atlas_shared.h b/code/common/atlas_shared.h deleted file mode 100644 index 4eb66dc..0000000 --- a/code/common/atlas_shared.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#define ATLAS_STRIDE 10 -#define ATLAS_XY(x,y) ((y*ATLAS_STRIDE)+x) diff --git a/code/common/world/blocks_list.c b/code/common/world/blocks_list.c deleted file mode 100644 index 1871d80..0000000 --- a/code/common/world/blocks_list.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "atlas_shared.h" -#include "world/blocks.h" - -static block blocks[] = { - {.tex_id = ATLAS_XY(0, 0), .name = "base-ground", .flags = 0, .kind = BLOCK_KIND_GROUND, .biome = 0, .symbol = '.'}, - {.tex_id = ATLAS_XY(1, 0), .name = "base-wall", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WALL, .biome = 0, .symbol = '#'}, - {.tex_id = ATLAS_XY(2, 0), .name = "base-hill", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL, .biome = 0, .symbol = '^'}, - {.tex_id = ATLAS_XY(3, 0), .name = "base-hill-snow", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL_SNOW, .biome = 0, .symbol = '*'}, - {.tex_id = ATLAS_XY(0, 1), .name = "base-water", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WATER, .biome = 0, .symbol = '~'}, -}; diff --git a/code/game/CMakeLists.txt b/code/game/CMakeLists.txt index 9eec963..18fbd10 100644 --- a/code/game/CMakeLists.txt +++ b/code/game/CMakeLists.txt @@ -1,24 +1,38 @@ -include(FindRaylib.cmake) +file(GLOB PKT_SRCS ../game/header/packets/*.h ../game/source/packets/*.c) -populate_pkt_srcs() add_executable(eco2d source/platform_raylib.c source/main.c source/network.c - source/game.c + source/game.c source/camera.c source/world_view.c source/prediction.c + + source/assets.c + source/compress.c + source/entity.c + source/entity_view.c + source/packet.c + source/player.c + source/signal_handling.c source/utils/options.c header/network.h + + source/world/blocks.c + source/world/perlin.c + source/world/world.c + + source/world/worldgen/worldgen_test.c + ${PKT_SRCS} ) target_compile_definitions(eco2d PRIVATE CLIENT) include_directories(header ../modules) -target_link_libraries(eco2d raylib cwpack eco2d-common eco2d-modules flecs-bundle) +target_link_libraries(eco2d raylib cwpack eco2d-modules flecs-bundle) link_system_libs(eco2d) diff --git a/code/common/assets.h b/code/game/header/assets.h similarity index 100% rename from code/common/assets.h rename to code/game/header/assets.h diff --git a/code/common/compress.h b/code/game/header/compress.h similarity index 100% rename from code/common/compress.h rename to code/game/header/compress.h diff --git a/code/common/entity.h b/code/game/header/entity.h similarity index 100% rename from code/common/entity.h rename to code/game/header/entity.h diff --git a/code/common/entity_view.h b/code/game/header/entity_view.h similarity index 100% rename from code/common/entity_view.h rename to code/game/header/entity_view.h diff --git a/code/common/game.h b/code/game/header/game.h similarity index 100% rename from code/common/game.h rename to code/game/header/game.h diff --git a/code/common/packet.h b/code/game/header/packet.h similarity index 100% rename from code/common/packet.h rename to code/game/header/packet.h diff --git a/code/common/packet_utils.h b/code/game/header/packet_utils.h similarity index 100% rename from code/common/packet_utils.h rename to code/game/header/packet_utils.h diff --git a/code/common/packets/pkt_00_init.h b/code/game/header/packets/pkt_00_init.h similarity index 100% rename from code/common/packets/pkt_00_init.h rename to code/game/header/packets/pkt_00_init.h diff --git a/code/common/packets/pkt_01_welcome.h b/code/game/header/packets/pkt_01_welcome.h similarity index 100% rename from code/common/packets/pkt_01_welcome.h rename to code/game/header/packets/pkt_01_welcome.h diff --git a/code/common/packets/pkt_send_keystate.h b/code/game/header/packets/pkt_send_keystate.h similarity index 100% rename from code/common/packets/pkt_send_keystate.h rename to code/game/header/packets/pkt_send_keystate.h diff --git a/code/common/packets/pkt_send_librg_update.h b/code/game/header/packets/pkt_send_librg_update.h similarity index 100% rename from code/common/packets/pkt_send_librg_update.h rename to code/game/header/packets/pkt_send_librg_update.h diff --git a/code/common/platform.h b/code/game/header/platform.h similarity index 100% rename from code/common/platform.h rename to code/game/header/platform.h diff --git a/code/common/player.h b/code/game/header/player.h similarity index 100% rename from code/common/player.h rename to code/game/header/player.h diff --git a/code/common/signal_handling.h b/code/game/header/signal_handling.h similarity index 100% rename from code/common/signal_handling.h rename to code/game/header/signal_handling.h diff --git a/code/common/system.h b/code/game/header/system.h similarity index 100% rename from code/common/system.h rename to code/game/header/system.h diff --git a/code/common/world/blocks.h b/code/game/header/world/blocks.h similarity index 90% rename from code/common/world/blocks.h rename to code/game/header/world/blocks.h index 4f6ec36..383e677 100644 --- a/code/common/world/blocks.h +++ b/code/game/header/world/blocks.h @@ -12,7 +12,6 @@ typedef enum { uint8_t blocks_find(uint32_t biome, uint32_t kind); char *blocks_get_name(uint8_t id); -uint8_t blocks_get_tex_id(uint8_t id); char blocks_get_symbol(uint8_t id); uint32_t blocks_get_flags(uint8_t id); uint32_t blocks_get_biome(uint8_t id); diff --git a/code/common/world/blocks_info.h b/code/game/header/world/blocks_info.h similarity index 100% rename from code/common/world/blocks_info.h rename to code/game/header/world/blocks_info.h diff --git a/code/common/world/perlin.h b/code/game/header/world/perlin.h similarity index 100% rename from code/common/world/perlin.h rename to code/game/header/world/perlin.h diff --git a/code/common/world/world.h b/code/game/header/world/world.h similarity index 100% rename from code/common/world/world.h rename to code/game/header/world/world.h diff --git a/code/common/world/worldgen/worldgen.h b/code/game/header/world/worldgen/worldgen.h similarity index 100% rename from code/common/world/worldgen/worldgen.h rename to code/game/header/world/worldgen/worldgen.h diff --git a/code/common/assets.c b/code/game/source/assets.c similarity index 100% rename from code/common/assets.c rename to code/game/source/assets.c diff --git a/code/common/compress.c b/code/game/source/compress.c similarity index 100% rename from code/common/compress.c rename to code/game/source/compress.c diff --git a/code/common/entity.c b/code/game/source/entity.c similarity index 97% rename from code/common/entity.c rename to code/game/source/entity.c index a640a7b..4402aec 100644 --- a/code/common/entity.c +++ b/code/game/source/entity.c @@ -2,7 +2,7 @@ #include "flecs/flecs.h" #include "flecs/flecs_meta.h" #include "librg.h" -#include "world.h" +#include "world/world.h" #include "modules/general.h" #include "modules/controllers.h" diff --git a/code/common/entity_view.c b/code/game/source/entity_view.c similarity index 100% rename from code/common/entity_view.c rename to code/game/source/entity_view.c diff --git a/code/common/packet.c b/code/game/source/packet.c similarity index 100% rename from code/common/packet.c rename to code/game/source/packet.c diff --git a/code/common/packets/pkt_00_init.c b/code/game/source/packets/pkt_00_init.c similarity index 100% rename from code/common/packets/pkt_00_init.c rename to code/game/source/packets/pkt_00_init.c diff --git a/code/common/packets/pkt_01_welcome.c b/code/game/source/packets/pkt_01_welcome.c similarity index 100% rename from code/common/packets/pkt_01_welcome.c rename to code/game/source/packets/pkt_01_welcome.c diff --git a/code/common/packets/pkt_send_keystate.c b/code/game/source/packets/pkt_send_keystate.c similarity index 100% rename from code/common/packets/pkt_send_keystate.c rename to code/game/source/packets/pkt_send_keystate.c diff --git a/code/common/packets/pkt_send_librg_update.c b/code/game/source/packets/pkt_send_librg_update.c similarity index 100% rename from code/common/packets/pkt_send_librg_update.c rename to code/game/source/packets/pkt_send_librg_update.c diff --git a/code/common/player.c b/code/game/source/player.c similarity index 98% rename from code/common/player.c rename to code/game/source/player.c index a567e60..a9c4cbf 100644 --- a/code/common/player.c +++ b/code/game/source/player.c @@ -3,7 +3,7 @@ #include "flecs/flecs.h" #include "flecs/flecs_meta.h" #include "librg.h" -#include "world.h" +#include "world/world.h" #include "modules/general.h" #include "modules/controllers.h" diff --git a/code/common/signal_handling.c b/code/game/source/signal_handling.c similarity index 100% rename from code/common/signal_handling.c rename to code/game/source/signal_handling.c diff --git a/code/common/world/blocks.c b/code/game/source/world/blocks.c similarity index 82% rename from code/common/world/blocks.c rename to code/game/source/world/blocks.c index f8d6a96..b16b0a0 100644 --- a/code/common/world/blocks.c +++ b/code/game/source/world/blocks.c @@ -1,23 +1,25 @@ +#define ZPL_PICO #include "zpl.h" #include "world/blocks.h" - -// todo: csv parsing + utils +#include "raylib.h" #define BLOCKS_COUNT (sizeof(blocks)/sizeof(block)) typedef struct { - uint8_t tex_id; char *name; uint32_t flags; uint32_t kind; uint32_t biome; char symbol; + + // NOTE(zaklaus): viewer data + Image tex; } block; #include "blocks_list.c" uint8_t blocks_find(uint32_t biome, uint32_t kind) { - for (int i=0; i