Did some code clean-up
Added TODOs for some changes that need to be made
This commit is contained in:
@@ -193,9 +193,6 @@ pub(crate) async fn handle_login_req(
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
let writer_clone = state.writer.clone().unwrap();
|
||||
create_chat_client_handler(writer_clone, chat_handler.clone()).await?;
|
||||
}
|
||||
|
||||
if let Some(mut state) = connection_service.get_connection_mut(&connection_id) {
|
||||
state.chat_handler = Some(chat_handler);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,6 +264,14 @@ pub(crate) async fn handle_select_char_req(
|
||||
state.character_id = Some(request.char_id as i8);
|
||||
}
|
||||
|
||||
//TODO: All of the following packet code needs to be moved to their own functions
|
||||
// We instead want to make our world service connection then request a player connection event
|
||||
// from the world service to the game logic service. Then we have the game logic service send
|
||||
// the appropriate events back and should cause the packet service to send the appropriate packets.
|
||||
|
||||
|
||||
//TODO: Switch server packet is used to accept the client into the server and should be sent after
|
||||
// the world service connection is established and confirm the client is in the correct map.
|
||||
let data = SrvSwitchServer {
|
||||
port: 0,
|
||||
session_id: 0,
|
||||
@@ -277,6 +285,9 @@ pub(crate) async fn handle_select_char_req(
|
||||
send_packet(&mut locked_stream, &response_packet).await?;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Get the character data from the character service should be moved to the game logic service
|
||||
// as it needs to be sent to all the other nearby clients as well.
|
||||
let mut character_client = character_client.lock().await;
|
||||
let character_data = character_client
|
||||
.get_character(&user_id.to_string(), character_id_list[request.char_id as usize] as u8)
|
||||
@@ -429,7 +440,8 @@ pub(crate) async fn handle_select_char_req(
|
||||
send_packet(&mut locked_stream, &response_packet).await?;
|
||||
}
|
||||
|
||||
// Send the billing message (we don't use this, so we just send the defaults to allow)
|
||||
// Send the billing message (we don't actually use this, so we just send the defaults to allow)
|
||||
// This tells the client to actually switch from character select to the game world
|
||||
let data = SrvBillingMessage {
|
||||
function_type: 0x1001,
|
||||
pay_flag: 2,
|
||||
|
||||
@@ -282,11 +282,38 @@ async fn handle_world_events(
|
||||
Some(crate::world_client::world::world_event::Event::NpcSpawn(npc_spawn)) => {
|
||||
debug!("Processing NPC spawn event: {:?}", npc_spawn);
|
||||
// Convert to the appropriate game packet and send to client
|
||||
// This would involve creating a spawn packet and sending it through the connection's writer
|
||||
let npc = WorldObject {
|
||||
id: npc_spawn.id,
|
||||
object_type: 2,
|
||||
x: npc_spawn.pos_x,
|
||||
y: npc_spawn.pos_y,
|
||||
z: 0.0,
|
||||
map_id: 0,
|
||||
name: "NPC".to_string(),
|
||||
hp: npc_spawn.hp,
|
||||
max_hp: npc_spawn.hp,
|
||||
};
|
||||
// if let Err(e) = spawn_npc(&npc, connection_service.clone(), session_id.clone()).await {
|
||||
// error!("Failed to spawn npc for session {}: {}", session_id, e);
|
||||
// }
|
||||
}
|
||||
Some(crate::world_client::world::world_event::Event::MobSpawn(mob_spawn)) => {
|
||||
debug!("Processing mob spawn event: {:?}", mob_spawn);
|
||||
// Convert to the appropriate game packet and send to client
|
||||
let mob = WorldObject {
|
||||
id: mob_spawn.id,
|
||||
object_type: 3,
|
||||
x: mob_spawn.pos_x,
|
||||
y: mob_spawn.pos_y,
|
||||
z: 0.0,
|
||||
map_id: 0,
|
||||
name: "Mob".to_string(),
|
||||
hp: mob_spawn.hp,
|
||||
max_hp: mob_spawn.hp,
|
||||
};
|
||||
if let Err(e) = spawn_mob(&mob, connection_service.clone(), session_id.clone()).await {
|
||||
error!("Failed to spawn mob for session {}: {}", session_id, e);
|
||||
}
|
||||
}
|
||||
Some(crate::world_client::world::world_event::Event::ObjectDespawn(despawn)) => {
|
||||
debug!("Processing object despawn event: {:?}", despawn);
|
||||
|
||||
Reference in New Issue
Block a user