code: update deps + fixes

isolation_bkp/dynres
Dominik Madarász 2021-01-14 17:37:20 +01:00
parent 553eca86aa
commit 659cbe700f
5 changed files with 184 additions and 244 deletions

View File

@ -7,7 +7,7 @@
typedef struct { typedef struct {
uint8_t tex_id; uint8_t tex_id;
const char *name; char *name;
uint32_t flags; uint32_t flags;
uint32_t kind; uint32_t kind;
uint32_t biome; uint32_t biome;

View File

@ -1,42 +1,46 @@
#include "world.h" #include "world.h"
#include "zpl.h" #include "zpl.h"
static uint8_t *world = NULL; typedef struct {
static uint32_t world_seed = 0; uint8_t *data;
static uint32_t world_size = 0; uint32_t seed;
static uint32_t world_width = 0; uint32_t size;
static uint32_t world_height = 0; uint32_t width;
uint32_t height;
} world_data;
static world_data world = {0};
int32_t world_gen(); int32_t world_gen();
int32_t world_init(int32_t seed, uint32_t width, uint32_t height) { int32_t world_init(int32_t seed, uint32_t width, uint32_t height) {
if (world) { if (world.data) {
world_destroy(); world_destroy();
} }
world_seed = seed; world.seed = seed;
world_width = width; world.width = width;
world_height = height; world.height = height;
world_size = width*height; world.size = width*height;
world = zpl_malloc(sizeof(uint8_t)*world_size); world.data = zpl_malloc(sizeof(uint8_t)*world.size);
if (!world) { if (!world.data) {
return WORLD_ERROR_OUTOFMEM; return WORLD_ERROR_OUTOFMEM;
} }
return world_gen(); return world_gen();
} }
int32_t world_destroy(void) { int32_t world_destroy(void) {
zpl_mfree(world); zpl_mfree(world.data);
world = NULL; zpl_memset(&world, 0, sizeof(world));
return WORLD_ERROR_NONE; return WORLD_ERROR_NONE;
} }
uint32_t world_buf(uint8_t const **ptr, uint32_t *width) { uint32_t world_buf(uint8_t const **ptr, uint32_t *width) {
ZPL_ASSERT_NOT_NULL(world); ZPL_ASSERT_NOT_NULL(world.data);
ZPL_ASSERT_NOT_NULL(ptr); ZPL_ASSERT_NOT_NULL(ptr);
*ptr = world; *ptr = world.data;
if (width) *width = world_width; if (width) *width = world.width;
return world_size; return world.size;
} }
#include "world_gen.c" #include "world_gen.c"

View File

@ -4,6 +4,7 @@
#include "zpl.h" #include "zpl.h"
#include <math.h> #include <math.h>
#include <stdlib.h>
#define WORLD_BLOCK_OBSERVER(name) uint32_t name(uint32_t id, uint32_t block_idx) #define WORLD_BLOCK_OBSERVER(name) uint32_t name(uint32_t id, uint32_t block_idx)
typedef WORLD_BLOCK_OBSERVER(world_block_observer_proc); typedef WORLD_BLOCK_OBSERVER(world_block_observer_proc);
@ -14,9 +15,9 @@ typedef WORLD_BLOCK_OBSERVER(world_block_observer_proc);
static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) { static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) {
for (uint32_t cy=y; cy<y+h; cy++) { for (uint32_t cy=y; cy<y+h; cy++) {
for (uint32_t cx=x; cx<x+w; cx++) { for (uint32_t cx=x; cx<x+w; cx++) {
if (cx < 0 || cx >= world_width) continue; if (cx < 0 || cx >= world.width) continue;
if (cy < 0 || cy >= world_height) continue; if (cy < 0 || cy >= world.height) continue;
uint32_t i = (cy*world_width) + cx; uint32_t i = (cy*world.width) + cx;
if (proc) { if (proc) {
uint32_t new_id = (*proc)(id, i); uint32_t new_id = (*proc)(id, i);
@ -26,7 +27,7 @@ static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uin
else continue; else continue;
} }
world[i] = id; world.data[i] = id;
} }
} }
} }
@ -34,9 +35,9 @@ static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uin
static void world_fill_circle(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) { static void world_fill_circle(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) {
for (uint32_t cy=y; cy<y+h; cy++) { for (uint32_t cy=y; cy<y+h; cy++) {
for (uint32_t cx=x; cx<x+w; cx++) { for (uint32_t cx=x; cx<x+w; cx++) {
if (cx < 0 || cx >= world_width) continue; if (cx < 0 || cx >= world.width) continue;
if (cy < 0 || cy >= world_height) continue; if (cy < 0 || cy >= world.height) continue;
uint32_t i = (cy*world_width) + cx; uint32_t i = (cy*world.width) + cx;
if (proc) { if (proc) {
uint32_t new_id = (*proc)(id, i); uint32_t new_id = (*proc)(id, i);
@ -46,7 +47,7 @@ static void world_fill_circle(uint32_t id, uint32_t x, uint32_t y, uint32_t w, u
else continue; else continue;
} }
world[i] = id; world.data[i] = id;
} }
} }
} }
@ -60,8 +61,8 @@ static void world_fill_rect_anchor(uint32_t id, uint32_t x, uint32_t y, uint32_t
static WORLD_BLOCK_OBSERVER(shaper) { static WORLD_BLOCK_OBSERVER(shaper) {
uint32_t biome = blocks_get_biome(id); uint32_t biome = blocks_get_biome(id);
uint32_t kind = blocks_get_kind(id); uint32_t kind = blocks_get_kind(id);
uint32_t old_biome = blocks_get_biome(world[block_idx]); uint32_t old_biome = blocks_get_biome(world.data[block_idx]);
uint32_t old_kind = blocks_get_kind(world[block_idx]); uint32_t old_kind = blocks_get_kind(world.data[block_idx]);
if (biome == old_biome) { if (biome == old_biome) {
if (kind == BLOCK_KIND_WALL && kind == old_kind) { if (kind == BLOCK_KIND_WALL && kind == old_kind) {
@ -76,10 +77,10 @@ static WORLD_BLOCK_OBSERVER(shaper) {
} }
static uint8_t world_perlin_cond(uint32_t block_idx, double chance) { static uint8_t world_perlin_cond(uint32_t block_idx, double chance) {
uint32_t x = block_idx % world_width; uint32_t x = block_idx % world.width;
uint32_t y = block_idx / world_width; uint32_t y = block_idx / world.width;
return perlin_fbm(world_seed, x, y, WORLD_PERLIN_FREQ, WORLD_PERLIN_OCTAVES) < chance; return perlin_fbm(world.seed, x, y, WORLD_PERLIN_FREQ, WORLD_PERLIN_OCTAVES) < chance;
} }
static WORLD_BLOCK_OBSERVER(shaper_noise80) { static WORLD_BLOCK_OBSERVER(shaper_noise80) {
@ -107,24 +108,24 @@ int32_t world_gen() {
uint32_t grnd_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_GROUND); uint32_t grnd_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_GROUND);
uint32_t watr_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_WATER); uint32_t watr_id = blocks_find(BLOCK_BIOME_DEV, BLOCK_KIND_WATER);
srand(world_seed); srand(world.seed);
// walls // walls
world_fill_rect(wall_id, 0, 0, world_width, world_height, NULL); world_fill_rect(wall_id, 0, 0, world.width, world.height, NULL);
// ground // ground
world_fill_rect(grnd_id, 1, 1, world_width-2, world_height-2, NULL); world_fill_rect(grnd_id, 1, 1, world.width-2, world.height-2, NULL);
// water // water
for (int i=0; i<RAND_RANGE(0, 12); i++) { for (int i=0; i<RAND_RANGE(0, 12); i++) {
world_fill_rect_anchor(watr_id, RAND_RANGE(0, world_width), RAND_RANGE(0, world_height), 4+RAND_RANGE(0,3), 4+RAND_RANGE(0,3), 0.5f, 0.5f, shaper_noise33); world_fill_rect_anchor(watr_id, RAND_RANGE(0, world.width), RAND_RANGE(0, world.height), 4+RAND_RANGE(0,3), 4+RAND_RANGE(0,3), 0.5f, 0.5f, shaper_noise33);
} }
const uint32_t HILLS_SIZE = 21; const uint32_t HILLS_SIZE = 21;
// hills // hills
for (int i=0; i<RAND_RANGE(8, 224); i++) { for (int i=0; i<RAND_RANGE(8, 224); i++) {
world_fill_rect_anchor(wall_id, RAND_RANGE(0, world_width), RAND_RANGE(0, world_height), RAND_RANGE(0,HILLS_SIZE), RAND_RANGE(0,HILLS_SIZE), 0.5f, 0.5f, shaper_noise33); world_fill_rect_anchor(wall_id, RAND_RANGE(0, world.width), RAND_RANGE(0, world.height), RAND_RANGE(0,HILLS_SIZE), RAND_RANGE(0,HILLS_SIZE), 0.5f, 0.5f, shaper_noise33);
} }
return WORLD_ERROR_NONE; return WORLD_ERROR_NONE;

208
code/vendors/librg.h vendored
View File

@ -149,7 +149,7 @@
#define LIBRG_VERSION_MAJOR 6 #define LIBRG_VERSION_MAJOR 6
#define LIBRG_VERSION_MINOR 0 #define LIBRG_VERSION_MINOR 0
#define LIBRG_VERSION_PATCH 6 #define LIBRG_VERSION_PATCH 8
#define LIBRG_VERSION_PRE "" #define LIBRG_VERSION_PRE ""
// file: librg_hedley.h // file: librg_hedley.h
@ -2332,7 +2332,7 @@ LIBRG_BEGIN_C_DECLS
// ! // !
// =======================================================================// // =======================================================================//
LIBRG_API int32_t librg_world_read(librg_world *world, int64_t owner_id, const char *buffer, size_t size, void *userdata); LIBRG_API int32_t librg_world_read(librg_world *world, int64_t owner_id, LIBRG_IN const char *buffer, size_t size, void *userdata);
LIBRG_API int32_t librg_world_write(librg_world *world, int64_t owner_id, LIBRG_OUT char *buffer, LIBRG_INOUT size_t *size, void *userdata); LIBRG_API int32_t librg_world_write(librg_world *world, int64_t owner_id, LIBRG_OUT char *buffer, LIBRG_INOUT size_t *size, void *userdata);
LIBRG_END_C_DECLS LIBRG_END_C_DECLS
@ -2374,6 +2374,9 @@ LIBRG_END_C_DECLS
https://github.com/zpl-c/zpl https://github.com/zpl-c/zpl
Version History: Version History:
10.12.1 - Fix missing zpL_alloc_str
10.12.0 - Add zpl_crc64
10.11.1 - Fix zpl_time_utc_ms on 32-bit OSes
10.11.0 - Added zpl_file_stream_buf 10.11.0 - Added zpl_file_stream_buf
10.10.3 - Math type-punning fixes 10.10.3 - Math type-punning fixes
10.10.1 - Fix memory writing issue + new write-only in-situ flag 10.10.1 - Fix memory writing issue + new write-only in-situ flag
@ -2641,8 +2644,8 @@ LIBRG_END_C_DECLS
#define ZPL_H #define ZPL_H
#define ZPL_VERSION_MAJOR 10 #define ZPL_VERSION_MAJOR 10
#define ZPL_VERSION_MINOR 11 #define ZPL_VERSION_MINOR 12
#define ZPL_VERSION_PATCH 0 #define ZPL_VERSION_PATCH 1
#define ZPL_VERSION_PRE "" #define ZPL_VERSION_PRE ""
// file: zpl_hedley.h // file: zpl_hedley.h
@ -5661,7 +5664,7 @@ LIBRG_END_C_DECLS
ZPL_DEF_INLINE void *zpl_alloc_copy_align(zpl_allocator a, void const *src, zpl_isize size, zpl_isize alignment); ZPL_DEF_INLINE void *zpl_alloc_copy_align(zpl_allocator a, void const *src, zpl_isize size, zpl_isize alignment);
//! Allocate memory for null-terminated C-String. //! Allocate memory for null-terminated C-String.
ZPL_DEF_INLINE char *zpl_alloc_str(zpl_allocator a, char const *str); ZPL_DEF char *zpl_alloc_str(zpl_allocator a, char const *str);
//! Allocate memory for C-String with specified size. //! Allocate memory for C-String with specified size.
ZPL_DEF_INLINE char *zpl_alloc_str_len(zpl_allocator a, char const *str, zpl_isize len); ZPL_DEF_INLINE char *zpl_alloc_str_len(zpl_allocator a, char const *str, zpl_isize len);
@ -8175,6 +8178,7 @@ LIBRG_END_C_DECLS
ZPL_DEF zpl_u32 zpl_adler32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_adler32(void const *data, zpl_isize len);
ZPL_DEF zpl_u32 zpl_crc32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_crc32(void const *data, zpl_isize len);
ZPL_DEF zpl_u64 zpl_crc64(void const *data, zpl_isize len);
// These use FNV-1 algorithm // These use FNV-1 algorithm
ZPL_DEF zpl_u32 zpl_fnv32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_fnv32(void const *data, zpl_isize len);
@ -11134,7 +11138,7 @@ LIBRG_END_C_DECLS
sz = x & 7; sz = x & 7;
accept = zpl__utf8_accept_ranges[x >> 4]; accept = zpl__utf8_accept_ranges[x >> 4];
if (str_len < zpl_size_of(sz)) goto invalid_codepoint; if (str_len < sz) goto invalid_codepoint;
b1 = str[1]; b1 = str[1];
if (b1 < accept.lo || accept.hi < b1) goto invalid_codepoint; if (b1 < accept.lo || accept.hi < b1) goto invalid_codepoint;
@ -12181,13 +12185,13 @@ LIBRG_END_C_DECLS
ZPL_NOT_IMPLEMENTED; ZPL_NOT_IMPLEMENTED;
return 0; return 0;
#else #else
zpl_isize size;
int existing_fd = open(existing_filename, O_RDONLY, 0); int existing_fd = open(existing_filename, O_RDONLY, 0);
int new_fd = open(new_filename, O_WRONLY | O_CREAT, 0666);
struct stat stat_existing; struct stat stat_existing;
fstat(existing_fd, &stat_existing); fstat(existing_fd, &stat_existing);
zpl_isize size;
int new_fd = open(new_filename, O_WRONLY | O_CREAT, stat_existing.st_mode);
#if defined(ZPL_SYSTEM_FREEBSD) #if defined(ZPL_SYSTEM_FREEBSD)
size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size, NULL, 0, 0); size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size, NULL, 0, 0);
#else #else
@ -13156,7 +13160,7 @@ LIBRG_END_C_DECLS
#else #else
clock_gettime(0 /*CLOCK_REALTIME*/, &t); clock_gettime(0 /*CLOCK_REALTIME*/, &t);
#endif #endif
return (t.tv_sec * 1000 + t.tv_nsec * 1e-6 + ZPL__UNIX_TO_WIN32_EPOCH); return ((zpl_u64)t.tv_sec * 1000 + t.tv_nsec * 1e-6 + ZPL__UNIX_TO_WIN32_EPOCH);
} }
void zpl_sleep_ms(zpl_u32 ms) { void zpl_sleep_ms(zpl_u32 ms) {
@ -13814,7 +13818,7 @@ LIBRG_END_C_DECLS
return (b << 16) | a; return (b << 16) | a;
} }
zpl_global zpl_u32 const ZPL__CRC32_TABLE[256] = { zpl_global zpl_u32 const zpl__crc32_table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832,
0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a,
@ -13846,14 +13850,68 @@ LIBRG_END_C_DECLS
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
}; };
zpl_global zpl_u64 const zpl__crc64_table[256] = {
0x0000000000000000ull, 0x7ad870c830358979ull, 0xf5b0e190606b12f2ull, 0x8f689158505e9b8bull, 0xc038e5739841b68full, 0xbae095bba8743ff6ull,
0x358804e3f82aa47dull, 0x4f50742bc81f2d04ull, 0xab28ecb46814fe75ull, 0xd1f09c7c5821770cull, 0x5e980d24087fec87ull, 0x24407dec384a65feull,
0x6b1009c7f05548faull, 0x11c8790fc060c183ull, 0x9ea0e857903e5a08ull, 0xe478989fa00bd371ull, 0x7d08ff3b88be6f81ull, 0x07d08ff3b88be6f8ull,
0x88b81eabe8d57d73ull, 0xf2606e63d8e0f40aull, 0xbd301a4810ffd90eull, 0xc7e86a8020ca5077ull, 0x4880fbd87094cbfcull, 0x32588b1040a14285ull,
0xd620138fe0aa91f4ull, 0xacf86347d09f188dull, 0x2390f21f80c18306ull, 0x594882d7b0f40a7full, 0x1618f6fc78eb277bull, 0x6cc0863448deae02ull,
0xe3a8176c18803589ull, 0x997067a428b5bcf0ull, 0xfa11fe77117cdf02ull, 0x80c98ebf2149567bull,
0x0fa11fe77117cdf0ull, 0x75796f2f41224489ull, 0x3a291b04893d698dull, 0x40f16bccb908e0f4ull, 0xcf99fa94e9567b7full, 0xb5418a5cd963f206ull,
0x513912c379682177ull, 0x2be1620b495da80eull, 0xa489f35319033385ull, 0xde51839b2936bafcull, 0x9101f7b0e12997f8ull, 0xebd98778d11c1e81ull,
0x64b116208142850aull, 0x1e6966e8b1770c73ull, 0x8719014c99c2b083ull, 0xfdc17184a9f739faull, 0x72a9e0dcf9a9a271ull, 0x08719014c99c2b08ull,
0x4721e43f0183060cull, 0x3df994f731b68f75ull, 0xb29105af61e814feull, 0xc849756751dd9d87ull, 0x2c31edf8f1d64ef6ull, 0x56e99d30c1e3c78full,
0xd9810c6891bd5c04ull, 0xa3597ca0a188d57dull, 0xec09088b6997f879ull, 0x96d1784359a27100ull, 0x19b9e91b09fcea8bull, 0x636199d339c963f2ull,
0xdf7adabd7a6e2d6full, 0xa5a2aa754a5ba416ull, 0x2aca3b2d1a053f9dull, 0x50124be52a30b6e4ull, 0x1f423fcee22f9be0ull, 0x659a4f06d21a1299ull,
0xeaf2de5e82448912ull, 0x902aae96b271006bull, 0x74523609127ad31aull, 0x0e8a46c1224f5a63ull, 0x81e2d7997211c1e8ull, 0xfb3aa75142244891ull,
0xb46ad37a8a3b6595ull, 0xceb2a3b2ba0eececull, 0x41da32eaea507767ull, 0x3b024222da65fe1eull, 0xa2722586f2d042eeull, 0xd8aa554ec2e5cb97ull,
0x57c2c41692bb501cull, 0x2d1ab4dea28ed965ull, 0x624ac0f56a91f461ull, 0x1892b03d5aa47d18ull, 0x97fa21650afae693ull, 0xed2251ad3acf6feaull,
0x095ac9329ac4bc9bull, 0x7382b9faaaf135e2ull, 0xfcea28a2faafae69ull, 0x8632586aca9a2710ull, 0xc9622c4102850a14ull, 0xb3ba5c8932b0836dull,
0x3cd2cdd162ee18e6ull, 0x460abd1952db919full, 0x256b24ca6b12f26dull, 0x5fb354025b277b14ull, 0xd0dbc55a0b79e09full, 0xaa03b5923b4c69e6ull,
0xe553c1b9f35344e2ull, 0x9f8bb171c366cd9bull, 0x10e3202993385610ull, 0x6a3b50e1a30ddf69ull, 0x8e43c87e03060c18ull, 0xf49bb8b633338561ull,
0x7bf329ee636d1eeaull, 0x012b592653589793ull, 0x4e7b2d0d9b47ba97ull, 0x34a35dc5ab7233eeull, 0xbbcbcc9dfb2ca865ull, 0xc113bc55cb19211cull,
0x5863dbf1e3ac9decull, 0x22bbab39d3991495ull, 0xadd33a6183c78f1eull, 0xd70b4aa9b3f20667ull, 0x985b3e827bed2b63ull, 0xe2834e4a4bd8a21aull,
0x6debdf121b863991ull, 0x1733afda2bb3b0e8ull, 0xf34b37458bb86399ull, 0x8993478dbb8deae0ull, 0x06fbd6d5ebd3716bull, 0x7c23a61ddbe6f812ull,
0x3373d23613f9d516ull, 0x49aba2fe23cc5c6full, 0xc6c333a67392c7e4ull, 0xbc1b436e43a74e9dull, 0x95ac9329ac4bc9b5ull, 0xef74e3e19c7e40ccull,
0x601c72b9cc20db47ull, 0x1ac40271fc15523eull, 0x5594765a340a7f3aull, 0x2f4c0692043ff643ull, 0xa02497ca54616dc8ull, 0xdafce7026454e4b1ull,
0x3e847f9dc45f37c0ull, 0x445c0f55f46abeb9ull, 0xcb349e0da4342532ull, 0xb1eceec59401ac4bull, 0xfebc9aee5c1e814full, 0x8464ea266c2b0836ull,
0x0b0c7b7e3c7593bdull, 0x71d40bb60c401ac4ull, 0xe8a46c1224f5a634ull, 0x927c1cda14c02f4dull, 0x1d148d82449eb4c6ull, 0x67ccfd4a74ab3dbfull,
0x289c8961bcb410bbull, 0x5244f9a98c8199c2ull, 0xdd2c68f1dcdf0249ull, 0xa7f41839ecea8b30ull, 0x438c80a64ce15841ull, 0x3954f06e7cd4d138ull,
0xb63c61362c8a4ab3ull, 0xcce411fe1cbfc3caull, 0x83b465d5d4a0eeceull, 0xf96c151de49567b7ull, 0x76048445b4cbfc3cull, 0x0cdcf48d84fe7545ull,
0x6fbd6d5ebd3716b7ull, 0x15651d968d029fceull, 0x9a0d8ccedd5c0445ull, 0xe0d5fc06ed698d3cull, 0xaf85882d2576a038ull, 0xd55df8e515432941ull,
0x5a3569bd451db2caull, 0x20ed197575283bb3ull, 0xc49581ead523e8c2ull, 0xbe4df122e51661bbull, 0x3125607ab548fa30ull, 0x4bfd10b2857d7349ull,
0x04ad64994d625e4dull, 0x7e7514517d57d734ull, 0xf11d85092d094cbfull, 0x8bc5f5c11d3cc5c6ull, 0x12b5926535897936ull, 0x686de2ad05bcf04full,
0xe70573f555e26bc4ull, 0x9ddd033d65d7e2bdull, 0xd28d7716adc8cfb9ull, 0xa85507de9dfd46c0ull, 0x273d9686cda3dd4bull, 0x5de5e64efd965432ull,
0xb99d7ed15d9d8743ull, 0xc3450e196da80e3aull, 0x4c2d9f413df695b1ull, 0x36f5ef890dc31cc8ull, 0x79a59ba2c5dc31ccull, 0x037deb6af5e9b8b5ull,
0x8c157a32a5b7233eull, 0xf6cd0afa9582aa47ull, 0x4ad64994d625e4daull, 0x300e395ce6106da3ull, 0xbf66a804b64ef628ull, 0xc5bed8cc867b7f51ull,
0x8aeeace74e645255ull, 0xf036dc2f7e51db2cull, 0x7f5e4d772e0f40a7ull, 0x05863dbf1e3ac9deull, 0xe1fea520be311aafull, 0x9b26d5e88e0493d6ull,
0x144e44b0de5a085dull, 0x6e963478ee6f8124ull, 0x21c640532670ac20ull, 0x5b1e309b16452559ull, 0xd476a1c3461bbed2ull, 0xaeaed10b762e37abull,
0x37deb6af5e9b8b5bull, 0x4d06c6676eae0222ull, 0xc26e573f3ef099a9ull, 0xb8b627f70ec510d0ull, 0xf7e653dcc6da3dd4ull, 0x8d3e2314f6efb4adull,
0x0256b24ca6b12f26ull, 0x788ec2849684a65full, 0x9cf65a1b368f752eull, 0xe62e2ad306bafc57ull, 0x6946bb8b56e467dcull, 0x139ecb4366d1eea5ull,
0x5ccebf68aecec3a1ull, 0x2616cfa09efb4ad8ull, 0xa97e5ef8cea5d153ull, 0xd3a62e30fe90582aull, 0xb0c7b7e3c7593bd8ull, 0xca1fc72bf76cb2a1ull,
0x45775673a732292aull, 0x3faf26bb9707a053ull, 0x70ff52905f188d57ull, 0x0a2722586f2d042eull, 0x854fb3003f739fa5ull, 0xff97c3c80f4616dcull,
0x1bef5b57af4dc5adull, 0x61372b9f9f784cd4ull, 0xee5fbac7cf26d75full, 0x9487ca0fff135e26ull, 0xdbd7be24370c7322ull, 0xa10fceec0739fa5bull,
0x2e675fb4576761d0ull, 0x54bf2f7c6752e8a9ull, 0xcdcf48d84fe75459ull, 0xb71738107fd2dd20ull, 0x387fa9482f8c46abull, 0x42a7d9801fb9cfd2ull,
0x0df7adabd7a6e2d6ull, 0x772fdd63e7936bafull, 0xf8474c3bb7cdf024ull, 0x829f3cf387f8795dull, 0x66e7a46c27f3aa2cull, 0x1c3fd4a417c62355ull,
0x935745fc4798b8deull, 0xe98f353477ad31a7ull, 0xa6df411fbfb21ca3ull, 0xdc0731d78f8795daull, 0x536fa08fdfd90e51ull, 0x29b7d047efec8728ull,
};
zpl_u32 zpl_crc32(void const *data, zpl_isize len) { zpl_u32 zpl_crc32(void const *data, zpl_isize len) {
zpl_isize remaining; zpl_isize remaining;
zpl_u32 result = ~(cast(zpl_u32) 0); zpl_u32 result = ~(cast(zpl_u32) 0);
zpl_u8 const *c = cast(zpl_u8 const *) data; zpl_u8 const *c = cast(zpl_u8 const *) data;
for (remaining = len; remaining--; c++) result = (result >> 8) ^ (ZPL__CRC32_TABLE[(result ^ *c) & 0xff]); for (remaining = len; remaining--; c++) result = (result >> 8) ^ (zpl__crc32_table[(result ^ *c) & 0xff]);
return ~result; return ~result;
} }
zpl_u64 zpl_crc64(void const *data, zpl_isize len) {
zpl_isize remaining;
zpl_u64 result = (cast(zpl_u64)0);
zpl_u8 const *c = cast(zpl_u8 const *) data;
for (remaining = len; remaining--; c++) result = (result >> 8) ^ (zpl__crc64_table[(result ^ *c) & 0xff]);
return result;
}
zpl_u32 zpl_fnv32(void const *data, zpl_isize len) { zpl_u32 zpl_fnv32(void const *data, zpl_isize len) {
zpl_isize i; zpl_isize i;
zpl_u32 h = 0x811c9dc5; zpl_u32 h = 0x811c9dc5;
@ -14090,7 +14148,6 @@ LIBRG_END_C_DECLS
} }
zpl_u64 zpl_murmur64_seed(void const *data_, zpl_isize len, zpl_u64 seed) { zpl_u64 zpl_murmur64_seed(void const *data_, zpl_isize len, zpl_u64 seed) {
#if defined(ZPL_ARCH_64_BIT)
zpl_u64 const m = 0xc6a4a7935bd1e995ULL; zpl_u64 const m = 0xc6a4a7935bd1e995ULL;
zpl_i32 const r = 47; zpl_i32 const r = 47;
@ -14127,65 +14184,6 @@ LIBRG_END_C_DECLS
h ^= h >> r; h ^= h >> r;
return h; return h;
#else
zpl_u64 h;
zpl_u32 const m = 0x5bd1e995;
zpl_i32 const r = 24;
zpl_u32 h1 = cast(zpl_u32)(seed) ^ cast(zpl_u32)(len);
zpl_u32 h2 = cast(zpl_u32)(seed >> 32);
zpl_u32 const *data = cast(zpl_u32 const *) data_;
while (len >= 8) {
zpl_u32 k1, k2;
k1 = *data++;
k1 *= m;
k1 ^= k1 >> r;
k1 *= m;
h1 *= m;
h1 ^= k1;
len -= 4;
k2 = *data++;
k2 *= m;
k2 ^= k2 >> r;
k2 *= m;
h2 *= m;
h2 ^= k2;
len -= 4;
}
if (len >= 4) {
zpl_u32 k1 = *data++;
k1 *= m;
k1 ^= k1 >> r;
k1 *= m;
h1 *= m;
h1 ^= k1;
len -= 4;
}
switch (len) {
case 3: h2 ^= (cast(zpl_u8 const *) data)[2] << 16;
case 2: h2 ^= (cast(zpl_u8 const *) data)[1] << 8;
case 1: h2 ^= (cast(zpl_u8 const *) data)[0] << 0; h2 *= m;
};
h1 ^= h2 >> 18;
h1 *= m;
h2 ^= h1 >> 22;
h2 *= m;
h1 ^= h2 >> 17;
h1 *= m;
h2 ^= h1 >> 19;
h2 *= m;
h = h1;
h = (h << 32) | h2;
return h;
#endif
} }
ZPL_END_C_DECLS ZPL_END_C_DECLS
@ -14813,8 +14811,6 @@ LIBRG_END_C_DECLS
if ((offset < len) && (pattern[offset] == '?')) { if ((offset < len) && (pattern[offset] == '?')) {
quantifier = ZPL_RE_OP_ONE_OR_MORE_SHORTEST; quantifier = ZPL_RE_OP_ONE_OR_MORE_SHORTEST;
if (quantifier == ZPL_RE_OP_ZERO_OR_MORE)
quantifier = ZPL_RE_OP_ZERO_OR_MORE_SHORTEST;
offset++; offset++;
} }
@ -17195,7 +17191,6 @@ LIBRG_END_C_DECLS
ZPL_BEGIN_C_DECLS ZPL_BEGIN_C_DECLS
static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_special_char(char c) { return !!zpl_strchr("<>:/", c); }
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_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); } static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_delim_char(char c) { return !!zpl_strchr(",|\n", c); }
@ -19653,27 +19648,6 @@ typedef struct librg_world_t {
void *userdata; void *userdata;
} librg_world_t; } librg_world_t;
/* unsued */
// #define LIBRG_OBSERVE_ALL (-0x01)
// #define LIBRG_OBSERVE_NONE (+0x00)
// typedef enum librg_entity_refreshing {
// LIBRG_CONSTANT, /* int argument, update entity every Nth tick */
// LIBRG_LINEAR, /* float argument, linearly decrease update interval based on distance step (argument) */
// LIBRG_QUADRATIC, /* float argument, cubicly decrease update inverval based on distance step (argument) */
// } librg_entity_refreshing;
// typedef enum {
// LIBRG_ENTITY_DYNAMIC,
// LIBRG_ENTITY_STATIC,
// } librg_behavior_type;
// typedef enum {
// LIBRG_BEHAVIOR_TYPE,
// LIBRG_BEHAVIOR_STEPBACK,
// } librg_behavior;
LIBRG_END_C_DECLS LIBRG_END_C_DECLS
// file: source/context.c // file: source/context.c
@ -20329,41 +20303,6 @@ int8_t librg_entity_visibility_owner_get(librg_world *world, int64_t entity_id,
return (value ? *value : LIBRG_VISIBLITY_DEFAULT); return (value ? *value : LIBRG_VISIBLITY_DEFAULT);
} }
#if 0
// int8_t librg_entity_type_set(librg_world *world, int64_t entity_id, uint8_t type) {
// LIBRG_ASSERT(world); if (!world) return LIBRG_WORLD_INVALID;
// librg_world_t *wld = (librg_world_t *)world;
// librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
// if (entity == NULL) return LIBRG_ENTITY_UNTRACKED;
// entity->type = type;
// return LIBRG_OK;
// }
// int16_t librg_entity_type_get(librg_world *world, int64_t entity_id) {
// LIBRG_ASSERT(world); if (!world) return LIBRG_WORLD_INVALID;
// librg_world_t *wld = (librg_world_t *)world;
// librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
// if (entity == NULL) return LIBRG_ENTITY_UNTRACKED;
// return entity->type;
// }
int librg_entity_refresh_set(librg_world *, int64_t entity_id, int type, float value); // ? {
return LIBRG_OK
}
int librg_entity_refresh_get(librg_world *, int64_t entity_id, int *type, float *value) {
return LIBRG_OK
}
// TODO: entity visibility
#endif
LIBRG_END_C_DECLS LIBRG_END_C_DECLS
// file: source/world.c // file: source/world.c
@ -20865,9 +20804,10 @@ int32_t librg_world_read(librg_world *world, int64_t owner_id, const char *buffe
else if (seg->type == LIBRG_WRITE_UPDATE) { else if (seg->type == LIBRG_WRITE_UPDATE) {
/* try to check if entity exists, and if it is foreign OR owner and token are correct */ /* try to check if entity exists, and if it is foreign OR owner and token are correct */
action_id = (librg_entity_tracked(world, val->id) == LIBRG_TRUE action_id = (librg_entity_tracked(world, val->id) == LIBRG_TRUE
&& (entity_blob->flag_foreign && entity_blob
|| (entity_blob->owner_id == owner_id && (entity_blob->flag_foreign || (entity_blob->owner_id == owner_id
&& entity_blob->ownership_token == val->token))) && entity_blob->ownership_token == val->token)
))
? LIBRG_READ_UPDATE ? LIBRG_READ_UPDATE
: LIBRG_ERROR_UPDATE; : LIBRG_ERROR_UPDATE;
} }

141
code/vendors/zpl.h vendored
View File

@ -27,6 +27,9 @@ GitHub:
https://github.com/zpl-c/zpl https://github.com/zpl-c/zpl
Version History: Version History:
10.12.1 - Fix missing zpL_alloc_str
10.12.0 - Add zpl_crc64
10.11.1 - Fix zpl_time_utc_ms on 32-bit OSes
10.11.0 - Added zpl_file_stream_buf 10.11.0 - Added zpl_file_stream_buf
10.10.3 - Math type-punning fixes 10.10.3 - Math type-punning fixes
10.10.1 - Fix memory writing issue + new write-only in-situ flag 10.10.1 - Fix memory writing issue + new write-only in-situ flag
@ -294,8 +297,8 @@ Version History:
#define ZPL_H #define ZPL_H
#define ZPL_VERSION_MAJOR 10 #define ZPL_VERSION_MAJOR 10
#define ZPL_VERSION_MINOR 11 #define ZPL_VERSION_MINOR 12
#define ZPL_VERSION_PATCH 0 #define ZPL_VERSION_PATCH 1
#define ZPL_VERSION_PRE "" #define ZPL_VERSION_PRE ""
// file: zpl_hedley.h // file: zpl_hedley.h
@ -3314,7 +3317,7 @@ ZPL_END_C_DECLS
ZPL_DEF_INLINE void *zpl_alloc_copy_align(zpl_allocator a, void const *src, zpl_isize size, zpl_isize alignment); ZPL_DEF_INLINE void *zpl_alloc_copy_align(zpl_allocator a, void const *src, zpl_isize size, zpl_isize alignment);
//! Allocate memory for null-terminated C-String. //! Allocate memory for null-terminated C-String.
ZPL_DEF_INLINE char *zpl_alloc_str(zpl_allocator a, char const *str); ZPL_DEF char *zpl_alloc_str(zpl_allocator a, char const *str);
//! Allocate memory for C-String with specified size. //! Allocate memory for C-String with specified size.
ZPL_DEF_INLINE char *zpl_alloc_str_len(zpl_allocator a, char const *str, zpl_isize len); ZPL_DEF_INLINE char *zpl_alloc_str_len(zpl_allocator a, char const *str, zpl_isize len);
@ -5828,6 +5831,7 @@ ZPL_END_C_DECLS
ZPL_DEF zpl_u32 zpl_adler32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_adler32(void const *data, zpl_isize len);
ZPL_DEF zpl_u32 zpl_crc32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_crc32(void const *data, zpl_isize len);
ZPL_DEF zpl_u64 zpl_crc64(void const *data, zpl_isize len);
// These use FNV-1 algorithm // These use FNV-1 algorithm
ZPL_DEF zpl_u32 zpl_fnv32(void const *data, zpl_isize len); ZPL_DEF zpl_u32 zpl_fnv32(void const *data, zpl_isize len);
@ -8787,7 +8791,7 @@ ZPL_END_C_DECLS
sz = x & 7; sz = x & 7;
accept = zpl__utf8_accept_ranges[x >> 4]; accept = zpl__utf8_accept_ranges[x >> 4];
if (str_len < zpl_size_of(sz)) goto invalid_codepoint; if (str_len < sz) goto invalid_codepoint;
b1 = str[1]; b1 = str[1];
if (b1 < accept.lo || accept.hi < b1) goto invalid_codepoint; if (b1 < accept.lo || accept.hi < b1) goto invalid_codepoint;
@ -9834,13 +9838,13 @@ ZPL_END_C_DECLS
ZPL_NOT_IMPLEMENTED; ZPL_NOT_IMPLEMENTED;
return 0; return 0;
#else #else
zpl_isize size;
int existing_fd = open(existing_filename, O_RDONLY, 0); int existing_fd = open(existing_filename, O_RDONLY, 0);
int new_fd = open(new_filename, O_WRONLY | O_CREAT, 0666);
struct stat stat_existing; struct stat stat_existing;
fstat(existing_fd, &stat_existing); fstat(existing_fd, &stat_existing);
zpl_isize size;
int new_fd = open(new_filename, O_WRONLY | O_CREAT, stat_existing.st_mode);
#if defined(ZPL_SYSTEM_FREEBSD) #if defined(ZPL_SYSTEM_FREEBSD)
size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size, NULL, 0, 0); size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size, NULL, 0, 0);
#else #else
@ -10809,7 +10813,7 @@ ZPL_END_C_DECLS
#else #else
clock_gettime(0 /*CLOCK_REALTIME*/, &t); clock_gettime(0 /*CLOCK_REALTIME*/, &t);
#endif #endif
return (t.tv_sec * 1000 + t.tv_nsec * 1e-6 + ZPL__UNIX_TO_WIN32_EPOCH); return ((zpl_u64)t.tv_sec * 1000 + t.tv_nsec * 1e-6 + ZPL__UNIX_TO_WIN32_EPOCH);
} }
void zpl_sleep_ms(zpl_u32 ms) { void zpl_sleep_ms(zpl_u32 ms) {
@ -11467,7 +11471,7 @@ ZPL_END_C_DECLS
return (b << 16) | a; return (b << 16) | a;
} }
zpl_global zpl_u32 const ZPL__CRC32_TABLE[256] = { zpl_global zpl_u32 const zpl__crc32_table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832,
0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a,
@ -11499,14 +11503,68 @@ ZPL_END_C_DECLS
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
}; };
zpl_global zpl_u64 const zpl__crc64_table[256] = {
0x0000000000000000ull, 0x7ad870c830358979ull, 0xf5b0e190606b12f2ull, 0x8f689158505e9b8bull, 0xc038e5739841b68full, 0xbae095bba8743ff6ull,
0x358804e3f82aa47dull, 0x4f50742bc81f2d04ull, 0xab28ecb46814fe75ull, 0xd1f09c7c5821770cull, 0x5e980d24087fec87ull, 0x24407dec384a65feull,
0x6b1009c7f05548faull, 0x11c8790fc060c183ull, 0x9ea0e857903e5a08ull, 0xe478989fa00bd371ull, 0x7d08ff3b88be6f81ull, 0x07d08ff3b88be6f8ull,
0x88b81eabe8d57d73ull, 0xf2606e63d8e0f40aull, 0xbd301a4810ffd90eull, 0xc7e86a8020ca5077ull, 0x4880fbd87094cbfcull, 0x32588b1040a14285ull,
0xd620138fe0aa91f4ull, 0xacf86347d09f188dull, 0x2390f21f80c18306ull, 0x594882d7b0f40a7full, 0x1618f6fc78eb277bull, 0x6cc0863448deae02ull,
0xe3a8176c18803589ull, 0x997067a428b5bcf0ull, 0xfa11fe77117cdf02ull, 0x80c98ebf2149567bull,
0x0fa11fe77117cdf0ull, 0x75796f2f41224489ull, 0x3a291b04893d698dull, 0x40f16bccb908e0f4ull, 0xcf99fa94e9567b7full, 0xb5418a5cd963f206ull,
0x513912c379682177ull, 0x2be1620b495da80eull, 0xa489f35319033385ull, 0xde51839b2936bafcull, 0x9101f7b0e12997f8ull, 0xebd98778d11c1e81ull,
0x64b116208142850aull, 0x1e6966e8b1770c73ull, 0x8719014c99c2b083ull, 0xfdc17184a9f739faull, 0x72a9e0dcf9a9a271ull, 0x08719014c99c2b08ull,
0x4721e43f0183060cull, 0x3df994f731b68f75ull, 0xb29105af61e814feull, 0xc849756751dd9d87ull, 0x2c31edf8f1d64ef6ull, 0x56e99d30c1e3c78full,
0xd9810c6891bd5c04ull, 0xa3597ca0a188d57dull, 0xec09088b6997f879ull, 0x96d1784359a27100ull, 0x19b9e91b09fcea8bull, 0x636199d339c963f2ull,
0xdf7adabd7a6e2d6full, 0xa5a2aa754a5ba416ull, 0x2aca3b2d1a053f9dull, 0x50124be52a30b6e4ull, 0x1f423fcee22f9be0ull, 0x659a4f06d21a1299ull,
0xeaf2de5e82448912ull, 0x902aae96b271006bull, 0x74523609127ad31aull, 0x0e8a46c1224f5a63ull, 0x81e2d7997211c1e8ull, 0xfb3aa75142244891ull,
0xb46ad37a8a3b6595ull, 0xceb2a3b2ba0eececull, 0x41da32eaea507767ull, 0x3b024222da65fe1eull, 0xa2722586f2d042eeull, 0xd8aa554ec2e5cb97ull,
0x57c2c41692bb501cull, 0x2d1ab4dea28ed965ull, 0x624ac0f56a91f461ull, 0x1892b03d5aa47d18ull, 0x97fa21650afae693ull, 0xed2251ad3acf6feaull,
0x095ac9329ac4bc9bull, 0x7382b9faaaf135e2ull, 0xfcea28a2faafae69ull, 0x8632586aca9a2710ull, 0xc9622c4102850a14ull, 0xb3ba5c8932b0836dull,
0x3cd2cdd162ee18e6ull, 0x460abd1952db919full, 0x256b24ca6b12f26dull, 0x5fb354025b277b14ull, 0xd0dbc55a0b79e09full, 0xaa03b5923b4c69e6ull,
0xe553c1b9f35344e2ull, 0x9f8bb171c366cd9bull, 0x10e3202993385610ull, 0x6a3b50e1a30ddf69ull, 0x8e43c87e03060c18ull, 0xf49bb8b633338561ull,
0x7bf329ee636d1eeaull, 0x012b592653589793ull, 0x4e7b2d0d9b47ba97ull, 0x34a35dc5ab7233eeull, 0xbbcbcc9dfb2ca865ull, 0xc113bc55cb19211cull,
0x5863dbf1e3ac9decull, 0x22bbab39d3991495ull, 0xadd33a6183c78f1eull, 0xd70b4aa9b3f20667ull, 0x985b3e827bed2b63ull, 0xe2834e4a4bd8a21aull,
0x6debdf121b863991ull, 0x1733afda2bb3b0e8ull, 0xf34b37458bb86399ull, 0x8993478dbb8deae0ull, 0x06fbd6d5ebd3716bull, 0x7c23a61ddbe6f812ull,
0x3373d23613f9d516ull, 0x49aba2fe23cc5c6full, 0xc6c333a67392c7e4ull, 0xbc1b436e43a74e9dull, 0x95ac9329ac4bc9b5ull, 0xef74e3e19c7e40ccull,
0x601c72b9cc20db47ull, 0x1ac40271fc15523eull, 0x5594765a340a7f3aull, 0x2f4c0692043ff643ull, 0xa02497ca54616dc8ull, 0xdafce7026454e4b1ull,
0x3e847f9dc45f37c0ull, 0x445c0f55f46abeb9ull, 0xcb349e0da4342532ull, 0xb1eceec59401ac4bull, 0xfebc9aee5c1e814full, 0x8464ea266c2b0836ull,
0x0b0c7b7e3c7593bdull, 0x71d40bb60c401ac4ull, 0xe8a46c1224f5a634ull, 0x927c1cda14c02f4dull, 0x1d148d82449eb4c6ull, 0x67ccfd4a74ab3dbfull,
0x289c8961bcb410bbull, 0x5244f9a98c8199c2ull, 0xdd2c68f1dcdf0249ull, 0xa7f41839ecea8b30ull, 0x438c80a64ce15841ull, 0x3954f06e7cd4d138ull,
0xb63c61362c8a4ab3ull, 0xcce411fe1cbfc3caull, 0x83b465d5d4a0eeceull, 0xf96c151de49567b7ull, 0x76048445b4cbfc3cull, 0x0cdcf48d84fe7545ull,
0x6fbd6d5ebd3716b7ull, 0x15651d968d029fceull, 0x9a0d8ccedd5c0445ull, 0xe0d5fc06ed698d3cull, 0xaf85882d2576a038ull, 0xd55df8e515432941ull,
0x5a3569bd451db2caull, 0x20ed197575283bb3ull, 0xc49581ead523e8c2ull, 0xbe4df122e51661bbull, 0x3125607ab548fa30ull, 0x4bfd10b2857d7349ull,
0x04ad64994d625e4dull, 0x7e7514517d57d734ull, 0xf11d85092d094cbfull, 0x8bc5f5c11d3cc5c6ull, 0x12b5926535897936ull, 0x686de2ad05bcf04full,
0xe70573f555e26bc4ull, 0x9ddd033d65d7e2bdull, 0xd28d7716adc8cfb9ull, 0xa85507de9dfd46c0ull, 0x273d9686cda3dd4bull, 0x5de5e64efd965432ull,
0xb99d7ed15d9d8743ull, 0xc3450e196da80e3aull, 0x4c2d9f413df695b1ull, 0x36f5ef890dc31cc8ull, 0x79a59ba2c5dc31ccull, 0x037deb6af5e9b8b5ull,
0x8c157a32a5b7233eull, 0xf6cd0afa9582aa47ull, 0x4ad64994d625e4daull, 0x300e395ce6106da3ull, 0xbf66a804b64ef628ull, 0xc5bed8cc867b7f51ull,
0x8aeeace74e645255ull, 0xf036dc2f7e51db2cull, 0x7f5e4d772e0f40a7ull, 0x05863dbf1e3ac9deull, 0xe1fea520be311aafull, 0x9b26d5e88e0493d6ull,
0x144e44b0de5a085dull, 0x6e963478ee6f8124ull, 0x21c640532670ac20ull, 0x5b1e309b16452559ull, 0xd476a1c3461bbed2ull, 0xaeaed10b762e37abull,
0x37deb6af5e9b8b5bull, 0x4d06c6676eae0222ull, 0xc26e573f3ef099a9ull, 0xb8b627f70ec510d0ull, 0xf7e653dcc6da3dd4ull, 0x8d3e2314f6efb4adull,
0x0256b24ca6b12f26ull, 0x788ec2849684a65full, 0x9cf65a1b368f752eull, 0xe62e2ad306bafc57ull, 0x6946bb8b56e467dcull, 0x139ecb4366d1eea5ull,
0x5ccebf68aecec3a1ull, 0x2616cfa09efb4ad8ull, 0xa97e5ef8cea5d153ull, 0xd3a62e30fe90582aull, 0xb0c7b7e3c7593bd8ull, 0xca1fc72bf76cb2a1ull,
0x45775673a732292aull, 0x3faf26bb9707a053ull, 0x70ff52905f188d57ull, 0x0a2722586f2d042eull, 0x854fb3003f739fa5ull, 0xff97c3c80f4616dcull,
0x1bef5b57af4dc5adull, 0x61372b9f9f784cd4ull, 0xee5fbac7cf26d75full, 0x9487ca0fff135e26ull, 0xdbd7be24370c7322ull, 0xa10fceec0739fa5bull,
0x2e675fb4576761d0ull, 0x54bf2f7c6752e8a9ull, 0xcdcf48d84fe75459ull, 0xb71738107fd2dd20ull, 0x387fa9482f8c46abull, 0x42a7d9801fb9cfd2ull,
0x0df7adabd7a6e2d6ull, 0x772fdd63e7936bafull, 0xf8474c3bb7cdf024ull, 0x829f3cf387f8795dull, 0x66e7a46c27f3aa2cull, 0x1c3fd4a417c62355ull,
0x935745fc4798b8deull, 0xe98f353477ad31a7ull, 0xa6df411fbfb21ca3ull, 0xdc0731d78f8795daull, 0x536fa08fdfd90e51ull, 0x29b7d047efec8728ull,
};
zpl_u32 zpl_crc32(void const *data, zpl_isize len) { zpl_u32 zpl_crc32(void const *data, zpl_isize len) {
zpl_isize remaining; zpl_isize remaining;
zpl_u32 result = ~(cast(zpl_u32) 0); zpl_u32 result = ~(cast(zpl_u32) 0);
zpl_u8 const *c = cast(zpl_u8 const *) data; zpl_u8 const *c = cast(zpl_u8 const *) data;
for (remaining = len; remaining--; c++) result = (result >> 8) ^ (ZPL__CRC32_TABLE[(result ^ *c) & 0xff]); for (remaining = len; remaining--; c++) result = (result >> 8) ^ (zpl__crc32_table[(result ^ *c) & 0xff]);
return ~result; return ~result;
} }
zpl_u64 zpl_crc64(void const *data, zpl_isize len) {
zpl_isize remaining;
zpl_u64 result = (cast(zpl_u64)0);
zpl_u8 const *c = cast(zpl_u8 const *) data;
for (remaining = len; remaining--; c++) result = (result >> 8) ^ (zpl__crc64_table[(result ^ *c) & 0xff]);
return result;
}
zpl_u32 zpl_fnv32(void const *data, zpl_isize len) { zpl_u32 zpl_fnv32(void const *data, zpl_isize len) {
zpl_isize i; zpl_isize i;
zpl_u32 h = 0x811c9dc5; zpl_u32 h = 0x811c9dc5;
@ -11743,7 +11801,6 @@ ZPL_END_C_DECLS
} }
zpl_u64 zpl_murmur64_seed(void const *data_, zpl_isize len, zpl_u64 seed) { zpl_u64 zpl_murmur64_seed(void const *data_, zpl_isize len, zpl_u64 seed) {
#if defined(ZPL_ARCH_64_BIT)
zpl_u64 const m = 0xc6a4a7935bd1e995ULL; zpl_u64 const m = 0xc6a4a7935bd1e995ULL;
zpl_i32 const r = 47; zpl_i32 const r = 47;
@ -11780,65 +11837,6 @@ ZPL_END_C_DECLS
h ^= h >> r; h ^= h >> r;
return h; return h;
#else
zpl_u64 h;
zpl_u32 const m = 0x5bd1e995;
zpl_i32 const r = 24;
zpl_u32 h1 = cast(zpl_u32)(seed) ^ cast(zpl_u32)(len);
zpl_u32 h2 = cast(zpl_u32)(seed >> 32);
zpl_u32 const *data = cast(zpl_u32 const *) data_;
while (len >= 8) {
zpl_u32 k1, k2;
k1 = *data++;
k1 *= m;
k1 ^= k1 >> r;
k1 *= m;
h1 *= m;
h1 ^= k1;
len -= 4;
k2 = *data++;
k2 *= m;
k2 ^= k2 >> r;
k2 *= m;
h2 *= m;
h2 ^= k2;
len -= 4;
}
if (len >= 4) {
zpl_u32 k1 = *data++;
k1 *= m;
k1 ^= k1 >> r;
k1 *= m;
h1 *= m;
h1 ^= k1;
len -= 4;
}
switch (len) {
case 3: h2 ^= (cast(zpl_u8 const *) data)[2] << 16;
case 2: h2 ^= (cast(zpl_u8 const *) data)[1] << 8;
case 1: h2 ^= (cast(zpl_u8 const *) data)[0] << 0; h2 *= m;
};
h1 ^= h2 >> 18;
h1 *= m;
h2 ^= h1 >> 22;
h2 *= m;
h1 ^= h2 >> 17;
h1 *= m;
h2 ^= h1 >> 19;
h2 *= m;
h = h1;
h = (h << 32) | h2;
return h;
#endif
} }
ZPL_END_C_DECLS ZPL_END_C_DECLS
@ -12466,8 +12464,6 @@ ZPL_END_C_DECLS
if ((offset < len) && (pattern[offset] == '?')) { if ((offset < len) && (pattern[offset] == '?')) {
quantifier = ZPL_RE_OP_ONE_OR_MORE_SHORTEST; quantifier = ZPL_RE_OP_ONE_OR_MORE_SHORTEST;
if (quantifier == ZPL_RE_OP_ZERO_OR_MORE)
quantifier = ZPL_RE_OP_ZERO_OR_MORE_SHORTEST;
offset++; offset++;
} }
@ -14848,7 +14844,6 @@ ZPL_END_C_DECLS
ZPL_BEGIN_C_DECLS ZPL_BEGIN_C_DECLS
static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_special_char(char c) { return !!zpl_strchr("<>:/", c); }
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_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); } static ZPL_ALWAYS_INLINE zpl_b32 zpl__json_is_delim_char(char c) { return !!zpl_strchr(",|\n", c); }