Browse Source

match libpso changes

pull/144/head
jake 1 year ago
parent
commit
b18ab064fa
  1. 2
      Cargo.toml
  2. 2
      src/entity/src/character.rs
  3. 2
      src/entity/src/gateway/postgres/models.rs
  4. 8
      src/login_server/src/character.rs
  5. 2
      src/pktbuilder/src/character.rs
  6. 2
      src/pktbuilder/src/lib.rs
  7. 16
      src/pktbuilder/src/quest.rs
  8. 4
      src/pktbuilder/src/ship.rs
  9. 2
      src/ship_server/src/communication.rs
  10. 6
      src/ship_server/src/direct_message.rs
  11. 4
      src/ship_server/src/room.rs
  12. 10
      tests/common.rs

2
Cargo.toml

@ -42,7 +42,7 @@ patch_server = { path = "./src/patch_server" }
login_server = { path = "./src/login_server" }
ship_server = { path = "./src/ship_server" }
libpso = { git = "http://git.sharnoth.com/jake/libpso" }
libpso = { git = "http://git.sharnoth.com/jake/libpso", rev="90246b6" }
async-std = { version = "1.9.0", features = ["unstable", "attributes"] }
futures = "0.3.5"

2
src/entity/src/character.rs

@ -223,7 +223,7 @@ impl CharacterInfoboard {
}
pub fn update_infoboard(&mut self, new_board: &WriteInfoboard) {
self.board = libpso::utf8_to_utf16_array!(new_board.message, 172);
self.board = libpso::util::utf8_to_utf16_array(&new_board.message);
}
}

2
src/entity/src/gateway/postgres/models.rs

@ -253,7 +253,7 @@ impl From<PgCharacter> for CharacterEntity {
raw_data: vec_to_array(other.config)
},
info_board: CharacterInfoboard {
board: libpso::utf8_to_utf16_array!(other.infoboard, 172),
board: libpso::util::utf8_to_utf16_array(other.infoboard),
},
guildcard: CharacterGuildCard {
description: other.guildcard,

8
src/login_server/src/character.rs

@ -19,7 +19,7 @@ use networking::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use networking::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use networking::interserver::{ServerId, InterserverActor, LoginMessage, ShipMessage, Ship};
use stats::leveltable::LEVEL_TABLE;
use libpso::{utf8_to_array, utf8_to_utf16_array};
use libpso::util::{utf8_to_array, utf8_to_utf16_array};
use entity::gateway::{EntityGateway, GatewayError};
use entity::account::{UserAccountId, UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
@ -150,7 +150,7 @@ fn generate_param_data(path: &str) -> (ParamDataHeader, Vec<u8>) {
size: len as u32,
checksum: crc.sum32(),
offset: buffer.len() as u32,
filename: utf8_to_array!(param.file_name().unwrap().to_str().unwrap(), 0x40),
filename: utf8_to_array(param.file_name().unwrap().to_str().unwrap()),
});
buffer.append(&mut filebuf);
@ -379,7 +379,7 @@ impl<EG: EntityGateway + Clone> CharacterServerState<EG> {
menu: SHIP_MENU_ID,
item: i.0 as u32,
flags: 0,
name: utf8_to_utf16_array!(s.name, 0x11)
name: utf8_to_utf16_array(&s.name)
}
}).collect()))
])
@ -824,7 +824,7 @@ impl<'a> SelectScreenCharacterBuilder<'a> {
hair_b: character.appearance.hair_b,
prop_x: character.appearance.prop_x,
prop_y: character.appearance.prop_y,
name: utf8_to_utf16_array!(character.name, 16),
name: utf8_to_utf16_array(&character.name),
play_time: character.playtime,
..character::SelectScreenCharacter::default()
}

2
src/pktbuilder/src/character.rs

@ -53,7 +53,7 @@ impl<'a> CharacterBytesBuilder<'a> {
let level = self.level.unwrap();
let meseta = self.meseta.unwrap();
character::Character {
name: libpso::utf8_to_utf16_array!(character.name, 16),
name: libpso::util::utf8_to_utf16_array(&character.name),
hp: stats.hp,
atp: stats.atp + character.materials.power as u16 * 2,
mst: stats.mst + character.materials.mind as u16 * 2,

2
src/pktbuilder/src/lib.rs

@ -19,7 +19,7 @@ pub fn player_header(tag: u32, client: &ClientState, area_client: &AreaClient) -
guildcard: client.user.id.0,
_unknown1: [0; 5],
client_id: area_client.local_client.id() as u32,
name: libpso::utf8_to_utf16_array!(client.character.name, 16),
name: libpso::util::utf8_to_utf16_array(&client.character.name),
_unknown2: 2,
}
}

16
src/pktbuilder/src/quest.rs

