adding low level communication with server khaganat (UDP)

This commit is contained in:
AleaJactaEst 2019-12-10 21:40:32 +01:00
parent 5d6160ee5a
commit fa0e971291
43 changed files with 1478 additions and 502 deletions

View file

@ -26,23 +26,58 @@ godot --gdnative-generate-json-api godot-cpp/godot_headers/api.json
scons -C godot-cpp platform=linux generate_bindings=yes custom_api_file=godot_headers/api.json bits=32
```
## Build crypt
## Build gdnative (crypt / bitstream / bitset)
### Build on 64bits
```
scons -C crypt platform=linux bits=64
scons -C gdnative platform=linux bits=64
```
### Build on 32bits
```
scons -C crypt platform=linux bits=32
scons -C gdnative platform=linux bits=32
```
## Build client khaganat
## Package client khaganat
TODO
### Configure export
Configure on project export (or edit file export_presets.cfg)
Ex.: export_presets.cfg
```
[preset.0]
name="khaganat.linux"
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
```
godot --path . --export khaganat.linux khaganat.linux.bin
```
## Launch client khaganat

View file

@ -3,68 +3,16 @@
[ext_resource path="res://assets/Game/textures/fire_01.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = false
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 2
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.390625, 0.390625, 0.390625, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 1, 0.886353, 0.617188, 1 )
emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Emission", "Flags", "Parameters", "Particles Anim" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 0.4, 0.4 )

View file

