|
@ -7,6 +7,7 @@ use crate::ship::location::{ClientLocation, LobbyId, RoomLobby, ClientLocationEr |
|
|
//use crate::ship::items::;
|
|
|
//use crate::ship::items::;
|
|
|
use crate::ship::packet;
|
|
|
use crate::ship::packet;
|
|
|
use crate::ship::items::ItemManager;
|
|
|
use crate::ship::items::ItemManager;
|
|
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
|
|
|
|
|
// this function needs a better home
|
|
|
// this function needs a better home
|
|
|
pub fn block_selected(id: ClientId,
|
|
|
pub fn block_selected(id: ClientId,
|
|
@ -59,13 +60,14 @@ pub fn send_player_to_lobby(id: ClientId, |
|
|
.map(|c| (c.client, SendShipPacket::AddToLobby(addto.clone())))).collect())
|
|
|
.map(|c| (c.client, SendShipPacket::AddToLobby(addto.clone())))).collect())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn change_lobby(id: ClientId,
|
|
|
|
|
|
|
|
|
pub fn change_lobby<EG: EntityGateway>(id: ClientId,
|
|
|
requested_lobby: u32,
|
|
|
requested_lobby: u32,
|
|
|
client_location: &mut ClientLocation,
|
|
|
client_location: &mut ClientLocation,
|
|
|
clients: &Clients,
|
|
|
clients: &Clients,
|
|
|
item_manager: &mut ItemManager,
|
|
|
item_manager: &mut ItemManager,
|
|
|
level_table: &CharacterLevelTable,
|
|
|
level_table: &CharacterLevelTable,
|
|
|
ship_rooms: &mut Rooms)
|
|
|
|
|
|
|
|
|
ship_rooms: &mut Rooms,
|
|
|
|
|
|
entity_gateway: &mut EG)
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, ShipError> {
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, ShipError> {
|
|
|
let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let prev_area = client_location.get_area(id).map_err(|err| -> ClientLocationError {err.into()})?;
|
|
|
let prev_area = client_location.get_area(id).map_err(|err| -> ClientLocationError {err.into()})?;
|
|
@ -96,6 +98,7 @@ pub fn change_lobby(id: ClientId, |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
item_manager.load_character(entity_gateway, &client.character);
|
|
|
let join_lobby = packet::builder::lobby::join_lobby(id, lobby, client_location, clients, item_manager, level_table)?;
|
|
|
let join_lobby = packet::builder::lobby::join_lobby(id, lobby, client_location, clients, item_manager, level_table)?;
|
|
|
let addto = packet::builder::lobby::add_to_lobby(id, lobby, client_location, clients, item_manager, level_table)?;
|
|
|
let addto = packet::builder::lobby::add_to_lobby(id, lobby, client_location, clients, item_manager, level_table)?;
|
|
|
let neighbors = client_location.get_client_neighbors(id).unwrap();
|
|
|
let neighbors = client_location.get_client_neighbors(id).unwrap();
|
|
|