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 {
|
||||
let id = *id;
|
||||
|
||||
|
@ -79,7 +79,7 @@ async fn main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::io::Error> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let msg = FromServer::ActorSpawn(actor);
|
||||
let msg = FromServer::ActorSpawn(actor, common.clone());
|
||||
|
||||
if handle.send(msg).is_err() {
|
||||
to_remove.push(id);
|
||||
|
@ -426,7 +426,7 @@ async fn client_loop(
|
|||
exit_rotation = None;
|
||||
|
||||
// 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 {
|
||||
category, param1, ..
|
||||
|
@ -981,8 +981,8 @@ async fn client_loop(
|
|||
msg = internal_recv.recv() => match msg {
|
||||
Some(msg) => match msg {
|
||||
FromServer::Message(msg)=>connection.send_message(&msg).await,
|
||||
FromServer::ActorSpawn(actor) => {
|
||||
connection.spawn_actor(actor).await
|
||||
FromServer::ActorSpawn(actor, common) => {
|
||||
connection.spawn_actor(actor, common).await
|
||||
},
|
||||
FromServer::ActorMove(actor_id, position) => connection.set_actor_position(actor_id, position).await,
|
||||
},
|
||||
|
|
|
@ -19,12 +19,11 @@ use crate::{
|
|||
|
||||
use super::{
|
||||
Actor, Event, Inventory, Item, LuaPlayer, StatusEffects, WorldDatabase, Zone,
|
||||
chat_handler::CUSTOMIZE_DATA,
|
||||
ipc::{
|
||||
ActorControlSelf, ActorMove, ActorSetPos, BattleNpcSubKind, ClientZoneIpcSegment,
|
||||
CommonSpawn, ContainerInfo, ContainerType, DisplayFlag, Equip, InitZone, ItemInfo,
|
||||
NpcSpawn, ObjectKind, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect,
|
||||
StatusEffectList, UpdateClassInfo, WeatherChange,
|
||||
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo,
|
||||
ContainerType, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerSubKind,
|
||||
ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList, UpdateClassInfo,
|
||||
WeatherChange,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -57,7 +56,7 @@ pub enum FromServer {
|
|||
/// A chat message.
|
||||
Message(String),
|
||||
/// An actor has been spawned.
|
||||
ActorSpawn(Actor),
|
||||
ActorSpawn(Actor, CommonSpawn),
|
||||
/// An actor moved to a new position.
|
||||
ActorMove(u32, Position),
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ impl ClientHandle {
|
|||
pub enum ToServer {
|
||||
NewClient(ClientHandle),
|
||||
Message(ClientId, String),
|
||||
ActorSpawned(ClientId, Actor),
|
||||
ActorSpawned(ClientId, Actor, CommonSpawn),
|
||||
ActorMoved(ClientId, u32, Position),
|
||||
FatalError(std::io::Error),
|
||||
}
|
||||
|
@ -303,10 +302,12 @@ impl ZoneConnection {
|
|||
.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!'
|
||||
assert!(actor.id.0 != self.player_data.actor_id);
|
||||
|
||||
common.spawn_index = self.get_free_spawn_index();
|
||||
|
||||
let ipc = ServerZoneIpcSegment {
|
||||
unk1: 20,
|
||||
unk2: 0,
|
||||
|
@ -314,31 +315,7 @@ impl ZoneConnection {
|
|||
server_id: 0,
|
||||
timestamp: timestamp_secs(),
|
||||
data: ServerZoneIpcData::NpcSpawn(NpcSpawn {
|
||||
common: CommonSpawn {
|
||||
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()
|
||||
},
|
||||
common,
|
||||
..Default::default()
|
||||
}),
|
||||
};
|
||||
|
@ -716,7 +693,7 @@ impl ZoneConnection {
|
|||
}
|
||||
|
||||
pub fn get_player_common_spawn(
|
||||
&mut self,
|
||||
&self,
|
||||
exit_position: Option<Position>,
|
||||
exit_rotation: Option<f32>,
|
||||
) -> CommonSpawn {
|
||||
|
|
Loading…
Add table
Reference in a new issue