@ -1,65 +1,31 @@
[gd_resource type="ParticlesMaterial" load_steps=5 format=2]
[sub_resource type="Curve" id=1]
min_value = -360.0
max_value = 360.0
bake_resolution = 100
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.959245, 38.6719 ), 89.2918, 89.2918, 0, 0, Vector2( 1, 324.844 ), 17644.8, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=2]
flags = 4
width = 2048
curve = SubResource( 1 )
[sub_resource type="Gradient" id=3]
offsets = PoolRealArray( 0, 0.0788644, 0.514196, 0.851735, 1 )
colors = PoolColorArray( 1, 1, 1, 0.359098, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.911608, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=4]
flags = 4
gradient = SubResource( 3 )
width = 2048
[resource]
render_priority = 0
trail_divisor = 1
emission_shape = 2
emission_box_extents = Vector3( 0.07, 0.07, 0.07 )
flag_align_y = false
flag_rotate_y = false
flag_disable_z = false
spread = 2.0
flatness = 0.0
gravity = Vector3( 0, 0.05, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 35.0
angular_velocity_random = 1.0
angular_velocity_curve = SubResource( 2 )
linear_accel = 0.01
linear_accel_random = 0.0
radial_accel = 0.0
radial_accel_random = 0.0
tangential_accel = 0.0
tangential_accel_random = 0.06
damping = 0.0
damping_random = 0.0
angle = 10.0
angle_random = 0.0
scale = 1.0
scale_random = 0.0
color_ramp = SubResource( 4 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 50.0
anim_speed_random = 0.0
anim_offset = 0.14
anim_offset_random = 0.0
anim_loop = true
_sections_unfolded = [ "Angle", "Angular Velocity", "Animation", "Color", "Damping", "Emission Shape", "Flags", "Gravity", "Hue Variation", "Initial Velocity", "Linear Accel", "Radial Accel", "Resource", "Scale", "Spread", "Tangential Accel", "Trail" ]

View file

@ -1,79 +1,40 @@
[gd_resource type="ParticlesMaterial" load_steps=7 format=2]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.293375, 1 )
colors = PoolColorArray( 1, 1, 1, 0, 1, 1, 1, 1, 0.949527, 0.949527, 0.949527, 0 )
[sub_resource type="GradientTexture" id=2]
flags = 4
gradient = SubResource( 1 )
width = 128
[sub_resource type="Curve" id=3]
min_value = 0.0
max_value = 1.0
bake_resolution = 100
_data = [ Vector2( 0, 0.40332 ), 0.0, -0.404933, 0, 1, Vector2( 0.996017, 0 ), -2.26433, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=4]
flags = 4
width = 128
curve = SubResource( 3 )
[sub_resource type="Curve" id=5]
min_value = 0.0
max_value = 1.0
bake_resolution = 100
_data = [ Vector2( 0, 0 ), 0.0, 0.928107, 0, 0, Vector2( 0.365168, 0.618164 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.500372, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=6]
flags = 4
width = 128
curve = SubResource( 5 )
[resource]
render_priority = 0
trail_divisor = 1
emission_shape = 2
emission_box_extents = Vector3( 0.05, 0.05, 0.05 )
flag_align_y = false
flag_rotate_y = false
flag_disable_z = false
spread = 1.0
flatness = 0.0
gravity = Vector3( 0, 0.3, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 50.0
angular_velocity_random = 1.0
linear_accel = 0.1
linear_accel_random = 0.0
linear_accel_curve = SubResource( 4 )
radial_accel = 0.01
radial_accel_random = 0.0
tangential_accel = 0.01
tangential_accel_random = 0.0
damping = 0.0
damping_random = 0.0
angle = 5.0
angle_random = 0.0
scale = 1.5
scale_random = 0.1
scale_curve = SubResource( 6 )
color_ramp = SubResource( 2 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 0.0
anim_speed_random = 0.0
anim_offset = 0.0
anim_offset_random = 0.0
anim_loop = false
_sections_unfolded = [ "Angle", "Angular Velocity", "Animation", "Color", "Damping", "Emission Shape", "Flags", "Gravity", "Hue Variation", "Initial Velocity", "Linear Accel", "Radial Accel", "Scale", "Spread", "Tangential Accel", "Trail" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_1.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_2.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_4.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -3,65 +3,15 @@
[ext_resource path="res://assets/Game/textures/smoke_5.png" type="Texture" id=1]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 3
params_grow = false
params_use_alpha_scissor = false
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = 0
particles_anim_loop = false
albedo_color = Color( 0.203125, 0.203125, 0.203125, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]
[resource]
material = SubResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector2( 1, 1 )
_sections_unfolded = [ "Albedo", "Flags", "Parameters" ]

View file

@ -18,10 +18,13 @@
class connexion:
var _url_login = ""
var _url_register = ""
var _khaganat_host = "localhost"
var _khaganat_port = "40916"
var _language = "FR"
var _valid_certificate = true
func _init():
print("Load connexion config");
print("[config connexion] Load connexion config");
#var message = load("res://assets/Scripts/Models/nel_login_message.gd")
var config_file = ConfigFile.new()
@ -34,11 +37,20 @@ class connexion:
config_file.set_value("global", "valid_certificate", false)
config_file.save("user://connexion.cfg")
self._url_login = config_file.get_value( "login", "url", "http://172.17.0.3/login/r2_login.php")
self._url_register = config_file.get_value( "register", "url", "http://172.17.0.3/login/r2_login.php")
self._valid_certificate = config_file.get_value( "global", "valid_certificate", false)
self._url_login = config_file.get_value("login", "url", "http://172.17.0.3/login/r2_login.php")
self._url_register = config_file.get_value("register", "url", "http://172.17.0.3/login/r2_login.php")
self._khaganat_host = config_file.get_value("server", "host", "172.17.0.3")
self._khaganat_port = config_file.get_value("server", "port", "47851")
self._language = config_file.get_value("global", "language", "fr")
self._valid_certificate = config_file.get_value("global", "valid_certificate", false)
config_file.save("user://connexion.cfg")
func get_khaganat_host():
return self._khaganat_host
func get_khaganat_port():
return int(self._khaganat_port)
func get_url_login():
return self._url_login
@ -46,4 +58,7 @@ class connexion:
return self._url_register
func get_valid_certificate():
return self._valid_certificate
return self._valid_certificate
func get_language():
return self._language

View file

@ -0,0 +1,231 @@
# Class to manage low level communication with khaganat
#
# Copyright (C) 2019 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# https://godotengine.org/qa/20026/to-send-a-udp-packet-godot-3
extends Control
enum TCONNECTIONSTATE {
NOTINITIALISED = 0, # nothing happened yet
NOTCONNECTED = 1, # init() called
AUTHENTICATE = 2, # connect() called, identified by the login server
LOGIN = 3, # connecting to the frontend, sending identification
SYNCHRONIZE = 4, # connection accepted by the frontend, synchronizing
CONNECTED = 5, # synchronized, connected, ready to work
PROBE = 6, # connection lost by frontend, probing for response
STALLED = 7, # server is stalled
DISCONNECT = 8, # disconnect() called, or timeout, or connection closed by frontend
QUIT = 9}
enum CLFECOMMON {
SYSTEM_LOGIN_CODE = 0,
SYSTEM_SYNC_CODE = 1,
SYSTEM_ACK_SYNC_CODE = 2,
SYSTEM_PROBE_CODE = 3,
SYSTEM_ACK_PROBE_CODE = 4,
SYSTEM_DISCONNECTION_CODE = 5,
SYSTEM_STALLED_CODE = 6,
SYSTEM_SERVER_DOWN_CODE = 7,
SYSTEM_QUIT_CODE = 8,
SYSTEM_ACK_QUIT_CODE = 9,
NUMBITSINLONGACK = 512}
var _connection_state
var _socketUDP
var _user_addr
var _user_key
var _user_id
var _current_received_number
var _last_received_number
var _confirmed_received_number
var _last_ack_bit
var _ack_bit_mask
var _long_ack_bit_field
var _last_ack_in_long_ack
var _latest_sync
var _queue_message_system
func _ready():
_current_received_number = 0
_last_received_number = 0
_confirmed_received_number = 0
_last_ack_bit = 0
_ack_bit_mask = 0
_connection_state = TCONNECTIONSTATE.NOTINITIALISED
_socketUDP = PacketPeerUDP.new()
_queue_message_system = Array()
_long_ack_bit_field = preload("res://bitset.gdns").new()
_last_ack_in_long_ack = 0
_latest_sync = 0
func send_system_login(user_addr, user_key, user_id, lang):
var msgout = preload("res://bitstream.gdns").new()
msgout.put_sint32(_current_received_number)
msgout.put_bool(true)
msgout.put_uint8(CLFECOMMON.SYSTEM_LOGIN_CODE)
msgout.put_string_hexa32(user_addr)
msgout.put_string_hexa32(user_key)
msgout.put_string_hexa32(user_id)
msgout.put_string(lang)
print("[net_low_level:send_system_login] Send System Login :" + msgout.show())
var res = _socketUDP.put_packet(msgout.get_data())
if ( res != OK):
print("[net_low_level:send_system_login] Error to send system login : " + str(res))
return
_connection_state = TCONNECTIONSTATE.CONNECTED
func send_system_sync():
var msgout = preload("res://bitstream.gdns").new()
var curtime = OS.get_ticks_msec()
msgout.put_uint8(CLFECOMMON.SYSTEM_ACK_SYNC_CODE)
msgout.put_sint32(_last_received_number)
msgout.put_sint32(_last_ack_in_long_ack)
_long_ack_bit_field.write_serial(msgout)
msgout.put_sint32(_latest_sync)
_queue_message_system.append(msgout)
func send_systemm_disconnect():
var msgout = preload("res://bitstream.gdns").new()
msgout.put_sint32(_current_received_number)
msgout.put_bool(true)
msgout.put_uint8(CLFECOMMON.SYSTEM_DISCONNECTION_CODE)
var res = _socketUDP.put_packet(msgout.get_data())
_connection_state == TCONNECTIONSTATE.QUIT
if ( res != OK):
print("[net_low_level:send_systemm_disconnect] Error to send system disconnection : " + str(res))
return
func disconnect_server():
print("[net_low_level:disconnect_server] Disconnect")
if _socketUDP:
send_systemm_disconnect()
print("[net_low_level:disconnect_server] Send disconnect to server")
_socketUDP.close()
func connect_to_server(user_addr, user_key, user_id):
var connexion = load("res://assets/Scripts/Config/connexion.gd").connexion.new()
var khaganat_host = connexion.get_khaganat_host()
var khaganat_port = connexion.get_khaganat_port()
var lang = connexion.get_language()
print("[net_low_level:connect_to_server] prepare:" + str(khaganat_host) + ":" + str(khaganat_port))
_socketUDP.set_dest_address(khaganat_host, khaganat_port)
send_system_login(user_addr, user_key, user_id, lang)
func analyze_message_received(msgbytes):
var msgin = preload("res://bitstream.gdns").new()
msgin.put_data(msgbytes)
#if msgin.size() == 0:
# return
_current_received_number = msgin.get_sint32()
var system_mode = msgin.get_bool()
print("[net_low_level:analyze_message_received] Tick:" + str(_current_received_number) + ", Mode:" + str(system_mode) + ", Size:" + str(msgin.size()))
if system_mode:
print("[net_low_level:analyze_message_received] System Mode")
if _current_received_number > _last_received_number + 1:
print("[net_low_level:analyze_message_received] lost message : " + str(_last_received_number + 1 - _current_received_number))
elif _current_received_number == _last_received_number:
print("[net_low_level:analyze_message_received] Server re-send last message")
return
elif _current_received_number < _last_received_number:
print("[net_low_level:analyze_message_received] Server re-send old message")
return
var ackBool = false
var ackBit = 0
if not system_mode:
match _connection_state:
TCONNECTIONSTATE.CONNECTED:
ackBool = true
ackBit = 1
TCONNECTIONSTATE.SYNCHRONIZE:
ackBool = true
ackBit = 1
_:
ackBool = false
if _current_received_number - _last_received_number < 32:
_ack_bit_mask <<= _current_received_number - _last_received_number
_ack_bit_mask |= _last_ack_bit << (_current_received_number - _last_received_number - 1)
elif (_current_received_number - _last_received_number) == 32 and _last_ack_bit != 0:
_ack_bit_mask = 0x80000000
else:
_ack_bit_mask = 0x00000000
_last_ack_bit = ackBit
for i in range(_last_received_number + 1, _current_received_number):
_long_ack_bit_field.clear_bit(i & 511) # (512 - 1) mask 9bit
_long_ack_bit_field.put(_current_received_number & 511, ackBool) # (512 - 1) mask 9bit
if _last_ack_in_long_ack <= (_last_received_number - 512):
_last_ack_in_long_ack = _last_received_number - 511 # (512 - 1) mask 9bit
print("[net_low_level:analyze_message_received] _last_ack_in_long_ack:" + str(_last_ack_in_long_ack) + ", _long_ack_bit_field:" + _long_ack_bit_field.show())
var message = msgin.get_uint8()
print("[net_low_level:analyze_message_received] Message type:" + str(message) )
match message:
CLFECOMMON.SYSTEM_LOGIN_CODE:
pass
CLFECOMMON.SYSTEM_SYNC_CODE:
var synchronize = msgin.get_uint32()
var stime = msgin.get_sint64()
_latest_sync = msgin.get_uint32()
var msg_xml = msgin.get_array_uint8(16)
var database_xml = msgin.get_array_uint8(16)
print("[net_low_level:analyze_message_received] synchronize:" + str(synchronize) + " stime:" + str(stime) + " latest_sync:" + str(_latest_sync))
var num = ""
for item in msg_xml:
num += str(item) + "."
print(num)
num = ""
for item in database_xml:
num += str(item) + "."
print(num)
send_system_sync()
CLFECOMMON.SYSTEM_STALLED_CODE:
pass
CLFECOMMON.SYSTEM_PROBE_CODE:
pass
CLFECOMMON.SYSTEM_SERVER_DOWN_CODE:
pass
_:
print("[net_low_level:analyze_message_received] Message type unknown (" + str(message) + ")")
_last_received_number = _current_received_number
func _process(delta):
if _connection_state == TCONNECTIONSTATE.NOTINITIALISED:
return
if _connection_state == TCONNECTIONSTATE.NOTCONNECTED:
return
if _connection_state == TCONNECTIONSTATE.QUIT:
return
if _queue_message_system.size() > 0:
var msgout = _queue_message_system.pop_front()
print("[net_low_level:_process] Send data system")
_socketUDP.put_packet(msgout.get_data())
if _socketUDP.get_available_packet_count() == 0:
return
var msgbytes = _socketUDP.get_packet()
if msgbytes.size() > 0:
analyze_message_received(msgbytes)
func _exit_tree():
disconnect_server()

7
bitset.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "BitSet"
library = ExtResource( 1 )

7
bitstream.gdns Normal file
View file

@ -0,0 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "BitStream"
library = ExtResource( 1 )

View file

@ -1,16 +0,0 @@
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=true
[entry]
X11.64="res://crypt/bin/libgodot-cpp.linux.debug.64.so"
X11.32="res://crypt/bin/libgodot-cpp.linux.debug.32.so"
[dependencies]
X11.64=[ ]
X11.32=[ ]

View file

@ -1,8 +1,7 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://crypt.gdnlib" type="GDNativeLibrary" id=1]
[ext_resource path="res://gdnative.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "GDCrypt"
class_name = "Crypt"
library = ExtResource( 1 )

2
crypt/.gitignore vendored
View file

@ -1,2 +0,0 @@
bin/
.sconsign.dblite

View file

@ -1,16 +0,0 @@
#include "gdcrypt.h"
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
godot::Godot::gdnative_terminate(o);
}
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_class<godot::GDCrypt>();
}

View file

@ -18,4 +18,3 @@ ss_reflections_enabled = true
ssao_enabled = true
ssao_quality = 1
glow_bloom = 0.2

View file

@ -57,7 +57,7 @@ func set_default_values():
self.slot = 0
self.ears_size = 0.0
self.eyes_color = Color( 0.0, 1.0, 0.0, 1.0 )
func update( start_position = null ):
if start_position:
# self.translation = start_position.to_global( start_position.translation )
@ -65,7 +65,7 @@ func update( start_position = null ):
# self.translate( start_position.translation )
self.translation = start_position.translation
self.rotation = start_position.rotation
self.scale = Vector3( self.size, self.size, self.size )
# $infos_spatial.scale = Vector3( self.size, self.size, self.size )
# self.player_mesh.scale = Vector3( self.size, self.size, self.size )
@ -85,11 +85,11 @@ func update( start_position = null ):
self.player_mesh.mesh.get( "surface_2/material" ).set_shader_param( "albedo", self.color )
# eyes color (pupil)
self.player_mesh.mesh.get( "surface_4/material" ).set_shader_param( "albedo", self.eyes_color )
func _process(delta):
process_input(delta)
process_movement(delta)
@ -216,14 +216,13 @@ func _input(event):
self.hide()
else:
self.show()
func hide_infos():
$infos_spatial/character_infos_billboard.hide()
func show_infos():
$infos_spatial/character_infos_billboard.show()
########
#### Cameras
func show_third_person_camera():
$camera_rotation_helper/camera.make_current()

View file

@ -7,107 +7,45 @@
[sub_resource type="CapsuleShape" id=1]
radius = 1.0
height = 1.0
[node name="character" type="KinematicBody" index="0"]
[node name="character" type="KinematicBody"]
transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0 )
input_ray_pickable = false
input_capture_on_drag = false
collision_layer = 1
collision_mask = 1
axis_lock_linear_x = false
axis_lock_linear_y = false
axis_lock_linear_z = false
axis_lock_angular_x = false
axis_lock_angular_y = false
axis_lock_angular_z = false
collision/safe_margin = 0.001
script = ExtResource( 1 )
_sections_unfolded = [ "Axis Lock", "Transform", "collision" ]
[node name="infos_spatial" type="Spatial" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, -9.56715e-015, 0, 1, -4.65661e-010, 2.47932, -0.0688725 )
[node name="infos_spatial" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, -9.56715e-15, 0, 1, -4.65661e-10, 2.47932, -0.0688725 )
script = ExtResource( 2 )
[node name="character_infos_billboard" parent="infos_spatial" index="0" instance=ExtResource( 3 )]
[node name="character_infos_billboard" parent="infos_spatial" instance=ExtResource( 3 )]
visible = false
mouse_filter = 2
mouse_default_cursor_shape = 2
_sections_unfolded = [ "Mouse", "Rect", "Size Flags", "Visibility" ]
[node name="camera_rotation_helper" type="Spatial" parent="." index="1"]
[node name="camera_rotation_helper" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0730682, 0 )
[node name="camera" type="Camera" parent="camera_rotation_helper" index="0"]
[node name="camera" type="Camera" parent="camera_rotation_helper"]
transform = Transform( 1, 0, 0, 0, 0.981951, 0, 0, 0, 1.05023, 0, 2.5, 3 )
keep_aspect = 1
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler_tracking = 0
projection = 0
current = false
fov = 75.0
size = 1.0
near = 0.05
far = 10000.0
_sections_unfolded = [ "Transform" ]
[node name="face_camera" type="Camera" parent="camera_rotation_helper" index="1"]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 1.91278, -2.96733 )
keep_aspect = 1
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler_tracking = 0
projection = 0
current = false
fov = 70.0
[node name="face_camera" type="Camera" parent="camera_rotation_helper"]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.91278, -2.96733 )
size = 2.0
near = 0.05
far = 10000.0
_sections_unfolded = [ "Transform" ]
[node name="suzanne" parent="." index="2" instance=ExtResource( 4 )]
[node name="suzanne" parent="." instance=ExtResource( 4 )]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.2572, -0.180126 )
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 1.2572, -0.180126 )
[node name="flashlight" type="SpotLight" parent="suzanne" index="1"]
transform = Transform( -0.718303, -4.51344e-010, 1.04295e-007, 0, 1.19299, 0.0148616, -6.27955e-008, 0.00516275, -1.19299, -0.020946, 0.599374, 0.0648584 )
layers = 1
light_color = Color( 1, 1, 1, 1 )
[node name="flashlight" type="SpotLight" parent="suzanne"]
transform = Transform( -0.718303, -4.51344e-10, 1.04295e-07, 0, 1.19299, 0.0148616, -6.27955e-08, 0.00516275, -1.19299, -0.020946, 0.599374, 0.0648584 )
light_energy = 2.0
light_indirect_energy = 2.0
light_negative = false
light_specular = 0.5
light_bake_mode = 1
light_cull_mask = -1
shadow_enabled = true
shadow_color = Color( 0, 0, 0, 1 )
shadow_bias = 0.15
shadow_contact = 0.0
shadow_reverse_cull_face = true
editor_only = false
spot_range = 9.90764
spot_attenuation = 1.0
spot_angle = 22.2473
spot_angle_attenuation = 1.0
_sections_unfolded = [ "Light", "Shadow" ]
[node name="collision_shape" type="CollisionShape" parent="." index="3"]
[node name="collision_shape" type="CollisionShape" parent="."]
transform = Transform( 0.430205, 0, 0, 0, 0.906621, 0, 0, 0, 0.294585, 0.00823072, 0.942657, -0.356263 )
shape = SubResource( 1 )
disabled = false

