A pair of servers built on https://github.com/panjf2000/gnet.
Program | Description | Location |
---|---|---|
WORLD | uses TCP to authenticate and communicate data to clients. | build/unix/world , build/win/world.exe |
SIM | uses UDP to propagate input and maintain physics authority. | build/unix/sim , build/win/sim.exe |
GEN | creates map data. | build/unix/gen , build/win/gen.exe |
TODO: Architecture diagrams.
osx: ./build/unix/gen assets/localMap
windows: build\win\gen.exe assets/localMap
osx
===
./build/unix/gen --cpf=512 --csize=128 --size=256 --seed=209323094 --threshold=0.36 assets/localMap
windows
=======
build\win\gen.exe --cpf=512 --csize=128 --size=256 --seed=209323094 --threshold=0.36 assets/localMap
WORLD and SIM do not have their own flags yet, so they are hardcoded to look for the map in assets/localMap
.
osx: ./build/unix/world
windows: build\win\world.exe
WORLD will load assets/localMap/meta.chunks
and print it out.
It will then wait for SIM to connect.
osx: ./build/unix/sim
windows: build\win\sim.exe
SIM will connect via tcp to WORLD.
WORLD will now begin accepting client connections.
Both programs look for map data in assets/localMap
When a client connects to WORLD, WORLD passes this information to SIM.
SIM will now accept UDP packets from this IP.
Clients will then perform a virtual connection sequence with SIM.
Once SIM is satisfied it will synchronize this client with the simulation and allow input.
The reliable ordered UDP protocol follows principles from these articles: https://www.gafferongames.com/
Shut down both servers by terminating the WORLD process.
all commands use the same syntax:
cmd --flag=value argument
where cmd is the name of the program
one or more flags as specified in the tables below
and an argument
Building is done using make
The makefile is in the root of the project.
unix targets
============
make gen
make world
make sim
windows targets
===============
make wingen
make winworld
make winsim
GEN
generates a simplex noise profile.- Each coordinate on the map is tested against this profile and a threshold value to determine if it is solid or empty.
- This information is then zipped and saved to a numbered file. Example:
assets/localMap/000.chunks
. - information based on flag inputs is saved to
assets/localMap/meta.chunks
Flag | Default | Description |
---|---|---|
cpf | 512 | How many chunks to put into one file. |
csize | 128 | How many blocks are in a chunk. |
size | 256 | Width and height of map in chunks. |
seed | 209323094 | noise seed. |
threshold | 0.36 | Threshold value for solid/empty. |
clean | false | Clean without generating the map. |
argument is a relative location to store the files.
- Loads the map specified by the argument passed to the command.
- Block and listen on the specified port for SIM.
- Allow player connections.
- On player connection send IP to SIM
- Send information about SIM to player.
- Receive updates from SIM about player positions.
- Send map data to players based on their position.
Flag | Default | Description |
---|---|---|
port | 9494 | Which port to listen on. |
argument is a relative location to where the map files are stored.
- Begins listening on specified port and tells WORLD to accept connections.
- Engages clients in handshake and adds them to connected players
- Run all input through local simulation, validate, and propagate.
Flag | Default | Description |
---|---|---|
cpuprofile | false | whether to generate a cpu profile. |
timestep | 33 | How many milliseconds per frame. |
timestepNano | 33000000 | How many nanoseconds per frame. |
protocolId | 3551548956 | Must be the same on client. Is a hash of project name and version. |
worldRate | 12 | How many frames between state updates sent to WORLD |