Skip to content

Commit

Permalink
Updated dependencies + docs clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Sep 26, 2018
1 parent f67e8c2 commit bc60c17
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 88 deletions.
123 changes: 63 additions & 60 deletions include/librg.h

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions other/librg_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
f32 update_deteoriation;
f32 update_moving_treshold;

zplm_vec3_t last_position;
zpl_vec3_t last_position;
} librg_limiter_t;

LIBRG_API void librg_limiter_init(librg_limiter_t *entity_limit);
Expand All @@ -51,10 +51,10 @@ extern "C" {
if (entity_limit->update_time < entity_limit->update_delay) {
entity_limit->update_time += ctx->tick_delay;
{
zplm_vec3_t dir;
zplm_vec3_sub(&dir, entity_limit->last_position, entity->position);
zpl_vec3_t dir;
zpl_vec3_sub(&dir, entity_limit->last_position, entity->position);

b32 is_moving = (zplm_vec3_dot(dir, dir) > entity_limit->update_moving_treshold);
b32 is_moving = (zpl_vec3_dot(dir, dir) > entity_limit->update_moving_treshold);

if (is_moving || entity_limit->update_now) {
entity_limit->update_delay = entity_limit->update_initial_delay;
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "librg.c",
"version": "3.3.0",
"version": "3.3.1",
"description": "Pure C library for building simple and elegant cross-platform mmo client-server solutions.",
"main": "include/librg.h",
"directories": {
Expand All @@ -21,6 +21,6 @@
"homepage": "https://github.com/reguider/librg#readme",
"dependencies": {
"enet.c": "^2.0.1",
"zpl.c": "^6.6.0"
"zpl.c": "^8.12.2"
}
}
2 changes: 1 addition & 1 deletion test/build-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {

ctx.tick_delay = 32;
ctx.mode = LIBRG_MODE_SERVER;
ctx.world_size = zplm_vec3f(5000.0f, 5000.0f, 0.0f);
ctx.world_size = zpl_vec3f(5000.0f, 5000.0f, 0.0f);

librg_init(&ctx);

Expand Down
2 changes: 1 addition & 1 deletion test/build-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {

ctx.tick_delay = 32;
ctx.mode = LIBRG_MODE_SERVER;
ctx.world_size = zplm_vec3f(5000.0f, 5000.0f, 0.0f);
ctx.world_size = zpl_vec3f(5000.0f, 5000.0f, 0.0f);

librg_init(&ctx);

Expand Down
2 changes: 1 addition & 1 deletion test/cli-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main() {
librg_ctx_t original = {0};
original.tick_delay = 100;
original.mode = LIBRG_MODE_CLIENT;
original.world_size = zplm_vec3f(5000.0f, 5000.0f, 0.f);
original.world_size = zpl_vec3f(5000.0f, 5000.0f, 0.f);
original.max_entities = 60000;

#define size 1
Expand Down
4 changes: 2 additions & 2 deletions test/cli-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ int main() {

ctx.tick_delay = 64;
ctx.mode = LIBRG_MODE_SERVER;
ctx.world_size = zplm_vec3f(5000.0f, 5000.0f, 0.f);
ctx.min_branch_size = zplm_vec3f(-1, -1, -1);
ctx.world_size = zpl_vec3f(5000.0f, 5000.0f, 0.f);
ctx.min_branch_size = zpl_vec3f(-1, -1, -1);
ctx.max_entities = 60000;
ctx.max_connections = 1200;

Expand Down
10 changes: 5 additions & 5 deletions test/demo-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum {
typedef struct {

struct {
zplm_vec3_t accel;
zpl_vec3_t accel;
f32 walk_time;
f32 cooldown;
i32 max_hp;
Expand All @@ -31,7 +31,7 @@ typedef struct {
#ifdef DEMO_CLIENT
// interpolation
f32 delta;
zplm_vec3_t curr_pos, last_pos, target_pos;
zpl_vec3_t curr_pos, last_pos, target_pos;
#endif
} hero_t;

Expand Down Expand Up @@ -144,8 +144,8 @@ void interpolate_npcs(librg_ctx_t *ctx) {

hero->delta += 16.666f / (ctx->timesync.server_delay / 0.001f);

zplm_vec3_t delta_pos;
zplm_vec3_lerp(&delta_pos, hero->last_pos, hero->target_pos, zpl_clamp01(hero->delta));
zpl_vec3_t delta_pos;
zpl_vec3_lerp(&delta_pos, hero->last_pos, hero->target_pos, zpl_clamp01(hero->delta));

hero->curr_pos = delta_pos;
// hero->curr_pos = entity->position;
Expand Down Expand Up @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) {
ctx.tick_delay = 16.66666666666 * 4;
// ctx.tick_delay = 250;
ctx.mode = LIBRG_MODE_CLIENT;
ctx.world_size = zplm_vec3f(50000.0f, 50000.0f, 0.f);
ctx.world_size = zpl_vec3f(50000.0f, 50000.0f, 0.f);
ctx.max_entities = 16000;

librg_option_set(LIBRG_NETWORK_BUFFER_SIZE, 2);
Expand Down
10 changes: 5 additions & 5 deletions test/demo-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum {
typedef struct hero_t {

struct {
zplm_vec3_t accel;
zpl_vec3_t accel;
f32 walk_time;
f32 cooldown;
i32 max_hp;
Expand All @@ -30,7 +30,7 @@ typedef struct hero_t {
#ifdef DEMO_CLIENT
// interpolation
f32 delta;
zplm_vec3_t curr_pos, last_pos, target_pos;
zpl_vec3_t curr_pos, last_pos, target_pos;
#endif

librg_entity_t *follower1;
Expand Down Expand Up @@ -140,7 +140,7 @@ void ai_think(librg_ctx_t *ctx) {
hero->stream.accel.y = (hero->stream.accel.y > -1.0) ? ((hero->stream.accel.y < 1.0) ? hero->stream.accel.y : 1.0) : -1.0;
}
else {
zplm_vec3_t curpos = entity->position;
zpl_vec3_t curpos = entity->position;

curpos.x += hero->stream.accel.x;
curpos.y += hero->stream.accel.y;
Expand All @@ -155,7 +155,7 @@ void ai_think(librg_ctx_t *ctx) {
hero->stream.accel.y *= -1;
}
#define PP(x) x*x
if (zplm_vec3_mag2(hero->stream.accel) > PP(0.3)) {
if (zpl_vec3_mag2(hero->stream.accel) > PP(0.3)) {
entity->position = curpos;
}
#undef PP
Expand Down Expand Up @@ -198,7 +198,7 @@ int main() {
ctx.mode = LIBRG_MODE_SERVER;
ctx.tick_delay = 16.66666666666 * 4;
// ctx.tick_delay = 1000;
ctx.world_size = zplm_vec3f(50000.0f, 50000.0f, 0.f);
ctx.world_size = zpl_vec3f(50000.0f, 50000.0f, 0.f);
ctx.max_connections = 128;
ctx.max_entities = 16000,

Expand Down

0 comments on commit bc60c17

Please sign in to comment.