Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/world-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4666,6 +4666,7 @@ async fn main() -> Result<ExitCode> {
addon_channel: world_config_bool(&world_configs, "CONFIG_ADDON_CHANNEL", true),
server_expansion: world_config_u8(&world_configs, "CONFIG_EXPANSION", 2),
characters_per_realm: world_config_u32(&world_configs, "CONFIG_CHARACTERS_PER_REALM", 60),
declined_names_used: world_config_bool(&world_configs, "CONFIG_DECLINED_NAMES_USED", false),
feature_system_bpay_store_enabled: world_config_bool(
&world_configs,
"CONFIG_FEATURE_SYSTEM_BPAY_STORE_ENABLED",
Expand Down Expand Up @@ -11826,6 +11827,7 @@ async fn create_session(
session.set_addon_channel_like_cpp(resources.addon_channel);
session.set_server_expansion_like_cpp(resources.server_expansion);
session.set_characters_per_realm_like_cpp(resources.characters_per_realm);
session.set_declined_names_used_like_cpp(resources.declined_names_used);
session.set_feature_system_bpay_store_enabled_like_cpp(
resources.feature_system_bpay_store_enabled,
);
Expand Down
2 changes: 2 additions & 0 deletions crates/wow-network/src/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ pub struct SessionResources {
pub server_expansion: u8,
/// C++ `CONFIG_CHARACTERS_PER_REALM` / `CharactersPerRealm`.
pub characters_per_realm: u32,
/// C++ `CONFIG_DECLINED_NAMES_USED` / `DeclinedNames`.
pub declined_names_used: bool,
/// C++ `CONFIG_FEATURE_SYSTEM_BPAY_STORE_ENABLED`.
pub feature_system_bpay_store_enabled: bool,
/// C++ `CONFIG_FEATURE_SYSTEM_CHARACTER_UNDELETE_ENABLED`.
Expand Down
39 changes: 35 additions & 4 deletions crates/wow-packet/src/packets/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ impl ServerPacket for EnumCharactersResult {
const OPCODE: ServerOpcodes = ServerOpcodes::EnumCharactersResult;

fn write(&self, pkt: &mut WorldPacket) {
// Bit flags (from C# EnumCharactersResult.Write)
// C++ `WorldPackets::Character::EnumCharactersResult::Write`
// writes these presence/status bits before the fixed count block.
pkt.write_bit(self.success);
pkt.write_bit(false); // IsDeletedCharacters
pkt.write_bit(false); // IsNewPlayerRestrictionSkipped
Expand All @@ -156,7 +157,7 @@ impl ServerPacket for EnumCharactersResult {
// No UnlockedConditionalAppearances (count=0)
// No RaceLimitDisables (count=0)

// Write each character (from C# CharacterInfo.Write)
// Write each character like C++ `EnumCharactersResult::CharacterInfo`.
for ch in &self.characters {
pkt.write_packed_guid(&ch.guid);
pkt.write_uint64(ch.guild_club_member_id);
Expand Down Expand Up @@ -222,7 +223,7 @@ impl ServerPacket for EnumCharactersResult {
pkt.write_string(&ch.name);
}

// RaceUnlockData (C# CharacterPackets.cs RaceUnlock.Write)
// C++ `EnumCharactersResult::RaceUnlock` writes RaceID followed by four bits.
for ru in &self.race_unlock_data {
pkt.write_int32(ru.race_id as i32);
pkt.write_bit(ru.has_expansion);
Expand Down Expand Up @@ -694,7 +695,7 @@ impl ServerPacket for CharCustomizeFailure {

// ── Response codes ──────────────────────────────────────────────────

/// Result codes for character operations (values from ResponseCodes enum in C#).
/// Result codes for character operations (`SharedDefines.h` `ResponseCodes`).
#[allow(dead_code)]
pub mod response_codes {
// Character creation results
Expand Down Expand Up @@ -755,6 +756,36 @@ mod tests {
assert!(bytes.len() > 2);
}

#[test]
fn enum_characters_result_preserves_pet_data_field_order_like_cpp() {
let character = CharacterInfo {
name: "Petowner".to_string(),
pet_display_id: 0x1122_3344,
pet_level: 0x5566_7788,
pet_family: 0x99aa_bbcc,
..CharacterInfo::default()
};
let bytes = EnumCharactersResult {
success: true,
characters: vec![character],
race_unlock_data: vec![],
}
.to_bytes();

let pet_sequence = [
0x44, 0x33, 0x22, 0x11, // PetCreatureDisplayID
0x88, 0x77, 0x66, 0x55, // PetExperienceLevel
0xcc, 0xbb, 0xaa, 0x99, // PetCreatureFamilyID
];
assert_eq!(
bytes
.windows(pet_sequence.len())
.filter(|window| *window == pet_sequence)
.count(),
1
);
}

#[test]
fn create_char_response_roundtrip() {
let resp = CreateChar {
Expand Down
Loading
Loading