1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-22 23:27:46 +00:00

Send a (currently hardcoded) list of equipped items to the client

This commit is contained in:
Joshua Goins 2025-03-23 17:10:47 -04:00
parent 48b1b9cdc2
commit a36c6dff90
2 changed files with 90 additions and 3 deletions

View file

@ -11,9 +11,10 @@ use kawari::packet::{
send_packet, send_packet,
}; };
use kawari::world::ipc::{ use kawari::world::ipc::{
ClientZoneIpcData, CommonSpawn, DisplayFlag, GameMasterCommandType, GameMasterRank, ObjectKind, ClientZoneIpcData, CommonSpawn, ContainerInfo, ContainerType, DisplayFlag,
OnlineStatus, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, ServerZoneIpcType, GameMasterCommandType, GameMasterRank, ItemInfo, ObjectKind, OnlineStatus, PlayerSubKind,
SocialListRequestType, StatusEffect, ServerZoneIpcData, ServerZoneIpcSegment, ServerZoneIpcType, SocialListRequestType,
StatusEffect,
}; };
use kawari::world::{ use kawari::world::{
ChatHandler, Zone, ZoneConnection, ChatHandler, Zone, ZoneConnection,
@ -188,6 +189,76 @@ async fn main() {
.await; .await;
} }
let item_ids = [
(12, 0x00003b1d),
(11, 0x0000114a),
(10, 0x00003b1c),
(9, 0x00003b1a),
(8, 0x00003b1b),
(7, 0x00000ea7),
(6, 0x00000ce1),
(4, 0x00000dc1),
(3, 0x00000ba8),
(0, 0x00000641),
];
// send inventory
{
for (slot, id) in &item_ids {
let ipc = ServerZoneIpcSegment {
op_code: ServerZoneIpcType::ItemInfo,
timestamp: timestamp_secs(),
data: ServerZoneIpcData::ItemInfo(ItemInfo {
container: ContainerType::Equipped,
slot: *slot,
quantity: 1,
catalog_id: *id,
condition: 30000,
..Default::default()
}),
..Default::default()
};
connection
.send_segment(PacketSegment {
source_actor: connection
.player_data
.actor_id,
target_actor: connection
.player_data
.actor_id,
segment_type: SegmentType::Ipc {
data: ipc,
},
})
.await;
}
}
// inform the client they have 10 items equipped
{
let ipc = ServerZoneIpcSegment {
op_code: ServerZoneIpcType::ContainerInfo,
timestamp: timestamp_secs(),
data: ServerZoneIpcData::ContainerInfo(
ContainerInfo {
container: ContainerType::Equipped,
num_items: item_ids.len() as u32,
..Default::default()
},
),
..Default::default()
};
connection
.send_segment(PacketSegment {
source_actor: connection.player_data.actor_id,
target_actor: connection.player_data.actor_id,
segment_type: SegmentType::Ipc { data: ipc },
})
.await;
}
// Control Data // Control Data
{ {
let ipc = ServerZoneIpcSegment { let ipc = ServerZoneIpcSegment {

View file

@ -108,6 +108,8 @@ impl ReadWriteIpcSegment for ServerZoneIpcSegment {
ServerZoneIpcType::NpcSpawn => 648, ServerZoneIpcType::NpcSpawn => 648,
ServerZoneIpcType::StatusEffectList => 384, ServerZoneIpcType::StatusEffectList => 384,
ServerZoneIpcType::WeatherChange => 8, ServerZoneIpcType::WeatherChange => 8,
ServerZoneIpcType::ItemInfo => 64,
ServerZoneIpcType::ContainerInfo => 16,
} }
} }
} }
@ -199,6 +201,10 @@ pub enum ServerZoneIpcType {
StatusEffectList = 0xBB, StatusEffectList = 0xBB,
// Sent by the server when it's time to change the weather // Sent by the server when it's time to change the weather
WeatherChange = 0x110, WeatherChange = 0x110,
// Sent to inform the client of an inventory item
ItemInfo = 0x3AA,
// Sent to inform the client of container status
ContainerInfo = 0x2EA,
} }
#[binrw] #[binrw]
@ -315,6 +321,8 @@ pub enum ServerZoneIpcData {
NpcSpawn(NpcSpawn), NpcSpawn(NpcSpawn),
StatusEffectList(StatusEffectList), StatusEffectList(StatusEffectList),
WeatherChange(WeatherChange), WeatherChange(WeatherChange),
ItemInfo(ItemInfo),
ContainerInfo(ContainerInfo),
} }
#[binrw] #[binrw]
@ -483,6 +491,14 @@ mod tests {
ServerZoneIpcType::ActorControl, ServerZoneIpcType::ActorControl,
ServerZoneIpcData::ActorControl(ActorControl::default()), ServerZoneIpcData::ActorControl(ActorControl::default()),
), ),
(
ServerZoneIpcType::ItemInfo,
ServerZoneIpcData::ItemInfo(ItemInfo::default()),
),
(
ServerZoneIpcType::ContainerInfo,
ServerZoneIpcData::ContainerInfo(ContainerInfo::default()),
),
]; ];
for (opcode, data) in &ipc_types { for (opcode, data) in &ipc_types {