Пример #1
0
void lobby_host_loop() {
	struct proto_join_packet packet;
	static int tick = 0;
	DARNIT_KEYS keys;
	
	keys = d_keys_get();
	d_keys_set(keys);
	
	d_render_tile_blit(config.menu_background, 0, 0, 0);
	
	if(!tick) {
		packet.type = PROTO_TYPE_JOIN;
		packet.player_id = -1;
		strcpy(packet.player_name, config.player_name);
		network_send(config.server.addr, &packet, sizeof(struct proto_join_packet));
		update_player_list(lobby_join.list_players, config.player.player);
	}
	server_loop();
	
	if(keys.select) {
		game_state(GAME_STATE_LOBBY);
	}
	if(keys.start) {
		game_state(GAME_STATE_GAME);
	}
	
	d_text_surface_draw(lobby_join.list_players);
	d_text_surface_draw(lobby_host.start_game);
	tick++;
	tick %= 3;
}
Пример #2
0
static GGZHookReturn ggz_info_player(GGZRoomEvent id,
				     const void *event_data,
				     const void *user_data)
{
	update_player_list();
	return GGZ_HOOK_OK;
}
Пример #3
0
void mp_staging::network_handler(window& window)
{
	// First, send off any changes if they've been accumulated
	if(state_changed_) {
		connect_engine_.update_and_send_diff();
	}

	// Next, check for any incoming changes
	config data;
	if(!state_changed_ && (!wesnothd_connection_ || !wesnothd_connection_->receive_data(data))) {
		return;
	}

	// Update chat
	find_widget<chatbox>(&window, "chat", false).process_network_data(data);

	// TODO: why is this needed...
	const bool was_able_to_start = connect_engine_.can_start_game();

	bool quit_signal_recieved;
	std::tie(quit_signal_recieved, std::ignore) = connect_engine_.process_network_data(data);

	if(quit_signal_recieved) {
		window.set_retval(window::CANCEL);
	}

	// Update side leader displays
	// This is basically only needed when a new player joins and selects their faction
	for(auto& tree_entry : side_tree_map_) {
		ng::side_engine_ptr side = tree_entry.first;

		grid& row_grid = tree_entry.second->get_grid();

		update_leader_display(side, row_grid);

		std::vector<config> controller_names;
		for(const auto& controller : side->controller_options()) {
			controller_names.push_back(config_of("label", controller.second));
		}

		menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);

		controller_selection.set_values(controller_names, side->current_controller_index());
		controller_selection.set_active(controller_names.size() > 1);
	}

	// Update player list
	// TODO: optimally, it wouldn't regenerate the entire list every single refresh cycle
	update_player_list(window);

	// Update status label and buttons
	update_status_label_and_buttons(window);

	if(!was_able_to_start && connect_engine_.can_start_game()) {
		mp_ui_alerts::ready_for_start();
	}

	state_changed_ = false;
}
Пример #4
0
static GGZHookReturn ggz_list_players(GGZRoomEvent id,
				      const void *event_data,
				      const void *user_data)
{
	const GGZRoom *room = event_data;

	update_player_list();
	client_update_one_room(room);
	return GGZ_HOOK_OK;
}
Пример #5
0
static GGZHookReturn ggz_room_leave(GGZRoomEvent id,
				    const void *event_data,
				    const void *user_data)
{
	const GGZRoomChangeEventData *data = event_data;

	client_update_one_room(data->to_room);
	client_update_one_room(data->from_room);
	update_player_list();
	chat_part(data->player_name, data->rooms_known, data->to_room);

	return GGZ_HOOK_OK;
}