eliminate using namespace
This commit is contained in:
+59
-60
@@ -7,13 +7,11 @@
|
||||
#include "LevelTable.hh"
|
||||
#include "PSOProtocol.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct DefaultSymbolChatEntry {
|
||||
array<const char*, 8> language_to_name;
|
||||
std::array<const char*, 8> language_to_name;
|
||||
uint32_t spec;
|
||||
array<uint16_t, 4> corner_objects;
|
||||
array<SymbolChatFacePart, 12> face_parts;
|
||||
std::array<uint16_t, 4> corner_objects;
|
||||
std::array<SymbolChatFacePart, 12> face_parts;
|
||||
|
||||
SaveFileSymbolChatEntryBB to_entry(Language language) const {
|
||||
SaveFileSymbolChatEntryBB ret;
|
||||
@@ -30,7 +28,7 @@ struct DefaultSymbolChatEntry {
|
||||
}
|
||||
};
|
||||
|
||||
static const array<DefaultSymbolChatEntry, 6> DEFAULT_SYMBOL_CHATS = {
|
||||
static const std::array<DefaultSymbolChatEntry, 6> DEFAULT_SYMBOL_CHATS = {
|
||||
DefaultSymbolChatEntry{{"\tJ\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF", "\tEHello", "\tEHallo", "\tESalut", "\tEHola", "\tB\xE4\xBD\xA0\xE5\xA5\xBD", "\tT\xE4\xBD\xA0\xE5\xA5\xBD", "\tK\xEC\x95\x88\xEB\x85\x95"}, 0x28, {0xFFFF, 0x000D, 0xFFFF, 0xFFFF}, {SymbolChatFacePart{0x05, 0x18, 0x1D, 0x00}, {0x05, 0x28, 0x1D, 0x01}, {0x36, 0x20, 0x2A, 0x00}, {0x3C, 0x00, 0x32, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}}},
|
||||
DefaultSymbolChatEntry{{"\tJ\xE3\x81\x95\xE3\x82\x88\xE3\x81\x86\xE3\x81\xAA\xE3\x82\x89", "\tEGood-bye", "\tETschus", "\tEAu revoir", "\tEAdios", "\tB\xE5\x86\x8D\xE8\xA7\x81", "\tT\xE5\x86\x8D\xE8\xA6\x8B", "\tK\xEC\x9E\x98\xEA\xB0\x80"}, 0x74, {0x0476, 0x000C, 0xFFFF, 0xFFFF}, {SymbolChatFacePart{0x06, 0x15, 0x14, 0x00}, {0x06, 0x2B, 0x14, 0x01}, {0x05, 0x18, 0x1F, 0x00}, {0x05, 0x28, 0x1F, 0x01}, {0x36, 0x20, 0x2A, 0x00}, {0x3C, 0x00, 0x32, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}}},
|
||||
DefaultSymbolChatEntry{{"\tJ\xE3\x81\xB0\xE3\x82\x93\xE3\x81\x96\xE3\x83\xBC\xE3\x81\x84", "\tEHurrah!", "\tEHurra!", "\tEHourra !", "\tEHurra", "\tB\xE4\xB8\x87\xE5\xB2\x81", "\tT\xE8\x90\xAC\xE6\xAD\xB2", "\tK\xEB\xA7\x8C\xEC\x84\xB8"}, 0x28, {0x0362, 0x0362, 0xFFFF, 0xFFFF}, {SymbolChatFacePart{0x09, 0x16, 0x1B, 0x00}, {0x09, 0x2B, 0x1B, 0x01}, {0x37, 0x20, 0x2C, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}}},
|
||||
@@ -39,11 +37,11 @@ static const array<DefaultSymbolChatEntry, 6> DEFAULT_SYMBOL_CHATS = {
|
||||
DefaultSymbolChatEntry{{"\tJ\xE3\x81\x9F\xE3\x81\x99\xE3\x81\x91\xE3\x81\xA6\xEF\xBC\x81", "\tEHelp me!", "\tEHilf mir!", "\tEAide-moi !", "\tEAyuda", "\tB\xE6\x95\x91\xE5\x91\xBD\xE5\x95\x8A\xEF\xBC\x81", "\tT\xE6\x95\x91\xE5\x91\xBD\xE5\x95\x8A\xEF\xBC\x81", "\tK\xEB\x8F\x84\xEC\x99\x80\xEC\xA4\x98\xEF\xBC\x81"}, 0xEC, {0x065E, 0x0138, 0xFFFF, 0xFFFF}, {SymbolChatFacePart{0x02, 0x17, 0x1B, 0x01}, {0x02, 0x2A, 0x1B, 0x00}, {0x31, 0x20, 0x2C, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x00}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}, {0xFF, 0x00, 0x00, 0x02}}},
|
||||
};
|
||||
|
||||
static const array<uint16_t, 20> DEFAULT_TECH_MENU_CONFIG = {
|
||||
static const std::array<uint16_t, 20> DEFAULT_TECH_MENU_CONFIG = {
|
||||
0x0000, 0x0006, 0x0003, 0x0001, 0x0007, 0x0004, 0x0002, 0x0008, 0x0005, 0x0009,
|
||||
0x0012, 0x000F, 0x0010, 0x0011, 0x000D, 0x000A, 0x000B, 0x000C, 0x000E, 0x0000};
|
||||
|
||||
static const array<uint8_t, 0x016C> DEFAULT_KEY_CONFIG = {
|
||||
static const std::array<uint8_t, 0x016C> DEFAULT_KEY_CONFIG = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -68,7 +66,7 @@ static const array<uint8_t, 0x016C> DEFAULT_KEY_CONFIG = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
|
||||
|
||||
static const array<uint8_t, 0x0038> DEFAULT_JOYSTICK_CONFIG = {
|
||||
static const std::array<uint8_t, 0x0038> DEFAULT_JOYSTICK_CONFIG = {
|
||||
0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
@@ -88,7 +86,7 @@ ShuffleTables::ShuffleTables(PSOV2Encryption& crypt) {
|
||||
while (r28 >= 0) {
|
||||
uint32_t r3 = this->pseudorand(crypt, r28 + 1);
|
||||
if (r3 >= 0x100) {
|
||||
throw logic_error("bad r3");
|
||||
throw std::logic_error("bad r3");
|
||||
}
|
||||
uint8_t t = this->forward_table[r3];
|
||||
this->forward_table[r3] = *r31;
|
||||
@@ -144,7 +142,7 @@ bool PSOVMSFileHeader::checksum_correct() const {
|
||||
|
||||
void PSOVMSFileHeader::check() const {
|
||||
if (!this->checksum_correct()) {
|
||||
throw runtime_error("VMS file unencrypted header checksum is incorrect");
|
||||
throw std::runtime_error("VMS file unencrypted header checksum is incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,19 +163,19 @@ bool PSOGCIFileHeader::checksum_correct() const {
|
||||
|
||||
void PSOGCIFileHeader::check() const {
|
||||
if (!this->checksum_correct()) {
|
||||
throw runtime_error("GCI file unencrypted header checksum is incorrect");
|
||||
throw std::runtime_error("GCI file unencrypted header checksum is incorrect");
|
||||
}
|
||||
if (this->developer_id[0] != '8' || this->developer_id[1] != 'P') {
|
||||
throw runtime_error("GCI file is not for a Sega game");
|
||||
throw std::runtime_error("GCI file is not for a Sega game");
|
||||
}
|
||||
if ((this->game_id[0] != 'G') && (this->game_id[0] != 'D')) {
|
||||
throw runtime_error("GCI file is not for a GameCube game");
|
||||
throw std::runtime_error("GCI file is not for a GameCube game");
|
||||
}
|
||||
if (this->game_id[1] != 'P') {
|
||||
throw runtime_error("GCI file is not for Phantasy Star Online");
|
||||
throw std::runtime_error("GCI file is not for Phantasy Star Online");
|
||||
}
|
||||
if ((this->game_id[2] != 'S') && (this->game_id[2] != 'O')) {
|
||||
throw runtime_error("GCI file is not for Phantasy Star Online");
|
||||
throw std::runtime_error("GCI file is not for Phantasy Star Online");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,10 +213,10 @@ phosg::ImageRGB888 PSOGCSnapshotFile::decode_image() const {
|
||||
size_t width = this->width ? this->width.load() : 256;
|
||||
size_t height = this->height ? this->height.load() : 192;
|
||||
if (width != 256) {
|
||||
throw runtime_error("width is incorrect");
|
||||
throw std::runtime_error("width is incorrect");
|
||||
}
|
||||
if (height != 192) {
|
||||
throw runtime_error("height is incorrect");
|
||||
throw std::runtime_error("height is incorrect");
|
||||
}
|
||||
|
||||
// 4x4 blocks of pixels
|
||||
@@ -307,7 +305,7 @@ bool PSOXBFileHeader::checksum_correct() const {
|
||||
|
||||
void PSOXBFileHeader::check() const {
|
||||
if (!this->checksum_correct()) {
|
||||
throw runtime_error("Xbox file intermediate header checksum is incorrect");
|
||||
throw std::runtime_error("Xbox file intermediate header checksum is incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +320,7 @@ uint32_t PSOBBGuildCardFile::checksum() const {
|
||||
|
||||
void PSOBBGuildCardFile::delete_duplicates() {
|
||||
{
|
||||
unordered_set<uint32_t> seen;
|
||||
std::unordered_set<uint32_t> seen;
|
||||
size_t read_index = 0, write_index = 0;
|
||||
for (read_index = 0; read_index < this->blocked_senders.size(); read_index++) {
|
||||
const auto& read_blocked_senders = this->blocked_senders[read_index];
|
||||
@@ -339,7 +337,7 @@ void PSOBBGuildCardFile::delete_duplicates() {
|
||||
}
|
||||
|
||||
{
|
||||
unordered_set<uint32_t> seen;
|
||||
std::unordered_set<uint32_t> seen;
|
||||
size_t read_index = 0, write_index = 0;
|
||||
for (read_index = 0; read_index < this->entries.size(); read_index++) {
|
||||
const auto& read_entry = this->entries[read_index];
|
||||
@@ -377,13 +375,13 @@ PlayerDispDataBBPreview PSOBBCharacterFile::to_preview() const {
|
||||
return pre;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
uint32_t guild_card_number,
|
||||
Language language,
|
||||
const PlayerVisualConfig& visual,
|
||||
const std::string& name,
|
||||
shared_ptr<const LevelTable> level_table) {
|
||||
static const array<array<PlayerInventoryItem, 5>, 12> initial_inventory{{
|
||||
std::shared_ptr<const LevelTable> level_table) {
|
||||
static const std::array<std::array<PlayerInventoryItem, 5>, 12> initial_inventory{{
|
||||
{
|
||||
PlayerInventoryItem(ItemData(0x0001000000000000, 0x0000000000000000), true),
|
||||
PlayerInventoryItem(ItemData(0x0101000000000000, 0x0000000000000000), true),
|
||||
@@ -470,7 +468,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
},
|
||||
}};
|
||||
|
||||
static const array<uint8_t, 0xE8> config_hunter_ranger{
|
||||
static const std::array<uint8_t, 0xE8> config_hunter_ranger{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -486,7 +484,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
static const array<uint8_t, 0xE8> config_force{
|
||||
static const std::array<uint8_t, 0xE8> config_force{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -503,7 +501,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
|
||||
auto ret = make_shared<PSOBBCharacterFile>();
|
||||
auto ret = std::make_shared<PSOBBCharacterFile>();
|
||||
ret->disp.visual = visual;
|
||||
ret->disp.name.encode(name, language);
|
||||
|
||||
@@ -514,7 +512,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
}
|
||||
|
||||
// Set mag color based on initial costume
|
||||
static const array<array<uint8_t, 25>, 12> mag_colors = {{
|
||||
static const std::array<std::array<uint8_t, 25>, 12> mag_colors = {{
|
||||
{0x09, 0x01, 0x02, 0x11, 0x0A, 0x05, 0x06, 0x0B, 0x05, 0x00, 0x07, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x01, 0x02, 0x11, 0x04, 0x05, 0x06, 0x08, 0x11, 0x0D, 0x01, 0x02, 0x0C, 0x04, 0x05, 0x06, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x01, 0x02, 0x11, 0x04, 0x0E, 0x06, 0x01, 0x0E, 0x09, 0x07, 0x02, 0x11, 0x04, 0x05, 0x06, 0x04, 0x11, 0x0D, 0x01, 0x0B, 0x11, 0x0D, 0x05, 0x06},
|
||||
@@ -567,16 +565,16 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_config(
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_preview(
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_preview(
|
||||
uint32_t guild_card_number,
|
||||
Language language,
|
||||
const PlayerDispDataBBPreview& preview,
|
||||
shared_ptr<const LevelTable> level_table) {
|
||||
std::shared_ptr<const LevelTable> level_table) {
|
||||
return PSOBBCharacterFile::create_from_config(
|
||||
guild_card_number, language, preview.visual, preview.name.decode(language), level_table);
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCNTECharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCNTECharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
Language::JAPANESE,
|
||||
@@ -609,7 +607,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCN
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODC112000CharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODC112000CharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -652,7 +650,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODC1
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV1CharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV1CharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -685,7 +683,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV2CharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV2CharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -725,7 +723,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSODCV
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCNTECharacterFileCharacter& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCNTECharacterFileCharacter& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -765,7 +763,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCN
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCCharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCCharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -815,7 +813,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCC
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCEp3CharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCEp3CharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -863,7 +861,7 @@ shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOGCE
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOXBCharacterFile::Character& src) {
|
||||
std::shared_ptr<PSOBBCharacterFile> PSOBBCharacterFile::create_from_file(const PSOXBCharacterFile::Character& src) {
|
||||
auto ret = PSOBBCharacterFile::create_from_config(
|
||||
src.guild_card.guild_card_number,
|
||||
src.inventory.language,
|
||||
@@ -1178,24 +1176,24 @@ PSOBBCharacterFile::operator PSOXBCharacterFile::Character() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PSOCHARFile::LoadSharedResult PSOCHARFile::load_shared(const string& filename, bool load_system) {
|
||||
PSOCHARFile::LoadSharedResult PSOCHARFile::load_shared(const std::string& filename, bool load_system) {
|
||||
auto f = phosg::fopen_unique(filename, "rb");
|
||||
auto header = phosg::freadx<PSOCommandHeaderBB>(f.get());
|
||||
if (header.size != 0x399C) {
|
||||
throw runtime_error("incorrect size in character file header");
|
||||
throw std::runtime_error("incorrect size in character file header");
|
||||
}
|
||||
if (header.command != 0x00E7) {
|
||||
throw runtime_error("incorrect command in character file header");
|
||||
throw std::runtime_error("incorrect command in character file header");
|
||||
}
|
||||
if (header.flag != 0x00000000) {
|
||||
throw runtime_error("incorrect flag in character file header");
|
||||
throw std::runtime_error("incorrect flag in character file header");
|
||||
}
|
||||
static_assert(sizeof(PSOBBCharacterFile) + sizeof(PSOBBBaseSystemFile) + sizeof(PSOBBFullTeamMembership) == 0x3994, ".psochar size is incorrect");
|
||||
|
||||
LoadSharedResult ret;
|
||||
ret.character_file = make_shared<PSOBBCharacterFile>(phosg::freadx<PSOBBCharacterFile>(f.get()));
|
||||
ret.character_file = std::make_shared<PSOBBCharacterFile>(phosg::freadx<PSOBBCharacterFile>(f.get()));
|
||||
if (load_system) {
|
||||
ret.system_file = make_shared<PSOBBBaseSystemFile>(phosg::freadx<PSOBBBaseSystemFile>(f.get()));
|
||||
ret.system_file = std::make_shared<PSOBBBaseSystemFile>(phosg::freadx<PSOBBBaseSystemFile>(f.get()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1245,7 +1243,7 @@ void PSOBBCharacterFile::add_item(const ItemData& item, const ItemData::StackLim
|
||||
if (y < this->inventory.num_items) {
|
||||
size_t new_stack_size = this->inventory.items[y].data.data1[5] + item.data1[5];
|
||||
if (new_stack_size > combine_max) {
|
||||
throw out_of_range("stack is too large");
|
||||
throw std::out_of_range("stack is too large");
|
||||
}
|
||||
this->inventory.items[y].data.data1[5] = new_stack_size;
|
||||
return;
|
||||
@@ -1254,7 +1252,7 @@ void PSOBBCharacterFile::add_item(const ItemData& item, const ItemData::StackLim
|
||||
|
||||
// If we get here, then it's not meseta and not a combine item, so it needs to go into an empty inventory slot
|
||||
if (this->inventory.num_items >= 30) {
|
||||
throw out_of_range("inventory is full");
|
||||
throw std::out_of_range("inventory is full");
|
||||
}
|
||||
auto& inv_item = this->inventory.items[this->inventory.num_items];
|
||||
inv_item.state = 1;
|
||||
@@ -1285,7 +1283,7 @@ ItemData PSOBBCharacterFile::remove_item(uint32_t item_id, uint32_t amount, cons
|
||||
// if amount is nonzero.
|
||||
if (amount && (inventory_item.data.stack_size(limits) > 1) && (amount < inventory_item.data.data1[5])) {
|
||||
if (is_equipped) {
|
||||
throw runtime_error("character has a combine item equipped");
|
||||
throw std::runtime_error("character has a combine item equipped");
|
||||
}
|
||||
ret = inventory_item.data;
|
||||
ret.data1[5] = amount;
|
||||
@@ -1318,7 +1316,7 @@ ItemData PSOBBCharacterFile::remove_item(uint32_t item_id, uint32_t amount, cons
|
||||
}
|
||||
|
||||
void PSOBBCharacterFile::add_meseta(uint32_t amount) {
|
||||
this->disp.stats.meseta = min<size_t>(static_cast<size_t>(this->disp.stats.meseta) + amount, 999999);
|
||||
this->disp.stats.meseta = std::min<size_t>(static_cast<size_t>(this->disp.stats.meseta) + amount, 999999);
|
||||
}
|
||||
|
||||
void PSOBBCharacterFile::remove_meseta(uint32_t amount, bool allow_overdraft) {
|
||||
@@ -1327,7 +1325,7 @@ void PSOBBCharacterFile::remove_meseta(uint32_t amount, bool allow_overdraft) {
|
||||
} else if (allow_overdraft) {
|
||||
this->disp.stats.meseta = 0;
|
||||
} else {
|
||||
throw out_of_range("player does not have enough meseta");
|
||||
throw std::out_of_range("player does not have enough meseta");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1363,7 +1361,7 @@ uint8_t PSOBBCharacterFile::get_material_usage(MaterialType which) const {
|
||||
case MaterialType::LUCK:
|
||||
return this->inventory.items[8 + static_cast<uint8_t>(which)].extension_data2;
|
||||
default:
|
||||
throw logic_error("invalid material type");
|
||||
throw std::logic_error("invalid material type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1383,7 +1381,7 @@ void PSOBBCharacterFile::set_material_usage(MaterialType which, uint8_t usage) {
|
||||
this->inventory.items[8 + static_cast<uint8_t>(which)].extension_data2 = usage;
|
||||
break;
|
||||
default:
|
||||
throw logic_error("invalid material type");
|
||||
throw std::logic_error("invalid material type");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,29 +1488,30 @@ static uint16_t crc16(const void* data, size_t size) {
|
||||
return ret ^ 0xFFFF;
|
||||
}
|
||||
|
||||
string encode_psobb_hangame_credentials(const string& user_id, const string& token, const string& unused) {
|
||||
std::string encode_psobb_hangame_credentials(
|
||||
const std::string& user_id, const std::string& token, const std::string& unused) {
|
||||
if (user_id.size() < 4) {
|
||||
throw runtime_error("user_id must be at least 4 characters");
|
||||
throw std::runtime_error("user_id must be at least 4 characters");
|
||||
}
|
||||
if (user_id.size() > 12) {
|
||||
throw runtime_error("user_id must be at most 12 characters");
|
||||
throw std::runtime_error("user_id must be at most 12 characters");
|
||||
}
|
||||
if (!user_id.ends_with("@HG")) {
|
||||
throw runtime_error("user_id must end with \"@HG\"");
|
||||
throw std::runtime_error("user_id must end with \"@HG\"");
|
||||
}
|
||||
if (token.empty()) {
|
||||
throw runtime_error("token must not be empty");
|
||||
throw std::runtime_error("token must not be empty");
|
||||
}
|
||||
if (token.size() > 8) {
|
||||
throw runtime_error("token must be at most 8 characters");
|
||||
throw std::runtime_error("token must be at most 8 characters");
|
||||
}
|
||||
for (char ch : token) {
|
||||
if (!isdigit(ch)) {
|
||||
throw runtime_error("token must contain only decimal digits");
|
||||
throw std::runtime_error("token must contain only decimal digits");
|
||||
}
|
||||
}
|
||||
if (unused.size() > 0xFF) {
|
||||
throw runtime_error("unused must be at most 255 characters");
|
||||
throw std::runtime_error("unused must be at most 255 characters");
|
||||
}
|
||||
|
||||
// The encoded format is:
|
||||
@@ -1526,7 +1525,7 @@ string encode_psobb_hangame_credentials(const string& user_id, const string& tok
|
||||
// uint8_t unused_size;
|
||||
// char unused[unused_size]; // Ignored (possibly email address?)
|
||||
// We'll fill in mask_key and checksum after all the other fields.
|
||||
string data(7, '\0'); // mask_key, checksum, unused
|
||||
std::string data(7, '\0'); // mask_key, checksum, unused
|
||||
data.push_back(user_id.size());
|
||||
data += user_id;
|
||||
data.push_back(token.size());
|
||||
|
||||
Reference in New Issue
Block a user