예제 #1
0
void pop_game_buffer(const FunctionCallbackInfo<Value>& args) {
	Block_Buffer *buf = GAME_MANAGER->pop_block_buffer();
	if (buf) {
		buf->reset();
		args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf));
	} else {
		//设置对象为空
		args.GetReturnValue().SetNull();
	}
}
예제 #2
0
void get_game_player_save_data_buffer(const FunctionCallbackInfo<Value>& args) {
	Game_Player *player = unwrap_game_player(args.Holder());
	if (!player) {
		args.GetReturnValue().SetNull();
		return;
	}

	Block_Buffer *buf = player->save_player_data_buffer();
	if (buf) {
		buf->reset();
		args.GetReturnValue().Set(wrap_buffer(args.GetIsolate(), buf));
	} else {
		//设置对象为空
		args.GetReturnValue().SetNull();
	}
}
예제 #3
0
int Map_Team::team_fb_create_player_monster(Scene_Player &player) {
	if (!player.is_in_battle()) {
		MSG_USER("has in battle");
		return -1;
	}

	if (player.dead_status()) {
		MSG_USER("has die");
		return -1;
	}
	Battle_Scene *scene = player.battle_scene();
	if(!scene){
		return -1;
	}

	int pos = -1;
	for (Battle_Scene::Debug_Mover_Map::const_iterator it = scene->pos_debug_map().begin();
			it != scene->pos_debug_map().end(); ++it) {
		if (it->second == player.role_id()) {
			pos = it->first.pos;
			break;
		}
	}
	if (pos == -1) {
		return -1;
	}
	Int_Hash_Set idx_set;
	{
		for (Battle_Scene::Debug_Mover_Map::const_iterator it = scene->pos_debug_map().begin();
				it != scene->pos_debug_map().end(); ++it) {
			if (it->first.pos != pos) continue;
			idx_set.insert(it->first.idx);
		}
		int ret = ensure_battle_pos_unique(idx_set);
		if (0 != ret) {
			return ret;
		}
	}
	if ((pos != 0 && pos != 1) || idx_set.size() >= 3){
		return -1;
	}

	Block_Buffer buf;
	const Team_Robot_Config_Map crc = CONFIG_CACHE_TEAM->team_robot_cfg();
	int y = Position_Key::LINE_ONE_BEHIND;
	int i = 0;
	for (Team_Robot_Config_Map::const_iterator it_crc = crc.begin(); it_crc != crc.end(); ++it_crc) {
		buf.reset();
		// 机器人信息
		create_team_player_detail(it_crc->second, buf);

		get_empty_pos(idx_set, y);
		y = get_other_idx(y);
		if (0 == y) {
			continue;
		}
		idx_set.insert(y);

		NPC_Addition_Info add_info;
		add_info.birth_coord.x = pos;
		add_info.birth_coord.y = y;

		add_info.ex_val1 = it_crc->second.career;
		add_info.ex_val2 = 1; // gender
		add_info.name = it_crc->second.name;
		int monster_type = 63800108;
		Player_Monster* player_monster = NPC_MANAGER->create_player_monster(monster_type, NULL, add_info, scene, buf);
		if(player_monster == NULL){
			return -1;
		}
		Int_Vec avatar_vec;
		if (i == 0) {
			avatar_vec.push_back(10731102);
			avatar_vec.push_back(10931102);
			avatar_vec.push_back(10831102);
		} else {
			avatar_vec.push_back(10711102);
			avatar_vec.push_back(10911102);
			avatar_vec.push_back(10811102);
		}
		player_monster->set_player_monster_avatar(avatar_vec);
		player_monster->set_clear_label(false);
		player_monster->restore_hp(player_monster->blood_max(), true);

		// 战斗英雄信息
		buf.reset();
		create_team_hero_detail(it_crc->second, buf);
		player_monster->hero_battle_birth(buf, scene);
		player_monster->battle_enter_appaer(scene);
		y += 2;
		++i;
	}

//	player.restore_hp(player.blood_max(), true);
//	player.set_battle_position(0, Position_Key::LINE_TWO_FRONT);
//	player.enter_battle_scene(scene);
	return 0;
}
예제 #4
0
int Gate_Manager::process_list(void) {
	int32_t cid = 0;
	Block_Buffer *buf = 0;

	while (1) {
		bool all_empty = true;

		/// 掉线玩家列表
		if (! drop_cid_list_.empty()) {
			all_empty = false;
			cid = drop_cid_list_.pop_front();
			process_drop_cid(cid);
		}
		/// client-->gate  消息队列
		if ((buf = gate_client_data_list_.pop_front()) != 0) {
			all_empty = false;
			if (buf->is_legal()) {
				cid = buf->peek_int32();
				GATE_CLIENT_MESSAGER->process_block(*buf);
			} else {
				LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx());
				buf->reset();
			}
			GATE_CLIENT_SERVER->push_block(cid, buf);
		}
		/// 游戏服内部循环消息队列
		if (! self_loop_block_list_.empty()) {
			all_empty = false;
			buf = self_loop_block_list_.front();
			self_loop_block_list_.pop_front();
			GATE_INNER_MESSAGER->process_self_loop_block(*buf);
			block_pool_.push(buf);
		}
		/// login-->gate  消息队列
		if ((buf = gate_login_data_list_.pop_front()) != 0) {
			all_empty = false;
			if (buf->is_legal()) {
				cid = buf->peek_int32();
				GATE_INNER_MESSAGER->process_login_block(*buf);
			} else {
				LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx());
				buf->reset();
			}
			GATE_LOGIN_CONNECTOR->push_block(cid, buf);
		}
		/// game-->gate  消息队列
		if ((buf = gate_game_data_list_.pop_front()) != 0) {
			all_empty = false;
			if (buf->is_legal()) {
				cid = buf->peek_int32();
				GATE_INNER_MESSAGER->process_game_block(*buf);
			} else {
				LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx());
				buf->reset();
			}
			GATE_GAME_CONNECTOR->push_block(cid, buf);
		}
		/// master-->gate  消息队列
		if ((buf = gate_master_data_list_.pop_front()) != 0) {
			all_empty = false;
			if (buf->is_legal()) {
				cid = buf->peek_int32();
				GATE_INNER_MESSAGER->process_master_block(*buf);
			} else {
				LOG_ERROR("buf.read_index = %ld, buf.write_index = %ld", buf->get_read_idx(), buf->get_write_idx());
				buf->reset();
			}
			GATE_MASTER_CONNECTOR->push_block(cid, buf);
		}

		if (all_empty)
			Time_Value::sleep(Time_Value(0,100));
	}
	return 0;
}