View file

@ -7,25 +7,25 @@ const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer
func _ready():
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
global.get_node("GUI").show()
global.get_node("GUI").play()
character.show_third_person_camera()
character.get_node( "infos_spatial" ).show()
global.get_node( "audio_stream_player" ).stop()
func _process(delta):
pass
func on_window_size_changed():
change_title()
func change_title():
if has_node( WINDOW_TITLE_INPUT ):
var title_node = get_node( WINDOW_TITLE_INPUT )
var title = "Khanat"
var title = "Khanat"
if title_node and not title_node.text.strip_edges() == "":
title = title_node.text.strip_edges()
title += " (" + String(OS.get_window_size().x) + "x" + String(OS.get_window_size().y) + ")"

View file

@ -5,14 +5,9 @@
[ext_resource path="res://scenes/Game/markers/arrow_z.tscn" type="PackedScene" id=3]
[node name="game_scene" type="Node"]
script = ExtResource( 1 )
_sections_unfolded = [ "Pause" ]
[node name="Game" parent="." index="0" instance=ExtResource( 2 )]
[node name="start_position" parent="." index="1" instance=ExtResource( 3 )]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, -15 )
[node name="Game" parent="." instance=ExtResource( 2 )]
[node name="start_position" parent="." instance=ExtResource( 3 )]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -15 )

