1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-21 07:27:45 +00:00

Don't panic in the Lobby server if the Login server is unavailable

See #21
This commit is contained in:
Joshua Goins 2025-06-18 19:38:00 -04:00
parent 3118ef2a5a
commit 97a1836e77
2 changed files with 31 additions and 18 deletions

View file

@ -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();

View file

@ -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)| {
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));
}
}