int Expedition_Occupy_Castle_Data::serialize(Block_Buffer &w) const {
	w.write_int64(role_id);
	w.write_int64(gang_id);
	w.write_int64(server_uuid);
	w.write_string(role_name);
	w.write_string(gang_name);
	w.write_string(server_name);
	w.write_int32(level);
	w.write_int32(force);
	w.write_int16(nums);
	w.write_int16(get_nums);
	return 0;
}
Exemplo n.º 2
0
void Map_Team::serialize(Block_Buffer &buf) {
	buf.write_int8(type_);
	buf.write_string(words_);
	buf.write_int32(scene_id_);
	buf.write_int8(degree_);
	buf.write_uint32(team_index_);
	buf.write_int64(team_id_);
	buf.write_int64(team_id_for_scene_);
	buf.write_int64(leader_role_id_);
	uint16_t len = 0;
	len = team_member_set_.size();
	buf.write_uint16(len);
	for (Role_Hash_Set::iterator it = team_member_set_.begin(); it != team_member_set_.end(); ++it) {
		buf.write_int64(*it);
	}
	len = offline_teamer_map_.size();
	buf.write_uint16(len);
	for (RoleID_OnlineMap_TeamerInfo_Map::iterator it = offline_teamer_map_.begin(); it != offline_teamer_map_.end(); ++it) {
		buf.write_int64(it->first);
	}
	buf.write_int8(in_battle_);
	len = lineup_.size();
	buf.write_uint16(len);
	for (Int_Role_Id_Vec::iterator it = lineup_.begin(); it != lineup_.end(); ++it) {
		it->serialize(buf);
	}
	buf.write_int32(enter_level_);
	buf.write_int16(fail_times_);
	buf.write_int16(match_fail_);
	buf.write_bool(is_not_first_team_fb_);
}
Exemplo n.º 3
0
void Msg_Struct::build_buffer_arg(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) {
    if(field_info.field_type == "int8") {
        int8_t val = 0;
        if (value->IsInt32()) {
            val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_int8(val);
    }
    else if(field_info.field_type == "int16") {
        int16_t val = 0;
        if (value->IsInt32()) {
            val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_int16(val);
    }
    else if(field_info.field_type == "int32") {
        int32_t val = 0;
        if (value->IsInt32()) {
            val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_int32(val);
    }
    else if(field_info.field_type == "int64") {
        int64_t val = 0;
        if (value->IsNumber()) {
            val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_int64(val);
    }
    else if(field_info.field_type == "double") {
        double val = 0;
        if (value->IsNumber()) {
            val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_double(val);
    }
    else if(field_info.field_type == "bool") {
        bool val = 0;
        if (value->IsBoolean()) {
            val = value->BooleanValue(isolate->GetCurrentContext()).FromJust();
        }
        buffer.write_bool(val);
    }
    else if(field_info.field_type == "string") {
        std::string val = "";
        if (value->IsString()) {
            String::Utf8Value str(value->ToString(isolate->GetCurrentContext()).ToLocalChecked());
            std::stringstream stream;
            stream << ToCString(str);
            val = stream.str();
        }
        buffer.write_string(val);
    }
    else {
        LOG_ERROR("Can not find the field_type:%s, struct_name:%s", field_info.field_type.c_str(), struct_name().c_str());
    }
}
Exemplo n.º 4
0
int Map_Team::sync_info_logic(void) {
	MSG_20100304 inner_msg;
	Block_Buffer buf;
	Time_Value now;
	now = Time_Value::gettimeofday();
	buf.make_message(inner_msg.msg_id);
	buf.write_int64(team_id_);
	buf.write_int16(fail_times_);
	buf.write_int16(match_fail_);
	now.serialize(buf);
	buf.finish_message();
	this->info_all_online_player(inner_msg.msg_id, &buf);
	return 0;
}
int Stronghold_Info::serialize(Block_Buffer &w) const {
	occupier.serialize(w);
//	attacker.serialize(w);
//	int8_t fight_status; // 0(和平状态) 1(攻占状态)
//	int8_t belong_status; // 0.未被初始化状态, 1.中立, 2.占领

//	 ; //防守队列
	uint16_t len = 0;
	for (Soldier_Map::const_iterator it = defend_map.begin();
			it != defend_map.end(); ++it) {
		if (it->second->type == EST_PLAYER) {
			continue;
		}
		++len;
	}
	w.write_uint16(len);
	for (Soldier_Map::const_iterator it = defend_map.begin();
			it != defend_map.end(); ++it) {
		if (it->second->type == EST_PLAYER) {
			continue;
		}
		w.write_int64(it->second->role_id);
		w.write_int16(it->second->nums);
	}
//	Soldier_Map attack_map; //攻占队列
//	Soldier_List defend_list;
//	Soldier_List attack_list;
	//	uint32_t npc_soldier_aid;//npc怪的id自增长

//	Soldier_Map defending_map;
//	Soldier_Map attacking_map;
//	Time_Value battle_finish_time;

//	Soldier_Map looking_defend_map;
//	GangID_SoldierMap_Map looking_attack_map;
//	Soldier_List looking_defend_list;
//	GangID_SoldierList_Map looking_attack_list;
	return 0;
}