14
gdnative.gdnlib Normal file
View file

@ -0,0 +1,14 @@
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=true
[entry]
X11.64="res://gdnative/bin/libgdnative.linux.debug.64.so"
[dependencies]
X11.64=[ ]

View file

@ -1,5 +1,8 @@
#!python
#
# On root project
# scons -C gdnative platform=linux bits=64
#
import os, subprocess, platform, sys
@ -140,11 +143,11 @@ env.Append(LIBS=[libgodot])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['src/'])
sources = Glob('src/*.cpp')
library = env.SharedLibrary(target=os.path.join(env['target_path'], 'libgodot-cpp.{}.{}.{}'.format(env['platform'], env['target'], env['bits'])), source=sources)
srcgdnative = Glob('src/*.cpp')
libgdnative = env.SharedLibrary(target=os.path.join(env['target_path'], 'libgdnative.{}.{}.{}'.format(env['platform'], env['target'], env['bits'])), source=srcgdnative)
Default(library)
Default(libgdnative)
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))

155
gdnative/src/bitset.cpp Normal file
View file

@ -0,0 +1,155 @@
/*
* Class BitSet
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Build :
scons platform=linux bits=64
*/
#include <Godot.hpp>
#include <iostream>
#include "bitset.h"
using namespace godot;
#define BITSET_SIZE 32
void BitSet::_register_methods()
{
register_method("size", &BitSet::size);
register_method("resize", &BitSet::resize);
register_method("clear", &BitSet::clear);
register_method("clear_data", &BitSet::clear_data);
register_method("set_bit", &BitSet::set_bit);
register_method("clear_bit", &BitSet::clear_bit);
register_method("put", &BitSet::put);
register_method("get", &BitSet::get);
register_method("write_serial", &BitSet::write_serial);
register_method("read_serial", &BitSet::read_serial);
register_method("show", &BitSet::show);
}
BitSet::BitSet()
{
this->_num_bits = 8;
this->_size_byte = 1;
this->_mask_last = 0;
this->_data = new uint32_t[1];
}
BitSet::~BitSet()
{
// add your cleanup here
delete [] this->_data;
}
void BitSet::_init()
{
}
int BitSet::size()
{
return this->_size_byte;
}
void BitSet::resize(uint32_t num_bits)
{
uint32_t i;
uint32_t n_last_bits;
if (this->_num_bits != num_bits )
{
this->_num_bits = num_bits;
this->_size_byte = (num_bits + BITSET_SIZE - 1) / BITSET_SIZE;
delete [] this->_data;
this->_data = new uint32_t[this->_size_byte];
n_last_bits = this->_num_bits & (BITSET_SIZE - 1);
if ( n_last_bits == 0 )
this->_mask_last = ~0;
else
this->_mask_last = (1 << n_last_bits) - 1;
}
this->clear_data();
}
void BitSet::clear()
{
this->resize(1);
}
void BitSet::clear_data()
{
for(uint32_t i = 0;i < this->_size_byte; ++i)
this->_data[i] = 0;
}
void BitSet::set_bit(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
this->_data[bit_number>>5] |= mask;
}
void BitSet::clear_bit(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
this->_data[bit_number>>5] &= mask;
}
void BitSet::put(uint32_t bit_number, bool value)
{
if ( value )
this->set_bit(bit_number);
else
this->clear_bit(bit_number);
}
bool BitSet::get(uint32_t bit_number)
{
uint32_t mask = bit_number & (BITSET_SIZE - 1);
mask = 1 << mask;
return this->_data[bit_number>>5] & mask != 0;
}
void BitSet::write_serial(BitStream * msgout)
{
uint8_t current_version = 0;
msgout->put_uint8(current_version);
msgout->put_uint32(this->_num_bits);
// _size_byte est lié à _num_bits dommage que l'on envoie celui-la
msgout->put_uint32(this->_size_byte);
for(uint32_t i = 0;i < this->_size_byte; ++i)
msgout->put_uint32(this->_data[i]);
}
void BitSet::read_serial(BitStream * msgin)
{
uint8_t current_version = msgin->get_sint8();
uint8_t num_bits = msgin->get_uint32();
this->resize(num_bits);
for(uint32_t i = 0;i < this->_size_byte; ++i)
this->_data[i] = msgin->get_uint32();
}
String BitSet::show()
{
BitStream msgout;
this->write_serial(&msgout);
return msgout.show();
}

