fix ep3 game creation

This commit is contained in:
Martin Michelsen
2022-03-09 00:28:44 -08:00
parent 1b663aed58
commit c3a2356972
4 changed files with 40 additions and 31 deletions
+27 -22
View File
@@ -359,32 +359,37 @@ static void process_subcommand_use_item(shared_ptr<ServerState>,
forward_subcommand(l, c, command, flag, p, count);
}
static void process_subcommand_open_shop(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t,
static void process_subcommand_open_shop_or_ep3_unknown(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const PSOSubcommand* p, size_t count) {
check_size(count, 2);
uint32_t shop_type = p[1].dword;
if (l->flags & LobbyFlag::Episode3) {
check_size(count, 2, 0xFFFF);
forward_subcommand(l, c, command, flag, p, count);
if ((l->version == GameVersion::BB) && l->is_game()) {
size_t num_items = (rand() % 4) + 9;
c->player.current_shop_contents.clear();
while (c->player.current_shop_contents.size() < num_items) {
ItemData item_data;
if (shop_type == 0) { // tool shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 3);
} else if (shop_type == 1) { // weapon shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 0);
} else if (shop_type == 2) { // guards shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 1);
} else { // unknown shop... just leave it blank I guess
break;
} else {
uint32_t shop_type = p[1].dword;
if ((l->version == GameVersion::BB) && l->is_game()) {
size_t num_items = (rand() % 4) + 9;
c->player.current_shop_contents.clear();
while (c->player.current_shop_contents.size() < num_items) {
ItemData item_data;
if (shop_type == 0) { // tool shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 3);
} else if (shop_type == 1) { // weapon shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 0);
} else if (shop_type == 2) { // guards shop
item_data = s->common_item_creator->create_shop_item(l->difficulty, 1);
} else { // unknown shop... just leave it blank I guess
break;
}
item_data.item_id = l->generate_item_id(c->lobby_client_id);
c->player.current_shop_contents.emplace_back(item_data);
}
item_data.item_id = l->generate_item_id(c->lobby_client_id);
c->player.current_shop_contents.emplace_back(item_data);
send_shop(c, shop_type);
}
send_shop(c, shop_type);
}
}
@@ -1105,7 +1110,7 @@ subcommand_handler_t subcommand_handlers[0x100] = {
process_subcommand_unimplemented,
process_subcommand_unimplemented,
process_subcommand_unimplemented,
process_subcommand_open_shop,
process_subcommand_open_shop_or_ep3_unknown,
process_subcommand_unimplemented,
process_subcommand_unimplemented,
process_subcommand_identify_item,