From 52544558727da0f98cd8b71ba31b598b8794bdb2 Mon Sep 17 00:00:00 2001 From: Vladyslav Hrytsenko Date: Mon, 10 May 2021 09:28:56 +0300 Subject: [PATCH] code: fixes for macos --- cmake/utils.cmake | 11 +++++++++++ code/apps/client/source/main.c | 2 ++ code/apps/client/source/network.c | 1 + code/apps/client/source/platform_raylib.c | 15 +++++++-------- code/apps/client/source/platform_text.c | 1 - code/apps/client/source/utils/options.c | 2 +- code/common/packet_utils.h | 3 ++- code/common/packets/pkt_00_init.c | 1 + code/common/packets/pkt_send_librg_update.h | 2 +- code/common/system.h | 4 ++++ code/modules/source/controllers.c | 2 +- code/modules/source/physics.c | 2 +- code/vendors/flecs/CMakeLists.txt | 3 +++ code/vendors/zpl.h | 16 ++++++++++------ 14 files changed, 45 insertions(+), 20 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index fd4f539..411faac 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -11,3 +11,14 @@ 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") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") + endif () + else () + set(CMAKE_CXX_STANDARD 11) + endif () +endmacro(use_cxx11) diff --git a/code/apps/client/source/main.c b/code/apps/client/source/main.c index f87cd53..64553be 100644 --- a/code/apps/client/source/main.c +++ b/code/apps/client/source/main.c @@ -2,7 +2,9 @@ #include "zpl.h" #include "system.h" #include "game.h" +#include "entity.h" #include "utils/options.h" +#include "signal_handling.h" #include "flecs/flecs.h" #include "flecs/flecs_dash.h" diff --git a/code/apps/client/source/network.c b/code/apps/client/source/network.c index 5325035..6b5d2d1 100644 --- a/code/apps/client/source/network.c +++ b/code/apps/client/source/network.c @@ -10,6 +10,7 @@ #include "network.h" #include "packet.h" +#include "world/world.h" #define NETWORK_UPDATE_DELAY 0.100 diff --git a/code/apps/client/source/platform_raylib.c b/code/apps/client/source/platform_raylib.c index 2c1ba4d..e750196 100644 --- a/code/apps/client/source/platform_raylib.c +++ b/code/apps/client/source/platform_raylib.c @@ -233,18 +233,17 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) { } } -void lerp_entity_positions(uint64_t key, entity_view data) { +void lerp_entity_positions(uint64_t key, entity_view *data) { world_view *view = game_world_view_get_active(); - if (data.flag == EFLAG_INTERP) { - entity_view *e = entity_view_get(&view->entities, key); + if (data->flag == EFLAG_INTERP) { #if 1 - e->x = smooth_val(e->x, e->tx, view->delta_time[e->layer_id]); - e->y = smooth_val(e->y, e->ty, view->delta_time[e->layer_id]); + data->x = smooth_val(data->x, data->tx, view->delta_time[data->layer_id]); + data->y = smooth_val(data->y, data->ty, view->delta_time[data->layer_id]); #else - e->x = e->tx; - e->y = e->ty; + data->x = data->tx; + data->y = data->ty; #endif } } @@ -271,4 +270,4 @@ void do_entity_fadeinout(uint64_t key, entity_view * data) { default: break; } -} \ No newline at end of file +} diff --git a/code/apps/client/source/platform_text.c b/code/apps/client/source/platform_text.c index 8610ee6..2524294 100644 --- a/code/apps/client/source/platform_text.c +++ b/code/apps/client/source/platform_text.c @@ -1,5 +1,4 @@ #include "platform.h" -#include "zpl.h" #include uint8_t is_running; diff --git a/code/apps/client/source/utils/options.c b/code/apps/client/source/utils/options.c index 587fb9b..abeded0 100644 --- a/code/apps/client/source/utils/options.c +++ b/code/apps/client/source/utils/options.c @@ -5,7 +5,7 @@ #include "utils/options.h" void generate_minimap(int32_t seed, uint16_t block_size, uint16_t chunk_size, uint16_t world_size) { - world_init(seed, block_size, chunk_size, world_size, NULL, NULL); + world_init(seed, block_size, chunk_size, world_size); uint8_t const *world; uint32_t world_length = chunk_size * world_size; diff --git a/code/common/packet_utils.h b/code/common/packet_utils.h index d9c5976..60ea95c 100644 --- a/code/common/packet_utils.h +++ b/code/common/packet_utils.h @@ -114,6 +114,7 @@ typedef struct pkt_desc { } pkt_desc; int32_t pkt_unpack_struct(cw_unpack_context *uc, pkt_desc *desc, void *raw_blob, uint32_t blob_size); +int32_t pkt_pack_struct(cw_pack_context *pc, pkt_desc *desc, void *raw_blob, uint32_t blob_size); static inline int32_t pkt_msg_decode(pkt_header *header, pkt_desc* desc, uint32_t args, void *raw_blob, uint32_t blob_size) { cw_unpack_context uc = {0}; @@ -129,4 +130,4 @@ static inline size_t pkt_pack_desc_args(pkt_desc *desc) { return cnt; } -void pkt_dump_struct(pkt_desc *desc, void* raw_blob, uint32_t blob_size); \ No newline at end of file +void pkt_dump_struct(pkt_desc *desc, void* raw_blob, uint32_t blob_size); diff --git a/code/common/packets/pkt_00_init.c b/code/common/packets/pkt_00_init.c index 7a5419f..6554b14 100644 --- a/code/common/packets/pkt_00_init.c +++ b/code/common/packets/pkt_00_init.c @@ -5,6 +5,7 @@ #include "game.h" #include "entity_view.h" #include "camera.h" +#include "player.h" #include "modules/net.h" diff --git a/code/common/packets/pkt_send_librg_update.h b/code/common/packets/pkt_send_librg_update.h index 2889dbb..246ce7f 100644 --- a/code/common/packets/pkt_send_librg_update.h +++ b/code/common/packets/pkt_send_librg_update.h @@ -2,7 +2,7 @@ #include "system.h" #include "packet_utils.h" -size_t pkt_send_librg_update_encode(void *data, int32_t data_length); +size_t pkt_send_librg_update_encode(void *data, int32_t data_length, uint8_t layer_id); PKT_HANDLER_PROC(pkt_send_librg_update_handler); diff --git a/code/common/system.h b/code/common/system.h index b2925a6..dd4a6a7 100644 --- a/code/common/system.h +++ b/code/common/system.h @@ -1,4 +1,8 @@ #pragma once #include +#include #include + +#define ZPL_NANO +#include "zpl.h" diff --git a/code/modules/source/controllers.c b/code/modules/source/controllers.c index e1916a7..1f06bb4 100644 --- a/code/modules/source/controllers.c +++ b/code/modules/source/controllers.c @@ -1,8 +1,8 @@ +#include "zpl.h" #include "modules/controllers.h" #include "modules/general.h" #include "modules/physics.h" -#include "zpl.h" #define PLR_MOVE_SPEED 50.0 #define PLR_MOVE_SPEED_MULT 4.0 diff --git a/code/modules/source/physics.c b/code/modules/source/physics.c index fa745f1..b69c77e 100644 --- a/code/modules/source/physics.c +++ b/code/modules/source/physics.c @@ -1,6 +1,6 @@ +#include "zpl.h" #include "modules/physics.h" #include "world/world.h" -#include "zpl.h" #define PHY_WALK_DRAG 0.12 diff --git a/code/vendors/flecs/CMakeLists.txt b/code/vendors/flecs/CMakeLists.txt index 6190804..a1ec228 100644 --- a/code/vendors/flecs/CMakeLists.txt +++ b/code/vendors/flecs/CMakeLists.txt @@ -1,3 +1,5 @@ +use_cxx11() + file(GLOB SRCS *.h flecs.c flecs_json.c @@ -11,4 +13,5 @@ file(GLOB SRCS *.h flecs-os_api-stdcpp.cpp flecs_components_http.c ) + add_library(flecs-bundle STATIC ${SRCS}) diff --git a/code/vendors/zpl.h b/code/vendors/zpl.h index da9a6e4..aa674d9 100644 --- a/code/vendors/zpl.h +++ b/code/vendors/zpl.h @@ -361,7 +361,7 @@ License: #define ZPL_VERSION_MAJOR 14 #define ZPL_VERSION_MINOR 1 -#define ZPL_VERSION_PATCH 0 +#define ZPL_VERSION_PATCH 2 #define ZPL_VERSION_PRE "" // file: zpl_hedley.h @@ -2316,8 +2316,8 @@ License: # define ZPL_DEF_INLINE # define ZPL_IMPL_INLINE # else -# define ZPL_DEF_INLINE ZPL_ALWAYS_INLINE -# define ZPL_IMPL_INLINE ZPL_INLINE +# define ZPL_DEF_INLINE static +# define ZPL_IMPL_INLINE static inline # endif #endif @@ -9961,13 +9961,16 @@ License: #define ZPL__FILE_STREAM_FD_MAGIC 37 - ZPL_ALWAYS_INLINE zpl_file_descriptor zpl__file_stream_fd_make(zpl__memory_fd* d) { + ZPL_DEF_INLINE zpl_file_descriptor zpl__file_stream_fd_make(zpl__memory_fd* d); + ZPL_DEF_INLINE zpl__memory_fd *zpl__file_stream_from_fd(zpl_file_descriptor fd); + + ZPL_IMPL_INLINE zpl_file_descriptor zpl__file_stream_fd_make(zpl__memory_fd* d) { zpl_file_descriptor fd = {0}; fd.p = (void*)d; return fd; } - ZPL_ALWAYS_INLINE zpl__memory_fd *zpl__file_stream_from_fd(zpl_file_descriptor fd) { + ZPL_IMPL_INLINE zpl__memory_fd *zpl__file_stream_from_fd(zpl_file_descriptor fd) { zpl__memory_fd *d = (zpl__memory_fd*)fd.p; ZPL_ASSERT(d->magic == ZPL__FILE_STREAM_FD_MAGIC); return d; @@ -17437,9 +17440,10 @@ License: static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_assign_char(char c) { return !!zpl_strchr(":=|", c); } static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_delim_char(char c) { return !!zpl_strchr(",|\n", c); } + ZPL_DEF_INLINE zpl_b32 zpl__json_validate_name(char const *str, char *err); #define jx(x) !zpl_char_is_hex_digit(str[x]) - ZPL_ALWAYS_INLINE zpl_b32 zpl__json_validate_name(char const *str, char *err) { + ZPL_IMPL_INLINE zpl_b32 zpl__json_validate_name(char const *str, char *err) { while (*str) { /* todo: refactor name validation. */ if ((str[0] == '\\' && !zpl_char_is_control(str[1])) &&