From f1a7c96135fcd5162681a335231fb7693b9db032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 10 May 2021 13:27:01 +0200 Subject: [PATCH] simplify project structure --- code/common/entity_view.h | 4 +-- code/common/game.h | 2 +- code/common/packets/pkt_00_init.h | 2 +- code/common/packets/pkt_01_welcome.h | 2 +- code/common/packets/pkt_send_keystate.h | 2 +- code/game/CMakeLists.txt | 35 +++++++++---------------- code/game/source/game.c | 2 +- code/game/source/platform_raylib.c | 6 +++++ 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/code/common/entity_view.h b/code/common/entity_view.h index 1246e93..70862b9 100644 --- a/code/common/entity_view.h +++ b/code/common/entity_view.h @@ -48,7 +48,7 @@ typedef struct entity_view { ZPL_TABLE_DECLARE(, entity_view_tbl, entity_view_tbl_, entity_view); -pkt_desc pkt_entity_view_desc[]; +extern pkt_desc pkt_entity_view_desc[]; void entity_view_init(entity_view_tbl *map); void entity_view_free(entity_view_tbl *map); @@ -63,4 +63,4 @@ size_t entity_view_pack_struct(void *data, size_t len, entity_view view); entity_view entity_view_unpack_struct(void *data, size_t len); void entity_view_mark_for_removal(entity_view_tbl *map, uint64_t ent_id); -void entity_view_mark_for_fadein(entity_view_tbl *map, uint64_t ent_id); \ No newline at end of file +void entity_view_mark_for_fadein(entity_view_tbl *map, uint64_t ent_id); diff --git a/code/common/game.h b/code/common/game.h index 6c971b2..b744124 100644 --- a/code/common/game.h +++ b/code/common/game.h @@ -17,7 +17,7 @@ world_view *game_world_view_get_active(void); world_view *game_world_view_get(uint16_t idx); void game_world_view_set_active_by_idx(uint16_t idx); void game_world_view_set_active(world_view *view); -void game_world_view_cycle_active(uint8_t dir); +void game_world_view_cycle_active(int8_t dir); void game_world_view_active_entity_map(void (*map_proc)(uint64_t key, entity_view * value)); void game_world_cleanup_entities(void); diff --git a/code/common/packets/pkt_00_init.h b/code/common/packets/pkt_00_init.h index 43d3967..d52b8c5 100644 --- a/code/common/packets/pkt_00_init.h +++ b/code/common/packets/pkt_00_init.h @@ -8,7 +8,7 @@ typedef struct { size_t pkt_00_init_encode(pkt_00_init *table); size_t pkt_00_init_send(uint16_t view_id); -pkt_desc pkt_00_init_desc[]; +extern pkt_desc pkt_00_init_desc[]; PKT_HANDLER_PROC(pkt_00_init_handler); diff --git a/code/common/packets/pkt_01_welcome.h b/code/common/packets/pkt_01_welcome.h index c684929..f92c057 100644 --- a/code/common/packets/pkt_01_welcome.h +++ b/code/common/packets/pkt_01_welcome.h @@ -16,7 +16,7 @@ size_t pkt_01_welcome_send(uint64_t peer_id, uint16_t chunk_size, uint16_t world_size); size_t pkt_01_welcome_encode(pkt_01_welcome *table); -pkt_desc pkt_01_welcome_desc[]; +extern pkt_desc pkt_01_welcome_desc[]; PKT_HANDLER_PROC(pkt_01_welcome_handler); diff --git a/code/common/packets/pkt_send_keystate.h b/code/common/packets/pkt_send_keystate.h index 257ba1f..5626b5b 100644 --- a/code/common/packets/pkt_send_keystate.h +++ b/code/common/packets/pkt_send_keystate.h @@ -14,7 +14,7 @@ size_t pkt_send_keystate_send(uint16_t view_id, uint8_t use, uint8_t sprint); size_t pkt_send_keystate_encode(pkt_send_keystate *table); -pkt_desc pkt_send_keystate_desc[]; +extern pkt_desc pkt_send_keystate_desc[]; PKT_HANDLER_PROC(pkt_send_keystate_handler); diff --git a/code/game/CMakeLists.txt b/code/game/CMakeLists.txt index c924f0c..9eec963 100644 --- a/code/game/CMakeLists.txt +++ b/code/game/CMakeLists.txt @@ -1,35 +1,24 @@ include(FindRaylib.cmake) populate_pkt_srcs() -add_library(client-common STATIC - source/network.c - source/game.c +add_executable(eco2d + source/platform_raylib.c + source/main.c + + source/network.c + source/game.c source/camera.c source/world_view.c source/prediction.c - source/utils/options.c + source/utils/options.c - header/network.h - ${PKT_SRCS} + header/network.h + ${PKT_SRCS} ) -add_executable(eco2d-client - source/platform_raylib.c - source/main.c -) - -add_executable(eco2d-cli - source/platform_text.c - source/main.c -) - -target_compile_definitions(client-common PRIVATE CLIENT) -set(LIBS client-common cwpack eco2d-common eco2d-modules flecs-bundle) - +target_compile_definitions(eco2d PRIVATE CLIENT) include_directories(header ../modules) -target_link_libraries(eco2d-client raylib ${LIBS}) -target_link_libraries(eco2d-cli ${LIBS}) +target_link_libraries(eco2d raylib cwpack eco2d-common eco2d-modules flecs-bundle) -link_system_libs(eco2d-cli) -link_system_libs(eco2d-client) +link_system_libs(eco2d) diff --git a/code/game/source/game.c b/code/game/source/game.c index 1d8e036..c889c33 100644 --- a/code/game/source/game.c +++ b/code/game/source/game.c @@ -77,7 +77,7 @@ world_view *game_world_view_get_active(void) { return active_viewer; } -void game_world_view_cycle_active(uint8_t dir) { +void game_world_view_cycle_active(int8_t dir) { uint16_t idx = (uint16_t)(active_viewer - world_viewers); game_world_view_set_active_by_idx((idx+dir)%zpl_buffer_count(world_viewers)); } diff --git a/code/game/source/platform_raylib.c b/code/game/source/platform_raylib.c index c660abd..767e1c3 100644 --- a/code/game/source/platform_raylib.c +++ b/code/game/source/platform_raylib.c @@ -15,6 +15,7 @@ float target_zoom = 4.0f; static Camera2D render_camera; void DrawTextEco(const char *text, float posX, float posY, int fontSize, Color color, float spacing) { +#if 1 // Check if default font has been loaded if (GetFontDefault().texture.id != 0) { Vector2 position = { (float)posX , (float)posY }; @@ -24,9 +25,11 @@ void DrawTextEco(const char *text, float posX, float posY, int fontSize, Color c DrawTextEx(GetFontDefault(), text, position, (float)fontSize , (float)new_spacing , color); } +#endif } int MeasureTextEco(const char *text, int fontSize, float spacing) { +#if 1 Vector2 vec = { 0.0f, 0.0f }; // Check if default font has been loaded @@ -38,6 +41,9 @@ int MeasureTextEco(const char *text, int fontSize, float spacing) { } return (int)vec.x; +#else + return 0; +#endif } void DrawCircleEco(float centerX, float centerY, float radius, Color color) {