Comparing version 6.0.1 to 6.0.2
@@ -5,3 +5,3 @@ <!-- _coverpage.md --> | ||
> Making multi-player simpler since 2017 | ||
> Making multi-player gamedev simpler since 2017 | ||
@@ -8,0 +8,0 @@ * cross-platform support |
@@ -30,4 +30,4 @@ # Custom allocators | ||
#define LIBRG_MEM_FREE(size) \ | ||
my_custom_free(size) | ||
#define LIBRG_MEM_FREE(ptr) \ | ||
my_custom_free(ptr) | ||
@@ -34,0 +34,0 @@ #define LIBRG_IMPL |
@@ -411,9 +411,121 @@ # Entities | ||
### TODO | ||
## librg_entity_visibility_global_set | ||
Add coverage for: | ||
* `int8_t librg_entity_visibility_global_set(librg_world *world, int64_t entity_id, librg_visibility value);` | ||
* `int8_t librg_entity_visibility_global_get(librg_world *world, int64_t entity_id);` | ||
* `int8_t librg_entity_visibility_owner_set(librg_world *world, int64_t entity_id, int64_t owner_id, librg_visibility value);` | ||
* `int8_t librg_entity_visibility_owner_get(librg_world *world, int64_t entity_id, int64_t owner_id);` | ||
Set entity global visibility value. | ||
It affects how this entity will be viewed by other owners. | ||
Global visibility has lower priority than relation (owner) visibility, | ||
meaning globally invisible entity, will still be visibile to an owner if it has `LIBRG_VISIBLITY_ALWAYS` set for that owner and vice verca. | ||
Possible values: | ||
* `LIBRG_VISIBLITY_DEFAULT` - the default value of the visibility setting | ||
* `LIBRG_VISIBLITY_NEVER` - specified entity will be always invisible, regardless of proximity | ||
* `LIBRG_VISIBLITY_ALWAYS` - specified entity will be always visible, regardless of proximity | ||
> Note: For the owner of the entity the entity will remain visible regardless of the visibility setting. | ||
##### Signature | ||
```c | ||
int8_t librg_entity_visibility_global_set( | ||
librg_world *world, | ||
int64_t entity_id, | ||
librg_visibility value | ||
) | ||
``` | ||
##### Returns | ||
* In case of success: `LIBRG_OK` | ||
* In case of invalid world: `LIBRG_WORLD_INVALID` | ||
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED` | ||
------------------------------ | ||
## librg_entity_visibility_global_get | ||
Get entity global visibility value. | ||
It affects how this entity will be viewed by other owners. | ||
Possible values: | ||
* `LIBRG_VISIBLITY_DEFAULT` - the default value of the visibility setting | ||
* `LIBRG_VISIBLITY_NEVER` - specified entity will be always invisible, regardless of proximity | ||
* `LIBRG_VISIBLITY_ALWAYS` - specified entity will be always visible, regardless of proximity | ||
> Note: For the owner of the entity the entity will remain visible regardless of the visibility setting. | ||
##### Signature | ||
```c | ||
int8_t librg_entity_visibility_global_get( | ||
librg_world *world, | ||
int64_t entity_id | ||
) | ||
``` | ||
##### Returns | ||
* In case of success: current visibility value | ||
* In case of invalid world: `LIBRG_WORLD_INVALID` | ||
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED` | ||
------------------------------ | ||
## librg_entity_visibility_owner_set | ||
Set entity relational visibility value. | ||
It affects how this entity will be viewed by provided owner. | ||
Relational (owner) visibility has higher priority than global visibility, | ||
meaning globally invisible entity, will still be visibile to an owner if it has `LIBRG_VISIBLITY_ALWAYS` set for that owner and vice verca. | ||
Possible values: | ||
* `LIBRG_VISIBLITY_DEFAULT` - the default value of the visibility setting | ||
* `LIBRG_VISIBLITY_NEVER` - specified entity will be always invisible, regardless of proximity | ||
* `LIBRG_VISIBLITY_ALWAYS` - specified entity will be always visible, regardless of proximity | ||
> Note: For the owner of the entity the entity will remain visible regardless of the visibility setting. | ||
##### Signature | ||
```c | ||
int8_t librg_entity_visibility_owner_set( | ||
librg_world *world, | ||
int64_t entity_id, | ||
int64_t owner_id, | ||
librg_visibility value | ||
) | ||
``` | ||
##### Returns | ||
* In case of success: `LIBRG_OK` | ||
* In case of invalid world: `LIBRG_WORLD_INVALID` | ||
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED` | ||
------------------------------ | ||
## librg_entity_visibility_owner_get | ||
Get entity relational visibility value. | ||
It affects how this entity will be viewed by provided owner. | ||
Possible values: | ||
* `LIBRG_VISIBLITY_DEFAULT` - the default value of the visibility setting | ||
* `LIBRG_VISIBLITY_NEVER` - specified entity will be always invisible, regardless of proximity | ||
* `LIBRG_VISIBLITY_ALWAYS` - specified entity will be always visible, regardless of proximity | ||
> Note: For the owner of the entity the entity will remain visible regardless of the visibility setting. | ||
##### Signature | ||
```c | ||
int8_t librg_entity_visibility_owner_get( | ||
librg_world *world, | ||
int64_t entity_id, | ||
int64_t owner_id | ||
) | ||
``` | ||
##### Returns | ||
* In case of success: current visibility value | ||
* In case of invalid world: `LIBRG_WORLD_INVALID` | ||
* In case of unknown entity: `LIBRG_ENTITY_UNTRACKED` |
@@ -106,2 +106,17 @@ # World manipulation methods | ||
## librg_version | ||
Method returns current library version in form of an integer. Can be used to compare against different librg versions. | ||
##### Signature | ||
```c | ||
int32_t librg_version() | ||
``` | ||
##### Returns | ||
* Integer representing current version | ||
------------------------------- | ||
## **Examples** | ||
@@ -108,0 +123,0 @@ |
@@ -46,9 +46,4 @@ # Quick start | ||
```c | ||
int main() { | ||
librg_world *world = librg_world_create(); | ||
This small example shows how can you create your first world, confgure it, add an entity, and use a querying and buffer packing methods. | ||
librg_world_destroy(world); | ||
return 0; | ||
} | ||
``` | ||
[example-simple.c](https://raw.githubusercontent.com/zpl-c/librg/master/code/apps/example-simple.c ':include :type=code') |
{ | ||
"name": "librg.c", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"author": "Inlife", | ||
@@ -5,0 +5,0 @@ "description": "Pure C library for building simple and elegant cross-platform multiplayer client-server solutions.", |
@@ -15,3 +15,3 @@ <div align="center"> | ||
<div align="center"> | ||
Making multi-player simpler since 2017. Single-header cross-platform world replication library in pure C99. | ||
Making multi-player gamedev simpler since 2017. Single-header cross-platform world replication library in pure C99. | ||
</div> | ||
@@ -30,3 +30,3 @@ | ||
**librg** is a lightweight library that can be used to serve as a middleware between data-transferring libraries (networking, file-streaming, etc.) and core application/game logic. | ||
**librg** is a lightweight library that serves as a middleware between data-transferring libraries (networking, file-streaming, etc.) and core application/game logic. | ||
@@ -40,3 +40,3 @@ Main responsibilities of the library include: | ||
The library was born to solve complexities of setting up and managing the flow of multi-player games and dedicated game servers. | ||
It came a long way of stripping out things that were non-essential, slowly sculpting in its current form, which you are able to see and use today. | ||
It came a long way of stripping out things that were non-essential, slowly sculpting into its current form, which you are able to see and use today. | ||
@@ -47,2 +47,3 @@ ## Features | ||
* lightweight, single-header | ||
* supports 2d/3d worlds of various sizes | ||
* compile- and run-time configurable | ||
@@ -55,25 +56,39 @@ * written in C99 (portability reasons) | ||
> **Question**: Is this a networking library? | ||
1. **Is this a networking library?** | ||
**Answer**: Not really, no. It is intended to be used with netwoking in mind, but it does not have any networking capabilities on its own. | ||
* Not really, no. It is intended to be used with netwoking in mind, but it does not have any networking capabilities on its own. | ||
> **Question**: Can I use any networking library with it? | ||
2. **Can I use any networking library with it?** | ||
**Anwser**: Yes. All you need is an ability to read data to and from the buffer, and most libraries do support that. | ||
* Yes. All you need is an ability to read data to and from the buffer, and most libraries do support that. Theoretically it can be anything as low level as pure `UDP`, and up to `Websocket`/`WebRTC`. | ||
> **Question**: The repository contains a bunch of `*.h` and `*.c` files, and yet you suggest it is a single-header library, how is that possible? | ||
3. **The repository contains a bunch of `*.h` and `*.c` files, and yet you suggest it is a single-header library, how is that possible?** | ||
**Answer**: The library is spread into multiple files so it is easier to work with it while developing, however each time a new release is created, a "bundled" version of the header file is created and pushed directly to the [releases](https://github.com/zpl-c/librg/releases) page. | ||
* The library is spread into multiple files so it is easier to work with it while developing, however each time a new release is created, a "bundled" version of the header file is created and pushed directly to the [releases](https://github.com/zpl-c/librg/releases) page. | ||
> **Question**: You've mentioned entities in the description above, does it mean I would need to use another entity system? | ||
4. **Does librg offer an entity system?** | ||
**Answer**: No, the library does not manage nor actually create its own entities, it rather expects you to provide your entity/object id to attach some internal data onto it, | ||
which in context of the library we call "tracking". | ||
* No, the library does not manage nor actually create its own entities, it rather expects you to provide your own entity/object handle to attach some internal data onto it, which in context of the library is called "tracking". | ||
5. **How do I pack data, do you provide methods for that?** | ||
* No, the library does not provide any data-packing/serialization methods. It's recommended you use some existing library for that (`protobuf`, `flatbuffers`, `msgpack`, etc.), or make your own implementation. | ||
6. **I see you mention chunks, does it mean my game/app should be chunk-based?** | ||
* No. Chunks are only used internally, to artificially divide the space of the world on statically sized squares/cubes so that querying would work efficiently. Even if your game does use chunks, their amount/sizes/offsets are not required to much and be the same. | ||
## Documentation | ||
To read detailed documentation about the library, see examples and quick start guide, please visit our [documentation page](https://zpl-c.github.io/librg/). | ||
To read detailed documentation about the library, see examples and quick start guide, please visit our [documentation page](https://zpl-c.github.io/librg/#/quickstart). | ||
Additionally you can check [code/apps](code/apps) folder for actual code examples. | ||
## Illustration | ||
Here is a simple illustration that attempts to describe how the library works on a simple 2d world of 4x4 chunks. | ||
For a 3d world of bigger size everything would work in a very similar way, just in 3 dimensions. | ||
 | ||
## Migration | ||
@@ -80,0 +95,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1191828
127