mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-19 22:36:49 +00:00
Send actual player data to other clients
Instead of a placeholder actor, you can now see the other player's correct appearance.
This commit is contained in:
parent
4f8f0d1fe2
commit
268c157180
2 changed files with 16 additions and 39 deletions
|
@ -71,7 +71,7 @@ async fn main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::io::Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ToServer::ActorSpawned(from_id, actor) => {
|
ToServer::ActorSpawned(from_id, actor, common) => {
|
||||||
for (id, handle) in &mut data.clients {
|
for (id, handle) in &mut data.clients {
|
||||||
let id = *id;
|
let id = *id;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ async fn main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::io::Error> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = FromServer::ActorSpawn(actor);
|
let msg = FromServer::ActorSpawn(actor, common.clone());
|
||||||
|
|
||||||
if handle.send(msg).is_err() {
|
if handle.send(msg).is_err() {
|
||||||
to_remove.push(id);
|
to_remove.push(id);
|
||||||
|
@ -426,7 +426,7 @@ async fn client_loop(
|
||||||
exit_rotation = None;
|
exit_rotation = None;
|
||||||
|
|
||||||
// tell the other players we're here
|
// tell the other players we're here
|
||||||
connection.handle.send(ToServer::ActorSpawned(connection.id, Actor { id: ObjectId(connection.player_data.actor_id), hp: 100 })).await;
|
connection.handle.send(ToServer::ActorSpawned(connection.id, Actor { id: ObjectId(connection.player_data.actor_id), hp: 100 }, connection.get_player_common_spawn(None, None))).await;
|
||||||
}
|
}
|
||||||
ClientZoneIpcData::Unk1 {
|
ClientZoneIpcData::Unk1 {
|
||||||
category, param1, ..
|
category, param1, ..
|
||||||
|
@ -981,8 +981,8 @@ async fn client_loop(
|
||||||
msg = internal_recv.recv() => match msg {
|
msg = internal_recv.recv() => match msg {
|
||||||
Some(msg) => match msg {
|
Some(msg) => match msg {
|
||||||
FromServer::Message(msg)=>connection.send_message(&msg).await,
|
FromServer::Message(msg)=>connection.send_message(&msg).await,
|
||||||
FromServer::ActorSpawn(actor) => {
|
FromServer::ActorSpawn(actor, common) => {
|
||||||
connection.spawn_actor(actor).await
|
connection.spawn_actor(actor, common).await
|
||||||
},
|
},
|
||||||
FromServer::ActorMove(actor_id, position) => connection.set_actor_position(actor_id, position).await,
|
FromServer::ActorMove(actor_id, position) => connection.set_actor_position(actor_id, position).await,
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,12 +19,11 @@ use crate::{
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Actor, Event, Inventory, Item, LuaPlayer, StatusEffects, WorldDatabase, Zone,
|
Actor, Event, Inventory, Item, LuaPlayer, StatusEffects, WorldDatabase, Zone,
|
||||||
chat_handler::CUSTOMIZE_DATA,
|
|
||||||
ipc::{
|
ipc::{
|
||||||
ActorControlSelf, ActorMove, ActorSetPos, BattleNpcSubKind, ClientZoneIpcSegment,
|
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo,
|
||||||
CommonSpawn, ContainerInfo, ContainerType, DisplayFlag, Equip, InitZone, ItemInfo,
|
ContainerType, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerSubKind,
|
||||||
NpcSpawn, ObjectKind, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect,
|
ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList, UpdateClassInfo,
|
||||||
StatusEffectList, UpdateClassInfo, WeatherChange,
|
WeatherChange,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ pub enum FromServer {
|
||||||
/// A chat message.
|
/// A chat message.
|
||||||
Message(String),
|
Message(String),
|
||||||
/// An actor has been spawned.
|
/// An actor has been spawned.
|
||||||
ActorSpawn(Actor),
|
ActorSpawn(Actor, CommonSpawn),
|
||||||
/// An actor moved to a new position.
|
/// An actor moved to a new position.
|
||||||
ActorMove(u32, Position),
|
ActorMove(u32, Position),
|
||||||
}
|
}
|
||||||
|
@ -96,7 +95,7 @@ impl ClientHandle {
|
||||||
pub enum ToServer {
|
pub enum ToServer {
|
||||||
NewClient(ClientHandle),
|
NewClient(ClientHandle),
|
||||||
Message(ClientId, String),
|
Message(ClientId, String),
|
||||||
ActorSpawned(ClientId, Actor),
|
ActorSpawned(ClientId, Actor, CommonSpawn),
|
||||||
ActorMoved(ClientId, u32, Position),
|
ActorMoved(ClientId, u32, Position),
|
||||||
FatalError(std::io::Error),
|
FatalError(std::io::Error),
|
||||||
}
|
}
|
||||||
|
@ -303,10 +302,12 @@ impl ZoneConnection {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn spawn_actor(&mut self, actor: Actor) {
|
pub async fn spawn_actor(&mut self, actor: Actor, mut common: CommonSpawn) {
|
||||||
// There is no reason for us to spawn our own player again. It's probably a bug!'
|
// There is no reason for us to spawn our own player again. It's probably a bug!'
|
||||||
assert!(actor.id.0 != self.player_data.actor_id);
|
assert!(actor.id.0 != self.player_data.actor_id);
|
||||||
|
|
||||||
|
common.spawn_index = self.get_free_spawn_index();
|
||||||
|
|
||||||
let ipc = ServerZoneIpcSegment {
|
let ipc = ServerZoneIpcSegment {
|
||||||
unk1: 20,
|
unk1: 20,
|
||||||
unk2: 0,
|
unk2: 0,
|
||||||
|
@ -314,31 +315,7 @@ impl ZoneConnection {
|
||||||
server_id: 0,
|
server_id: 0,
|
||||||
timestamp: timestamp_secs(),
|
timestamp: timestamp_secs(),
|
||||||
data: ServerZoneIpcData::NpcSpawn(NpcSpawn {
|
data: ServerZoneIpcData::NpcSpawn(NpcSpawn {
|
||||||
common: CommonSpawn {
|
common,
|
||||||
hp_curr: 100,
|
|
||||||
hp_max: 100,
|
|
||||||
mp_curr: 100,
|
|
||||||
mp_max: 100,
|
|
||||||
look: CUSTOMIZE_DATA,
|
|
||||||
spawn_index: self.get_free_spawn_index(),
|
|
||||||
bnpc_base: 13498,
|
|
||||||
bnpc_name: 10261,
|
|
||||||
object_kind: ObjectKind::BattleNpc(BattleNpcSubKind::Enemy),
|
|
||||||
level: 1,
|
|
||||||
models: [
|
|
||||||
0, // head
|
|
||||||
89, // body
|
|
||||||
89, // hands
|
|
||||||
89, // legs
|
|
||||||
89, // feet
|
|
||||||
0, // ears
|
|
||||||
0, // neck
|
|
||||||
0, // wrists
|
|
||||||
0, // left finger
|
|
||||||
0, // right finger
|
|
||||||
],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -716,7 +693,7 @@ impl ZoneConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_player_common_spawn(
|
pub fn get_player_common_spawn(
|
||||||
&mut self,
|
&self,
|
||||||
exit_position: Option<Position>,
|
exit_position: Option<Position>,
|
||||||
exit_rotation: Option<f32>,
|
exit_rotation: Option<f32>,
|
||||||
) -> CommonSpawn {
|
) -> CommonSpawn {
|
||||||
|
|
Loading…
Add table
Reference in a new issue