test-client-godot/README.md

300 lines
9.7 KiB
Markdown
Raw Normal View History

# Build
2020-03-30 20:20:59 +00:00
Before build and launch client, build module (before, we need include modules on godot source)
2020-01-24 18:56:51 +00:00
## Build module
```
mkdir build
cd build
# Disable build directory on godot editor
touch .gdignore
# clone godot
git clone https://github.com/godotengine/godot.git
cd godot
# switch on release
2020-02-09 15:13:30 +00:00
#git checkout 3.1.2-stable
git checkout 3.2
2020-01-24 18:56:51 +00:00
# Create link with our module (or copy file to godot/modules - as you like)
cd modules
for file in ../../../modules/*
do
if [ -d $file ]
then
2020-04-19 12:37:04 +00:00
if [ -L $file ]
then
echo "Create link $(basename $file)"
ln -s $file .
else
echo "Link $(basename $file) exist"
fi
2020-01-24 18:56:51 +00:00
fi
done
cd ..
# Copy modules doc to godot
cp modules/*/doc_classes/* doc/classes/.
# Clean project (if you build before)
scons -j$(nproc) -c
# Build a debug version
2020-03-30 20:20:59 +00:00
scons -j$(nproc) platform=x11 target=debug
# or build release_debug
2020-03-30 20:20:59 +00:00
scons -j$(nproc) platform=x11 target=release_debug
# or build release -> becarefull, this version works on root project and impossible to launch editor
scons -j$(nproc) platform=x11 target=release tools=no
2020-04-19 12:37:04 +00:00
# Build optimized with GCC
scons -j$(nproc) platform=x11 target=release_debug use_lto=yes
# Build optimized with CLang
scons -j$(nproc) platform=x11 target=release_debug use_llvm=yes use_lld=yes
2020-01-24 18:56:51 +00:00
cd ../..
```
### Generate doc
If you want, you can regenerate doc.
(Normally it's generated)
```
cd build/godot
./bin/godot.x11.tools.64 --doctool .
cp modules/*/doc_classes/* doc/classes/.
```
### Launch godot with module
```
cd build/godot
bin/godot.x11.tools.64
cd ../..
```
## Package client khaganat
### Configure export
Configure on project export (or edit file export_presets.cfg)
Ex.: export_presets.cfg
```
[preset.0]
2019-12-11 21:27:49 +00:00
name="khaganat.linux.64"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
custom_template/release=""
custom_template/debug=""
```
### Generate package
```
2019-12-11 21:27:49 +00:00
godot --path . --export khaganat.linux.64 khaganat.linux64.bin
```
## Launch client khaganat
### With godot
```
godot login_scene/login_scene.tsc
```
2020-03-30 20:20:59 +00:00
## Library
### NetworkConnection
NetworkConnection -> class to manage/use NetworkConnectionCore
All times, connect on NetworkConnectionCore (to get singleton) and launch function
The goal is to don't managed Singleton, this class manage
At end of program, you need execute function "terminate_network_connection" to remove singleton.
NetworkConnectionCore -> class Singleton (uniq object) [contains network connexion, state connexion]
_state_connexion[StateConnectionBase] : Object change class with state connexion [StateConnectionNotInitialized, StateConnectionLogin, StateConnectionSynchronize, StateConnectionConnected, StateConnectionQuit]
_network_data [NetworkData] : Object state connexion (Tick receive, send, bit acknowledge)
_queue [BitStreamQueue] : queue to store message UDP (just simple method to try re-order message receive by UDP)
_socketUDP [Ref<PacketPeerUDP>] : network connexion
NetworkConnection(object A) NetworkConnection(object B) ...
| |
+-------+----+---------------------------------------+-----------------------------------------+
|
NetworkConnectionCore
* _network_data
* _queue
* _socketUDP
* _state_connexion
if StateConnectionConnected
### ReferentialMessage
ReferentialMessage -> class to manage/use ReferentialMessageCore
ReferentialMessageCore -> class singleton (uniq object) [Manage data provide by msg.xml], we can encode/decode khaganat's message
### ViewMessage
2020-04-10 16:09:06 +00:00
Message UDP :
+-------------------+------------+---
| CurrentSendNumber | SystemMode | . . .
| 32 bits | 1 bit |
+-+-+-+-+-+-+-+-+-+-+------------+---
1 -> system mode
0 -> normal mode
+---------+
| | +----------------+
| | -> | System Message |
| Message | +----------------+
| |
| UDP | +----------------+ +---------------+ +---------+ +---------+ +---------+
| | -> | Normal Message | -> |LastReceivedAck|-| Level A +-+ Level B +-+ Level C +
| | +----------------+ +---------------+ +---------+ +---------+ +---------+
+---------+
System mode :
+---------+--
| Message | see system message
| 8 bits |
+---------+--
System Message:
SYSTEM_LOGIN_CODE = 0 : [client]
...
SYSTEM_SYNC_CODE = 1 : [server]
+----
| Synchronize (32 bits - unsigned)
+------
| stime (64 bits - signed)
+------
| LatestSync ( 32 bits - unsigned )
+------
| MsgData ( 16 * 8bits : Array - md5sum of msg.xml)
+------
| DatabaseData ( 16 * 8 bits : Array - md5sum database.xml)
+------
SYSTEM_ACK_SYNC_CODE = 2 : [client]
+----
| frontack ( 32 bits - unsigned)
+----
| backack ( 32 bits - unsigned)
+----
| longackbitfield ( 1024 )
+----
| syncCode ( 32 bits unsigned)
+----
SYSTEM_PROBE_CODE = 3 : [server]
+----
| LatestProbe ( 32 bits - signed)
+----
SYSTEM_ACK_PROBE_CODE = 4 : [client]
...
SYSTEM_DISCONNECTION_CODE = 5 : [client]
...
SYSTEM_STALLED_CODE = 6 : [server]
No more data
SYSTEM_SERVER_DOWN_CODE = 7 : [server]
No more data
SYSTEM_QUIT_CODE = 8 : [client]
...
SYSTEM_ACK_QUIT_CODE = 9 : [server]
No more data
Normal mode: :
2020-03-30 20:20:59 +00:00
PacketServer
+---------+ +---------+ +---------+
| Level A | | Level B | | Level C |
| (0) | | (0) | | (0) |
+---------+ +---------+ +---------+
+---------+ +---------+
| Level B | | Level C |
| (1) | | (1) |
+---------+ +---------+
+---------+
| Level C |
| (2) |
+---------+
+---------+
| Level C |
| (3) |
+---------+
2020-04-10 16:09:06 +00:00
+---------------+
|LastReceivedAck|
| 32 bits |
+---------------+
+---------+ +-----+-+-----------+ +-------------+
| Level X | -> | next | shortcode | -> 1 (true) | Action code | +-----------
+---------+ | 1 bit | 1 bit | | 2 bit | | Action
+-------+-----------+ +-------------+ -> | (X bits)
+-------------+ +-----------
-> 0 (false) | Action code |
| 8 bits |
+-------------+
Action code :
ACTION_POSITION_CODE = 0: khanat-opennel-code/code/ryzom/common/src/game_share/action_position.cpp:34 void CActionPosition::unpack (NLMISC::CBitMemStream &message)
px ( 16 bit unsigned )
py ( 16 bit unsigned )
pz ( 16 bit unsigned ) : low bit have other signification
0x01 : IsRelative
0x02 : Interior
ACTION_GENERIC_CODE = 1: khanat-opennel-code/code/ryzom/common/src/game_share/action_generic.cpp void CActionGeneric::unpack (NLMISC::CBitMemStream &message)
size ( 32 bits unsigned ) : if size > 512 we have an error (normally reject by server)
StreamByte ( Array : size * 8 bits unsigned )
ACTION_GENERIC_MULTI_PART_CODE = 2 : khanat-opennel-code/code/ryzom/common/src/game_share/action_generic_multi_part.h:46 virtual void unpack (NLMISC::CBitMemStream &message)
Number ( 8 bits unsigned )
Part ( 16 bits unsigned )
NbBlock ( 16 bits unsigned )
size ( 32 bits unsigned )
PartCont ( Array : size * 8 bits unsigned )
ACTION_SINT64 = 3 : khanat-opennel-code/code/ryzom/common/src/game_share/action_sint64.cpp:86 void CActionSint64::unpack (NLMISC::CBitMemStream &message)
value ( 64 bits unsigned )
ACTION_SYNC_CODE = 10 : khanat-opennel-code/code/ryzom/common/src/game_share/action_sync.h:44 virtual void unpack (NLMISC::CBitMemStream &message)
Sync ( 32 bits unsigned )
BKEntityId ( 64 bits unsigned ) [see definition : khanat-opennel-code/code/nel/include/nel/misc/entity_id.h:64]
ACTION_DISCONNECTION_CODE = 11 : khanat-opennel-code/code/ryzom/common/src/game_share/action_disconnection.h
No data
ACTION_ASSOCIATION_CODE = 12 : khanat-opennel-code/code/ryzom/common/src/game_share/action_association.h virtual void unpack (NLMISC::CBitMemStream &message)
IsNewAssociation ( bool / 1 bit )
if IsNewAssociation is true:
SheetId ( 32 bits unsigned )
Replace ( bool / 1 bit )
ACTION_LOGIN_CODE = 13 : khanat-opennel-code/code/ryzom/common/src/game_share/action_login.h virtual void unpack (NLMISC::CBitMemStream &message)
ua ( 32 bits unsigned )
uk ( 32 bits unsigned )
ui ( 32 bits unsigned )
ACTION_TARGET_SLOT_CODE = 40 : khanat-opennel-code/code/ryzom/common/src/game_share/action_target_slot.h virtual void unpack (NLMISC::CBitMemStream &message)
Slot ( 8 bits unsigned )
TargetOrPickup (2 bits unsigned)
ACTION_DUMMY_CODE = 99 : khanat-opennel-code/code/ryzom/common/src/game_share/action_dummy.h virtual void unpack (NLMISC::CBitMemStream &message)
Dummy1 ( 32 bits unsigned )
2020-04-19 12:37:04 +00:00
Dummy2 ( 32 bits unsigned )
Impulse : (include on ACTION_GENERIC_CODE or ACTION_GENERIC_MULTI_PART_CODE)