update network part
This commit is contained in:
parent
6903d7918a
commit
8a34bc6e39
11 changed files with 1251 additions and 1118 deletions
|
@ -14,11 +14,19 @@ var _shard_names = Array()
|
||||||
var _character_summaries = Array()
|
var _character_summaries = Array()
|
||||||
var _mainlands = Array()
|
var _mainlands = Array()
|
||||||
|
|
||||||
|
var _create_char = false
|
||||||
var _delete_char = false
|
var _delete_char = false
|
||||||
|
var _select_char = false
|
||||||
var _launch_create_user = false
|
var _launch_create_user = false
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
|
var cmd = ImpulseConnectionDeleteChar.new()
|
||||||
|
cmd.set_data(0)
|
||||||
|
var name = cmd.get_name()
|
||||||
|
print("slot:" + name)
|
||||||
|
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func phrase_send(message):
|
func phrase_send(message):
|
||||||
|
@ -28,7 +36,7 @@ func phrase_send(message):
|
||||||
var id = message['string_id'][i]
|
var id = message['string_id'][i]
|
||||||
if _string_manager.check_phrases(id) == false:
|
if _string_manager.check_phrases(id) == false:
|
||||||
decoded = false
|
decoded = false
|
||||||
var command = {'action': Action.ACTION_GENERIC_CODE, 'impulse': ImpulseBase.STRING_MANAGER_STRING_RQ, "string_id": id}
|
var command = {'action': Action.ACTION_GENERIC_CODE, 'impulse': Impulse.STRING_MANAGER_STRING_RQ, "string_id": id}
|
||||||
_networkconnection.put_command(command);
|
_networkconnection.put_command(command);
|
||||||
else:
|
else:
|
||||||
tmp.append(_string_manager.get_phrases(id))
|
tmp.append(_string_manager.get_phrases(id))
|
||||||
|
@ -54,7 +62,7 @@ func string_resp(message):
|
||||||
decoded = false
|
decoded = false
|
||||||
var command = {
|
var command = {
|
||||||
'action': Action.ACTION_GENERIC_CODE,
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
'impulse': ImpulseBase.STRING_MANAGER_STRING_RQ,
|
'impulse': Impulse.STRING_MANAGER_STRING_RQ,
|
||||||
"string_id": id
|
"string_id": id
|
||||||
}
|
}
|
||||||
_networkconnection.put_command(command);
|
_networkconnection.put_command(command);
|
||||||
|
@ -97,8 +105,8 @@ func append_message(id, flow):
|
||||||
# add message to debug
|
# add message to debug
|
||||||
var msg = Dictionary()
|
var msg = Dictionary()
|
||||||
msg['flow'] = flow
|
msg['flow'] = flow
|
||||||
var impulse_base = ImpulseBase.new()
|
var impulse_base = Impulse.new()
|
||||||
msg['impulse_debug'] = impulse_base.get_name(id)
|
msg['impulse_debug'] = impulse_base.extract_name(id)
|
||||||
_history.append(msg)
|
_history.append(msg)
|
||||||
|
|
||||||
func append_message_raw(message, flow):
|
func append_message_raw(message, flow):
|
||||||
|
@ -110,6 +118,8 @@ func append_message_raw(message, flow):
|
||||||
|
|
||||||
func create_char():
|
func create_char():
|
||||||
var slot = 2
|
var slot = 2
|
||||||
|
if _create_char == true:
|
||||||
|
return
|
||||||
if _character_summaries.size() <= slot:
|
if _character_summaries.size() <= slot:
|
||||||
return
|
return
|
||||||
if _character_summaries[slot]['people'] != People.Unknown:
|
if _character_summaries[slot]['people'] != People.Unknown:
|
||||||
|
@ -117,12 +127,17 @@ func create_char():
|
||||||
print("***** Delete old car")
|
print("***** Delete old car")
|
||||||
var command = {
|
var command = {
|
||||||
'action': Action.ACTION_GENERIC_CODE,
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
'impulse': ImpulseBase.CONNECTION_DELETE_CHAR,
|
'impulse': Impulse.CONNECTION_DELETE_CHAR,
|
||||||
"slot": slot
|
"slot": slot
|
||||||
}
|
}
|
||||||
_networkconnection.put_command(command);
|
_networkconnection.put_command(command);
|
||||||
append_message(command['impulse'], '<')
|
append_message(command['impulse'], '<')
|
||||||
_delete_char = true
|
_delete_char = true
|
||||||
|
|
||||||
|
#var cmd = ImpulseConnectionDeleteChar.new()
|
||||||
|
#cmd.set_slot(0)
|
||||||
|
#print("slot:" + String(cmd['slot']))
|
||||||
|
|
||||||
return
|
return
|
||||||
if _launch_create_user == true:
|
if _launch_create_user == true:
|
||||||
return
|
return
|
||||||
|
@ -143,7 +158,7 @@ func create_char():
|
||||||
# void setHAIR_COLOR(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
|
# void setHAIR_COLOR(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
|
||||||
var command1 = {
|
var command1 = {
|
||||||
'action': Action.ACTION_GENERIC_CODE,
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
'impulse': ImpulseBase.CONNECTION_CREATE_CHAR,
|
'impulse': Impulse.CONNECTION_CREATE_CHAR,
|
||||||
'slot': slot,
|
'slot': slot,
|
||||||
'sheet_id': 0,
|
'sheet_id': 0,
|
||||||
'session_id': int(_shard_names[0]['session_id']),
|
'session_id': int(_shard_names[0]['session_id']),
|
||||||
|
@ -154,7 +169,7 @@ func create_char():
|
||||||
'nb_point_caster': 1,
|
'nb_point_caster': 1,
|
||||||
'nb_point_crafter': 1,
|
'nb_point_crafter': 1,
|
||||||
'nb_point_harvester': 1,
|
'nb_point_harvester': 1,
|
||||||
'start_point': 2281701451,
|
'start_point': 1,
|
||||||
'hair_type': 7,
|
'hair_type': 7,
|
||||||
'hair_color': 7,
|
'hair_color': 7,
|
||||||
'gabarit_height': 255,
|
'gabarit_height': 255,
|
||||||
|
@ -181,7 +196,7 @@ func create_char():
|
||||||
}
|
}
|
||||||
var command2 = {
|
var command2 = {
|
||||||
'action': Action.ACTION_GENERIC_CODE,
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
'impulse': ImpulseBase.CONNECTION_CREATE_CHAR,
|
'impulse': Impulse.CONNECTION_CREATE_CHAR,
|
||||||
'slot': slot,
|
'slot': slot,
|
||||||
'sheet_id': 0,
|
'sheet_id': 0,
|
||||||
'session_id': int(_shard_names[0]['session_id']),
|
'session_id': int(_shard_names[0]['session_id']),
|
||||||
|
@ -192,7 +207,7 @@ func create_char():
|
||||||
'nb_point_caster': 1,
|
'nb_point_caster': 1,
|
||||||
'nb_point_crafter': 1,
|
'nb_point_crafter': 1,
|
||||||
'nb_point_harvester': 1,
|
'nb_point_harvester': 1,
|
||||||
'start_point': 123,
|
'start_point': 1,
|
||||||
'hair_type': 1,
|
'hair_type': 1,
|
||||||
'hair_color': 2,
|
'hair_color': 2,
|
||||||
'gabarit_height': 3,
|
'gabarit_height': 3,
|
||||||
|
@ -219,7 +234,7 @@ func create_char():
|
||||||
}
|
}
|
||||||
var command = {
|
var command = {
|
||||||
'action': Action.ACTION_GENERIC_CODE,
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
'impulse': ImpulseBase.CONNECTION_CREATE_CHAR,
|
'impulse': Impulse.CONNECTION_CREATE_CHAR,
|
||||||
'slot': slot,
|
'slot': slot,
|
||||||
'sheet_id': 0,
|
'sheet_id': 0,
|
||||||
'session_id': int(_shard_names[0]['session_id']),
|
'session_id': int(_shard_names[0]['session_id']),
|
||||||
|
@ -230,7 +245,7 @@ func create_char():
|
||||||
'nb_point_caster': 0,
|
'nb_point_caster': 0,
|
||||||
'nb_point_crafter': 0,
|
'nb_point_crafter': 0,
|
||||||
'nb_point_harvester': 0,
|
'nb_point_harvester': 0,
|
||||||
'start_point': 0,
|
'start_point': 1,
|
||||||
'hair_type': 0,
|
'hair_type': 0,
|
||||||
'hair_color': 0,
|
'hair_color': 0,
|
||||||
'gabarit_height': 0,
|
'gabarit_height': 0,
|
||||||
|
@ -255,25 +270,40 @@ func create_char():
|
||||||
'hands_color': 0,
|
'hands_color': 0,
|
||||||
'feet_color': 0
|
'feet_color': 0
|
||||||
}
|
}
|
||||||
_networkconnection.put_command(command);
|
_networkconnection.put_command(command1);
|
||||||
append_message(command['impulse'], '<')
|
append_message(command['impulse'], '<')
|
||||||
_delete_char = true
|
_delete_char = true
|
||||||
|
_create_char = true
|
||||||
|
|
||||||
|
func select_char():
|
||||||
|
var slot = 2
|
||||||
|
var command = {
|
||||||
|
'action': Action.ACTION_GENERIC_CODE,
|
||||||
|
'impulse': Impulse.CONNECTION_SELECT_CHAR,
|
||||||
|
"slot": slot
|
||||||
|
}
|
||||||
|
_networkconnection.put_command(command);
|
||||||
|
append_message(command['impulse'], '<')
|
||||||
|
_select_char = true
|
||||||
|
|
||||||
func analyze_message(message):
|
func analyze_message(message):
|
||||||
if message['action'] == Action.ACTION_POSITION_CODE:
|
if message['action'] == Action.ACTION_POSITION_CODE:
|
||||||
pass
|
pass
|
||||||
elif message['action'] == Action.ACTION_GENERIC_CODE:
|
elif message['action'] == Action.ACTION_GENERIC_CODE:
|
||||||
if message['impulse'] == ImpulseBase.STRING_MANAGER_RELOAD_CACHE:
|
if message['impulse'] == Impulse.STRING_MANAGER_RELOAD_CACHE:
|
||||||
print(message['timestamp'])
|
print(message['timestamp'])
|
||||||
_string_manager.set_timestamp(message['timestamp'])
|
_string_manager.set_timestamp(message['timestamp'])
|
||||||
elif message['impulse'] == ImpulseBase.STRING_MANAGER_PHRASE_SEND:
|
elif message['impulse'] == Impulse.STRING_MANAGER_PHRASE_SEND:
|
||||||
phrase_send(message)
|
phrase_send(message)
|
||||||
elif message['impulse'] == ImpulseBase.STRING_MANAGER_STRING_RESP:
|
elif message['impulse'] == Impulse.STRING_MANAGER_STRING_RESP:
|
||||||
string_resp(message)
|
string_resp(message)
|
||||||
elif message['impulse'] == ImpulseBase.CONNECTION_USER_CHARS:
|
elif message['impulse'] == Impulse.CONNECTION_USER_CHARS:
|
||||||
user_chars(message)
|
user_chars(message)
|
||||||
# Normally this step is executed when player ask to create
|
# Normally this step is executed when player ask to create
|
||||||
|
if _create_char == false:
|
||||||
create_char()
|
create_char()
|
||||||
|
elif _select_char == false:
|
||||||
|
select_char()
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -204,32 +204,43 @@ void BitStream::put_uint32(uint32_t value)
|
||||||
this->put_serial(value, 32);
|
this->put_serial(value, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitStream::put_sint64(int64_t value)
|
void BitStream::put_uint64(uint64_t value)
|
||||||
{
|
{
|
||||||
|
// khanat-opennel-code/code/nel/include/nel/misc/stream_inline.h inline void IStream::serial(uint64 &b)
|
||||||
|
// khanat-opennel-code/code/nel/include/nel/misc/stream.h #define NLMISC_BSWAP64(src) (src) = (((src)>>56)&0xFF) | ((((src)>>48)&0xFF)<<8) | ((((src)>>40)&0xFF)<<16) | ((((src)>>32)&0xFF)<<24) | ((((src)>>24)&0xFF)<<32) | ((((src)>>16)&0xFF)<<40) | ((((src)>>8)&0xFF)<<48) | (((src)&0xFF)<<56)
|
||||||
|
union S {
|
||||||
|
uint64_t full;
|
||||||
|
uint8_t key[8];
|
||||||
|
};
|
||||||
|
S v;
|
||||||
|
v.full = value;
|
||||||
if(little_endian)
|
if(little_endian)
|
||||||
{
|
{
|
||||||
this->put_serial(value>>32, 32);
|
this->put_uint8(v.key[3]);
|
||||||
this->put_serial(value, 32);
|
this->put_uint8(v.key[2]);
|
||||||
|
this->put_uint8(v.key[1]);
|
||||||
|
this->put_uint8(v.key[0]);
|
||||||
|
this->put_uint8(v.key[7]);
|
||||||
|
this->put_uint8(v.key[6]);
|
||||||
|
this->put_uint8(v.key[5]);
|
||||||
|
this->put_uint8(v.key[4]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->put_serial(value, 32);
|
this->put_uint8(v.key[0]);
|
||||||
this->put_serial(value>>32, 32);
|
this->put_uint8(v.key[1]);
|
||||||
|
this->put_uint8(v.key[2]);
|
||||||
|
this->put_uint8(v.key[3]);
|
||||||
|
this->put_uint8(v.key[4]);
|
||||||
|
this->put_uint8(v.key[5]);
|
||||||
|
this->put_uint8(v.key[6]);
|
||||||
|
this->put_uint8(v.key[7]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitStream::put_uint64(uint64_t value)
|
void BitStream::put_sint64(int64_t value)
|
||||||
{
|
{
|
||||||
if(little_endian)
|
put_uint64((uint64_t) value);
|
||||||
{
|
|
||||||
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)
|
void BitStream::put_string_hexa32(String hexa)
|
||||||
|
@ -525,38 +536,43 @@ uint32_t BitStream::get_uint32()
|
||||||
return this->get_serial(32);
|
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()
|
uint64_t BitStream::get_uint64()
|
||||||
{
|
{
|
||||||
int64_t v1;
|
// khanat-opennel-code/code/nel/include/nel/misc/stream_inline.h inline void IStream::serial(uint64 &b)
|
||||||
int64_t v2;
|
// khanat-opennel-code/code/nel/include/nel/misc/stream.h #define NLMISC_BSWAP64(src) (src) = (((src)>>56)&0xFF) | ((((src)>>48)&0xFF)<<8) | ((((src)>>40)&0xFF)<<16) | ((((src)>>32)&0xFF)<<24) | ((((src)>>24)&0xFF)<<32) | ((((src)>>16)&0xFF)<<40) | ((((src)>>8)&0xFF)<<48) | (((src)&0xFF)<<56)
|
||||||
|
union S {
|
||||||
|
uint64_t full;
|
||||||
|
uint8_t key[8];
|
||||||
|
};
|
||||||
|
S v;
|
||||||
if(little_endian)
|
if(little_endian)
|
||||||
{
|
{
|
||||||
v1 = this->get_serial(32);
|
v.key[3] = this->get_uint8();
|
||||||
v2 = this->get_serial(32);
|
v.key[2] = this->get_uint8();
|
||||||
|
v.key[1] = this->get_uint8();
|
||||||
|
v.key[0] = this->get_uint8();
|
||||||
|
v.key[7] = this->get_uint8();
|
||||||
|
v.key[6] = this->get_uint8();
|
||||||
|
v.key[5] = this->get_uint8();
|
||||||
|
v.key[4] = this->get_uint8();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v2 = this->get_serial(32);
|
v.key[0] = this->get_uint8();
|
||||||
v1 = this->get_serial(32);
|
v.key[1] = this->get_uint8();
|
||||||
|
v.key[2] = this->get_uint8();
|
||||||
|
v.key[3] = this->get_uint8();
|
||||||
|
v.key[4] = this->get_uint8();
|
||||||
|
v.key[5] = this->get_uint8();
|
||||||
|
v.key[6] = this->get_uint8();
|
||||||
|
v.key[7] = this->get_uint8();
|
||||||
}
|
}
|
||||||
return (v1 << 32) | v2;
|
return v.full;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t BitStream::get_sint64()
|
||||||
|
{
|
||||||
|
return (int64_t) get_uint64();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BitStream::get_version()
|
uint32_t BitStream::get_version()
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,23 +18,22 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IMPULSE_BASE_H
|
#ifndef IMPULSE_H
|
||||||
#define IMPULSE_BASE_H
|
#define IMPULSE_H
|
||||||
|
|
||||||
#include "core/object.h"
|
#include "core/object.h"
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
#include "modules/bitstream/bitstream.h"
|
||||||
|
|
||||||
class ImpulseBase : public Reference
|
class Impulse : public Reference
|
||||||
{
|
{
|
||||||
GDCLASS(ImpulseBase, Reference)
|
GDCLASS(Impulse, Reference)
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
private:
|
||||||
|
int _id;
|
||||||
public:
|
public:
|
||||||
|
enum eImpulse {
|
||||||
ImpulseBase() {}
|
|
||||||
~ImpulseBase() {}
|
|
||||||
|
|
||||||
enum Impulse {
|
|
||||||
TARGET_PARTY,
|
TARGET_PARTY,
|
||||||
TARGET_INVENTORY,
|
TARGET_INVENTORY,
|
||||||
TARGET_FOLLOW,
|
TARGET_FOLLOW,
|
||||||
|
@ -372,12 +371,21 @@ public:
|
||||||
__LAST_ELEMENT
|
__LAST_ELEMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_command(String name);
|
Impulse() {_id = eImpulse::__LAST_ELEMENT;}
|
||||||
static String get_command_name(uint32_t id);
|
Impulse(int id) {_id = id;}
|
||||||
String get_name(Variant id);
|
~Impulse() {}
|
||||||
|
|
||||||
|
static int extract_command_id(String name);
|
||||||
|
static String extract_command_name(uint32_t id);
|
||||||
|
String extract_name(Variant id); // if static flag is activate, I can't find method to bind with gdscript
|
||||||
|
String get_name();
|
||||||
|
|
||||||
|
int get_id() {return this->_id;}
|
||||||
|
|
||||||
|
void put_stream(Ref<BitStream> msgout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(ImpulseBase::Impulse);
|
VARIANT_ENUM_CAST(Impulse::eImpulse);
|
||||||
|
|
||||||
#endif
|
#endif
|
61
modules/impulse/impulse_connection_delete_char.h
Normal file
61
modules/impulse/impulse_connection_delete_char.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
Header Impulse CONNECTION_DELETE_CHAR
|
||||||
|
|
||||||
|
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 IMPULSE_CONNECTION_DELETE_CHAR
|
||||||
|
#define IMPULSE_CONNECTION_DELETE_CHAR
|
||||||
|
|
||||||
|
|
||||||
|
#include "core/reference.h"
|
||||||
|
#include "modules/impulse/impulse.h"
|
||||||
|
#include "modules/bitstream/bitstream.h"
|
||||||
|
|
||||||
|
class ImpulseConnectionDeleteChar : public Impulse
|
||||||
|
{
|
||||||
|
GDCLASS(ImpulseConnectionDeleteChar, Reference)
|
||||||
|
Variant _slot;
|
||||||
|
public:
|
||||||
|
|
||||||
|
ImpulseConnectionDeleteChar() : Impulse(Impulse::CONNECTION_DELETE_CHAR) {_slot = 0;}
|
||||||
|
~ImpulseConnectionDeleteChar() {}
|
||||||
|
|
||||||
|
void set_data(Variant slot) { _slot = slot;}
|
||||||
|
|
||||||
|
void put_stream(Ref<BitStream> msgout)
|
||||||
|
{
|
||||||
|
Impulse::put_stream(msgout);
|
||||||
|
msgout->put_uint8((uint8_t)_slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get_name()
|
||||||
|
{
|
||||||
|
// We need re-expose function for gdscript
|
||||||
|
return Impulse::get_name();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods()
|
||||||
|
{
|
||||||
|
ClassDB::bind_method(D_METHOD("get_name"), &ImpulseConnectionDeleteChar::get_name);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_data", "slot"), &ImpulseConnectionDeleteChar::set_data);
|
||||||
|
ClassDB::bind_method(D_METHOD("put_stream", "msgout"), &ImpulseConnectionDeleteChar::put_stream);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,11 +3,13 @@
|
||||||
#include "register_types.h"
|
#include "register_types.h"
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/class_db.h"
|
||||||
#include "impulsebase.h"
|
#include "impulse.h"
|
||||||
|
#include "impulse_connection_delete_char.h"
|
||||||
#include "people.h"
|
#include "people.h"
|
||||||
|
|
||||||
void register_impulse_types() {
|
void register_impulse_types() {
|
||||||
ClassDB::register_class<ImpulseBase>();
|
ClassDB::register_class<Impulse>();
|
||||||
|
ClassDB::register_class<ImpulseConnectionDeleteChar>();
|
||||||
ClassDB::register_class<People>();
|
ClassDB::register_class<People>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "referentialmessage.h"
|
#include "referentialmessage.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "modules/impulse/impulsebase.h"
|
#include "modules/impulse/impulse.h"
|
||||||
|
|
||||||
void ReferentialMessage::_bind_methods()
|
void ReferentialMessage::_bind_methods()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ int ReferentialMessage::read_command(Ref<BitStream> msgin)
|
||||||
return ReferentialMessageCore::get_singleton()->read_command(msgin);
|
return ReferentialMessageCore::get_singleton()->read_command(msgin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReferentialMessage::write_command(ImpulseBase::Impulse command, Ref<BitStream> msgout)
|
void ReferentialMessage::write_command(Impulse::eImpulse command, Ref<BitStream> msgout)
|
||||||
{
|
{
|
||||||
ReferentialMessageCore::get_singleton()->write_command(command, msgout);
|
ReferentialMessageCore::get_singleton()->write_command(command, msgout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
//#include "core/dictionary.h"
|
//#include "core/dictionary.h"
|
||||||
//#include "modules/bitstream/bitstream.h"
|
//#include "modules/bitstream/bitstream.h"
|
||||||
#include "modules/referentialmessage/referentialmessagecore.h"
|
#include "modules/referentialmessage/referentialmessagecore.h"
|
||||||
#include "modules/impulse/impulsebase.h"
|
#include "modules/impulse/impulse.h"
|
||||||
|
|
||||||
class ReferentialMessage : public Reference {
|
class ReferentialMessage : public Reference {
|
||||||
GDCLASS(ReferentialMessage, Reference)
|
GDCLASS(ReferentialMessage, Reference)
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
int read_command(Ref<BitStream> msgin);
|
int read_command(Ref<BitStream> msgin);
|
||||||
void write_command(ImpulseBase::Impulse command, Ref<BitStream> msgout);
|
void write_command(Impulse::eImpulse command, Ref<BitStream> msgout);
|
||||||
|
|
||||||
void clear_session();
|
void clear_session();
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "modules/debug/debug.h"
|
#include "modules/debug/debug.h"
|
||||||
#include "modules/impulse/impulsebase.h"
|
#include "modules/impulse/impulse.h"
|
||||||
#include "referentialmessagecore.h"
|
#include "referentialmessagecore.h"
|
||||||
|
|
||||||
ReferentialMessageCore *ReferentialMessageCore::singleton = nullptr;
|
ReferentialMessageCore *ReferentialMessageCore::singleton = nullptr;
|
||||||
|
@ -35,14 +35,14 @@ void ElementReferential::show(int level, int pos)
|
||||||
String a;
|
String a;
|
||||||
for(int i=0;i<level;++i)
|
for(int i=0;i<level;++i)
|
||||||
a += String(CharString("+"));
|
a += String(CharString("+"));
|
||||||
if(_id == ImpulseBase::Impulse::__LAST_ELEMENT)
|
if(_id == Impulse::__LAST_ELEMENT)
|
||||||
{
|
{
|
||||||
//OS::get_singleton()->print("[%s:%d] level:%d %s pos:%3d ------ power:%d\n", __FILE__, __LINE__, level, a.ascii().get_data(), pos, _power2);
|
//OS::get_singleton()->print("[%s:%d] level:%d %s pos:%3d ------ power:%d\n", __FILE__, __LINE__, level, a.ascii().get_data(), pos, _power2);
|
||||||
DBG_PRINT("level:" + itos(level) + " " + a + " id:" + ImpulseBase::get_command_name(_id) + " pos:" + itos(pos) + " ------ power:" + itos(_power2));
|
DBG_PRINT("level:" + itos(level) + " " + a + " id:" + Impulse::extract_command_name(_id) + " pos:" + itos(pos) + " ------ power:" + itos(_power2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG_PRINT("level:" + itos(level) + " " + a + " pos:" + itos(pos) + " id:" + ImpulseBase::get_command_name(_id));
|
DBG_PRINT("level:" + itos(level) + " " + a + " pos:" + itos(pos) + " id:" + Impulse::extract_command_name(_id));
|
||||||
}
|
}
|
||||||
level ++;
|
level ++;
|
||||||
for(int i=0;i<_children.size();++i)
|
for(int i=0;i<_children.size();++i)
|
||||||
|
@ -57,7 +57,7 @@ int ElementReferential::read_command(Ref<BitStream> msgin)
|
||||||
uint32_t i = msgin->get_serial(_power2);
|
uint32_t i = msgin->get_serial(_power2);
|
||||||
Ref<ElementReferential> child = _children[i];
|
Ref<ElementReferential> child = _children[i];
|
||||||
|
|
||||||
if ( child->_id != ImpulseBase::Impulse::__LAST_ELEMENT )
|
if ( child->_id != Impulse::__LAST_ELEMENT )
|
||||||
return child->_id;
|
return child->_id;
|
||||||
return child->read_command(msgin);
|
return child->read_command(msgin);
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,8 @@ void ReferentialMessageCore::read_referential_step(Dictionary step, Vector<Eleme
|
||||||
a += head.get(ii).get_name();
|
a += head.get(ii).get_name();
|
||||||
uint32_t _size = head.get(ii).get_size()+1;
|
uint32_t _size = head.get(ii).get_size()+1;
|
||||||
ele->put_serial(head.get(ii).get_pos(), getPowerOf2(_size));
|
ele->put_serial(head.get(ii).get_pos(), getPowerOf2(_size));
|
||||||
int id = ImpulseBase::get_command(a);
|
int id = Impulse::extract_command_id(a);
|
||||||
if (id != ImpulseBase::Impulse::__LAST_ELEMENT)
|
if (id != Impulse::__LAST_ELEMENT)
|
||||||
{
|
{
|
||||||
_encoder[id].copy_ref_bitstream(ele);
|
_encoder[id].copy_ref_bitstream(ele);
|
||||||
root->set_id(id);
|
root->set_id(id);
|
||||||
|
@ -117,7 +117,7 @@ void ReferentialMessageCore::read_referential_step(Dictionary step, Vector<Eleme
|
||||||
if(info.size() == 2 )
|
if(info.size() == 2 )
|
||||||
{
|
{
|
||||||
uint32_t id = info[0].to_int();
|
uint32_t id = info[0].to_int();
|
||||||
Ref<ElementReferential> root_child = root->add_child(ImpulseBase::Impulse::__LAST_ELEMENT, i);
|
Ref<ElementReferential> root_child = root->add_child(Impulse::__LAST_ELEMENT, i);
|
||||||
Variant child ;
|
Variant child ;
|
||||||
child = step[name];
|
child = step[name];
|
||||||
ElementHead tmp;
|
ElementHead tmp;
|
||||||
|
@ -133,7 +133,7 @@ void ReferentialMessageCore::read_referential(Dictionary dictionary_message)
|
||||||
{
|
{
|
||||||
Vector<ElementHead> head;
|
Vector<ElementHead> head;
|
||||||
DBG_PRINT("Read Referential Message");
|
DBG_PRINT("Read Referential Message");
|
||||||
_decoder->set_id(ImpulseBase::Impulse::__LAST_ELEMENT);
|
_decoder->set_id(Impulse::__LAST_ELEMENT);
|
||||||
read_referential_step(dictionary_message, head, _decoder);
|
read_referential_step(dictionary_message, head, _decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ void ReferentialMessageCore::show()
|
||||||
*/
|
*/
|
||||||
// show Element to push data
|
// show Element to push data
|
||||||
{
|
{
|
||||||
for(int i = 0; i < ImpulseBase::Impulse::__LAST_ELEMENT; ++i)
|
for(int i = 0; i < Impulse::__LAST_ELEMENT; ++i)
|
||||||
{
|
{
|
||||||
DBG_PRINT(itos(i) + ") " + ImpulseBase::get_command_name(i) + " " + this->_encoder[i].show().ascii().get_data() + " [size:" + itos(this->_encoder[i].size_data()) + "]");
|
DBG_PRINT(itos(i) + ") " + Impulse::extract_command_name(i) + " " + this->_encoder[i].show().ascii().get_data() + " [size:" + itos(this->_encoder[i].size_data()) + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// show element to read data
|
// show element to read data
|
||||||
|
@ -171,12 +171,12 @@ int ReferentialMessageCore::read_command(Ref<BitStream> msgin)
|
||||||
return _decoder->read_command(msgin);
|
return _decoder->read_command(msgin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReferentialMessageCore::write_command(ImpulseBase::Impulse command, Ref<BitStream> msgout)
|
void ReferentialMessageCore::write_command(Impulse::eImpulse command, Ref<BitStream> msgout)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if ( command >= ImpulseBase::Impulse::__LAST_ELEMENT )
|
if ( command >= Impulse::__LAST_ELEMENT )
|
||||||
{
|
{
|
||||||
ERR_PRINT("Out of range (" + itos(command) + " / " + itos(ImpulseBase::Impulse::__LAST_ELEMENT) + ")");
|
ERR_PRINT("Out of range (" + itos(command) + " / " + itos(Impulse::__LAST_ELEMENT) + ")");
|
||||||
throw "Out of range";
|
throw "Out of range";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "core/dictionary.h"
|
#include "core/dictionary.h"
|
||||||
#include "modules/bitstream/bitstream.h"
|
#include "modules/bitstream/bitstream.h"
|
||||||
#include "modules/debug/debug.h"
|
#include "modules/debug/debug.h"
|
||||||
#include "modules/impulse/impulsebase.h"
|
#include "modules/impulse/impulse.h"
|
||||||
|
|
||||||
inline uint32_t getPowerOf2(uint32_t v)
|
inline uint32_t getPowerOf2(uint32_t v)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
static ReferentialMessageCore *singleton;
|
static ReferentialMessageCore *singleton;
|
||||||
BitStream _encoder[ImpulseBase::Impulse::__LAST_ELEMENT];
|
BitStream _encoder[Impulse::__LAST_ELEMENT];
|
||||||
Ref<ElementReferential> _decoder;
|
Ref<ElementReferential> _decoder;
|
||||||
void read_referential_step(Dictionary step, Vector<ElementHead> head, Ref<ElementReferential> root);
|
void read_referential_step(Dictionary step, Vector<ElementHead> head, Ref<ElementReferential> root);
|
||||||
public:
|
public:
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
|
|
||||||
static void clear_session();
|
static void clear_session();
|
||||||
int read_command(Ref<BitStream> msgin);
|
int read_command(Ref<BitStream> msgin);
|
||||||
void write_command(ImpulseBase::Impulse command, Ref<BitStream> msgout);
|
void write_command(Impulse::eImpulse command, Ref<BitStream> msgout);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue