diff --git a/engine/bind/v4k.lua b/engine/bind/v4k.lua
index 4d4fca0..3f079ea 100644
--- a/engine/bind/v4k.lua
+++ b/engine/bind/v4k.lua
@@ -2118,7 +2118,8 @@ enum { NETWORK_RANK = 0 };
enum { NETWORK_PING = 1 };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
-enum { NETWORK_USERID = 5, NETWORK_COUNT , NETWORK_CAPACITY };
+enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
+enum { NETWORK_USERID = 7, NETWORK_COUNT , NETWORK_CAPACITY };
int64_t network_get(uint64_t key);
int64_t network_put(uint64_t key, int64_t value);
void network_rpc(const char *signature, void *function);
diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h
index cc3259f..43e1e50 100644
--- a/engine/joint/v4k.h
+++ b/engine/joint/v4k.h
@@ -15948,7 +15948,8 @@ enum { NETWORK_RANK = 0 }; // [0..N] where 0 is server
enum { NETWORK_PING = 1 }; // NETWORK_BANDWIDTH, NETWORK_QUALITY };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
-enum { NETWORK_USERID = 5, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
+enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
+enum { NETWORK_USERID = 7, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
API int64_t network_get(uint64_t key);
API int64_t network_put(uint64_t key, int64_t value);
@@ -338767,6 +338768,7 @@ void network_create(unsigned max_clients, const char *ip, const char *port_, uns
network_put(NETWORK_LIVE, -1);
network_put(NETWORK_COUNT, 0);
network_put(NETWORK_CAPACITY, max_clients);
+ network_put(NETWORK_BUF_CLEAR_ON_JOIN, 1);
if( !(flags&NETWORK_CONNECT) || flags&NETWORK_BIND ) {
// server, else client
@@ -338924,6 +338926,16 @@ char** server_poll(unsigned timeout_ms) {
}
else client_id = next_client_id++;
+ if (network_get(NETWORK_BUF_CLEAR_ON_JOIN)) {
+ array(netbuffer_t) *list = map_find(buffers, client_id);
+
+ if (list)
+ for(int i = 0, end = array_count(list); i < end; ++i) {
+ netbuffer_t *nb = &list[i];
+ memset(nb->ptr, 0, nb->sz);
+ }
+ }
+
map_find_or_add(clients, event.peer, client_id);
map_find_or_add(peers, client_id, event.peer);
network_put(NETWORK_COUNT, network_get(NETWORK_COUNT)+1);
diff --git a/engine/split/v4k_netsync.c b/engine/split/v4k_netsync.c
index 816b68f..626600c 100644
--- a/engine/split/v4k_netsync.c
+++ b/engine/split/v4k_netsync.c
@@ -305,6 +305,7 @@ void network_create(unsigned max_clients, const char *ip, const char *port_, uns
network_put(NETWORK_LIVE, -1);
network_put(NETWORK_COUNT, 0);
network_put(NETWORK_CAPACITY, max_clients);
+ network_put(NETWORK_BUF_CLEAR_ON_JOIN, 1);
if( !(flags&NETWORK_CONNECT) || flags&NETWORK_BIND ) {
// server, else client
@@ -462,6 +463,16 @@ char** server_poll(unsigned timeout_ms) {
}
else client_id = next_client_id++;
+ if (network_get(NETWORK_BUF_CLEAR_ON_JOIN)) {
+ array(netbuffer_t) *list = map_find(buffers, client_id);
+
+ if (list)
+ for(int i = 0, end = array_count(list); i < end; ++i) {
+ netbuffer_t *nb = &list[i];
+ memset(nb->ptr, 0, nb->sz);
+ }
+ }
+
map_find_or_add(clients, event.peer, client_id);
map_find_or_add(peers, client_id, event.peer);
network_put(NETWORK_COUNT, network_get(NETWORK_COUNT)+1);
diff --git a/engine/split/v4k_netsync.h b/engine/split/v4k_netsync.h
index 5dcbb45..35beb82 100644
--- a/engine/split/v4k_netsync.h
+++ b/engine/split/v4k_netsync.h
@@ -45,7 +45,8 @@ enum { NETWORK_RANK = 0 }; // [0..N] where 0 is server
enum { NETWORK_PING = 1 }; // NETWORK_BANDWIDTH, NETWORK_QUALITY };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
-enum { NETWORK_USERID = 5, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
+enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
+enum { NETWORK_USERID = 7, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
API int64_t network_get(uint64_t key);
API int64_t network_put(uint64_t key, int64_t value);
diff --git a/engine/v4k.c b/engine/v4k.c
index 303cfcc..a024c86 100644
--- a/engine/v4k.c
+++ b/engine/v4k.c
@@ -9782,6 +9782,7 @@ void network_create(unsigned max_clients, const char *ip, const char *port_, uns
network_put(NETWORK_LIVE, -1);
network_put(NETWORK_COUNT, 0);
network_put(NETWORK_CAPACITY, max_clients);
+ network_put(NETWORK_BUF_CLEAR_ON_JOIN, 1);
if( !(flags&NETWORK_CONNECT) || flags&NETWORK_BIND ) {
// server, else client
@@ -9939,6 +9940,16 @@ char** server_poll(unsigned timeout_ms) {
}
else client_id = next_client_id++;
+ if (network_get(NETWORK_BUF_CLEAR_ON_JOIN)) {
+ array(netbuffer_t) *list = map_find(buffers, client_id);
+
+ if (list)
+ for(int i = 0, end = array_count(list); i < end; ++i) {
+ netbuffer_t *nb = &list[i];
+ memset(nb->ptr, 0, nb->sz);
+ }
+ }
+
map_find_or_add(clients, event.peer, client_id);
map_find_or_add(peers, client_id, event.peer);
network_put(NETWORK_COUNT, network_get(NETWORK_COUNT)+1);
diff --git a/engine/v4k.h b/engine/v4k.h
index 870bf2e..f8fd197 100644
--- a/engine/v4k.h
+++ b/engine/v4k.h
@@ -2031,7 +2031,8 @@ enum { NETWORK_RANK = 0 }; // [0..N] where 0 is server
enum { NETWORK_PING = 1 }; // NETWORK_BANDWIDTH, NETWORK_QUALITY };
enum { NETWORK_PORT = 2, NETWORK_IP, NETWORK_LIVE };
enum { NETWORK_SEND_MS = 4 };
-enum { NETWORK_USERID = 5, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
+enum { NETWORK_BUF_CLEAR_ON_JOIN = 5 };
+enum { NETWORK_USERID = 7, /*NETWORK_SALT,*/ NETWORK_COUNT/*N users*/ /*...*/, NETWORK_CAPACITY };
API int64_t network_get(uint64_t key);
API int64_t network_put(uint64_t key, int64_t value);
diff --git a/engine/v4k.html b/engine/v4k.html
index ff65aed..56a3172 100644
--- a/engine/v4k.html
+++ b/engine/v4k.html
@@ -596,7 +596,7 @@ details > summary::-webkit-details-marker {
|Version: | 2023.7 |
|:--------------|:------------|
|Branch: | main |
-|Commit: | 58 |
+|Commit: | 59 |
# [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k)
@@ -6626,7 +6626,21 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
🄴 enum {;
~~~~~~C
enum {
- NETWORK_USERID = 5,
+ NETWORK_BUF_CLEAR_ON_JOIN = 5
+};
+~~~~~~
+
+Under construction. Yet to be documented.
+
+Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
+
+
+
+
+🄴 enum {;
+~~~~~~C
+enum {
+ NETWORK_USERID = 7,
NETWORK_COUNT,
NETWORK_CAPACITY
};