fix instance start
This commit is contained in:
@@ -745,15 +745,17 @@ pub fn instance_join(tx: &mut Transaction, account: &Account, instance_id: Uuid,
|
||||
instance_update(tx, instance)
|
||||
}
|
||||
|
||||
pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid) -> Result<Instance, Error> {
|
||||
pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid) -> Result<RpcMessage, Error> {
|
||||
let mut instance = instance_get(tx, instance_id)?;
|
||||
let player_id = instance.account_player(account.id)?.id;
|
||||
|
||||
if let Some(game) = instance.player_ready(player_id)? {
|
||||
game_write(tx, &game)?;
|
||||
instance_update(tx, instance)?;
|
||||
return Ok(RpcMessage::GameState(game));
|
||||
}
|
||||
|
||||
instance_update(tx, instance)
|
||||
Ok(RpcMessage::InstanceState(instance_update(tx, instance)?))
|
||||
}
|
||||
|
||||
pub fn instance_state(tx: &mut Transaction, _account: &Account, instance_id: Uuid) -> Result<RpcMessage, Error> {
|
||||
|
||||
+3
-1
@@ -122,8 +122,10 @@ pub fn receive(data: Vec<u8>, db: &Db, _client: &mut Ws, begin: Instant, account
|
||||
Ok(RpcMessage::InstanceState(instance_new(&mut tx, account, construct_ids, name, pve, password)?)),
|
||||
RpcRequest::InstanceJoin { instance_id, construct_ids } =>
|
||||
Ok(RpcMessage::InstanceState(instance_join(&mut tx, account, instance_id, construct_ids)?)),
|
||||
|
||||
// these two can return GameState or InstanceState
|
||||
RpcRequest::InstanceReady { instance_id } =>
|
||||
Ok(RpcMessage::InstanceState(instance_ready(&mut tx, account, instance_id)?)),
|
||||
Ok(instance_ready(&mut tx, account, instance_id)?),
|
||||
RpcRequest::InstanceState { instance_id } =>
|
||||
Ok(instance_state(&mut tx, account, instance_id)?),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user