当前位置: 首页>>代码示例>>C++>>正文


C++ Block_Buffer类代码示例

本文整理汇总了C++中Block_Buffer的典型用法代码示例。如果您正苦于以下问题:C++ Block_Buffer类的具体用法?C++ Block_Buffer怎么用?C++ Block_Buffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Block_Buffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: data_channle

int Answer_Manager::data_channle(Block_Buffer& buf) {
	uint8_t type = 0;
	buf.read_uint8(type);
	switch(type) {
		case ANSWER_DATA_CHANNLE_TYPE_SL_GET_RANK_REWARD: {
			uint16_t size = 0;
			buf.read_uint16(size);
			for(uint16_t i = 0; i < size; ++i) {
				uint16_t nsize = 0;
				buf.read_uint16(nsize);
				for(uint16_t j = 0; j < nsize; ++j) {
					role_id_t role_id = 0;
					buf.read_int64(role_id);
					reward_to_player(role_id, i+1);
				} //end j
			}//end i
			break;
		}// end case
		case ANSWER_DATA_CHANNLE_TYPE_SL_SAVE_DATA: {
			save_data(buf);
			break;
		}
	}
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:25,代码来源:Answer_Manager.cpp

示例2: if

int Scene_Server_Request::process_20100403(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) {
	JUDGE_PLAYER_NULL(player, role_id);
	int8_t type = 0;
	buf.read_int8(type);
	uint16_t vec_size = 0;
	if (buf.read_uint16(vec_size)) {
		return -1;
	}

	Int_Double_Map force_map;
	player->get_all_pre_force(force_map);
	int old_val = player->fighter_detail().force;

	Skill_Info skill_info;
	for (uint16_t i = 0; i < vec_size; ++i) {
		skill_info.reset();
		skill_info.deserialize(buf);
		if (type == NPT_ADD) {
			player->add_skill_extra(skill_info.skill_id, skill_info.skill_lv);
		} else if (type == NPT_REMOVE) {
			player->remove_skill_extra(skill_info.skill_id, skill_info.skill_lv);
		}
	}

	if (vec_size > 0) {
		player->sync_force_to_client();
	}

	int new_val = player->fighter_detail().force;
	player->print_all_part_force(100, new_val-old_val, force_map);

	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:33,代码来源:Scene_Server_Request.cpp

示例3: process_timer_msg

int Message_Unit::process_timer_msg(uint32_t msg_id, Block_Buffer &buf, Time_Value &now) {
	if (data_pro_tick_ < Time_Value::gettimeofday()) {
		server_status();
	}


	switch (msg_id) {
	case SERVER_INNER_CLIENT_CLOSE: {
		int cid = 0, close_type = 0;
		int64_t value = 0;
		buf.read_int32(cid);
		buf.read_int32(close_type);
		buf.read_int64(value);
		monitor()->close_link_by_cid(cid, Link_Close(close_type, value));

		break;
	}
	default : {
		return CALL_CONTINUE;
		break;
	}
	}

	return CALL_RETURN;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:25,代码来源:Message_Unit.cpp

示例4: serialize

int Stronghold::serialize(Block_Buffer &w) const {
	w.write_uint32(point_id);
	w.write_int8((int8_t)type);

	info.serialize(w);
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Expedition_Scene_Struct.cpp

示例5:

int Scene_Server_Request::process_20300303(int cid, role_id_t role_id, Scene_Player *player, Block_Buffer &buf) {
	//MSG_20300303 msg;
	//JUDGE_ERROR_RETURN(msg.deserialize(buf));
	int act_icon_id = 0;
	role_id_t gang_id = 0;
	buf.read_int32(act_icon_id);
	buf.read_int64(gang_id);
	switch(act_icon_id){
		case 16:{
			WORLD_BOSS_MANAGER->inner_act_end(gang_id, buf);
			break;
		}
		case 19:{
			GANG_BOSS_MANAGER->inner_act_end(gang_id, buf);
			break;
		}
		case 20:{
			VALENTINE_MONSTER_MANAGER->inner_act_end(gang_id, buf);
			break;
		}
		case 22:{
			HONOR_ARENA_MANAGER->inner_act_end(gang_id, buf);
			break;
		}
		default:{
			break;
		}
	}
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:30,代码来源:Scene_Server_Request.cpp

示例6: say

void Chat::say(Time_Value &now, Location &location) {
	if(now >= (last_say_time + say_interval)) {
		last_say_time = now;
		Robot_Player *player = (Robot_Player*)this;
		MSG_10300000 msg;
		msg.chat_type = 1;
		Chat_Content cc;
		//人物信息
		cc.reset();
		cc.type = 2;
		cc.role_Info.role_name = player->base_detail().role_name;
		cc.role_Info.career = player->base_detail().career;
		cc.role_Info.gender = player->base_detail().gender;
		cc.role_Info.role_id = player->base_detail().role_id;
		msg.content.push_back(cc);
		//聊天内容
		cc.reset();
		cc.type = 0;
		std::ostringstream text;
		text << "各位你好!我目前的场景是:" << location.scene_id << ",坐标(x=" << location.coord.x << ",y=" << location.coord.y << "), 过来找我吧~{a" << ((rand()%39)+1) << "}";
		cc.text = text.str();
		msg.content.push_back(cc);
		//send
		Block_Buffer buf;
		buf.make_client_message(10300000, player->msg_detail().msg_serial++, Time_Value::gettimeofday().sec());
		msg.serialize(buf);
		buf.finish_message();
		player->send_to_server(buf);
	}
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:30,代码来源:Chat.cpp

示例7: start_monitor_timer

int Record_Monitor::start_monitor_timer(void) {
	Block_Buffer buf;
	buf.make_message(TIMER_GLOBAL_MONITOR_SELF);
	buf.finish_message();
	GLOBAL_TIMER->register_loop_handler(buf, Time_Value(Time_Value::ONE_MINUTE_IN_SECS, 0), unit_);
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Record_Monitor.cpp

示例8: deserialize

int Smelter_Detail::deserialize(Block_Buffer & r) {
	if(r.read_int8(smelter_idx) ||
			r.read_int8(is_open)) {
		return -1;
	}
 	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Rune_Stone_Struct.cpp

示例9: self_close_process

int Gate_Manager::self_close_process(void) {
	server_status_ = STATUS_CLOSING;

	Block_Buffer buf;
	buf.make_inner_message(ACTIVE_DISCONNECT, ERROR_DISCONNECT_SELF);
	buf.finish_message();
	for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) {
		GATE_MANAGER->send_to_client(iter->first, buf);
	}
	//等待服务器通知客户端完毕
	sleep(2);

	//关闭客户端连接
	for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) {
		iter->second->link_close();
	}

	int i = 0;
	while (++i < 60) {
		sleep(1);
		LOG_DEBUG("gate server has user:%d", player_cid_map_.size());
		if (player_cid_map_.size() == 0)
			break;
	}

	return 0;
}
开发者ID:firehot,项目名称:server,代码行数:27,代码来源:Gate_Manager.cpp

示例10: deserialize

int Artifact_Detail::deserialize(Block_Buffer & r) {
	if(r.read_int32(artifact_id) ||
			r.read_int32(artifact_lvl)) {
		return -1;
	}
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Logic_Heroer_Struct.cpp

示例11: save_data

void Answer_Manager::save_data(Block_Buffer& buf_) {
	Block_Buffer buf;
	buf.make_message(MONGO_SAVE_ANSWER_INFO);
	buf.copy(&buf_);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Answer_Manager.cpp

示例12: build_buffer_map

void Msg_Struct::build_buffer_map(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) {
    if (!value->IsMap()) {
        LOG_ERROR("field_name:%s is not map, struct_name:%s", field_info.field_name.c_str(), struct_name().c_str());
        buffer.write_uint16(0);
        return;
    }

    Local<Map> map = Local<Map>::Cast(value);
    int16_t len = map->Size();
    buffer.write_uint16(len);
    Local<Array> array = map->AsArray();
    //index N is the Nth key and index N + 1 is the Nth value.
    if(is_struct(field_info.field_type)) {
        for (int i = 0; i < len * 2; i = i + 2) {
            Local<Value> element = array->Get(isolate->GetCurrentContext(), i + 1).ToLocalChecked();
            build_buffer_struct(field_info, buffer, isolate, element);
        }
    }
    else {
        Field_Info key_info;
        key_info.field_label = "args";
        key_info.field_type = field_info.key_type;
        key_info.field_name = field_info.key_name;
        for (int i = 0; i < len * 2; i = i + 2) {
            Local<Value> key = array->Get(isolate->GetCurrentContext(), i).ToLocalChecked();
            Local<Value> element = array->Get(isolate->GetCurrentContext(), i + 1).ToLocalChecked();
            build_buffer_struct(key_info, buffer, isolate, key);
            build_buffer_struct(field_info, buffer, isolate, element);
        }
    }
}
开发者ID:jice1001,项目名称:server,代码行数:31,代码来源:Msg_Struct.cpp

示例13: deserialize

int Anci_Artifact_Detail::deserialize(Block_Buffer &buffer) {
	buffer.read_int64(role_id);
//	buffer.read_int64(perfectPoint);
	uint16_t len = 0;
	buffer.read_uint16(len);
	aa_info_map.clear();
	Anci_Artifact_Cond_Info info;
	for (uint16_t i = 0; i < len; ++i) {
		info.reset();
		buffer.read_int32(info.id);
		buffer.read_int8(info.state_count);
		buffer.read_int32(info.data);
		aa_info_map.insert(std::make_pair(info.id, info));
	}
	buffer.read_uint16(len);
	complete_ids.clear();
	int32_t complete_id = 0;
	for (uint16_t i = 0; i < len; ++i) {
		buffer.read_int32(complete_id);
		complete_ids.insert(complete_id);
	}
	aa_unban_info.clear();
	Anci_Artifact_Unban_Info aa_ui;
	for (uint16_t i = 0; i < len; ++i) {
		aa_ui.reset();
		buffer.read_int32(aa_ui.id);
		buffer.read_int8(aa_ui.state);
		buffer.read_int8(aa_ui.box_state);
		aa_unban_info.insert(std::make_pair(aa_ui.id, aa_ui));
	}
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:32,代码来源:Anci_Artifact_Struct.cpp

示例14: process_client_buffer

int Message_Unit::process_client_buffer(Block_Buffer &buf) {
	msg_tick_ = Time_Value::gettimeofday();

	int cid = 0;
	uint32_t len = 0;
	uint32_t msg_id = 0;
	uint32_t serial_cipher = 0;
	uint32_t msg_time_cipher = 0;

	if (buf.read_int32(cid) ||
		buf.read_uint32(len) ||
		buf.read_uint32(msg_id) ||
		buf.read_uint32(serial_cipher) ||
		buf.read_uint32(msg_time_cipher)) {

		LOG_USER("deserialize error, cid:%d len:%d msg_id:%d", cid, len, msg_id);
		monitor()->close_client_by_cid(cid, Time_Value(2), 10000101);
		return -1;
	}

	process_client_msg(msg_id, cid, buf, serial_cipher, msg_time_cipher);

	count_process_time(msg_id);

	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:26,代码来源:Message_Unit.cpp

示例15: deserialize

int Expedition_Force::deserialize(Block_Buffer &r) {
	r.read_int64(server_uuid);
	r.read_string(server_name);
	r.read_int64(gang_id);
	r.read_string(gang_name);
	return 0;
}
开发者ID:tidaybreak,项目名称:game-server,代码行数:7,代码来源:Expedition_Scene_Struct.cpp


注:本文中的Block_Buffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。