clean up some player structs
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ Client::Client(
|
||||
|
||||
void Client::set_license(shared_ptr<const License> l) {
|
||||
this->license = l;
|
||||
this->game_data.serial_number = this->license->serial_number;
|
||||
this->game_data.guild_card_number = this->license->serial_number;
|
||||
if (this->version() == GameVersion::BB) {
|
||||
this->game_data.bb_username = this->license->username;
|
||||
}
|
||||
|
||||
@@ -3252,6 +3252,7 @@ struct G_ShopContents_BB_6xB6 {
|
||||
uint8_t shop_type;
|
||||
uint8_t num_items;
|
||||
le_uint16_t unused;
|
||||
// Note: data2d of these entries should be the price
|
||||
ItemData entries[20];
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ void player_use_item(shared_ptr<Client> c, size_t item_index) {
|
||||
// ssize_t equipped_shield = -1;
|
||||
// ssize_t equipped_mag = -1;
|
||||
for (size_t y = 0; y < c->game_data.player()->inventory.num_items; y++) {
|
||||
if (c->game_data.player()->inventory.items[y].equip_flags & 0x0008) {
|
||||
if (c->game_data.player()->inventory.items[y].flags & 0x00000008) {
|
||||
if (c->game_data.player()->inventory.items[y].data.data1[0] == 0) {
|
||||
equipped_weapon = y;
|
||||
}
|
||||
|
||||
+3
-4
@@ -11,7 +11,6 @@ using namespace std;
|
||||
|
||||
|
||||
LevelTable::LevelTable(const string& filename, bool compressed) {
|
||||
|
||||
string data = load_file(filename);
|
||||
if (compressed) {
|
||||
data = prs_decompress(data);
|
||||
@@ -31,7 +30,7 @@ const PlayerStats& LevelTable::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->base_stats[char_class];
|
||||
}
|
||||
|
||||
const LevelStats& LevelTable::stats_for_level(uint8_t char_class,
|
||||
const LevelTable::LevelStats& LevelTable::stats_for_level(uint8_t char_class,
|
||||
uint8_t level) const {
|
||||
if (char_class >= 12) {
|
||||
throw invalid_argument("invalid character class");
|
||||
@@ -42,12 +41,12 @@ const PlayerStats& LevelTable::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->levels[char_class][level];
|
||||
}
|
||||
|
||||
// Levels up a character by adding the level-up bonuses to the player's stats.
|
||||
void LevelStats::apply(PlayerStats& ps) const {
|
||||
void LevelTable::LevelStats::apply(PlayerStats& ps) const {
|
||||
ps.ata += this->ata;
|
||||
ps.atp += this->atp;
|
||||
ps.dfp += this->dfp;
|
||||
ps.evp += this->evp;
|
||||
ps.hp += this->hp;
|
||||
ps.mst += this->mst;
|
||||
ps.lck += this->lck;
|
||||
}
|
||||
|
||||
+16
-14
@@ -19,22 +19,21 @@ struct PlayerStats {
|
||||
PlayerStats() noexcept;
|
||||
} __attribute__((packed));
|
||||
|
||||
// information on a single level for a single class
|
||||
struct LevelStats {
|
||||
uint8_t atp; // atp to add on level up
|
||||
uint8_t mst; // mst to add on level up
|
||||
uint8_t evp; // evp to add on level up
|
||||
uint8_t hp; // hp to add on level up
|
||||
uint8_t dfp; // dfp to add on level up
|
||||
uint8_t ata; // ata to add on level up
|
||||
uint8_t unknown[2];
|
||||
le_uint32_t experience; // EXP value of this level
|
||||
struct LevelTable { // from PlyLevelTbl.prs
|
||||
struct LevelStats {
|
||||
uint8_t atp;
|
||||
uint8_t mst;
|
||||
uint8_t evp;
|
||||
uint8_t hp;
|
||||
uint8_t dfp;
|
||||
uint8_t ata;
|
||||
uint8_t lck;
|
||||
uint8_t tp;
|
||||
le_uint32_t experience;
|
||||
|
||||
void apply(PlayerStats& ps) const;
|
||||
} __attribute__((packed));
|
||||
void apply(PlayerStats& ps) const;
|
||||
} __attribute__((packed));
|
||||
|
||||
// level table format (PlyLevelTbl.prs)
|
||||
struct LevelTable {
|
||||
PlayerStats base_stats[12];
|
||||
le_uint32_t unknown[12];
|
||||
LevelStats levels[12][200];
|
||||
@@ -43,4 +42,7 @@ struct LevelTable {
|
||||
|
||||
const PlayerStats& base_stats_for_class(uint8_t char_class) const;
|
||||
const LevelStats& stats_for_level(uint8_t char_class, uint8_t level) const;
|
||||
|
||||
static std::shared_ptr<LevelTable> load_shared(
|
||||
const std::string& filename, bool compressed);
|
||||
} __attribute__((packed));
|
||||
|
||||
+2
-1
@@ -18,7 +18,8 @@ struct BattleParams {
|
||||
le_uint16_t dfp; // defense
|
||||
le_uint16_t ata; // accuracy
|
||||
le_uint16_t lck; // luck
|
||||
uint8_t unknown_a1[0x0E];
|
||||
le_uint16_t esp; // ???
|
||||
uint8_t unknown_a1[0x0C];
|
||||
le_uint32_t experience;
|
||||
le_uint32_t difficulty;
|
||||
} __attribute__((packed));
|
||||
|
||||
+4
-7
@@ -524,7 +524,7 @@ PlayerBB ClientGameData::export_player_bb() {
|
||||
ret.option_flags = account->option_flags;
|
||||
ret.quest_data1 = player->quest_data1;
|
||||
ret.bank = player->bank;
|
||||
ret.serial_number = this->serial_number;
|
||||
ret.guild_card_number = this->guild_card_number;
|
||||
ret.name = player->disp.name;
|
||||
ret.team_name = account->team_name;
|
||||
ret.guild_card_description = player->guild_card_description;
|
||||
@@ -657,14 +657,11 @@ PlayerInventoryItem::PlayerInventoryItem() {
|
||||
}
|
||||
|
||||
PlayerInventoryItem::PlayerInventoryItem(const PlayerBankItem& src)
|
||||
: tech_flag(0x0001), data(src.data) {
|
||||
this->equip_flags = (this->data.data1[0] > 2) ? 0x0044 : 0x0050;
|
||||
}
|
||||
: present(1), flags(0), data(src.data) { }
|
||||
|
||||
void PlayerInventoryItem::clear() {
|
||||
this->equip_flags = 0x0000;
|
||||
this->tech_flag = 0x0000;
|
||||
this->game_flags = 0x00000000;
|
||||
this->present = 0x00000000;
|
||||
this->flags = 0x00000000;
|
||||
this->data.clear();
|
||||
}
|
||||
|
||||
|
||||
+35
-34
@@ -36,9 +36,8 @@ struct ItemData { // 0x14 bytes
|
||||
struct PlayerBankItem;
|
||||
|
||||
struct PlayerInventoryItem { // 0x1C bytes
|
||||
le_uint16_t equip_flags;
|
||||
le_uint16_t tech_flag;
|
||||
le_uint32_t game_flags;
|
||||
le_uint32_t present;
|
||||
le_uint32_t flags; // 8 = equipped
|
||||
ItemData data;
|
||||
|
||||
PlayerInventoryItem();
|
||||
@@ -68,7 +67,7 @@ struct PlayerInventory { // 0x34C bytes
|
||||
size_t find_item(uint32_t item_id);
|
||||
} __attribute__((packed));
|
||||
|
||||
struct PlayerBank { // 0xFA8 bytes
|
||||
struct PlayerBank { // 0x12C8 bytes
|
||||
le_uint32_t num_items;
|
||||
le_uint32_t meseta;
|
||||
PlayerBankItem items[200];
|
||||
@@ -176,7 +175,7 @@ struct PlayerDispDataBB {
|
||||
le_uint32_t meseta;
|
||||
ptext<char, 0x10> guild_card;
|
||||
uint64_t unknown_a2;
|
||||
le_uint32_t name_color;
|
||||
le_uint32_t name_color; // ARGB8888
|
||||
uint8_t extra_model;
|
||||
parray<uint8_t, 0x0F> unused;
|
||||
le_uint32_t name_color_checksum;
|
||||
@@ -195,7 +194,9 @@ struct PlayerDispDataBB {
|
||||
le_uint16_t hair_b;
|
||||
le_float proportion_x;
|
||||
le_float proportion_y;
|
||||
ptext<char16_t, 0x10> name;
|
||||
ptext<char16_t, 0x0C> name;
|
||||
le_uint32_t play_time;
|
||||
uint32_t unknown_a3;
|
||||
parray<uint8_t, 0xE8> config;
|
||||
parray<uint8_t, 0x14> technique_levels;
|
||||
|
||||
@@ -262,7 +263,7 @@ struct KeyAndTeamConfigBB {
|
||||
parray<uint8_t, 0x0114> unknown_a1; // 0000
|
||||
parray<uint8_t, 0x016C> key_config; // 0114
|
||||
parray<uint8_t, 0x0038> joystick_config; // 0280
|
||||
le_uint32_t serial_number; // 02B8
|
||||
le_uint32_t guild_card_number; // 02B8
|
||||
le_uint32_t team_id; // 02BC
|
||||
le_uint64_t team_info; // 02C0
|
||||
le_uint16_t team_privilege_level; // 02C8
|
||||
@@ -413,31 +414,31 @@ struct PSOPlayerDataBB { // For command 61
|
||||
} __attribute__((packed));
|
||||
|
||||
struct PlayerBB { // Used in 00E7 command
|
||||
PlayerInventory inventory; // player
|
||||
PlayerDispDataBB disp; // player
|
||||
parray<uint8_t, 0x0010> unknown; // not saved
|
||||
le_uint32_t option_flags; // account
|
||||
parray<uint8_t, 0x0208> quest_data1; // player
|
||||
PlayerBank bank; // player
|
||||
le_uint32_t serial_number; // player
|
||||
ptext<char16_t, 0x18> name; // player
|
||||
ptext<char16_t, 0x10> team_name; // player
|
||||
ptext<char16_t, 0x58> guild_card_description; // player
|
||||
uint8_t reserved1; // player
|
||||
uint8_t reserved2; // player
|
||||
uint8_t section_id; // player
|
||||
uint8_t char_class; // player
|
||||
le_uint32_t unknown3; // not saved
|
||||
parray<uint8_t, 0x04E0> symbol_chats; // account
|
||||
parray<uint8_t, 0x0A40> shortcuts; // account
|
||||
ptext<char16_t, 0x00AC> auto_reply; // player
|
||||
ptext<char16_t, 0x00AC> info_board; // player
|
||||
parray<uint8_t, 0x001C> unknown5; // not saved
|
||||
parray<uint8_t, 0x0140> challenge_data; // player
|
||||
parray<uint8_t, 0x0028> tech_menu_config; // player
|
||||
parray<uint8_t, 0x002C> unknown6; // not saved
|
||||
parray<uint8_t, 0x0058> quest_data2; // player
|
||||
KeyAndTeamConfigBB key_config; // account
|
||||
PlayerInventory inventory; // 0000-034C; player
|
||||
PlayerDispDataBB disp; // 034C-04DC; player
|
||||
parray<uint8_t, 0x0010> unknown; // 04DC-04EC; not saved
|
||||
le_uint32_t option_flags; // 04EC-04F0; account
|
||||
parray<uint8_t, 0x0208> quest_data1; // 04F0-06F8; player
|
||||
PlayerBank bank; // 06F8-19C0; player
|
||||
le_uint32_t guild_card_number; // 19C0-19C4; player
|
||||
ptext<char16_t, 0x18> name; // 19C4-19F4; player
|
||||
ptext<char16_t, 0x10> team_name; // 19F4-1A14; player
|
||||
ptext<char16_t, 0x58> guild_card_description; // 1A14-1AC4; player
|
||||
uint8_t reserved1; // 1AC4-1AC5; player
|
||||
uint8_t reserved2; // 1AC5-1AC6; player
|
||||
uint8_t section_id; // 1AC6-1AC7; player
|
||||
uint8_t char_class; // 1AC7-1AC8; player
|
||||
le_uint32_t unknown3; // 1AC8-1ACC; not saved
|
||||
parray<uint8_t, 0x04E0> symbol_chats; // 1ACC-1FAC; account
|
||||
parray<uint8_t, 0x0A40> shortcuts; // 1FAC-29EC; account
|
||||
ptext<char16_t, 0x00AC> auto_reply; // 29EC-2B44; player
|
||||
ptext<char16_t, 0x00AC> info_board; // 2B44-2C9C; player
|
||||
parray<uint8_t, 0x001C> unknown5; // 2C9C-2CB8; not saved
|
||||
parray<uint8_t, 0x0140> challenge_data; // 2CB8-2DF8; player
|
||||
parray<uint8_t, 0x0028> tech_menu_config; // 2DF8-2E20; player
|
||||
parray<uint8_t, 0x002C> unknown6; // 2E20-2E4C; not saved
|
||||
parray<uint8_t, 0x0058> quest_data2; // 2E4C-2EA4; player
|
||||
KeyAndTeamConfigBB key_config; // 2EA4-3994; account
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
@@ -482,7 +483,7 @@ private:
|
||||
std::shared_ptr<SavedPlayerDataBB> player_data;
|
||||
|
||||
public:
|
||||
uint32_t serial_number;
|
||||
uint32_t guild_card_number;
|
||||
|
||||
// The following fields are not saved, and are only used in certain situations
|
||||
|
||||
@@ -499,7 +500,7 @@ public:
|
||||
std::vector<ItemData> shop_contents;
|
||||
bool should_save;
|
||||
|
||||
ClientGameData() : serial_number(0), bb_player_index(0), should_save(true) { }
|
||||
ClientGameData() : guild_card_number(0), bb_player_index(0), should_save(true) { }
|
||||
~ClientGameData();
|
||||
|
||||
std::shared_ptr<SavedAccountDataBB> account(bool should_load = true);
|
||||
|
||||
@@ -1723,7 +1723,7 @@ static void on_player_preview_request_bb(shared_ptr<ServerState>, shared_ptr<Cli
|
||||
}
|
||||
|
||||
ClientGameData temp_gd;
|
||||
temp_gd.serial_number = c->license->serial_number;
|
||||
temp_gd.guild_card_number = c->license->serial_number;
|
||||
temp_gd.bb_username = c->license->username;
|
||||
temp_gd.bb_player_index = cmd.player_index;
|
||||
|
||||
|
||||
+12
-16
@@ -318,9 +318,8 @@ static void on_subcommand_create_inventory_item(shared_ptr<ServerState>,
|
||||
|
||||
if (l->flags & Lobby::Flag::ITEM_TRACKING_ENABLED) {
|
||||
PlayerInventoryItem item;
|
||||
item.equip_flags = 0; // TODO: Use the right default flags here
|
||||
item.tech_flag = 0;
|
||||
item.game_flags = 0;
|
||||
item.present = 1;
|
||||
item.flags = 0;
|
||||
item.data = cmd->item;
|
||||
c->game_data.player()->add_item(item);
|
||||
|
||||
@@ -350,9 +349,8 @@ static void on_subcommand_drop_partial_stack(shared_ptr<ServerState>,
|
||||
// TODO: Should we delete anything from the inventory here? Does the client
|
||||
// send an appropriate 6x29 alongside this?
|
||||
PlayerInventoryItem item;
|
||||
item.equip_flags = 0; // TODO: Use the right default flags here
|
||||
item.tech_flag = 0;
|
||||
item.game_flags = 0;
|
||||
item.present = 1;
|
||||
item.flags = 0;
|
||||
item.data = cmd->data;
|
||||
l->add_item(item, cmd->area, cmd->x, cmd->z);
|
||||
|
||||
@@ -419,9 +417,8 @@ static void on_subcommand_buy_shop_item(shared_ptr<ServerState>,
|
||||
|
||||
if (l->flags & Lobby::Flag::ITEM_TRACKING_ENABLED) {
|
||||
PlayerInventoryItem item;
|
||||
item.equip_flags = 0; // TODO: Use the right default flags here
|
||||
item.tech_flag = 0;
|
||||
item.game_flags = 0;
|
||||
item.present = 1;
|
||||
item.flags = 0;
|
||||
item.data = cmd->item;
|
||||
c->game_data.player()->add_item(item);
|
||||
|
||||
@@ -447,9 +444,8 @@ static void on_subcommand_box_or_enemy_item_drop(shared_ptr<ServerState>,
|
||||
}
|
||||
|
||||
PlayerInventoryItem item;
|
||||
item.equip_flags = 0; // TODO: Use the right default flags here
|
||||
item.tech_flag = 0;
|
||||
item.game_flags = 0;
|
||||
item.present = 1;
|
||||
item.flags = 0;
|
||||
item.data = cmd->data;
|
||||
l->add_item(item, cmd->area, cmd->x, cmd->z);
|
||||
|
||||
@@ -526,10 +522,10 @@ static void on_subcommand_equip_unequip_item(shared_ptr<ServerState>,
|
||||
|
||||
if (l->flags & Lobby::Flag::ITEM_TRACKING_ENABLED) {
|
||||
size_t index = c->game_data.player()->inventory.find_item(cmd->item_id);
|
||||
if (cmd->command == 0x25) {
|
||||
c->game_data.player()->inventory.items[index].equip_flags |= 0x00000008; // equip
|
||||
} else {
|
||||
c->game_data.player()->inventory.items[index].equip_flags &= 0xFFFFFFF7; // unequip
|
||||
if (cmd->command == 0x25) { // equip
|
||||
c->game_data.player()->inventory.items[index].flags |= 0x00000008;
|
||||
} else { // unequip
|
||||
c->game_data.player()->inventory.items[index].flags &= 0xFFFFFFF7;
|
||||
}
|
||||
} else if (l->version == GameVersion::BB) {
|
||||
throw logic_error("item tracking not enabled in BB game");
|
||||
|
||||
+1
-1
@@ -1476,7 +1476,7 @@ void send_level_up(shared_ptr<Lobby> l, shared_ptr<Client> c) {
|
||||
PlayerStats stats = c->game_data.player()->disp.stats;
|
||||
|
||||
for (size_t x = 0; x < c->game_data.player()->inventory.num_items; x++) {
|
||||
if ((c->game_data.player()->inventory.items[x].equip_flags & 0x08) &&
|
||||
if ((c->game_data.player()->inventory.items[x].flags & 0x08) &&
|
||||
(c->game_data.player()->inventory.items[x].data.data1[0] == 0x02)) {
|
||||
stats.dfp += (c->game_data.player()->inventory.items[x].data.data1w[2] / 100);
|
||||
stats.atp += (c->game_data.player()->inventory.items[x].data.data1w[3] / 50);
|
||||
|
||||
Reference in New Issue
Block a user