update action

This commit is contained in:
AleaJactaEst 2020-05-13 13:25:01 +02:00
parent 8a34bc6e39
commit f24902f4bc
7 changed files with 575 additions and 71 deletions

View file

@ -192,29 +192,36 @@ custom_fonts/font = SubResource( 3 )
text = "Tester sans se connecter"
[node name="error_dialog" type="PopupDialog" parent="."]
margin_right = 400.0
margin_bottom = 150.0
margin_right = 658.0
margin_bottom = 229.0
size_flags_horizontal = 7
size_flags_vertical = 7
popup_exclusive = true
[node name="v_box_container" type="VBoxContainer" parent="error_dialog"]
margin_right = 400.0
margin_bottom = 150.0
margin_right = 657.0
margin_bottom = 224.0
size_flags_horizontal = 7
size_flags_vertical = 7
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="label" type="Label" parent="error_dialog/v_box_container"]
margin_right = 400.0
margin_bottom = 17.0
margin_top = 85.0
margin_right = 657.0
margin_bottom = 102.0
custom_colors/font_color = Color( 1, 1, 1, 1 )
text = "Error detected"
align = 1
valign = 1
[node name="button" type="Button" parent="error_dialog/v_box_container"]
margin_right = 16.0
margin_bottom = 33.0
margin_left = 311.0
margin_top = 106.0
margin_right = 346.0
margin_bottom = 139.0
size_flags_horizontal = 4
size_flags_vertical = 4
text = "Ok"

View file

@ -58,6 +58,7 @@ func _on_sound_button_toggled(button_pressed):
func _on_login_menu_register_button_pressed():
print("register_button_pressed")
$login_menu.hide()
$register_menu.show()
$license_menu.hide()
@ -65,6 +66,7 @@ func _on_login_menu_register_button_pressed():
$message_system.hide()
func _on_register_menu_cancel_button_pressed():
print("_on_register_menu_cancel_button_pressed")
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
@ -72,6 +74,7 @@ func _on_register_menu_cancel_button_pressed():
$message_system.hide()
func _on_register_menu_license_button_pressed():
print("_on_register_menu_license_button_pressed")
$login_menu.hide()
$register_menu.hide()
$license_menu.show()
@ -79,6 +82,7 @@ func _on_register_menu_license_button_pressed():
$message_system.hide()
func _on_license_menu_return_button_pressed():
print("_on_license_menu_return_button_pressed")
$login_menu.hide()
$register_menu.show()
$license_menu.hide()
@ -86,6 +90,7 @@ func _on_license_menu_return_button_pressed():
$message_system.hide()
func _on_register_menu_register_account_created():
print("_on_register_menu_register_account_created")
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
@ -93,6 +98,7 @@ func _on_register_menu_register_account_created():
$message_system.hide()
func _on_Settings_menu_return_pressed():
print("_on_Settings_menu_return_pressed")
$login_menu.show()
$register_menu.hide()
$license_menu.hide()
@ -100,6 +106,7 @@ func _on_Settings_menu_return_pressed():
$message_system.hide()
func _on_settings_button_pressed():
print("_on_settings_button_pressed")
$login_menu.hide()
$register_menu.hide()
$license_menu.hide()

View file