59
gdnative/src/bitset.h Normal file
View file

@ -0,0 +1,59 @@
/*
Header BitSet
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BIT_SET_H
#define BIT_SET_H
#include <Godot.hpp>
#include <Reference.hpp>
#include "bitstream.h"
namespace godot {
class BitSet : public Reference {
GODOT_CLASS(BitSet, Reference)
private:
uint32_t _num_bits;
uint32_t _size_byte;
uint32_t _mask_last;
uint32_t * _data;
public:
static void _register_methods();
BitSet();
~BitSet();
void _init(); // our initializer called by Godot
int size();
void resize(uint32_t num_bits);
void clear();
void clear_data();
void set_bit(uint32_t bit_number);
void clear_bit(uint32_t bit_number);
void put(uint32_t bit_number, bool value);
bool get(uint32_t bit_number);
void write_serial(BitStream * msgout);
void read_serial(BitStream * msgin);
String show();
};
}
#endif

444
gdnative/src/bitstream.cpp Normal file
View file

@ -0,0 +1,444 @@
/*
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Build :
scons platform=linux bits=64
*/
#include <Godot.hpp>
#include "bitstream.h"
using namespace godot;
bool little_endian = false;
void BitStream::_register_methods()
{
register_method("is_little_endian", &BitStream::is_little_endian);
register_method("size", &BitStream::size);
register_method("put_serial", &BitStream::put_serial);
register_method("put_bool", &BitStream::put_bool);
register_method("put_char", &BitStream::put_char);
register_method("put_uint8", &BitStream::put_uint8);
register_method("put_sint8", &BitStream::put_sint8);
register_method("put_sint16", &BitStream::put_sint16);
register_method("put_uint16", &BitStream::put_uint16);
register_method("put_sint32", &BitStream::put_sint32);
register_method("put_uint32", &BitStream::put_uint32);
register_method("put_sint64", &BitStream::put_sint64);
register_method("put_uint64", &BitStream::put_uint64);
register_method("put_string", &BitStream::put_string);
register_method("put_string_hexa32", &BitStream::put_string_hexa32);
register_method("put_array_uint8", &BitStream::put_array_uint8);
register_method("show", &BitStream::show);
register_method("show_detail", &BitStream::show_detail);
register_method("get_data", &BitStream::get_data);
register_method("put_data", &BitStream::put_data);
register_method("get_serial", &BitStream::get_serial);
register_method("get_bool", &BitStream::get_bool);
register_method("get_sint8", &BitStream::get_sint8);
register_method("get_uint8", &BitStream::get_uint8);
register_method("get_sint16", &BitStream::get_sint16);
register_method("get_uint16", &BitStream::get_uint16);
register_method("get_sint32", &BitStream::get_sint32);
register_method("get_uint32", &BitStream::get_uint32);
register_method("get_sint64", &BitStream::get_sint64);
register_method("get_uint64", &BitStream::get_uint64);
register_method("get_array_uint8", &BitStream::get_array_uint8);
}
BitStream::BitStream()
{
this->_pos = 0;
this->_read = 0;
}
BitStream::~BitStream()
{
// add your cleanup here
}
void BitStream::_init()
{
uint32_t i=0x12345678;
if ( (*((uint8_t*)(&i))) == 0x78 )
little_endian = true;
else
little_endian = false;
}
bool BitStream::is_little_endian()
{
return little_endian;
}
int BitStream::size()
{
return (this->_pos * 7) / 8;
}
int BitStream::size_data()
{
return this->_pos;
}
void BitStream::put_serial(uint32_t value, uint32_t nbits)
{
uint32_t v;
uint32_t mask;
uint32_t freeBits;
uint32_t pos;
if ( nbits == 0 )
return;
else if ( nbits > 32 )
throw "Out of range";
if ( this->_pos % 8 == 0 ) // Increase node
this->_data.append(0);
if ( nbits != 32 )
{
mask = (1 << nbits) - 1;
v = value & mask;
}
else
{
v = value;
}
freeBits = 8 - (this->_pos % 8);
pos = this->_data.size() - 1;
if(nbits > freeBits)
{
this->_data.set(pos, this->_data[pos] | (v >> (nbits - freeBits)));
this->_pos += freeBits;
this->put_serial(v, nbits - freeBits);
}
else
{
this->_data.set(pos, this->_data[pos] | (v << (freeBits - nbits)));
this->_pos += nbits;
}
}
void BitStream::put_bool(bool value)
{
this->put_serial(value, 1);
}
void BitStream::put_sint8(int8_t value)
{
this->put_serial(value, 8);
}
void BitStream::put_uint8(uint8_t value)
{
this->put_serial(value, 8);
}
void BitStream::put_sint16(int16_t value)
{
this->put_serial(value, 16);
}
void BitStream::put_uint16(uint16_t value)
{
this->put_serial(value, 16);
}
void BitStream::put_sint32(int32_t value)
{
this->put_serial(value, 32);
}
void BitStream::put_uint32(uint32_t value)
{
this->put_serial(value, 32);
}
void BitStream::put_sint64(int64_t value)
{
if(little_endian)
{
this->put_serial(value>>32, 32);
this->put_serial(value, 32);
}
else
{
this->put_serial(value, 32);
this->put_serial(value>>32, 32);
}
}
void BitStream::put_uint64(uint64_t value)
{
if(little_endian)
{
this->put_serial(value>>32, 32);
this->put_serial(value, 32);
}
else
{
this->put_serial(value, 32);
this->put_serial(value>>32, 32);
}
}
void BitStream::put_string_hexa32(String hexa)
{
uint32_t res = 0;
CharString tmp = hexa.ascii();
for(const char * c = tmp.get_data(); *c != 0; c++)
{
res <<= 4;
if ( *c >= '0' && *c <= '9')
res += *c - '0';
else if ( *c >= 'A' && *c <= 'F')
res += *c - 'A' + 10;
}
this->put_serial(res,32);
}
void BitStream::put_char(String value)
{
if ( value.length() >= 1)
this->put_uint8( value[0] );
else
this->put_uint8( 0 );
}
void BitStream::put_string(String value)
{
uint32_t lenvalue = value.length();
this->put_uint32(lenvalue);
//CharString tmp = value.ascii();
for(uint32_t i = 0; i < lenvalue ; ++i)
{
this->put_char(value[i]);
}
}
void BitStream::put_array_uint8(PoolByteArray value)
{
uint32_t i;
for(i = 0; i < value.size() ; ++i)
this->put_serial(value[i], 8);
}
String BitStream::show()
{
String ret;
uint32_t pos = 0;
for(uint32_t i = 0; i < this->_data.size(); ++i)
{
uint8_t c = this->_data[i];
uint8_t mask = 0x80;
while(mask)
{
if ( (c & mask) != 0 )
ret += String('1');
else
ret += String('0');
mask >>= 1;
pos += 1;
if (pos >= this->_pos)
break;
}
if (pos >= this->_pos)
break;
}
return ret ;
}
String BitStream::show_detail()
{
String ret;
uint32_t pos = 0;
for(uint32_t i = 0; i < this->_data.size(); ++i)
{
uint8_t c = this->_data[i];
uint8_t mask = 0x80;
while(mask)
{
if ( (c & mask) != 0 )
ret += String('1');
else
ret += String('0');
mask >>= 1;
pos += 1;
if (pos >= this->_pos)
break;
}
if (pos >= this->_pos)
break;
}
String strsize;
uint32_t t = this->_data.size();
if ( t == 0) strsize = "0";
while ( t > 0 )
{
char c = '0' + ( t % 10 );
strsize = String(c) + strsize;
t /= 10;
}
String strpos;
t = this->_pos;
if ( t == 0) strpos = "0";
while ( t > 0 )
{
char c = '0' + ( t % 10 );
strpos = String(c) + strpos;
t /= 10;
}
return "[size:" + strsize + ", pos:" + strpos + "]" + ret ;
}
PoolByteArray BitStream::get_data()
{
return this->_data;
}
void BitStream::put_data(PoolByteArray value)
{
this->_data = value;
this->_pos = value.size() * 8;
}
uint32_t BitStream::get_serial(uint32_t nbits)
{
uint32_t value;
uint32_t pos;
uint32_t freeBits;
uint32_t v;
if ( nbits == 0 )
return 0;
else if ( nbits > 32 )
{
ERR_PRINT("Out of range (BitStream::get_serial)");
throw "Out of range";
}
if (this->_read + nbits > this->_pos)
{
ERR_PRINT("Out of range (BitStream::get_serial)");
throw "Out of range";
}
value = 0;
pos = this->_read / 8;
freeBits = 8 - (this->_read % 8);
v = this->_data[pos] & ((1 << freeBits) - 1);
if(nbits > freeBits)
{
value |= (v << (nbits-freeBits));
this->_read += freeBits;
value |= this->get_serial(nbits - freeBits);
}
else
{
value |= (v >> (freeBits-nbits));
this->_read += nbits;
}
return value;
}
bool BitStream::get_bool()
{
if(this->get_serial(1) == 0)
return false;
return true;
}
int8_t BitStream::get_sint8()
{
return this->get_serial(8);
}
uint8_t BitStream::get_uint8()
{
return this->get_serial(8);
}
int16_t BitStream::get_sint16()
{
return this->get_serial(16);
}
uint16_t BitStream::get_uint16()
{
return this->get_serial(16);
}
int32_t BitStream::get_sint32()
{
return this->get_serial(32);
}
uint32_t BitStream::get_uint32()
{
return this->get_serial(32);
}
int64_t BitStream::get_sint64()
{
int64_t v1;
int64_t v2;
if(little_endian)
{
v1 = this->get_serial(32);
v2 = this->get_serial(32);
}
else
{
v2 = this->get_serial(32);
v1 = this->get_serial(32);
}
return (v1 << 32) | v2;
}
uint64_t BitStream::get_uint64()
{
int64_t v1;
int64_t v2;
if(little_endian)
{
v1 = this->get_serial(32);
v2 = this->get_serial(32);
}
else
{
v2 = this->get_serial(32);
v1 = this->get_serial(32);
}
return (v1 << 32) | v2;
}
PoolByteArray BitStream::get_array_uint8(uint32_t length)
{
PoolByteArray ret;
while(length != 0)
{
ret.append(this->get_serial(8));
--length;
}
return ret;
}

