various networking improvements
parent
1b0951057d
commit
4449738580
|
@ -186,7 +186,9 @@ void game_shutdown() {
|
|||
|
||||
if (game_mode != GAMEKIND_HEADLESS) {
|
||||
world_viewers_destroy();
|
||||
platform_shutdown();
|
||||
|
||||
// TODO(zaklaus): crashes on exit
|
||||
//platform_shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ static inline float spherical_lerp(float a, float b, float t) {
|
|||
}
|
||||
|
||||
float smooth_val(float cur, float tgt, uint64_t dt) {
|
||||
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_FAST_MS, WORLD_TRACKER_UPDATE_SLOW_MS)));
|
||||
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_MP_FAST_MS, WORLD_TRACKER_UPDATE_MP_SLOW_MS)));
|
||||
|
||||
#if 0
|
||||
dt = 200;
|
||||
factor = map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_FAST_MS, WORLD_TRACKER_UPDATE_SLOW_MS));
|
||||
factor = map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_MP_FAST_MS, WORLD_TRACKER_UPDATE_MP_SLOW_MS));
|
||||
zpl_printf("lerp factor: %f\n", factor);
|
||||
zpl_exit(0);
|
||||
#endif
|
||||
|
@ -46,7 +46,7 @@ float smooth_val(float cur, float tgt, uint64_t dt) {
|
|||
}
|
||||
|
||||
float smooth_val_spherical(float cur, float tgt, uint64_t dt) {
|
||||
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_FAST_MS, WORLD_TRACKER_UPDATE_SLOW_MS)));
|
||||
float factor = zpl_clamp01(map_factor(zpl_unlerp(dt, WORLD_TRACKER_UPDATE_MP_FAST_MS, WORLD_TRACKER_UPDATE_MP_SLOW_MS)));
|
||||
|
||||
return spherical_lerp(cur, tgt, zpl_lerp(PREDICT_SMOOTH_FACTOR_LO, PREDICT_SMOOTH_FACTOR_HI, factor));
|
||||
}
|
||||
|
@ -75,17 +75,16 @@ void lerp_entity_positions(uint64_t key, entity_view *data) {
|
|||
world_view *view = game_world_view_get_active();
|
||||
|
||||
if (data->flag == EFLAG_INTERP) {
|
||||
|
||||
#if 0
|
||||
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]);
|
||||
data->heading = smooth_val_spherical(data->heading, data->theading, view->delta_time[data->layer_id]);
|
||||
#else
|
||||
(void)view;
|
||||
data->x = data->tx;
|
||||
data->y = data->ty;
|
||||
data->heading = data->theading;
|
||||
#endif
|
||||
if (game_get_kind() == GAMEKIND_CLIENT) {
|
||||
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]);
|
||||
data->heading = smooth_val_spherical(data->heading, data->theading, view->delta_time[data->layer_id]);
|
||||
} else {
|
||||
(void)view;
|
||||
data->x = data->tx;
|
||||
data->y = data->ty;
|
||||
data->heading = data->theading;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "world/worldgen/worldgen.h"
|
||||
#include "platform.h"
|
||||
#include "profiler.h"
|
||||
#include "game.h"
|
||||
|
||||
#include "packets/pkt_send_librg_update.h"
|
||||
|
||||
|
@ -282,15 +283,24 @@ static void world_tracker_update(uint8_t ticker, uint32_t freq, uint8_t radius)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t world_update() {
|
||||
profile (PROF_UPDATE_SYSTEMS) {
|
||||
ecs_progress(world.ecs, 0.0f);
|
||||
}
|
||||
|
||||
world_tracker_update(0, WORLD_TRACKER_UPDATE_FAST_MS, 2);
|
||||
world_tracker_update(1, WORLD_TRACKER_UPDATE_NORMAL_MS, 4);
|
||||
world_tracker_update(2, WORLD_TRACKER_UPDATE_SLOW_MS, 6);
|
||||
uint32_t fast_ms = WORLD_TRACKER_UPDATE_FAST_MS;
|
||||
uint32_t normal_ms = WORLD_TRACKER_UPDATE_NORMAL_MS;
|
||||
uint32_t slow_ms = WORLD_TRACKER_UPDATE_SLOW_MS;
|
||||
|
||||
if (game_get_kind() != GAMEKIND_SINGLE) {
|
||||
fast_ms = WORLD_TRACKER_UPDATE_MP_FAST_MS;
|
||||
normal_ms = WORLD_TRACKER_UPDATE_MP_NORMAL_MS;
|
||||
slow_ms = WORLD_TRACKER_UPDATE_MP_SLOW_MS;
|
||||
}
|
||||
|
||||
world_tracker_update(0, fast_ms, 2);
|
||||
world_tracker_update(1, normal_ms, 4);
|
||||
world_tracker_update(2, slow_ms, 6);
|
||||
|
||||
debug_replay_update();
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#define WORLD_TRACKER_UPDATE_FAST_MS 10
|
||||
#define WORLD_TRACKER_UPDATE_NORMAL_MS 50
|
||||
#define WORLD_TRACKER_UPDATE_SLOW_MS 100
|
||||
#define WORLD_TRACKER_UPDATE_MP_FAST_MS 50
|
||||
#define WORLD_TRACKER_UPDATE_MP_NORMAL_MS 150
|
||||
#define WORLD_TRACKER_UPDATE_MP_SLOW_MS 300
|
||||
#define WORLD_BLOCK_SIZE 64
|
||||
|
||||
#define WORLD_PKT_READER(name) int32_t name(void* data, uint32_t datalen, void *udata)
|
||||
|
|
|
@ -96,8 +96,12 @@ void DropItem(ecs_iter_t *it) {
|
|||
if (in[i].sprint) {
|
||||
dropped_count /= 2;
|
||||
} else if (in[i].ctrl) {
|
||||
dropped_count = 1;
|
||||
dropped_count = dropped_count > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
if (dropped_count == 0)
|
||||
continue;
|
||||
|
||||
ecs_entity_t te = item_spawn(item->kind, dropped_count);
|
||||
item->quantity -= dropped_count;
|
||||
|
||||
|
|
Loading…
Reference in New Issue