@ -80,6 +80,7 @@ texture_normal = ExtResource( 12 )
[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"]
[connection signal="register_button_pressed" from="login_menu" to="." method="_on_login_menu_register_button_pressed"]
[connection signal="cancel_button_pressed" from="register_menu" to="." method="_on_register_menu_cancel_button_pressed"]
[connection signal="license_button_pressed" from="register_menu" to="." method="_on_register_menu_license_button_pressed"]
[connection signal="register_account_created" from="register_menu" to="." method="_on_register_menu_register_account_created"]

View file

@ -5,6 +5,8 @@ extends Control
# var a = 2
# var b = "text"
enum State {INIT, DELETED_CHAR, CREATE_CHAR, ASK_NAME, SELECT_CHAR, READY, BOTCHAT_SET_FILTERS}
var _networkconnection = NetworkConnection.new()
var _history = Array()
const StringManager = preload("res://assets/Scripts/Config/string_manager.gd")
@ -13,11 +15,19 @@ var _phrases_not_decoded = Array()
var _shard_names = Array()
var _character_summaries = Array()
var _mainlands = Array()
var _tick_position = 0
var _pos_current = 0
var _create_char = false
var _delete_char = false
var _select_char = false
var _launch_create_user = false
var _state = State.INIT
var _slot = 2
var _name = "OhMeVoila"
var _loop_position = [{'x':8858357, 'y': -10595281, 'z':4619, 'heading': -0.470425},
{'x':8859099, 'y': -10595661, 'z':4688, 'heading': -0.470425},
{'x':8859885, 'y': -10596062, 'z':4726, 'heading': -0.470425},
{'x':8870072, 'y': -10596763, 'z':5542, 'heading': 0.179909},
{'x':8879656, 'y': -10590482, 'z':5613, 'heading': 0.507214}]
# Called when the node enters the scene tree for the first time.
func _ready():
@ -116,32 +126,22 @@ func append_message_raw(message, flow):
msg['impulse_debug'] = message
_history.append(msg)
func delete_char():
print("***** Delete old car")
if _character_summaries.size() <= _slot:
return
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_DELETE_CHAR,
"slot": _slot
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_state = State.DELETED_CHAR
func create_char():
var slot = 2
if _create_char == true:
if _character_summaries.size() <= _slot:
return
if _character_summaries.size() <= slot:
return
if _character_summaries[slot]['people'] != People.Unknown:
if _delete_char == false:
print("***** Delete old car")
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_DELETE_CHAR,
"slot": slot
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_delete_char = true
#var cmd = ImpulseConnectionDeleteChar.new()
#cmd.set_slot(0)
#print("slot:" + String(cmd['slot']))
return
if _launch_create_user == true:
return
_launch_create_user = true
print("***** Launch command to create User")
# Becarefull with check like
# nb_point_fighter + nb_point_caster + nb_point_crafter + nb_point_harvester <= 5 # bool CCharacter::checkCreateParams( const CCreateCharMsg& createCharMsg, CCreateCharErrorMsg& createCharErrorMsg, uint32 userId )
@ -159,10 +159,10 @@ func create_char():
var command1 = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_CREATE_CHAR,
'slot': slot,
'slot': _slot,
'sheet_id': 0,
'session_id': int(_shard_names[0]['session_id']),
'name': "UnSuperTest",
'name': _name,
'people': People.Zorai,
'sex': 1,
'nb_point_fighter': 2,
@ -197,10 +197,10 @@ func create_char():
var command2 = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_CREATE_CHAR,
'slot': slot,
'slot': _slot,
'sheet_id': 0,
'session_id': int(_shard_names[0]['session_id']),
'name': "UnSuperTest",
'name': _name,
'people': People.Fyros,
'sex': 1,
'nb_point_fighter': 2,
@ -235,10 +235,10 @@ func create_char():
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_CREATE_CHAR,
'slot': slot,
'slot': _slot,
'sheet_id': 0,
'session_id': int(_shard_names[0]['session_id']),
'name': "UnSuperTest",
'name': _name,
'people': People.Fyros,
'sex': 1,
'nb_point_fighter': 0,
@ -272,19 +272,79 @@ func create_char():
}
_networkconnection.put_command(command1);
append_message(command['impulse'], '<')
_delete_char = true
_create_char = true
_state = State.CREATE_CHAR
func select_char():
var slot = 2
func ask_name():
var session_id = int(_shard_names[0]['session_id'])
var name = "UnSuperTest"
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_SELECT_CHAR,
"slot": slot
'impulse': Impulse.CONNECTION_ASK_NAME,
'name': name,
'session_id': session_id
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_state = State.ASK_NAME
func select_char():
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_SELECT_CHAR,
"slot": _slot
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_state = State.SELECT_CHAR
func botchat_set_filters():
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.BOTCHAT_SET_FILTERS,
'quality_min': 0,
'quality_max': 300,
'price_min': 0,
'price_max': 999999999,
'class_min': 0,
'class_max': 4,
'item_part': 26,
'item_type': 67
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_state = State.BOTCHAT_SET_FILTERS
func connection_ready():
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.CONNECTION_READY,
"language_code": "fr"
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_state = State.READY
func position(pos):
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.POSITION,
'x': pos['x'],
'y': pos['y'],
'z': pos['z'],
'heading': pos['heading']
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
#_state = State.READY
func debug_ping(localtime):
var command = {
'action': Action.ACTION_GENERIC_CODE,
'impulse': Impulse.DEBUG_PING,
'local_time': localtime
}
_networkconnection.put_command(command);
append_message(command['impulse'], '<')
_select_char = true
func analyze_message(message):
if message['action'] == Action.ACTION_POSITION_CODE:
@ -300,10 +360,41 @@ func analyze_message(message):
elif message['impulse'] == Impulse.CONNECTION_USER_CHARS:
user_chars(message)
# Normally this step is executed when player ask to create
if _create_char == false:
if _character_summaries[_slot]['people'] != People.Unknown and _state == State.INIT:
delete_char()
elif _state == State.INIT or _state == State.DELETED_CHAR:
create_char()
elif _select_char == false:
select_char()
elif _character_summaries[_slot]['people'] != People.Unknown:
ask_name()
elif _character_summaries[_slot]['people'] == People.Unknown and _state == State.CREATE_CHAR:
_state = State.DELETED_CHAR
elif message['impulse'] == Impulse.CONNECTION_VALID_NAME:
print("------------------------------------------------------------------------")
print(_state)
print(State.CREATE_CHAR)
print(_character_summaries[_slot]['people'])
print("------------------------------------------------------------------------")
select_char()
elif message['impulse'] == Impulse.CONNECTION_USER_CHAR:
pass
elif message['impulse'] == Impulse.CONNECTION_READY:
connection_ready()
elif message['impulse'] == Impulse.GUILD_USE_FEMALE_TITLES:
pass
func send_state():
if _state == State.READY:
botchat_set_filters()
elif _state == State.BOTCHAT_SET_FILTERS:
var tick = _networkconnection.get_server_tick()
if _tick_position < tick:
_tick_position = tick + 20
position(_loop_position[_pos_current])
append_message_raw("position:" + String(_pos_current), "-")
_pos_current = (_pos_current + 1 ) % _loop_position.size()
if tick % 40 == 0:
debug_ping(tick)
#elif _state == State.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
@ -316,6 +407,7 @@ func _process(delta):
message['flow'] = '>'
print(message)
analyze_message(message)
send_state()
if _history.size() > 0:
# just to see last message (normally cleanned each time we read message)
while _history.size() > 20:

