Sync from and adapt to upstream 20260514
Sync/upstream 20260514
This commit is contained in:
+224
-12
@@ -9,6 +9,191 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
BattleParamsIndex::AttackData BattleParamsIndex::AttackData::from_json(const phosg::JSON& json) {
|
||||
return AttackData{
|
||||
json.get_int("MinATP"),
|
||||
json.get_int("MaxATP"),
|
||||
json.get_int("MinATA"),
|
||||
json.get_int("MaxATA"),
|
||||
json.get_float("DistanceX"),
|
||||
json.get_int("Angle"),
|
||||
json.get_float("DistanceY"),
|
||||
json.get_int("UnknownA8"),
|
||||
json.get_int("UnknownA9"),
|
||||
json.get_int("UnknownA10"),
|
||||
json.get_int("UnknownA11"),
|
||||
json.get_int("UnknownA12"),
|
||||
json.get_int("UnknownA13"),
|
||||
json.get_int("UnknownA14"),
|
||||
json.get_int("UnknownA15"),
|
||||
json.get_int("UnknownA16"),
|
||||
};
|
||||
}
|
||||
phosg::JSON BattleParamsIndex::AttackData::json() const {
|
||||
return phosg::JSON::dict({
|
||||
{"MinATP", this->min_atp.load()},
|
||||
{"MaxATP", this->max_atp.load()},
|
||||
{"MinATA", this->min_ata.load()},
|
||||
{"MaxATA", this->max_ata.load()},
|
||||
{"DistanceX", this->distance_x.load()},
|
||||
{"Angle", this->angle.load()},
|
||||
{"DistanceY", this->distance_y.load()},
|
||||
{"UnknownA8", this->unknown_a8.load()},
|
||||
{"UnknownA9", this->unknown_a9.load()},
|
||||
{"UnknownA10", this->unknown_a10.load()},
|
||||
{"UnknownA11", this->unknown_a11.load()},
|
||||
{"UnknownA12", this->unknown_a12.load()},
|
||||
{"UnknownA13", this->unknown_a13.load()},
|
||||
{"UnknownA14", this->unknown_a14.load()},
|
||||
{"UnknownA15", this->unknown_a15.load()},
|
||||
{"UnknownA16", this->unknown_a16.load()},
|
||||
});
|
||||
}
|
||||
|
||||
BattleParamsIndex::ResistData BattleParamsIndex::ResistData::from_json(const phosg::JSON& json) {
|
||||
return BattleParamsIndex::ResistData{
|
||||
json.get_int("EVPBonus"),
|
||||
json.get_int("EFR"),
|
||||
json.get_int("EIC"),
|
||||
json.get_int("ETH"),
|
||||
json.get_int("ELT"),
|
||||
json.get_int("EDK"),
|
||||
json.get_int("UnknownA6"),
|
||||
json.get_int("UnknownA7"),
|
||||
json.get_int("UnknownA8"),
|
||||
json.get_int("UnknownA9"),
|
||||
json.get_int("DFPBonus"),
|
||||
};
|
||||
}
|
||||
phosg::JSON BattleParamsIndex::ResistData::json() const {
|
||||
return phosg::JSON::dict({
|
||||
{"EVPBonus", this->evp_bonus.load()},
|
||||
{"EFR", this->efr.load()},
|
||||
{"EIC", this->eic.load()},
|
||||
{"ETH", this->eth.load()},
|
||||
{"ELT", this->elt.load()},
|
||||
{"EDK", this->edk.load()},
|
||||
{"UnknownA6", this->unknown_a6.load()},
|
||||
{"UnknownA7", this->unknown_a7.load()},
|
||||
{"UnknownA8", this->unknown_a8.load()},
|
||||
{"UnknownA9", this->unknown_a9.load()},
|
||||
{"DFPBonus", this->dfp_bonus.load()},
|
||||
});
|
||||
}
|
||||
|
||||
BattleParamsIndex::MovementData BattleParamsIndex::MovementData::from_json(const phosg::JSON& json) {
|
||||
const auto& fparams_json = json.at("FParams").as_list();
|
||||
const auto& iparams_json = json.at("IParams").as_list();
|
||||
return BattleParamsIndex::MovementData{
|
||||
fparams_json.at(0)->as_float(),
|
||||
fparams_json.at(1)->as_float(),
|
||||
fparams_json.at(2)->as_float(),
|
||||
fparams_json.at(3)->as_float(),
|
||||
fparams_json.at(4)->as_float(),
|
||||
fparams_json.at(5)->as_float(),
|
||||
iparams_json.at(0)->as_float(),
|
||||
iparams_json.at(1)->as_float(),
|
||||
iparams_json.at(2)->as_float(),
|
||||
iparams_json.at(3)->as_float(),
|
||||
iparams_json.at(4)->as_float(),
|
||||
iparams_json.at(5)->as_float(),
|
||||
};
|
||||
}
|
||||
phosg::JSON BattleParamsIndex::MovementData::json() const {
|
||||
auto fparams_list = phosg::JSON::list({
|
||||
this->fparam1.load(),
|
||||
this->fparam2.load(),
|
||||
this->fparam3.load(),
|
||||
this->fparam4.load(),
|
||||
this->fparam5.load(),
|
||||
this->fparam6.load(),
|
||||
});
|
||||
auto iparams_list = phosg::JSON::list({
|
||||
this->iparam1.load(),
|
||||
this->iparam2.load(),
|
||||
this->iparam3.load(),
|
||||
this->iparam4.load(),
|
||||
this->iparam5.load(),
|
||||
this->iparam6.load(),
|
||||
});
|
||||
return phosg::JSON::dict({{"FParams", std::move(fparams_list)}, {"IParams", std::move(iparams_list)}});
|
||||
}
|
||||
|
||||
BattleParamsIndex::Table BattleParamsIndex::Table::from_json(const phosg::JSON& json) {
|
||||
BattleParamsIndex::Table ret;
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
const auto& diff_json = json.at(name_for_difficulty(difficulty));
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
const auto& entry_json = diff_json.at(z);
|
||||
ret.stats[static_cast<size_t>(difficulty)][z] = PlayerStats::from_json(entry_json.at("Stats"));
|
||||
ret.attack_data[static_cast<size_t>(difficulty)][z] = AttackData::from_json(entry_json.at("AttackData"));
|
||||
ret.resist_data[static_cast<size_t>(difficulty)][z] = ResistData::from_json(entry_json.at("ResistData"));
|
||||
ret.movement_data[static_cast<size_t>(difficulty)][z] = MovementData::from_json(entry_json.at("MovementData"));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
phosg::JSON BattleParamsIndex::Table::json() const {
|
||||
auto ret = phosg::JSON::dict();
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
auto diff_ret = phosg::JSON::list();
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
auto stats_json = this->stats_for_index(difficulty, z).json();
|
||||
auto attack_data_json = this->attack_data_for_index(difficulty, z).json();
|
||||
auto resist_data_json = this->resist_data_for_index(difficulty, z).json();
|
||||
auto movement_data_json = this->movement_data_for_index(difficulty, z).json();
|
||||
std::set<EnemyType> stats_names;
|
||||
std::set<EnemyType> attack_data_names;
|
||||
std::set<EnemyType> resist_data_names;
|
||||
std::set<EnemyType> movement_data_names;
|
||||
for (Episode episode : ALL_EPISODES_V4) {
|
||||
for (const auto& enemy_type : enemy_types_for_battle_param_stats_index(episode, z)) {
|
||||
stats_names.emplace(enemy_type);
|
||||
}
|
||||
for (const auto& enemy_type : enemy_types_for_battle_param_attack_data_index(episode, z)) {
|
||||
attack_data_names.emplace(enemy_type);
|
||||
}
|
||||
for (const auto& enemy_type : enemy_types_for_battle_param_resist_data_index(episode, z)) {
|
||||
resist_data_names.emplace(enemy_type);
|
||||
}
|
||||
for (const auto& enemy_type : enemy_types_for_battle_param_movement_data_index(episode, z)) {
|
||||
movement_data_names.emplace(enemy_type);
|
||||
}
|
||||
}
|
||||
auto stats_names_json = phosg::JSON::list();
|
||||
for (EnemyType enemy_type : stats_names) {
|
||||
stats_names_json.emplace_back(phosg::name_for_enum(enemy_type));
|
||||
}
|
||||
auto attack_data_names_json = phosg::JSON::list();
|
||||
for (EnemyType enemy_type : attack_data_names) {
|
||||
attack_data_names_json.emplace_back(phosg::name_for_enum(enemy_type));
|
||||
}
|
||||
auto resist_data_names_json = phosg::JSON::list();
|
||||
for (EnemyType enemy_type : resist_data_names) {
|
||||
resist_data_names_json.emplace_back(phosg::name_for_enum(enemy_type));
|
||||
}
|
||||
auto movement_data_names_json = phosg::JSON::list();
|
||||
for (EnemyType enemy_type : movement_data_names) {
|
||||
movement_data_names_json.emplace_back(phosg::name_for_enum(enemy_type));
|
||||
}
|
||||
stats_json.emplace("Enemies", std::move(stats_names_json));
|
||||
attack_data_json.emplace("Enemies", std::move(attack_data_names_json));
|
||||
resist_data_json.emplace("Enemies", std::move(resist_data_names_json));
|
||||
movement_data_json.emplace("Enemies", std::move(movement_data_names_json));
|
||||
diff_ret.emplace_back(phosg::JSON::dict({
|
||||
{"BPIndex", z},
|
||||
{"Stats", std::move(stats_json)},
|
||||
{"AttackData", std::move(attack_data_json)},
|
||||
{"ResistData", std::move(resist_data_json)},
|
||||
{"MovementData", std::move(movement_data_json)},
|
||||
}));
|
||||
}
|
||||
ret.emplace(name_for_difficulty(difficulty), std::move(diff_ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BattleParamsIndex::Table::print(FILE* stream, Episode episode) const {
|
||||
phosg::fwrite_fmt(stream, "========== STATS\n");
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
@@ -27,7 +212,7 @@ void BattleParamsIndex::Table::print(FILE* stream, Episode episode) const {
|
||||
phosg::fwrite_fmt(stream,
|
||||
"{:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {}",
|
||||
e.char_stats.atp, e.char_stats.mst, e.char_stats.evp, e.char_stats.hp, e.char_stats.dfp, e.char_stats.ata,
|
||||
e.char_stats.lck, e.esp, e.experience, e.meseta, names_str);
|
||||
e.char_stats.lck, e.esp, e.exp, e.meseta, names_str);
|
||||
fputc('\n', stream);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +261,40 @@ void BattleParamsIndex::Table::print(FILE* stream, Episode episode) const {
|
||||
}
|
||||
}
|
||||
|
||||
BattleParamsIndex::BattleParamsIndex(
|
||||
phosg::JSON BattleParamsIndex::json() const {
|
||||
return phosg::JSON::dict({
|
||||
{"Episode1-Online", this->get_table(false, Episode::EP1).json()},
|
||||
{"Episode2-Online", this->get_table(false, Episode::EP2).json()},
|
||||
{"Episode4-Online", this->get_table(false, Episode::EP4).json()},
|
||||
{"Episode1-Solo", this->get_table(true, Episode::EP1).json()},
|
||||
{"Episode2-Solo", this->get_table(true, Episode::EP2).json()},
|
||||
{"Episode4-Solo", this->get_table(true, Episode::EP4).json()},
|
||||
});
|
||||
}
|
||||
|
||||
JSONBattleParamsIndex::JSONBattleParamsIndex(const phosg::JSON& json) {
|
||||
this->tables[0][0] = Table::from_json(json.at("Episode1-Online"));
|
||||
this->tables[0][1] = Table::from_json(json.at("Episode2-Online"));
|
||||
this->tables[0][2] = Table::from_json(json.at("Episode4-Online"));
|
||||
this->tables[1][0] = Table::from_json(json.at("Episode1-Solo"));
|
||||
this->tables[1][1] = Table::from_json(json.at("Episode2-Solo"));
|
||||
this->tables[1][2] = Table::from_json(json.at("Episode4-Solo"));
|
||||
}
|
||||
|
||||
const BattleParamsIndex::Table& JSONBattleParamsIndex::get_table(bool solo, Episode episode) const {
|
||||
switch (episode) {
|
||||
case Episode::EP1:
|
||||
return this->tables[!!solo][0];
|
||||
case Episode::EP2:
|
||||
return this->tables[!!solo][1];
|
||||
case Episode::EP4:
|
||||
return this->tables[!!solo][2];
|
||||
default:
|
||||
throw invalid_argument("invalid episode");
|
||||
}
|
||||
}
|
||||
|
||||
BinaryBattleParamsIndex::BinaryBattleParamsIndex(
|
||||
shared_ptr<const string> data_on_ep1,
|
||||
shared_ptr<const string> data_on_ep2,
|
||||
shared_ptr<const string> data_on_ep4,
|
||||
@@ -103,21 +321,15 @@ BattleParamsIndex::BattleParamsIndex(
|
||||
}
|
||||
}
|
||||
|
||||
const BattleParamsIndex::Table& BattleParamsIndex::get_table(bool solo, Episode episode) const {
|
||||
uint8_t ep_index;
|
||||
const BattleParamsIndex::Table& BinaryBattleParamsIndex::get_table(bool solo, Episode episode) const {
|
||||
switch (episode) {
|
||||
case Episode::EP1:
|
||||
ep_index = 0;
|
||||
break;
|
||||
return *this->files[!!solo][0].table;
|
||||
case Episode::EP2:
|
||||
ep_index = 1;
|
||||
break;
|
||||
return *this->files[!!solo][1].table;
|
||||
case Episode::EP4:
|
||||
ep_index = 2;
|
||||
break;
|
||||
return *this->files[!!solo][2].table;
|
||||
default:
|
||||
throw invalid_argument("invalid episode");
|
||||
}
|
||||
|
||||
return *this->files[!!solo][ep_index].table;
|
||||
}
|
||||
|
||||
+38
-10
@@ -35,7 +35,8 @@ public:
|
||||
/* 24 */ le_uint32_t unknown_a14;
|
||||
/* 28 */ le_uint32_t unknown_a15;
|
||||
/* 2C */ le_uint32_t unknown_a16;
|
||||
/* 30 */
|
||||
static AttackData from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
} __packed_ws__(AttackData, 0x30);
|
||||
|
||||
struct ResistData {
|
||||
@@ -50,7 +51,8 @@ public:
|
||||
/* 14 */ le_uint32_t unknown_a8;
|
||||
/* 18 */ le_uint32_t unknown_a9;
|
||||
/* 1C */ le_int32_t dfp_bonus;
|
||||
/* 20 */
|
||||
static ResistData from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
} __packed_ws__(ResistData, 0x20);
|
||||
|
||||
struct MovementData {
|
||||
@@ -66,7 +68,8 @@ public:
|
||||
/* 24 */ le_uint32_t iparam4;
|
||||
/* 28 */ le_uint32_t iparam5;
|
||||
/* 2C */ le_uint32_t iparam6;
|
||||
/* 30 */
|
||||
static MovementData from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
} __packed_ws__(MovementData, 0x30);
|
||||
|
||||
struct Table {
|
||||
@@ -76,23 +79,48 @@ public:
|
||||
/* AE00 */ parray<parray<MovementData, 0x60>, 4> movement_data; // [difficulty][bp_index]
|
||||
/* F600 */
|
||||
|
||||
const PlayerStats& stats_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
inline const PlayerStats& stats_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->stats.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const AttackData& attack_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
inline const AttackData& attack_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->attack_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const ResistData& resist_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
inline const ResistData& resist_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->resist_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const MovementData& movement_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
inline const MovementData& movement_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->movement_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
|
||||
static Table from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
|
||||
void print(FILE* stream, Episode episode) const;
|
||||
} __packed_ws__(Table, 0xF600);
|
||||
|
||||
BattleParamsIndex(
|
||||
virtual ~BattleParamsIndex() = default;
|
||||
|
||||
virtual const Table& get_table(bool solo, Episode episode) const = 0;
|
||||
phosg::JSON json() const;
|
||||
|
||||
protected:
|
||||
BattleParamsIndex() = default;
|
||||
};
|
||||
|
||||
class JSONBattleParamsIndex : public BattleParamsIndex {
|
||||
public:
|
||||
explicit JSONBattleParamsIndex(const phosg::JSON& json);
|
||||
|
||||
virtual const Table& get_table(bool solo, Episode episode) const;
|
||||
|
||||
protected:
|
||||
// Indexed as [online/offline][episode]
|
||||
std::array<std::array<Table, 3>, 2> tables;
|
||||
};
|
||||
|
||||
class BinaryBattleParamsIndex : public BattleParamsIndex {
|
||||
public:
|
||||
BinaryBattleParamsIndex(
|
||||
std::shared_ptr<const std::string> data_on_ep1, // BattleParamEntry_on.dat
|
||||
std::shared_ptr<const std::string> data_on_ep2, // BattleParamEntry_lab_on.dat
|
||||
std::shared_ptr<const std::string> data_on_ep4, // BattleParamEntry_ep4_on.dat
|
||||
@@ -100,9 +128,9 @@ public:
|
||||
std::shared_ptr<const std::string> data_off_ep2, // BattleParamEntry_lab.dat
|
||||
std::shared_ptr<const std::string> data_off_ep4); // BattleParamEntry_ep4.dat
|
||||
|
||||
const Table& get_table(bool solo, Episode episode) const;
|
||||
virtual const Table& get_table(bool solo, Episode episode) const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
struct File {
|
||||
std::shared_ptr<const std::string> data;
|
||||
const Table* table = nullptr;
|
||||
|
||||
+29
-27
@@ -540,7 +540,7 @@ static asio::awaitable<void> server_command_bbchar_savechar(const Args& a, bool
|
||||
bb_player->disp.stats.char_stats.dfp += bb_player->get_material_usage(PSOBBCharacterFile::MaterialType::DEF) * 2;
|
||||
bb_player->disp.stats.char_stats.lck += bb_player->get_material_usage(PSOBBCharacterFile::MaterialType::LUCK) * 2;
|
||||
bb_player->disp.stats.char_stats.hp += bb_player->get_material_usage(PSOBBCharacterFile::MaterialType::HP) * 2;
|
||||
bb_player->disp.stats.experience = ch.character->disp.stats.experience;
|
||||
bb_player->disp.stats.exp = ch.character->disp.stats.exp;
|
||||
bb_player->disp.stats.meseta = ch.character->disp.stats.meseta;
|
||||
}
|
||||
bb_player->disp.technique_levels_v1 = ch.character->disp.technique_levels_v1;
|
||||
@@ -915,7 +915,7 @@ ChatCommandDefinition cc_edit(
|
||||
} else if (tokens.at(0) == "meseta" && (cheats_allowed || !s->cheat_flags.edit_stats)) {
|
||||
p->disp.stats.meseta = stoul(tokens.at(1));
|
||||
} else if (tokens.at(0) == "exp" && (cheats_allowed || !s->cheat_flags.edit_stats)) {
|
||||
p->disp.stats.experience = stoul(tokens.at(1));
|
||||
p->disp.stats.exp = stoul(tokens.at(1));
|
||||
} else if (tokens.at(0) == "level" && (cheats_allowed || !s->cheat_flags.edit_stats)) {
|
||||
p->disp.stats.level = stoul(tokens.at(1)) - 1;
|
||||
p->recompute_stats(s->level_table(a.c->version()), true);
|
||||
@@ -1111,9 +1111,9 @@ ChatCommandDefinition cc_exit(
|
||||
a.c->check_flag(Client::Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE)) {
|
||||
co_await prepare_client_for_patches(a.c);
|
||||
auto s = a.c->require_server_state();
|
||||
shared_ptr<const CompiledFunctionCode> fn;
|
||||
shared_ptr<const ClientFunctionIndex::Function> fn;
|
||||
try {
|
||||
fn = s->function_code_index->get_patch("ExitAnywhere", a.c->specific_version);
|
||||
fn = s->client_functions->get("ExitAnywhere", a.c->specific_version);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
if (fn) {
|
||||
@@ -1571,7 +1571,7 @@ ChatCommandDefinition cc_loadchar(
|
||||
auto send_set_extended_player_info = [&a, &s]<typename CharT>(const CharT& char_file) -> asio::awaitable<void> {
|
||||
co_await prepare_client_for_patches(a.c);
|
||||
try {
|
||||
auto fn = s->function_code_index->get_patch("SetExtendedPlayerInfo", a.c->specific_version);
|
||||
auto fn = s->client_functions->get("SetExtendedPlayerInfo", a.c->specific_version);
|
||||
co_await send_function_call(a.c, fn, {}, &char_file, sizeof(CharT));
|
||||
auto l = a.c->lobby.lock();
|
||||
if (l) {
|
||||
@@ -1707,7 +1707,7 @@ ChatCommandDefinition cc_makeobj(
|
||||
|
||||
co_await prepare_client_for_patches(a.c);
|
||||
auto s = a.c->require_server_state();
|
||||
auto fn = s->function_code_index->get_patch("CreateObject", a.c->specific_version);
|
||||
auto fn = s->client_functions->get("CreateObject", a.c->specific_version);
|
||||
co_await send_function_call(a.c, fn, label_writes);
|
||||
});
|
||||
|
||||
@@ -1847,14 +1847,31 @@ ChatCommandDefinition cc_patch(
|
||||
try {
|
||||
auto s = a.c->require_server_state();
|
||||
// Note: We can't look this up before prepare_client_for_patches because specific_version may not be set
|
||||
auto fn = s->function_code_index->get_patch(patch_name, a.c->specific_version);
|
||||
auto fn = s->client_functions->get(patch_name, a.c->specific_version);
|
||||
|
||||
switch (fn->visibility) {
|
||||
case ClientFunctionIndex::Function::Visibility::DEBUG_ONLY:
|
||||
case ClientFunctionIndex::Function::Visibility::PATCHES_MENU_ONLY:
|
||||
a.check_debug_enabled();
|
||||
break;
|
||||
case ClientFunctionIndex::Function::Visibility::CHAT_COMMAND_ONLY_WITH_CHEAT_MODE:
|
||||
a.check_cheats_enabled_or_allowed(true);
|
||||
break;
|
||||
case ClientFunctionIndex::Function::Visibility::CHAT_COMMAND_ONLY:
|
||||
case ClientFunctionIndex::Function::Visibility::PATCHES_MENU_AND_CHAT_COMMAND:
|
||||
break;
|
||||
default:
|
||||
throw std::logic_error("Invalid client function visibility");
|
||||
}
|
||||
|
||||
auto ret = co_await send_function_call(a.c, fn, label_writes);
|
||||
if (fn->show_return_value) {
|
||||
send_text_message_fmt(a.c, "$C6Return value:$C7\nInt: {}\nHex: {:08X}\nFloat: {:g}",
|
||||
ret.return_value.load(), ret.return_value.load(), std::bit_cast<float>(ret.return_value.load()));
|
||||
}
|
||||
|
||||
} catch (const out_of_range&) {
|
||||
send_text_message(a.c, "$C6Invalid patch name");
|
||||
send_text_message(a.c, "$C6Invalid function");
|
||||
}
|
||||
co_return;
|
||||
});
|
||||
@@ -2277,15 +2294,10 @@ ChatCommandDefinition cc_readmem(
|
||||
|
||||
co_await prepare_client_for_patches(a.c);
|
||||
|
||||
shared_ptr<const CompiledFunctionCode> fn;
|
||||
shared_ptr<const ClientFunctionIndex::Function> fn;
|
||||
try {
|
||||
auto s = a.c->require_server_state();
|
||||
const char* function_name = is_dc(a.c->version())
|
||||
? "ReadMemoryWordDC"
|
||||
: is_gc(a.c->version())
|
||||
? "ReadMemoryWordGC"
|
||||
: "ReadMemoryWordX86";
|
||||
fn = s->function_code_index->name_to_function.at(function_name);
|
||||
fn = s->client_functions->get("ReadMemoryWord", a.c->specific_version);
|
||||
} catch (const out_of_range&) {
|
||||
throw precondition_failed("Invalid patch name");
|
||||
}
|
||||
@@ -3139,12 +3151,7 @@ ChatCommandDefinition cc_writemem(
|
||||
|
||||
try {
|
||||
auto s = a.c->require_server_state();
|
||||
const char* function_name = is_dc(a.c->version())
|
||||
? "WriteMemoryDC"
|
||||
: is_gc(a.c->version())
|
||||
? "WriteMemoryGC"
|
||||
: "WriteMemoryX86";
|
||||
auto fn = s->function_code_index->name_to_function.at(function_name);
|
||||
auto fn = s->client_functions->get("WriteMemory", a.c->specific_version);
|
||||
unordered_map<string, uint32_t> label_writes{{"dest_addr", addr}, {"size", data.size()}};
|
||||
co_await send_function_call(a.c, fn, label_writes, data.data(), data.size());
|
||||
} catch (const out_of_range&) {
|
||||
@@ -3184,12 +3191,7 @@ ChatCommandDefinition cc_nativecall(
|
||||
|
||||
try {
|
||||
auto s = a.c->require_server_state();
|
||||
const char* function_name = is_dc(a.c->version())
|
||||
? "CallNativeFunctionDC"
|
||||
: is_gc(a.c->version())
|
||||
? "CallNativeFunctionGC"
|
||||
: "CallNativeFunctionX86";
|
||||
auto fn = s->function_code_index->name_to_function.at(function_name);
|
||||
auto fn = s->client_functions->get("CallNativeFunction", a.c->specific_version);
|
||||
co_await send_function_call(a.c, fn, label_writes);
|
||||
} catch (const out_of_range&) {
|
||||
throw precondition_failed("Invalid patch name");
|
||||
|
||||
+1
-1
@@ -703,7 +703,7 @@ void Client::create_challenge_overlay(
|
||||
overlay->disp.visual.char_class, overlay->disp.stats.level);
|
||||
overlay->disp.stats.esp = 40;
|
||||
overlay->disp.stats.attack_range = 10.0;
|
||||
overlay->disp.stats.experience = stats_delta.experience;
|
||||
overlay->disp.stats.exp = stats_delta.exp;
|
||||
overlay->disp.stats.meseta = 0;
|
||||
overlay->clear_all_material_usage();
|
||||
for (size_t z = 0; z < 0x13; z++) {
|
||||
|
||||
+1
-1
@@ -6,11 +6,11 @@
|
||||
#include "Account.hh"
|
||||
#include "AsyncUtils.hh"
|
||||
#include "Channel.hh"
|
||||
#include "ClientFunctionIndex.hh"
|
||||
#include "CommandFormats.hh"
|
||||
#include "Episode3/BattleRecord.hh"
|
||||
#include "Episode3/Tournament.hh"
|
||||
#include "FileContentsCache.hh"
|
||||
#include "FunctionCompiler.hh"
|
||||
#include "PSOEncryption.hh"
|
||||
#include "PSOProtocol.hh"
|
||||
#include "PatchFileIndex.hh"
|
||||
|
||||
@@ -0,0 +1,558 @@
|
||||
#include "ClientFunctionIndex.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/Time.hh>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <resource_file/Emulators/PPC32Emulator.hh>
|
||||
#include <resource_file/Emulators/SH4Emulator.hh>
|
||||
#include <resource_file/Emulators/X86Emulator.hh>
|
||||
|
||||
#include "CommandFormats.hh"
|
||||
#include "CommonFileFormats.hh"
|
||||
#include "Compression.hh"
|
||||
#include "Loggers.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
using Arch = ClientFunctionIndex::Function::Architecture;
|
||||
|
||||
const char* name_for_architecture(Arch arch) {
|
||||
switch (arch) {
|
||||
case Arch::SH4:
|
||||
return "SH-4";
|
||||
case Arch::POWERPC:
|
||||
return "PowerPC";
|
||||
case Arch::X86:
|
||||
return "x86";
|
||||
default:
|
||||
throw logic_error("invalid architecture");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t specific_version_for_architecture(Arch arch) {
|
||||
switch (arch) {
|
||||
case Arch::SH4:
|
||||
return SPECIFIC_VERSION_SH4_INDETERMINATE;
|
||||
case Arch::POWERPC:
|
||||
return SPECIFIC_VERSION_PPC_INDETERMINATE;
|
||||
case Arch::X86:
|
||||
return SPECIFIC_VERSION_X86_INDETERMINATE;
|
||||
default:
|
||||
throw logic_error("invalid architecture");
|
||||
}
|
||||
}
|
||||
|
||||
Arch architecture_for_specific_version(uint32_t specific_version) {
|
||||
if (specific_version == SPECIFIC_VERSION_SH4_INDETERMINATE) {
|
||||
return Arch::SH4;
|
||||
} else if (specific_version == SPECIFIC_VERSION_PPC_INDETERMINATE) {
|
||||
return Arch::POWERPC;
|
||||
} else if (specific_version == SPECIFIC_VERSION_X86_INDETERMINATE) {
|
||||
return Arch::X86;
|
||||
} else if (specific_version_is_dc(specific_version)) {
|
||||
return Arch::SH4;
|
||||
} else if (specific_version_is_gc(specific_version)) {
|
||||
return Arch::POWERPC;
|
||||
} else {
|
||||
return Arch::X86;
|
||||
}
|
||||
}
|
||||
|
||||
static inline std::string cache_key(const std::string& name, uint32_t specific_version) {
|
||||
return std::format("{}-{:08X}", name, specific_version);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& get_with_sv_fallback(
|
||||
const std::unordered_map<std::string, T>& index, const std::string& name, uint32_t specific_version) {
|
||||
try {
|
||||
return index.at(cache_key(name, specific_version));
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
uint32_t arch_specific_version = specific_version_for_architecture(architecture_for_specific_version(
|
||||
specific_version));
|
||||
if (arch_specific_version != specific_version) {
|
||||
try {
|
||||
return index.at(cache_key(name, arch_specific_version));
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
}
|
||||
return index.at(name);
|
||||
}
|
||||
|
||||
template <bool BE>
|
||||
string ClientFunctionIndex::Function::generate_client_command_t(
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
uint32_t override_relocations_offset) const {
|
||||
using FooterT = RELFileFooterT<BE>;
|
||||
|
||||
FooterT footer;
|
||||
footer.num_relocations = this->relocation_deltas.size();
|
||||
footer.unused1.clear(0);
|
||||
footer.root_offset = this->entrypoint_offset_offset;
|
||||
footer.unused2.clear(0);
|
||||
|
||||
phosg::StringWriter w;
|
||||
if (!label_writes.empty()) {
|
||||
string modified_code = this->code;
|
||||
for (const auto& it : label_writes) {
|
||||
size_t offset = this->label_offsets.at(it.first);
|
||||
if (offset > modified_code.size() - 4) {
|
||||
throw runtime_error("label out of range");
|
||||
}
|
||||
*reinterpret_cast<U32T<FooterT::IsBE>*>(modified_code.data() + offset) = it.second;
|
||||
}
|
||||
w.write(modified_code);
|
||||
} else {
|
||||
w.write(this->code);
|
||||
}
|
||||
if (suffix_size) {
|
||||
w.write(suffix_data, suffix_size);
|
||||
}
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
|
||||
footer.relocations_offset = w.size();
|
||||
|
||||
// Always write at least 4 bytes even if there are no relocations
|
||||
if (this->relocation_deltas.empty()) {
|
||||
w.put_u32(0);
|
||||
}
|
||||
|
||||
if (override_relocations_offset) {
|
||||
footer.relocations_offset = override_relocations_offset;
|
||||
} else {
|
||||
for (uint16_t delta : this->relocation_deltas) {
|
||||
w.put<U16T<FooterT::IsBE>>(delta);
|
||||
}
|
||||
if (this->relocation_deltas.size() & 1) {
|
||||
w.put_u16(0);
|
||||
}
|
||||
}
|
||||
|
||||
w.put(footer);
|
||||
return std::move(w.str());
|
||||
}
|
||||
|
||||
string ClientFunctionIndex::Function::generate_client_command(
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
uint32_t override_relocations_offset) const {
|
||||
if (this->is_big_endian()) {
|
||||
return this->generate_client_command_t<true>(label_writes, suffix_data, suffix_size, override_relocations_offset);
|
||||
} else if ((this->arch == Architecture::X86) || (this->arch == Architecture::SH4)) {
|
||||
return this->generate_client_command_t<false>(label_writes, suffix_data, suffix_size, override_relocations_offset);
|
||||
} else {
|
||||
throw logic_error("invalid architecture");
|
||||
}
|
||||
}
|
||||
|
||||
static unordered_map<uint32_t, std::string> preprocess_function_code(const std::string& text) {
|
||||
std::unordered_set<uint32_t> all_specific_versions;
|
||||
struct Line {
|
||||
std::string text;
|
||||
std::unordered_map<uint32_t, size_t> new_specific_versions; // Nonempty iff line is a .versions directive
|
||||
bool enable_all_versions = false;
|
||||
};
|
||||
|
||||
std::vector<Line> lines;
|
||||
for (auto& line_text : phosg::split(text, '\n')) {
|
||||
auto& line = lines.emplace_back();
|
||||
line.text = std::move(line_text);
|
||||
|
||||
string stripped_line = line.text;
|
||||
phosg::strip_whitespace(stripped_line);
|
||||
|
||||
if (stripped_line == ".all_versions") {
|
||||
line.enable_all_versions = true;
|
||||
} else if (stripped_line.starts_with(".versions ")) {
|
||||
for (auto& vers_token : phosg::split(stripped_line.substr(10), ' ')) {
|
||||
phosg::strip_whitespace(vers_token);
|
||||
if (!vers_token.empty()) {
|
||||
uint32_t specific_version = specific_version_for_str(vers_token);
|
||||
size_t version_index = line.new_specific_versions.size();
|
||||
all_specific_versions.emplace(specific_version);
|
||||
line.new_specific_versions.emplace(std::move(specific_version), version_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const std::string empty_str = "";
|
||||
|
||||
unordered_map<uint32_t, std::string> ret;
|
||||
for (uint32_t specific_version : all_specific_versions) {
|
||||
std::deque<std::string> version_lines;
|
||||
bool include_current_line = true;
|
||||
size_t current_vers_index = all_specific_versions.size();
|
||||
for (size_t line_znum = 0; line_znum < lines.size(); line_znum++) {
|
||||
const auto& line = lines[line_znum];
|
||||
|
||||
if (line.enable_all_versions) {
|
||||
include_current_line = true;
|
||||
current_vers_index = all_specific_versions.size();
|
||||
version_lines.emplace_back(empty_str);
|
||||
|
||||
} else if (!line.new_specific_versions.empty()) {
|
||||
auto it = line.new_specific_versions.find(specific_version);
|
||||
if (it == line.new_specific_versions.end()) {
|
||||
include_current_line = false;
|
||||
current_vers_index = all_specific_versions.size();
|
||||
} else {
|
||||
include_current_line = true;
|
||||
current_vers_index = it->second;
|
||||
}
|
||||
version_lines.emplace_back(empty_str);
|
||||
|
||||
} else if (!include_current_line) {
|
||||
version_lines.emplace_back(empty_str);
|
||||
|
||||
} else {
|
||||
std::string line_text = line.text;
|
||||
size_t vers_offset = line_text.find("<VERS ");
|
||||
while (vers_offset != string::npos) {
|
||||
size_t end_offset = line_text.find('>', vers_offset + 6);
|
||||
if (end_offset == string::npos) {
|
||||
throw runtime_error(std::format("(version {}) (line {}) unterminated <VERS> replacement",
|
||||
str_for_specific_version(specific_version), line_znum + 1));
|
||||
}
|
||||
auto tokens = phosg::split(line_text.substr(vers_offset + 6, end_offset - vers_offset - 6), ' ');
|
||||
if (current_vers_index >= tokens.size()) {
|
||||
throw runtime_error(std::format("(version {}) (line {}) invalid <VERS> replacement",
|
||||
str_for_specific_version(specific_version), line_znum + 1));
|
||||
}
|
||||
line_text = line_text.substr(0, vers_offset) + tokens[current_vers_index] + line_text.substr(end_offset + 1);
|
||||
vers_offset = line_text.find("<VERS ");
|
||||
}
|
||||
version_lines.emplace_back(std::move(line_text));
|
||||
}
|
||||
}
|
||||
ret.emplace(specific_version, phosg::join(version_lines, "\n"));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ClientFunctionIndex::ClientFunctionIndex(const string& root_dir, bool raise_on_any_failure) {
|
||||
map<string, string> source_files;
|
||||
std::function<void(const std::string&)> add_directory = [&](const std::string& dir) -> void {
|
||||
for (const auto& item : std::filesystem::directory_iterator(dir)) {
|
||||
string item_name = item.path().filename().string();
|
||||
string item_path = dir.ends_with("/") ? (dir + item_name) : (dir + "/" + item_name);
|
||||
if (std::filesystem::is_directory(item_path)) {
|
||||
add_directory(item_path);
|
||||
} else if (item_path.ends_with(".s") && std::filesystem::is_regular_file(item_path)) {
|
||||
client_functions_log.debug_f("Adding {} from {}", item_name, item_path);
|
||||
if (!source_files.emplace(item_name, phosg::load_file(item_path)).second) {
|
||||
throw std::runtime_error(std::format("Duplicate source filename: {}", item_name));
|
||||
}
|
||||
} else if (item_path.ends_with(".bin") && std::filesystem::is_regular_file(item_path)) {
|
||||
client_functions_log.debug_f("Adding {} from {}", item_name, item_path);
|
||||
if (!source_files.emplace(item_name, phosg::load_file(item_path)).second) {
|
||||
throw std::runtime_error(std::format("Duplicate binary filename: {}", item_name));
|
||||
}
|
||||
} else {
|
||||
client_functions_log.debug_f("Ignoring {}", item_path);
|
||||
}
|
||||
}
|
||||
};
|
||||
add_directory(root_dir);
|
||||
|
||||
unordered_map<string, string> include_cache;
|
||||
uint32_t last_menu_item_id = 0;
|
||||
for (const auto& [source_filename, source] : source_files) {
|
||||
if (!source_filename.ends_with(".s")) {
|
||||
client_functions_log.debug_f("Skipping root compile for {} because it is not a .s file", source_filename);
|
||||
continue;
|
||||
}
|
||||
if (source_filename.ends_with(".inc.s")) {
|
||||
client_functions_log.debug_f("Skipping root compile for {} because it is an include", source_filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, std::string> preprocessed;
|
||||
try {
|
||||
preprocessed = preprocess_function_code(source);
|
||||
} catch (const std::exception& e) {
|
||||
throw std::runtime_error(std::format("({} preprocessing) {}", source_filename, e.what()));
|
||||
}
|
||||
|
||||
for (const auto& [specific_version, source] : preprocessed) {
|
||||
shared_ptr<Function> fn = make_shared<Function>();
|
||||
fn->short_name = source_filename.substr(0, source_filename.size() - 2);
|
||||
fn->specific_version = specific_version;
|
||||
fn->menu_item_id = ++last_menu_item_id;
|
||||
fn->arch = architecture_for_specific_version(fn->specific_version);
|
||||
|
||||
try {
|
||||
unordered_set<string> get_include_stack;
|
||||
function<string(const string&, uint32_t)> get_include_for_sv = [&include_cache, &source_files, &get_include_stack, &get_include_for_sv](const string& name, uint32_t specific_version) -> string {
|
||||
try {
|
||||
return get_with_sv_fallback(include_cache, name, specific_version);
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
if (client_functions_log.should_log(phosg::LogLevel::L_DEBUG)) {
|
||||
client_functions_log.debug_f("({}) Include {}-{} needs to be compiled",
|
||||
get_include_stack.size(), name, str_for_specific_version(specific_version));
|
||||
}
|
||||
|
||||
auto it = source_files.find(name + ".inc.s");
|
||||
if (it != source_files.end()) {
|
||||
if (!get_include_stack.emplace(name).second) {
|
||||
throw runtime_error("Mutual recursion between includes: " + name);
|
||||
}
|
||||
for (const auto& [include_specific_version, include_source] : preprocess_function_code(it->second)) {
|
||||
ResourceDASM::EmulatorBase::AssembleResult ret;
|
||||
auto get_include = std::bind(get_include_for_sv, std::placeholders::_1, include_specific_version);
|
||||
switch (architecture_for_specific_version(include_specific_version)) {
|
||||
case Arch::POWERPC:
|
||||
ret = ResourceDASM::PPC32Emulator::assemble(include_source, get_include);
|
||||
break;
|
||||
case Arch::X86:
|
||||
ret = ResourceDASM::X86Emulator::assemble(include_source, get_include);
|
||||
break;
|
||||
case Arch::SH4:
|
||||
ret = ResourceDASM::SH4Emulator::assemble(include_source, get_include);
|
||||
break;
|
||||
default:
|
||||
throw runtime_error("unknown architecture");
|
||||
}
|
||||
if (client_functions_log.should_log(phosg::LogLevel::L_DEBUG)) {
|
||||
client_functions_log.debug_f("({}) Compiled include {}-{}",
|
||||
get_include_stack.size(), name, str_for_specific_version(include_specific_version));
|
||||
}
|
||||
include_cache.emplace(cache_key(name, include_specific_version), std::move(ret.code));
|
||||
}
|
||||
get_include_stack.erase(name);
|
||||
|
||||
} else {
|
||||
it = source_files.find(name + ".inc.bin");
|
||||
if (it != source_files.end()) {
|
||||
include_cache.emplace(name, it->second).first->second;
|
||||
client_functions_log.debug_f("({}) Cached binary include {}", get_include_stack.size(), name);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return get_with_sv_fallback(include_cache, name, specific_version);
|
||||
} catch (const std::out_of_range&) {
|
||||
}
|
||||
throw runtime_error(std::format(
|
||||
"Data not found for include {} ({})", name, str_for_specific_version(specific_version)));
|
||||
};
|
||||
|
||||
try {
|
||||
ResourceDASM::EmulatorBase::AssembleResult assembled;
|
||||
auto get_include = std::bind(get_include_for_sv, std::placeholders::_1, specific_version);
|
||||
switch (fn->arch) {
|
||||
case Arch::POWERPC:
|
||||
assembled = ResourceDASM::PPC32Emulator::assemble(source, get_include);
|
||||
break;
|
||||
case Arch::X86:
|
||||
assembled = ResourceDASM::X86Emulator::assemble(source, get_include);
|
||||
break;
|
||||
case Arch::SH4:
|
||||
assembled = ResourceDASM::SH4Emulator::assemble(source, get_include);
|
||||
break;
|
||||
default:
|
||||
throw runtime_error("invalid architecture");
|
||||
}
|
||||
|
||||
fn->code = std::move(assembled.code);
|
||||
fn->label_offsets = std::move(assembled.label_offsets);
|
||||
for (const auto& [key, value] : assembled.metadata_keys) {
|
||||
if (key == "visibility") {
|
||||
if (value == "hidden") {
|
||||
fn->visibility = Function::Visibility::DEBUG_ONLY;
|
||||
} else if (value == "cheat") {
|
||||
fn->visibility = Function::Visibility::CHAT_COMMAND_ONLY_WITH_CHEAT_MODE;
|
||||
} else if (value == "chat") {
|
||||
fn->visibility = Function::Visibility::CHAT_COMMAND_ONLY;
|
||||
} else if (value == "menu") {
|
||||
fn->visibility = Function::Visibility::PATCHES_MENU_ONLY;
|
||||
} else if (value == "all") {
|
||||
fn->visibility = Function::Visibility::PATCHES_MENU_AND_CHAT_COMMAND;
|
||||
} else {
|
||||
throw std::runtime_error("Invalid visibility value");
|
||||
}
|
||||
} else if (key == "key") {
|
||||
fn->short_name = value;
|
||||
} else if (key == "name") {
|
||||
fn->long_name = value;
|
||||
} else if (key == "description") {
|
||||
fn->description = value;
|
||||
} else if (key == "client_flag") {
|
||||
fn->client_flag = stoull(value, nullptr, 0);
|
||||
} else if (key == "show_return_value") {
|
||||
fn->show_return_value = true;
|
||||
} else {
|
||||
throw runtime_error("unknown metadata key: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fn->entrypoint_offset_offset = fn->label_offsets.at("entry_ptr");
|
||||
} catch (const out_of_range&) {
|
||||
throw runtime_error("code does not contain entry_ptr label");
|
||||
}
|
||||
|
||||
set<uint32_t> reloc_indexes;
|
||||
for (const auto& it : fn->label_offsets) {
|
||||
if (it.first.starts_with("reloc")) {
|
||||
reloc_indexes.emplace(it.second / 4);
|
||||
}
|
||||
}
|
||||
uint32_t prev_index = 0;
|
||||
for (const auto& it : reloc_indexes) {
|
||||
uint32_t delta = it - prev_index;
|
||||
if (delta > 0xFFFF) {
|
||||
throw runtime_error("relocation delta too far away");
|
||||
}
|
||||
fn->relocation_deltas.emplace_back(delta);
|
||||
prev_index = it;
|
||||
}
|
||||
|
||||
} catch (const exception& e) {
|
||||
if (raise_on_any_failure) {
|
||||
throw;
|
||||
}
|
||||
client_functions_log.warning_f("Failed to compile function {} ({}): {}",
|
||||
fn->short_name, str_for_specific_version(specific_version), e.what());
|
||||
}
|
||||
|
||||
auto key = cache_key(fn->short_name, specific_version);
|
||||
if (!this->all_functions.emplace(key, fn).second) {
|
||||
throw std::runtime_error("Duplicate function key: " + key);
|
||||
}
|
||||
this->functions_by_specific_version[specific_version].emplace(key, fn);
|
||||
this->functions_by_menu_item_id.emplace(fn->menu_item_id, fn);
|
||||
|
||||
client_functions_log.debug_f("Compiled function {} ({}; {}; {})",
|
||||
fn->short_name, str_for_specific_version(fn->specific_version), name_for_architecture(fn->arch),
|
||||
phosg::name_for_enum(fn->visibility));
|
||||
} catch (const std::exception& e) {
|
||||
throw std::runtime_error(std::format(
|
||||
"({}-{}) {}", fn->short_name, str_for_specific_version(specific_version), e.what()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<const Menu> ClientFunctionIndex::patch_switches_menu(
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const {
|
||||
auto ret = make_shared<Menu>(MenuID::PATCH_SWITCHES, "Patches");
|
||||
ret->items.emplace_back(PatchesMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
||||
|
||||
auto map_it = this->functions_by_specific_version.find(specific_version);
|
||||
if (map_it != this->functions_by_specific_version.end()) {
|
||||
for (auto [name, fn] : map_it->second) {
|
||||
if (fn->appears_in_patches_menu() && !server_auto_patches_enabled.count(fn->short_name)) {
|
||||
string item_text;
|
||||
item_text.push_back(client_auto_patches_enabled.count(fn->short_name) ? '*' : '-');
|
||||
item_text += fn->long_name.empty() ? fn->short_name : fn->long_name;
|
||||
ret->items.emplace_back(
|
||||
fn->menu_item_id, item_text, fn->description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ClientFunctionIndex::patch_menu_empty(uint32_t specific_version) const {
|
||||
uint32_t mask = specific_version_is_indeterminate(specific_version) ? 0xFF000000 : 0xFFFFFFFF;
|
||||
auto it = this->functions_by_specific_version.lower_bound(specific_version & mask);
|
||||
return ((it == this->functions_by_specific_version.end()) || ((it->first & mask) != (specific_version & mask)));
|
||||
}
|
||||
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> ClientFunctionIndex::get(
|
||||
const std::string& name, uint32_t specific_version) const {
|
||||
return get_with_sv_fallback(this->all_functions, name, specific_version);
|
||||
}
|
||||
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> ClientFunctionIndex::get(
|
||||
const std::string& name, Arch arch) const {
|
||||
return get_with_sv_fallback(this->all_functions, name, specific_version_for_architecture(arch));
|
||||
}
|
||||
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> ClientFunctionIndex::get(const std::string& name) const {
|
||||
return this->all_functions.at(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> ClientFunctionIndex::get_by_menu_item_id(
|
||||
uint32_t menu_item_id) const {
|
||||
return this->functions_by_menu_item_id.at(menu_item_id);
|
||||
}
|
||||
|
||||
uint32_t specific_version_for_gc_header_checksum(uint32_t header_checksum) {
|
||||
static unordered_map<uint32_t, uint32_t> checksum_to_specific_version;
|
||||
if (checksum_to_specific_version.empty()) {
|
||||
struct {
|
||||
char system_code = 'G';
|
||||
char game_code1 = 'P';
|
||||
char game_code2;
|
||||
char region_code;
|
||||
char developer_code1 = '8';
|
||||
char developer_code2 = 'P';
|
||||
uint8_t disc_number = 0;
|
||||
uint8_t version_code;
|
||||
} __attribute__((packed)) data;
|
||||
for (const char* game_code2 = "OS"; *game_code2; game_code2++) {
|
||||
data.game_code2 = *game_code2;
|
||||
for (const char* region_code = "JEP"; *region_code; region_code++) {
|
||||
data.region_code = *region_code;
|
||||
for (uint8_t version_code = 0; version_code < 8; version_code++) {
|
||||
data.version_code = version_code;
|
||||
uint32_t checksum = phosg::crc32(&data, sizeof(data));
|
||||
uint32_t specific_version = 0x33000030 | (*game_code2 << 16) | (*region_code << 8) | version_code;
|
||||
if (!checksum_to_specific_version.emplace(checksum, specific_version).second) {
|
||||
throw logic_error("multiple specific_versions have same header checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// Generate entries for Trial Editions
|
||||
data.region_code = 'J';
|
||||
data.system_code = 'D';
|
||||
data.version_code = 0;
|
||||
uint32_t checksum = phosg::crc32(&data, sizeof(data));
|
||||
uint32_t specific_version = 0x33004A54 | (*game_code2 << 16);
|
||||
if (!checksum_to_specific_version.emplace(checksum, specific_version).second) {
|
||||
throw logic_error("multiple specific_versions have same header checksum");
|
||||
}
|
||||
data.system_code = 'G';
|
||||
}
|
||||
}
|
||||
}
|
||||
return checksum_to_specific_version.at(header_checksum);
|
||||
}
|
||||
|
||||
template <>
|
||||
const char* phosg::name_for_enum<ClientFunctionIndex::Function::Visibility>(
|
||||
ClientFunctionIndex::Function::Visibility vis) {
|
||||
switch (vis) {
|
||||
case ClientFunctionIndex::Function::Visibility::DEBUG_ONLY:
|
||||
return "DEBUG_ONLY";
|
||||
case ClientFunctionIndex::Function::Visibility::CHAT_COMMAND_ONLY_WITH_CHEAT_MODE:
|
||||
return "CHAT_COMMAND_ONLY_WITH_CHEAT_MODE";
|
||||
case ClientFunctionIndex::Function::Visibility::CHAT_COMMAND_ONLY:
|
||||
return "CHAT_COMMAND_ONLY";
|
||||
case ClientFunctionIndex::Function::Visibility::PATCHES_MENU_ONLY:
|
||||
return "PATCHES_MENU_ONLY";
|
||||
case ClientFunctionIndex::Function::Visibility::PATCHES_MENU_AND_CHAT_COMMAND:
|
||||
return "PATCHES_MENU_AND_CHAT_COMMAND";
|
||||
default:
|
||||
throw std::logic_error("Invalid client function visibility");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <phosg/Strings.hh>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "Menu.hh"
|
||||
|
||||
class ClientFunctionIndex {
|
||||
public:
|
||||
struct Function {
|
||||
enum class Architecture {
|
||||
UNKNOWN = 0,
|
||||
POWERPC, // GC
|
||||
X86, // PC, XB, BB
|
||||
SH4, // Dreamcast
|
||||
};
|
||||
Architecture arch = Architecture::UNKNOWN;
|
||||
std::string code;
|
||||
std::vector<uint16_t> relocation_deltas;
|
||||
std::unordered_map<std::string, uint32_t> label_offsets;
|
||||
uint32_t entrypoint_offset_offset = 0;
|
||||
std::string short_name; // Based on filename
|
||||
std::string long_name; // From .meta name directive
|
||||
std::string description; // From .meta description directive
|
||||
uint64_t client_flag = 0; // From .meta client_flag directive
|
||||
uint32_t menu_item_id = 0;
|
||||
enum class Visibility {
|
||||
DEBUG_ONLY = 0,
|
||||
CHAT_COMMAND_ONLY_WITH_CHEAT_MODE,
|
||||
CHAT_COMMAND_ONLY,
|
||||
PATCHES_MENU_ONLY,
|
||||
PATCHES_MENU_AND_CHAT_COMMAND,
|
||||
};
|
||||
Visibility visibility;
|
||||
bool show_return_value = false;
|
||||
uint32_t specific_version;
|
||||
|
||||
inline bool appears_in_patches_menu() const {
|
||||
return (this->visibility == Visibility::PATCHES_MENU_ONLY) ||
|
||||
(this->visibility == Visibility::PATCHES_MENU_AND_CHAT_COMMAND);
|
||||
}
|
||||
inline bool allowed_via_chat_command(bool cheat_mode_enabled) const {
|
||||
return (cheat_mode_enabled && (this->visibility == Visibility::CHAT_COMMAND_ONLY_WITH_CHEAT_MODE)) ||
|
||||
(this->visibility == Visibility::CHAT_COMMAND_ONLY) ||
|
||||
(this->visibility == Visibility::PATCHES_MENU_AND_CHAT_COMMAND);
|
||||
}
|
||||
|
||||
inline bool is_big_endian() const {
|
||||
return (this->arch == Architecture::POWERPC);
|
||||
}
|
||||
|
||||
template <bool BE>
|
||||
std::string generate_client_command_t(
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes,
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
uint32_t override_relocations_offset = 0) const;
|
||||
std::string generate_client_command(
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes = {},
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
uint32_t override_relocations_offset = 0) const;
|
||||
};
|
||||
|
||||
ClientFunctionIndex() = default;
|
||||
ClientFunctionIndex(const std::string& directory, bool raise_on_any_failure);
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Function>> all_functions; // Key is "PatchName-SpecificVersion"
|
||||
std::map<uint32_t, std::map<std::string, std::shared_ptr<Function>>> functions_by_specific_version;
|
||||
std::map<uint32_t, std::shared_ptr<Function>> functions_by_menu_item_id;
|
||||
|
||||
std::shared_ptr<const Menu> patch_switches_menu(
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const;
|
||||
bool patch_menu_empty(uint32_t specific_version) const;
|
||||
|
||||
std::shared_ptr<const Function> get(const std::string& name, uint32_t specific_version) const;
|
||||
std::shared_ptr<const Function> get(const std::string& name, Function::Architecture arch) const;
|
||||
std::shared_ptr<const Function> get(const std::string& name) const;
|
||||
std::shared_ptr<const Function> get_by_menu_item_id(uint32_t menu_item_id) const;
|
||||
};
|
||||
|
||||
const char* name_for_architecture(ClientFunctionIndex::Function::Architecture arch);
|
||||
uint32_t specific_version_for_gc_header_checksum(uint32_t header_checksum);
|
||||
|
||||
template <>
|
||||
const char* phosg::name_for_enum<ClientFunctionIndex::Function::Visibility>(
|
||||
ClientFunctionIndex::Function::Visibility vis);
|
||||
@@ -4269,7 +4269,9 @@ struct G_Attack_6x43_6x44_6x45 {
|
||||
le_uint16_t unknown_a2 = 0;
|
||||
} __packed_ws__(G_Attack_6x43_6x44_6x45, 8);
|
||||
|
||||
// 6x46: Attack finished (sent after each of 43, 44, and 45) (protected on GC NTE/V3/V4)
|
||||
// 6x46: Set attack strike targets (sent after each of 43, 44, and 45) (protected on GC NTE/V3/V4)
|
||||
// This command sets the targets of each strike of an attack (e.g. each pair of mechgun bullets, or each swing of a
|
||||
// pair of daggers). For multi-strike attacks, this is sent multiple times.
|
||||
// The number of targets is not bounds-checked during byteswapping on GC clients. The client only expects up to 10
|
||||
// entries here, so if the number of targets is too large, the client will byteswap the function's return address on
|
||||
// the stack, and it will crash.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <phosg/Encoding.hh>
|
||||
#include <phosg/Strings.hh>
|
||||
#include <phosg/Vector.hh>
|
||||
#include <set>
|
||||
|
||||
#include "Text.hh"
|
||||
|
||||
@@ -160,3 +162,114 @@ struct RELFileFooterT {
|
||||
} __packed_ws_be__(RELFileFooterT, 0x20);
|
||||
using RELFileFooter = RELFileFooterT<false>;
|
||||
using RELFileFooterBE = RELFileFooterT<true>;
|
||||
|
||||
template <bool BE>
|
||||
std::set<uint32_t> all_relocation_offsets_for_rel_file(const void* data, size_t size) {
|
||||
phosg::StringReader r(data, size);
|
||||
|
||||
std::set<uint32_t> ret;
|
||||
ret.emplace(r.size() - 0x20); // REL footer
|
||||
ret.emplace(r.pget<U32T<BE>>(r.size() - 0x10)); // root
|
||||
ret.emplace(r.pget<U32T<BE>>(r.size() - 0x20)); // relocations
|
||||
|
||||
const auto& footer = r.pget<RELFileFooterT<BE>>(r.size() - sizeof(RELFileFooterT<BE>));
|
||||
auto sub_r = r.sub(footer.relocations_offset, footer.num_relocations * sizeof(U16T<BE>));
|
||||
uint32_t offset = 0;
|
||||
while (!sub_r.eof()) {
|
||||
offset += sub_r.template get<U16T<BE>>() * 4;
|
||||
ret.emplace(r.pget<U32T<BE>>(offset));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t get_rel_array_count(const std::set<uint32_t>& offsets, size_t start_offset) {
|
||||
auto it = offsets.lower_bound(start_offset);
|
||||
if (it == offsets.end()) {
|
||||
throw std::out_of_range("start offset out of range");
|
||||
}
|
||||
if (*it == start_offset) {
|
||||
it++;
|
||||
}
|
||||
if (it == offsets.end()) {
|
||||
throw std::out_of_range("no further offset beyond start offset");
|
||||
}
|
||||
return (*it - start_offset) / sizeof(T);
|
||||
}
|
||||
|
||||
template <bool BE>
|
||||
class RELFileWriter {
|
||||
public:
|
||||
RELFileWriter() = default;
|
||||
~RELFileWriter() = default;
|
||||
|
||||
template <typename T>
|
||||
uint32_t put(const T& obj) {
|
||||
uint32_t ret = this->w.size();
|
||||
this->w.put<T>(obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t write(const void* data, size_t size) {
|
||||
uint32_t ret = this->w.size();
|
||||
this->w.write(data, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t write(const std::string& data) {
|
||||
uint32_t ret = this->w.size();
|
||||
this->w.write(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t write_offset(uint32_t value) {
|
||||
uint32_t ret = this->w.size();
|
||||
this->relocations.emplace(ret);
|
||||
this->w.put<U32T<BE>>(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t write_ref(const ArrayRefT<BE>& ref) {
|
||||
uint32_t ret = this->w.size();
|
||||
this->w.put<ArrayRefT<BE>>(ref);
|
||||
this->relocations.emplace(ret + offsetof(ArrayRefT<BE>, offset));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void align(size_t alignment) {
|
||||
while (this->w.size() & (alignment - 1)) {
|
||||
this->w.put_u8(0);
|
||||
}
|
||||
}
|
||||
|
||||
std::string finalize(uint32_t root_offset) {
|
||||
RELFileFooterT<BE> footer;
|
||||
footer.root_offset = root_offset;
|
||||
|
||||
this->align(0x20);
|
||||
footer.relocations_offset = this->w.size();
|
||||
footer.num_relocations = this->relocations.size();
|
||||
footer.unused1[0] = 1;
|
||||
uint32_t last_offset = 0;
|
||||
for (uint32_t reloc_offset : this->relocations) {
|
||||
if (reloc_offset & 3) {
|
||||
throw std::logic_error("Relocation is not 4-byte aligned");
|
||||
}
|
||||
size_t reloc_value = (reloc_offset - last_offset) >> 2;
|
||||
if (reloc_value > 0xFFFF) {
|
||||
throw std::runtime_error("Relocation offset is too far away from previous");
|
||||
}
|
||||
this->w.put<U16T<BE>>(reloc_value);
|
||||
last_offset = reloc_offset;
|
||||
}
|
||||
|
||||
align(0x20);
|
||||
this->w.put<RELFileFooterT<BE>>(footer);
|
||||
|
||||
return std::move(this->w.str());
|
||||
}
|
||||
|
||||
phosg::StringWriter w;
|
||||
std::set<uint32_t> relocations;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "DOLFileIndex.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/Time.hh>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <resource_file/Emulators/PPC32Emulator.hh>
|
||||
#include <resource_file/Emulators/SH4Emulator.hh>
|
||||
#include <resource_file/Emulators/X86Emulator.hh>
|
||||
|
||||
#include "CommandFormats.hh"
|
||||
#include "CommonFileFormats.hh"
|
||||
#include "Compression.hh"
|
||||
#include "Loggers.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
DOLFileIndex::DOLFileIndex(const string& directory) {
|
||||
if (!std::filesystem::is_directory(directory)) {
|
||||
client_functions_log.info_f("DOL file directory is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
auto menu = make_shared<Menu>(MenuID::PROGRAMS, "Programs");
|
||||
this->menu = menu;
|
||||
menu->items.emplace_back(ProgramsMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
for (const auto& item : std::filesystem::directory_iterator(directory)) {
|
||||
filenames.emplace_back(item.path().filename().string());
|
||||
}
|
||||
std::sort(filenames.begin(), filenames.end());
|
||||
|
||||
uint32_t next_menu_item_id = 0;
|
||||
for (const auto& filename : filenames) {
|
||||
bool is_dol = filename.ends_with(".dol");
|
||||
bool is_compressed_dol = filename.ends_with(".dol.prs");
|
||||
if (!is_dol && !is_compressed_dol) {
|
||||
continue;
|
||||
}
|
||||
string name = filename.substr(0, filename.size() - (is_compressed_dol ? 8 : 4));
|
||||
|
||||
try {
|
||||
auto dol = make_shared<File>();
|
||||
dol->menu_item_id = next_menu_item_id++;
|
||||
dol->name = name;
|
||||
|
||||
string path = directory + "/" + filename;
|
||||
string file_data = phosg::load_file(path);
|
||||
|
||||
string description;
|
||||
if (is_compressed_dol) {
|
||||
size_t decompressed_size = prs_decompress_size(file_data);
|
||||
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(file_data.size());
|
||||
w.put_u32b(decompressed_size);
|
||||
w.write(file_data);
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
dol->data = std::move(w.str());
|
||||
|
||||
string compressed_size_str = phosg::format_size(file_data.size());
|
||||
string decompressed_size_str = phosg::format_size(decompressed_size);
|
||||
client_functions_log.debug_f("Loaded compressed DOL file {} ({} -> {})",
|
||||
dol->name, compressed_size_str, decompressed_size_str);
|
||||
description = std::format("$C6{}$C7\n{}\n{} (orig)", dol->name, compressed_size_str, decompressed_size_str);
|
||||
|
||||
} else {
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(0);
|
||||
w.put_u32b(file_data.size());
|
||||
w.write(file_data);
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
dol->data = std::move(w.str());
|
||||
|
||||
string size_str = phosg::format_size(dol->data.size());
|
||||
client_functions_log.debug_f("Loaded DOL file {} ({})", filename, size_str);
|
||||
description = std::format("$C6{}$C7\n{}", dol->name, size_str);
|
||||
}
|
||||
|
||||
this->item_id_to_file.emplace_back(dol);
|
||||
menu->items.emplace_back(dol->menu_item_id, dol->name, description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
|
||||
} catch (const exception& e) {
|
||||
client_functions_log.warning_f("Failed to load DOL file {}: {}", filename, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "Menu.hh"
|
||||
|
||||
struct DOLFileIndex {
|
||||
struct File {
|
||||
uint32_t menu_item_id;
|
||||
std::string name;
|
||||
std::string data;
|
||||
bool is_compressed;
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<File>> item_id_to_file;
|
||||
std::shared_ptr<const Menu> menu;
|
||||
|
||||
DOLFileIndex() = default;
|
||||
explicit DOLFileIndex(const std::string& directory);
|
||||
|
||||
inline bool empty() const {
|
||||
return this->item_id_to_file.empty();
|
||||
}
|
||||
};
|
||||
+207
-147
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Strings.hh>
|
||||
#include <set>
|
||||
|
||||
#include "Loggers.hh"
|
||||
#include "PSOEncryption.hh"
|
||||
@@ -18,140 +19,140 @@ static constexpr uint8_t BOSS = EnemyTypeDefinition::Flag::IS_BOSS;
|
||||
static constexpr uint8_t NONE = 0xFF;
|
||||
static const vector<EnemyTypeDefinition> type_defs{
|
||||
// clang-format off
|
||||
// TYPE FLAGS RT OLDRT BP-STATS BP-ATTACK BP-RESIST ENUM NAME IN-GAME NAME ULTIMATE NAME
|
||||
{EnemyType::UNKNOWN, 0, NONE, NONE, {}, {}, {}, "UNKNOWN", "__UNKNOWN__", nullptr},
|
||||
{EnemyType::NONE, 0, NONE, NONE, {}, {}, {}, "NONE", "__NONE__", nullptr},
|
||||
{EnemyType::NON_ENEMY_NPC, EP1 | EP2 | EP4, NONE, NONE, {}, {}, {}, "NON_ENEMY_NPC", "__NPC__", nullptr},
|
||||
{EnemyType::AL_RAPPY, EP1 | RARE, 0x06, 0x06, {0x19}, {0x19}, {0x19}, "AL_RAPPY", "Al Rappy", "Pal Rappy"},
|
||||
{EnemyType::ASTARK, EP4, 0x58, 0x41, {0x09}, {0x0B, 0x0A, 0x0C}, {0x09}, "ASTARK", "Astark", nullptr},
|
||||
{EnemyType::BA_BOOTA, EP4, 0x62, 0x4F, {0x03}, {0x03, 0x02, 0x04}, {0x03}, "BA_BOOTA", "Ba Boota", nullptr},
|
||||
{EnemyType::BARBA_RAY, EP2 | BOSS, 0x49, 0x49, {0x0F}, {0x0F}, {0x0F}, "BARBA_RAY", "Barba Ray", nullptr},
|
||||
{EnemyType::BARBA_RAY_JOINT, EP2 | BOSS, 0x49, 0x49, {0x10}, {0x0F}, {0x10}, "BARBA_RAY_JOINT", "Barba Ray (joint)", nullptr},
|
||||
{EnemyType::BARBAROUS_WOLF, EP1 | EP2, 0x08, 0x08, {0x03}, {0x03}, {0x03}, "BARBAROUS_WOLF", "Barbarous Wolf", "Gulgus-gue"},
|
||||
{EnemyType::BEE_L, EP1 | EP2, NONE, NONE, {0x0C}, {0x0C}, {0x0C}, "BEE_L", "Bee L", "Gee L"},
|
||||
{EnemyType::BEE_R, EP1 | EP2, NONE, NONE, {0x0B}, {0x0B}, {0x0B}, "BEE_R", "Bee R", "Gee R"},
|
||||
{EnemyType::BOOMA, EP1, 0x09, 0x09, {0x4B}, {0x4E}, {0x4A}, "BOOMA", "Booma", "Bartle"},
|
||||
{EnemyType::BOOTA, EP4, 0x60, 0x4D, {0x00}, {0x00, 0x02, 0x04}, {0x00}, "BOOTA", "Boota", nullptr},
|
||||
{EnemyType::BULCLAW, EP1, 0x28, 0x28, {0x1F}, {0x1F}, {0x1F}, "BULCLAW", "Bulclaw", nullptr},
|
||||
{EnemyType::BULK, EP1, 0x27, 0x27, {0x1F}, {0x1F}, {0x1F}, "BULK", "Bulk", nullptr},
|
||||
{EnemyType::CANADINE, EP1, 0x1C, 0x1C, {0x07}, {0x07}, {0x07}, "CANADINE", "Canadine", "Canabin"},
|
||||
{EnemyType::CANADINE_GROUP, EP1, 0x1C, 0x1C, {0x08}, {0x08}, {0x08}, "CANADINE_GROUP", "Canadine (group)", "Canabin (group)"},
|
||||
{EnemyType::CANANE, EP1, 0x1D, 0x1D, {0x09}, {0x09}, {0x09}, "CANANE", "Canane", "Canune"},
|
||||
{EnemyType::CHAOS_BRINGER, EP1, 0x24, 0x24, {0x0D}, {0x0D}, {0x0D}, "CHAOS_BRINGER", "Chaos Bringer", "Dark Bringer"},
|
||||
{EnemyType::CHAOS_SORCERER, EP1 | EP2, 0x1F, 0x1F, {0x0A}, {0x0A}, {0x0A}, "CHAOS_SORCERER", "Chaos Sorceror", "Gran Sorceror"},
|
||||
{EnemyType::CLAW, EP1, 0x26, 0x26, {0x20}, {0x20}, {0x20}, "CLAW", "Claw", nullptr},
|
||||
{EnemyType::DARK_BELRA, EP1 | EP2, 0x25, 0x25, {0x0E}, {0x0E, 0x13}, {0x0E}, "DARK_BELRA", "Dark Belra", "Indi Belra"},
|
||||
{EnemyType::DARK_FALZ_1, EP1 | BOSS, NONE, NONE, {0x36}, {0x36}, {0x36}, "DARK_FALZ_1", "Dark Falz (phase 1)", nullptr},
|
||||
{EnemyType::DARK_FALZ_2, EP1 | BOSS, 0x2F, 0x2F, {0x37}, {0x37}, {0x37}, "DARK_FALZ_2", "Dark Falz (phase 2)", nullptr},
|
||||
{EnemyType::DARK_FALZ_3, EP1 | BOSS, 0x2F, 0x2F, {0x38}, {0x38}, {0x38}, "DARK_FALZ_3", "Dark Falz (phase 3)", nullptr},
|
||||
{EnemyType::DARK_GUNNER, EP1, 0x22, 0x22, {0x1E}, {0x1E}, {0x1E}, "DARK_GUNNER", "Dark Gunner", nullptr},
|
||||
{EnemyType::DARK_GUNNER_CONTROL, EP1, NONE, NONE, {}, {}, {}, "DARK_GUNNER_CONTROL", "Dark Gunner (control)", nullptr},
|
||||
{EnemyType::DARVANT, EP1, NONE, NONE, {0x35}, {0x35}, {0x35}, "DARVANT", "Darvant", nullptr},
|
||||
{EnemyType::DE_ROL_LE, EP1 | BOSS, 0x2D, 0x2D, {0x0F}, {0x0F}, {0x0F}, "DE_ROL_LE", "De Rol Le", "Dal Ral Lie"},
|
||||
{EnemyType::DE_ROL_LE_BODY, EP1 | BOSS, NONE, NONE, {0x10}, {0x0F}, {0x10}, "DE_ROL_LE_BODY", "De Rol Le (body)", "Dal Ral Lie (body)"},
|
||||
{EnemyType::DE_ROL_LE_MINE, EP1 | BOSS, NONE, NONE, {0x11}, {0x0F}, {0x11}, "DE_ROL_LE_MINE", "De Rol Le (mine)", "Dal Ral Lie (mine)"},
|
||||
{EnemyType::DEATH_GUNNER, EP1, 0x23, 0x23, {0x1E}, {0x1E}, {0x1E}, "DEATH_GUNNER", "Death Gunner", nullptr},
|
||||
{EnemyType::DEL_LILY, EP2, 0x53, 0x53, {0x25}, {0x25}, {0x25}, "DEL_LILY", "Del Lily", nullptr},
|
||||
{EnemyType::DEL_RAPPY_CRATER, EP4, 0x69, 0x57, {0x06}, {0x06}, {0x06}, "DEL_RAPPY_CRATER", "Del Rappy (crater)", nullptr},
|
||||
{EnemyType::DEL_RAPPY_DESERT, EP4, 0x69, 0x58, {0x18}, {0x18}, {0x18}, "DEL_RAPPY_DESERT", "Del Rappy (desert)", nullptr},
|
||||
{EnemyType::DELBITER, EP2, 0x48, 0x48, {0x0D}, {0x0D}, {0x0D}, "DELBITER", "Delbiter", nullptr},
|
||||
{EnemyType::DELDEPTH, EP2, 0x47, 0x47, {0x30}, {0x30}, {0x30}, "DELDEPTH", "Deldepth", nullptr},
|
||||
{EnemyType::DELSABER, EP1 | EP2, 0x1E, 0x1E, {0x52}, {0x57, 0x58, 0x59}, {0x51}, "DELSABER", "Delsaber", nullptr},
|
||||
{EnemyType::DIMENIAN, EP1 | EP2, 0x29, 0x29, {0x53}, {0x5A}, {0x52}, "DIMENIAN", "Dimenian", "Arlan"},
|
||||
{EnemyType::DOLMDARL, EP2, 0x41, 0x41, {0x50}, {0x55}, {0x4F}, "DOLMDARL", "Dolmdarl", nullptr},
|
||||
{EnemyType::DOLMOLM, EP2, 0x40, 0x40, {0x4F}, {0x54}, {0x4E}, "DOLMOLM", "Dolmolm", nullptr},
|
||||
{EnemyType::DORPHON, EP4, 0x63, 0x50, {0x0F}, {0x0F}, {0x0F}, "DORPHON", "Dorphon", nullptr},
|
||||
{EnemyType::DORPHON_ECLAIR, EP4 | RARE, 0x64, 0x51, {0x10}, {0x10}, {0x10}, "DORPHON_ECLAIR", "Dorphon Eclair", nullptr},
|
||||
{EnemyType::DRAGON, EP1 | BOSS, 0x2C, 0x2C, {0x12}, {0x12, 0x14, 0x15, 0x16, 0x17}, {0x12}, "DRAGON", "Dragon", "Sil Dragon"},
|
||||
{EnemyType::DUBCHIC, EP1 | EP2, 0x18, 0x18, {0x1B}, {0x1B}, {0x1B}, "DUBCHIC", "Dubchic", "Dubchich"},
|
||||
{EnemyType::DUBWITCH, EP1 | EP2, NONE, NONE, {}, {}, {}, "DUBWITCH", "Dubwitch", "Duvuik"},
|
||||
{EnemyType::EGG_RAPPY, EP2, 0x51, 0x51, {0x19}, {0x19}, {0x19}, "EGG_RAPPY", "Egg Rappy", nullptr},
|
||||
{EnemyType::EPSIGARD, EP2, NONE, NONE, {0x24}, {0x24}, {0x24}, "EPSIGARD", "Episgard", nullptr},
|
||||
{EnemyType::EPSILON, EP2, 0x54, 0x54, {0x23}, {0x23}, {0x23}, "EPSILON", "Epsilon", nullptr},
|
||||
{EnemyType::EVIL_SHARK, EP1, 0x10, 0x10, {0x4F}, {0x54}, {0x4E}, "EVIL_SHARK", "Evil Shark", "Vulmer"},
|
||||
{EnemyType::GAEL_OR_GIEL, EP2, NONE, NONE, {0x2E}, {0x2E}, {0x2E}, "GAEL_OR_GIEL", "Gael/Giel", nullptr},
|
||||
{EnemyType::GAL_GRYPHON, EP2 | BOSS, 0x4D, 0x4D, {0x1E}, {0x1E, 0x1F, 0x20, 0x21, 0x22}, {0x1E}, "GAL_GRYPHON", "Gal Gryphon", nullptr},
|
||||
{EnemyType::GARANZ, EP1 | EP2, 0x19, 0x19, {0x1D}, {0x1D}, {0x1D}, "GARANZ", "Garanz", "Baranz"},
|
||||
{EnemyType::GEE, EP2, 0x36, 0x36, {0x07}, {0x07}, {0x07}, "GEE", "Gee", nullptr},
|
||||
{EnemyType::GI_GUE, EP2, 0x37, 0x37, {0x1A}, {0x1A}, {0x1A}, "GI_GUE", "Gi Gue", nullptr},
|
||||
{EnemyType::GIBBLES, EP2, 0x3D, 0x3D, {0x3D}, {0x3D, 0x3E, 0x3F}, {0x3D}, "GIBBLES", "Gibbles", nullptr},
|
||||
{EnemyType::GIGOBOOMA, EP1, 0x0B, 0x0B, {0x4D}, {0x50}, {0x4C}, "GIGOBOOMA", "Gigobooma", "Tollaw"},
|
||||
{EnemyType::GILLCHIC, EP1 | EP2, 0x32, 0x32, {0x1C}, {0x1C}, {0x1C}, "GILLCHIC", "Gillchic", "Gillchich"},
|
||||
{EnemyType::GIRTABLULU, EP4, 0x5D, 0x48, {0x1F}, {0x1F}, {0x1F}, "GIRTABLULU", "Girtablulu", nullptr},
|
||||
{EnemyType::GOBOOMA, EP1, 0x0A, 0x0A, {0x4C}, {0x4F}, {0x4B}, "GOBOOMA", "Gobooma", "Barble"},
|
||||
{EnemyType::GOL_DRAGON, EP2 | BOSS, 0x4C, 0x4C, {0x12}, {0x12, 0x14, 0x15, 0x16, 0x17}, {0x12}, "GOL_DRAGON", "Gol Dragon", nullptr},
|
||||
{EnemyType::GORAN, EP4, 0x65, 0x52, {0x11}, {0x11, 0x14}, {0x11}, "GORAN", "Goran", nullptr},
|
||||
{EnemyType::GORAN_DETONATOR, EP4, 0x66, 0x53, {0x13}, {0x13, 0x16}, {0x13}, "GORAN_DETONATOR", "Goran Detonator", nullptr},
|
||||
{EnemyType::GRASS_ASSASSIN, EP1 | EP2, 0x0C, 0x0C, {0x4E}, {0x51, 0x52, 0x53}, {0x4D}, "GRASS_ASSASSIN", "Grass Assassin", "Crimson Assassin"},
|
||||
{EnemyType::GUIL_SHARK, EP1, 0x12, 0x12, {0x51}, {0x56}, {0x50}, "GUIL_SHARK", "Guil Shark", "Melqueek"},
|
||||
{EnemyType::HALLO_RAPPY, EP2, 0x50, 0x50, {0x19}, {0x19}, {0x19}, "HALLO_RAPPY", "Hallo Rappy", nullptr},
|
||||
{EnemyType::HIDOOM, EP1 | EP2, 0x17, 0x17, {0x32}, {0x32}, {0x32}, "HIDOOM", "Hidoom", nullptr},
|
||||
{EnemyType::HILDEBEAR, EP1 | EP2, 0x01, 0x01, {0x49}, {0x48, 0x49, 0x4A}, {0x48}, "HILDEBEAR", "Hildebear", "Hildelt"},
|
||||
{EnemyType::HILDEBLUE, EP1 | EP2 | RARE, 0x02, 0x02, {0x4A}, {0x4B, 0x4C, 0x4D}, {0x49}, "HILDEBLUE", "Hildeblue", "Hildetorr"},
|
||||
{EnemyType::ILL_GILL, EP2, 0x52, 0x52, {0x26}, {0x26, 0x27, 0x28, 0x29}, {0x26}, "ILL_GILL", "Ill Gill", nullptr},
|
||||
{EnemyType::KONDRIEU, EP4 | RARE | BOSS, 0x6C, 0x5B, {0x28, 0x2A}, {0x28, 0x2A}, {0x28, 0x2A}, "KONDRIEU", "Kondrieu", nullptr},
|
||||
{EnemyType::KONDRIEU_SPINNER, EP4 | RARE | BOSS, 0x6C, 0x5B, {0x29, 0x2B}, {0x29, 0x2B}, {0x29, 0x2B}, "KONDRIEU_SPINNER", "Kondrieu (spinner)", nullptr},
|
||||
{EnemyType::LA_DIMENIAN, EP1 | EP2, 0x2A, 0x2A, {0x54}, {0x5B}, {0x53}, "LA_DIMENIAN", "La Dimenian", "Merlan"},
|
||||
{EnemyType::LOVE_RAPPY, EP2, 0x33, 0x33, {0x19}, {0x19}, {0x19}, "LOVE_RAPPY", "Love Rappy", nullptr},
|
||||
{EnemyType::MERICARAND, EP2, 0x38, 0x38, {0x3A}, {0x3A}, {0x3A}, "MERICARAND", "Mericarand", nullptr},
|
||||
{EnemyType::MERICAROL, EP2, 0x38, 0x38, {0x3A}, {0x3A}, {0x3A}, "MERICAROL", "Mericarol", nullptr},
|
||||
{EnemyType::MERICUS, EP2 | RARE, 0x3A, 0x3A, {0x46}, {0x46}, {0x46}, "MERICUS", "Mericus", nullptr},
|
||||
{EnemyType::MERIKLE, EP2 | RARE, 0x39, 0x39, {0x45}, {0x45}, {0x45}, "MERIKLE", "Merikle", nullptr},
|
||||
{EnemyType::MERILLIA, EP2, 0x34, 0x34, {0x4B}, {0x4E}, {0x4A}, "MERILLIA", "Merillia", nullptr},
|
||||
{EnemyType::MERILTAS, EP2, 0x35, 0x35, {0x4C}, {0x4F}, {0x4B}, "MERILTAS", "Meriltas", nullptr},
|
||||
{EnemyType::MERISSA_A, EP4, 0x5B, 0x46, {0x19}, {0x19}, {0x19}, "MERISSA_A", "Merissa A", nullptr},
|
||||
{EnemyType::MERISSA_AA, EP4 | RARE, 0x5C, 0x47, {0x1A}, {0x1A}, {0x1A}, "MERISSA_AA", "Merissa AA", nullptr},
|
||||
{EnemyType::MIGIUM, EP1 | EP2, 0x16, 0x16, {0x33}, {0x33}, {0x33}, "MIGIUM", "Migium", nullptr},
|
||||
{EnemyType::MONEST, EP1 | EP2, 0x04, 0x04, {0x01}, {0x01}, {0x01}, "MONEST", "Monest", "Mothvist"},
|
||||
{EnemyType::MORFOS, EP2, 0x42, 0x42, {0x40}, {0x40, 0x50}, {0x40}, "MORFOS", "Morfos", nullptr},
|
||||
{EnemyType::MOTHMANT, EP1 | EP2, 0x03, 0x03, {0x00}, {0x00}, {0x00}, "MOTHMANT", "Mothmant", "Mothvert"},
|
||||
{EnemyType::NANO_DRAGON, EP1, 0x0F, 0x0F, {0x1A}, {0x1A}, {0x1A}, "NANO_DRAGON", "Nano Dragon", nullptr},
|
||||
{EnemyType::NAR_LILY, EP1 | EP2 | RARE, 0x0E, 0x0E, {0x05}, {0x05}, {0x05}, "NAR_LILY", "Nar Lily", "Mil Lily"},
|
||||
{EnemyType::OLGA_FLOW_1, EP2 | BOSS, NONE, NONE, {0x2B}, {0x2B}, {0x2B}, "OLGA_FLOW_1", "Olga Flow (phase 1)", nullptr},
|
||||
{EnemyType::OLGA_FLOW_2, EP2 | BOSS, 0x4E, 0x4E, {0x2C}, {0x2C}, {0x2C}, "OLGA_FLOW_2", "Olga Flow (phase 2)", nullptr},
|
||||
{EnemyType::PAL_SHARK, EP1, 0x11, 0x11, {0x50}, {0x55}, {0x4F}, "PAL_SHARK", "Pal Shark", "Govulmer"},
|
||||
{EnemyType::PAN_ARMS, EP1 | EP2, 0x15, 0x15, {0x31}, {0x31}, {0x31}, "PAN_ARMS", "Pan Arms", nullptr},
|
||||
{EnemyType::PAZUZU_CRATER, EP4 | RARE, 0x5F, 0x4B, {0x08}, {0x08}, {0x08}, "PAZUZU_CRATER", "Pazuzu (crater)", nullptr},
|
||||
{EnemyType::PAZUZU_DESERT, EP4 | RARE, 0x5F, 0x4C, {0x1C}, {0x1C}, {0x1C}, "PAZUZU_DESERT", "Pazuzu (desert)", nullptr},
|
||||
{EnemyType::PIG_RAY, EP2, 0x4A, NONE, {0x08}, {0x08}, {0x08}, "PIG_RAY", "Pig Ray", nullptr},
|
||||
{EnemyType::POFUILLY_SLIME, EP1, 0x13, 0x13, {0x30}, {0x30}, {0x30}, "POFUILLY_SLIME", "Pofuilly Slime", nullptr},
|
||||
{EnemyType::POUILLY_SLIME, EP1 | RARE, 0x14, 0x14, {0x34}, {0x34}, {0x34}, "POUILLY_SLIME", "Pouilly Slime", nullptr},
|
||||
{EnemyType::POISON_LILY, EP1 | EP2, 0x0D, 0x0D, {0x04}, {0x04}, {0x04}, "POISON_LILY", "Poison Lily", "Ob Lily"},
|
||||
{EnemyType::PYRO_GORAN, EP4, 0x67, 0x54, {0x12}, {0x12, 0x15}, {0x12}, "PYRO_GORAN", "Pyro Goran", nullptr},
|
||||
{EnemyType::RAG_RAPPY, EP1 | EP2, 0x05, 0x05, {0x18}, {0x18}, {0x18}, "RAG_RAPPY", "Rag Rappy", "El Rappy"},
|
||||
{EnemyType::RECOBOX, EP2, 0x43, 0x43, {0x41}, {0x41}, {0x41}, "RECOBOX", "Recobox", nullptr},
|
||||
{EnemyType::RECON, EP2, 0x44, 0x44, {0x42}, {0x42}, {0x42}, "RECON", "Recon", nullptr},
|
||||
{EnemyType::SAINT_MILION, EP4 | BOSS, 0x6A, 0x59, {0x20, 0x22}, {0x20, 0x22}, {0x20, 0x22}, "SAINT_MILION", "Saint-Milion", nullptr},
|
||||
{EnemyType::SAINT_MILION_SPINNER, EP4 | BOSS, 0x6A, 0x59, {0x21, 0x23}, {0x21, 0x23}, {0x21, 0x23}, "SAINT_MILION_SPINNER", "Saint-Milion (spinner)", nullptr},
|
||||
{EnemyType::SAINT_RAPPY, EP2, 0x4F, 0x4F, {0x19}, {0x19}, {0x19}, "SAINT_RAPPY", "Saint Rappy", nullptr},
|
||||
{EnemyType::SAND_RAPPY_CRATER, EP4, 0x68, 0x55, {0x05}, {0x05}, {0x05}, "SAND_RAPPY_CRATER", "Sand Rappy (crater)", nullptr},
|
||||
{EnemyType::SAND_RAPPY_DESERT, EP4, 0x68, 0x56, {0x17}, {0x17}, {0x17}, "SAND_RAPPY_DESERT", "Sand Rappy (desert)", nullptr},
|
||||
{EnemyType::SATELLITE_LIZARD_CRATER, EP4, 0x5A, 0x44, {0x0D}, {0x0D}, {0x0D}, "SATELLITE_LIZARD_CRATER", "Satellite Lizard (crater)", nullptr},
|
||||
{EnemyType::SATELLITE_LIZARD_DESERT, EP4, 0x5A, 0x45, {0x1D}, {0x1D}, {0x1D}, "SATELLITE_LIZARD_DESERT", "Satellite Lizard (desert)", nullptr},
|
||||
{EnemyType::SAVAGE_WOLF, EP1 | EP2, 0x07, 0x07, {0x02}, {0x02}, {0x02}, "SAVAGE_WOLF", "Savage Wolf", "Gulgus"},
|
||||
{EnemyType::SHAMBERTIN, EP4 | BOSS, 0x6B, 0x5A, {0x24, 0x26}, {0x24, 0x26}, {0x24, 0x26}, "SHAMBERTIN", "Shambertin", nullptr},
|
||||
{EnemyType::SHAMBERTIN_SPINNER, EP4 | BOSS, 0x6B, 0x5A, {0x25, 0x27}, {0x25, 0x27}, {0x25, 0x27}, "SHAMBERTIN_SPINNER", "Shambertin (spinner)", nullptr},
|
||||
{EnemyType::SINOW_BEAT, EP1, 0x1A, 0x1A, {0x06}, {0x06}, {0x06}, "SINOW_BEAT", "Sinow Beat", "Sinow Blue"},
|
||||
{EnemyType::SINOW_BERILL, EP2, 0x3E, 0x3E, {0x06}, {0x06}, {0x06}, "SINOW_BERILL", "Sinow Berill", nullptr},
|
||||
{EnemyType::SINOW_GOLD, EP1, 0x1B, 0x1B, {0x13}, {0x47}, {0x13}, "SINOW_GOLD", "Sinow Gold", "Sinow Red"},
|
||||
{EnemyType::SINOW_SPIGELL, EP2, 0x3F, 0x3F, {0x13}, {0x47}, {0x13}, "SINOW_SPIGELL", "Sinow Spigell", nullptr},
|
||||
{EnemyType::SINOW_ZELE, EP2, 0x46, 0x46, {0x44}, {0x44}, {0x44}, "SINOW_ZELE", "Sinow Zele", nullptr},
|
||||
{EnemyType::SINOW_ZOA, EP2, 0x45, 0x45, {0x43}, {0x43}, {0x43}, "SINOW_ZOA", "Sinow Zoa", nullptr},
|
||||
{EnemyType::SO_DIMENIAN, EP1 | EP2, 0x2B, 0x2B, {0x55}, {0x5C}, {0x54}, "SO_DIMENIAN", "So Dimenian", "Del-D"},
|
||||
{EnemyType::UL_GIBBON, EP2, 0x3B, 0x3B, {0x3B}, {0x3B}, {0x3B}, "UL_GIBBON", "Ul Gibbon", nullptr},
|
||||
{EnemyType::UL_RAY, EP2, 0x4B, NONE, {0x09}, {0x09}, {0x09}, "UL_RAY", "Ul Ray", nullptr},
|
||||
{EnemyType::VOL_OPT_1, EP1 | BOSS, NONE, NONE, {0x21}, {0x21}, {0x21}, "VOL_OPT_1", "Vol Opt (phase 1)", "Vol Opt ver.2 (phase 1)"},
|
||||
{EnemyType::VOL_OPT_2, EP1 | BOSS, 0x2E, 0x2E, {0x25}, {0x25}, {0x25}, "VOL_OPT_2", "Vol Opt (phase 2)", "Vol Opt ver.2 (phase 2)"},
|
||||
{EnemyType::VOL_OPT_AMP, EP1 | BOSS, NONE, NONE, {0x24}, {0x24}, {0x24}, "VOL_OPT_AMP", "Vol Opt (amp)", "Vol Opt ver.2 (amp)"},
|
||||
{EnemyType::VOL_OPT_CORE, EP1 | BOSS, NONE, NONE, {0x26}, {0x26}, {0x26}, "VOL_OPT_CORE", "Vol Opt (core)", "Vol Opt ver.2 (core)"},
|
||||
{EnemyType::VOL_OPT_MONITOR, EP1 | BOSS, NONE, NONE, {0x23}, {0x23}, {0x23}, "VOL_OPT_MONITOR", "Vol Opt (monitor)", "Vol Opt ver.2 (monitor)"},
|
||||
{EnemyType::VOL_OPT_PILLAR, EP1 | BOSS, NONE, NONE, {0x22}, {0x22}, {0x22}, "VOL_OPT_PILLAR", "Vol Opt (pillar)", "Vol Opt ver.2 (pillar)"},
|
||||
{EnemyType::YOWIE_CRATER, EP4, 0x59, 0x42, {0x0E}, {0x0E}, {0x0E}, "YOWIE_CRATER", "Yowie (crater)", nullptr},
|
||||
{EnemyType::YOWIE_DESERT, EP4, 0x59, 0x43, {0x1E}, {0x1E}, {0x1E}, "YOWIE_DESERT", "Yowie (desert)", nullptr},
|
||||
{EnemyType::ZE_BOOTA, EP4, 0x61, 0x4E, {0x01}, {0x01, 0x02, 0x04}, {0x01}, "ZE_BOOTA", "Ze Boota", nullptr},
|
||||
{EnemyType::ZOL_GIBBON, EP2, 0x3C, 0x3C, {0x3C}, {0x3C}, {0x3C}, "ZOL_GIBBON", "Zol Gibbon", nullptr},
|
||||
{EnemyType::ZU_CRATER, EP4, 0x5E, 0x49, {0x07}, {0x07}, {0x07}, "ZU_CRATER", "Zu (crater)", nullptr},
|
||||
{EnemyType::ZU_DESERT, EP4, 0x5E, 0x4A, {0x1B}, {0x1B}, {0x1B}, "ZU_DESERT", "Zu (desert)", nullptr},
|
||||
// TYPE FLAGS RT OLDRT BP-STATS BP-ATTACK BP-RESIST BP-MOVEMENT ENUM NAME IN-GAME NAME ULTIMATE NAME
|
||||
{EnemyType::UNKNOWN, 0, NONE, NONE, {}, {}, {}, {}, "UNKNOWN", "__UNKNOWN__", nullptr},
|
||||
{EnemyType::NONE, 0, NONE, NONE, {}, {}, {}, {}, "NONE", "__NONE__", nullptr},
|
||||
{EnemyType::NON_ENEMY_NPC, EP1 | EP2 | EP4, NONE, NONE, {}, {}, {}, {}, "NON_ENEMY_NPC", "__NPC__", nullptr},
|
||||
{EnemyType::AL_RAPPY, EP1 | RARE, 0x06, 0x06, {0x19}, {0x19}, {0x19}, {0x19}, "AL_RAPPY", "Al Rappy", "Pal Rappy"},
|
||||
{EnemyType::ASTARK, EP4, 0x58, 0x41, {0x09}, {0x0B, 0x0A, 0x0C}, {0x09}, {0x09}, "ASTARK", "Astark", nullptr},
|
||||
{EnemyType::BA_BOOTA, EP4, 0x62, 0x4F, {0x03}, {0x03, 0x02, 0x04}, {0x03}, {0x03}, "BA_BOOTA", "Ba Boota", nullptr},
|
||||
{EnemyType::BARBA_RAY, EP2 | BOSS, 0x49, 0x49, {0x0F}, {0x0F}, {0x0F}, {0x0F}, "BARBA_RAY", "Barba Ray", nullptr},
|
||||
{EnemyType::BARBA_RAY_JOINT, EP2 | BOSS, 0x49, 0x49, {0x10}, {0x0F}, {0x10}, {}, "BARBA_RAY_JOINT", "Barba Ray (joint)", nullptr},
|
||||
{EnemyType::BARBAROUS_WOLF, EP1 | EP2, 0x08, 0x08, {0x03}, {0x03}, {0x03}, {0x03}, "BARBAROUS_WOLF", "Barbarous Wolf", "Gulgus-gue"},
|
||||
{EnemyType::BEE_L, EP1 | EP2, NONE, NONE, {0x0C}, {0x0C}, {0x0C}, {0x0C}, "BEE_L", "Bee L", "Gee L"},
|
||||
{EnemyType::BEE_R, EP1 | EP2, NONE, NONE, {0x0B}, {0x0B}, {0x0B}, {0x0B}, "BEE_R", "Bee R", "Gee R"},
|
||||
{EnemyType::BOOMA, EP1, 0x09, 0x09, {0x4B}, {0x4E}, {0x4A}, {0x4A}, "BOOMA", "Booma", "Bartle"},
|
||||
{EnemyType::BOOTA, EP4, 0x60, 0x4D, {0x00}, {0x00, 0x02, 0x04}, {0x00}, {0x00}, "BOOTA", "Boota", nullptr},
|
||||
{EnemyType::BULCLAW, EP1, 0x28, 0x28, {0x1F}, {0x1F}, {0x1F}, {0x1F, 0x20}, "BULCLAW", "Bulclaw", nullptr},
|
||||
{EnemyType::BULK, EP1, 0x27, 0x27, {0x1F}, {0x1F}, {0x1F}, {0x1F, 0x20}, "BULK", "Bulk", nullptr},
|
||||
{EnemyType::CANADINE, EP1, 0x1C, 0x1C, {0x07}, {0x07}, {0x07}, {0x07}, "CANADINE", "Canadine", "Canabin"},
|
||||
{EnemyType::CANADINE_GROUP, EP1, 0x1C, 0x1C, {0x08}, {0x08}, {0x08}, {0x08}, "CANADINE_GROUP", "Canadine (group)", "Canabin (group)"},
|
||||
{EnemyType::CANANE, EP1, 0x1D, 0x1D, {0x09}, {0x09}, {0x09}, {0x09}, "CANANE", "Canane", "Canune"},
|
||||
{EnemyType::CHAOS_BRINGER, EP1, 0x24, 0x24, {0x0D}, {0x0D}, {0x0D}, {0x0A, 0x0D}, "CHAOS_BRINGER", "Chaos Bringer", "Dark Bringer"},
|
||||
{EnemyType::CHAOS_SORCERER, EP1 | EP2, 0x1F, 0x1F, {0x0A}, {0x0A}, {0x0A}, {}, "CHAOS_SORCERER", "Chaos Sorceror", "Gran Sorceror"},
|
||||
{EnemyType::CLAW, EP1, 0x26, 0x26, {0x20}, {0x20}, {0x20}, {}, "CLAW", "Claw", nullptr},
|
||||
{EnemyType::DARK_BELRA, EP1 | EP2, 0x25, 0x25, {0x0E}, {0x0E, 0x13}, {0x0E}, {0x0E}, "DARK_BELRA", "Dark Belra", "Indi Belra"},
|
||||
{EnemyType::DARK_FALZ_1, EP1 | BOSS, NONE, NONE, {0x36}, {0x36}, {0x36}, {0x36, 0x39}, "DARK_FALZ_1", "Dark Falz (phase 1)", nullptr},
|
||||
{EnemyType::DARK_FALZ_2, EP1 | BOSS, 0x2F, 0x2F, {0x37}, {0x37}, {0x37}, {0x37}, "DARK_FALZ_2", "Dark Falz (phase 2)", nullptr},
|
||||
{EnemyType::DARK_FALZ_3, EP1 | BOSS, 0x2F, 0x2F, {0x38}, {0x38}, {0x38}, {0x38}, "DARK_FALZ_3", "Dark Falz (phase 3)", nullptr},
|
||||
{EnemyType::DARK_GUNNER, EP1, 0x22, 0x22, {0x1E}, {0x1E}, {0x1E}, {0x1E}, "DARK_GUNNER", "Dark Gunner", nullptr},
|
||||
{EnemyType::DARK_GUNNER_CONTROL, EP1, NONE, NONE, {}, {}, {}, {}, "DARK_GUNNER_CONTROL", "Dark Gunner (control)", nullptr},
|
||||
{EnemyType::DARVANT, EP1, NONE, NONE, {0x35}, {0x35}, {0x35}, {0x35, 0x39}, "DARVANT", "Darvant", nullptr},
|
||||
{EnemyType::DE_ROL_LE, EP1 | BOSS, 0x2D, 0x2D, {0x0F}, {0x0F}, {0x0F}, {0x0F}, "DE_ROL_LE", "De Rol Le", "Dal Ral Lie"},
|
||||
{EnemyType::DE_ROL_LE_BODY, EP1 | BOSS, NONE, NONE, {0x10}, {0x0F}, {0x10}, {0x0F}, "DE_ROL_LE_BODY", "De Rol Le (body)", "Dal Ral Lie (body)"},
|
||||
{EnemyType::DE_ROL_LE_MINE, EP1 | BOSS, NONE, NONE, {0x11}, {0x0F}, {0x11}, {0x0F}, "DE_ROL_LE_MINE", "De Rol Le (mine)", "Dal Ral Lie (mine)"},
|
||||
{EnemyType::DEATH_GUNNER, EP1, 0x23, 0x23, {0x1E}, {0x1E}, {0x1E}, {0x1E}, "DEATH_GUNNER", "Death Gunner", nullptr},
|
||||
{EnemyType::DEL_LILY, EP2, 0x53, 0x53, {0x25}, {0x25}, {0x25}, {0x25}, "DEL_LILY", "Del Lily", nullptr},
|
||||
{EnemyType::DEL_RAPPY_CRATER, EP4, 0x69, 0x57, {0x06}, {0x06}, {0x06}, {0x06}, "DEL_RAPPY_CRATER", "Del Rappy (crater)", nullptr},
|
||||
{EnemyType::DEL_RAPPY_DESERT, EP4, 0x69, 0x58, {0x18}, {0x18}, {0x18}, {0x18}, "DEL_RAPPY_DESERT", "Del Rappy (desert)", nullptr},
|
||||
{EnemyType::DELBITER, EP2, 0x48, 0x48, {0x0D}, {0x0D}, {0x0D}, {0x0D}, "DELBITER", "Delbiter", nullptr},
|
||||
{EnemyType::DELDEPTH, EP2, 0x47, 0x47, {0x30}, {0x30}, {0x30}, {0x30}, "DELDEPTH", "Deldepth", nullptr},
|
||||
{EnemyType::DELSABER, EP1 | EP2, 0x1E, 0x1E, {0x52}, {0x57, 0x58, 0x59}, {0x51}, {0x51}, "DELSABER", "Delsaber", nullptr},
|
||||
{EnemyType::DIMENIAN, EP1 | EP2, 0x29, 0x29, {0x53}, {0x5A}, {0x52}, {0x52}, "DIMENIAN", "Dimenian", "Arlan"},
|
||||
{EnemyType::DOLMDARL, EP2, 0x41, 0x41, {0x50}, {0x55}, {0x4F}, {0x4F}, "DOLMDARL", "Dolmdarl", nullptr},
|
||||
{EnemyType::DOLMOLM, EP2, 0x40, 0x40, {0x4F}, {0x54}, {0x4E}, {0x4E}, "DOLMOLM", "Dolmolm", nullptr},
|
||||
{EnemyType::DORPHON, EP4, 0x63, 0x50, {0x0F}, {0x0F}, {0x0F}, {0x0F}, "DORPHON", "Dorphon", nullptr},
|
||||
{EnemyType::DORPHON_ECLAIR, EP4 | RARE, 0x64, 0x51, {0x10}, {0x10}, {0x10}, {0x10}, "DORPHON_ECLAIR", "Dorphon Eclair", nullptr},
|
||||
{EnemyType::DRAGON, EP1 | BOSS, 0x2C, 0x2C, {0x12}, {0x12, 0x14, 0x15, 0x16, 0x17}, {0x12}, {0x11}, "DRAGON", "Dragon", "Sil Dragon"},
|
||||
{EnemyType::DUBCHIC, EP1 | EP2, 0x18, 0x18, {0x1B}, {0x1B}, {0x1B}, {0x1B}, "DUBCHIC", "Dubchic", "Dubchich"},
|
||||
{EnemyType::DUBWITCH, EP1 | EP2, NONE, NONE, {}, {}, {}, {}, "DUBWITCH", "Dubwitch", "Duvuik"},
|
||||
{EnemyType::EGG_RAPPY, EP2, 0x51, 0x51, {0x19}, {0x19}, {0x19}, {0x19}, "EGG_RAPPY", "Egg Rappy", nullptr},
|
||||
{EnemyType::EPSIGARD, EP2, NONE, NONE, {0x24}, {0x24}, {0x24}, {0x24}, "EPSIGARD", "Episgard", nullptr},
|
||||
{EnemyType::EPSILON, EP2, 0x54, 0x54, {0x23}, {0x23}, {0x23}, {0x23}, "EPSILON", "Epsilon", nullptr},
|
||||
{EnemyType::EVIL_SHARK, EP1, 0x10, 0x10, {0x4F}, {0x54}, {0x4E}, {0x4E}, "EVIL_SHARK", "Evil Shark", "Vulmer"},
|
||||
{EnemyType::GAEL_OR_GIEL, EP2, NONE, NONE, {0x2E}, {0x2E}, {0x2E}, {}, "GAEL_OR_GIEL", "Gael/Giel", nullptr},
|
||||
{EnemyType::GAL_GRYPHON, EP2 | BOSS, 0x4D, 0x4D, {0x1E}, {0x1E, 0x1F, 0x20, 0x21, 0x22}, {0x1E}, {0x1E, 0x1F, 0x20}, "GAL_GRYPHON", "Gal Gryphon", nullptr},
|
||||
{EnemyType::GARANZ, EP1 | EP2, 0x19, 0x19, {0x1D}, {0x1D}, {0x1D}, {0x1D}, "GARANZ", "Garanz", "Baranz"},
|
||||
{EnemyType::GEE, EP2, 0x36, 0x36, {0x07}, {0x07}, {0x07}, {0x07}, "GEE", "Gee", nullptr},
|
||||
{EnemyType::GI_GUE, EP2, 0x37, 0x37, {0x1A}, {0x1A}, {0x1A}, {0x1A}, "GI_GUE", "Gi Gue", nullptr},
|
||||
{EnemyType::GIBBLES, EP2, 0x3D, 0x3D, {0x3D}, {0x3D, 0x3E, 0x3F}, {0x3D}, {0x3D}, "GIBBLES", "Gibbles", nullptr},
|
||||
{EnemyType::GIGOBOOMA, EP1, 0x0B, 0x0B, {0x4D}, {0x50}, {0x4C}, {0x4C}, "GIGOBOOMA", "Gigobooma", "Tollaw"},
|
||||
{EnemyType::GILLCHIC, EP1 | EP2, 0x32, 0x32, {0x1C}, {0x1C}, {0x1C}, {0x1C}, "GILLCHIC", "Gillchic", "Gillchich"},
|
||||
{EnemyType::GIRTABLULU, EP4, 0x5D, 0x48, {0x1F}, {0x1F}, {0x1F}, {0x1F}, "GIRTABLULU", "Girtablulu", nullptr},
|
||||
{EnemyType::GOBOOMA, EP1, 0x0A, 0x0A, {0x4C}, {0x4F}, {0x4B}, {0x4B}, "GOBOOMA", "Gobooma", "Barble"},
|
||||
{EnemyType::GOL_DRAGON, EP2 | BOSS, 0x4C, 0x4C, {0x12}, {0x12, 0x14, 0x15, 0x16, 0x17}, {0x12}, {0x11, 0x12, 0x13}, "GOL_DRAGON", "Gol Dragon", nullptr},
|
||||
{EnemyType::GORAN, EP4, 0x65, 0x52, {0x11}, {0x11, 0x14}, {0x11}, {0x11}, "GORAN", "Goran", nullptr},
|
||||
{EnemyType::GORAN_DETONATOR, EP4, 0x66, 0x53, {0x13}, {0x13, 0x16}, {0x13}, {0x13}, "GORAN_DETONATOR", "Goran Detonator", nullptr},
|
||||
{EnemyType::GRASS_ASSASSIN, EP1 | EP2, 0x0C, 0x0C, {0x4E}, {0x51, 0x52, 0x53}, {0x4D}, {0x4D}, "GRASS_ASSASSIN", "Grass Assassin", "Crimson Assassin"},
|
||||
{EnemyType::GUIL_SHARK, EP1, 0x12, 0x12, {0x51}, {0x56}, {0x50}, {0x50}, "GUIL_SHARK", "Guil Shark", "Melqueek"},
|
||||
{EnemyType::HALLO_RAPPY, EP2, 0x50, 0x50, {0x19}, {0x19}, {0x19}, {0x19}, "HALLO_RAPPY", "Hallo Rappy", nullptr},
|
||||
{EnemyType::HIDOOM, EP1 | EP2, 0x17, 0x17, {0x32}, {0x32}, {0x32}, {0x32}, "HIDOOM", "Hidoom", nullptr},
|
||||
{EnemyType::HILDEBEAR, EP1 | EP2, 0x01, 0x01, {0x49}, {0x48, 0x49, 0x4A}, {0x48}, {0x48}, "HILDEBEAR", "Hildebear", "Hildelt"},
|
||||
{EnemyType::HILDEBLUE, EP1 | EP2 | RARE, 0x02, 0x02, {0x4A}, {0x4B, 0x4C, 0x4D}, {0x49}, {0x49}, "HILDEBLUE", "Hildeblue", "Hildetorr"},
|
||||
{EnemyType::ILL_GILL, EP2, 0x52, 0x52, {0x26}, {0x26, 0x27, 0x28, 0x29}, {0x26}, {0x26}, "ILL_GILL", "Ill Gill", nullptr},
|
||||
{EnemyType::KONDRIEU, EP4 | RARE | BOSS, 0x6C, 0x5B, {0x28, 0x2A}, {0x28, 0x2A}, {0x28, 0x2A}, {0x28, 0x2A}, "KONDRIEU", "Kondrieu", nullptr},
|
||||
{EnemyType::KONDRIEU_SPINNER, EP4 | RARE | BOSS, 0x6C, 0x5B, {0x29, 0x2B}, {0x29, 0x2B}, {0x29, 0x2B}, {0x29, 0x2B}, "KONDRIEU_SPINNER", "Kondrieu (spinner)", nullptr},
|
||||
{EnemyType::LA_DIMENIAN, EP1 | EP2, 0x2A, 0x2A, {0x54}, {0x5B}, {0x53}, {0x53}, "LA_DIMENIAN", "La Dimenian", "Merlan"},
|
||||
{EnemyType::LOVE_RAPPY, EP2, 0x33, 0x33, {0x19}, {0x19}, {0x19}, {0x19}, "LOVE_RAPPY", "Love Rappy", nullptr},
|
||||
{EnemyType::MERICARAND, EP2, 0x38, 0x38, {0x3A}, {0x3A}, {0x3A}, {0x3A}, "MERICARAND", "Mericarand", nullptr},
|
||||
{EnemyType::MERICAROL, EP2, 0x38, 0x38, {0x3A}, {0x3A}, {0x3A}, {0x3A}, "MERICAROL", "Mericarol", nullptr},
|
||||
{EnemyType::MERICUS, EP2 | RARE, 0x3A, 0x3A, {0x46}, {0x46}, {0x46}, {0x46}, "MERICUS", "Mericus", nullptr},
|
||||
{EnemyType::MERIKLE, EP2 | RARE, 0x39, 0x39, {0x45}, {0x45}, {0x45}, {0x45}, "MERIKLE", "Merikle", nullptr},
|
||||
{EnemyType::MERILLIA, EP2, 0x34, 0x34, {0x4B}, {0x4E}, {0x4A}, {0x4A}, "MERILLIA", "Merillia", nullptr},
|
||||
{EnemyType::MERILTAS, EP2, 0x35, 0x35, {0x4C}, {0x4F}, {0x4B}, {0x4B}, "MERILTAS", "Meriltas", nullptr},
|
||||
{EnemyType::MERISSA_A, EP4, 0x5B, 0x46, {0x19}, {0x19}, {0x19}, {0x19}, "MERISSA_A", "Merissa A", nullptr},
|
||||
{EnemyType::MERISSA_AA, EP4 | RARE, 0x5C, 0x47, {0x1A}, {0x1A}, {0x1A}, {0x1A}, "MERISSA_AA", "Merissa AA", nullptr},
|
||||
{EnemyType::MIGIUM, EP1 | EP2, 0x16, 0x16, {0x33}, {0x33}, {0x33}, {0x33}, "MIGIUM", "Migium", nullptr},
|
||||
{EnemyType::MONEST, EP1 | EP2, 0x04, 0x04, {0x01}, {0x01}, {0x01}, {0x01}, "MONEST", "Monest", "Mothvist"},
|
||||
{EnemyType::MORFOS, EP2, 0x42, 0x42, {0x40}, {0x40, 0x50}, {0x40}, {0x40}, "MORFOS", "Morfos", nullptr},
|
||||
{EnemyType::MOTHMANT, EP1 | EP2, 0x03, 0x03, {0x00}, {0x00}, {0x00}, {0x00}, "MOTHMANT", "Mothmant", "Mothvert"},
|
||||
{EnemyType::NANO_DRAGON, EP1, 0x0F, 0x0F, {0x1A}, {0x1A}, {0x1A}, {0x1A}, "NANO_DRAGON", "Nano Dragon", nullptr},
|
||||
{EnemyType::NAR_LILY, EP1 | EP2 | RARE, 0x0E, 0x0E, {0x05}, {0x05}, {0x05}, {0x05}, "NAR_LILY", "Nar Lily", "Mil Lily"},
|
||||
{EnemyType::OLGA_FLOW_1, EP2 | BOSS, NONE, NONE, {0x2B}, {0x2B}, {0x2B}, {0x2B, 0x2D, 0x2F}, "OLGA_FLOW_1", "Olga Flow (phase 1)", nullptr},
|
||||
{EnemyType::OLGA_FLOW_2, EP2 | BOSS, 0x4E, 0x4E, {0x2C}, {0x2C}, {0x2C}, {0x2C, 0x2D, 0x3E, 0x2F}, "OLGA_FLOW_2", "Olga Flow (phase 2)", nullptr},
|
||||
{EnemyType::PAL_SHARK, EP1, 0x11, 0x11, {0x50}, {0x55}, {0x4F}, {0x4F}, "PAL_SHARK", "Pal Shark", "Govulmer"},
|
||||
{EnemyType::PAN_ARMS, EP1 | EP2, 0x15, 0x15, {0x31}, {0x31}, {0x31}, {0x31}, "PAN_ARMS", "Pan Arms", nullptr},
|
||||
{EnemyType::PAZUZU_CRATER, EP4 | RARE, 0x5F, 0x4B, {0x08}, {0x08}, {0x08}, {0x08}, "PAZUZU_CRATER", "Pazuzu (crater)", nullptr},
|
||||
{EnemyType::PAZUZU_DESERT, EP4 | RARE, 0x5F, 0x4C, {0x1C}, {0x1C}, {0x1C}, {0x1C}, "PAZUZU_DESERT", "Pazuzu (desert)", nullptr},
|
||||
{EnemyType::PIG_RAY, EP2, 0x4A, NONE, {0x08}, {0x08}, {0x08}, {0x08}, "PIG_RAY", "Pig Ray", nullptr},
|
||||
{EnemyType::POFUILLY_SLIME, EP1, 0x13, 0x13, {0x30}, {0x30}, {0x30}, {0x30}, "POFUILLY_SLIME", "Pofuilly Slime", nullptr},
|
||||
{EnemyType::POISON_LILY, EP1 | EP2, 0x0D, 0x0D, {0x04}, {0x04}, {0x04}, {0x04}, "POISON_LILY", "Poison Lily", "Ob Lily"},
|
||||
{EnemyType::POUILLY_SLIME, EP1 | RARE, 0x14, 0x14, {0x34}, {0x34}, {0x34}, {0x34}, "POUILLY_SLIME", "Pouilly Slime", nullptr},
|
||||
{EnemyType::PYRO_GORAN, EP4, 0x67, 0x54, {0x12}, {0x12, 0x15}, {0x12}, {0x12}, "PYRO_GORAN", "Pyro Goran", nullptr},
|
||||
{EnemyType::RAG_RAPPY, EP1 | EP2, 0x05, 0x05, {0x18}, {0x18}, {0x18}, {0x18}, "RAG_RAPPY", "Rag Rappy", "El Rappy"},
|
||||
{EnemyType::RECOBOX, EP2, 0x43, 0x43, {0x41}, {0x41}, {0x41}, {0x41}, "RECOBOX", "Recobox", nullptr},
|
||||
{EnemyType::RECON, EP2, 0x44, 0x44, {0x42}, {0x42}, {0x42}, {0x42}, "RECON", "Recon", nullptr},
|
||||
{EnemyType::SAINT_MILION, EP4 | BOSS, 0x6A, 0x59, {0x20, 0x22}, {0x20, 0x22}, {0x20, 0x22}, {0x20, 0x22}, "SAINT_MILION", "Saint-Milion", nullptr},
|
||||
{EnemyType::SAINT_MILION_SPINNER, EP4 | BOSS, 0x6A, 0x59, {0x21, 0x23}, {0x21, 0x23}, {0x21, 0x23}, {0x21, 0x23}, "SAINT_MILION_SPINNER", "Saint-Milion (spinner)", nullptr},
|
||||
{EnemyType::SAINT_RAPPY, EP2, 0x4F, 0x4F, {0x19}, {0x19}, {0x19}, {0x19}, "SAINT_RAPPY", "Saint Rappy", nullptr},
|
||||
{EnemyType::SAND_RAPPY_CRATER, EP4, 0x68, 0x55, {0x05}, {0x05}, {0x05}, {0x05}, "SAND_RAPPY_CRATER", "Sand Rappy (crater)", nullptr},
|
||||
{EnemyType::SAND_RAPPY_DESERT, EP4, 0x68, 0x56, {0x17}, {0x17}, {0x17}, {0x17}, "SAND_RAPPY_DESERT", "Sand Rappy (desert)", nullptr},
|
||||
{EnemyType::SATELLITE_LIZARD_CRATER, EP4, 0x5A, 0x44, {0x0D}, {0x0D}, {0x0D}, {0x0D}, "SATELLITE_LIZARD_CRATER", "Satellite Lizard (crater)", nullptr},
|
||||
{EnemyType::SATELLITE_LIZARD_DESERT, EP4, 0x5A, 0x45, {0x1D}, {0x1D}, {0x1D}, {0x1D}, "SATELLITE_LIZARD_DESERT", "Satellite Lizard (desert)", nullptr},
|
||||
{EnemyType::SAVAGE_WOLF, EP1 | EP2, 0x07, 0x07, {0x02}, {0x02}, {0x02}, {0x02}, "SAVAGE_WOLF", "Savage Wolf", "Gulgus"},
|
||||
{EnemyType::SHAMBERTIN, EP4 | BOSS, 0x6B, 0x5A, {0x24, 0x26}, {0x24, 0x26}, {0x24, 0x26}, {0x24, 0x26}, "SHAMBERTIN", "Shambertin", nullptr},
|
||||
{EnemyType::SHAMBERTIN_SPINNER, EP4 | BOSS, 0x6B, 0x5A, {0x25, 0x27}, {0x25, 0x27}, {0x25, 0x27}, {0x25, 0x27}, "SHAMBERTIN_SPINNER", "Shambertin (spinner)", nullptr},
|
||||
{EnemyType::SINOW_BEAT, EP1, 0x1A, 0x1A, {0x06}, {0x06}, {0x06}, {0x06}, "SINOW_BEAT", "Sinow Beat", "Sinow Blue"},
|
||||
{EnemyType::SINOW_BERILL, EP2, 0x3E, 0x3E, {0x06}, {0x06}, {0x06}, {0x06}, "SINOW_BERILL", "Sinow Berill", nullptr},
|
||||
{EnemyType::SINOW_GOLD, EP1, 0x1B, 0x1B, {0x13}, {0x47}, {0x13}, {0x10}, "SINOW_GOLD", "Sinow Gold", "Sinow Red"},
|
||||
{EnemyType::SINOW_SPIGELL, EP2, 0x3F, 0x3F, {0x13}, {0x47}, {0x13}, {0x10}, "SINOW_SPIGELL", "Sinow Spigell", nullptr},
|
||||
{EnemyType::SINOW_ZELE, EP2, 0x46, 0x46, {0x44}, {0x44}, {0x44}, {0x44}, "SINOW_ZELE", "Sinow Zele", nullptr},
|
||||
{EnemyType::SINOW_ZOA, EP2, 0x45, 0x45, {0x43}, {0x43}, {0x43}, {0x43}, "SINOW_ZOA", "Sinow Zoa", nullptr},
|
||||
{EnemyType::SO_DIMENIAN, EP1 | EP2, 0x2B, 0x2B, {0x55}, {0x5C}, {0x54}, {0x54}, "SO_DIMENIAN", "So Dimenian", "Del-D"},
|
||||
{EnemyType::UL_GIBBON, EP2, 0x3B, 0x3B, {0x3B}, {0x3B}, {0x3B}, {0x3B}, "UL_GIBBON", "Ul Gibbon", nullptr},
|
||||
{EnemyType::UL_RAY, EP2, 0x4B, NONE, {0x09}, {0x09}, {0x09}, {0x09}, "UL_RAY", "Ul Ray", nullptr},
|
||||
{EnemyType::VOL_OPT_1, EP1 | BOSS, NONE, NONE, {0x21}, {0x21}, {0x21}, {0x21, 0x22, 0x23}, "VOL_OPT_1", "Vol Opt (phase 1)", "Vol Opt ver.2 (phase 1)"},
|
||||
{EnemyType::VOL_OPT_2, EP1 | BOSS, 0x2E, 0x2E, {0x25}, {0x25}, {0x25}, {0x25, 0x26, 0x28, 0x29, 0x2A}, "VOL_OPT_2", "Vol Opt (phase 2)", "Vol Opt ver.2 (phase 2)"},
|
||||
{EnemyType::VOL_OPT_AMP, EP1 | BOSS, NONE, NONE, {0x24}, {0x24}, {0x24}, {}, "VOL_OPT_AMP", "Vol Opt (amp)", "Vol Opt ver.2 (amp)"},
|
||||
{EnemyType::VOL_OPT_CORE, EP1 | BOSS, NONE, NONE, {0x26}, {0x26}, {0x26}, {}, "VOL_OPT_CORE", "Vol Opt (core)", "Vol Opt ver.2 (core)"},
|
||||
{EnemyType::VOL_OPT_MONITOR, EP1 | BOSS, NONE, NONE, {0x23}, {0x23}, {0x23}, {}, "VOL_OPT_MONITOR", "Vol Opt (monitor)", "Vol Opt ver.2 (monitor)"},
|
||||
{EnemyType::VOL_OPT_PILLAR, EP1 | BOSS, NONE, NONE, {0x22}, {0x22}, {0x22}, {}, "VOL_OPT_PILLAR", "Vol Opt (pillar)", "Vol Opt ver.2 (pillar)"},
|
||||
{EnemyType::YOWIE_CRATER, EP4, 0x59, 0x42, {0x0E}, {0x0E}, {0x0E}, {0x0E}, "YOWIE_CRATER", "Yowie (crater)", nullptr},
|
||||
{EnemyType::YOWIE_DESERT, EP4, 0x59, 0x43, {0x1E}, {0x1E}, {0x1E}, {0x1E}, "YOWIE_DESERT", "Yowie (desert)", nullptr},
|
||||
{EnemyType::ZE_BOOTA, EP4, 0x61, 0x4E, {0x01}, {0x01, 0x02, 0x04}, {0x01}, {0x01}, "ZE_BOOTA", "Ze Boota", nullptr},
|
||||
{EnemyType::ZOL_GIBBON, EP2, 0x3C, 0x3C, {0x3C}, {0x3C}, {0x3C}, {0x3C}, "ZOL_GIBBON", "Zol Gibbon", nullptr},
|
||||
{EnemyType::ZU_CRATER, EP4, 0x5E, 0x49, {0x07}, {0x07}, {0x07}, {0x07}, "ZU_CRATER", "Zu (crater)", nullptr},
|
||||
{EnemyType::ZU_DESERT, EP4, 0x5E, 0x4A, {0x1B}, {0x1B}, {0x1B}, {0x1B}, "ZU_DESERT", "Zu (desert)", nullptr},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -201,26 +202,85 @@ const vector<EnemyType>& enemy_types_for_rare_table_index(Episode episode, uint8
|
||||
}
|
||||
}
|
||||
|
||||
const vector<EnemyType>& enemy_types_for_battle_param_stats_index(Episode episode, uint8_t bp_index) {
|
||||
static array<vector<vector<EnemyType>>, 5> data;
|
||||
auto& ret = data.at(static_cast<size_t>(episode));
|
||||
if (ret.empty()) {
|
||||
struct BPIndexCacheEntry {
|
||||
std::set<EnemyType> stats;
|
||||
std::set<EnemyType> attack_data;
|
||||
std::set<EnemyType> resist_data;
|
||||
std::set<EnemyType> movement_data;
|
||||
};
|
||||
|
||||
static const BPIndexCacheEntry& get_bp_index_cache_entry(Episode episode, uint8_t bp_index) {
|
||||
static bool cache_populated = false;
|
||||
static array<vector<BPIndexCacheEntry>, 5> data;
|
||||
if (!cache_populated) {
|
||||
cache_populated = true;
|
||||
for (const auto& def : type_defs) {
|
||||
if (def.valid_in_episode(episode) && !def.bp_stats_indexes.empty()) {
|
||||
// Some enemies (e.g. Ep4 bosses) have multiple stats structures; we use the last one, since that's the only
|
||||
// one used when giving EXP
|
||||
size_t bp_index = def.bp_stats_indexes.back();
|
||||
if (bp_index >= ret.size()) {
|
||||
ret.resize(bp_index + 1);
|
||||
for (const auto& episode : ALL_EPISODES_V4) {
|
||||
if (!def.valid_in_episode(episode)) {
|
||||
continue;
|
||||
}
|
||||
auto& ep_index = data[static_cast<size_t>(episode)];
|
||||
for (const auto& bp_index : def.bp_stats_indexes) {
|
||||
if (bp_index >= ep_index.size()) {
|
||||
ep_index.resize(bp_index + 1);
|
||||
}
|
||||
ep_index[bp_index].stats.emplace(def.type);
|
||||
}
|
||||
for (const auto& bp_index : def.bp_attack_data_indexes) {
|
||||
if (bp_index >= ep_index.size()) {
|
||||
ep_index.resize(bp_index + 1);
|
||||
}
|
||||
ep_index[bp_index].attack_data.emplace(def.type);
|
||||
}
|
||||
for (const auto& bp_index : def.bp_resist_data_indexes) {
|
||||
if (bp_index >= ep_index.size()) {
|
||||
ep_index.resize(bp_index + 1);
|
||||
}
|
||||
ep_index[bp_index].resist_data.emplace(def.type);
|
||||
}
|
||||
for (const auto& bp_index : def.bp_movement_data_indexes) {
|
||||
if (bp_index >= ep_index.size()) {
|
||||
ep_index.resize(bp_index + 1);
|
||||
}
|
||||
ep_index[bp_index].movement_data.emplace(def.type);
|
||||
}
|
||||
ret[bp_index].emplace_back(def.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto& ep_index = data.at(static_cast<size_t>(episode));
|
||||
return ep_index.at(bp_index);
|
||||
}
|
||||
|
||||
static const std::set<EnemyType> empty_vec;
|
||||
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_stats_index(Episode episode, uint8_t bp_index) {
|
||||
try {
|
||||
return ret.at(bp_index);
|
||||
return get_bp_index_cache_entry(episode, bp_index).stats;
|
||||
} catch (const out_of_range&) {
|
||||
return empty_vec;
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_attack_data_index(Episode episode, uint8_t bp_index) {
|
||||
try {
|
||||
return get_bp_index_cache_entry(episode, bp_index).attack_data;
|
||||
} catch (const out_of_range&) {
|
||||
return empty_vec;
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_resist_data_index(Episode episode, uint8_t bp_index) {
|
||||
try {
|
||||
return get_bp_index_cache_entry(episode, bp_index).resist_data;
|
||||
} catch (const out_of_range&) {
|
||||
return empty_vec;
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_movement_data_index(Episode episode, uint8_t bp_index) {
|
||||
try {
|
||||
return get_bp_index_cache_entry(episode, bp_index).movement_data;
|
||||
} catch (const out_of_range&) {
|
||||
static const vector<EnemyType> empty_vec;
|
||||
return empty_vec;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -3,6 +3,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <phosg/Tools.hh>
|
||||
#include <set>
|
||||
|
||||
#include "StaticGameData.hh"
|
||||
#include "Types.hh"
|
||||
@@ -165,6 +166,7 @@ struct EnemyTypeDefinition {
|
||||
std::vector<uint8_t> bp_stats_indexes;
|
||||
std::vector<uint8_t> bp_attack_data_indexes;
|
||||
std::vector<uint8_t> bp_resist_data_indexes;
|
||||
std::vector<uint8_t> bp_movement_data_indexes;
|
||||
// Note: movement data isn't bound as strongly to the enemy types; some enemies use many entries and some use none at
|
||||
// all, so we don't list them here. See notes/movement-data.txt for a listing of which enemies use which entries.
|
||||
const char* enum_name;
|
||||
@@ -200,4 +202,7 @@ template <>
|
||||
EnemyType phosg::enum_for_name<EnemyType>(const char* name);
|
||||
|
||||
const std::vector<EnemyType>& enemy_types_for_rare_table_index(Episode episode, uint8_t rt_index);
|
||||
const std::vector<EnemyType>& enemy_types_for_battle_param_stats_index(Episode episode, uint8_t bp_index);
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_stats_index(Episode episode, uint8_t bp_index);
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_attack_data_index(Episode episode, uint8_t bp_index);
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_resist_data_index(Episode episode, uint8_t bp_index);
|
||||
const std::set<EnemyType>& enemy_types_for_battle_param_movement_data_index(Episode episode, uint8_t bp_index);
|
||||
|
||||
@@ -323,7 +323,7 @@ void PlayerState::apply_assist_card_effect_on_set(shared_ptr<PlayerState> setter
|
||||
if (!s->options.is_nte()) {
|
||||
s->team_num_cards_destroyed[this->team_id] = 0;
|
||||
for (size_t client_id = 0; client_id < 4; client_id++) {
|
||||
const auto other_ps = s->get_player_state(client_id);
|
||||
auto other_ps = s->get_player_state(client_id);
|
||||
if (other_ps && (this->team_id == other_ps->get_team_id())) {
|
||||
auto card = other_ps->get_sc_card();
|
||||
if (card) {
|
||||
|
||||
@@ -1,612 +0,0 @@
|
||||
#include "FunctionCompiler.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/Time.hh>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <resource_file/Emulators/PPC32Emulator.hh>
|
||||
#include <resource_file/Emulators/SH4Emulator.hh>
|
||||
#include <resource_file/Emulators/X86Emulator.hh>
|
||||
|
||||
#include "CommandFormats.hh"
|
||||
#include "CommonFileFormats.hh"
|
||||
#include "Compression.hh"
|
||||
#include "Loggers.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const char* name_for_architecture(CompiledFunctionCode::Architecture arch) {
|
||||
switch (arch) {
|
||||
case CompiledFunctionCode::Architecture::POWERPC:
|
||||
return "PowerPC";
|
||||
case CompiledFunctionCode::Architecture::X86:
|
||||
return "x86";
|
||||
case CompiledFunctionCode::Architecture::SH4:
|
||||
return "SH-4";
|
||||
default:
|
||||
throw logic_error("invalid architecture");
|
||||
}
|
||||
}
|
||||
|
||||
template <bool BE>
|
||||
string CompiledFunctionCode::generate_client_command_t(
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
uint32_t override_relocations_offset) const {
|
||||
using FooterT = RELFileFooterT<BE>;
|
||||
|
||||
FooterT footer;
|
||||
footer.num_relocations = this->relocation_deltas.size();
|
||||
footer.unused1.clear(0);
|
||||
footer.root_offset = this->entrypoint_offset_offset;
|
||||
footer.unused2.clear(0);
|
||||
|
||||
phosg::StringWriter w;
|
||||
if (!label_writes.empty()) {
|
||||
string modified_code = this->code;
|
||||
for (const auto& it : label_writes) {
|
||||
size_t offset = this->label_offsets.at(it.first);
|
||||
if (offset > modified_code.size() - 4) {
|
||||
throw runtime_error("label out of range");
|
||||
}
|
||||
*reinterpret_cast<U32T<FooterT::IsBE>*>(modified_code.data() + offset) = it.second;
|
||||
}
|
||||
w.write(modified_code);
|
||||
} else {
|
||||
w.write(this->code);
|
||||
}
|
||||
if (suffix_size) {
|
||||
w.write(suffix_data, suffix_size);
|
||||
}
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
|
||||
footer.relocations_offset = w.size();
|
||||
|
||||
// Always write at least 4 bytes even if there are no relocations
|
||||
if (this->relocation_deltas.empty()) {
|
||||
w.put_u32(0);
|
||||
}
|
||||
|
||||
if (override_relocations_offset) {
|
||||
footer.relocations_offset = override_relocations_offset;
|
||||
} else {
|
||||
for (uint16_t delta : this->relocation_deltas) {
|
||||
w.put<U16T<FooterT::IsBE>>(delta);
|
||||
}
|
||||
if (this->relocation_deltas.size() & 1) {
|
||||
w.put_u16(0);
|
||||
}
|
||||
}
|
||||
|
||||
w.put(footer);
|
||||
return std::move(w.str());
|
||||
}
|
||||
|
||||
string CompiledFunctionCode::generate_client_command(
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
uint32_t override_relocations_offset) const {
|
||||
if (this->arch == Architecture::POWERPC) {
|
||||
return this->generate_client_command_t<true>(label_writes, suffix_data, suffix_size, override_relocations_offset);
|
||||
} else if ((this->arch == Architecture::X86) || (this->arch == Architecture::SH4)) {
|
||||
return this->generate_client_command_t<false>(label_writes, suffix_data, suffix_size, override_relocations_offset);
|
||||
} else {
|
||||
throw logic_error("invalid architecture");
|
||||
}
|
||||
}
|
||||
|
||||
bool CompiledFunctionCode::is_big_endian() const {
|
||||
return (this->arch == Architecture::POWERPC);
|
||||
}
|
||||
|
||||
static unordered_map<uint32_t, std::string> preprocess_function_code(const std::string& text) {
|
||||
auto parse_specific_version_list = +[](std::string&& text) -> vector<uint32_t> {
|
||||
phosg::strip_whitespace(text);
|
||||
vector<uint32_t> ret;
|
||||
for (auto& vers_token : phosg::split(text, ' ')) {
|
||||
phosg::strip_whitespace(vers_token);
|
||||
if (vers_token.empty()) {
|
||||
continue;
|
||||
}
|
||||
if (vers_token.size() != 4) {
|
||||
throw std::runtime_error("invalid specific_version: " + vers_token);
|
||||
}
|
||||
ret.emplace_back(*reinterpret_cast<const be_uint32_t*>(vers_token.data()));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Find a .versions directive and populate specific_versions
|
||||
vector<uint32_t> specific_versions;
|
||||
auto lines = phosg::split(text, '\n');
|
||||
for (auto& line : lines) {
|
||||
if (line.starts_with(".versions ")) {
|
||||
if (!specific_versions.empty()) {
|
||||
throw std::runtime_error("multiple .versions directives in file");
|
||||
}
|
||||
specific_versions = parse_specific_version_list(line.substr(10));
|
||||
if (specific_versions.empty()) {
|
||||
throw std::runtime_error(".versions directive does not specify any versions");
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// If there's no .versions directive, just return the text as-is
|
||||
if (specific_versions.empty()) {
|
||||
return {{0, std::move(text)}};
|
||||
}
|
||||
|
||||
vector<deque<string>> version_lines;
|
||||
version_lines.resize(specific_versions.size());
|
||||
|
||||
size_t line_num = 1;
|
||||
vector<uint32_t> current_only_versions;
|
||||
unordered_set<uint32_t> current_only_versions_set;
|
||||
auto add_blank_line = [&]() -> void {
|
||||
for (size_t vers_index = 0; vers_index < specific_versions.size(); vers_index++) {
|
||||
version_lines[vers_index].emplace_back("");
|
||||
}
|
||||
};
|
||||
for (auto& line : lines) {
|
||||
phosg::strip_whitespace(line);
|
||||
if (line.starts_with(".only_versions ")) {
|
||||
current_only_versions = parse_specific_version_list(line.substr(15));
|
||||
current_only_versions_set.clear();
|
||||
for (uint32_t specific_version : current_only_versions) {
|
||||
current_only_versions_set.emplace(specific_version);
|
||||
}
|
||||
add_blank_line();
|
||||
|
||||
} else if (line == ".all_versions") {
|
||||
current_only_versions.clear();
|
||||
current_only_versions_set.clear();
|
||||
add_blank_line();
|
||||
|
||||
} else {
|
||||
size_t vers_offset = line.find("<VERS ");
|
||||
if (vers_offset == string::npos) {
|
||||
for (size_t vers_index = 0; vers_index < specific_versions.size(); vers_index++) {
|
||||
if (current_only_versions.empty() || current_only_versions_set.count(specific_versions[vers_index])) {
|
||||
version_lines[vers_index].emplace_back(line);
|
||||
} else {
|
||||
version_lines[vers_index].emplace_back("");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
size_t token_index = 0;
|
||||
for (size_t vers_index = 0; vers_index < specific_versions.size(); vers_index++) {
|
||||
if (current_only_versions.empty() || current_only_versions_set.count(specific_versions[vers_index])) {
|
||||
string version_line = line;
|
||||
size_t vers_offset = line.find("<VERS ");
|
||||
while (vers_offset != string::npos) {
|
||||
size_t end_offset = version_line.find('>', vers_offset + 6);
|
||||
if (end_offset == string::npos) {
|
||||
throw runtime_error(std::format("(line {}) unterminated <VERS> replacement", line_num));
|
||||
}
|
||||
auto tokens = phosg::split(version_line.substr(vers_offset + 6, end_offset - vers_offset - 6), ' ');
|
||||
if (tokens.size() <= token_index) {
|
||||
throw runtime_error(std::format("(line {}) invalid <VERS> replacement", line_num));
|
||||
}
|
||||
version_line = version_line.substr(0, vers_offset) + tokens.at(token_index) + version_line.substr(end_offset + 1);
|
||||
vers_offset = version_line.find("<VERS ");
|
||||
}
|
||||
version_lines[vers_index].emplace_back(version_line);
|
||||
token_index++;
|
||||
} else {
|
||||
version_lines[vers_index].emplace_back("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line_num++;
|
||||
}
|
||||
|
||||
unordered_map<uint32_t, string> ret;
|
||||
for (size_t z = 0; z < specific_versions.size(); z++) {
|
||||
ret.emplace(specific_versions[z], phosg::join(version_lines.at(z), "\n"));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static vector<shared_ptr<CompiledFunctionCode>> compile_function_code(
|
||||
CompiledFunctionCode::Architecture arch,
|
||||
const string& function_directory,
|
||||
const string& system_directory,
|
||||
const string& name,
|
||||
const string& text,
|
||||
bool raise_on_any_failure) {
|
||||
unordered_set<string> get_include_stack;
|
||||
function<string(const string&)> get_include = [&](const string& name) -> string {
|
||||
const char* arch_name_token;
|
||||
switch (arch) {
|
||||
case CompiledFunctionCode::Architecture::POWERPC:
|
||||
arch_name_token = "ppc";
|
||||
break;
|
||||
case CompiledFunctionCode::Architecture::X86:
|
||||
arch_name_token = "x86";
|
||||
break;
|
||||
case CompiledFunctionCode::Architecture::SH4:
|
||||
arch_name_token = "sh4";
|
||||
break;
|
||||
default:
|
||||
throw runtime_error("unknown architecture");
|
||||
}
|
||||
|
||||
// Look in the function directory first, then the system directory
|
||||
string asm_filename = std::format("{}/{}.{}.inc.s", function_directory, name, arch_name_token);
|
||||
if (!std::filesystem::is_regular_file(asm_filename)) {
|
||||
asm_filename = std::format("{}/{}.{}.inc.s", system_directory, name, arch_name_token);
|
||||
}
|
||||
if (std::filesystem::is_regular_file(asm_filename)) {
|
||||
if (!get_include_stack.emplace(name).second) {
|
||||
throw runtime_error("mutual recursion between includes: " + name);
|
||||
}
|
||||
ResourceDASM::EmulatorBase::AssembleResult ret;
|
||||
switch (arch) {
|
||||
case CompiledFunctionCode::Architecture::POWERPC:
|
||||
ret = ResourceDASM::PPC32Emulator::assemble(phosg::load_file(asm_filename), get_include);
|
||||
break;
|
||||
case CompiledFunctionCode::Architecture::X86:
|
||||
ret = ResourceDASM::X86Emulator::assemble(phosg::load_file(asm_filename), get_include);
|
||||
break;
|
||||
case CompiledFunctionCode::Architecture::SH4:
|
||||
ret = ResourceDASM::SH4Emulator::assemble(phosg::load_file(asm_filename), get_include);
|
||||
break;
|
||||
default:
|
||||
throw runtime_error("unknown architecture");
|
||||
}
|
||||
get_include_stack.erase(name);
|
||||
return ret.code;
|
||||
}
|
||||
|
||||
string bin_filename = function_directory + "/" + name + ".inc.bin";
|
||||
if (std::filesystem::is_regular_file(bin_filename)) {
|
||||
return phosg::load_file(bin_filename);
|
||||
}
|
||||
bin_filename = system_directory + "/" + name + ".inc.bin";
|
||||
if (std::filesystem::is_regular_file(bin_filename)) {
|
||||
return phosg::load_file(bin_filename);
|
||||
}
|
||||
throw runtime_error("data not found for include: " + name + " (from " + asm_filename + " or " + bin_filename + ")");
|
||||
};
|
||||
|
||||
auto version_texts = preprocess_function_code(text);
|
||||
|
||||
vector<shared_ptr<CompiledFunctionCode>> ret;
|
||||
for (const auto& [specific_version, version_text] : version_texts) {
|
||||
try {
|
||||
ResourceDASM::EmulatorBase::AssembleResult assembled;
|
||||
if (arch == CompiledFunctionCode::Architecture::POWERPC) {
|
||||
assembled = ResourceDASM::PPC32Emulator::assemble(version_text, get_include);
|
||||
} else if (arch == CompiledFunctionCode::Architecture::X86) {
|
||||
assembled = ResourceDASM::X86Emulator::assemble(version_text, get_include);
|
||||
} else if (arch == CompiledFunctionCode::Architecture::SH4) {
|
||||
assembled = ResourceDASM::SH4Emulator::assemble(version_text, get_include);
|
||||
} else {
|
||||
throw runtime_error("invalid architecture");
|
||||
}
|
||||
|
||||
auto compiled = ret.emplace_back(make_shared<CompiledFunctionCode>());
|
||||
compiled->arch = arch;
|
||||
compiled->short_name = name;
|
||||
compiled->specific_version = specific_version;
|
||||
compiled->code = std::move(assembled.code);
|
||||
compiled->label_offsets = std::move(assembled.label_offsets);
|
||||
for (const auto& it : assembled.metadata_keys) {
|
||||
if (it.first == "hide_from_patches_menu") {
|
||||
compiled->hide_from_patches_menu = true;
|
||||
} else if (it.first == "name") {
|
||||
compiled->long_name = it.second;
|
||||
} else if (it.first == "description") {
|
||||
compiled->description = it.second;
|
||||
} else if (it.first == "client_flag") {
|
||||
compiled->client_flag = stoull(it.second, nullptr, 0);
|
||||
} else if (it.first == "show_return_value") {
|
||||
compiled->show_return_value = true;
|
||||
} else {
|
||||
throw runtime_error("unknown metadata key: " + it.first);
|
||||
}
|
||||
}
|
||||
|
||||
set<uint32_t> reloc_indexes;
|
||||
for (const auto& it : compiled->label_offsets) {
|
||||
if (it.first.starts_with("reloc")) {
|
||||
reloc_indexes.emplace(it.second / 4);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
compiled->entrypoint_offset_offset = compiled->label_offsets.at("entry_ptr");
|
||||
} catch (const out_of_range&) {
|
||||
throw runtime_error("code does not contain entry_ptr label");
|
||||
}
|
||||
|
||||
uint32_t prev_index = 0;
|
||||
for (const auto& it : reloc_indexes) {
|
||||
uint32_t delta = it - prev_index;
|
||||
if (delta > 0xFFFF) {
|
||||
throw runtime_error("relocation delta too far away");
|
||||
}
|
||||
compiled->relocation_deltas.emplace_back(delta);
|
||||
prev_index = it;
|
||||
}
|
||||
|
||||
} catch (const exception& e) {
|
||||
string version_str = specific_version ? (" (" + str_for_specific_version(specific_version) + ")") : "";
|
||||
if (raise_on_any_failure) {
|
||||
throw;
|
||||
}
|
||||
function_compiler_log.warning_f("Failed to compile function {}{}: {}", name, version_str, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FunctionCodeIndex::FunctionCodeIndex(const string& directory, bool raise_on_any_failure) {
|
||||
string system_dir_path = directory.ends_with("/") ? (directory + "System") : (directory + "/System");
|
||||
|
||||
uint32_t next_menu_item_id = 1;
|
||||
for (const auto& item : std::filesystem::directory_iterator(directory)) {
|
||||
string subdir_name = item.path().filename().string();
|
||||
string subdir_path = directory.ends_with("/") ? (directory + subdir_name) : (directory + "/" + subdir_name);
|
||||
|
||||
auto add_file = [&](string filename) -> void {
|
||||
try {
|
||||
if (!filename.ends_with(".s")) {
|
||||
return;
|
||||
}
|
||||
|
||||
string name = filename.substr(0, filename.size() - 2);
|
||||
if (name.ends_with(".inc")) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_patch = name.ends_with(".patch");
|
||||
if (is_patch) {
|
||||
name.resize(name.size() - 6);
|
||||
}
|
||||
|
||||
// Figure out the version or specific_version
|
||||
CompiledFunctionCode::Architecture arch = CompiledFunctionCode::Architecture::UNKNOWN;
|
||||
uint32_t specific_version = 0;
|
||||
string short_name = name;
|
||||
if (name.ends_with(".ppc")) {
|
||||
arch = CompiledFunctionCode::Architecture::POWERPC;
|
||||
name.resize(name.size() - 4);
|
||||
short_name = name;
|
||||
} else if (name.ends_with(".x86")) {
|
||||
arch = CompiledFunctionCode::Architecture::X86;
|
||||
name.resize(name.size() - 4);
|
||||
short_name = name;
|
||||
} else if (name.ends_with(".sh4")) {
|
||||
arch = CompiledFunctionCode::Architecture::SH4;
|
||||
name.resize(name.size() - 4);
|
||||
short_name = name;
|
||||
} else if (is_patch && (name.size() >= 5) && (name[name.size() - 5] == '.')) {
|
||||
specific_version = (name[name.size() - 4] << 24) | (name[name.size() - 3] << 16) | (name[name.size() - 2] << 8) | name[name.size() - 1];
|
||||
if (specific_version_is_dc(specific_version)) {
|
||||
arch = CompiledFunctionCode::Architecture::SH4;
|
||||
} else if (specific_version_is_gc(specific_version)) {
|
||||
arch = CompiledFunctionCode::Architecture::POWERPC;
|
||||
} else if (specific_version_is_pc_v2(specific_version) ||
|
||||
specific_version_is_xb(specific_version) ||
|
||||
specific_version_is_bb(specific_version)) {
|
||||
arch = CompiledFunctionCode::Architecture::X86;
|
||||
} else {
|
||||
throw runtime_error("unable to determine architecture from specific_version");
|
||||
}
|
||||
short_name = name.substr(0, name.size() - 5);
|
||||
}
|
||||
|
||||
if (arch == CompiledFunctionCode::Architecture::UNKNOWN) {
|
||||
throw runtime_error("unable to determine architecture");
|
||||
}
|
||||
|
||||
string path = subdir_path + "/" + filename;
|
||||
string text = phosg::load_file(path);
|
||||
for (auto code : compile_function_code(arch, subdir_path, system_dir_path, name, text, raise_on_any_failure)) {
|
||||
if (code->specific_version == 0) {
|
||||
code->specific_version = specific_version;
|
||||
}
|
||||
code->source_path = path;
|
||||
code->short_name = short_name;
|
||||
this->name_to_function.emplace(name, code);
|
||||
if (is_patch) {
|
||||
code->menu_item_id = next_menu_item_id++;
|
||||
this->menu_item_id_and_specific_version_to_patch_function.emplace(
|
||||
static_cast<uint64_t>(code->menu_item_id) << 32 | code->specific_version, code);
|
||||
this->name_and_specific_version_to_patch_function.emplace(
|
||||
std::format("{}-{:08X}", code->short_name, code->specific_version), code);
|
||||
}
|
||||
|
||||
string patch_prefix = is_patch ? std::format("[{:08X}] ", code->menu_item_id) : "";
|
||||
function_compiler_log.debug_f("Compiled function {}{} ({}; {})",
|
||||
patch_prefix, name, str_for_specific_version(code->specific_version), name_for_architecture(code->arch));
|
||||
}
|
||||
|
||||
} catch (const exception& e) {
|
||||
if (raise_on_any_failure) {
|
||||
throw runtime_error(format("({}) {}", filename, e.what()));
|
||||
}
|
||||
function_compiler_log.warning_f("Failed to compile function {}: {}", filename, e.what());
|
||||
}
|
||||
};
|
||||
|
||||
if (std::filesystem::is_regular_file(subdir_path)) {
|
||||
add_file(subdir_path);
|
||||
} else if (std::filesystem::is_directory(subdir_path)) {
|
||||
for (const auto& item : std::filesystem::directory_iterator(subdir_path)) {
|
||||
string filename = item.path().filename().string();
|
||||
add_file(filename);
|
||||
}
|
||||
} else {
|
||||
function_compiler_log.warning_f("Skipping {} (unknown file type)", subdir_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<const Menu> FunctionCodeIndex::patch_switches_menu(
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const {
|
||||
auto suffix = std::format("-{:08X}", specific_version);
|
||||
|
||||
auto ret = make_shared<Menu>(MenuID::PATCH_SWITCHES, "Patches");
|
||||
ret->items.emplace_back(PatchesMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
||||
for (const auto& it : this->name_and_specific_version_to_patch_function) {
|
||||
const auto& fn = it.second;
|
||||
if (fn->hide_from_patches_menu || !it.first.ends_with(suffix) || server_auto_patches_enabled.count(fn->short_name)) {
|
||||
continue;
|
||||
}
|
||||
string name;
|
||||
name.push_back(client_auto_patches_enabled.count(fn->short_name) ? '*' : '-');
|
||||
name += fn->long_name.empty() ? fn->short_name : fn->long_name;
|
||||
ret->items.emplace_back(fn->menu_item_id, name, fn->description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FunctionCodeIndex::patch_menu_empty(uint32_t specific_version) const {
|
||||
uint32_t mask = specific_version_is_indeterminate(specific_version) ? 0xFF000000 : 0xFFFFFFFF;
|
||||
for (const auto& it : this->menu_item_id_and_specific_version_to_patch_function) {
|
||||
if ((it.first & mask) == (specific_version & mask)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<const CompiledFunctionCode> FunctionCodeIndex::get_patch(
|
||||
const std::string& name, uint32_t specific_version) const {
|
||||
return this->name_and_specific_version_to_patch_function.at(std::format("{}-{:08X}", name, specific_version));
|
||||
}
|
||||
|
||||
DOLFileIndex::DOLFileIndex(const string& directory) {
|
||||
if (!std::filesystem::is_directory(directory)) {
|
||||
function_compiler_log.info_f("DOL file directory is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
auto menu = make_shared<Menu>(MenuID::PROGRAMS, "Programs");
|
||||
this->menu = menu;
|
||||
menu->items.emplace_back(ProgramsMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0);
|
||||
|
||||
uint32_t next_menu_item_id = 0;
|
||||
for (const auto& item : std::filesystem::directory_iterator(directory)) {
|
||||
string filename = item.path().filename().string();
|
||||
bool is_dol = filename.ends_with(".dol");
|
||||
bool is_compressed_dol = filename.ends_with(".dol.prs");
|
||||
if (!is_dol && !is_compressed_dol) {
|
||||
continue;
|
||||
}
|
||||
string name = filename.substr(0, filename.size() - (is_compressed_dol ? 8 : 4));
|
||||
|
||||
try {
|
||||
auto dol = make_shared<File>();
|
||||
dol->menu_item_id = next_menu_item_id++;
|
||||
dol->name = name;
|
||||
|
||||
string path = directory + "/" + filename;
|
||||
string file_data = phosg::load_file(path);
|
||||
|
||||
string description;
|
||||
if (is_compressed_dol) {
|
||||
size_t decompressed_size = prs_decompress_size(file_data);
|
||||
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(file_data.size());
|
||||
w.put_u32b(decompressed_size);
|
||||
w.write(file_data);
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
dol->data = std::move(w.str());
|
||||
|
||||
string compressed_size_str = phosg::format_size(file_data.size());
|
||||
string decompressed_size_str = phosg::format_size(decompressed_size);
|
||||
function_compiler_log.debug_f("Loaded compressed DOL file {} ({} -> {})",
|
||||
dol->name, compressed_size_str, decompressed_size_str);
|
||||
description = std::format("$C6{}$C7\n{}\n{} (orig)", dol->name, compressed_size_str, decompressed_size_str);
|
||||
|
||||
} else {
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(0);
|
||||
w.put_u32b(file_data.size());
|
||||
w.write(file_data);
|
||||
while (w.size() & 3) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
dol->data = std::move(w.str());
|
||||
|
||||
string size_str = phosg::format_size(dol->data.size());
|
||||
function_compiler_log.debug_f("Loaded DOL file {} ({})", filename, size_str);
|
||||
description = std::format("$C6{}$C7\n{}", dol->name, size_str);
|
||||
}
|
||||
|
||||
this->name_to_file.emplace(dol->name, dol);
|
||||
this->item_id_to_file.emplace_back(dol);
|
||||
|
||||
menu->items.emplace_back(dol->menu_item_id, dol->name, description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
|
||||
} catch (const exception& e) {
|
||||
function_compiler_log.warning_f("Failed to load DOL file {}: {}", filename, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t specific_version_for_gc_header_checksum(uint32_t header_checksum) {
|
||||
static unordered_map<uint32_t, uint32_t> checksum_to_specific_version;
|
||||
if (checksum_to_specific_version.empty()) {
|
||||
struct {
|
||||
char system_code = 'G';
|
||||
char game_code1 = 'P';
|
||||
char game_code2;
|
||||
char region_code;
|
||||
char developer_code1 = '8';
|
||||
char developer_code2 = 'P';
|
||||
uint8_t disc_number = 0;
|
||||
uint8_t version_code;
|
||||
} __attribute__((packed)) data;
|
||||
for (const char* game_code2 = "OS"; *game_code2; game_code2++) {
|
||||
data.game_code2 = *game_code2;
|
||||
for (const char* region_code = "JEP"; *region_code; region_code++) {
|
||||
data.region_code = *region_code;
|
||||
for (uint8_t version_code = 0; version_code < 8; version_code++) {
|
||||
data.version_code = version_code;
|
||||
uint32_t checksum = phosg::crc32(&data, sizeof(data));
|
||||
uint32_t specific_version = 0x33000030 | (*game_code2 << 16) | (*region_code << 8) | version_code;
|
||||
if (!checksum_to_specific_version.emplace(checksum, specific_version).second) {
|
||||
throw logic_error("multiple specific_versions have same header checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// Generate entries for Trial Editions
|
||||
data.region_code = 'J';
|
||||
data.system_code = 'D';
|
||||
data.version_code = 0;
|
||||
uint32_t checksum = phosg::crc32(&data, sizeof(data));
|
||||
uint32_t specific_version = 0x33004A54 | (*game_code2 << 16);
|
||||
if (!checksum_to_specific_version.emplace(checksum, specific_version).second) {
|
||||
throw logic_error("multiple specific_versions have same header checksum");
|
||||
}
|
||||
data.system_code = 'G';
|
||||
}
|
||||
}
|
||||
}
|
||||
return checksum_to_specific_version.at(header_checksum);
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "Menu.hh"
|
||||
|
||||
// TODO: Support x86 and SH4 function calls in the future. Currently we only
|
||||
// support PPC32 because I haven't written an appropriate x86 assembler yet.
|
||||
|
||||
struct CompiledFunctionCode {
|
||||
enum class Architecture {
|
||||
UNKNOWN = 0,
|
||||
POWERPC, // GC
|
||||
X86, // PC, XB, BB
|
||||
SH4, // Dreamcast
|
||||
};
|
||||
Architecture arch;
|
||||
std::string code;
|
||||
std::vector<uint16_t> relocation_deltas;
|
||||
std::unordered_map<std::string, uint32_t> label_offsets;
|
||||
uint32_t entrypoint_offset_offset = 0;
|
||||
std::string source_path; // Path to source file from newserv root
|
||||
std::string short_name; // Based on filename
|
||||
std::string long_name; // From .meta name directive
|
||||
std::string description; // From .meta description directive
|
||||
uint64_t client_flag = 0; // From .meta client_flag directive
|
||||
uint32_t menu_item_id = 0;
|
||||
bool hide_from_patches_menu = false;
|
||||
bool show_return_value = false;
|
||||
uint32_t specific_version = 0; // 0 = not a client-selectable patch
|
||||
|
||||
bool is_big_endian() const;
|
||||
|
||||
template <bool BE>
|
||||
std::string generate_client_command_t(
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes,
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
uint32_t override_relocations_offset = 0) const;
|
||||
std::string generate_client_command(
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes = {},
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
uint32_t override_relocations_offset = 0) const;
|
||||
};
|
||||
|
||||
const char* name_for_architecture(CompiledFunctionCode::Architecture arch);
|
||||
|
||||
struct FunctionCodeIndex {
|
||||
FunctionCodeIndex() = default;
|
||||
FunctionCodeIndex(const std::string& directory, bool raise_on_any_failure);
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<CompiledFunctionCode>> name_to_function;
|
||||
std::unordered_map<uint8_t, std::shared_ptr<CompiledFunctionCode>> index_to_function;
|
||||
std::unordered_map<uint64_t, std::shared_ptr<CompiledFunctionCode>> menu_item_id_and_specific_version_to_patch_function;
|
||||
// Key here is e.g. "PATCHNAME-SPECIFICVERSION", with the latter in hex
|
||||
std::map<std::string, std::shared_ptr<CompiledFunctionCode>> name_and_specific_version_to_patch_function;
|
||||
|
||||
std::shared_ptr<const Menu> patch_switches_menu(
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const;
|
||||
bool patch_menu_empty(uint32_t specific_version) const;
|
||||
|
||||
std::shared_ptr<const CompiledFunctionCode> get_patch(const std::string& name, uint32_t specific_version) const;
|
||||
};
|
||||
|
||||
struct DOLFileIndex {
|
||||
struct File {
|
||||
uint32_t menu_item_id;
|
||||
std::string name;
|
||||
std::string data;
|
||||
bool is_compressed;
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<File>> item_id_to_file;
|
||||
std::unordered_map<std::string, std::shared_ptr<File>> name_to_file;
|
||||
std::shared_ptr<const Menu> menu;
|
||||
|
||||
DOLFileIndex() = default;
|
||||
explicit DOLFileIndex(const std::string& directory);
|
||||
|
||||
inline bool empty() const {
|
||||
return this->name_to_file.empty() && this->item_id_to_file.empty();
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t specific_version_for_gc_header_checksum(uint32_t header_checksum);
|
||||
+1
-1
@@ -303,7 +303,7 @@ HTTPServer::HTTPServer(shared_ptr<ServerState> state)
|
||||
client_json.emplace("DFP", p->disp.stats.char_stats.dfp.load());
|
||||
client_json.emplace("ATA", p->disp.stats.char_stats.ata.load());
|
||||
client_json.emplace("LCK", p->disp.stats.char_stats.lck.load());
|
||||
client_json.emplace("EXP", p->disp.stats.experience.load());
|
||||
client_json.emplace("EXP", p->disp.stats.exp.load());
|
||||
client_json.emplace("Meseta", p->disp.stats.meseta.load());
|
||||
auto tech_levels_json = phosg::JSON::dict();
|
||||
for (size_t z = 0; z < 0x13; z++) {
|
||||
|
||||
+18
-3
@@ -1356,9 +1356,24 @@ asio::awaitable<void> IPStackSimulator::open_server_connection(
|
||||
string conn_str = this->str_for_tcp_connection(c, conn);
|
||||
|
||||
// Figure out which logical port the connection should go to
|
||||
auto port_config_it = this->state->number_to_port_config.find(conn->server_port);
|
||||
uint16_t effective_server_port = conn->server_port;
|
||||
auto remap_it = this->state->ip_stack_port_remap.find(effective_server_port);
|
||||
if (remap_it != this->state->ip_stack_port_remap.end()) {
|
||||
this->log.info_f(
|
||||
"Remapping IP stack TCP destination port {} to {} for connection {}",
|
||||
effective_server_port,
|
||||
remap_it->second,
|
||||
conn_str);
|
||||
effective_server_port = remap_it->second;
|
||||
}
|
||||
|
||||
auto port_config_it = this->state->number_to_port_config.find(effective_server_port);
|
||||
if (port_config_it == this->state->number_to_port_config.end()) {
|
||||
this->log.error_f("TCP connection {} is to undefined port {}", conn_str, conn->server_port);
|
||||
this->log.error_f(
|
||||
"TCP connection {} is to undefined port {} after remap from {}",
|
||||
conn_str,
|
||||
effective_server_port,
|
||||
conn->server_port);
|
||||
co_await this->close_tcp_connection(c, conn);
|
||||
co_return;
|
||||
}
|
||||
@@ -1371,7 +1386,7 @@ asio::awaitable<void> IPStackSimulator::open_server_connection(
|
||||
co_await this->close_tcp_connection(c, conn);
|
||||
co_return;
|
||||
} else {
|
||||
this->state->game_server->connect_channel(conn->server_channel, conn->server_port, port_config->behavior);
|
||||
this->state->game_server->connect_channel(conn->server_channel, effective_server_port, port_config->behavior);
|
||||
this->log.info_f("Connected TCP connection {} to game server", conn_str);
|
||||
}
|
||||
}
|
||||
|
||||
+129
-206
@@ -1134,7 +1134,7 @@ public:
|
||||
return std::make_pair(event_table.data(), event_table.size());
|
||||
}
|
||||
|
||||
virtual const std::unordered_set<uint32_t>& all_unsealable_items() const {
|
||||
virtual const std::set<uint32_t>& all_unsealable_items() const {
|
||||
return this->unsealable_items;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1178,7 @@ protected:
|
||||
std::vector<SoundRemaps> sound_remaps;
|
||||
std::vector<TechBoost> tech_boosts;
|
||||
std::vector<std::vector<EventItem>> unwrap_table;
|
||||
std::unordered_set<uint32_t> unsealable_items;
|
||||
std::set<uint32_t> unsealable_items;
|
||||
std::vector<RangedSpecial> ranged_specials;
|
||||
};
|
||||
|
||||
@@ -2465,7 +2465,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_weapon_classes() const {
|
||||
return this->get_data_array_count<ArrayRefT<BE>>(this->root->weapon_table);
|
||||
return get_rel_array_count<ArrayRefT<BE>>(this->all_start_offsets(), this->root->weapon_table);
|
||||
}
|
||||
|
||||
virtual size_t num_weapons_in_class(uint8_t data1_1) const {
|
||||
@@ -2512,7 +2512,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_tool_classes() const {
|
||||
return this->get_data_array_count<ArrayRefT<BE>>(this->root->tool_table);
|
||||
return get_rel_array_count<ArrayRefT<BE>>(this->all_start_offsets(), this->root->tool_table);
|
||||
}
|
||||
|
||||
virtual size_t num_tools_in_class(uint8_t data1_1) const {
|
||||
@@ -2559,7 +2559,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_weapon_kinds() const {
|
||||
return this->get_data_array_count<uint8_t>(this->root->weapon_kind_table);
|
||||
return get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->weapon_kind_table);
|
||||
}
|
||||
|
||||
virtual uint8_t get_weapon_kind(uint8_t data1_1) const {
|
||||
@@ -2567,7 +2567,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_photon_colors() const {
|
||||
return this->get_data_array_count<PhotonColorEntryT<BE>>(this->root->photon_color_table);
|
||||
return get_rel_array_count<PhotonColorEntryT<BE>>(this->all_start_offsets(), this->root->photon_color_table);
|
||||
}
|
||||
|
||||
virtual const PhotonColorEntry& get_photon_color(size_t index) const {
|
||||
@@ -2575,7 +2575,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_weapon_ranges() const {
|
||||
return this->get_data_array_count<WeaponRangeT<BE>>(this->root->weapon_range_table);
|
||||
return get_rel_array_count<WeaponRangeT<BE>>(this->all_start_offsets(), this->root->weapon_range_table);
|
||||
}
|
||||
|
||||
virtual const WeaponRange& get_weapon_range(size_t index) const {
|
||||
@@ -2584,9 +2584,9 @@ public:
|
||||
|
||||
virtual size_t num_weapon_sale_divisors() const {
|
||||
if constexpr (requires { this->root->weapon_integral_sale_divisor_table; }) {
|
||||
return this->get_data_array_count<uint8_t>(this->root->weapon_integral_sale_divisor_table);
|
||||
return get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->weapon_integral_sale_divisor_table);
|
||||
} else {
|
||||
return this->get_data_array_count<F32T<BE>>(this->root->weapon_sale_divisor_table);
|
||||
return get_rel_array_count<F32T<BE>>(this->all_start_offsets(), this->root->weapon_sale_divisor_table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2647,7 +2647,7 @@ public:
|
||||
|
||||
virtual std::pair<uint32_t, uint32_t> get_star_value_index_range() const {
|
||||
return std::make_pair(
|
||||
ItemStarsFirstID, this->get_data_array_count<uint8_t>(this->root->star_value_table) + ItemStarsFirstID);
|
||||
ItemStarsFirstID, get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->star_value_table) + ItemStarsFirstID);
|
||||
}
|
||||
|
||||
virtual uint32_t get_special_stars_base_index() const {
|
||||
@@ -2667,14 +2667,15 @@ public:
|
||||
|
||||
virtual std::string get_unknown_a1() const {
|
||||
if constexpr (requires { this->root->unknown_a1; }) {
|
||||
return this->r.pread(this->root->unknown_a1, this->get_data_range_size(this->root->unknown_a1));
|
||||
return this->r.pread(
|
||||
this->root->unknown_a1, get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->unknown_a1));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
virtual size_t num_specials() const {
|
||||
return this->get_data_array_count<SpecialT<BE>>(this->root->special_table);
|
||||
return get_rel_array_count<SpecialT<BE>>(this->all_start_offsets(), this->root->special_table);
|
||||
}
|
||||
|
||||
virtual const Special& get_special(uint8_t special) const {
|
||||
@@ -2690,7 +2691,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_weapon_effects() const {
|
||||
return this->get_data_array_count<WeaponEffectT<BE>>(this->root->weapon_effect_table);
|
||||
return get_rel_array_count<WeaponEffectT<BE>>(this->all_start_offsets(), this->root->weapon_effect_table);
|
||||
}
|
||||
|
||||
virtual const WeaponEffect& get_weapon_effect(size_t index) const {
|
||||
@@ -2699,7 +2700,7 @@ public:
|
||||
|
||||
virtual size_t num_weapon_stat_boost_indexes() const {
|
||||
if constexpr (requires { this->root->weapon_stat_boost_index_table; }) {
|
||||
return this->get_data_range_size(this->root->weapon_stat_boost_index_table);
|
||||
return get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->weapon_stat_boost_index_table);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -2715,7 +2716,7 @@ public:
|
||||
|
||||
virtual size_t num_armor_stat_boost_indexes() const {
|
||||
if constexpr (requires { this->root->armor_stat_boost_index_table; }) {
|
||||
return this->get_data_range_size(this->root->armor_stat_boost_index_table);
|
||||
return get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->armor_stat_boost_index_table);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -2731,7 +2732,7 @@ public:
|
||||
|
||||
virtual size_t num_shield_stat_boost_indexes() const {
|
||||
if constexpr (requires { this->root->shield_stat_boost_index_table; }) {
|
||||
return this->get_data_range_size(this->root->shield_stat_boost_index_table);
|
||||
return get_rel_array_count<uint8_t>(this->all_start_offsets(), this->root->shield_stat_boost_index_table);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -2746,7 +2747,7 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t num_stat_boosts() const {
|
||||
return this->get_data_array_count<StatBoostT<BE>>(this->root->stat_boost_table);
|
||||
return get_rel_array_count<StatBoostT<BE>>(this->all_start_offsets(), this->root->stat_boost_table);
|
||||
}
|
||||
|
||||
virtual const StatBoost& get_stat_boost(size_t index) const {
|
||||
@@ -2755,7 +2756,7 @@ public:
|
||||
|
||||
virtual size_t num_shield_effects() const {
|
||||
if constexpr (requires { this->root->shield_effect_table; }) {
|
||||
return this->get_data_array_count<ShieldEffectT<BE>>(this->root->shield_effect_table);
|
||||
return get_rel_array_count<ShieldEffectT<BE>>(this->all_start_offsets(), this->root->shield_effect_table);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -2826,13 +2827,16 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this->sound_remaps;
|
||||
} else {
|
||||
static const std::vector<SoundRemaps> empty_vec{};
|
||||
return empty_vec;
|
||||
}
|
||||
return *this->sound_remaps;
|
||||
}
|
||||
|
||||
virtual size_t num_tech_boosts() const {
|
||||
if constexpr (requires { this->root->tech_boost_table; }) {
|
||||
return this->get_data_array_count<TechBoostT<BE>>(this->root->tech_boost_table);
|
||||
return get_rel_array_count<TechBoostT<BE>>(this->all_start_offsets(), this->root->tech_boost_table);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -2868,7 +2872,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual const std::unordered_set<uint32_t>& all_unsealable_items() const {
|
||||
virtual const std::set<uint32_t>& all_unsealable_items() const {
|
||||
if constexpr (requires { this->root->unsealable_table; }) {
|
||||
if (!this->unsealable_table.has_value()) {
|
||||
auto& ret = this->unsealable_table.emplace();
|
||||
@@ -2880,7 +2884,7 @@ public:
|
||||
}
|
||||
return *this->unsealable_table;
|
||||
} else {
|
||||
static const std::unordered_set<uint32_t> empty_set{};
|
||||
static const std::set<uint32_t> empty_set{};
|
||||
return empty_set;
|
||||
}
|
||||
}
|
||||
@@ -2902,262 +2906,211 @@ public:
|
||||
}
|
||||
|
||||
const std::set<uint32_t>& all_start_offsets() const {
|
||||
if (!this->start_offsets.has_value()) {
|
||||
auto& ret = this->start_offsets.emplace();
|
||||
ret.emplace(r.size() - 0x20); // REL footer
|
||||
ret.emplace(BE ? r.pget_u32b(r.size() - 0x10) : r.pget_u32l(r.size() - 0x10)); // root
|
||||
ret.emplace(BE ? r.pget_u32b(r.size() - 0x20) : r.pget_u32l(r.size() - 0x20)); // relocations
|
||||
|
||||
const auto& footer = r.pget<RELFileFooterT<BE>>(r.size() - sizeof(RELFileFooterT<BE>));
|
||||
auto sub_r = r.sub(footer.relocations_offset, footer.num_relocations * sizeof(U16T<BE>));
|
||||
uint32_t offset = 0;
|
||||
while (!sub_r.eof()) {
|
||||
offset += sub_r.template get<U16T<BE>>() * 4;
|
||||
ret.emplace(r.pget<U32T<BE>>(offset));
|
||||
}
|
||||
if (this->start_offsets.empty()) {
|
||||
this->start_offsets = all_relocation_offsets_for_rel_file<BE>(r.pgetv(0, r.size()), r.size());
|
||||
}
|
||||
return *this->start_offsets;
|
||||
}
|
||||
|
||||
size_t get_data_range_size(size_t start_offset) const {
|
||||
const auto& offsets = this->all_start_offsets();
|
||||
auto it = offsets.lower_bound(start_offset);
|
||||
if (it == offsets.end()) {
|
||||
throw std::out_of_range("start offset out of range");
|
||||
}
|
||||
if (*it == start_offset) {
|
||||
it++;
|
||||
}
|
||||
if (it == offsets.end()) {
|
||||
throw std::out_of_range("no further offset beyond start offset");
|
||||
}
|
||||
return *it - start_offset;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
size_t get_data_array_count(size_t start_offset) const {
|
||||
return this->get_data_range_size(start_offset) / sizeof(T);
|
||||
return this->start_offsets;
|
||||
}
|
||||
|
||||
static std::string serialize(const ItemParameterTable& pmt) {
|
||||
set<uint32_t> relocations;
|
||||
RELFileWriter<BE> rel;
|
||||
RootT root;
|
||||
phosg::StringWriter w;
|
||||
|
||||
if constexpr (!std::is_same_v<HeaderT, EmptyHeader>) {
|
||||
w.put<HeaderT>(HeaderT());
|
||||
rel.template put<HeaderT>(HeaderT());
|
||||
}
|
||||
|
||||
auto align = [&w](size_t alignment) -> void {
|
||||
while (w.size() & (alignment - 1)) {
|
||||
w.put_u8(0);
|
||||
}
|
||||
};
|
||||
auto write_ref = [&w, &relocations](const ArrayRefT<BE>& ref) -> void {
|
||||
w.put<ArrayRefT<BE>>(ref);
|
||||
relocations.emplace(w.size() - 4);
|
||||
};
|
||||
|
||||
if constexpr (requires { root.entry_count; }) {
|
||||
root.entry_count = 0x13;
|
||||
}
|
||||
|
||||
align(4);
|
||||
ArrayRefT<BE> shields_ref{pmt.num_armors_or_shields_in_class(2) - HasImplicitPlaceholders, w.size()};
|
||||
rel.align(4);
|
||||
ArrayRefT<BE> shields_ref{pmt.num_armors_or_shields_in_class(2) - HasImplicitPlaceholders, rel.w.size()};
|
||||
for (size_t data1_2 = 0; data1_2 < (shields_ref.count + HasImplicitPlaceholders); data1_2++) {
|
||||
w.put<ArmorOrShieldT>(pmt.get_armor_or_shield(2, data1_2));
|
||||
rel.template put<ArmorOrShieldT>(pmt.get_armor_or_shield(2, data1_2));
|
||||
}
|
||||
if constexpr (requires { root.shield_stat_boost_index_table; }) {
|
||||
root.shield_stat_boost_index_table = w.size();
|
||||
w.write(pmt.get_shield_stat_boost_index_table());
|
||||
root.shield_stat_boost_index_table = rel.write(pmt.get_shield_stat_boost_index_table());
|
||||
}
|
||||
|
||||
align(4);
|
||||
ArrayRefT<BE> armors_ref{pmt.num_armors_or_shields_in_class(1) - HasImplicitPlaceholders, w.size()};
|
||||
rel.align(4);
|
||||
ArrayRefT<BE> armors_ref{pmt.num_armors_or_shields_in_class(1) - HasImplicitPlaceholders, rel.w.size()};
|
||||
for (size_t data1_2 = 0; data1_2 < (armors_ref.count + HasImplicitPlaceholders); data1_2++) {
|
||||
w.put<ArmorOrShieldT>(pmt.get_armor_or_shield(1, data1_2));
|
||||
rel.template put<ArmorOrShieldT>(pmt.get_armor_or_shield(1, data1_2));
|
||||
}
|
||||
if constexpr (requires { root.armor_stat_boost_index_table; }) {
|
||||
root.armor_stat_boost_index_table = w.size();
|
||||
w.write(pmt.get_armor_stat_boost_index_table());
|
||||
root.armor_stat_boost_index_table = rel.write(pmt.get_armor_stat_boost_index_table());
|
||||
}
|
||||
|
||||
align(4);
|
||||
ArrayRefT<BE> units_ref{pmt.num_units() - HasImplicitPlaceholders, w.size()};
|
||||
rel.align(4);
|
||||
ArrayRefT<BE> units_ref{pmt.num_units() - HasImplicitPlaceholders, rel.w.size()};
|
||||
for (size_t data1_2 = 0; data1_2 < (units_ref.count + HasImplicitPlaceholders); data1_2++) {
|
||||
w.put<UnitT>(pmt.get_unit(data1_2));
|
||||
rel.template put<UnitT>(pmt.get_unit(data1_2));
|
||||
}
|
||||
|
||||
align(4);
|
||||
ArrayRefT<BE> mags_ref{pmt.num_mags() - HasImplicitPlaceholders, w.size()};
|
||||
rel.align(4);
|
||||
ArrayRefT<BE> mags_ref{pmt.num_mags() - HasImplicitPlaceholders, rel.w.size()};
|
||||
for (size_t data1_2 = 0; data1_2 < (mags_ref.count + HasImplicitPlaceholders); data1_2++) {
|
||||
w.put<MagT>(pmt.get_mag(data1_2));
|
||||
rel.template put<MagT>(pmt.get_mag(data1_2));
|
||||
}
|
||||
|
||||
align(4);
|
||||
rel.align(4);
|
||||
std::vector<ArrayRefT<BE>> tool_refs;
|
||||
for (size_t data1_1 = 0; data1_1 < pmt.num_tool_classes(); data1_1++) {
|
||||
auto& ref = tool_refs.emplace_back(ArrayRefT<BE>{pmt.num_tools_in_class(data1_1), w.size()});
|
||||
auto& ref = tool_refs.emplace_back(ArrayRefT<BE>{pmt.num_tools_in_class(data1_1), rel.w.size()});
|
||||
for (size_t data1_2 = 0; data1_2 < ref.count; data1_2++) {
|
||||
w.put<ToolT>(pmt.get_tool(data1_1, data1_2));
|
||||
rel.template put<ToolT>(pmt.get_tool(data1_1, data1_2));
|
||||
}
|
||||
}
|
||||
|
||||
align(4);
|
||||
rel.align(4);
|
||||
std::vector<ArrayRefT<BE>> weapon_refs;
|
||||
for (size_t data1_1 = 0; data1_1 < pmt.num_weapon_classes(); data1_1++) {
|
||||
auto& ref = weapon_refs.emplace_back(ArrayRefT<BE>{pmt.num_weapons_in_class(data1_1), w.size()});
|
||||
auto& ref = weapon_refs.emplace_back(ArrayRefT<BE>{pmt.num_weapons_in_class(data1_1), rel.w.size()});
|
||||
for (size_t data1_2 = 0; data1_2 < ref.count; data1_2++) {
|
||||
w.put<WeaponT>(pmt.get_weapon(data1_1, data1_2));
|
||||
rel.template put<WeaponT>(pmt.get_weapon(data1_1, data1_2));
|
||||
}
|
||||
}
|
||||
if constexpr (requires { root.weapon_stat_boost_index_table; }) {
|
||||
root.weapon_stat_boost_index_table = w.size();
|
||||
w.write(pmt.get_weapon_stat_boost_index_table());
|
||||
root.weapon_stat_boost_index_table = rel.write(pmt.get_weapon_stat_boost_index_table());
|
||||
}
|
||||
|
||||
align(4);
|
||||
root.photon_color_table = w.size();
|
||||
rel.align(4);
|
||||
root.photon_color_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_photon_colors(); z++) {
|
||||
w.put<PhotonColorEntryT<BE>>(pmt.get_photon_color(z));
|
||||
rel.template put<PhotonColorEntryT<BE>>(pmt.get_photon_color(z));
|
||||
}
|
||||
|
||||
align(4);
|
||||
root.weapon_range_table = w.size();
|
||||
rel.align(4);
|
||||
root.weapon_range_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_weapon_ranges(); z++) {
|
||||
w.put<WeaponRangeT<BE>>(pmt.get_weapon_range(z));
|
||||
rel.template put<WeaponRangeT<BE>>(pmt.get_weapon_range(z));
|
||||
}
|
||||
|
||||
root.weapon_kind_table = w.size();
|
||||
root.weapon_kind_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_weapon_classes(); z++) {
|
||||
w.put_u8(pmt.get_weapon_kind(z));
|
||||
rel.w.put_u8(pmt.get_weapon_kind(z));
|
||||
}
|
||||
|
||||
if constexpr (requires { root.weapon_integral_sale_divisor_table; }) {
|
||||
root.weapon_integral_sale_divisor_table = w.size();
|
||||
root.weapon_integral_sale_divisor_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_weapon_classes(); z++) {
|
||||
w.put_u8(pmt.get_sale_divisor(0, z));
|
||||
rel.w.put_u8(pmt.get_sale_divisor(0, z));
|
||||
}
|
||||
} else {
|
||||
align(4);
|
||||
root.weapon_sale_divisor_table = w.size();
|
||||
rel.align(4);
|
||||
root.weapon_sale_divisor_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_weapon_sale_divisors(); z++) {
|
||||
w.put<F32T<BE>>(pmt.get_sale_divisor(0, z));
|
||||
rel.template put<F32T<BE>>(pmt.get_sale_divisor(0, z));
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (requires { root.non_weapon_integral_sale_divisor_table; }) {
|
||||
root.non_weapon_integral_sale_divisor_table = w.size();
|
||||
NonWeaponSaleDivisorsDCProtos sds;
|
||||
sds.armor_divisor = pmt.get_sale_divisor(1, 1);
|
||||
sds.shield_divisor = pmt.get_sale_divisor(1, 2);
|
||||
sds.unit_divisor = pmt.get_sale_divisor(1, 3);
|
||||
w.put<NonWeaponSaleDivisorsDCProtos>(sds);
|
||||
root.non_weapon_integral_sale_divisor_table = rel.template put<NonWeaponSaleDivisorsDCProtos>(sds);
|
||||
} else {
|
||||
align(4);
|
||||
root.non_weapon_sale_divisor_table = w.size();
|
||||
rel.align(4);
|
||||
NonWeaponSaleDivisorsT<BE> sds;
|
||||
sds.armor_divisor = pmt.get_sale_divisor(1, 1);
|
||||
sds.shield_divisor = pmt.get_sale_divisor(1, 2);
|
||||
sds.unit_divisor = pmt.get_sale_divisor(1, 3);
|
||||
sds.mag_divisor = pmt.get_sale_divisor(2, 0);
|
||||
w.put<NonWeaponSaleDivisorsT<BE>>(sds);
|
||||
root.non_weapon_sale_divisor_table = rel.template put<NonWeaponSaleDivisorsT<BE>>(sds);
|
||||
}
|
||||
|
||||
MagFeedResultsListOffsetsT<BE> mag_feed_result_offsets;
|
||||
for (size_t table_index = 0; table_index < 8; table_index++) {
|
||||
mag_feed_result_offsets[table_index] = w.size();
|
||||
mag_feed_result_offsets[table_index] = rel.w.size();
|
||||
for (size_t item_id = 0; item_id < 11; item_id++) {
|
||||
w.put<MagFeedResult>(pmt.get_mag_feed_result(table_index, item_id));
|
||||
rel.template put<MagFeedResult>(pmt.get_mag_feed_result(table_index, item_id));
|
||||
}
|
||||
}
|
||||
|
||||
root.star_value_table = w.size();
|
||||
w.write(pmt.get_star_value_table());
|
||||
root.star_value_table = rel.write(pmt.get_star_value_table());
|
||||
|
||||
if constexpr (requires { root.unknown_a1; }) {
|
||||
align(2);
|
||||
root.unknown_a1 = w.size();
|
||||
w.write(pmt.get_unknown_a1());
|
||||
rel.align(2);
|
||||
root.unknown_a1 = rel.write(pmt.get_unknown_a1());
|
||||
}
|
||||
|
||||
align(2);
|
||||
root.special_table = w.size();
|
||||
rel.align(2);
|
||||
root.special_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_specials(); z++) {
|
||||
w.put<SpecialT<BE>>(pmt.get_special(z));
|
||||
rel.template put<SpecialT<BE>>(pmt.get_special(z));
|
||||
}
|
||||
|
||||
align(4);
|
||||
root.weapon_effect_table = w.size();
|
||||
rel.align(4);
|
||||
root.weapon_effect_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_weapon_effects(); z++) {
|
||||
w.put<WeaponEffectT<BE>>(pmt.get_weapon_effect(z));
|
||||
rel.template put<WeaponEffectT<BE>>(pmt.get_weapon_effect(z));
|
||||
}
|
||||
|
||||
align(4);
|
||||
rel.align(4);
|
||||
if constexpr (requires { root.shield_effect_table; }) {
|
||||
root.shield_effect_table = w.size();
|
||||
root.shield_effect_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_shield_effects(); z++) {
|
||||
w.put<ShieldEffectT<BE>>(pmt.get_shield_effect(z));
|
||||
rel.template put<ShieldEffectT<BE>>(pmt.get_shield_effect(z));
|
||||
}
|
||||
}
|
||||
|
||||
align(4);
|
||||
rel.align(4);
|
||||
if constexpr (requires { root.sound_remap_table; }) {
|
||||
std::vector<SoundRemapTableOffsetsT<BE>> remap_refs;
|
||||
const auto& remaps = pmt.get_all_sound_remaps();
|
||||
for (const auto& remap : remaps) {
|
||||
auto& remap_ref = remap_refs.emplace_back();
|
||||
remap_ref.sound_id = remap.sound_id;
|
||||
remap_ref.remaps_for_rt_index_table = w.size();
|
||||
remap_ref.remaps_for_rt_index_table = rel.w.size();
|
||||
for (uint32_t remap_sound_id : remap.by_rt_index) {
|
||||
w.put<U32T<BE>>(remap_sound_id);
|
||||
rel.template put<U32T<BE>>(remap_sound_id);
|
||||
}
|
||||
remap_ref.remaps_for_char_class_table = w.size();
|
||||
remap_ref.remaps_for_char_class_table = rel.w.size();
|
||||
for (uint32_t remap_sound_id : remap.by_char_class) {
|
||||
w.put<U32T<BE>>(remap_sound_id);
|
||||
rel.template put<U32T<BE>>(remap_sound_id);
|
||||
}
|
||||
}
|
||||
ArrayRefT<BE> remap_vec{remaps.size(), w.size()};
|
||||
ArrayRefT<BE> remap_vec{remaps.size(), rel.w.size()};
|
||||
for (const auto& remap_ref : remap_refs) {
|
||||
w.put<SoundRemapTableOffsetsT<BE>>(remap_ref);
|
||||
relocations.emplace(w.size() - 8);
|
||||
relocations.emplace(w.size() - 4);
|
||||
uint32_t offset = rel.template put<SoundRemapTableOffsetsT<BE>>(remap_ref);
|
||||
rel.relocations.emplace(offset + 4);
|
||||
rel.relocations.emplace(offset + 8);
|
||||
}
|
||||
root.sound_remap_table = w.size();
|
||||
write_ref(remap_vec);
|
||||
root.sound_remap_table = rel.write_ref(remap_vec);
|
||||
}
|
||||
|
||||
align(4);
|
||||
root.stat_boost_table = w.size();
|
||||
rel.align(4);
|
||||
root.stat_boost_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_stat_boosts(); z++) {
|
||||
w.put<StatBoostT<BE>>(pmt.get_stat_boost(z));
|
||||
rel.template put<StatBoostT<BE>>(pmt.get_stat_boost(z));
|
||||
}
|
||||
|
||||
if constexpr (requires { root.max_tech_level_table; }) {
|
||||
root.max_tech_level_table = w.size();
|
||||
MaxTechniqueLevels max_tech_levels;
|
||||
for (size_t tech_num = 0; tech_num < 0x13; tech_num++) {
|
||||
for (size_t char_class = 0; char_class < 0x0C; char_class++) {
|
||||
max_tech_levels[tech_num][char_class] = pmt.get_max_tech_level(char_class, tech_num);
|
||||
}
|
||||
}
|
||||
w.put<MaxTechniqueLevels>(max_tech_levels);
|
||||
root.max_tech_level_table = rel.template put<MaxTechniqueLevels>(max_tech_levels);
|
||||
}
|
||||
|
||||
ArrayRefT<BE> combination_table_ref;
|
||||
if constexpr (requires { root.combination_table; }) {
|
||||
combination_table_ref.offset = w.size();
|
||||
combination_table_ref.offset = rel.w.size();
|
||||
combination_table_ref.count = pmt.num_item_combinations();
|
||||
for (size_t z = 0; z < combination_table_ref.count; z++) {
|
||||
w.put<ItemCombination>(pmt.get_item_combination(z));
|
||||
rel.template put<ItemCombination>(pmt.get_item_combination(z));
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (requires { root.tech_boost_table; }) {
|
||||
align(4);
|
||||
root.tech_boost_table = w.size();
|
||||
rel.align(4);
|
||||
root.tech_boost_table = rel.w.size();
|
||||
for (size_t z = 0; z < pmt.num_tech_boosts(); z++) {
|
||||
w.put<TechBoostT<BE>>(pmt.get_tech_boost(z));
|
||||
rel.template put<TechBoostT<BE>>(pmt.get_tech_boost(z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3165,8 +3118,8 @@ public:
|
||||
if constexpr (requires { root.unwrap_table; }) {
|
||||
for (size_t event = 0; event < pmt.num_events(); event++) {
|
||||
auto [event_items, num_items] = pmt.get_event_items(event);
|
||||
unwrap_table_refs.emplace_back(ArrayRefT<BE>{num_items, w.size()});
|
||||
w.write(event_items, sizeof(EventItem) * num_items);
|
||||
unwrap_table_refs.emplace_back(ArrayRefT<BE>{num_items, rel.w.size()});
|
||||
rel.write(event_items, sizeof(EventItem) * num_items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3174,95 +3127,65 @@ public:
|
||||
if constexpr (requires { root.unsealable_table; }) {
|
||||
const auto& items = pmt.all_unsealable_items();
|
||||
unsealable_table_ref.count = items.size();
|
||||
unsealable_table_ref.offset = w.size();
|
||||
unsealable_table_ref.offset = rel.w.size();
|
||||
for (const auto& item : items) {
|
||||
UnsealableItem encoded;
|
||||
u32_to_item_code(encoded.item, item);
|
||||
w.put<UnsealableItem>(encoded);
|
||||
rel.template put<UnsealableItem>(encoded);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayRefT<BE> ranged_specials_ref;
|
||||
if constexpr (requires { root.ranged_special_table; }) {
|
||||
ranged_specials_ref.count = pmt.num_ranged_specials();
|
||||
ranged_specials_ref.offset = w.size();
|
||||
ranged_specials_ref.offset = rel.w.size();
|
||||
for (size_t z = 0; z < ranged_specials_ref.count; z++) {
|
||||
w.put<RangedSpecial>(pmt.get_ranged_special(z));
|
||||
rel.template put<RangedSpecial>(pmt.get_ranged_special(z));
|
||||
}
|
||||
}
|
||||
|
||||
align(4);
|
||||
root.armor_table = w.size();
|
||||
write_ref(armors_ref);
|
||||
write_ref(shields_ref);
|
||||
root.unit_table = w.size();
|
||||
write_ref(units_ref);
|
||||
root.mag_table = w.size();
|
||||
write_ref(mags_ref);
|
||||
root.tool_table = w.size();
|
||||
rel.align(4);
|
||||
root.armor_table = rel.write_ref(armors_ref);
|
||||
rel.write_ref(shields_ref);
|
||||
root.unit_table = rel.write_ref(units_ref);
|
||||
root.mag_table = rel.write_ref(mags_ref);
|
||||
root.tool_table = rel.w.size();
|
||||
for (const auto& ref : tool_refs) {
|
||||
write_ref(ref);
|
||||
rel.write_ref(ref);
|
||||
}
|
||||
root.weapon_table = w.size();
|
||||
root.weapon_table = rel.w.size();
|
||||
for (const auto& ref : weapon_refs) {
|
||||
write_ref(ref);
|
||||
rel.write_ref(ref);
|
||||
}
|
||||
if constexpr (requires { root.combination_table; }) {
|
||||
root.combination_table = w.size();
|
||||
write_ref(combination_table_ref);
|
||||
root.combination_table = rel.write_ref(combination_table_ref);
|
||||
}
|
||||
if constexpr (requires { root.unwrap_table; }) {
|
||||
ArrayRefT<BE> event_ref{unwrap_table_refs.size(), w.size()};
|
||||
ArrayRefT<BE> event_ref{unwrap_table_refs.size(), rel.w.size()};
|
||||
for (const auto& ref : unwrap_table_refs) {
|
||||
write_ref(ref);
|
||||
rel.write_ref(ref);
|
||||
}
|
||||
root.unwrap_table = w.size();
|
||||
write_ref(event_ref);
|
||||
root.unwrap_table = rel.write_ref(event_ref);
|
||||
}
|
||||
if constexpr (requires { root.unsealable_table; }) {
|
||||
root.unsealable_table = w.size();
|
||||
write_ref(unsealable_table_ref);
|
||||
root.unsealable_table = rel.write_ref(unsealable_table_ref);
|
||||
}
|
||||
if constexpr (requires { root.ranged_special_table; }) {
|
||||
root.ranged_special_table = w.size();
|
||||
write_ref(ranged_specials_ref);
|
||||
root.ranged_special_table = rel.write_ref(ranged_specials_ref);
|
||||
}
|
||||
|
||||
root.mag_feed_table = w.size();
|
||||
w.put<MagFeedResultsListOffsetsT<BE>>(mag_feed_result_offsets);
|
||||
root.mag_feed_table = rel.template put<MagFeedResultsListOffsetsT<BE>>(mag_feed_result_offsets);
|
||||
for (size_t z = 1; z <= 8; z++) {
|
||||
relocations.emplace(w.size() - (z * 4));
|
||||
rel.relocations.emplace(rel.w.size() - (z * 4));
|
||||
}
|
||||
|
||||
RELFileFooterT<BE> footer;
|
||||
footer.root_offset = w.size();
|
||||
w.put<RootT>(root);
|
||||
uint32_t root_offset = rel.template put<RootT>(root);
|
||||
constexpr size_t root_field_count = (sizeof(RootT) / 4) - ((requires { root.entry_count; }) ? 1 : 0);
|
||||
for (size_t z = 1; z <= root_field_count; z++) {
|
||||
relocations.emplace(w.size() - (z * 4));
|
||||
rel.relocations.emplace(rel.w.size() - (z * 4));
|
||||
}
|
||||
|
||||
align(0x20);
|
||||
footer.relocations_offset = w.size();
|
||||
footer.num_relocations = relocations.size();
|
||||
footer.unused1[0] = 1;
|
||||
uint32_t last_offset = 0;
|
||||
for (uint32_t reloc_offset : relocations) {
|
||||
if (reloc_offset & 3) {
|
||||
throw logic_error("Relocation is not 4-byte aligned");
|
||||
}
|
||||
size_t reloc_value = (reloc_offset - last_offset) >> 2;
|
||||
if (reloc_value > 0xFFFF) {
|
||||
throw runtime_error("Relocation offset is too far away from previous");
|
||||
}
|
||||
w.put<U16T<BE>>(reloc_value);
|
||||
last_offset = reloc_offset;
|
||||
}
|
||||
|
||||
align(0x20);
|
||||
w.put<RELFileFooterT<BE>>(footer);
|
||||
|
||||
return std::move(w.str());
|
||||
return rel.finalize(root_offset);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -3270,7 +3193,7 @@ protected:
|
||||
phosg::StringReader r;
|
||||
const RootT* root;
|
||||
|
||||
mutable std::optional<std::set<uint32_t>> start_offsets;
|
||||
mutable std::set<uint32_t> start_offsets;
|
||||
|
||||
mutable std::unordered_map<uint16_t, Weapon> weapons;
|
||||
mutable std::vector<ArmorOrShield> armors;
|
||||
@@ -3292,7 +3215,7 @@ protected:
|
||||
// the matching order matters.
|
||||
mutable std::optional<std::map<uint32_t, std::vector<ItemCombination>>> item_combination_index;
|
||||
|
||||
mutable std::optional<std::unordered_set<uint32_t>> unsealable_table;
|
||||
mutable std::optional<std::set<uint32_t>> unsealable_table;
|
||||
};
|
||||
|
||||
using ItemParameterTableDCNTE = BinaryItemParameterTableT<
|
||||
|
||||
@@ -472,7 +472,7 @@ public:
|
||||
virtual std::pair<const EventItem*, size_t> get_event_items(uint8_t event_number) const = 0;
|
||||
|
||||
// unsealable_table accessors
|
||||
virtual const std::unordered_set<uint32_t>& all_unsealable_items() const = 0;
|
||||
virtual const std::set<uint32_t>& all_unsealable_items() const = 0;
|
||||
bool is_unsealable_item(uint8_t data1_0, uint8_t data1_1, uint8_t data1_2) const;
|
||||
bool is_unsealable_item(const ItemData& item) const;
|
||||
|
||||
|
||||
+182
-92
@@ -5,14 +5,13 @@
|
||||
#include <phosg/Filesystem.hh>
|
||||
|
||||
#include "CommonFileFormats.hh"
|
||||
#include "Compression.hh"
|
||||
#include "PSOEncryption.hh"
|
||||
#include "StaticGameData.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void LevelTable::reset_to_base(PlayerStats& stats, uint8_t char_class) const {
|
||||
stats.level = 0;
|
||||
stats.experience = 0;
|
||||
stats.exp = 0;
|
||||
stats.char_stats = this->base_stats_for_class(char_class);
|
||||
}
|
||||
|
||||
@@ -28,43 +27,111 @@ void LevelTable::advance_to_level(PlayerStats& stats, uint32_t level, uint8_t ch
|
||||
stats.char_stats.dfp += level_stats.dfp;
|
||||
stats.char_stats.ata += level_stats.ata;
|
||||
// Note: It is not a bug that lck is ignored here; the original code ignores it too.
|
||||
stats.experience = level_stats.experience;
|
||||
stats.exp = level_stats.exp;
|
||||
}
|
||||
}
|
||||
|
||||
LevelTableV2::LevelTableV2(const string& data, bool compressed) {
|
||||
struct Offsets {
|
||||
// TODO: The overall format of this file on V2 has much more data than we actually use. What's known of the
|
||||
// structure so far:
|
||||
le_uint32_t level_deltas; // (5468) -> u32[9] -> LevelStatsDelta[200]
|
||||
le_uint32_t unknown_a1; // (548C) -> float[6]
|
||||
le_uint32_t max_stats; // (54A4) -> PlayerStats[9]
|
||||
le_uint32_t level_100_stats; // (55E8) -> PlayerStats[9]
|
||||
le_uint32_t base_stats; // (57AC) -> u32[9] -> CharacterStats
|
||||
le_uint32_t unknown_a2; // (57D0) -> (0x120 zero bytes)
|
||||
le_uint32_t attack_data; // (58F0) -> AttackData[9]
|
||||
le_uint32_t unknown_a4; // (5AA0) -> parray<parray<float, 5>, 9>
|
||||
le_uint32_t unknown_a5; // (5B54) -> float[9]
|
||||
le_uint32_t unknown_a6; // (5B78) -> (0x30 bytes)
|
||||
le_uint32_t unknown_a7; // (5BA8) -> (0x2D bytes)
|
||||
le_uint32_t unknown_a8; // (5E00) -> u32[3] -> float[0x2D]
|
||||
le_uint32_t unknown_a9; // (5DF4) -> (0x90 bytes)
|
||||
le_uint32_t unknown_a10; // (60D0) -> u32[3] -> (0x10-byte struct)[0x0C]
|
||||
le_uint32_t unknown_a11; // (616C) -> u32[3] -> (0x30-bytes)
|
||||
le_uint32_t unknown_a12; // (64FC) -> u32[3] -> (0x14-byte struct)[0x0F]
|
||||
} __packed_ws__(Offsets, 0x40);
|
||||
|
||||
phosg::StringReader r;
|
||||
string decompressed_data;
|
||||
if (compressed) {
|
||||
decompressed_data = prs_decompress(data);
|
||||
r = phosg::StringReader(decompressed_data);
|
||||
} else {
|
||||
r = phosg::StringReader(data);
|
||||
phosg::JSON LevelTable::json() const {
|
||||
auto base_stats_json = phosg::JSON::list();
|
||||
auto max_stats_json = phosg::JSON::list();
|
||||
auto level_deltas_json = phosg::JSON::list();
|
||||
for (size_t char_class = 0; char_class < this->num_char_classes(); char_class++) {
|
||||
base_stats_json.emplace_back(this->base_stats_for_class(char_class).json());
|
||||
max_stats_json.emplace_back(this->max_stats_for_class(char_class).json());
|
||||
auto this_class_level_deltas_json = phosg::JSON::list();
|
||||
for (size_t level = 0; level < 200; level++) {
|
||||
this_class_level_deltas_json.emplace_back(this->stats_delta_for_level(char_class, level).json());
|
||||
}
|
||||
level_deltas_json.emplace_back(std::move(this_class_level_deltas_json));
|
||||
}
|
||||
return phosg::JSON::dict({
|
||||
{"BaseStats", std::move(base_stats_json)},
|
||||
{"MaxStats", std::move(max_stats_json)},
|
||||
{"LevelDeltas", std::move(level_deltas_json)},
|
||||
});
|
||||
}
|
||||
|
||||
JSONLevelTable::JSONLevelTable(const phosg::JSON& json) {
|
||||
const auto& base_stats_json = json.at("BaseStats").as_list();
|
||||
const auto& max_stats_json = json.at("MaxStats").as_list();
|
||||
const auto& level_deltas_json = json.at("LevelDeltas").as_list();
|
||||
for (size_t char_class = 0; char_class < base_stats_json.size(); char_class++) {
|
||||
this->base_stats.emplace_back(CharacterStats::from_json(*base_stats_json.at(char_class)));
|
||||
this->max_stats.emplace_back(PlayerStats::from_json(*max_stats_json.at(char_class)));
|
||||
const auto& this_class_level_deltas_json = level_deltas_json.at(char_class)->as_list();
|
||||
auto& parsed_deltas = this->level_deltas.emplace_back();
|
||||
for (size_t level = 0; level < 200; level++) {
|
||||
parsed_deltas[level] = LevelStatsDelta::from_json(*this_class_level_deltas_json.at(level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t JSONLevelTable::num_char_classes() const {
|
||||
return this->base_stats.size();
|
||||
}
|
||||
|
||||
const CharacterStats& JSONLevelTable::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->base_stats.at(char_class);
|
||||
}
|
||||
|
||||
const PlayerStats& JSONLevelTable::max_stats_for_class(uint8_t char_class) const {
|
||||
return this->max_stats.at(char_class);
|
||||
}
|
||||
|
||||
const LevelStatsDelta& JSONLevelTable::stats_delta_for_level(uint8_t char_class, uint8_t level) const {
|
||||
return this->level_deltas.at(char_class).at(level);
|
||||
}
|
||||
|
||||
LevelTableV2::LevelTableV2(const string& data) {
|
||||
struct Root {
|
||||
// The overall format of this file on V2 has much more data than we actually use. This table is sorted by the
|
||||
// offset in the PlayerTable.prs file; note that the offset fields in this structure do not match that order.
|
||||
// ## OFFS WHAT -> TARGET
|
||||
// 0008 level_deltas[0] -> LevelStatsDelta[200] (by level) (the rest follow immediately)
|
||||
// 00 5468 level_deltas -> u32[9] (by char_class)
|
||||
// 04 548C hp_tp_factors -> HPTPFactors[3] (by char_class_class; [0] = hunter, [1] = ranger, [2] = force)
|
||||
// 08 54A4 max_stats -> PlayerStats[9] (by char_class)
|
||||
// 0C 55E8 level_100_stats -> PlayerStats[9] (by char_class)
|
||||
// 572C base_stats[0] -> CharacterStats
|
||||
// 10 57AC base_stats -> u32[9] (by char_class)
|
||||
// 14 57D0 resist_data -> ResistData[9] (by char_class)
|
||||
// 18 58F0 attack_data -> AttackData[9] (by char_class)
|
||||
// 1C 5AA0 unknown_a4 -> float[15][3] (by [???][attack_number])
|
||||
// 20 5B54 unknown_a5 -> float[3][3] (by [strike_number][attack_number])
|
||||
// 24 5B78 unknown_a6 -> float[3][3] (by [strike_number][attack_number]) (may be [4][3] in original code; there are 0xC zero bytes after)
|
||||
// 28 5BA8 unknown_a7 -> uint8_t[15][3] (same indexes as unknown_a4)
|
||||
// 5BD8 unknown_a9[0] -> UnknownA9[15] (index unknown; appears animation-related)
|
||||
// 30 5DF4 unknown_a9 -> u32[3] (by char_class_class)
|
||||
// 2C 5E00 area_sound_configs -> AreaSoundConfig[0x12] (by area)
|
||||
// 5E90 unknown_a10[0] -> (0x10-byte struct)[0x0C] (the rest follow immediately)
|
||||
// 34 60D0 unknown_a10 -> u32[3] (by char_class_class)
|
||||
// 60DC unknown_a11[0] -> WeaponReference[12] (the rest follow immediately)
|
||||
// 38 616C unknown_a11 -> u32[3] (by char_class_class)
|
||||
// 6178 unknown_a12[0] -> UnknownA12[15] (the rest follow immediately)
|
||||
// 3C 64FC unknown_a12 -> u32[3] (by char_class_class)
|
||||
|
||||
/* 00 / 5468 * */ le_uint32_t level_deltas;
|
||||
/* 04 / 548C * */ le_uint32_t hp_tp_factors;
|
||||
/* 08 / 54A4 * */ le_uint32_t max_stats;
|
||||
/* 0C / 55E8 * */ le_uint32_t level_100_stats;
|
||||
/* 10 / 57AC * */ le_uint32_t base_stats;
|
||||
/* 14 / 57D0 * */ le_uint32_t resist_data;
|
||||
/* 18 / 58F0 * */ le_uint32_t attack_data;
|
||||
/* 1C / 5AA0 * */ le_uint32_t unknown_a4;
|
||||
/* 20 / 5B54 * */ le_uint32_t unknown_a5;
|
||||
/* 24 / 5B78 * */ le_uint32_t unknown_a6;
|
||||
/* 28 / 5BA8 * */ le_uint32_t unknown_a7;
|
||||
/* 2C / 5E00 * */ le_uint32_t area_sound_configs;
|
||||
/* 30 / 5DF4 * */ le_uint32_t unknown_a9;
|
||||
/* 34 / 60D0 * */ le_uint32_t unknown_a10;
|
||||
/* 38 / 616C * */ le_uint32_t unknown_a11;
|
||||
/* 3C / 64FC * */ le_uint32_t unknown_a12;
|
||||
} __packed_ws__(Root, 0x40);
|
||||
|
||||
phosg::StringReader r(data);
|
||||
|
||||
const auto& footer = r.pget<RELFileFooter>(r.size() - sizeof(RELFileFooter));
|
||||
const auto& offsets = r.pget<Offsets>(footer.root_offset);
|
||||
const auto& offsets = r.pget<Root>(footer.root_offset);
|
||||
const auto& level_deltas_offsets = r.pget<parray<le_uint32_t, 9>>(offsets.level_deltas);
|
||||
const auto& base_stats_offsets = r.pget<parray<le_uint32_t, 9>>(offsets.base_stats);
|
||||
for (size_t char_class = 0; char_class < 9; char_class++) {
|
||||
@@ -73,17 +140,16 @@ LevelTableV2::LevelTableV2(const string& data, bool compressed) {
|
||||
this->level_deltas[char_class][level] = src_level_deltas[level];
|
||||
}
|
||||
this->max_stats[char_class] = r.pget<PlayerStats>(offsets.max_stats + char_class * sizeof(PlayerStats));
|
||||
this->level_100_stats[char_class] = r.pget<PlayerStats>(offsets.level_100_stats + char_class * sizeof(PlayerStats));
|
||||
this->base_stats[char_class] = r.pget<CharacterStats>(base_stats_offsets[char_class]);
|
||||
}
|
||||
}
|
||||
|
||||
const CharacterStats& LevelTableV2::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->base_stats.at(char_class);
|
||||
size_t LevelTableV2::num_char_classes() const {
|
||||
return 9;
|
||||
}
|
||||
|
||||
const PlayerStats& LevelTableV2::level_100_stats_for_class(uint8_t char_class) const {
|
||||
return this->level_100_stats.at(char_class);
|
||||
const CharacterStats& LevelTableV2::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->base_stats.at(char_class);
|
||||
}
|
||||
|
||||
const PlayerStats& LevelTableV2::max_stats_for_class(uint8_t char_class) const {
|
||||
@@ -94,46 +160,11 @@ const LevelStatsDelta& LevelTableV2::stats_delta_for_level(uint8_t char_class, u
|
||||
return this->level_deltas.at(char_class).at(level);
|
||||
}
|
||||
|
||||
LevelTableV3BE::LevelTableV3BE(const string& data, bool encrypted) {
|
||||
phosg::StringReader r;
|
||||
string decompressed_data;
|
||||
if (encrypted) {
|
||||
auto decrypted = decrypt_pr2_data<true>(data);
|
||||
decompressed_data = prs_decompress(decrypted.compressed_data);
|
||||
if (decompressed_data.size() != decrypted.decompressed_size) {
|
||||
throw runtime_error("decompressed data size does not match expected size");
|
||||
}
|
||||
r = phosg::StringReader(decompressed_data);
|
||||
} else {
|
||||
r = phosg::StringReader(data);
|
||||
}
|
||||
|
||||
// The GC format is very simple (but everything is big-endian):
|
||||
// root:
|
||||
// u32 offset:
|
||||
// u32[12] offsets:
|
||||
// LevelStatsDeltaBE[200] level_deltas
|
||||
const auto& footer = r.pget<RELFileFooterBE>(r.size() - sizeof(RELFileFooterBE));
|
||||
const auto& offsets = r.pget<parray<be_uint32_t, 12>>(r.pget_u32b(footer.root_offset));
|
||||
for (size_t char_class = 0; char_class < 12; char_class++) {
|
||||
const auto& src_deltas = r.pget<parray<LevelStatsDeltaBE, 200>>(offsets[char_class]);
|
||||
for (size_t level = 0; level < 200; level++) {
|
||||
const auto& src_delta = src_deltas[level];
|
||||
auto& dest_delta = this->level_deltas[char_class][level];
|
||||
dest_delta.atp = src_delta.atp;
|
||||
dest_delta.mst = src_delta.mst;
|
||||
dest_delta.evp = src_delta.evp;
|
||||
dest_delta.hp = src_delta.hp;
|
||||
dest_delta.dfp = src_delta.dfp;
|
||||
dest_delta.ata = src_delta.ata;
|
||||
dest_delta.lck = src_delta.lck;
|
||||
dest_delta.tp = src_delta.tp;
|
||||
dest_delta.experience = src_delta.experience;
|
||||
}
|
||||
}
|
||||
size_t LevelTableV3::num_char_classes() const {
|
||||
return 12;
|
||||
}
|
||||
|
||||
const CharacterStats& LevelTableV3BE::base_stats_for_class(uint8_t char_class) const {
|
||||
const CharacterStats& LevelTableV3::base_stats_for_class(uint8_t char_class) const {
|
||||
static const array<CharacterStats, 12> data = {
|
||||
// ATP MST EVP HP DFP ATA LCK
|
||||
CharacterStats{0x0023, 0x001D, 0x002D, 0x0014, 0x0011, 0x001E, 0x000A},
|
||||
@@ -168,31 +199,86 @@ static const array<PlayerStats, 12> max_stats_v3_v4 = {
|
||||
PlayerStats{{0x0474, 0x0407, 0x0384, 0x02CF, 0x0241, 0x06C2, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
|
||||
};
|
||||
|
||||
const PlayerStats& LevelTableV3BE::max_stats_for_class(uint8_t char_class) const {
|
||||
const PlayerStats& LevelTableV3::max_stats_for_class(uint8_t char_class) const {
|
||||
return max_stats_v3_v4.at(char_class);
|
||||
}
|
||||
|
||||
const LevelStatsDelta& LevelTableV3BE::stats_delta_for_level(uint8_t char_class, uint8_t level) const {
|
||||
const LevelStatsDelta& LevelTableV3::stats_delta_for_level(uint8_t char_class, uint8_t level) const {
|
||||
return this->level_deltas.at(char_class).at(level);
|
||||
}
|
||||
|
||||
LevelTableV4::LevelTableV4(const string& data, bool compressed) {
|
||||
struct Offsets {
|
||||
le_uint32_t base_stats; // -> u32[12] -> CharacterStats
|
||||
le_uint32_t level_deltas; // -> u32[12] -> LevelStatsDelta[200]
|
||||
} __packed_ws__(Offsets, 8);
|
||||
template <bool BE>
|
||||
void parse_level_deltas_t(std::array<std::array<LevelStatsDelta, 200>, 12>& deltas, const string& data) {
|
||||
// The V3 format is very simple:
|
||||
// root:
|
||||
// u32 offset:
|
||||
// u32[12] offsets:
|
||||
// LevelStatsDeltaBE[200] level_deltas
|
||||
phosg::StringReader r(data);
|
||||
const auto& footer = r.pget<RELFileFooterT<BE>>(r.size() - sizeof(RELFileFooterT<BE>));
|
||||
const auto& offsets = r.pget<parray<U32T<BE>, 12>>(r.pget<U32T<BE>>(footer.root_offset));
|
||||
for (size_t char_class = 0; char_class < 12; char_class++) {
|
||||
const auto& src_deltas = r.pget<parray<LevelStatsDeltaT<BE>, 200>>(offsets[char_class]);
|
||||
for (size_t level = 0; level < 200; level++) {
|
||||
deltas[char_class][level] = src_deltas[level];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
phosg::StringReader r;
|
||||
string decompressed_data;
|
||||
if (compressed) {
|
||||
decompressed_data = prs_decompress(data);
|
||||
r = phosg::StringReader(decompressed_data);
|
||||
} else {
|
||||
r = phosg::StringReader(data);
|
||||
LevelTableGC::LevelTableGC(const string& data) {
|
||||
parse_level_deltas_t<true>(this->level_deltas, data);
|
||||
}
|
||||
|
||||
LevelTableXB::LevelTableXB(const string& data) {
|
||||
parse_level_deltas_t<false>(this->level_deltas, data);
|
||||
}
|
||||
|
||||
struct RootV4 {
|
||||
le_uint32_t base_stats; // -> u32[12] -> CharacterStats
|
||||
le_uint32_t level_deltas; // -> u32[12] -> LevelStatsDelta[200]
|
||||
} __packed_ws__(RootV4, 8);
|
||||
|
||||
std::string LevelTable::serialize_binary_v4() const {
|
||||
RELFileWriter<false> rel;
|
||||
RootV4 root;
|
||||
|
||||
{
|
||||
std::vector<uint32_t> offsets;
|
||||
for (size_t char_class = 0; char_class < this->num_char_classes(); char_class++) {
|
||||
offsets.emplace_back(rel.put<CharacterStats>(this->base_stats_for_class(char_class)));
|
||||
}
|
||||
root.base_stats = rel.w.size();
|
||||
for (uint32_t offset : offsets) {
|
||||
rel.write_offset(offset);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<uint32_t> offsets;
|
||||
for (size_t char_class = 0; char_class < this->num_char_classes(); char_class++) {
|
||||
offsets.emplace_back(rel.w.size());
|
||||
for (size_t level = 0; level < 200; level++) {
|
||||
rel.put<LevelStatsDelta>(this->stats_delta_for_level(char_class, level));
|
||||
}
|
||||
}
|
||||
root.level_deltas = rel.w.size();
|
||||
for (uint32_t offset : offsets) {
|
||||
rel.write_offset(offset);
|
||||
}
|
||||
}
|
||||
|
||||
size_t root_offset = rel.put<RootV4>(root);
|
||||
rel.relocations.emplace(root_offset);
|
||||
rel.relocations.emplace(root_offset + 4);
|
||||
|
||||
return rel.finalize(root_offset);
|
||||
}
|
||||
|
||||
LevelTableV4::LevelTableV4(const string& data) {
|
||||
|
||||
phosg::StringReader r(data);
|
||||
const auto& footer = r.pget<RELFileFooter>(r.size() - sizeof(RELFileFooter));
|
||||
const auto& offsets = r.pget<Offsets>(footer.root_offset);
|
||||
const auto& offsets = r.pget<RootV4>(footer.root_offset);
|
||||
const auto& level_deltas_offsets = r.pget<parray<le_uint32_t, 12>>(offsets.level_deltas);
|
||||
const auto& base_stats_offsets = r.pget<parray<le_uint32_t, 12>>(offsets.base_stats);
|
||||
for (size_t char_class = 0; char_class < 12; char_class++) {
|
||||
@@ -204,6 +290,10 @@ LevelTableV4::LevelTableV4(const string& data, bool compressed) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t LevelTableV4::num_char_classes() const {
|
||||
return 12;
|
||||
}
|
||||
|
||||
const CharacterStats& LevelTableV4::base_stats_for_class(uint8_t char_class) const {
|
||||
return this->base_stats.at(char_class);
|
||||
}
|
||||
|
||||
+168
-41
@@ -21,17 +21,34 @@ struct CharacterStatsT {
|
||||
/* 0A */ U16T<BE> ata = 0;
|
||||
/* 0C */ U16T<BE> lck = 0;
|
||||
/* 0E */
|
||||
|
||||
static CharacterStatsT<BE> from_json(const phosg::JSON& json) {
|
||||
return CharacterStatsT<BE>{
|
||||
json.at("ATP").as_int(),
|
||||
json.at("MST").as_int(),
|
||||
json.at("EVP").as_int(),
|
||||
json.at("HP").as_int(),
|
||||
json.at("DFP").as_int(),
|
||||
json.at("ATA").as_int(),
|
||||
json.at("LCK").as_int()};
|
||||
}
|
||||
phosg::JSON json() const {
|
||||
return phosg::JSON::dict({{"ATP", this->atp.load()},
|
||||
{"MST", this->mst.load()},
|
||||
{"EVP", this->evp.load()},
|
||||
{"HP", this->hp.load()},
|
||||
{"DFP", this->dfp.load()},
|
||||
{"ATA", this->ata.load()},
|
||||
{"LCK", this->lck.load()}});
|
||||
}
|
||||
operator CharacterStatsT<!BE>() const {
|
||||
CharacterStatsT<!BE> ret;
|
||||
ret.atp = this->atp;
|
||||
ret.mst = this->mst;
|
||||
ret.evp = this->evp;
|
||||
ret.hp = this->hp;
|
||||
ret.dfp = this->dfp;
|
||||
ret.ata = this->ata;
|
||||
ret.lck = this->lck;
|
||||
return ret;
|
||||
return CharacterStatsT<!BE>{
|
||||
this->atp.load(),
|
||||
this->mst.load(),
|
||||
this->evp.load(),
|
||||
this->hp.load(),
|
||||
this->dfp.load(),
|
||||
this->ata.load(),
|
||||
this->lck.load()};
|
||||
}
|
||||
} __packed_ws_be__(CharacterStatsT, 0x0E);
|
||||
using CharacterStats = CharacterStatsT<false>;
|
||||
@@ -44,37 +61,82 @@ struct PlayerStatsT {
|
||||
/* 10 */ F32T<BE> attack_range = 0.0;
|
||||
/* 14 */ F32T<BE> knockback_range = 0.0;
|
||||
/* 18 */ U32T<BE> level = 0; // Qedit specifies this as tech level when used for enemies
|
||||
/* 1C */ U32T<BE> experience = 0;
|
||||
/* 1C */ U32T<BE> exp = 0;
|
||||
/* 20 */ U32T<BE> meseta = 0; // Qedit specifies this as TP when used for enemies
|
||||
/* 24 */
|
||||
|
||||
operator PlayerStatsT<!BE>() const {
|
||||
PlayerStatsT<!BE> ret;
|
||||
ret.char_stats = this->char_stats;
|
||||
ret.esp = this->esp;
|
||||
ret.attack_range = this->attack_range;
|
||||
ret.knockback_range = this->knockback_range;
|
||||
ret.level = this->level;
|
||||
ret.experience = this->experience;
|
||||
ret.meseta = this->meseta;
|
||||
static PlayerStatsT<BE> from_json(const phosg::JSON& json) {
|
||||
return PlayerStatsT<BE>{
|
||||
CharacterStatsT<BE>::from_json(json),
|
||||
json.at("ESP").as_int(),
|
||||
json.at("AttackRange").as_float(),
|
||||
json.at("KnockbackRange").as_float(),
|
||||
json.at("Level").as_int(),
|
||||
json.at("EXP").as_int(),
|
||||
json.at("Meseta").as_int()};
|
||||
}
|
||||
phosg::JSON json() const {
|
||||
auto ret = this->char_stats.json();
|
||||
ret.emplace("ESP", this->esp.load());
|
||||
ret.emplace("AttackRange", this->attack_range.load());
|
||||
ret.emplace("KnockbackRange", this->knockback_range.load());
|
||||
ret.emplace("Level", this->level.load());
|
||||
ret.emplace("EXP", this->exp.load());
|
||||
ret.emplace("Meseta", this->meseta.load());
|
||||
return ret;
|
||||
}
|
||||
operator PlayerStatsT<!BE>() const {
|
||||
return PlayerStatsT<!BE>{
|
||||
this->char_stats,
|
||||
this->esp.load(),
|
||||
this->attack_range.load(),
|
||||
this->knockback_range.load(),
|
||||
this->level.load(),
|
||||
this->exp.load(),
|
||||
this->meseta.load()};
|
||||
}
|
||||
} __packed_ws_be__(PlayerStatsT, 0x24);
|
||||
using PlayerStats = PlayerStatsT<false>;
|
||||
using PlayerStatsBE = PlayerStatsT<true>;
|
||||
|
||||
template <bool BE>
|
||||
struct LevelStatsDeltaT {
|
||||
/* 00 */ uint8_t atp;
|
||||
/* 01 */ uint8_t mst;
|
||||
/* 02 */ uint8_t evp;
|
||||
/* 03 */ uint8_t hp;
|
||||
/* 04 */ uint8_t dfp;
|
||||
/* 05 */ uint8_t ata;
|
||||
/* 06 */ uint8_t lck;
|
||||
/* 07 */ uint8_t tp;
|
||||
/* 08 */ U32T<BE> experience;
|
||||
/* 00 */ uint8_t atp = 0;
|
||||
/* 01 */ uint8_t mst = 0;
|
||||
/* 02 */ uint8_t evp = 0;
|
||||
/* 03 */ uint8_t hp = 0;
|
||||
/* 04 */ uint8_t dfp = 0;
|
||||
/* 05 */ uint8_t ata = 0;
|
||||
/* 06 */ uint8_t lck = 0;
|
||||
/* 07 */ uint8_t tp = 0;
|
||||
/* 08 */ U32T<BE> exp = 0;
|
||||
/* 0C */
|
||||
static LevelStatsDeltaT<BE> from_json(const phosg::JSON& json) {
|
||||
return LevelStatsDeltaT<BE>{
|
||||
static_cast<uint8_t>(json.at("ATP").as_int()),
|
||||
static_cast<uint8_t>(json.at("MST").as_int()),
|
||||
static_cast<uint8_t>(json.at("EVP").as_int()),
|
||||
static_cast<uint8_t>(json.at("HP").as_int()),
|
||||
static_cast<uint8_t>(json.at("DFP").as_int()),
|
||||
static_cast<uint8_t>(json.at("ATA").as_int()),
|
||||
static_cast<uint8_t>(json.at("LCK").as_int()),
|
||||
static_cast<uint8_t>(json.at("TP").as_int()),
|
||||
static_cast<uint32_t>(json.at("EXP").as_int())};
|
||||
}
|
||||
phosg::JSON json() const {
|
||||
return phosg::JSON::dict({{"ATP", this->atp},
|
||||
{"MST", this->mst},
|
||||
{"EVP", this->evp},
|
||||
{"HP", this->hp},
|
||||
{"DFP", this->dfp},
|
||||
{"ATA", this->ata},
|
||||
{"LCK", this->lck},
|
||||
{"TP", this->tp},
|
||||
{"EXP", this->exp.load()}});
|
||||
}
|
||||
operator LevelStatsDeltaT<!BE>() const {
|
||||
return LevelStatsDeltaT<!BE>{
|
||||
this->atp, this->mst, this->evp, this->hp, this->dfp, this->ata, this->lck, this->tp, this->exp.load()};
|
||||
}
|
||||
|
||||
void apply(CharacterStats& ps) const {
|
||||
ps.ata += this->ata;
|
||||
@@ -95,6 +157,8 @@ class LevelTable {
|
||||
// Offsets structures inside the subclasses' constructor implementations for more details on the file formats.
|
||||
public:
|
||||
virtual ~LevelTable() = default;
|
||||
|
||||
virtual size_t num_char_classes() const = 0;
|
||||
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const = 0;
|
||||
virtual const PlayerStats& max_stats_for_class(uint8_t char_class) const = 0;
|
||||
virtual const LevelStatsDelta& stats_delta_for_level(uint8_t char_class, uint8_t level) const = 0;
|
||||
@@ -102,50 +166,113 @@ public:
|
||||
void reset_to_base(PlayerStats& stats, uint8_t char_class) const;
|
||||
void advance_to_level(PlayerStats& stats, uint32_t level, uint8_t char_class) const;
|
||||
|
||||
std::string serialize_binary_v4() const;
|
||||
phosg::JSON json() const;
|
||||
|
||||
protected:
|
||||
LevelTable() = default;
|
||||
};
|
||||
|
||||
class LevelTableV2 : public LevelTable { // from PlayerTable.prs (PC)
|
||||
class JSONLevelTable : public LevelTable {
|
||||
public:
|
||||
LevelTableV2(const std::string& data, bool compressed);
|
||||
virtual ~LevelTableV2() = default;
|
||||
JSONLevelTable(const phosg::JSON& json);
|
||||
virtual ~JSONLevelTable() = default;
|
||||
|
||||
virtual size_t num_char_classes() const;
|
||||
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const;
|
||||
const PlayerStats& level_100_stats_for_class(uint8_t char_class) const;
|
||||
virtual const PlayerStats& max_stats_for_class(uint8_t char_class) const;
|
||||
virtual const LevelStatsDelta& stats_delta_for_level(uint8_t char_class, uint8_t level) const;
|
||||
|
||||
private:
|
||||
std::vector<CharacterStats> base_stats;
|
||||
std::vector<PlayerStats> max_stats;
|
||||
std::vector<std::array<LevelStatsDelta, 200>> level_deltas;
|
||||
};
|
||||
|
||||
class LevelTableV2 : public LevelTable { // from PlayerTable.prs (PC)
|
||||
public:
|
||||
struct HPTPFactors {
|
||||
le_float hp_factor;
|
||||
le_float tp_factor;
|
||||
} __packed_ws__(HPTPFactors, 8);
|
||||
|
||||
struct UnknownA9 {
|
||||
le_float unknown_a1;
|
||||
le_float unknown_a2;
|
||||
le_float unknown_a3;
|
||||
} __packed_ws__(UnknownA9, 0x0C);
|
||||
|
||||
struct AreaSoundConfig {
|
||||
le_uint16_t step_sound;
|
||||
le_uint16_t grass_step_sound;
|
||||
le_uint16_t water_step_sound;
|
||||
parray<uint8_t, 2> unused;
|
||||
} __packed_ws__(AreaSoundConfig, 8);
|
||||
|
||||
struct WeaponReference {
|
||||
le_uint16_t data1_1;
|
||||
le_uint16_t data1_2;
|
||||
} __packed_ws__(WeaponReference, 4);
|
||||
|
||||
struct UnknownA12 {
|
||||
le_float unknown_a1;
|
||||
le_float unknown_a2;
|
||||
le_float unknown_a3;
|
||||
le_float unknown_a4;
|
||||
le_uint32_t unknown_a5;
|
||||
} __packed_ws__(UnknownA12, 0x14);
|
||||
|
||||
explicit LevelTableV2(const std::string& data);
|
||||
virtual ~LevelTableV2() = default;
|
||||
|
||||
virtual size_t num_char_classes() const;
|
||||
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const;
|
||||
virtual const PlayerStats& max_stats_for_class(uint8_t char_class) const;
|
||||
virtual const LevelStatsDelta& stats_delta_for_level(uint8_t char_class, uint8_t level) const;
|
||||
|
||||
protected:
|
||||
std::array<CharacterStats, 9> base_stats;
|
||||
std::array<PlayerStats, 9> level_100_stats;
|
||||
std::array<PlayerStats, 9> max_stats;
|
||||
std::array<std::array<LevelStatsDelta, 200>, 9> level_deltas;
|
||||
};
|
||||
|
||||
class LevelTableV3BE : public LevelTable { // from PlyLevelTbl.cpt (GC)
|
||||
class LevelTableV3 : public LevelTable { // from PlyLevelTbl.cpt (GC/XB)
|
||||
public:
|
||||
LevelTableV3BE(const std::string& data, bool encrypted);
|
||||
virtual ~LevelTableV3BE() = default;
|
||||
virtual ~LevelTableV3() = default;
|
||||
|
||||
virtual size_t num_char_classes() const;
|
||||
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const;
|
||||
virtual const PlayerStats& max_stats_for_class(uint8_t char_class) const;
|
||||
virtual const LevelStatsDelta& stats_delta_for_level(uint8_t char_class, uint8_t level) const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
LevelTableV3() = default;
|
||||
std::array<std::array<LevelStatsDelta, 200>, 12> level_deltas;
|
||||
};
|
||||
|
||||
class LevelTableGC : public LevelTableV3 {
|
||||
public:
|
||||
explicit LevelTableGC(const std::string& data);
|
||||
virtual ~LevelTableGC() = default;
|
||||
};
|
||||
|
||||
class LevelTableXB : public LevelTableV3 {
|
||||
public:
|
||||
explicit LevelTableXB(const std::string& data);
|
||||
virtual ~LevelTableXB() = default;
|
||||
};
|
||||
|
||||
class LevelTableV4 : public LevelTable { // from PlyLevelTbl.prs (BB)
|
||||
public:
|
||||
LevelTableV4(const std::string& data, bool compressed);
|
||||
explicit LevelTableV4(const std::string& data);
|
||||
virtual ~LevelTableV4() = default;
|
||||
|
||||
virtual size_t num_char_classes() const;
|
||||
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const;
|
||||
virtual const PlayerStats& max_stats_for_class(uint8_t char_class) const;
|
||||
virtual const LevelStatsDelta& stats_delta_for_level(uint8_t char_class, uint8_t level) const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::array<CharacterStats, 12> base_stats;
|
||||
std::array<std::array<LevelStatsDelta, 200>, 12> level_deltas;
|
||||
};
|
||||
|
||||
+3
-3
@@ -5,11 +5,11 @@
|
||||
using namespace std;
|
||||
|
||||
phosg::PrefixedLogger channel_exceptions_log("[Channel] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger client_functions_log("[ClientFunctionIndex] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger client_log("", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger command_data_log("[Commands] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger config_log("[Config] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger dns_server_log("[DNSServer] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger function_compiler_log("[FunctionCompiler] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger ip_stack_simulator_log("[IPStackSimulator] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger lobby_log("", phosg::LogLevel::L_USE_DEFAULT);
|
||||
phosg::PrefixedLogger patch_index_log("[PatchFileIndex] ", phosg::LogLevel::L_USE_DEFAULT);
|
||||
@@ -30,11 +30,11 @@ static void set_log_level_from_json(
|
||||
|
||||
void set_all_log_levels(phosg::LogLevel level) {
|
||||
channel_exceptions_log.min_level = level;
|
||||
client_functions_log.min_level = level;
|
||||
client_log.min_level = level;
|
||||
command_data_log.min_level = level;
|
||||
config_log.min_level = level;
|
||||
dns_server_log.min_level = level;
|
||||
function_compiler_log.min_level = level;
|
||||
ip_stack_simulator_log.min_level = level;
|
||||
lobby_log.min_level = level;
|
||||
patch_index_log.min_level = level;
|
||||
@@ -47,11 +47,11 @@ void set_all_log_levels(phosg::LogLevel level) {
|
||||
|
||||
void set_log_levels_from_json(const phosg::JSON& json) {
|
||||
set_log_level_from_json(channel_exceptions_log, json, "ChannelExceptions");
|
||||
set_log_level_from_json(client_functions_log, json, "ClientFunctionIndex");
|
||||
set_log_level_from_json(client_log, json, "Clients");
|
||||
set_log_level_from_json(command_data_log, json, "CommandData");
|
||||
set_log_level_from_json(config_log, json, "Config");
|
||||
set_log_level_from_json(dns_server_log, json, "DNSServer");
|
||||
set_log_level_from_json(function_compiler_log, json, "FunctionCompiler");
|
||||
set_log_level_from_json(ip_stack_simulator_log, json, "IPStackSimulator");
|
||||
set_log_level_from_json(lobby_log, json, "Lobbies");
|
||||
set_log_level_from_json(patch_index_log, json, "PatchFileIndex");
|
||||
|
||||
+1
-1
@@ -4,11 +4,11 @@
|
||||
#include <phosg/Strings.hh>
|
||||
|
||||
extern phosg::PrefixedLogger channel_exceptions_log;
|
||||
extern phosg::PrefixedLogger client_functions_log;
|
||||
extern phosg::PrefixedLogger client_log;
|
||||
extern phosg::PrefixedLogger command_data_log;
|
||||
extern phosg::PrefixedLogger config_log;
|
||||
extern phosg::PrefixedLogger dns_server_log;
|
||||
extern phosg::PrefixedLogger function_compiler_log;
|
||||
extern phosg::PrefixedLogger ip_stack_simulator_log;
|
||||
extern phosg::PrefixedLogger lobby_log;
|
||||
extern phosg::PrefixedLogger patch_index_log;
|
||||
|
||||
+202
-64
@@ -4,80 +4,120 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct MotionReference {
|
||||
struct Side {
|
||||
// This specifies which entry in ItemMagMotion.dat is used. The file is just a list of 0x64-byte structures.
|
||||
// 0xFF = no TItemMagSub is created
|
||||
uint8_t motion_table_entry = 0xFF;
|
||||
parray<uint8_t, 5> unknown_a1 = 0;
|
||||
} __packed_ws__(Side, 0x06);
|
||||
parray<Side, 2> sides; // [0] = right side, [1] = left side
|
||||
} __packed_ws__(MotionReference, 0x0C);
|
||||
|
||||
template <bool BE>
|
||||
struct MotionReferenceTables {
|
||||
// It seems that there are two definition tables, but only the first is used on any version of PSO. On v3 and later,
|
||||
// the two offsets point to the same table, but on v2 they don't and the second table contains different data.
|
||||
// TODO: Figure out what the deal is with the different v2 tables.
|
||||
U32T<BE> ref_table; // -> MotionReference[num_mags]
|
||||
U32T<BE> unused_ref_table; // -> MotionReference[num_mags]
|
||||
U32T<BE> ref_table;
|
||||
U32T<BE> unused_ref_table;
|
||||
} __packed_ws_be__(MotionReferenceTables, 0x08);
|
||||
|
||||
template <bool BE>
|
||||
struct ColorEntry {
|
||||
// Colors are specified as 4 floats, each in the range [0, 1], for each color channel. The default colors are:
|
||||
// alpha red green blue color (see StaticGameData.cc)
|
||||
// 1.0 1.0 0.2 0.1 red
|
||||
// 1.0 0.2 0.2 1.0 blue
|
||||
// 1.0 1.0 0.9 0.1 yellow
|
||||
// 1.0 0.1 1.0 0.1 green
|
||||
// 1.0 0.8 0.1 1.0 purple
|
||||
// 1.0 0.1 0.1 0.2 black
|
||||
// 1.0 0.9 1.0 1.0 white
|
||||
// 1.0 0.1 0.9 1.0 cyan
|
||||
// 1.0 0.5 0.3 0.2 brown
|
||||
// 1.0 1.0 0.4 0.0 orange (v3+)
|
||||
// 1.0 0.502 0.545 0.977 light-blue (v3+)
|
||||
// 1.0 0.502 0.502 0.0 olive (v3+)
|
||||
// 1.0 0.0 0.941 0.714 turquoise (v3+)
|
||||
// 1.0 0.8 0.098 0.392 fuchsia (v3+)
|
||||
// 1.0 0.498 0.498 0.498 grey (v3+)
|
||||
// 1.0 0.996 0.996 0.832 cream (v3+)
|
||||
// 1.0 0.996 0.498 0.784 pink (v3+)
|
||||
// 1.0 0.0 0.498 0.322 dark-green (v3+)
|
||||
// alpha red green blue color (see StaticGameData.cc)
|
||||
// 00 => 1.0 1.0 0.2 0.1 red
|
||||
// 01 => 1.0 0.2 0.2 1.0 blue
|
||||
// 02 => 1.0 1.0 0.9 0.1 yellow
|
||||
// 03 => 1.0 0.1 1.0 0.1 green
|
||||
// 04 => 1.0 0.8 0.1 1.0 purple
|
||||
// 05 => 1.0 0.1 0.1 0.2 black
|
||||
// 06 => 1.0 0.9 1.0 1.0 white
|
||||
// 07 => 1.0 0.1 0.9 1.0 cyan
|
||||
// 08 => 1.0 0.5 0.3 0.2 brown
|
||||
// 09 => 1.0 1.0 0.4 0.0 orange (v3+)
|
||||
// 0A => 1.0 0.502 0.545 0.977 light-blue (v3+)
|
||||
// 0B => 1.0 0.502 0.502 0.0 olive (v3+)
|
||||
// 0C => 1.0 0.0 0.941 0.714 turquoise (v3+)
|
||||
// 0D => 1.0 0.8 0.098 0.392 fuchsia (v3+)
|
||||
// 0E => 1.0 0.498 0.498 0.498 grey (v3+)
|
||||
// 0F => 1.0 0.996 0.996 0.832 cream (v3+)
|
||||
// 10 => 1.0 0.996 0.498 0.784 pink (v3+)
|
||||
// 11 => 1.0 0.0 0.498 0.322 dark-green (v3+)
|
||||
// If a mag's color index is invalid (>= 0x12), it is reassigned at equip time using the following logic:
|
||||
// - Set base_index to player->visual.skin if player is an android, or player->visual.costume otherwise
|
||||
// - If (base_index % 9) < 7 (that is, if their costume or body color is one of the colored slots on the character
|
||||
// creation screen), then set the mag color to either (base_index % 9) or (base_index % 9) + 9, with equal
|
||||
// probability.
|
||||
// - If (base_index % 9) >= 7 (that is, if their costume or body color is one of the last two blank-colored slots
|
||||
// on the character creation screen), then set the mag color to any of the available colors, chosen at random.
|
||||
F32T<BE> alpha;
|
||||
F32T<BE> red;
|
||||
F32T<BE> green;
|
||||
F32T<BE> blue;
|
||||
ColorEntry(const VectorXYZTF& c) : alpha(c.t), red(c.x), green(c.y), blue(c.z) {}
|
||||
operator VectorXYZTF() const {
|
||||
return VectorXYZTF{this->red.load(), this->green.load(), this->blue.load(), this->alpha.load()};
|
||||
}
|
||||
} __packed_ws_be__(ColorEntry, 0x10);
|
||||
|
||||
template <bool BE>
|
||||
struct UnknownA3Entry {
|
||||
struct UnknownA3EntryT {
|
||||
uint8_t flags;
|
||||
uint8_t unknown_a2;
|
||||
U16T<BE> unknown_a3;
|
||||
U16T<BE> unknown_a4;
|
||||
U16T<BE> unknown_a5;
|
||||
} __packed_ws_be__(UnknownA3Entry, 0x08);
|
||||
UnknownA3EntryT(const MagEvolutionTable::UnknownA3Entry& e)
|
||||
: flags(e.flags),
|
||||
unknown_a2(e.unknown_a2),
|
||||
unknown_a3(e.unknown_a3),
|
||||
unknown_a4(e.unknown_a4),
|
||||
unknown_a5(e.unknown_a5) {}
|
||||
operator MagEvolutionTable::UnknownA3Entry() const {
|
||||
return MagEvolutionTable::UnknownA3Entry{
|
||||
this->flags, this->unknown_a2, this->unknown_a3, this->unknown_a4, this->unknown_a5};
|
||||
}
|
||||
} __packed_ws_be__(UnknownA3EntryT, 0x08);
|
||||
|
||||
struct HeaderV1 {
|
||||
parray<uint8_t, 4> unknown_a1 = {0x0F, 0xF0, 0x00, 0x00};
|
||||
le_uint32_t unknown_a2 = 0x00000003;
|
||||
le_uint16_t unknown_a3 = 0x00C8;
|
||||
le_uint16_t unknown_a4 = 0x0078;
|
||||
// unknown_a5 added in V2
|
||||
le_float unknown_a6 = 0.25;
|
||||
le_float unknown_a7 = 0.1;
|
||||
le_uint32_t unknown_a8 = 0x00000C00;
|
||||
} __packed_ws__(HeaderV1, 0x18);
|
||||
|
||||
template <bool BE>
|
||||
struct RootV2V3V4 {
|
||||
/* -- / 112K / V1 / V2 / V3 / BB */
|
||||
/* 00 / 0438 / 0438 / 05BC / 0340 / 0400 */ U32T<BE> motion_tables; // -> MotionReferenceTables
|
||||
/* 04 / 0440 / 0440 / 0594 / 0348 / 0408 */ U32T<BE> unknown_a2; // -> (uint8_t[2])[NumMags] (references into unknown_a3)
|
||||
/* 08 / 0498 / 0498 / 0608 / 03CE / 04AE */ U32T<BE> unknown_a3; // -> UnknownA3Entry[max(unknown_a2) + 1]
|
||||
/* 0C / 0510 / 0520 / 06B0 / 0476 / 0556 */ U32T<BE> unknown_a4; // -> uint8_t[NumMags]
|
||||
/* 10 / 053C / 054C / 06EC / 04BC / 05AC */ U32T<BE> color_table; // -> ColorEntry[NumColors]
|
||||
/* 14 / / / 077C / 05DC / 06CC */ U32T<BE> evolution_number_table; // -> uint8_t[NumMags]
|
||||
} __packed_ws_be__(RootV2V3V4, 0x18);
|
||||
struct HeaderV2V3V4 {
|
||||
parray<uint8_t, 4> unknown_a1 = {0x0F, 0xF0, 0x00, 0x00};
|
||||
U32T<BE> unknown_a2 = 0x00000003;
|
||||
U16T<BE> unknown_a3 = 0x00C8;
|
||||
U16T<BE> unknown_a4 = 0x0078;
|
||||
parray<uint8_t, 4> unknown_a5 = {0xC8, 0x00, 0x00, 0x00};
|
||||
F32T<BE> unknown_a6 = 0.25;
|
||||
F32T<BE> unknown_a7 = 0.1;
|
||||
U32T<BE> unknown_a8 = 0x00000C00;
|
||||
} __packed_ws_be__(HeaderV2V3V4, 0x1C);
|
||||
|
||||
// Fields:
|
||||
// 112K / V1 / V2 / V3 / BB R
|
||||
// 0018 / 0018 / 001C / 001C / 001C motion_tables.ref_table // -> MotionReference[NumMags]
|
||||
// 0228 / 0228 / 02D4 / 001C / 001C motion_tables.unused_ref_table // -> MotionReference[NumMags]
|
||||
// 0438 / 0438 / 05BC / 0340 / 0400 * motion_tables; // -> MotionReferenceTables
|
||||
// 0440 / 0440 / 0594 / 0348 / 0408 * unknown_a2; // -> (uint8_t[2])[NumMags] (references into unknown_a3)
|
||||
// 0498 / 0498 / 0608 / 03CE / 04AE * unknown_a3; // -> UnknownA3Entry[max(unknown_a2) + 1]
|
||||
// 0510 / 0520 / 06B0 / 0476 / 0556 * unknown_a4; // -> uint8_t[NumMags]
|
||||
// 053C / 054C / 06EC / 04BC / 05AC * color_table; // -> ColorEntry[NumColors]
|
||||
// ---- / ---- / 077C / 05DC / 06CC * evolution_number_table; // -> uint8_t[NumMags]
|
||||
|
||||
template <bool BE>
|
||||
struct RootV1 {
|
||||
le_uint32_t motion_tables;
|
||||
le_uint32_t unknown_a2;
|
||||
le_uint32_t unknown_a3;
|
||||
le_uint32_t unknown_a4;
|
||||
le_uint32_t color_table;
|
||||
} __packed_ws__(RootV1, 0x14);
|
||||
U32T<BE> motion_tables;
|
||||
U32T<BE> unknown_a2;
|
||||
U32T<BE> unknown_a3;
|
||||
U32T<BE> unknown_a4;
|
||||
U32T<BE> color_table;
|
||||
} __packed_ws_be__(RootV1, 0x14);
|
||||
|
||||
template <bool BE>
|
||||
struct RootV2V3V4 : RootV1<BE> {
|
||||
U32T<BE> evolution_number_table;
|
||||
} __packed_ws_be__(RootV2V3V4, 0x18);
|
||||
|
||||
static uint8_t get_v1_mag_evolution_number(uint8_t data1_1) {
|
||||
static const std::array<uint8_t, 0x2C> v1_evolution_number_table{
|
||||
@@ -90,22 +130,81 @@ static uint8_t get_v1_mag_evolution_number(uint8_t data1_1) {
|
||||
return v1_evolution_number_table[data1_1];
|
||||
}
|
||||
|
||||
template <typename RootT, size_t NumMags, size_t NumColors, bool BE>
|
||||
class MagEvolutionTableT : public MagEvolutionTable {
|
||||
template <typename HeaderT, typename RootT, size_t NumMags, size_t NumColors, bool BE>
|
||||
class BinaryMagEvolutionTableT : public MagEvolutionTable {
|
||||
public:
|
||||
explicit MagEvolutionTableT(std::shared_ptr<const std::string> data)
|
||||
explicit BinaryMagEvolutionTableT(std::shared_ptr<const std::string> data)
|
||||
: data(data), r(*data), root(&r.pget<RootT>(this->r.pget_u32l(this->data->size() - 0x10))) {}
|
||||
virtual ~MagEvolutionTableT() = default;
|
||||
virtual ~BinaryMagEvolutionTableT() = default;
|
||||
|
||||
virtual VectorXYZTF get_color_rgba(size_t index) const {
|
||||
template <typename RawT, typename ParsedT>
|
||||
const ParsedT& add_to_vector_cache(std::vector<ParsedT>& cache, size_t base_offset, size_t index) const {
|
||||
while (cache.size() <= index) {
|
||||
cache.emplace_back(this->r.pget<RawT>(base_offset + sizeof(RawT) * cache.size()));
|
||||
}
|
||||
return cache[index];
|
||||
}
|
||||
|
||||
virtual size_t num_mags() const {
|
||||
return NumMags;
|
||||
}
|
||||
|
||||
virtual size_t num_motion_entries(bool use_second_table) const {
|
||||
const auto& tables = this->r.pget<MotionReferenceTables<BE>>(this->root->motion_tables);
|
||||
return get_rel_array_count<MotionReference>(
|
||||
this->all_start_offsets(), use_second_table ? tables.unused_ref_table : tables.ref_table);
|
||||
}
|
||||
|
||||
virtual const MotionReference& get_motion_reference(bool use_second_table, size_t index) const {
|
||||
if (index >= this->num_motion_entries(use_second_table)) {
|
||||
throw std::logic_error("Invalid motion reference index");
|
||||
}
|
||||
const auto& tables = this->r.pget<MotionReferenceTables<BE>>(this->root->motion_tables);
|
||||
uint32_t array_offset = use_second_table ? tables.unused_ref_table : tables.ref_table;
|
||||
return this->r.pget<MotionReference>(array_offset + sizeof(MotionReference) * index);
|
||||
}
|
||||
|
||||
virtual std::pair<uint8_t, uint8_t> get_unknown_a2(size_t index) const {
|
||||
if (index >= this->num_mags()) {
|
||||
throw std::logic_error("Invalid unknown_a2 index");
|
||||
}
|
||||
uint32_t base_offset = this->root->unknown_a2 + (index * 2);
|
||||
return std::make_pair(this->r.pget_u8(base_offset), this->r.pget_u8(base_offset + 1));
|
||||
}
|
||||
|
||||
virtual size_t num_unknown_a3_entries() const {
|
||||
return get_rel_array_count<UnknownA3EntryT<BE>>(this->all_start_offsets(), this->root->unknown_a3);
|
||||
}
|
||||
|
||||
virtual const UnknownA3Entry& get_unknown_a3(size_t index) const {
|
||||
if (index >= this->num_unknown_a3_entries()) {
|
||||
throw std::logic_error("Invalid unknown_a2 index");
|
||||
}
|
||||
return this->add_to_vector_cache<UnknownA3EntryT<BE>>(this->unknown_a3_entries, this->root->unknown_a3, index);
|
||||
}
|
||||
|
||||
virtual uint8_t get_unknown_a4(size_t index) const {
|
||||
if (index >= this->num_mags()) {
|
||||
throw std::logic_error("Invalid unknown_a4 index");
|
||||
}
|
||||
return this->r.pget_u8(this->root->unknown_a2 + index);
|
||||
}
|
||||
|
||||
virtual size_t num_colors() const {
|
||||
return NumColors;
|
||||
}
|
||||
|
||||
virtual const VectorXYZTF& get_color_rgba(size_t index) const {
|
||||
if (index >= NumColors) {
|
||||
throw runtime_error("invalid mag color index");
|
||||
}
|
||||
const auto& color = this->r.pget<ColorEntry<BE>>(this->root->color_table + sizeof(ColorEntry<BE>) * index);
|
||||
return {color.red.load(), color.green.load(), color.blue.load(), color.alpha.load()};
|
||||
return this->add_to_vector_cache<ColorEntry<BE>>(this->colors, this->root->color_table, index);
|
||||
}
|
||||
|
||||
virtual uint8_t get_evolution_number(uint8_t data1_1) const {
|
||||
if (data1_1 >= this->num_mags()) {
|
||||
throw std::logic_error("Invalid unknown_a4 index");
|
||||
}
|
||||
if constexpr (requires { this->root->evolution_number_table; }) {
|
||||
return this->r.pget_u8(this->root->evolution_number_table + data1_1);
|
||||
} else {
|
||||
@@ -113,10 +212,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<uint32_t>& all_start_offsets() const {
|
||||
if (this->start_offsets.empty()) {
|
||||
this->start_offsets = all_relocation_offsets_for_rel_file<BE>(r.pgetv(0, r.size()), r.size());
|
||||
}
|
||||
return this->start_offsets;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<const std::string> data;
|
||||
phosg::StringReader r;
|
||||
const RootT* root;
|
||||
mutable std::set<uint32_t> start_offsets;
|
||||
mutable std::vector<UnknownA3Entry> unknown_a3_entries;
|
||||
mutable std::vector<VectorXYZTF> colors;
|
||||
};
|
||||
|
||||
class MagEvolutionTableDCNTE : public MagEvolutionTable {
|
||||
@@ -124,8 +233,37 @@ public:
|
||||
MagEvolutionTableDCNTE() = default;
|
||||
virtual ~MagEvolutionTableDCNTE() = default;
|
||||
|
||||
virtual VectorXYZTF get_color_rgba(size_t) const {
|
||||
throw runtime_error("mag colors not available on DC NTE");
|
||||
virtual size_t num_mags() const {
|
||||
return 0x2C;
|
||||
}
|
||||
|
||||
virtual size_t num_motion_entries(bool) const {
|
||||
return 0;
|
||||
}
|
||||
virtual const MotionReference& get_motion_reference(bool, size_t) const {
|
||||
throw runtime_error("Mag tables not available on DC NTE");
|
||||
}
|
||||
|
||||
virtual std::pair<uint8_t, uint8_t> get_unknown_a2(size_t) const {
|
||||
throw runtime_error("Mag tables not available on DC NTE");
|
||||
}
|
||||
|
||||
virtual size_t num_unknown_a3_entries() const {
|
||||
return 0;
|
||||
}
|
||||
virtual const UnknownA3Entry& get_unknown_a3(size_t) const {
|
||||
throw runtime_error("Mag tables not available on DC NTE");
|
||||
}
|
||||
|
||||
virtual uint8_t get_unknown_a4(size_t) const {
|
||||
throw runtime_error("Mag tables not available on DC NTE");
|
||||
}
|
||||
|
||||
virtual size_t num_colors() const {
|
||||
return 0;
|
||||
}
|
||||
virtual const VectorXYZTF& get_color_rgba(size_t) const {
|
||||
throw runtime_error("Mag tables not available on DC NTE");
|
||||
}
|
||||
|
||||
virtual uint8_t get_evolution_number(uint8_t data1_1) const {
|
||||
@@ -133,13 +271,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
using MagEvolutionTableDC112000 = MagEvolutionTableT<RootV2V3V4<false>, 0x28, 0x09, false>;
|
||||
using MagEvolutionTableV1 = MagEvolutionTableT<RootV2V3V4<false>, 0x28, 0x09, false>;
|
||||
using MagEvolutionTableV2 = MagEvolutionTableT<RootV2V3V4<false>, 0x3A, 0x09, false>;
|
||||
using MagEvolutionTableGCNTE = MagEvolutionTableT<RootV2V3V4<true>, 0x3A, 0x09, true>;
|
||||
using MagEvolutionTableGC = MagEvolutionTableT<RootV2V3V4<true>, 0x43, 0x12, true>;
|
||||
using MagEvolutionTableXB = MagEvolutionTableT<RootV2V3V4<false>, 0x43, 0x12, false>;
|
||||
using MagEvolutionTableV4 = MagEvolutionTableT<RootV2V3V4<false>, 0x53, 0x12, false>;
|
||||
using MagEvolutionTableDC112000 = BinaryMagEvolutionTableT<HeaderV1, RootV1<false>, 0x28, 0x09, false>;
|
||||
using MagEvolutionTableV1 = BinaryMagEvolutionTableT<HeaderV1, RootV1<false>, 0x28, 0x09, false>;
|
||||
using MagEvolutionTableV2 = BinaryMagEvolutionTableT<HeaderV2V3V4<false>, RootV2V3V4<false>, 0x3A, 0x09, false>;
|
||||
using MagEvolutionTableGCNTE = BinaryMagEvolutionTableT<HeaderV2V3V4<true>, RootV2V3V4<true>, 0x3A, 0x09, true>;
|
||||
using MagEvolutionTableGC = BinaryMagEvolutionTableT<HeaderV2V3V4<true>, RootV2V3V4<true>, 0x43, 0x12, true>;
|
||||
using MagEvolutionTableXB = BinaryMagEvolutionTableT<HeaderV2V3V4<false>, RootV2V3V4<false>, 0x43, 0x12, false>;
|
||||
using MagEvolutionTableV4 = BinaryMagEvolutionTableT<HeaderV2V3V4<false>, RootV2V3V4<false>, 0x53, 0x12, false>;
|
||||
|
||||
std::shared_ptr<MagEvolutionTable> MagEvolutionTable::create(
|
||||
std::shared_ptr<const std::string> data, Version version) {
|
||||
|
||||
@@ -14,11 +14,43 @@
|
||||
|
||||
class MagEvolutionTable {
|
||||
public:
|
||||
struct MotionReference {
|
||||
struct Side {
|
||||
// This specifies which entry in ItemMagMotion.dat is used. The file is just a list of 0x64-byte structures.
|
||||
// 0xFF = no TItemMagSub is created
|
||||
uint8_t motion_table_entry = 0xFF;
|
||||
parray<uint8_t, 5> unknown_a1 = 0;
|
||||
} __packed_ws__(Side, 0x06);
|
||||
parray<Side, 2> sides; // [0] = right side, [1] = left side
|
||||
} __packed_ws__(MotionReference, 0x0C);
|
||||
|
||||
struct UnknownA3Entry {
|
||||
uint8_t flags;
|
||||
uint8_t unknown_a2;
|
||||
uint16_t unknown_a3;
|
||||
uint16_t unknown_a4;
|
||||
uint16_t unknown_a5;
|
||||
};
|
||||
|
||||
virtual ~MagEvolutionTable() = default;
|
||||
|
||||
static std::shared_ptr<MagEvolutionTable> create(std::shared_ptr<const std::string> data, Version version);
|
||||
|
||||
virtual VectorXYZTF get_color_rgba(size_t index) const = 0;
|
||||
virtual size_t num_mags() const = 0;
|
||||
|
||||
virtual size_t num_motion_entries(bool use_second_table) const = 0;
|
||||
virtual const MotionReference& get_motion_reference(bool use_second_table, size_t index) const = 0;
|
||||
|
||||
virtual std::pair<uint8_t, uint8_t> get_unknown_a2(size_t index) const = 0;
|
||||
|
||||
virtual size_t num_unknown_a3_entries() const = 0;
|
||||
virtual const UnknownA3Entry& get_unknown_a3(size_t index) const = 0;
|
||||
|
||||
virtual uint8_t get_unknown_a4(size_t index) const = 0;
|
||||
|
||||
virtual size_t num_colors() const = 0;
|
||||
virtual const VectorXYZTF& get_color_rgba(size_t index) const = 0;
|
||||
|
||||
virtual uint8_t get_evolution_number(uint8_t data1_1) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
+136
-42
@@ -23,9 +23,11 @@
|
||||
|
||||
#include "AddressTranslator.hh"
|
||||
#include "BMLArchive.hh"
|
||||
#include "CommonFileFormats.hh"
|
||||
#include "Compression.hh"
|
||||
#include "DCSerialNumbers.hh"
|
||||
#include "DNSServer.hh"
|
||||
#include "DOLFileIndex.hh"
|
||||
#include "DownloadSession.hh"
|
||||
#include "GSLArchive.hh"
|
||||
#include "GameServer.hh"
|
||||
@@ -1750,18 +1752,22 @@ Action a_assemble_quest_script(
|
||||
write_output_data(args, result_data.data(), result_data.size(), compress ? "bin" : "bind");
|
||||
});
|
||||
|
||||
Action a_assemble_all_patches(
|
||||
"assemble-all-patches", "\
|
||||
assemble-all-patches [--skip-encrypted]\n\
|
||||
Action a_assemble_all_client_functions(
|
||||
"assemble-all-client-functions", "\
|
||||
assemble-all-client-functions [--skip-encrypted] OUTPUT-DIRECTORY\n\
|
||||
Assemble all patches in the system/client-functions directory, and produce\n\
|
||||
two compiled .bin files for each patch (one unencrypted, for most PSO\n\
|
||||
two compiled .bin files for each patch: one unencrypted, for most PSO\n\
|
||||
versions, and one encrypted, for PSO GC JP v1.4, JP Ep3, and Ep3 Trial\n\
|
||||
Edition). The output files are saved in system/client-functions.\n",
|
||||
Edition. If --skip-encrypted is given, only the unencrypted .bin files are\n\
|
||||
created.\n",
|
||||
+[](phosg::Arguments& args) {
|
||||
auto fci = make_shared<FunctionCodeIndex>("system/client-functions", false);
|
||||
auto fci = make_shared<ClientFunctionIndex>("system/client-functions", false);
|
||||
|
||||
const std::string& output_dir = args.get<string>(1);
|
||||
std::filesystem::create_directories(output_dir);
|
||||
|
||||
bool skip_encrypted = args.get<bool>("skip-encrypted");
|
||||
auto process_code = [&](shared_ptr<const CompiledFunctionCode> code,
|
||||
auto process_code = [&](shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
uint32_t checksum_addr,
|
||||
uint32_t checksum_size,
|
||||
uint32_t override_start_addr) -> void {
|
||||
@@ -1774,34 +1780,18 @@ Action a_assemble_all_patches(
|
||||
code, {}, nullptr, 0, checksum_addr, checksum_size, override_start_addr, encrypted);
|
||||
w.put(PSOCommandHeaderDCV3{.command = 0xB2, .flag = 0x00, .size = data.size() + 4});
|
||||
w.write(data);
|
||||
string out_path = std::format("{}.{}.{}.bin",
|
||||
code->source_path, str_for_specific_version(code->specific_version), (encrypted ? "enc" : "std"));
|
||||
string out_path = std::format("{}/{}.{}.{}.bin",
|
||||
output_dir, code->short_name, str_for_specific_version(code->specific_version), (encrypted ? "enc" : "std"));
|
||||
phosg::save_file(out_path, w.str());
|
||||
phosg::fwrite_fmt(stderr, "... {}\n", out_path);
|
||||
}
|
||||
};
|
||||
|
||||
for (const auto& it : fci->name_and_specific_version_to_patch_function) {
|
||||
process_code(it.second, 0, 0, 0);
|
||||
for (const auto& [_, fn] : fci->all_functions) {
|
||||
process_code(fn, 0, 0, 0);
|
||||
}
|
||||
try {
|
||||
process_code(fci->name_to_function.at("VersionDetectDC"), 0, 0, 0);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
process_code(fci->name_to_function.at("VersionDetectGC"), 0, 0, 0);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
process_code(fci->name_to_function.at("VersionDetectXB"), 0, 0, 0);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
process_code(fci->name_to_function.at("CacheClearFix-Phase1"), 0x80000000, 8, 0x7F2734EC);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
process_code(fci->name_to_function.at("CacheClearFix-Phase2"), 0, 0, 0);
|
||||
process_code(fci->get("CacheClearFix-Phase1", SPECIFIC_VERSION_PPC_INDETERMINATE), 0x80000000, 8, 0x7F2734EC);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
});
|
||||
@@ -2428,6 +2418,93 @@ Action a_encode_item_parameter_table(
|
||||
write_output_data(args, data.data(), data.size(), nullptr);
|
||||
});
|
||||
|
||||
Action a_decode_level_table(
|
||||
"decode-level-table", nullptr,
|
||||
+[](phosg::Arguments& args) {
|
||||
auto input_data = read_input_data(args);
|
||||
std::shared_ptr<LevelTable> table;
|
||||
bool decompressed = args.get<bool>("decompressed");
|
||||
switch (get_cli_version(args)) {
|
||||
case Version::PC_V2:
|
||||
table = std::make_shared<LevelTableV2>(decompressed ? input_data : prs_decompress(input_data));
|
||||
break;
|
||||
case Version::GC_V3:
|
||||
table = std::make_shared<LevelTableGC>(
|
||||
decompressed ? input_data : decrypt_and_decompress_pr2_data<true>(input_data));
|
||||
break;
|
||||
case Version::XB_V3:
|
||||
table = std::make_shared<LevelTableXB>(
|
||||
decompressed ? input_data : decrypt_and_decompress_pr2_data<false>(input_data));
|
||||
break;
|
||||
case Version::BB_V4:
|
||||
table = std::make_shared<LevelTableV4>(decompressed ? input_data : prs_decompress(input_data));
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("This version does not have a level table");
|
||||
}
|
||||
auto json = table->json();
|
||||
uint32_t serialize_options = phosg::JSON::SerializeOption::FORMAT | phosg::JSON::SerializeOption::SORT_DICT_KEYS;
|
||||
if (args.get<bool>("hex")) {
|
||||
serialize_options |= phosg::JSON::SerializeOption::HEX_INTEGERS;
|
||||
}
|
||||
string json_data = json.serialize(serialize_options);
|
||||
write_output_data(args, json_data.data(), json_data.size(), nullptr);
|
||||
});
|
||||
|
||||
Action a_encode_level_table(
|
||||
"encode-level-table-v4", nullptr,
|
||||
+[](phosg::Arguments& args) {
|
||||
JSONLevelTable table(phosg::JSON::parse(read_input_data(args)));
|
||||
string data = table.serialize_binary_v4();
|
||||
if (!args.get<bool>("decompressed")) {
|
||||
data = prs_compress_optimal(data);
|
||||
}
|
||||
write_output_data(args, data.data(), data.size(), nullptr);
|
||||
});
|
||||
|
||||
Action a_decode_battle_params(
|
||||
"decode-battle-params", nullptr,
|
||||
+[](phosg::Arguments& args) {
|
||||
auto data_on_ep1 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(1)));
|
||||
auto data_on_ep2 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(2)));
|
||||
auto data_on_ep4 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(3)));
|
||||
auto data_off_ep1 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(4)));
|
||||
auto data_off_ep2 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(5)));
|
||||
auto data_off_ep4 = std::make_shared<std::string>(phosg::load_file(args.get<std::string>(6)));
|
||||
BinaryBattleParamsIndex index(data_on_ep1, data_on_ep2, data_on_ep4, data_off_ep1, data_off_ep2, data_off_ep4);
|
||||
auto json = index.json();
|
||||
uint32_t serialize_options = phosg::JSON::SerializeOption::FORMAT | phosg::JSON::SerializeOption::SORT_DICT_KEYS;
|
||||
if (args.get<bool>("hex")) {
|
||||
serialize_options |= phosg::JSON::SerializeOption::HEX_INTEGERS;
|
||||
}
|
||||
phosg::save_file(args.get<std::string>(7), json.serialize(serialize_options));
|
||||
});
|
||||
|
||||
Action a_encode_battle_params(
|
||||
"encode-battle-params", nullptr,
|
||||
+[](phosg::Arguments& args) {
|
||||
JSONBattleParamsIndex index(phosg::JSON::parse(read_input_data(args)));
|
||||
std::string pfx = args.get<string>(2);
|
||||
phosg::save_file(pfx + "_on.dat", &index.get_table(false, Episode::EP1), sizeof(BattleParamsIndex::Table));
|
||||
phosg::save_file(pfx + "_lab_on.dat", &index.get_table(false, Episode::EP2), sizeof(BattleParamsIndex::Table));
|
||||
phosg::save_file(pfx + "_ep4_on.dat", &index.get_table(false, Episode::EP4), sizeof(BattleParamsIndex::Table));
|
||||
phosg::save_file(pfx + ".dat", &index.get_table(true, Episode::EP1), sizeof(BattleParamsIndex::Table));
|
||||
phosg::save_file(pfx + "_lab.dat", &index.get_table(true, Episode::EP2), sizeof(BattleParamsIndex::Table));
|
||||
phosg::save_file(pfx + "_ep4.dat", &index.get_table(true, Episode::EP4), sizeof(BattleParamsIndex::Table));
|
||||
});
|
||||
|
||||
Action a_find_rel_section(
|
||||
"find-rel-sections", nullptr,
|
||||
+[](phosg::Arguments& args) {
|
||||
auto data = read_input_data(args);
|
||||
auto offsets = args.get<bool>("big-endian")
|
||||
? all_relocation_offsets_for_rel_file<true>(data.data(), data.size())
|
||||
: all_relocation_offsets_for_rel_file<false>(data.data(), data.size());
|
||||
for (uint32_t offset : offsets) {
|
||||
phosg::fwrite_fmt(stdout, "{:08X}\n", offset);
|
||||
}
|
||||
});
|
||||
|
||||
Action a_describe_item(
|
||||
"describe-item", "\
|
||||
describe-item DATA-OR-DESCRIPTION\n\
|
||||
@@ -2603,7 +2680,6 @@ Action a_print_level_stats(
|
||||
|
||||
vector<PlayerStats> level_1_v1_v2;
|
||||
vector<PlayerStats> level_100_v1_v2;
|
||||
vector<PlayerStats> level_100_limit_v1_v2;
|
||||
vector<PlayerStats> level_200_v1_v2;
|
||||
vector<PlayerStats> level_200_limit_v1_v2;
|
||||
vector<PlayerStats> level_1_v3;
|
||||
@@ -2615,7 +2691,6 @@ Action a_print_level_stats(
|
||||
for (size_t z = 0; z < 12; z++) {
|
||||
if (z < 9) {
|
||||
level_1_v1_v2.emplace_back().char_stats = s->level_table_v1_v2->base_stats_for_class(z);
|
||||
level_100_limit_v1_v2.emplace_back(s->level_table_v1_v2->level_100_stats_for_class(z));
|
||||
level_200_limit_v1_v2.emplace_back(s->level_table_v1_v2->max_stats_for_class(z));
|
||||
s->level_table_v1_v2->advance_to_level(level_100_v1_v2.emplace_back(level_1_v1_v2.back()), 99, z);
|
||||
s->level_table_v1_v2->advance_to_level(level_200_v1_v2.emplace_back(level_1_v1_v2.back()), 199, z);
|
||||
@@ -2669,7 +2744,6 @@ Action a_print_level_stats(
|
||||
|
||||
print_stats_set(level_1_v1_v2, "v1/v2 Lv.1 ");
|
||||
print_stats_set(level_100_v1_v2, "v1/v2 Lv.100");
|
||||
print_stats_set(level_100_limit_v1_v2, "v1 limit ");
|
||||
print_stats_set(level_200_v1_v2, "v2 Lv.200 ");
|
||||
print_stats_set(level_200_limit_v1_v2, "v2 limit ");
|
||||
print_stats_set(level_1_v3, "v3 Lv.1 ");
|
||||
@@ -3600,7 +3674,7 @@ Action a_check_client_functions(
|
||||
"check-client-functions", nullptr,
|
||||
+[](phosg::Arguments&) {
|
||||
set_all_log_levels(phosg::LogLevel::L_DEBUG);
|
||||
FunctionCodeIndex fci("system/client-functions", true);
|
||||
ClientFunctionIndex index("system/client-functions", true);
|
||||
phosg::fwrite_fmt(stdout, "All client functions compiled\n");
|
||||
});
|
||||
|
||||
@@ -3967,7 +4041,7 @@ Action a_run_server_replay_log(
|
||||
std::filesystem::create_directories("system/players");
|
||||
}
|
||||
|
||||
const string& replay_log_filename = args.get<string>("replay-log");
|
||||
const auto& replay_log_filenames = args.get_multi<string>("replay-log");
|
||||
|
||||
#ifndef PHOSG_WINDOWS
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@@ -3976,7 +4050,7 @@ Action a_run_server_replay_log(
|
||||
use_terminal_colors = true;
|
||||
}
|
||||
|
||||
auto state = make_shared<ServerState>(get_config_filename(args), !replay_log_filename.empty());
|
||||
auto state = make_shared<ServerState>(get_config_filename(args), !replay_log_filenames.empty());
|
||||
if (args.get<bool>("debug")) {
|
||||
state->is_debug = true;
|
||||
}
|
||||
@@ -3995,19 +4069,39 @@ Action a_run_server_replay_log(
|
||||
}
|
||||
|
||||
shared_ptr<ServerShell> shell;
|
||||
shared_ptr<ReplaySession> replay_session;
|
||||
shared_ptr<SignalWatcher> signal_watcher;
|
||||
if (!replay_log_filename.empty()) {
|
||||
shared_ptr<ReplaySession> last_running_replay;
|
||||
if (!replay_log_filenames.empty()) {
|
||||
config_log.info_f("Starting game server");
|
||||
state->game_server = make_shared<GameServer>(state);
|
||||
|
||||
// TODO: Do this properly via a config option, you lazy bum
|
||||
state->dol_file_index = make_shared<DOLFileIndex>();
|
||||
|
||||
auto log_f = phosg::fopen_shared(replay_log_filename, "rt");
|
||||
|
||||
replay_session = make_shared<ReplaySession>(state, log_f.get(), false);
|
||||
asio::co_spawn(*state->io_context, replay_session->run(), asio::detached);
|
||||
auto run_replays = [&]() -> asio::awaitable<void> {
|
||||
try {
|
||||
for (const auto& log_filename : replay_log_filenames) {
|
||||
phosg::log_info_f("[Replay] {} ...", log_filename);
|
||||
auto log_f = phosg::fopen_shared(log_filename, "rt");
|
||||
last_running_replay = make_shared<ReplaySession>(state, log_f.get());
|
||||
co_await last_running_replay->run();
|
||||
if (last_running_replay->failed()) {
|
||||
phosg::log_error_f("[Replay] {} failed", log_filename);
|
||||
break;
|
||||
}
|
||||
phosg::log_info_f("[Replay] {} OK", log_filename);
|
||||
state->reset_between_replays();
|
||||
}
|
||||
phosg::log_info_f("[Replay] All replays complete");
|
||||
} catch (const std::exception& e) {
|
||||
phosg::log_info_f("[Replay] Replays failed: {}", e.what());
|
||||
}
|
||||
if (!last_running_replay->failed()) {
|
||||
last_running_replay.reset();
|
||||
}
|
||||
state->io_context->stop();
|
||||
};
|
||||
asio::co_spawn(*state->io_context, run_replays, asio::detached);
|
||||
|
||||
} else {
|
||||
config_log.info_f("Opening sockets");
|
||||
@@ -4100,7 +4194,7 @@ Action a_run_server_replay_log(
|
||||
should_run_shell = false;
|
||||
}
|
||||
if (should_run_shell) {
|
||||
should_run_shell = !replay_session.get();
|
||||
should_run_shell = replay_log_filenames.empty();
|
||||
}
|
||||
|
||||
config_log.info_f("Ready");
|
||||
@@ -4111,7 +4205,7 @@ Action a_run_server_replay_log(
|
||||
state->io_context->run();
|
||||
config_log.info_f("Normal shutdown");
|
||||
|
||||
if (replay_session && replay_session->failed()) {
|
||||
if (last_running_replay) {
|
||||
throw runtime_error("Replay failed");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -334,7 +334,7 @@ using PlayerDispDataDCPCV3 = PlayerDispDataDCPCV3T<false>;
|
||||
using PlayerDispDataDCPCV3BE = PlayerDispDataDCPCV3T<true>;
|
||||
|
||||
struct PlayerDispDataBBPreview {
|
||||
/* 00 */ le_uint32_t experience = 0;
|
||||
/* 00 */ le_uint32_t exp = 0;
|
||||
/* 04 */ le_uint32_t level = 0;
|
||||
// The name field in this structure is used for the player's Guild Card number, apparently (possibly because it's a
|
||||
// char array and this is BB)
|
||||
|
||||
@@ -75,19 +75,16 @@ static asio::awaitable<HandlerResult> C_1D(shared_ptr<Client> c, Channel::Messag
|
||||
double ping_ms = static_cast<double>(ping_usecs) / 1000.0;
|
||||
send_text_message_fmt(c->channel, "To proxy: {:g}ms", ping_ms);
|
||||
co_return HandlerResult::SUPPRESS;
|
||||
}
|
||||
|
||||
if (c->proxy_session->is_in_game) {
|
||||
c->log.info_f("Forwarding in-game command 1D through proxy");
|
||||
} else {
|
||||
if (c->proxy_session->is_in_game) {
|
||||
c->log.info_f("Forwarding in-game command 1D through proxy");
|
||||
}
|
||||
co_return HandlerResult::FORWARD;
|
||||
}
|
||||
|
||||
co_return HandlerResult::SUPPRESS;
|
||||
}
|
||||
|
||||
static asio::awaitable<HandlerResult> S_1D(shared_ptr<Client> c, Channel::Message&) {
|
||||
c->proxy_session->server_channel->send(0x1D);
|
||||
co_return HandlerResult::SUPPRESS;
|
||||
static asio::awaitable<HandlerResult> S_1D(shared_ptr<Client>, Channel::Message&) {
|
||||
co_return HandlerResult::FORWARD;
|
||||
}
|
||||
|
||||
static asio::awaitable<HandlerResult> S_97(shared_ptr<Client> c, Channel::Message&) {
|
||||
|
||||
+617
-623
File diff suppressed because it is too large
Load Diff
+16
-16
@@ -342,7 +342,7 @@ static void send_main_menu(shared_ptr<Client> c) {
|
||||
|
||||
main_menu->items.emplace_back(MainMenuItemID::DOWNLOAD_QUESTS, "Download quests",
|
||||
"Download quests", MenuItem::Flag::INVISIBLE_ON_DC_PROTOS | MenuItem::Flag::INVISIBLE_ON_PC_NTE | MenuItem::Flag::INVISIBLE_ON_BB);
|
||||
if (!s->function_code_index->patch_menu_empty(c->specific_version)) {
|
||||
if (!s->client_functions->patch_menu_empty(c->specific_version)) {
|
||||
main_menu->items.emplace_back(MainMenuItemID::PATCH_SWITCHES, "Patches",
|
||||
"Change game\nbehaviors", MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
}
|
||||
@@ -450,14 +450,14 @@ static asio::awaitable<void> send_auto_patches_if_needed(shared_ptr<Client> c) {
|
||||
c->set_flag(Client::Flag::HAS_AUTO_PATCHES);
|
||||
co_await prepare_client_for_patches(c);
|
||||
|
||||
unordered_set<shared_ptr<const CompiledFunctionCode>> functions_to_send;
|
||||
unordered_set<shared_ptr<const ClientFunctionIndex::Function>> functions_to_send;
|
||||
if (c->version() == Version::BB_V4) {
|
||||
for (const auto& patch_name : s->bb_required_patches) {
|
||||
try {
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
functions_to_send.emplace(s->client_functions->get(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
string message = std::format(
|
||||
"Your client is not compatible with a\nrequired patch on this server.\n\nClient version: {:08X}\nPatch name: {}", c->specific_version, patch_name);
|
||||
"Your client is not compatible with a\nrequired patch on this server.\n\nClient version: {}\nPatch name: {}", str_for_specific_version(c->specific_version), patch_name);
|
||||
send_message_box(c, message);
|
||||
c->channel->disconnect();
|
||||
co_return;
|
||||
@@ -466,18 +466,18 @@ static asio::awaitable<void> send_auto_patches_if_needed(shared_ptr<Client> c) {
|
||||
}
|
||||
for (const auto& patch_name : s->auto_patches) {
|
||||
try {
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
functions_to_send.emplace(s->client_functions->get(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
c->log.warning_f("Server has auto patch {} enabled, but it is not available for specific_version {:08X}",
|
||||
patch_name, c->specific_version);
|
||||
c->log.warning_f("Server has auto patch {} enabled, but it is not available for specific_version {}",
|
||||
patch_name, str_for_specific_version(c->specific_version));
|
||||
}
|
||||
}
|
||||
for (const auto& patch_name : c->login->account->auto_patches_enabled) {
|
||||
try {
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
functions_to_send.emplace(s->client_functions->get(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
c->log.warning_f("Client has auto patch {} enabled, but it is not available for specific_version {:08X}",
|
||||
patch_name, c->specific_version);
|
||||
c->log.warning_f("Client has auto patch {} enabled, but it is not available for specific_version {}",
|
||||
patch_name, str_for_specific_version(c->specific_version));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,7 +1535,7 @@ static asio::awaitable<void> on_9D_9E(shared_ptr<Client> c, Channel::Message& ms
|
||||
// not; we'll call on_login_complete once we receive the B3 response
|
||||
if (c->version() == Version::PC_V2) {
|
||||
try {
|
||||
auto code = s->function_code_index->name_to_function.at("ReturnTokenX86");
|
||||
auto code = s->client_functions->get("ReturnToken", SPECIFIC_VERSION_X86_INDETERMINATE);
|
||||
unordered_map<string, uint32_t> label_writes{{"token", c->login->account->account_id}};
|
||||
auto resp = co_await send_function_call(c, code, label_writes, nullptr, 0, 0x00400000, 0x0000E000, 0, true);
|
||||
|
||||
@@ -1558,7 +1558,8 @@ static asio::awaitable<void> on_9D_9E(shared_ptr<Client> c, Channel::Message& ms
|
||||
c->specific_version = SPECIFIC_VERSION_PC_V2_INDETERMINATE;
|
||||
c->log.info_f("Version cannot be determined from PE header checksum {:08X}", resp.checksum);
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
} catch (const out_of_range& e) {
|
||||
c->log.info_f("Cannot determine PSO PC specific version: {}", e.what());
|
||||
}
|
||||
}
|
||||
co_await on_login_complete(c);
|
||||
@@ -2960,7 +2961,7 @@ static asio::awaitable<void> on_10_main_menu(shared_ptr<Client> c, uint32_t item
|
||||
// We have to prepare the client for patches here, even though we don't send them from this mennu, because we
|
||||
// need to know the client's specific_version before sending the menu.
|
||||
co_await prepare_client_for_patches(c);
|
||||
send_menu(c, c->require_server_state()->function_code_index->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
send_menu(c, c->require_server_state()->client_functions->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3337,13 +3338,12 @@ static void on_10_patch_switches(shared_ptr<Client> c, uint32_t item_id) {
|
||||
}
|
||||
|
||||
auto s = c->require_server_state();
|
||||
uint64_t key = (static_cast<uint64_t>(item_id) << 32) | c->specific_version;
|
||||
auto fn = s->function_code_index->menu_item_id_and_specific_version_to_patch_function.at(key);
|
||||
auto fn = s->client_functions->get_by_menu_item_id(item_id);
|
||||
if (!c->login->account->auto_patches_enabled.emplace(fn->short_name).second) {
|
||||
c->login->account->auto_patches_enabled.erase(fn->short_name);
|
||||
}
|
||||
c->login->account->save();
|
||||
send_menu(c, s->function_code_index->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
send_menu(c, s->client_functions->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4234,7 +4234,7 @@ static void add_player_exp(shared_ptr<Client> c, uint32_t exp, uint16_t from_ene
|
||||
auto s = c->require_server_state();
|
||||
auto p = c->character_file();
|
||||
|
||||
p->disp.stats.experience += exp;
|
||||
p->disp.stats.exp += exp;
|
||||
if (c->version() == Version::BB_V4) {
|
||||
send_give_experience(c, exp, from_enemy_id);
|
||||
}
|
||||
@@ -4242,7 +4242,7 @@ static void add_player_exp(shared_ptr<Client> c, uint32_t exp, uint16_t from_ene
|
||||
bool leveled_up = false;
|
||||
do {
|
||||
const auto& level = s->level_table(c->version())->stats_delta_for_level(p->disp.visual.char_class, p->disp.stats.level + 1);
|
||||
if (p->disp.stats.experience >= level.experience) {
|
||||
if (p->disp.stats.exp >= level.exp) {
|
||||
leveled_up = true;
|
||||
level.apply(p->disp.stats.char_stats);
|
||||
p->disp.stats.level++;
|
||||
@@ -4304,7 +4304,7 @@ static uint32_t base_exp_for_enemy_type(
|
||||
const auto& bp_table = bp_index->get_table(is_solo, episode);
|
||||
const auto& bp_stats_indexes = type_definition_for_enemy(enemy_type).bp_stats_indexes;
|
||||
if (!bp_stats_indexes.empty()) {
|
||||
return bp_table.stats_for_index(difficulty, bp_stats_indexes.back()).experience;
|
||||
return bp_table.stats_for_index(difficulty, bp_stats_indexes.back()).exp;
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
@@ -4987,8 +4987,8 @@ static asio::awaitable<void> on_battle_level_up_bb(shared_ptr<Client> c, Subcomm
|
||||
auto s = c->require_server_state();
|
||||
auto lp = lc->character_file();
|
||||
uint32_t target_level = min<uint32_t>(lp->disp.stats.level + cmd.num_levels, 199);
|
||||
uint32_t before_exp = lp->disp.stats.experience;
|
||||
int32_t exp_delta = lp->disp.stats.experience - before_exp;
|
||||
uint32_t before_exp = lp->disp.stats.exp;
|
||||
int32_t exp_delta = lp->disp.stats.exp - before_exp;
|
||||
if (exp_delta > 0) {
|
||||
s->level_table(lc->version())->advance_to_level(lp->disp.stats, target_level, lp->disp.visual.char_class);
|
||||
if (lc->version() == Version::BB_V4) {
|
||||
|
||||
@@ -321,9 +321,8 @@ void ReplaySession::apply_default_mask(shared_ptr<Event> ev) {
|
||||
}
|
||||
}
|
||||
|
||||
ReplaySession::ReplaySession(shared_ptr<ServerState> state, FILE* input_log, bool is_interactive)
|
||||
ReplaySession::ReplaySession(shared_ptr<ServerState> state, FILE* input_log)
|
||||
: state(state),
|
||||
is_interactive(is_interactive),
|
||||
prev_psov2_crypt_enabled(this->state->use_psov2_rand_crypt),
|
||||
commands_sent(0),
|
||||
bytes_sent(0),
|
||||
@@ -669,9 +668,6 @@ asio::awaitable<void> ReplaySession::run() {
|
||||
replay_log.info_f("Replay complete: {} commands sent ({} bytes), {} commands received ({} bytes)",
|
||||
this->commands_sent, this->bytes_sent, this->commands_received, this->bytes_received);
|
||||
}
|
||||
if (!this->is_interactive) {
|
||||
this->state->io_context->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void ReplaySession::reschedule_idle_timeout() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class ReplaySession {
|
||||
public:
|
||||
ReplaySession(std::shared_ptr<ServerState> state, FILE* input_log, bool is_interactive);
|
||||
ReplaySession(std::shared_ptr<ServerState> state, FILE* input_log);
|
||||
ReplaySession(const ReplaySession&) = delete;
|
||||
ReplaySession(ReplaySession&&) = delete;
|
||||
ReplaySession& operator=(const ReplaySession&) = delete;
|
||||
@@ -62,7 +62,6 @@ private:
|
||||
};
|
||||
|
||||
std::shared_ptr<ServerState> state;
|
||||
bool is_interactive;
|
||||
bool prev_psov2_crypt_enabled;
|
||||
|
||||
std::unordered_map<uint64_t, std::shared_ptr<Client>> clients;
|
||||
|
||||
@@ -370,7 +370,7 @@ PSOBBBaseSystemFile::PSOBBBaseSystemFile() {
|
||||
PlayerDispDataBBPreview PSOBBCharacterFile::to_preview() const {
|
||||
PlayerDispDataBBPreview pre;
|
||||
pre.level = this->disp.stats.level;
|
||||
pre.experience = this->disp.stats.experience;
|
||||
pre.exp = this->disp.stats.exp;
|
||||
pre.visual = this->disp.visual;
|
||||
pre.name = this->disp.name;
|
||||
pre.play_time_seconds = this->play_time_seconds;
|
||||
@@ -1429,11 +1429,11 @@ void PSOBBCharacterFile::import_tethealla_material_usage(std::shared_ptr<const L
|
||||
|
||||
void PSOBBCharacterFile::recompute_stats(std::shared_ptr<const LevelTable> level_table, bool reset_exp) {
|
||||
uint32_t level = this->disp.stats.level;
|
||||
uint32_t exp = this->disp.stats.experience;
|
||||
uint32_t exp = this->disp.stats.exp;
|
||||
level_table->reset_to_base(this->disp.stats, this->disp.visual.char_class);
|
||||
level_table->advance_to_level(this->disp.stats, level, this->disp.visual.char_class);
|
||||
if (!reset_exp) {
|
||||
this->disp.stats.experience = exp;
|
||||
this->disp.stats.exp = exp;
|
||||
}
|
||||
|
||||
this->disp.stats.char_stats.atp += (this->get_material_usage(MaterialType::POWER) * 2);
|
||||
|
||||
+18
-18
@@ -336,7 +336,7 @@ asio::awaitable<void> prepare_client_for_patches(shared_ptr<Client> c) {
|
||||
auto s = c->require_server_state();
|
||||
|
||||
if (!c->check_flag(Client::Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH)) {
|
||||
auto fn = s->function_code_index->name_to_function.at("CacheClearFix-Phase1");
|
||||
auto fn = s->client_functions->get("CacheClearFix-Phase1", ClientFunctionIndex::Function::Architecture::POWERPC);
|
||||
unordered_map<string, uint32_t> label_writes;
|
||||
auto call1_res = co_await send_function_call(c, fn, label_writes, nullptr, 0, 0x80000000, 8, 0x7F2734EC);
|
||||
try {
|
||||
@@ -345,29 +345,29 @@ asio::awaitable<void> prepare_client_for_patches(shared_ptr<Client> c) {
|
||||
} catch (const out_of_range&) {
|
||||
c->log.info_f("Could not detect specific version from header checksum {:08X}", call1_res.checksum);
|
||||
}
|
||||
co_await send_function_call(c, s->function_code_index->name_to_function.at("CacheClearFix-Phase2"));
|
||||
co_await send_function_call(c, s->client_functions->get("CacheClearFix-Phase2", ClientFunctionIndex::Function::Architecture::POWERPC));
|
||||
c->log.info_f("Client cache behavior patched");
|
||||
c->set_flag(Client::Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
|
||||
}
|
||||
|
||||
const char* version_detect_name = nullptr;
|
||||
ClientFunctionIndex::Function::Architecture arch = ClientFunctionIndex::Function::Architecture::UNKNOWN;
|
||||
if (c->version() == Version::DC_V2) {
|
||||
version_detect_name = "VersionDetectDC";
|
||||
arch = ClientFunctionIndex::Function::Architecture::SH4;
|
||||
} else if (is_gc(c->version())) {
|
||||
version_detect_name = "VersionDetectGC";
|
||||
arch = ClientFunctionIndex::Function::Architecture::POWERPC;
|
||||
} else if (c->version() == Version::XB_V3) {
|
||||
version_detect_name = "VersionDetectXB";
|
||||
arch = ClientFunctionIndex::Function::Architecture::X86;
|
||||
}
|
||||
if (version_detect_name && specific_version_is_indeterminate(c->specific_version)) {
|
||||
auto vers_detect_res = co_await send_function_call(
|
||||
c, s->function_code_index->name_to_function.at(version_detect_name));
|
||||
if ((arch != ClientFunctionIndex::Function::Architecture::UNKNOWN) &&
|
||||
specific_version_is_indeterminate(c->specific_version)) {
|
||||
auto vers_detect_res = co_await send_function_call(c, s->client_functions->get("VersionDetect", arch));
|
||||
c->specific_version = vers_detect_res.return_value;
|
||||
c->log.info_f("Version detected as {:08X}", c->specific_version);
|
||||
}
|
||||
}
|
||||
|
||||
string prepare_send_function_call_data(
|
||||
shared_ptr<const CompiledFunctionCode> code,
|
||||
shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
@@ -417,7 +417,7 @@ string prepare_send_function_call_data(
|
||||
|
||||
asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
shared_ptr<Client> c,
|
||||
shared_ptr<const CompiledFunctionCode> code,
|
||||
shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
@@ -446,7 +446,7 @@ asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
}
|
||||
|
||||
asio::awaitable<void> send_function_call_multi(
|
||||
shared_ptr<Client> c, unordered_set<shared_ptr<const CompiledFunctionCode>> codes) {
|
||||
shared_ptr<Client> c, unordered_set<shared_ptr<const ClientFunctionIndex::Function>> codes) {
|
||||
if (codes.empty()) {
|
||||
co_return;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ asio::awaitable<void> send_function_call_multi(
|
||||
void send_function_call(
|
||||
shared_ptr<Channel> ch,
|
||||
uint64_t client_enabled_flags,
|
||||
shared_ptr<const CompiledFunctionCode> code,
|
||||
shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const unordered_map<string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
@@ -526,7 +526,7 @@ asio::awaitable<bool> send_protected_command(std::shared_ptr<Client> c, const vo
|
||||
co_await prepare_client_for_patches(c);
|
||||
|
||||
try {
|
||||
auto fn = s->function_code_index->get_patch("CallProtectedHandler", c->specific_version);
|
||||
auto fn = s->client_functions->get("CallProtectedHandler", c->specific_version);
|
||||
unordered_map<string, uint32_t> label_writes{{"size", size}};
|
||||
co_await send_function_call(c, fn, label_writes, data, size);
|
||||
auto l = echo_to_lobby ? c->lobby.lock() : nullptr;
|
||||
@@ -550,7 +550,7 @@ asio::awaitable<void> send_dol_file(shared_ptr<Client> c, shared_ptr<DOLFileInde
|
||||
// Determine the necessary start address for the data
|
||||
unordered_map<string, uint32_t> label_writes{{"address", 0x80000034}}; // ArenaHigh from GC globals
|
||||
auto addr_ret = co_await send_function_call(
|
||||
c, s->function_code_index->name_to_function.at("ReadMemoryWordGC"), label_writes);
|
||||
c, s->client_functions->get("ReadMemoryWord", c->specific_version), label_writes);
|
||||
uint32_t dol_base_addr = (addr_ret.return_value - dol->data.size()) & (~3);
|
||||
|
||||
// Write the file in multiple chunks
|
||||
@@ -562,7 +562,7 @@ asio::awaitable<void> send_dol_file(shared_ptr<Client> c, shared_ptr<DOLFileInde
|
||||
string data_to_send = dol->data.substr(offset, bytes_to_send);
|
||||
|
||||
auto s = c->require_server_state();
|
||||
auto fn = s->function_code_index->name_to_function.at("WriteMemoryGC");
|
||||
auto fn = s->client_functions->get("WriteMemory", c->specific_version);
|
||||
label_writes = {{"dest_addr", (dol_base_addr + offset)}, {"size", bytes_to_send}};
|
||||
co_await send_function_call(c, fn, label_writes, data_to_send.data(), data_to_send.size());
|
||||
|
||||
@@ -573,7 +573,7 @@ asio::awaitable<void> send_dol_file(shared_ptr<Client> c, shared_ptr<DOLFileInde
|
||||
}
|
||||
|
||||
// Send the final function, which moves the DOL's sections into place and calls the entrypoint
|
||||
auto fn = s->function_code_index->name_to_function.at("RunDOL");
|
||||
auto fn = s->client_functions->get("RunDOL", c->specific_version);
|
||||
label_writes = {{"dol_base_ptr", dol_base_addr}};
|
||||
co_await send_function_call(c, fn, label_writes);
|
||||
// The client will stop running PSO after this, so disconnect them
|
||||
@@ -2547,7 +2547,7 @@ asio::awaitable<GetPlayerInfoResult> send_get_player_info(shared_ptr<Client> c,
|
||||
}
|
||||
try {
|
||||
auto s = c->require_server_state();
|
||||
auto fn = s->function_code_index->get_patch("GetExtendedPlayerInfo", c->specific_version);
|
||||
auto fn = s->client_functions->get("GetExtendedPlayerInfo", c->specific_version);
|
||||
send_function_call(c->channel, c->enabled_flags, fn);
|
||||
c->function_call_response_queue.emplace_back(make_shared<AsyncPromise<C_ExecuteCodeResult_B3>>());
|
||||
full_req_sent = true;
|
||||
|
||||
+5
-5
@@ -9,8 +9,8 @@
|
||||
#include <unordered_set>
|
||||
|
||||
#include "Client.hh"
|
||||
#include "ClientFunctionIndex.hh"
|
||||
#include "CommandFormats.hh"
|
||||
#include "FunctionCompiler.hh"
|
||||
#include "Lobby.hh"
|
||||
#include "Menu.hh"
|
||||
#include "Quest.hh"
|
||||
@@ -150,7 +150,7 @@ void send_patch_change_to_directory(
|
||||
|
||||
asio::awaitable<void> prepare_client_for_patches(std::shared_ptr<Client> c);
|
||||
std::string prepare_send_function_call_data(
|
||||
std::shared_ptr<const CompiledFunctionCode> code,
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes,
|
||||
const void* suffix_data,
|
||||
size_t suffix_size,
|
||||
@@ -163,7 +163,7 @@ std::string prepare_send_function_call_data(
|
||||
void send_function_call(
|
||||
std::shared_ptr<Channel> ch,
|
||||
uint64_t client_enabled_flags,
|
||||
std::shared_ptr<const CompiledFunctionCode> code,
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes = {},
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
@@ -173,7 +173,7 @@ void send_function_call(
|
||||
bool ignore_actually_runs_code_flag = false);
|
||||
asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
std::shared_ptr<Client> c,
|
||||
std::shared_ptr<const CompiledFunctionCode> code,
|
||||
std::shared_ptr<const ClientFunctionIndex::Function> code,
|
||||
const std::unordered_map<std::string, uint32_t>& label_writes = {},
|
||||
const void* suffix_data = nullptr,
|
||||
size_t suffix_size = 0,
|
||||
@@ -182,7 +182,7 @@ asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
uint32_t override_relocations_offset = 0,
|
||||
bool ignore_actually_runs_code_flag = false);
|
||||
asio::awaitable<void> send_function_call_multi(
|
||||
std::shared_ptr<Client> c, std::unordered_set<std::shared_ptr<const CompiledFunctionCode>> codes);
|
||||
std::shared_ptr<Client> c, std::unordered_set<std::shared_ptr<const ClientFunctionIndex::Function>> codes);
|
||||
asio::awaitable<bool> send_protected_command(std::shared_ptr<Client> c, const void* data, size_t size, bool echo_to_lobby);
|
||||
asio::awaitable<void> send_dol_file(std::shared_ptr<Client> c, std::shared_ptr<DOLFileIndex::File> dol);
|
||||
|
||||
|
||||
+108
-47
@@ -737,6 +737,23 @@ void ServerState::load_config_early() {
|
||||
}
|
||||
|
||||
this->set_port_configuration(parse_port_configuration(this->config_json->at("PortConfiguration")));
|
||||
|
||||
this->ip_stack_port_remap.clear();
|
||||
try {
|
||||
for (const auto& item : this->config_json->at("IPStackPortRemap").as_dict()) {
|
||||
uint64_t from_port = stoull(item.first, nullptr, 0);
|
||||
uint64_t to_port = item.second->as_int();
|
||||
|
||||
if (from_port > 0xFFFF || to_port > 0xFFFF) {
|
||||
throw runtime_error("IPStackPortRemap port number is out of range");
|
||||
}
|
||||
|
||||
this->ip_stack_port_remap.emplace(
|
||||
static_cast<uint16_t>(from_port),
|
||||
static_cast<uint16_t>(to_port));
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
auto spec = this->parse_port_spec(this->config_json->at("DNSServerPort"));
|
||||
this->dns_server_addr = std::move(spec.first);
|
||||
@@ -1892,21 +1909,30 @@ void ServerState::load_set_data_tables() {
|
||||
}
|
||||
|
||||
void ServerState::load_battle_params() {
|
||||
config_log.info_f("Loading battle parameters");
|
||||
this->battle_params = make_shared<BattleParamsIndex>(
|
||||
this->load_bb_file("BattleParamEntry_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry_lab_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry_ep4_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry.dat"),
|
||||
this->load_bb_file("BattleParamEntry_lab.dat"),
|
||||
this->load_bb_file("BattleParamEntry_ep4.dat"));
|
||||
config_log.info_f("Loading JSON battle parameters");
|
||||
try {
|
||||
this->battle_params = make_shared<JSONBattleParamsIndex>(phosg::JSON::parse(phosg::load_file(
|
||||
"system/tables/battle-params.json")));
|
||||
} catch (const std::exception& e) {
|
||||
config_log.info_f("Cannot load JSON battle parameters ({}); loading binary battle parameters", e.what());
|
||||
this->battle_params = make_shared<BinaryBattleParamsIndex>(
|
||||
this->load_bb_file("BattleParamEntry_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry_lab_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry_ep4_on.dat"),
|
||||
this->load_bb_file("BattleParamEntry.dat"),
|
||||
this->load_bb_file("BattleParamEntry_lab.dat"),
|
||||
this->load_bb_file("BattleParamEntry_ep4.dat"));
|
||||
}
|
||||
}
|
||||
|
||||
void ServerState::load_level_tables() {
|
||||
config_log.info_f("Loading level tables");
|
||||
this->level_table_v1_v2 = make_shared<LevelTableV2>(phosg::load_file("system/level-tables/PlayerTable-pc-v2.prs"), true);
|
||||
this->level_table_v3 = make_shared<LevelTableV3BE>(phosg::load_file("system/level-tables/PlyLevelTbl-gc-v3.cpt"), true);
|
||||
this->level_table_v4 = make_shared<LevelTableV4>(*this->load_bb_file("PlyLevelTbl.prs"), true);
|
||||
this->level_table_v1_v2 = make_shared<JSONLevelTable>(phosg::JSON::parse(phosg::load_file(
|
||||
"system/tables/level-table-v1-v2.json")));
|
||||
this->level_table_v3 = make_shared<JSONLevelTable>(phosg::JSON::parse(phosg::load_file(
|
||||
"system/tables/level-table-v3.json")));
|
||||
this->level_table_v4 = make_shared<JSONLevelTable>(phosg::JSON::parse(phosg::load_file(
|
||||
"system/tables/level-table-v4.json")));
|
||||
}
|
||||
|
||||
void ServerState::load_text_index() {
|
||||
@@ -2032,11 +2058,11 @@ void ServerState::load_drop_tables() {
|
||||
|
||||
unordered_map<string, shared_ptr<const RareItemSet>> new_rare_item_sets;
|
||||
unordered_map<string, shared_ptr<const CommonItemSet>> new_common_item_sets;
|
||||
for (const auto& item : std::filesystem::directory_iterator("system/item-tables")) {
|
||||
for (const auto& item : std::filesystem::directory_iterator("system/tables")) {
|
||||
string filename = item.path().filename().string();
|
||||
|
||||
if (filename.starts_with("common-table-") || filename.starts_with("ItemPT-")) {
|
||||
string path = "system/item-tables/" + filename;
|
||||
string path = "system/tables/" + filename;
|
||||
size_t ext_offset = filename.rfind('.');
|
||||
string basename = (ext_offset == string::npos) ? filename : filename.substr(0, ext_offset);
|
||||
|
||||
@@ -2055,7 +2081,7 @@ void ServerState::load_drop_tables() {
|
||||
auto data = make_shared<string>(phosg::load_file(path));
|
||||
shared_ptr<string> ct_data;
|
||||
try {
|
||||
string ct_path = "system/item-tables/" + ct_filename;
|
||||
string ct_path = "system/tables/" + ct_filename;
|
||||
ct_data = make_shared<string>(phosg::load_file(ct_path));
|
||||
config_log.info_f("Loading AFS common item table {} with challenge table {}", filename, ct_filename);
|
||||
} catch (const phosg::cannot_open_file&) {
|
||||
@@ -2075,7 +2101,7 @@ void ServerState::load_drop_tables() {
|
||||
}
|
||||
|
||||
} else if (filename.starts_with("rare-table-") || filename.starts_with("ItemRT-")) {
|
||||
string path = "system/item-tables/" + filename;
|
||||
string path = "system/tables/" + filename;
|
||||
size_t ext_offset = filename.rfind('.');
|
||||
string basename = (ext_offset == string::npos) ? filename : filename.substr(0, ext_offset);
|
||||
|
||||
@@ -2124,20 +2150,20 @@ void ServerState::load_drop_tables() {
|
||||
}
|
||||
|
||||
config_log.info_f("Loading armor table");
|
||||
auto armor_data = make_shared<string>(phosg::load_file("system/item-tables/ArmorRandom-gc-v3.rel"));
|
||||
auto armor_data = make_shared<string>(phosg::load_file("system/tables/ArmorRandom-gc-v3.rel"));
|
||||
auto new_armor_random_set = make_shared<ArmorRandomSet>(armor_data);
|
||||
|
||||
config_log.info_f("Loading tool table");
|
||||
auto tool_data = make_shared<string>(phosg::load_file("system/item-tables/ToolRandom-gc-v3.rel"));
|
||||
auto tool_data = make_shared<string>(phosg::load_file("system/tables/ToolRandom-gc-v3.rel"));
|
||||
auto new_tool_random_set = make_shared<ToolRandomSet>(tool_data);
|
||||
|
||||
config_log.info_f("Loading weapon tables");
|
||||
array<shared_ptr<const WeaponRandomSet>, 4> new_weapon_random_sets;
|
||||
const char* filenames[4] = {
|
||||
"system/item-tables/WeaponRandomNormal-gc-v3.rel",
|
||||
"system/item-tables/WeaponRandomHard-gc-v3.rel",
|
||||
"system/item-tables/WeaponRandomVeryHard-gc-v3.rel",
|
||||
"system/item-tables/WeaponRandomUltimate-gc-v3.rel",
|
||||
"system/tables/WeaponRandomNormal-gc-v3.rel",
|
||||
"system/tables/WeaponRandomHard-gc-v3.rel",
|
||||
"system/tables/WeaponRandomVeryHard-gc-v3.rel",
|
||||
"system/tables/WeaponRandomUltimate-gc-v3.rel",
|
||||
};
|
||||
for (size_t z = 0; z < 4; z++) {
|
||||
auto weapon_data = make_shared<string>(phosg::load_file(filenames[z]));
|
||||
@@ -2145,7 +2171,7 @@ void ServerState::load_drop_tables() {
|
||||
}
|
||||
|
||||
config_log.info_f("Loading tekker adjustment table");
|
||||
auto tekker_data = make_shared<string>(phosg::load_file("system/item-tables/JudgeItem-gc-v3.rel"));
|
||||
auto tekker_data = make_shared<string>(phosg::load_file("system/tables/JudgeItem-gc-v3.rel"));
|
||||
auto new_tekker_adjustment_set = make_shared<TekkerAdjustmentSet>(tekker_data);
|
||||
|
||||
this->rare_item_sets = std::move(new_rare_item_sets);
|
||||
@@ -2161,25 +2187,32 @@ void ServerState::load_item_definitions() {
|
||||
config_log.info_f("Loading item definition tables");
|
||||
for (size_t v_s = NUM_PATCH_VERSIONS; v_s < NUM_VERSIONS; v_s++) {
|
||||
Version v = static_cast<Version>(v_s);
|
||||
string path = std::format("system/item-tables/item-parameter-table-{}.json", file_path_token_for_version(v));
|
||||
config_log.debug_f("Loading item definition table {}", path);
|
||||
new_item_parameter_tables[v_s] = ItemParameterTable::from_json(phosg::JSON::parse(phosg::load_file(path)));
|
||||
string json_path = std::format("system/tables/item-parameter-table-{}.json", file_path_token_for_version(v));
|
||||
try {
|
||||
config_log.debug_f("Loading item definition table {}", json_path);
|
||||
new_item_parameter_tables[v_s] = ItemParameterTable::from_json(phosg::JSON::parse(phosg::load_file(json_path)));
|
||||
} catch (const std::exception& e) {
|
||||
string path = std::format("system/tables/ItemPMT-{}.prs", file_path_token_for_version(v));
|
||||
config_log.debug_f("Cannot load {} ({}); loading item definition table {}", json_path, e.what(), path);
|
||||
auto data = std::make_shared<std::string>(prs_decompress(phosg::load_file(path)));
|
||||
new_item_parameter_tables[v_s] = ItemParameterTable::from_binary(data, v);
|
||||
}
|
||||
}
|
||||
|
||||
auto json = phosg::JSON::parse(phosg::load_file("system/item-tables/translation-table.json"));
|
||||
auto json = phosg::JSON::parse(phosg::load_file("system/tables/translation-table.json"));
|
||||
auto new_item_translation_table = make_shared<ItemTranslationTable>(json, new_item_parameter_tables);
|
||||
|
||||
config_log.info_f("Loading v1 mag evolution table");
|
||||
auto mag_data_v1 = make_shared<string>(prs_decompress(phosg::load_file("system/item-tables/ItemMagEdit-dc-v1.prs")));
|
||||
auto mag_data_v1 = make_shared<string>(prs_decompress(phosg::load_file("system/tables/ItemMagEdit-dc-v1.prs")));
|
||||
auto new_table_v1 = MagEvolutionTable::create(mag_data_v1, Version::DC_V1);
|
||||
config_log.info_f("Loading v2 mag evolution table");
|
||||
auto mag_data_v2 = make_shared<string>(prs_decompress(phosg::load_file("system/item-tables/ItemMagEdit-dc-v2.prs")));
|
||||
auto mag_data_v2 = make_shared<string>(prs_decompress(phosg::load_file("system/tables/ItemMagEdit-dc-v2.prs")));
|
||||
auto new_table_v2 = MagEvolutionTable::create(mag_data_v2, Version::DC_V2);
|
||||
config_log.info_f("Loading v3 mag evolution table");
|
||||
auto mag_data_v3 = make_shared<string>(prs_decompress(phosg::load_file("system/item-tables/ItemMagEdit-xb-v3.prs")));
|
||||
auto mag_data_v3 = make_shared<string>(prs_decompress(phosg::load_file("system/tables/ItemMagEdit-xb-v3.prs")));
|
||||
auto new_table_v3 = MagEvolutionTable::create(mag_data_v3, Version::XB_V3);
|
||||
config_log.info_f("Loading v4 mag evolution table");
|
||||
auto mag_data_v4 = make_shared<string>(prs_decompress(phosg::load_file("system/item-tables/ItemMagEdit-bb-v4.prs")));
|
||||
auto mag_data_v4 = make_shared<string>(prs_decompress(phosg::load_file("system/tables/ItemMagEdit-bb-v4.prs")));
|
||||
auto new_table_v4 = MagEvolutionTable::create(mag_data_v4, Version::BB_V4);
|
||||
|
||||
this->item_parameter_tables = std::move(new_item_parameter_tables);
|
||||
@@ -2231,7 +2264,7 @@ void ServerState::load_quest_index(bool raise_on_any_failure) {
|
||||
|
||||
void ServerState::compile_functions(bool raise_on_any_failure) {
|
||||
config_log.info_f("Compiling client functions");
|
||||
this->function_code_index = make_shared<FunctionCodeIndex>("system/client-functions", raise_on_any_failure);
|
||||
this->client_functions = make_shared<ClientFunctionIndex>("system/client-functions", raise_on_any_failure);
|
||||
}
|
||||
|
||||
void ServerState::load_dol_files() {
|
||||
@@ -2243,31 +2276,38 @@ void ServerState::generate_bb_stream_file() {
|
||||
config_log.info_f("Generating BB stream file");
|
||||
auto sf = std::make_shared<BBStreamFile>();
|
||||
|
||||
auto add_file = [&](const std::string& filename, std::string&& file_data = "") -> void {
|
||||
if (file_data.empty()) {
|
||||
file_data = phosg::load_file("system/blueburst/" + filename);
|
||||
}
|
||||
auto add_file = [&](const std::string& filename, const void* data = nullptr, size_t size = 0) -> void {
|
||||
auto& e = sf->entries.emplace_back();
|
||||
e.size = file_data.size();
|
||||
e.checksum = phosg::crc32(file_data.data(), file_data.size());
|
||||
e.offset = sf->data.size();
|
||||
e.filename = filename;
|
||||
sf->data += file_data;
|
||||
if (!data) {
|
||||
std::string file_data = phosg::load_file("system/blueburst/" + filename);
|
||||
e.size = file_data.size();
|
||||
e.checksum = phosg::crc32(file_data.data(), file_data.size());
|
||||
sf->data += file_data;
|
||||
} else {
|
||||
e.size = size;
|
||||
e.checksum = phosg::crc32(data, size);
|
||||
sf->data.append(reinterpret_cast<const char*>(data), size);
|
||||
}
|
||||
config_log.debug_f(
|
||||
"[BBStreamFile] Added file {} at offset {:08X} ({:08X} bytes) with checksum {:08X}; total size is now {:08X}",
|
||||
filename, e.offset, e.size, e.checksum, sf->data.size());
|
||||
};
|
||||
|
||||
add_file("BattleParamEntry.dat");
|
||||
add_file("BattleParamEntry_on.dat");
|
||||
add_file("BattleParamEntry_lab.dat");
|
||||
add_file("BattleParamEntry_lab_on.dat");
|
||||
add_file("BattleParamEntry_ep4.dat");
|
||||
add_file("BattleParamEntry_ep4_on.dat");
|
||||
add_file("PlyLevelTbl.prs");
|
||||
auto level_table_data = prs_compress_optimal(this->level_table_v4->serialize_binary_v4());
|
||||
auto pmt_data = prs_compress_optimal(this->item_parameter_table(Version::BB_V4)->serialize_binary(Version::BB_V4));
|
||||
|
||||
const auto& bps = *this->battle_params;
|
||||
add_file("BattleParamEntry.dat", &bps.get_table(true, Episode::EP1), sizeof(BattleParamsIndex::Table));
|
||||
add_file("BattleParamEntry_lab.dat", &bps.get_table(true, Episode::EP2), sizeof(BattleParamsIndex::Table));
|
||||
add_file("BattleParamEntry_ep4.dat", &bps.get_table(true, Episode::EP4), sizeof(BattleParamsIndex::Table));
|
||||
add_file("BattleParamEntry_on.dat", &bps.get_table(false, Episode::EP1), sizeof(BattleParamsIndex::Table));
|
||||
add_file("BattleParamEntry_lab_on.dat", &bps.get_table(false, Episode::EP2), sizeof(BattleParamsIndex::Table));
|
||||
add_file("BattleParamEntry_ep4_on.dat", &bps.get_table(false, Episode::EP4), sizeof(BattleParamsIndex::Table));
|
||||
add_file("PlyLevelTbl.prs", level_table_data.data(), level_table_data.size());
|
||||
add_file("ItemMagEdit.prs");
|
||||
auto pmt = this->item_parameter_table(Version::BB_V4);
|
||||
add_file("ItemPMT.prs", prs_compress_optimal(pmt->serialize_binary(Version::BB_V4)));
|
||||
add_file("ItemPMT.prs", pmt_data.data(), pmt_data.size());
|
||||
|
||||
this->bb_stream_file = sf;
|
||||
}
|
||||
@@ -2354,6 +2394,27 @@ void ServerState::load_all(bool enable_thread_pool) {
|
||||
this->generate_bb_stream_file();
|
||||
}
|
||||
|
||||
void ServerState::reset_between_replays() {
|
||||
if (this->allow_saving_accounts) {
|
||||
throw std::logic_error("Account saving is enabled during replay");
|
||||
}
|
||||
this->account_index = make_shared<AccountIndex>(true);
|
||||
|
||||
this->next_lobby_id = 0;
|
||||
std::vector<std::shared_ptr<Lobby>> lobbies_to_delete;
|
||||
for (const auto& l : this->all_lobbies()) {
|
||||
if (l->is_game()) {
|
||||
lobbies_to_delete.emplace_back(l);
|
||||
} else {
|
||||
this->next_lobby_id = std::max<uint32_t>(this->next_lobby_id, l->lobby_id + 1);
|
||||
}
|
||||
}
|
||||
for (const auto& l : lobbies_to_delete) {
|
||||
phosg::log_warning_f("Previous replay left a game open ({:08X}); destroying it", l->lobby_id);
|
||||
this->remove_lobby(l);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerState::disconnect_all_banned_clients() {
|
||||
uint64_t now_usecs = phosg::now();
|
||||
|
||||
|
||||
+7
-3
@@ -11,11 +11,12 @@
|
||||
|
||||
#include "Account.hh"
|
||||
#include "Client.hh"
|
||||
#include "ClientFunctionIndex.hh"
|
||||
#include "CommonItemSet.hh"
|
||||
#include "DNSServer.hh"
|
||||
#include "DOLFileIndex.hh"
|
||||
#include "Episode3/DataIndexes.hh"
|
||||
#include "Episode3/Tournament.hh"
|
||||
#include "FunctionCompiler.hh"
|
||||
#include "GSLArchive.hh"
|
||||
#include "IPV4RangeSet.hh"
|
||||
#include "ItemNameIndex.hh"
|
||||
@@ -111,6 +112,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::string name;
|
||||
std::unordered_map<std::string, std::shared_ptr<PortConfiguration>> name_to_port_config;
|
||||
std::unordered_map<uint16_t, std::shared_ptr<PortConfiguration>> number_to_port_config;
|
||||
std::unordered_map<uint16_t, uint16_t> ip_stack_port_remap;
|
||||
std::string username;
|
||||
std::string dns_server_addr;
|
||||
uint16_t dns_server_port = 0;
|
||||
@@ -191,7 +193,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::vector<std::shared_ptr<const PSOBBEncryption::KeyFile>> bb_private_keys;
|
||||
std::shared_ptr<const parray<uint8_t, 0x16C>> bb_default_keyboard_config;
|
||||
std::shared_ptr<const parray<uint8_t, 0x38>> bb_default_joystick_config;
|
||||
std::shared_ptr<const FunctionCodeIndex> function_code_index;
|
||||
std::shared_ptr<const ClientFunctionIndex> client_functions;
|
||||
std::shared_ptr<const PatchFileIndex> pc_patch_file_index;
|
||||
std::shared_ptr<const PatchFileIndex> bb_patch_file_index;
|
||||
std::unordered_map<uint64_t, std::shared_ptr<const MapFile>> map_file_for_source_hash;
|
||||
@@ -212,7 +214,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::shared_ptr<const G_SetEXResultValues_Ep3_6xB4x4B> ep3_tournament_final_round_ex_values;
|
||||
std::shared_ptr<const QuestCategoryIndex> quest_category_index;
|
||||
std::shared_ptr<const QuestIndex> quest_index;
|
||||
std::shared_ptr<const LevelTableV2> level_table_v1_v2;
|
||||
std::shared_ptr<const LevelTable> level_table_v1_v2;
|
||||
std::shared_ptr<const LevelTable> level_table_v3;
|
||||
std::shared_ptr<const LevelTable> level_table_v4;
|
||||
std::shared_ptr<const BattleParamsIndex> battle_params;
|
||||
@@ -465,5 +467,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
|
||||
void load_all(bool enable_thread_pool);
|
||||
|
||||
void reset_between_replays();
|
||||
|
||||
void disconnect_all_banned_clients();
|
||||
};
|
||||
|
||||
@@ -1095,15 +1095,3 @@ ShellCommand c_create_item(
|
||||
send_text_message(c->channel, "$C7Item created:\n" + name);
|
||||
co_return deque<string>{};
|
||||
});
|
||||
|
||||
ShellCommand c_replay_log(
|
||||
"replay-log", nullptr,
|
||||
+[](ShellCommand::Args& args) -> asio::awaitable<deque<string>> {
|
||||
if (args.s->allow_saving_accounts) {
|
||||
throw runtime_error("Replays cannot be run when account saving is enabled");
|
||||
}
|
||||
auto log_f = phosg::fopen_shared(args.args, "rt");
|
||||
auto replay_session = make_shared<ReplaySession>(args.s, log_f.get(), true);
|
||||
co_await replay_session->run();
|
||||
co_return deque<string>{};
|
||||
});
|
||||
|
||||
+12
-12
@@ -293,18 +293,18 @@ uint8_t npc_for_name(const string& name, Version version) {
|
||||
|
||||
const char* name_for_char_class(uint8_t cls) {
|
||||
static const array<const char*, 12> names = {
|
||||
/* 00 */ "HUmar", // 0
|
||||
/* 01 */ "HUnewearl", // 0
|
||||
/* 02 */ "HUcast", // 1
|
||||
/* 03 */ "RAmar", // 0
|
||||
/* 04 */ "RAcast", // 2
|
||||
/* 05 */ "RAcaseal", // 1
|
||||
/* 06 */ "FOmarl", // 0
|
||||
/* 07 */ "FOnewm", // 0
|
||||
/* 08 */ "FOnewearl", // 0
|
||||
/* 09 */ "HUcaseal", // 1
|
||||
/* 0A */ "FOmar", // 0
|
||||
/* 0B */ "RAmarl"}; // 0
|
||||
/* 00 */ "HUmar",
|
||||
/* 01 */ "HUnewearl",
|
||||
/* 02 */ "HUcast",
|
||||
/* 03 */ "RAmar",
|
||||
/* 04 */ "RAcast",
|
||||
/* 05 */ "RAcaseal",
|
||||
/* 06 */ "FOmarl",
|
||||
/* 07 */ "FOnewm",
|
||||
/* 08 */ "FOnewearl",
|
||||
/* 09 */ "HUcaseal",
|
||||
/* 0A */ "FOmar",
|
||||
/* 0B */ "RAmarl"};
|
||||
try {
|
||||
return names.at(cls);
|
||||
} catch (const out_of_range&) {
|
||||
|
||||
+22
-5
@@ -140,7 +140,7 @@ uint32_t default_sub_version_for_version(Version version) {
|
||||
uint32_t default_specific_version_for_version(Version version, int64_t sub_version) {
|
||||
// For versions that don't support send_function_call by default, we need to set the specific_version based on
|
||||
// sub_version. Fortunately, all versions that share sub_version values also support send_function_call, so for those
|
||||
// versions we get the specific_version later by sending VersionDetectDC, VersionDetectGC, or VersionDetectXB.
|
||||
// versions we get the specific_version later by sending VersionDetect.
|
||||
switch (version) {
|
||||
case Version::DC_NTE:
|
||||
return SPECIFIC_VERSION_DC_NTE; // 1OJ1 (NTE)
|
||||
@@ -159,7 +159,7 @@ uint32_t default_specific_version_for_version(Version version, int64_t sub_versi
|
||||
return SPECIFIC_VERSION_DC_V1_INDETERMINATE;
|
||||
}
|
||||
case Version::DC_V2:
|
||||
return SPECIFIC_VERSION_DC_V2_INDETERMINATE; // 2___; need to send VersionDetectDC
|
||||
return SPECIFIC_VERSION_DC_V2_INDETERMINATE; // 2___; need to send VersionDetect
|
||||
case Version::PC_NTE:
|
||||
return SPECIFIC_VERSION_PC_V2_NTE; // 2OJT
|
||||
case Version::PC_V2:
|
||||
@@ -184,7 +184,7 @@ uint32_t default_specific_version_for_version(Version version, int64_t sub_versi
|
||||
case 0x30: // GC Ep1&2 GameJam demo, GC Ep1&2 Trial Edition, GC Ep1&2 JP v1.2, at least one version of PSO XB
|
||||
case 0x31: // GC Ep1&2 US v1.0, GC US v1.1, XB US
|
||||
default:
|
||||
return SPECIFIC_VERSION_GC_V3_INDETERMINATE; // 3O__; need to send VersionDetectGC
|
||||
return SPECIFIC_VERSION_GC_V3_INDETERMINATE; // 3O__; need to send VersionDetect
|
||||
}
|
||||
throw logic_error("this should be impossible");
|
||||
case Version::GC_EP3_NTE:
|
||||
@@ -199,10 +199,10 @@ uint32_t default_specific_version_for_version(Version version, int64_t sub_versi
|
||||
case -1: // Initial check (before sub_version recognition)
|
||||
case 0x40: // GC Ep3 trial and GC Ep3 JP
|
||||
default:
|
||||
return SPECIFIC_VERSION_GC_EP3_INDETERMINATE; // 3SJ_; need to send VersionDetectGC
|
||||
return SPECIFIC_VERSION_GC_EP3_INDETERMINATE; // 3SJ_; need to send VersionDetect
|
||||
}
|
||||
case Version::XB_V3:
|
||||
return SPECIFIC_VERSION_XB_V3_INDETERMINATE; // 4O__; need to send VersionDetectXB
|
||||
return SPECIFIC_VERSION_XB_V3_INDETERMINATE; // 4O__; need to send VersionDetect
|
||||
case Version::BB_V4:
|
||||
return SPECIFIC_VERSION_BB_V4_INDETERMINATE; // 5___; we should be able to determine version from initial login
|
||||
default:
|
||||
@@ -244,6 +244,23 @@ bool specific_version_is_bb(uint32_t specific_version) {
|
||||
return ((specific_version & 0xFF000000) == 0x35000000);
|
||||
}
|
||||
|
||||
uint32_t specific_version_for_str(const std::string& s) {
|
||||
switch (s.size()) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return (s[0] << 24);
|
||||
case 2:
|
||||
return (s[0] << 24) | (s[1] << 16);
|
||||
case 3:
|
||||
return (s[0] << 24) | (s[1] << 16) | (s[2] << 8);
|
||||
case 4:
|
||||
return (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||
default:
|
||||
throw std::runtime_error("Invalid specific_version string");
|
||||
}
|
||||
}
|
||||
|
||||
string str_for_specific_version(uint32_t specific_version) {
|
||||
string ret;
|
||||
for (size_t z = 0; z < 4; z++) {
|
||||
|
||||
@@ -184,6 +184,10 @@ constexpr bool uses_utf16(Version version) {
|
||||
(version == Version::BB_V4);
|
||||
}
|
||||
|
||||
constexpr uint32_t SPECIFIC_VERSION_SH4_INDETERMINATE = 0x53483400; // SH4_
|
||||
constexpr uint32_t SPECIFIC_VERSION_PPC_INDETERMINATE = 0x50504300; // PPC_
|
||||
constexpr uint32_t SPECIFIC_VERSION_X86_INDETERMINATE = 0x58383600; // X86_
|
||||
|
||||
constexpr uint32_t SPECIFIC_VERSION_DC_NTE = 0x314F4A31; // 1OJ1
|
||||
constexpr uint32_t SPECIFIC_VERSION_DC_11_2000_PROTOTYPE = 0x314F4A32; // 1OJ2
|
||||
constexpr uint32_t SPECIFIC_VERSION_DC_V1_JP = 0x314F4A46; // 1OJF
|
||||
@@ -220,6 +224,7 @@ bool specific_version_is_gc(uint32_t specific_version);
|
||||
bool specific_version_is_xb(uint32_t specific_version);
|
||||
bool specific_version_is_bb(uint32_t specific_version);
|
||||
|
||||
uint32_t specific_version_for_str(const std::string& specific_version);
|
||||
std::string str_for_specific_version(uint32_t specific_version);
|
||||
|
||||
enum class ServerBehavior {
|
||||
|
||||
Reference in New Issue
Block a user