This commit is contained in:
ntr
2019-07-21 20:38:01 +10:00
parent 3088d104da
commit e95d559edd
3 changed files with 17 additions and 10 deletions
+7 -1
View File
@@ -697,7 +697,7 @@ pub fn instances_idle(tx: &mut Transaction) -> Result<Vec<Instance>, Error> {
}
pub fn instance_new(tx: &mut Transaction, account: &Account, construct_ids: Vec<Uuid>, name: String, pve: bool, password: Option<String>) -> Result<Instance, Error> {
pub fn instance_new(tx: &mut Transaction, account: &Account, construct_ids: Vec<Uuid>, name: String, pve: bool, _password: Option<String>) -> Result<Instance, Error> {
let mut instance = match pve {
true => {
let bot = bot_player();
@@ -716,6 +716,8 @@ pub fn instance_new(tx: &mut Transaction, account: &Account, construct_ids: Vec<
instance.add_player(bot)?;
instance.player_ready(bot_id)?;
instance.open = false;
instance
},
false => Instance::new()
@@ -738,6 +740,10 @@ pub fn instance_join(tx: &mut Transaction, account: &Account, instance_id: Uuid,
return Err(format_err!("incorrect player size. ({:})", 3));
}
if instance.players.len() >= instance.max_players {
return Err(err_msg("game is full"));
}
let player = player_create(tx, Player::new(account.id, &account.name, constructs), instance.id, account)?;
instance.add_player(player)?;