83
gdnative/src/bitstream.h Normal file
View file

@ -0,0 +1,83 @@
/*
Header BitStream
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BIT_STREAM_H
#define BIT_STREAM_H
#include <Godot.hpp>
#include <Reference.hpp>
namespace godot {
class BitStream : public Reference {
GODOT_CLASS(BitStream, Reference)
private:
uint32_t _pos;
uint32_t _read;
PoolByteArray _data;
public:
static void _register_methods();
BitStream();
~BitStream();
void _init(); // our initializer called by Godot
bool is_little_endian();
int size();
int size_data();
void put_serial(uint32_t value, uint32_t nbits);
void put_bool(bool value);
void put_sint8(int8_t value);
void put_uint8(uint8_t value);
void put_sint16(int16_t value);
void put_uint16(uint16_t value);
void put_sint32(int32_t value);
void put_uint32(uint32_t value);
void put_sint64(int64_t value);
void put_uint64(uint64_t value);
void put_string_hexa32(String hexa);
void put_char(String value);
void put_string(String value);
void put_array_uint8(PoolByteArray value);
String show();
String show_detail();
PoolByteArray get_data();
void put_data(PoolByteArray value);
uint32_t get_serial(uint32_t nbits);
bool get_bool();
int8_t get_sint8();
uint8_t get_uint8();
int16_t get_sint16();
uint16_t get_uint16();
int32_t get_sint32();
uint32_t get_uint32();
int64_t get_sint64();
uint64_t get_uint64();
PoolByteArray get_array_uint8(uint32_t length);
};
}
#endif

View file

@ -5,27 +5,27 @@ Build :
scons platform=linux bits=64
*/
#include "gdcrypt.h"
#include "crypt.h"
#include "sha512crypt.h"
using namespace godot;
void GDCrypt::_register_methods() {
register_method("encrypt", &GDCrypt::encrypt);
void Crypt::_register_methods() {
register_method("encrypt", &Crypt::encrypt);
}
GDCrypt::GDCrypt() {
Crypt::Crypt() {
}
GDCrypt::~GDCrypt() {
Crypt::~Crypt() {
// add your cleanup here
}
void GDCrypt::_init() {
void Crypt::_init() {
// initialize any variables here
}
String GDCrypt::encrypt(String key, String salt) {
String Crypt::encrypt(String key, String salt) {
String out = "";
char * res = sha512_crypt (key.ascii().get_data(), salt.ascii().get_data());

View file

@ -1,18 +1,18 @@
#ifndef GDCRYPT_H
#define GDCRYPT_H
#ifndef CRYPT_H
#define CRYPT_H
#include <Godot.hpp>
#include <Reference.hpp>
namespace godot {
class GDCrypt : public Reference {
GODOT_CLASS(GDCrypt, Reference)
class Crypt : public Reference {
GODOT_CLASS(Crypt, Reference)
public:
static void _register_methods();
GDCrypt();
~GDCrypt();
Crypt();
~Crypt();
void _init(); // our initializer called by Godot

View file

@ -0,0 +1,42 @@
/*
Header to link with Godot
Copyright (C) 2019 AleaJactaEst
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bitstream.h"
#include "bitset.h"
#include "crypt.h"
/** GDNative Initialize **/
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}
/** GDNative Terminate **/
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
godot::Godot::gdnative_terminate(o);
}
/** NativeScript Initialize **/
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_class<godot::BitStream>();
godot::register_class<godot::BitSet>();
godot::register_class<godot::Crypt>();
}

41
gdnative/test/bitset.gd Normal file
View file

@ -0,0 +1,41 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func test_resize():
var bitset = preload("res://bitset.gdns").new()
print ("[bitset:test_init]")
bitset.resize(1024)
func test_put():
var bitset = preload("res://bitset.gdns").new()
print ("[bitset:test_init]")
bitset.resize(1024)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(1, 1)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(2, 1)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
bitset.put(1, 0)
#print ("[bitset:test_init] " + bitset.show())
assert( bitset.show() == "0000000000000000000000000000010000000000000000000000000000000000001000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
func test():
print("[bitset] Start check -> start")
test_resize()
test_put()
print("[bitset] Start check -> end")

219
gdnative/test/bitstream.gd Normal file
View file

@ -0,0 +1,219 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func test_bool_true():
var bitstream = preload("res://bitstream.gdns").new()
bitstream.put_bool(true)
var res = bitstream.show()
assert(res == "1")
func test_bool_false():
var bitstream = preload("res://bitstream.gdns").new()
bitstream.put_bool(false)
var res = bitstream.show()
assert(res == "0")
func test_uint8():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint8(18)
res = bitstream.show()
#print(res)
assert(res == "00010010")
bitstream.put_uint8(255)
res = bitstream.show()
#print(res)
assert(res == "0001001011111111")
# trunc number if more 255 (1205 -> 226)
bitstream.put_uint8(1250)
res = bitstream.show()
#print(res)
assert(res == "000100101111111111100010")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint8("A")
res = bitstream.show()
#print(res)
assert(res == "00010010111111111110001000000000")
func test_sint8():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint8(-18)
res = bitstream.show()
#print(res)
assert(res == "11101110")
bitstream.put_sint8(-1)
res = bitstream.show()
#print(res)
assert(res == "1110111011111111")
# trunc number, reduce number bit
bitstream.put_sint8(-1250)
res = bitstream.show()
#print(res)
assert(res == "111011101111111100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint8("A")
res = bitstream.show()
#print(res)
assert(res == "11101110111111110001111000000000")
func test_uint16():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint16(18)
res = bitstream.show()
#print(res)
assert(res == "0000000000010010")
bitstream.put_uint16(65535)
res = bitstream.show()
#print(res)
assert(res == "00000000000100101111111111111111")
# trunc number, reduce number bit
bitstream.put_uint16(14597)
res = bitstream.show()
#print(res)
assert(res == "000000000001001011111111111111110011100100000101")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint16("A")
res = bitstream.show()
#print(res)
assert(res == "0000000000010010111111111111111100111001000001010000000000000000")
func test_sint16():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint16(-18)
res = bitstream.show()
#print(res)
assert(res == "1111111111101110")
bitstream.put_sint16(-1)
res = bitstream.show()
#print(res)
assert(res == "11111111111011101111111111111111")
# trunc number, reduce number bit
bitstream.put_sint16(-1250)
res = bitstream.show()
#print(res)
assert(res == "111111111110111011111111111111111111101100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint16("A")
res = bitstream.show()
#print(res)
assert(res == "1111111111101110111111111111111111111011000111100000000000000000")
func test_uint32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_uint32(1459747891)
res = bitstream.show()
#print(res)
assert(res == "01010111000000011111110000110011")
bitstream.put_uint32(4294967295)
res = bitstream.show()
#print(res)
assert(res == "0101011100000001111111000011001111111111111111111111111111111111")
# trunc number, reduce number bit
bitstream.put_uint32(14597)
res = bitstream.show()
#print(res)
assert(res == "010101110000000111111100001100111111111111111111111111111111111100000000000000000011100100000101")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_uint32("A")
res = bitstream.show()
#print(res)
assert(res == "01010111000000011111110000110011111111111111111111111111111111110000000000000000001110010000010100000000000000000000000000000000")
func test_sint32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_sint32(-18)
res = bitstream.show()
#print(res)
assert(res == "11111111111111111111111111101110")
bitstream.put_sint32(-1)
res = bitstream.show()
#print(res)
assert(res == "1111111111111111111111111110111011111111111111111111111111111111")
# trunc number, reduce number bit
bitstream.put_sint32(-1250)
res = bitstream.show()
#print(res)
assert(res == "111111111111111111111111111011101111111111111111111111111111111111111111111111111111101100011110")
# Ignore String (replaced by 'A' -> 0)
bitstream.put_sint32("A")
res = bitstream.show()
#print(res)
assert(res == "11111111111111111111111111101110111111111111111111111111111111111111111111111111111110110001111000000000000000000000000000000000")
func test_string_hexa32():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_string_hexa32(1)
res = bitstream.show()
#print(res)
assert(res == "00000000000000000000000000000001")
bitstream.put_string_hexa32("DEADBEAF")
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000111011110101011011011111010101111")
bitstream = preload("res://bitstream.gdns").new()
bitstream.put_string_hexa32("010011AC")
res = bitstream.show()
#print(res)
assert(res == "00000001000000000001000110101100")
func test_char():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_char(1)
res = bitstream.show()
#print(res)
assert(res == "00110001")
bitstream.put_char("A")
res = bitstream.show()
#print(res)
assert(res == "0011000101000001")
func test_string():
var bitstream = preload("res://bitstream.gdns").new()
var res
bitstream.put_string(1)
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000100110001")
bitstream.put_string("FR")
res = bitstream.show()
#print(res)
assert(res == "0000000000000000000000000000000100110001000000000000000000000000000000100100011001010010")
func test_little_endian():
var bitstream = preload("res://bitstream.gdns").new()
var res = bitstream.is_little_endian()
print ("[bitstream] little endian : " + str(res))
func test():
print("[bitstream] Start check -> start")
test_little_endian()
test_bool_true()
test_bool_false()
test_uint8()
test_sint8()
test_uint16()
test_sint16()
test_uint32()
test_sint32()
test_string_hexa32()
test_char()
test_string()
print("[bitstream] Start check -> end")

22
gdnative/test/crypt.gd Normal file
View file

@ -0,0 +1,22 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func test():
print("[crypt] Start check -> start")
var crypt = load("res://crypt.gdns").new()
var salt = "$6$mZ3k4xrnvjLM8dV6"
var password = "tester"
var crypted = crypt.encrypt(password, salt)
assert(crypted == "$6$mZ3k4xrnvjLM8dV6$EbOqHNpkzyniUgcf19E2JZHB3bl9.7sWN.ChIjtUiuMtsJIbINbYA0//HRWiKB2U6c7NniJgiACmidYBtsnJ71")
print("[crypt] Start check -> end")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View file

@ -28,10 +28,22 @@ var current_state = "login"
var font_size= 14
func launch_gdscript_test():
print("[global] Launch test gdscript -> Start")
var crypt = preload("res://gdnative/test/crypt.gd").new()
crypt.test()
var bitstream = preload("res://gdnative/test/bitstream.gd").new()
bitstream.test()
var bitset = preload("res://gdnative/test/bitset.gd").new()
bitset.test()
print("[global] Launch test gdscript -> End")
return true
func _ready():
var root = get_tree().get_root()
# current_scene = root.get_child(root.get_child_count() -1)
assert(launch_gdscript_test() == true)
change_title()
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")

View file

@ -14,4 +14,3 @@ script = ExtResource( 1 )
visible = false
[node name="audio_stream_player" type="AudioStreamPlayer" parent="."]

View file

@ -74,22 +74,26 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
var text = str2var(body.get_string_from_utf8())
var lines = body.get_string_from_utf8().split("\n")
if lines.size() != 2:
get_node("error_dialog/v_box_container/label").text = "Impossible de se connecter (bad return)"
print("[login_menu] Impossible to connect (bad return)")
get_node("error_dialog/v_box_container/label").text = "Impossible to connect (bad return)"
get_node("error_dialog").popup_centered()
return
var line1 = lines[0].split("#")
var line2 = lines[1].split("#")
#print("[login_menu:_on_HTTPRequest_request_completed] return:'" + str(text) + "'" + str(lines.size()) + "'" + str(line1.size()) + "'" + str(line2.size()))
if line1[0] != "1":
get_node("error_dialog/v_box_container/label").text = "Impossible de se connecter (return :" + str(line1[0]) + ")"
print("[login_menu] Impossible to connect (return" + line1[0] + ")")
get_node("error_dialog/v_box_container/label").text = "Impossible to connect (return :" + str(line1[0]) + ")"
get_node("error_dialog").popup_centered()
return
if line1.size() < 5:
get_node("error_dialog/v_box_container/label").text = "Impossible de se connecter (bad return 1st line, size:" + str(line1.size()) + ")"
print("[login_menu] Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")")
get_node("error_dialog/v_box_container/label").text = "Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")"
get_node("error_dialog").popup_centered()
return
if line2.size() != 3:
get_node("error_dialog/v_box_container/label").text = "Impossible de se connecter (bad return 2nd line, size:" + str(line2.size()) + ")"
print("[login_menu] Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")")
get_node("error_dialog/v_box_container/label").text = "Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")"
get_node("error_dialog").popup_centered()
return
var server_info_script = load("res://assets/Scripts/Models/nel_server_info.gd");
@ -106,8 +110,19 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
var r2backuppatchurl = line2[1]
var r2patchurl = line2[2]
var cookieSplit = cookie.split("|")
if cookieSplit.size() != 3:
get_node("error_dialog/v_box_container/label").text = "Impossible de se connecter (bad cookies size:" + str(cookieSplit.size()) + ")"
get_node("error_dialog").popup_centered()
return
var UserAddr = cookieSplit[0]
var UserKey = cookieSplit[1]
var UserId = cookieSplit[2]
print("[login_menu:_on_HTTPRequest_request_completed] state:" + state + ", cookie:" + cookie + ", fsaddr:" + fsaddr + ", ringmainurl:" + ringmainurl + ", fartp:" + fartp + ", stat:" + stat + ", r2serverversion:" + r2serverversion + ", r2backuppatchurl:" + r2backuppatchurl + ", r2patchurl:" + r2patchurl)
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
net_low_level.connect_to_server(UserAddr, UserKey, UserId)
emit_signal( "login_button_pressed" )
func _make_post_request(url, data_to_send, use_ssl):

View file

@ -42,6 +42,8 @@ func _on_character_selection_menu_character_selected( slot ):
func _on_quit_button_pressed():
print("[login_scene:_on_quit_button_pressed] Stop application")
net_low_level.disconnect_server()
self.get_tree().quit()

View file

@ -66,7 +66,6 @@ margin_left = 1226.0
margin_right = 1280.0
margin_bottom = 61.0
texture_normal = ExtResource( 11 )
[connection signal="character_selected" from="character_selection_menu" to="." method="_on_character_selection_menu_character_selected"]
[connection signal="return_button_pressed" from="character_selection_menu" to="." method="_on_character_selection_menu_return_button_pressed"]
[connection signal="login_button_pressed" from="login_menu" to="." method="_on_login_menu_login_button_pressed"]

View file

@ -24,6 +24,7 @@ config/icon="res://icon.png"
global="*res://global.tscn"
character="*res://game_scene/Game/Character/Character.tscn"
net_low_level="*res://assets/Scripts/Network/net_low_level.gd"
[display]