View file

@ -133,6 +133,29 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::CONNECTION_USER_CHAR:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::sendUserChar( uint32 userId, uint8 scenarioSeason, const R2::TUserRole& userRole )
int32_t x = msgin->get_sint32();
int32_t y = msgin->get_sint32();
int32_t z = msgin->get_sint32();
float heading = msgin->get_float();
uint32_t season = msgin->get_serial(3);
uint32_t user_role = msgin->get_serial(3);
uint32_t highest_mainland_session_id = msgin->get_uint32();
uint32_t first_connected_time = msgin->get_uint32();
uint32_t played_time = msgin->get_uint32();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " x:" + itos(x) + " y:" + itos(y) + " z:" + itos(z) + " season:" + itos(season) +
" user_role:" + itos(user_role) + " highest_mainland_session_id:" + itos(highest_mainland_session_id) +
" first_connected_time:" + itos(first_connected_time) + " played_time:" + itos(played_time) + "heading:" + rtos(heading));
value["x"] = x;
value["y"] = y;
value["z"] = z;
value["heading"] = heading;
value["season"] = season;
value["user_role"] = user_role;
value["highest_mainland_session_id"] = highest_mainland_session_id;
value["first_connected_time"] = first_connected_time;
value["played_time"] = played_time;
break;
}
case Impulse::CONNECTION_NO_USER_CHAR:
@ -271,6 +294,10 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::CONNECTION_READY:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/id_impulsions.cpp void impulsionRdy( CEntityId& sender, CBitMemStream &bms, TGameCycle gamecycle, uint16 serviceId )
String language_code = msgin->get_string();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " language_code:" + language_code);
value["language_code"] = language_code;
break;
}
case Impulse::CONNECTION_TIME_DATE_SYNCHRO:
@ -283,6 +310,10 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::CONNECTION_VALID_NAME:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/entity_manager/entity_callbacks.cpp void sendIfNameIsValide( uint32 userId, bool nameValide )
uint8_t valid = msgin->get_uint8();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " valid:" + itos(valid));
value["valid"] = valid;
break;
}
case Impulse::CONNECTION_CREATE_CHAR_ERROR:
@ -299,6 +330,12 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::CONNECTION_SHARD_ID:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/entity_manager/entity_callbacks.cpp void cbClientReady( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
uint32_t shard_id = msgin->get_uint32();
String web_host = msgin->get_string();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " shard_id:" + itos(shard_id) + " web_host:" + web_host);
value["shard_id"] = shard_id;
value["web_host"] = web_host;
break;
}
case Impulse::CONNECTION_SERVER_QUIT_OK:
@ -535,6 +572,10 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::STRING_DYN_STRING:
{
// khanat-opennel-code/code/ryzom/server/src/input_output_service/messages.cpp void cbGroupDynString( CMessage& msgin, const string &serviceName, TServiceId serviceId )
uint32_t phrase_id = msgin->get_uint32();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " phrase_id:" + itos(phrase_id));
value["phrase_id"] = phrase_id;
break;
}
case Impulse::STRING_DYN_STRING_GROUP:
@ -655,6 +696,39 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::TEAM_CONTACT_INIT:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::sendContactListInit()
uint32_t i;
uint32_t friend_string_ids_len = msgin->get_uint32();
value["friend_string_ids_len"] = friend_string_ids_len;
Array friend_string_ids;
for(i = 0;i < friend_string_ids_len;++i)
{
uint32_t in = msgin->get_uint32();
friend_string_ids.append(in);
}
value["friend_string_ids"] = friend_string_ids;
uint32_t nb_state = msgin->get_uint32();
value["nb_state"] = nb_state;
Array friend_online_status;
for(i = 0;i < nb_state;++i)
{
uint8_t state = msgin->get_uint8();
friend_online_status.append(state);
}
value["friend_online_status"] = friend_online_status;
uint32_t ignore_list_len = msgin->get_uint32();
value["ignore_list_len"] = ignore_list_len;
Array ignore_list;
for(i = 0;i < ignore_list_len;++i)
{
String str = msgin->get_string_utf16();
ignore_list.append(str);
}
value["ignore_list"] = ignore_list;
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id));
break;
}
case Impulse::TEAM_CONTACT_ADD:
@ -787,6 +861,26 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::DEATH_RESPAWN_POINT:
{
// entities_game_service/player_manager/character_respawn_points.cpp
// void CCharacterRespawnPoints::resetUserDb() const
// void CCharacterRespawnPoints::addRespawnPointToUserDb(TRespawnPoint respawnPoint) const
uint32_t i;
bool need_to_reset = msgin->get_bool();
value["need_to_reset"] = need_to_reset;
uint32_t respawn_points_len = msgin->get_uint32();
Array respawn_points;
for(i = 0;i < respawn_points_len;++i)
{
Dictionary respawn_point;
int32_t x = msgin->get_sint32();
int32_t y = msgin->get_sint32();
respawn_point['x'] = x;
respawn_point['y'] = y;
respawn_points.append(respawn_point);
}
value["respawn_points"] = respawn_points;
break;
}
case Impulse::DEATH_ASK_RESPAWN:
@ -987,6 +1081,28 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::BOTCHAT_SET_FILTERS:
{
// /home/aleajactaest/Projets/khanat/khanat-opennel-code/code/ryzom/server/src/entities_game_service/client_messages.cpp void cbClientBotChatSetFilters( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
//uint32_t quality_min = msgin->get_uint32();
//uint32_t quality_max = msgin->get_uint32();
//uint32_t price_min = msgin->get_uint32();
//uint32_t price_max = msgin->get_uint32();
//uint32_t class_min = msgin->get_uint8();
//uint32_t class_max = msgin->get_uint8();
//uint32_t item_part = msgin->get_uint8();
//uint32_t item_type = msgin->get_uint8();
//DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) +
// " quality_min:" + itos(quality_min) + " quality_max:" + itos(quality_max) +
// " price_min:" + itos(price_min) + " price_max:" + itos(price_max) +
// " class_min:" + itos(class_min) + " class_max:" + itos(class_max) +
// " item_part:" + itos(item_part) + " item_type:" + itos(item_type));
//value["quality_min"] = quality_min;
//value["quality_max"] = quality_max;
//value["price_min"] = price_min;
//value["price_max"] = price_max;
//value["class_min"] = class_min;
//value["class_max"] = class_max;
//value["item_part"] = item_part;
//value["item_type"] = item_type;
break;
}
case Impulse::BOTCHAT_START_CHOOSE_MISSION:
@ -1221,10 +1337,27 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::GUILD_UPDATE_PLAYER_TITLE:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::sendReservedTitleStatus(CHARACTER_TITLE::ECharacterTitle title, bool available) const
uint32_t i;
bool available = msgin->get_bool();
value["available"] = available;
uint32_t title_len = msgin->get_uint32();
value["title_len"] = title_len;
Array titles;
for(i = 0;i < title_len;++i)
{
titles.append(msgin->get_uint16());
}
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " available:" + itos(available));
value["titles"] = titles;
break;
}
case Impulse::GUILD_USE_FEMALE_TITLES:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/entity_manager/entity_callbacks.cpp void cbSelectChar( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
bool use_female_titles = msgin->get_bool();
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id) + " use_female_titles:" + itos(use_female_titles));
value["use_female_titles"] = use_female_titles;
break;
}
case Impulse::GUILD_PUT_MONEY:
@ -1345,6 +1478,62 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::PHRASE_DOWNLOAD:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::sendPhrasesToClient()
uint32_t i;
uint32_t known_phrases_len = msgin->get_uint32();
value["known_phrases_len"] = known_phrases_len;
Array known_phrases;
DBG_PRINT("known_phrases_len:" + itos(known_phrases_len));
for(i = 0;i < known_phrases_len;++i)
{
DBG_PRINT("i:" + itos(i));
Dictionary known_phrase;
// Phrase
{
String phrase = msgin->get_string_utf8();
DBG_PRINT("phrase:" + phrase);
known_phrase["phrase"] = phrase;
uint32_t size = msgin->get_uint32();
DBG_PRINT("size:" + itos(size));
Array comp_bricks;
for(uint32_t ii = 0;ii < size;++ii)
{
uint16_t comp_brick = msgin->get_uint16();
DBG_PRINT(itos(ii) + " = comp_brick:" + itos(comp_brick));
comp_bricks.append(comp_brick);
}
known_phrase["comp_bricks"] = comp_bricks;
}
// KnownSlot
uint16_t known_slot = msgin->get_uint16();
DBG_PRINT("known_slot:" + itos(known_slot));
known_phrase["known_slot"] = known_slot;
// PhraseSheetId
uint32_t phrase_sheet_id = msgin->get_uint32();
DBG_PRINT("phrase_sheet_id:" + itos(phrase_sheet_id));
known_phrase["phrase_sheet_id"] = phrase_sheet_id;
known_phrases.append(known_phrase);
}
value["known_phrases"] = known_phrases;
// memorized_phrases
uint32_t memorized_phrases_len = msgin->get_uint32();
DBG_PRINT("memorized_phrases_len:" + itos(memorized_phrases_len));
Array memorized_phrases;
for(i = 0;i < memorized_phrases_len;++i)
{
DBG_PRINT("i:" + itos(i));
Dictionary memory;
memory["memory_line_id"] = msgin->get_uint8();
DBG_PRINT("memory_line_id:" + itos(memory["memory_line_id"]));
memory["memory_slot_id"] = msgin->get_uint8();
DBG_PRINT("memory_slot_id:" + itos(memory["memory_slot_id"]));
memory["phrase_id"] = msgin->get_uint16();
DBG_PRINT("phrase_id:" + itos(memory["phrase_id"]));
memorized_phrases.append(memory);
}
value["memorized_phrases"] = memorized_phrases;
break;
}
case Impulse::PHRASE_BUY:
@ -1501,10 +1690,110 @@ void ActionFactory::decode_message(NetworkData * data, Ref<BitStream> msgin)
}
case Impulse::ENCYCLOPEDIA_INIT:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character_encyclopedia.cpp void CCharacterEncyclopedia::sendEncycloToClient()
int32_t type = msgin->get_sint32();
value["type"] = type;
switch(type)
{
case 0:
{
// All albums
uint32_t i;
uint32_t all_albums_len = msgin->get_uint32();
value["all_albums_len"] = all_albums_len;
Array all_albums;
for(i = 0;i < all_albums_len;++i)
{
Dictionary album;
uint32_t album_name = msgin->get_uint32();
album["album_name"] = album_name;
uint32_t reward_brick = msgin->get_uint32();
album["reward_brick"] = reward_brick;
uint8_t state = msgin->get_uint8();
album["state"] = state;
all_albums.append(album);
}
value["all_albums"] = all_albums;
break;
}
case 1:
{
// Update
Dictionary album;
uint32_t album_name = msgin->get_uint32();
album["album_name"] = album_name;
uint32_t reward_brick = msgin->get_uint32();
album["reward_brick"] = reward_brick;
uint8_t state = msgin->get_uint8();
album["state"] = state;
value["update_album"] = album;
break;
}
default: // default & case 2
{
// Thema
uint32_t i;
uint32_t ii;
uint32_t album_name = msgin->get_uint32();
value["album_name"] = album_name;
uint32_t thema_len = msgin->get_uint32();
value["thema_len"] = thema_len;
Array themas;
for(i = 0;i < thema_len;++i)
{
Dictionary thema;
uint32_t thema_name = msgin->get_uint32();
thema["thema_name"] = thema_name;
uint8_t state_nb_task = msgin->get_uint8();
uint8_t state = state_nb_task & 0x3;
uint8_t nb_task = state_nb_task >> 2;
thema["state_nb_task"] = state_nb_task;
thema["state"] = state;
thema["nb_task"] = nb_task;
if(state == 2)
{
uint32_t reward_text = msgin->get_uint32();
thema["reward_text"] = reward_text;
uint32_t reward_sheet = msgin->get_uint32();
thema["reward_sheet"] = reward_sheet;
}
Array tasks;
for(ii = 0;ii < nb_task;++ii)
{
Dictionary task;
uint32_t task_name = msgin->get_uint32();
task["task_name"] = task_name;
uint32_t task_npc_name = msgin->get_uint32();
task["task_npc_name"] = task_npc_name;
tasks.append(task);
}
thema["tasks"] = tasks;
themas.append(thema);
uint16_t rite_task_state_packed = msgin->get_uint16();
thema["rite_task_state_packed"] = rite_task_state_packed;
}
value["themas"] = themas;
break;
}
}
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id));
break;
}
case Impulse::USER_BARS:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::barUpdate()
uint8_t bar_sent_to_player_msg_number = msgin->get_uint8();
value["bar_sent_to_player_msg_number"] = bar_sent_to_player_msg_number;
int32_t old_cha_score_1_bar_sent_to_player = msgin->get_sint32();
value["old_cha_score_1_bar_sent_to_player"] = old_cha_score_1_bar_sent_to_player;
int32_t old_cha_score_2_bar_sent_to_player = msgin->get_sint32();
value["old_cha_score_2_bar_sent_to_player"] = old_cha_score_2_bar_sent_to_player;
int32_t old_cha_score_3_bar_sent_to_player = msgin->get_sint32();
value["old_cha_score_3_bar_sent_to_player"] = old_cha_score_3_bar_sent_to_player;
int32_t old_cha_score_4_bar_sent_to_player = msgin->get_sint32();
value["old_cha_score_4_bar_sent_to_player"] = old_cha_score_4_bar_sent_to_player;
DBG_PRINT("Decode message:" + Impulse::extract_command_name(id));
break;
}
case Impulse::USER_POPUP:
@ -1636,6 +1925,7 @@ void ActionFactory::encode_message(Dictionary value, Ref<BitStream> msgout)
}
case Impulse::CONNECTION_CREATE_CHAR:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/uid_impulsions.cpp static void impulsionCreateChar(uint32 uid, NLMISC::CBitMemStream &bms, NLMISC::TGameCycle gameCycle)
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp:7977 bool CCharacter::checkCreateParams( const CCreateCharMsg& createCharMsg, CCreateCharErrorMsg& createCharErrorMsg, uint32 userId )
uint8_t slot = value["slot"];
uint8_t people = value["people"];
@ -1708,6 +1998,88 @@ void ActionFactory::encode_message(Dictionary value, Ref<BitStream> msgout)
DBG_PRINT("[ActionFactory::pack] ACTION_GENERIC_CODE encode_message B:" + itos(id) + " / " + msgout->show_detail());
break;
}
case Impulse::CONNECTION_ASK_NAME:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/uid_impulsions.cpp static void impulsionAskChar(uint32 uid, NLMISC::CBitMemStream &bms, NLMISC::TGameCycle gameCycle)
String name = value["name"];
uint32_t session_id = value["session_id"];
msgout->put_string_utf16(name);
msgout->put_uint32(session_id);
break;
}
case Impulse::CONNECTION_SELECT_CHAR:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/uid_impulsions.cpp static void impulsionSelectChar(uint32 uid, NLMISC::CBitMemStream &bms, NLMISC::TGameCycle gameCycle)
uint8_t slot = value["slot"];
msgout->put_uint8(slot);
break;
}
case Impulse::CONNECTION_READY:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/id_impulsions.cpp void impulsionRdy( CEntityId& sender, CBitMemStream &bms, TGameCycle gamecycle, uint16 serviceId )
String language_code = value["language_code"];
msgout->put_string(language_code);
break;
}
case Impulse::BOTCHAT_SET_FILTERS:
{
// /home/aleajactaest/Projets/khanat/khanat-opennel-code/code/ryzom/server/src/entities_game_service/client_messages.cpp void cbClientBotChatSetFilters( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
uint32_t quality_min = value["quality_min"];
uint32_t quality_max = value["quality_max"];
uint32_t price_min = value["price_min"];
uint32_t price_max = value["price_max"];
uint8_t class_min = value["class_min"];
uint8_t class_max = value["class_max"];
uint8_t item_part = value["item_part"];
uint8_t item_type = value["item_type"];
msgout->put_uint32(quality_min);
msgout->put_uint32(quality_max);
msgout->put_uint32(price_min);
msgout->put_uint32(price_max);
msgout->put_uint8(class_min);
msgout->put_uint8(class_max);
msgout->put_uint8(item_part);
msgout->put_uint8(item_type);
break;
}
case Impulse::POSITION:
{
// khanat-opennel-code/code/ryzom/server/src/gpm_service/client_messages.cpp void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
int32_t x = value["x"];
int32_t y = value["y"];
int32_t z = value["z"];
float heading = value["heading"];
msgout->put_sint32(x);
msgout->put_sint32(y);
msgout->put_sint32(z);
msgout->put_float(heading);
break;
}
case Impulse::DEBUG_PING:
{
// khanat-opennel-code/code/ryzom/server/src/entities_game_service/client_messages.cpp void cbClientPing( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
uint32_t local_time = value["local_time"];
msgout->put_uint32(local_time);
break;
}
case Impulse::NPC_ICON_GET_DESC:
{
// khanat-opennel-code/code/ryzom/server/src/frontend_service/id_impulsions.cpp void cbImpulsionGetNpcIconDesc( CEntityId& sender, CBitMemStream &bms, TGameCycle gamecycle, uint16 serviceId )
// khanat-opennel-code/code/ryzom/client/src/npc_icon.cpp void CNPCIconCache::update()
// Every tick update at most (2 cycles actually, cf. server<->client communication frequency),
// send all pending requests in a single message.
uint8_t i;
Array npc_icon_cache_key = value["npc_icon_cache_key"];
uint8_t npc_icon_cache_key_len = (uint8_t) npc_icon_cache_key.size();
msgout->put_uint8(npc_icon_cache_key_len);
for(i = 0;i < npc_icon_cache_key_len; ++i)
{
uint32_t npc_icon_cache_key_i = npc_icon_cache_key[i];
msgout->put_uint32(npc_icon_cache_key_i);
}
break;
}
default:
{
break;

View file

@ -20,6 +20,13 @@ Build :
*/
// Temporary workaround until c++11 alignas()
#ifdef __GNUC__
#define GCC_ALIGNED_8 __attribute__((aligned(8)))
#else
#define GCC_ALIGNED_8
#endif
#include "modules/bitstream/bitstream.h"
#include "modules/debug/debug.h"
#include "modules/bitstream/convert_utf16.h"
@ -208,11 +215,10 @@ 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 {
union {
uint64_t full;
uint8_t key[8];
};
S v;
} v GCC_ALIGNED_8;
v.full = value;
if(little_endian)
{
@ -337,6 +343,16 @@ void BitStream::put_version(uint32_t value)
}
}
void BitStream::put_float(float value)
{
union {
float f;
uint32_t u;
} data GCC_ALIGNED_8;
data.f = value;
put_uint32(data.u);
}
void BitStream::put_string_utf16(String value)
{
uint16_t * u16_buf = NULL;
@ -543,8 +559,7 @@ uint64_t BitStream::get_uint64()
union S {
uint64_t full;
uint8_t key[8];
};
S v;
} v GCC_ALIGNED_8;
if(little_endian)
{
v.key[3] = this->get_uint8();
@ -586,6 +601,16 @@ uint32_t BitStream::get_version()
return ret;
}
float BitStream::get_float()
{
union {
float f;
uint32_t u;
} data GCC_ALIGNED_8;
data.u = get_uint32();
return data.f;
}
PoolByteArray BitStream::get_array_uint8(uint32_t length)
{
PoolByteArray ret;
@ -619,14 +644,13 @@ String BitStream::get_string()
{
String ret;
uint32_t size = this->get_uint32();
union S {
uint8_t v;
char c;
};
while(size > 0)
{
S x;
union
{
uint8_t v;
char c;
} x GCC_ALIGNED_8;
x.v = this->get_uint8();
CharString cs;
cs += x.c;
@ -659,15 +683,14 @@ String BitStream::get_string_utf8()
uint32_t i;
uint32_t size = this->get_uint32();
char * src = new char[size+1];
union S {
uint8_t v;
char c;
};
src[size] = 0;
for(i=0;i<size;++i)
{
S x;
union {
uint8_t v;
char c;
} x GCC_ALIGNED_8;;
x.v = this->get_uint8();
src[i] = x.c;
}

View file

@ -63,6 +63,7 @@ public:
void put_bitstream(BitStream & value);
void put_bitstream(BitStream * value);
void put_version(uint32_t value);
void put_float(float value);
void put_string_utf16(String value);
String show();
@ -86,6 +87,7 @@ public:
int64_t get_sint64();
uint64_t get_uint64();
uint32_t get_version();
float get_float();
PoolByteArray get_array_uint8(uint32_t length);
BitStream get_bitstream(uint32_t length);
String get_string();