mirror of
https://github.com/redstrate/Kawari.git
synced 2025-06-20 23:17:45 +00:00
Don't panic in the Lobby server if the Login server is unavailable
See #21
This commit is contained in:
parent
3118ef2a5a
commit
97a1836e77
2 changed files with 31 additions and 18 deletions
|
@ -78,16 +78,27 @@ async fn main() {
|
|||
|
||||
let config = get_config();
|
||||
|
||||
let body = reqwest::get(format!(
|
||||
let Ok(login_reply) = reqwest::get(format!(
|
||||
"http://{}/_private/service_accounts?sid={}",
|
||||
config.login.get_socketaddr(),
|
||||
session_id
|
||||
))
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
else {
|
||||
tracing::warn!(
|
||||
"Failed to contact login server, is it running?"
|
||||
);
|
||||
connection.send_error(*sequence, 1012, 13101).await;
|
||||
break;
|
||||
};
|
||||
|
||||
let Ok(body) = login_reply.text().await else {
|
||||
tracing::warn!(
|
||||
"Failed to contact login server, is it running?"
|
||||
);
|
||||
connection.send_error(*sequence, 1012, 13101).await;
|
||||
break;
|
||||
};
|
||||
|
||||
let service_accounts: Option<Vec<ServiceAccount>> =
|
||||
serde_json::from_str(&body).ok();
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use mlua::{FromLua, Lua, LuaSerdeExt, UserData, UserDataFields, UserDataMethods, Value};
|
||||
|
||||
use crate::{
|
||||
common::{ObjectId, ObjectTypeId, Position, timestamp_secs, workdefinitions::RemakeMode, write_quantized_rotation},
|
||||
common::{
|
||||
ObjectId, ObjectTypeId, Position, timestamp_secs, workdefinitions::RemakeMode,
|
||||
write_quantized_rotation,
|
||||
},
|
||||
ipc::zone::{
|
||||
ActionEffect, DamageElement, DamageKind, DamageType, EffectKind, EventScene,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment, Warp,
|
||||
|
@ -157,12 +160,15 @@ impl UserData for LuaPlayer {
|
|||
Ok(())
|
||||
},
|
||||
);
|
||||
methods.add_method_mut("set_position", |lua, this, (position, rotation): (Value, Value)| {
|
||||
let position: Position = lua.from_value(position).unwrap();
|
||||
let rotation: f32 = lua.from_value(rotation).unwrap();
|
||||
this.set_position(position, rotation);
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method_mut(
|
||||
"set_position",
|
||||
|lua, this, (position, rotation): (Value, Value)| {
|
||||
let position: Position = lua.from_value(position).unwrap();
|
||||
let rotation: f32 = lua.from_value(rotation).unwrap();
|
||||
this.set_position(position, rotation);
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
methods.add_method_mut("change_territory", |_, this, zone_id: u16| {
|
||||
this.change_territory(zone_id);
|
||||
Ok(())
|
||||
|
@ -205,12 +211,8 @@ impl UserData for LuaPlayer {
|
|||
fields.add_field_method_get("teleport_query", |_, this| {
|
||||
Ok(this.player_data.teleport_query.clone())
|
||||
});
|
||||
fields.add_field_method_get("rotation", |_, this| {
|
||||
Ok(this.player_data.rotation)
|
||||
});
|
||||
fields.add_field_method_get("position", |_, this| {
|
||||
Ok(this.player_data.position)
|
||||
});
|
||||
fields.add_field_method_get("rotation", |_, this| Ok(this.player_data.rotation));
|
||||
fields.add_field_method_get("position", |_, this| Ok(this.player_data.position));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue