191 Commits
Author SHA1 Message Date
Bryan Tabor 0e3bc3655c add null check (#74) 2024-10-19 14:11:02 +02:00
BIAGINI Nathan 75cfb93bee fix RPC message not being properly handled on client side 2024-09-11 18:53:22 +02:00
stemvork fadfa5d3c9 fix possible bug in nbnet.h related to NBN_GameServer_RejectIncomingConnection (#67)
reproducing the possible bug:
- cd examples/echo
- cmake . && make
- ./echo_server (terminal 1) and ./echo_client TEST (terminal 2) and ./echo_client TEST (terminal 3)

error message related to possible bug:
```
Assertion failed: (client->is_accepted || outgoing_msg->type == NBN_CLIENT_ACCEPTED_MESSAGE_TYPE), function GameServer_SendMessageTo, file nbnet.h, line 5498
```

suggested fix if this is indeed a bug:
- add `|| outgoing_msg->type == NBN_CLIENT_CLOSED_MESSAGE_TYPE` to assertion
2024-08-22 16:29:13 +02:00
Volodymyr FialkoandBIAGINI Nathan 15d823dab6 Enable build flags and fix compilation warnings (gcc 14.1.0) (#66)
* Fix rpc build with other examples

CPP_COMPILE is an option, a cache variable, thus regular unset() is not
working for it since it tries to unset the scope variable.

This causing cmake to skip compilation of rpc.
Unset CPP_COMPILE from CACHE to make it work as intended.

* Fix compiler flags with build targets

Currently tests, soak and examples are build without extra flags,
because add_compile_options is specified after defining build targets.

From add_compile_options() docs:
Adds options to the compiler command line for targets in the current
directory and below that are added *after* this command is invoked.

* Pass debug callbacks as struct

Fixes:
warning: ISO C forbids conversion of function pointer to object pointer
type

* Move global variables under NBNET_IMPL

Nb net could be included multiple times, to prevent creation of global
variables in each file move them under NBNET_IMPL.

Also use designated initializer to initiate a driver structure to
remove warnings about partial initialization. Designated initializer
would initialize other members to zero.

* Resolve unused variables warnings.

Cast unused function arguments to (void) to suspend warnings.

* Resolve signed vs unsigned warnings

Remove unnecessary lt 0 checks and sync types to remove signed vs
unsigned warnings.

* Resolve string related warnings

Fixes:
nbnet/tests/string_tests.c:18:9: error: ‘strncpy’
output truncated before terminating nul copying 5 bytes from a string of
the same length
[-Werror=stringop-truncation]
   18 |         strncpy(res + pos, b, len_b);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

nbnet/tests/string_tests.c:24:9: error: ‘strncpy’
specified bound depends on the length of the source argument
[-Werror=stringop-truncation]

* Resolve function defined but not used warnings

Mark GameServer_GetClientCount() as inline.

* Attempt to fix warning in ASSERT_VALUE_IN_RANGE

In case when value in unsigned type and min is 0, this commit just
obfuscates types, maybe there's better solution.

Fixes:
warning: comparison of unsigned expression in ‘>= 0’ is always true
[-Wtype-limits]

* Ensure that read len is less than word size

In release mode(-DCMAKE_BUILD_TYPE=Release) tests returning following
error:
nbnet/tests/../nbnet.h:2272:9: error: ‘memcpy’ forming offset [4, 7] is
out of the bound s [0, 4] of object ‘word’ with type ‘Word’ {aka
‘unsigned int’} [-Werror=array-bounds=]
 2272 |         memcpy(bytes, &word, length); |
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add check to verify that length is less than Word size.

* add -Wno-unknown-pragmas flag

* fix examples compilation on windows

* fix examples compilation on windows

* fix examples compilation on windows

* fix unit tests compilation on windows

* fix soak test compilation on windows

* fix unit tests compilation on windows

* fix unit tests compilation on windows

---------

Co-authored-by: BIAGINI Nathan <nath.biagini@gmail.com>
2024-08-10 12:02:42 +02:00
web3gamedev 4cd581be62 cast jitter to double before dividing by 1000 2024-07-21 15:41:48 -07:00
Nathan 32b1b62781 remove encryption support from core library (#59)
remove encryption support from the core library
2024-07-16 23:34:00 +02:00
Nathan 2148088753 Merge pull request #60 from preston-thompson/fix-channel-destroy-leak
Fix memory leak for read_chunk_buffer and write_chunk_buffer
2024-05-25 17:19:03 +03:00
ashn 0285d6cf28 Add void parameter list to csprng_create declaration and definitions
C99 functions declared with an empty parameter list may accept any
number of arguments. Add a void parameter list to the declaration and
definitions of csprng_create to indicate that they accept zero
arguments.
2024-05-18 09:52:53 -04:00
Preston Thompson 2a9b557d92 Fix memory leak for read_chunk_buffer and write_chunk_buffer 2024-05-12 16:29:01 -07:00
BIAGINI Nathan 0e1974d287 update copyright year 2024-02-07 22:28:54 +01:00
Nathan bb401c914a Merge pull request #54 from nathhB/conn-vector-remove-rewrite
rewrite NBN_ConnectionVector_RemoveAt function in a simpler way
2023-11-25 17:38:38 +01:00
BIAGINI Nathan 576717f8ad rewrite NBN_ConnectionVector_RemoveAt function in a simpler way 2023-11-25 17:32:12 +01:00
BIAGINI Nathan faa67417be fix NBN_GameServer_GetDisconnectedClient 2023-11-12 15:54:38 +01:00
ashn 02383a2197 Log and error and return in Endpoint_CreateOutgoingMessage when the outgoing message pool is full 2023-10-28 10:07:30 -04:00
ashn b3c187dd68 Declare NBN_ConnectionTable struct with a name in typedef declaration 2023-09-27 16:57:36 -04:00
BIAGINI Nathan ce2ed6518c fix issue with incorrect time computations 2023-09-25 18:41:32 +02:00
Nathan 9e28e97685 nbnet 2.0 (#35)
2.0 release - internal refactoring, public API rework, and introduction of a new CI based on GitHub actions
2023-09-24 19:43:08 +02:00
ashn 1bf41f3231 Declare structs, usions, and enums with a name in typedef declarations
Structs, unions, and enums declared as `struct NAME`, `union NAME`, and
`enum NAME` are easier to handle than typedef-ed anonymous structs when
using tools such as `clang -Xclang -ast-dump`. This changeset updates
structs declared as `typedef struct { ... } NAME;` to be declared as
`typedef NAME struct { ... } NAME;` (and similar for unions and enums).
This changeset does not require any changes to user code.
2023-09-12 08:21:03 -04:00
Alan Paradis b6773e4a3a Rename temp_rpc to rpc 2023-08-12 17:12:50 +02:00
Alan Paradis 6329fe2641 Fix for MSVC C++ Compilation Issue with Compound Literals
Replaced compound literals with temporary variables for MSVC C++ compatibility.
2023-08-07 19:18:06 +02:00
Nathan 2df38ebf7c Merge pull request #34 from raisinrand/ub-fix
Fix undefined behavior left shift
2023-07-18 21:14:22 +02:00
raisinrand 8c0c8943c6 Fix ub 2023-07-15 14:50:08 -04:00
BIAGINI Nathan 7e9cb4f1c6 initialize outgoing message pools when creating channel 2023-07-11 20:52:20 +02:00
BIAGINI Nathan 236b4c002f remove broadcast functions 2023-05-27 18:37:40 +02:00
BIAGINI Nathan c371edfecf remove debug log 2023-05-27 15:09:05 +02:00
BIAGINI Nathan a085157f45 rework channels 2023-05-24 16:28:06 +02:00
Mark Deneen 5cd9bfcc53 Allow echo example to be built with C++ 2023-05-21 09:02:15 -04:00
BIAGINI Nathan 7067490e04 introduce uint64 serialization 2023-04-07 12:28:38 +02:00
BIAGINI Nathan eeb5f17a85 fix segfault when disconnecting a WebRTC native driver peer 2023-03-23 19:38:31 +01:00
BIAGINI Nathan a59c4303ec update copyrights year 2023-02-18 11:28:18 +01:00
BIAGINI Nathan b1d20eaa76 WebRTC native driver: make sure the connection is accepted before attempting to send any packet 2023-02-11 10:50:14 +01:00
BIAGINI Nathan 2b0c221574 webrtc native driver WIP 2023-02-05 10:17:16 +01:00
BIAGINI Nathan 6f75b3b807 WIP 2023-01-15 18:57:32 +01:00
BIAGINI Nathan 069042e7d6 fix potential clash with reserved identifiers 2022-12-25 12:18:04 +01:00
Nathan 9b8f40ba93 Merge pull request #27 from nathhB/feat/rpc
Feat/rpc
2022-12-11 14:21:27 +01:00
BIAGINI Nathan 68c051a502 fix issue with resending reliable messages 2022-12-11 14:17:25 +01:00
BIAGINI Nathan c01b594ef6 keep track of total lost packets and expose it in NBN_ConnectionStats 2022-11-12 11:02:08 +01:00
BIAGINI Nathan 1cc8198b72 keep track of total lost packets and expose it in NBN_ConnectionStats 2022-11-12 10:56:36 +01:00
CarterDugan 30b8530486 __NBN_Connection more cache friendly 2022-07-17 10:55:40 -04:00
BIAGINI Nathan 239d3cbe91 Add error checks for Connection_RecycleMessage function calls 2022-07-17 10:01:04 +02:00
BIAGINI Nathan df73ca99ea fix RPC string param 2022-04-15 13:02:07 +02:00
BIAGINI Nathan b0ec60f51c fix rpc string param 2022-04-09 12:39:53 +02:00
BIAGINI Nathan fbb38ad454 fix warnings 2022-04-09 11:40:34 +02:00
BIAGINI Nathan 8177e4cb66 first working version of RPC 2022-03-20 08:41:20 +01:00
BIAGINI Nathan a6b7ee7ef5 RPC WIP 2022-03-19 18:14:59 +01:00
BIAGINI Nathan 220838f695 RPC WIP 2022-03-19 17:04:36 +01:00
nathb 612d0e6d69 RPC WIP 2022-03-13 22:36:39 +01:00
nathb f1ac2ed770 RPC WIP 2022-03-13 19:34:25 +01:00
Nathan 59339329e1 Merge pull request #23 from nathhB/feat/issue_19
Feat/issue 19
2022-03-05 09:41:33 +01:00
BIAGINI Nathan b7d553994d set NBN_CONNECTION_VECTOR_INITIAL_CAPACITY to 32 2022-03-05 09:38:39 +01:00