@ -1,6 +1,6 @@
use quests::{Quest, QuestList};
use libpso::packet::ship::*;
use libpso::{utf8_to_array, utf8_to_utf16_array};
use libpso::util::{utf8_to_array, utf8_to_utf16_array};
pub const QUEST_CATEGORY_MENU_ID: u32 = 0xA2;
pub const QUEST_SELECT_MENU_ID: u32 = 0xA3;
@ -12,8 +12,8 @@ pub fn quest_category_list(quests: &QuestList) -> QuestCategoryList {
QuestCategory {
menu_id: QUEST_CATEGORY_MENU_ID,
option_id: i as u32,
name: utf8_to_utf16_array!(category.name, 32),
description: utf8_to_utf16_array!(category.description, 122),
name: utf8_to_utf16_array(&category.name),
description: utf8_to_utf16_array(&category.description),
}
})
.collect();
@ -30,8 +30,8 @@ pub fn quest_list(category_id: u32, quests: &[Quest]) -> QuestOptionList {
menu_id: QUEST_SELECT_MENU_ID,
category_id: category_id as u16,
quest_id: quest.id,
name: utf8_to_utf16_array!(quest.name, 32),
description: utf8_to_utf16_array!(quest.description, 122),
name: utf8_to_utf16_array(&quest.name),
description: utf8_to_utf16_array(&quest.description),
}
})
.collect();
@ -43,7 +43,7 @@ pub fn quest_list(category_id: u32, quests: &[Quest]) -> QuestOptionList {
pub fn quest_detail(quest: &Quest) -> QuestDetail {
QuestDetail {
description: utf8_to_utf16_array!(quest.full_description, 288),
description: utf8_to_utf16_array(&quest.full_description),
}
}
@ -51,9 +51,9 @@ pub fn quest_header(quest_menu_select: &QuestMenuSelect, data_blob: &[u8], suffi
let path = format!("{}-{}.{}", quest_menu_select.category, quest_menu_select.quest, suffix);
QuestHeader {
unknown1: [0; 0x24],
filename: utf8_to_array!(path, 16),
filename: utf8_to_array(&path),
length: data_blob.len() as u32,
name: utf8_to_array!(path, 16),
name: utf8_to_array(&path),
unknown2: [0; 8],
}
}

4
src/pktbuilder/src/ship.rs

@ -1,5 +1,5 @@
use libpso::packet::login::{ShipList, ShipListEntry};
use libpso::utf8_to_utf16_array;
use libpso::util::utf8_to_utf16_array;
use networking::interserver::Ship;
@ -13,7 +13,7 @@ pub fn ship_list(ships: &[Ship]) -> ShipList {
menu: SHIP_MENU_ID,
item: i as u32,
flags: 0,
name: utf8_to_utf16_array!(ship.name, 0x11)
name: utf8_to_utf16_array(&ship.name)
}
})
.collect();

2
src/ship_server/src/communication.rs

@ -32,7 +32,7 @@ pub async fn request_infoboard(id: ClientId,
.map(|client| async {
clients.with(client.client, |client| Box::pin(async move {
InfoboardResponse {
name: libpso::utf8_to_utf16_array!(client.character.name, 16),
name: libpso::util::utf8_to_utf16_array(&client.character.name),
message: client.character.info_board.as_bytes(),
}
})).await

6
src/ship_server/src/direct_message.rs

@ -13,7 +13,7 @@ use room::Rooms;
use items::ClientItemId;
use entity::gateway::EntityGateway;
use entity::item;
use libpso::utf8_to_utf16_array;
use libpso::util::utf8_to_utf16_array;
use pktbuilder as builder;
use shops::{ItemShops, ShopItem, ToolShopItem, ArmorShopItem};
use items::state::{ItemState, ItemStateError};
@ -64,9 +64,9 @@ pub async fn guildcard_send(id: ClientId,
client: guildcard_send.client,
target: guildcard_send.target,
guildcard: client.user.id.0,
name: utf8_to_utf16_array!(client.character.name, 0x18),
name: utf8_to_utf16_array(&client.character.name),
team: [0; 0x10], // TODO: teams not yet implemented
desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),
desc: utf8_to_utf16_array(&client.character.guildcard.description),
one: 1,
language: 0, // TODO: add language flag to character
section_id: client.character.section_id.into(),

4
src/ship_server/src/room.rs

@ -260,7 +260,7 @@ pub async fn request_room_list(id: ClientId,
.filter_map(|(i, r)| async move {
r.as_ref().map(|room| {
let difficulty = room.get_difficulty_for_room_list();
let name = libpso::utf8_to_utf16_array!(room.name, 16);
let name = libpso::util::utf8_to_utf16_array(&room.name);
let episode = room.get_episode_for_room_list();
let flags = room.get_flags_for_room_list();
async move {
@ -280,7 +280,7 @@ pub async fn request_room_list(id: ClientId,
item_id: ROOM_MENU_ID,
difficulty: 0x00,
players: 0x00,
name: libpso::utf8_to_utf16_array!("Room list menu", 16),
name: libpso::util::utf8_to_utf16_array("Room list menu"),
episode: 0,
flags: 0,
};

10
tests/common.rs

@ -19,7 +19,7 @@ use entity::item;
use libpso::packet::ship::*;
use libpso::packet::login::{Login, Session};
use libpso::{utf8_to_array, utf8_to_utf16_array};
use libpso::util::{utf8_to_array, utf8_to_utf16_array};
fn null_quest_builder(_mode: RoomMode) -> Result<QuestList, QuestLoadError> {
Ok(Default::default())
@ -107,9 +107,9 @@ pub async fn log_in_char<EG: EntityGateway + Clone>(ship: &mut ShipServerState<E
version: 0,
unknown1: [0; 6],
team: 0,
username: utf8_to_array!(username, 16),
username: utf8_to_array(&username),
unknown2: [0; 32],
password: utf8_to_array!(password, 16),
password: utf8_to_array(&password),
unknown3: [0; 40],
hwinfo: [0; 8],
session: Session::new(),
@ -136,8 +136,8 @@ pub async fn leave_room<EG: EntityGateway + Clone>(ship: &mut ShipServerState<EG
pub async fn create_room_with_difficulty<EG: EntityGateway + Clone>(ship: &mut ShipServerState<EG>, id: ClientId, name: &str, password: &str, difficulty: Difficulty) {
ship.handle(id, RecvShipPacket::CreateRoom(CreateRoom {
unknown: [0; 2],
name: utf8_to_utf16_array!(name, 16),
password: utf8_to_utf16_array!(password, 16),
name: utf8_to_utf16_array(name),
password: utf8_to_utf16_array(password),
difficulty: difficulty.into(),
battle: 0,
challenge: 0,

Loading…
Cancel
Save