forked from NewEriduPubSec/JaneDoe-ZS
Compare commits
No commits in common. "6ac186a1cfbcab671c112c3602576663cee187e1" and "2041d8dd03dc16f42f2bd3bc04b3f98533274a4e" have entirely different histories.
6ac186a1cf
...
2041d8dd03
6 changed files with 36 additions and 96 deletions
|
@ -87,6 +87,5 @@ impl CommandManager {
|
||||||
player::procedure "[player_uid] [procedure_id]" "changes current beginner procedure id, parameter -1 can be used for skipping it";
|
player::procedure "[player_uid] [procedure_id]" "changes current beginner procedure id, parameter -1 can be used for skipping it";
|
||||||
avatar::add "[player_uid] [avatar_id]" "gives avatar with specified id to player";
|
avatar::add "[player_uid] [avatar_id]" "gives avatar with specified id to player";
|
||||||
item::add_weapon "[player_uid] [weapon_id]" "gives weapon with specified id to player";
|
item::add_weapon "[player_uid] [weapon_id]" "gives weapon with specified id to player";
|
||||||
player::kick "[player_uid] [reason]" "kick the specified player (reason is optional)";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use data::tables::{AvatarBaseID, ProcedureConfigID};
|
use data::tables::{AvatarBaseID, ProcedureConfigID};
|
||||||
use proto::{DisconnectReason, DisconnectScNotify, PlayerSyncScNotify};
|
use proto::PlayerSyncScNotify;
|
||||||
|
|
||||||
use crate::ServerState;
|
use crate::ServerState;
|
||||||
|
|
||||||
|
@ -126,44 +126,3 @@ pub async fn procedure(
|
||||||
"successfully changed procedure_id to {procedure_id:?}"
|
"successfully changed procedure_id to {procedure_id:?}"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn kick(
|
|
||||||
args: ArgSlice<'_>,
|
|
||||||
state: &ServerState,
|
|
||||||
) -> Result<String, Box<dyn std::error::Error>> {
|
|
||||||
const USAGE: &str = "Usage: player kick [player_uid]";
|
|
||||||
|
|
||||||
if args.len() > 2 {
|
|
||||||
return Ok(USAGE.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
let uid = args[0].parse::<u32>()?;
|
|
||||||
let reason = match args.get(1) {
|
|
||||||
Some(arg) => match arg.parse::<i32>() {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(_err) => 1,
|
|
||||||
},
|
|
||||||
None => 1,
|
|
||||||
};
|
|
||||||
let reason_str = match DisconnectReason::try_from(reason) {
|
|
||||||
Ok(converted_enum) => converted_enum.as_str_name().to_owned(),
|
|
||||||
Err(_err) => reason.to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(player_lock) = state.player_mgr.get_player(uid).await else {
|
|
||||||
return Ok(String::from("player not found"));
|
|
||||||
};
|
|
||||||
|
|
||||||
let session_id = player_lock.lock().await.current_session_id();
|
|
||||||
|
|
||||||
if let Some(session) = session_id.map(|id| state.session_mgr.get(id)).flatten() {
|
|
||||||
session
|
|
||||||
.notify(DisconnectScNotify { reason: reason })
|
|
||||||
.await?;
|
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;
|
|
||||||
session.shutdown().await?;
|
|
||||||
Ok(format!("kicked player, uid: {uid}, reason: {reason_str}"))
|
|
||||||
} else {
|
|
||||||
Ok(format!("player uid: {uid} is not online yet."))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,19 +7,11 @@ use rand::{thread_rng, Rng};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::hash::{BuildHasher, Hash};
|
use std::hash::{BuildHasher, Hash};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct GachaModel {
|
pub struct GachaModel {
|
||||||
pub gacha_bin: GachaModelBin,
|
pub gacha_bin: GachaModelBin,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GachaModel {
|
|
||||||
fn default() -> GachaModel {
|
|
||||||
let result = GachaModel {
|
|
||||||
gacha_bin: GachaModelBin::default(),
|
|
||||||
};
|
|
||||||
result.post_deserialize()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GachaModel {
|
impl GachaModel {
|
||||||
pub fn from_bin(gacha_bin: GachaModelBin) -> Self {
|
pub fn from_bin(gacha_bin: GachaModelBin) -> Self {
|
||||||
let result = Self { gacha_bin };
|
let result = Self { gacha_bin };
|
||||||
|
|
|
@ -62,12 +62,6 @@ impl Player {
|
||||||
.add_resource(ItemStatic::FrontendGold as u32, 1_000_000);
|
.add_resource(ItemStatic::FrontendGold as u32, 1_000_000);
|
||||||
self.item_model
|
self.item_model
|
||||||
.add_resource(ItemStatic::GameDiamond as u32, 1_000_000);
|
.add_resource(ItemStatic::GameDiamond as u32, 1_000_000);
|
||||||
self.item_model
|
|
||||||
.add_resource(ItemStatic::GachaTicketEvent as u32, 30_000);
|
|
||||||
self.item_model
|
|
||||||
.add_resource(ItemStatic::GachaTicketStandard as u32, 30_000);
|
|
||||||
self.item_model
|
|
||||||
.add_resource(ItemStatic::GachaTicketBangboo as u32, 30_000);
|
|
||||||
self.item_model.add_resource(ItemStatic::Energy as u32, 240);
|
self.item_model.add_resource(ItemStatic::Energy as u32, 240);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,8 +247,4 @@ impl NetSession {
|
||||||
pub fn set_state(&self, state: NetSessionState) {
|
pub fn set_state(&self, state: NetSessionState) {
|
||||||
self.state.store(state, std::sync::atomic::Ordering::SeqCst);
|
self.state.store(state, std::sync::atomic::Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn shutdown(&self) -> Result<(), std::io::Error> {
|
|
||||||
self.writer.lock().await.shutdown().await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28249,8 +28249,8 @@ pub struct Flpgnabkedc {
|
||||||
#[derive(proto_gen::XorFields)]
|
#[derive(proto_gen::XorFields)]
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct DisconnectScNotify {
|
pub struct Igapopdfcef {
|
||||||
#[prost(enumeration = "DisconnectReason", tag = "15")]
|
#[prost(enumeration = "Obpfhejepck", tag = "15")]
|
||||||
pub reason: i32,
|
pub reason: i32,
|
||||||
}
|
}
|
||||||
#[derive(proto_gen::CmdID)]
|
#[derive(proto_gen::CmdID)]
|
||||||
|
@ -54259,9 +54259,9 @@ pub enum ItemStatic {
|
||||||
FrontendGold = 10,
|
FrontendGold = 10,
|
||||||
GameDiamond = 100,
|
GameDiamond = 100,
|
||||||
RechargeDiamond = 101,
|
RechargeDiamond = 101,
|
||||||
GachaTicketStandard = 110,
|
Lcdlfoheaim = 110,
|
||||||
GachaTicketEvent = 111,
|
Mndhfchkhcl = 111,
|
||||||
GachaTicketBangboo = 112,
|
Fcffdnjnemf = 112,
|
||||||
Exp = 201,
|
Exp = 201,
|
||||||
Energy = 501,
|
Energy = 501,
|
||||||
Gdglcfmgoji = 3000001,
|
Gdglcfmgoji = 3000001,
|
||||||
|
@ -54280,9 +54280,9 @@ impl ItemStatic {
|
||||||
ItemStatic::FrontendGold => "ITEM_STATIC_FRONTEND_GOLD",
|
ItemStatic::FrontendGold => "ITEM_STATIC_FRONTEND_GOLD",
|
||||||
ItemStatic::GameDiamond => "ITEM_STATIC_GAME_DIAMOND",
|
ItemStatic::GameDiamond => "ITEM_STATIC_GAME_DIAMOND",
|
||||||
ItemStatic::RechargeDiamond => "ITEM_STATIC_RECHARGE_DIAMOND",
|
ItemStatic::RechargeDiamond => "ITEM_STATIC_RECHARGE_DIAMOND",
|
||||||
ItemStatic::GachaTicketStandard => "ItemStatic_GACHA_TICKET_STANDARD",
|
ItemStatic::Lcdlfoheaim => "ItemStatic_LCDLFOHEAIM",
|
||||||
ItemStatic::GachaTicketEvent => "ItemStatic_GACHA_TICKET_EVENT",
|
ItemStatic::Mndhfchkhcl => "ItemStatic_MNDHFCHKHCL",
|
||||||
ItemStatic::GachaTicketBangboo => "ItemStatic_GACHA_TICKET_BANGBOO",
|
ItemStatic::Fcffdnjnemf => "ItemStatic_FCFFDNJNEMF",
|
||||||
ItemStatic::Exp => "ITEM_STATIC_EXP",
|
ItemStatic::Exp => "ITEM_STATIC_EXP",
|
||||||
ItemStatic::Energy => "ITEM_STATIC_ENERGY",
|
ItemStatic::Energy => "ITEM_STATIC_ENERGY",
|
||||||
ItemStatic::Gdglcfmgoji => "ItemStatic_GDGLCFMGOJI",
|
ItemStatic::Gdglcfmgoji => "ItemStatic_GDGLCFMGOJI",
|
||||||
|
@ -54298,9 +54298,9 @@ impl ItemStatic {
|
||||||
"ITEM_STATIC_FRONTEND_GOLD" => Some(Self::FrontendGold),
|
"ITEM_STATIC_FRONTEND_GOLD" => Some(Self::FrontendGold),
|
||||||
"ITEM_STATIC_GAME_DIAMOND" => Some(Self::GameDiamond),
|
"ITEM_STATIC_GAME_DIAMOND" => Some(Self::GameDiamond),
|
||||||
"ITEM_STATIC_RECHARGE_DIAMOND" => Some(Self::RechargeDiamond),
|
"ITEM_STATIC_RECHARGE_DIAMOND" => Some(Self::RechargeDiamond),
|
||||||
"ItemStatic_GACHA_TICKET_STANDARD" => Some(Self::GachaTicketStandard),
|
"ItemStatic_LCDLFOHEAIM" => Some(Self::Lcdlfoheaim),
|
||||||
"ItemStatic_GACHA_TICKET_EVENT" => Some(Self::GachaTicketEvent),
|
"ItemStatic_MNDHFCHKHCL" => Some(Self::Mndhfchkhcl),
|
||||||
"ItemStatic_GACHA_TICKET_BANGBOO" => Some(Self::GachaTicketBangboo),
|
"ItemStatic_FCFFDNJNEMF" => Some(Self::Fcffdnjnemf),
|
||||||
"ITEM_STATIC_EXP" => Some(Self::Exp),
|
"ITEM_STATIC_EXP" => Some(Self::Exp),
|
||||||
"ITEM_STATIC_ENERGY" => Some(Self::Energy),
|
"ITEM_STATIC_ENERGY" => Some(Self::Energy),
|
||||||
"ItemStatic_GDGLCFMGOJI" => Some(Self::Gdglcfmgoji),
|
"ItemStatic_GDGLCFMGOJI" => Some(Self::Gdglcfmgoji),
|
||||||
|
@ -55320,9 +55320,9 @@ impl Jiedoddkipa {
|
||||||
#[derive(proto_gen::XorFields)]
|
#[derive(proto_gen::XorFields)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum DisconnectReason {
|
pub enum Obpfhejepck {
|
||||||
Domjllafeac = 0,
|
Domjllafeac = 0,
|
||||||
ServerRelogin = 1,
|
Gdbjccehcdb = 1,
|
||||||
Clcbejonokn = 2,
|
Clcbejonokn = 2,
|
||||||
Jlimlghggke = 3,
|
Jlimlghggke = 3,
|
||||||
Omjjggajcbh = 4,
|
Omjjggajcbh = 4,
|
||||||
|
@ -55332,38 +55332,38 @@ pub enum DisconnectReason {
|
||||||
Lgjemnlahcp = 8,
|
Lgjemnlahcp = 8,
|
||||||
Mfgomdhiejh = 9,
|
Mfgomdhiejh = 9,
|
||||||
}
|
}
|
||||||
impl DisconnectReason {
|
impl Obpfhejepck {
|
||||||
/// String value of the enum field names used in the ProtoBuf definition.
|
/// String value of the enum field names used in the ProtoBuf definition.
|
||||||
///
|
///
|
||||||
/// The values are not transformed in any way and thus are considered stable
|
/// The values are not transformed in any way and thus are considered stable
|
||||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||||
pub fn as_str_name(&self) -> &'static str {
|
pub fn as_str_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
DisconnectReason::Domjllafeac => "DISCONNECT_REASON_DOMJLLAFEAC",
|
Obpfhejepck::Domjllafeac => "OBPFHEJEPCK_DOMJLLAFEAC",
|
||||||
DisconnectReason::ServerRelogin => "DISCONNECT_REASON_SERVER_RELOGIN",
|
Obpfhejepck::Gdbjccehcdb => "OBPFHEJEPCK_GDBJCCEHCDB",
|
||||||
DisconnectReason::Clcbejonokn => "DISCONNECT_REASON_CLCBEJONOKN",
|
Obpfhejepck::Clcbejonokn => "OBPFHEJEPCK_CLCBEJONOKN",
|
||||||
DisconnectReason::Jlimlghggke => "DISCONNECT_REASON_JLIMLGHGGKE",
|
Obpfhejepck::Jlimlghggke => "OBPFHEJEPCK_JLIMLGHGGKE",
|
||||||
DisconnectReason::Omjjggajcbh => "DISCONNECT_REASON_OMJJGGAJCBH",
|
Obpfhejepck::Omjjggajcbh => "OBPFHEJEPCK_OMJJGGAJCBH",
|
||||||
DisconnectReason::Kdpiceebneb => "DISCONNECT_REASON_KDPICEEBNEB",
|
Obpfhejepck::Kdpiceebneb => "OBPFHEJEPCK_KDPICEEBNEB",
|
||||||
DisconnectReason::Nmcpihldicf => "DISCONNECT_REASON_NMCPIHLDICF",
|
Obpfhejepck::Nmcpihldicf => "OBPFHEJEPCK_NMCPIHLDICF",
|
||||||
DisconnectReason::Ihcmpplkgkn => "DISCONNECT_REASON_IHCMPPLKGKN",
|
Obpfhejepck::Ihcmpplkgkn => "OBPFHEJEPCK_IHCMPPLKGKN",
|
||||||
DisconnectReason::Lgjemnlahcp => "DISCONNECT_REASON_LGJEMNLAHCP",
|
Obpfhejepck::Lgjemnlahcp => "OBPFHEJEPCK_LGJEMNLAHCP",
|
||||||
DisconnectReason::Mfgomdhiejh => "DISCONNECT_REASON_MFGOMDHIEJH",
|
Obpfhejepck::Mfgomdhiejh => "OBPFHEJEPCK_MFGOMDHIEJH",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||||
match value {
|
match value {
|
||||||
"DISCONNECT_REASON_DOMJLLAFEAC" => Some(Self::Domjllafeac),
|
"OBPFHEJEPCK_DOMJLLAFEAC" => Some(Self::Domjllafeac),
|
||||||
"DISCONNECT_REASON_SERVER_RELOGIN" => Some(Self::ServerRelogin),
|
"OBPFHEJEPCK_GDBJCCEHCDB" => Some(Self::Gdbjccehcdb),
|
||||||
"DISCONNECT_REASON_CLCBEJONOKN" => Some(Self::Clcbejonokn),
|
"OBPFHEJEPCK_CLCBEJONOKN" => Some(Self::Clcbejonokn),
|
||||||
"DISCONNECT_REASON_JLIMLGHGGKE" => Some(Self::Jlimlghggke),
|
"OBPFHEJEPCK_JLIMLGHGGKE" => Some(Self::Jlimlghggke),
|
||||||
"DISCONNECT_REASON_OMJJGGAJCBH" => Some(Self::Omjjggajcbh),
|
"OBPFHEJEPCK_OMJJGGAJCBH" => Some(Self::Omjjggajcbh),
|
||||||
"DISCONNECT_REASON_KDPICEEBNEB" => Some(Self::Kdpiceebneb),
|
"OBPFHEJEPCK_KDPICEEBNEB" => Some(Self::Kdpiceebneb),
|
||||||
"DISCONNECT_REASON_NMCPIHLDICF" => Some(Self::Nmcpihldicf),
|
"OBPFHEJEPCK_NMCPIHLDICF" => Some(Self::Nmcpihldicf),
|
||||||
"DISCONNECT_REASON_IHCMPPLKGKN" => Some(Self::Ihcmpplkgkn),
|
"OBPFHEJEPCK_IHCMPPLKGKN" => Some(Self::Ihcmpplkgkn),
|
||||||
"DISCONNECT_REASON_LGJEMNLAHCP" => Some(Self::Lgjemnlahcp),
|
"OBPFHEJEPCK_LGJEMNLAHCP" => Some(Self::Lgjemnlahcp),
|
||||||
"DISCONNECT_REASON_MFGOMDHIEJH" => Some(Self::Mfgomdhiejh),
|
"OBPFHEJEPCK_MFGOMDHIEJH" => Some(Self::Mfgomdhiejh),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue