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:
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 config = get_config();
|
||||||
|
|
||||||
let body = reqwest::get(format!(
|
let Ok(login_reply) = reqwest::get(format!(
|
||||||
"http://{}/_private/service_accounts?sid={}",
|
"http://{}/_private/service_accounts?sid={}",
|
||||||
config.login.get_socketaddr(),
|
config.login.get_socketaddr(),
|
||||||
session_id
|
session_id
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
else {
|
||||||
.text()
|
tracing::warn!(
|
||||||
.await
|
"Failed to contact login server, is it running?"
|
||||||
.unwrap();
|
);
|
||||||
|
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>> =
|
let service_accounts: Option<Vec<ServiceAccount>> =
|
||||||
serde_json::from_str(&body).ok();
|
serde_json::from_str(&body).ok();
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use mlua::{FromLua, Lua, LuaSerdeExt, UserData, UserDataFields, UserDataMethods, Value};
|
use mlua::{FromLua, Lua, LuaSerdeExt, UserData, UserDataFields, UserDataMethods, Value};
|
||||||
|
|
||||||
use crate::{
|
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::{
|
ipc::zone::{
|
||||||
ActionEffect, DamageElement, DamageKind, DamageType, EffectKind, EventScene,
|
ActionEffect, DamageElement, DamageKind, DamageType, EffectKind, EventScene,
|
||||||
ServerZoneIpcData, ServerZoneIpcSegment, Warp,
|
ServerZoneIpcData, ServerZoneIpcSegment, Warp,
|
||||||
|
@ -157,12 +160,15 @@ impl UserData for LuaPlayer {
|
||||||
Ok(())
|
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 position: Position = lua.from_value(position).unwrap();
|
||||||
let rotation: f32 = lua.from_value(rotation).unwrap();
|
let rotation: f32 = lua.from_value(rotation).unwrap();
|
||||||
this.set_position(position, rotation);
|
this.set_position(position, rotation);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
},
|
||||||
|
);
|
||||||
methods.add_method_mut("change_territory", |_, this, zone_id: u16| {
|
methods.add_method_mut("change_territory", |_, this, zone_id: u16| {
|
||||||
this.change_territory(zone_id);
|
this.change_territory(zone_id);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -205,12 +211,8 @@ impl UserData for LuaPlayer {
|
||||||
fields.add_field_method_get("teleport_query", |_, this| {
|
fields.add_field_method_get("teleport_query", |_, this| {
|
||||||
Ok(this.player_data.teleport_query.clone())
|
Ok(this.player_data.teleport_query.clone())
|
||||||
});
|
});
|
||||||
fields.add_field_method_get("rotation", |_, this| {
|
fields.add_field_method_get("rotation", |_, this| Ok(this.player_data.rotation));
|
||||||
Ok(this.player_data.rotation)
|
fields.add_field_method_get("position", |_, this| Ok(this.player_data.position));
|
||||||
});
|
|
||||||
fields.add_field_method_get("position", |_, this| {
|
|
||||||
Ok(this.player_data.position)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue