int Expedition_Occupy_Castle_Data::deserialize(Block_Buffer &r) {
	r.read_int64(role_id);
	r.read_int64(gang_id);
	r.read_int64(server_uuid);
	r.read_string(role_name);
	r.read_string(gang_name);
	r.read_string(server_name);
	r.read_int32(level);
	r.read_int32(force);
	r.read_int16(nums);
	r.read_int16(get_nums);
	return 0;
}
int Scene_Server_Request::process_20300100(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) {
	Monitor_Unique_ID logic_muid;
	role_id_t player_role_id = 0;
	int level = 0;
	int force = 0;
	role_id_t gang_id = 0;
	int8_t remain_income_num = 0;
	int16_t income_rate = 0;
	int total_merit = 0;
	int remain_time = 0;
	int act_time = 0;
	std::string server_name;
	logic_muid.deserialize(buf);
	buf.read_int64(player_role_id);
	buf.read_int32(level);
	buf.read_int32(force);
	buf.read_int64(gang_id);
	buf.read_int8(remain_income_num);
	buf.read_int16(income_rate);
	buf.read_int32(total_merit);
	buf.read_int32(remain_time);
	buf.read_int32(act_time);
	buf.read_string(server_name);
	SCENE_WAR_MANAGER->req_enter_war_scene(logic_muid, player_role_id, level,
			force, gang_id, remain_income_num, income_rate, total_merit, remain_time, act_time, server_name);
	return 0;
}
Ejemplo n.º 3
0
void Map_Team::deserialize(Block_Buffer &buf) {
	buf.read_int8(type_);
	buf.read_string(words_);
	buf.read_int32(scene_id_);
	buf.read_int8(degree_);
	buf.read_uint32(team_index_);
	buf.read_int64(team_id_);
	buf.read_int64(team_id_for_scene_);
	buf.read_int64(leader_role_id_);
	uint16_t len = 0;
	buf.read_uint16(len);
	int64_t role_id = 0;
	for (uint16_t i = 0; i < len; ++i) {
		buf.read_int64(role_id);
		team_member_set_.insert(role_id);
	}
	buf.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		buf.read_int64(role_id);
		offline_teamer_map_.insert(std::make_pair(role_id, Online_Teamer_Info()));
	}
	buf.read_int8(in_battle_);
	buf.read_uint16(len);
	Int_Role_Id int_role_id;
	Int_Role_Id_Vec lineup;
	for (uint16_t i = 0; i < len; ++i) {
		int_role_id.deserialize(buf);
		lineup.push_back(int_role_id);
	}
	this->lineup_replace(lineup);
	buf.read_int32(enter_level_);
	buf.read_int16(fail_times_);
	buf.read_int16(match_fail_);
	buf.read_bool(is_not_first_team_fb_);
}
Ejemplo n.º 4
0
int Login_Client_Messager::process_block(Block_Buffer &buf) {
	LOGIN_MANAGER->add_recv_bytes(buf.readable_bytes());

	int32_t cid = 0;
	int16_t len = 0;
	int32_t msg_id = 0;
	int32_t status = 0;
	int32_t serial_cipher = 0;
	int32_t msg_time_cipher = 0;
	buf.read_int32(cid);
	buf.read_int16(len);
	buf.read_int32(msg_id);
	buf.read_int32(status);
	buf.read_int32(serial_cipher);
	buf.read_int32(msg_time_cipher);

	LOGIN_MANAGER->add_msg_count(msg_id);
	switch (msg_id) {
	case REQ_CONNECT_LOGIN:{
			connect_login(cid, msg_id, buf);
			break;
	}
	default:	{
		LOG_ERROR("error msg_id:%d", msg_id);
		break;
	}
	}

	return 0;
}
Ejemplo n.º 5
0
int Gate_Client_Messager::process_block(Block_Buffer &buf) {
	GATE_MANAGER->add_recv_bytes(buf.readable_bytes());

	int32_t cid = 0;
	int16_t len = 0;
	int32_t msg_id = 0;
	int32_t status = 0;
	int32_t serial_cipher = 0;
	int32_t msg_time_cipher = 0;
	buf.read_int32(cid);
	buf.read_int16(len);
	buf.read_int32(msg_id);
	buf.read_int32(status);
	buf.read_int32(serial_cipher);
	buf.read_int32(msg_time_cipher);

	GATE_MANAGER->add_msg_count(msg_id);
	if (msg_id >= CLIENT_GATE_MESSAGE_START && msg_id <= CLIENT_GATE_MESSAGE_END) {
		return process_gate_block(cid, msg_id, buf);
	}

	Gate_Player *player = dynamic_cast<Gate_Player*>(GATE_MANAGER->find_cid_player(cid));
	if (!player) {
		LOG_ERROR("cannot find player_cid = %d msg_id = %d ", cid, msg_id);
		return GATE_MANAGER->close_client(0, cid, ERROR_NOT_LOGIN);
	}

	 /// 校验包, 用于防截包/自组包/重复发包
	if (GATE_MANAGER->verify_pack()) {
		int result = player->verify_msg_info(serial_cipher, msg_time_cipher);
		if (result != 0) {
			LOG_ERROR("msg verify error, player_cid:%d, len:%d, serial_cipher:%d, msg_time_cipher:%d, msg_id:%d, status:%d", cid, len, serial_cipher, msg_time_cipher, msg_id, status);
			return GATE_MANAGER->close_client(0, cid, result);
		}
	}

	Block_Buffer player_buf;
	player_buf.reset();
	player_buf.make_player_message(msg_id, status, cid);
	player_buf.copy(&buf);
	player_buf.finish_message();

	if (msg_id >= CLIENT_MASTER_MESSAGE_START && msg_id <= CLIENT_MASTER_MESSAGE_END) {
		GATE_MANAGER->send_to_master(player_buf);
	} else if (msg_id >= CLIENT_GAME_MESSAGE_START && msg_id <= CLIENT_GAME_MESSAGE_END) {
		GATE_MANAGER->send_to_game(player->game_cid(), player_buf);
	}
	else {
		LOG_ERROR("msg_id:%d error", msg_id);
	}

	return 0;
}
Ejemplo n.º 6
0
v8::Local<v8::Value> Msg_Struct::build_object_arg(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate) {
    EscapableHandleScope handle_scope(isolate);

    Local<Value> value;
    if(field_info.field_type == "int8") {
        int8_t val = 0;
        buffer.read_int8(val);
        value = Int32::New(isolate, val);
    }
    else if(field_info.field_type == "int16") {
        int16_t val = 0;
        buffer.read_int16(val);
        value = Int32::New(isolate, val);
    }
    else if(field_info.field_type == "int32") {
        int32_t val = 0;
        buffer.read_int32(val);
        value = Int32::New(isolate, val);
    }
    else if(field_info.field_type == "int64") {
        int64_t val = 0;
        buffer.read_int64(val);
        value = Number::New(isolate, val);
    }
    else if(field_info.field_type == "double") {
        double val = 0;
        buffer.read_double(val);
        value = Number::New(isolate, val);
    }
    else if(field_info.field_type == "bool") {
        bool val = false;
        buffer.read_bool(val);
        value = Boolean::New(isolate, val);
    }
    else if(field_info.field_type == "string") {
        std::string val = "";
        buffer.read_string(val);
        value = String::NewFromUtf8(isolate, val.c_str(), NewStringType::kNormal).ToLocalChecked();
    }
    else {
        LOG_ERROR("Can not find the field_type:%s, struct_name:%s", field_info.field_type.c_str(), struct_name().c_str());
        return handle_scope.Escape(Local<Value>());
    }
    return handle_scope.Escape(value);
}