From dba4edc32d7e67691ddc4aac03d453f78d884dfe Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 9 May 2025 19:45:08 -0400 Subject: [PATCH] Remove some dead, unused code --- src/bin/kawari-world.rs | 16 ++++------------ src/world/connection.rs | 26 +++++--------------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index dc03e8b..4de7ec5 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex}; use kawari::RECEIVE_BUFFER_SIZE; use kawari::common::Position; -use kawari::common::{GameData, ObjectId, timestamp_secs}; +use kawari::common::{GameData, timestamp_secs}; use kawari::config::get_config; use kawari::inventory::Item; use kawari::ipc::chat::{ServerChatIpcData, ServerChatIpcSegment}; @@ -21,11 +21,11 @@ use kawari::packet::oodle::OodleNetwork; use kawari::packet::{ ConnectionType, PacketSegment, PacketState, SegmentData, SegmentType, send_keep_alive, }; +use kawari::world::{ChatHandler, Zone, ZoneConnection}; use kawari::world::{ - Actor, ClientHandle, EffectsBuilder, Event, FromServer, LuaPlayer, PlayerData, ServerHandle, + ClientHandle, EffectsBuilder, Event, FromServer, LuaPlayer, PlayerData, ServerHandle, StatusEffects, ToServer, WorldDatabase, handle_custom_ipc, server_main_loop, }; -use kawari::world::{ChatHandler, Zone, ZoneConnection}; use mlua::{Function, Lua}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -64,8 +64,6 @@ fn spawn_main_loop() -> (ServerHandle, JoinHandle<()>) { } struct ClientData { - //id: ClientId, - // handle: ServerHandle, /// Socket for data recieved from the global server recv: Receiver, connection: ZoneConnection, @@ -78,12 +76,7 @@ pub fn spawn_client(connection: ZoneConnection) { let id = &connection.id.clone(); let ip = &connection.ip.clone(); - let data = ClientData { - //id: connection.id, - //handle: connection.handle.clone(), - recv, - connection, - }; + let data = ClientData { recv, connection }; // Spawn a new client task let (my_send, my_recv) = oneshot::channel(); @@ -96,7 +89,6 @@ pub fn spawn_client(connection: ZoneConnection) { channel: send, actor_id: 0, common: CommonSpawn::default(), - //kill, }; let _ = my_send.send(handle); } diff --git a/src/world/connection.rs b/src/world/connection.rs index a6b2870..132cb13 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -376,43 +376,27 @@ impl ZoneConnection { pub async fn change_zone(&mut self, new_zone_id: u16) { // tell everyone we're gone // the connection already checks to see if the actor already exists, so it's seems harmless if we do - if self.zone.is_some() { + if let Some(zone) = &self.zone { self.handle .send(ToServer::LeftZone( self.id, self.player_data.actor_id, - self.zone.as_ref().unwrap().id, + zone.id, )) .await; } + + // load the new zone now { let mut game_data = self.gamedata.lock().unwrap(); self.zone = Some(Zone::load(&mut game_data.game_data, new_zone_id)); } + self.player_data.zone_id = new_zone_id; // Player Class Info self.update_class_info().await; - // link shell information - /*{ - let ipc = ServerZoneIpcSegment { - op_code: ServerZoneIpcType::LinkShellInformation, - timestamp: timestamp_secs(), - data: ServerZoneIpcData::LinkShellInformation { unk: [0; 456] }, - ..Default::default() - }; - - self.send_segment(PacketSegment { - source_actor: self.player_data.actor_id, - target_actor: self.player_data.actor_id, - segment_type: SegmentType::Ipc { data: ipc }, - }) - .await; - }*/ - - // TODO: send unk16? - // Init Zone { let config = get_config();