mirror of
https://github.com/redstrate/Kawari.git
synced 2025-05-06 04:37:46 +00:00
Re-organize IPC segments into the ipc module
These were kind of scattered everywhere, instead we should move them into their own module. Kawari's custom IPC is moved here too.
This commit is contained in:
parent
80b06b3294
commit
5111a38424
49 changed files with 57 additions and 70 deletions
|
@ -1,12 +1,12 @@
|
|||
use kawari::RECEIVE_BUFFER_SIZE;
|
||||
use kawari::common::GameData;
|
||||
use kawari::common::custom_ipc::CustomIpcData;
|
||||
use kawari::common::custom_ipc::CustomIpcSegment;
|
||||
use kawari::common::custom_ipc::CustomIpcType;
|
||||
use kawari::config::get_config;
|
||||
use kawari::ipc::kawari::CustomIpcData;
|
||||
use kawari::ipc::kawari::CustomIpcSegment;
|
||||
use kawari::ipc::kawari::CustomIpcType;
|
||||
use kawari::ipc::lobby::ServiceAccount;
|
||||
use kawari::ipc::lobby::{ClientLobbyIpcData, ServerLobbyIpcSegment};
|
||||
use kawari::lobby::LobbyConnection;
|
||||
use kawari::lobby::ipc::ServiceAccount;
|
||||
use kawari::lobby::ipc::{ClientLobbyIpcData, ServerLobbyIpcSegment};
|
||||
use kawari::lobby::send_custom_world_packet;
|
||||
use kawari::oodle::OodleNetwork;
|
||||
use kawari::packet::ConnectionType;
|
||||
|
|
|
@ -6,8 +6,8 @@ use axum::routing::post;
|
|||
use axum::{Form, Router, routing::get};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use axum_extra::extract::cookie::{Cookie, Expiration};
|
||||
use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||
use kawari::config::get_config;
|
||||
use kawari::ipc::kawari::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||
use kawari::lobby::send_custom_world_packet;
|
||||
use kawari::login::{LoginDatabase, LoginError};
|
||||
use minijinja::{Environment, context};
|
||||
|
|
|
@ -3,33 +3,31 @@ use std::net::SocketAddr;
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use kawari::RECEIVE_BUFFER_SIZE;
|
||||
use kawari::common::custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||
use kawari::common::workdefinitions::CharaMake;
|
||||
use kawari::common::{GameData, ObjectId, timestamp_secs};
|
||||
use kawari::common::{Position, determine_initial_starting_zone};
|
||||
use kawari::config::get_config;
|
||||
use kawari::ipc::chat::{ServerChatIpcData, ServerChatIpcSegment};
|
||||
use kawari::ipc::kawari::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||
use kawari::ipc::zone::{
|
||||
ActionEffect, ActionResult, ClientZoneIpcData, EffectKind, GameMasterCommandType,
|
||||
GameMasterRank, OnlineStatus, ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType,
|
||||
};
|
||||
use kawari::ipc::zone::{
|
||||
ActorControlCategory, ActorControlSelf, CommonSpawn, PlayerEntry, PlayerSetup, PlayerSpawn,
|
||||
SocialList,
|
||||
};
|
||||
use kawari::oodle::OodleNetwork;
|
||||
use kawari::opcodes::{ServerChatIpcType, ServerZoneIpcType};
|
||||
use kawari::packet::{
|
||||
CompressionType, ConnectionType, PacketSegment, PacketState, SegmentData, SegmentType,
|
||||
send_keep_alive, send_packet,
|
||||
};
|
||||
use kawari::world::chat::{ServerChatIpcData, ServerChatIpcSegment};
|
||||
use kawari::world::ipc::{
|
||||
ActionEffect, ActionResult, ClientZoneIpcData, EffectKind, GameMasterCommandType,
|
||||
GameMasterRank, OnlineStatus, ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType,
|
||||
};
|
||||
use kawari::world::{
|
||||
Actor, ClientHandle, ClientId, EffectsBuilder, FromServer, Inventory, Item, LuaPlayer,
|
||||
PlayerData, ServerHandle, StatusEffects, ToServer, WorldDatabase,
|
||||
};
|
||||
use kawari::world::{
|
||||
ChatHandler, Zone, ZoneConnection,
|
||||
ipc::{
|
||||
ActorControlCategory, ActorControlSelf, CommonSpawn, PlayerEntry, PlayerSetup, PlayerSpawn,
|
||||
SocialList,
|
||||
},
|
||||
};
|
||||
use kawari::world::{ChatHandler, Zone, ZoneConnection};
|
||||
|
||||
use mlua::{Function, Lua};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
|
|
@ -7,8 +7,6 @@ mod customize_data;
|
|||
use binrw::binrw;
|
||||
pub use customize_data::CustomizeData;
|
||||
|
||||
pub mod custom_ipc;
|
||||
|
||||
mod position;
|
||||
pub use position::Position;
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use binrw::binrw;
|
||||
|
||||
use crate::{
|
||||
common::{CHAR_NAME_MAX_LENGTH, read_bool_from, read_string, write_bool_as},
|
||||
lobby::ipc::CharacterDetails,
|
||||
common::{CHAR_NAME_MAX_LENGTH, read_bool_from, read_string, write_bool_as, write_string},
|
||||
ipc::lobby::CharacterDetails,
|
||||
packet::{IpcSegment, ReadWriteIpcSegment},
|
||||
};
|
||||
|
||||
use super::write_string;
|
||||
|
||||
pub type CustomIpcSegment = IpcSegment<CustomIpcType, CustomIpcData>;
|
||||
|
||||
impl ReadWriteIpcSegment for CustomIpcSegment {
|
4
src/ipc/mod.rs
Normal file
4
src/ipc/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub mod chat;
|
||||
pub mod kawari;
|
||||
pub mod lobby;
|
||||
pub mod zone;
|
|
@ -36,6 +36,9 @@ pub mod patch;
|
|||
/// Opcodes, see `resources/opcodes.json`
|
||||
pub mod opcodes;
|
||||
|
||||
/// IPC
|
||||
pub mod ipc;
|
||||
|
||||
/// Used in the encryption key.
|
||||
const GAME_VERSION: u16 = 7000;
|
||||
|
||||
|
|
|
@ -5,11 +5,7 @@ use tokio::{io::AsyncReadExt, net::TcpStream};
|
|||
use crate::{
|
||||
RECEIVE_BUFFER_SIZE,
|
||||
blowfish::Blowfish,
|
||||
common::{
|
||||
custom_ipc::{CustomIpcData, CustomIpcSegment, CustomIpcType},
|
||||
timestamp_secs,
|
||||
workdefinitions::CharaMake,
|
||||
},
|
||||
common::{timestamp_secs, workdefinitions::CharaMake},
|
||||
config::get_config,
|
||||
oodle::OodleNetwork,
|
||||
opcodes::ServerLobbyIpcType,
|
||||
|
@ -19,12 +15,12 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
use super::ipc::{
|
||||
CharacterDetails, LobbyCharacterAction, LobbyCharacterActionKind, LobbyCharacterList,
|
||||
LobbyServerList, LobbyServiceAccountList, Server, ServerLobbyIpcData, ServerLobbyIpcSegment,
|
||||
ServiceAccount,
|
||||
use crate::ipc::kawari::{CustomIpcData, CustomIpcSegment, CustomIpcType};
|
||||
use crate::ipc::lobby::{
|
||||
CharacterDetails, ClientLobbyIpcSegment, LobbyCharacterAction, LobbyCharacterActionKind,
|
||||
LobbyCharacterList, LobbyServerList, LobbyServiceAccountList, Server, ServerLobbyIpcData,
|
||||
ServerLobbyIpcSegment, ServiceAccount,
|
||||
};
|
||||
use crate::lobby::ipc::ClientLobbyIpcSegment;
|
||||
|
||||
/// Represents a single connection between an instance of the client and the lobby server.
|
||||
pub struct LobbyConnection {
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
mod connection;
|
||||
pub use connection::{LobbyConnection, send_custom_world_packet};
|
||||
|
||||
/// The IPC packets for the Lobby connection.
|
||||
pub mod ipc;
|
||||
|
|
|
@ -4,7 +4,7 @@ use rand::Rng;
|
|||
use rand::distr::Alphanumeric;
|
||||
use rusqlite::Connection;
|
||||
|
||||
use crate::lobby::ipc::ServiceAccount;
|
||||
use crate::ipc::lobby::ServiceAccount;
|
||||
|
||||
pub struct LoginDatabase {
|
||||
connection: Mutex<Connection>,
|
||||
|
|
|
@ -4,8 +4,9 @@ use binrw::{BinRead, BinWrite, binrw};
|
|||
use tokio::{io::AsyncWriteExt, net::TcpStream};
|
||||
|
||||
use crate::{
|
||||
common::{custom_ipc::CustomIpcSegment, read_string, timestamp_msecs, write_string},
|
||||
common::{read_string, timestamp_msecs, write_string},
|
||||
config::get_config,
|
||||
ipc::kawari::CustomIpcSegment,
|
||||
oodle::OodleNetwork,
|
||||
packet::{compression::compress, encryption::decrypt},
|
||||
};
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
use crate::{
|
||||
common::{CustomizeData, ObjectId, ObjectTypeId, Position, timestamp_secs},
|
||||
config::get_config,
|
||||
ipc::zone::{
|
||||
ActorControl, ActorControlCategory, BattleNpcSubKind, ChatMessage, CommonSpawn,
|
||||
DisplayFlag, EventStart, NpcSpawn, ObjectKind, OnlineStatus, PlayerSpawn, PlayerSubKind,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment,
|
||||
},
|
||||
opcodes::ServerZoneIpcType,
|
||||
packet::{PacketSegment, SegmentData, SegmentType},
|
||||
world::{
|
||||
Actor, Event,
|
||||
ipc::{
|
||||
ActorControl, ActorControlCategory, BattleNpcSubKind, CommonSpawn, DisplayFlag,
|
||||
EventStart, NpcSpawn, ObjectKind, OnlineStatus, PlayerSpawn, PlayerSubKind,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment,
|
||||
},
|
||||
},
|
||||
world::{Actor, Event},
|
||||
};
|
||||
|
||||
use super::{LuaPlayer, ZoneConnection, ipc::ChatMessage};
|
||||
use super::{LuaPlayer, ZoneConnection};
|
||||
|
||||
pub const CUSTOMIZE_DATA: CustomizeData = CustomizeData {
|
||||
race: 4,
|
||||
|
|
|
@ -12,6 +12,13 @@ use crate::{
|
|||
OBFUSCATION_ENABLED_MODE,
|
||||
common::{GameData, ObjectId, Position, timestamp_secs},
|
||||
config::get_config,
|
||||
ipc::chat::ServerChatIpcSegment,
|
||||
ipc::zone::{
|
||||
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo,
|
||||
ContainerType, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerStats,
|
||||
PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList,
|
||||
UpdateClassInfo, WeatherChange,
|
||||
},
|
||||
opcodes::ServerZoneIpcType,
|
||||
packet::{
|
||||
CompressionType, ConnectionType, PacketSegment, PacketState, SegmentData, SegmentType,
|
||||
|
@ -21,14 +28,7 @@ use crate::{
|
|||
|
||||
use super::{
|
||||
Actor, CharacterData, Event, Inventory, Item, LuaPlayer, StatusEffects, WorldDatabase, Zone,
|
||||
chat::ServerChatIpcSegment,
|
||||
inventory::Container,
|
||||
ipc::{
|
||||
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo,
|
||||
ContainerType, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerStats,
|
||||
PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList,
|
||||
UpdateClassInfo, WeatherChange,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
CustomizeData, GameData, Position,
|
||||
workdefinitions::{CharaMake, ClientSelectData, RemakeMode},
|
||||
},
|
||||
lobby::ipc::{CharacterDetails, CharacterFlag},
|
||||
ipc::lobby::{CharacterDetails, CharacterFlag},
|
||||
};
|
||||
|
||||
use super::{Inventory, PlayerData};
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use crate::common::GameData;
|
||||
|
||||
use super::ipc::{ContainerType, InventoryModify};
|
||||
use crate::ipc::zone::{ContainerType, InventoryModify};
|
||||
|
||||
// TODO: rename to storage?
|
||||
pub trait Container {
|
||||
|
|
|
@ -2,17 +2,15 @@ use mlua::{FromLua, Lua, LuaSerdeExt, UserData, UserDataMethods, Value};
|
|||
|
||||
use crate::{
|
||||
common::{ObjectId, ObjectTypeId, Position, timestamp_secs},
|
||||
ipc::zone::{
|
||||
ActionEffect, ActorSetPos, DamageElement, DamageKind, DamageType, EffectKind, EventPlay,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment,
|
||||
},
|
||||
opcodes::ServerZoneIpcType,
|
||||
packet::{PacketSegment, SegmentData, SegmentType},
|
||||
};
|
||||
|
||||
use super::{
|
||||
PlayerData, StatusEffects, Zone,
|
||||
ipc::{
|
||||
ActionEffect, ActorSetPos, DamageElement, DamageKind, DamageType, EffectKind, EventPlay,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment,
|
||||
},
|
||||
};
|
||||
use super::{PlayerData, StatusEffects, Zone};
|
||||
|
||||
pub struct ChangeTerritoryTask {
|
||||
pub zone_id: u16,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
pub mod ipc;
|
||||
|
||||
mod zone;
|
||||
pub use zone::Zone;
|
||||
|
||||
|
@ -28,5 +26,3 @@ pub use actor::Actor;
|
|||
|
||||
mod status_effects;
|
||||
pub use status_effects::StatusEffects;
|
||||
|
||||
pub mod chat;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::world::ipc::StatusEffect;
|
||||
use crate::ipc::zone::StatusEffect;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct StatusEffects {
|
||||
|
|
Loading…
Add table
Reference in a new issue