Compare commits

..

234 Commits

Author SHA1 Message Date
Martin Michelsen e27426dc16 delete unverified BB HTML drop tables
Docker / Build (push) Has been cancelled
2025-03-09 20:40:07 -07:00
Martin Michelsen 4cf650fb98 fix team member remove bug 2025-03-09 17:36:08 -07:00
Martin Michelsen 3857cda4e5 fix team member count updates 2025-03-09 16:11:34 -07:00
Martin Michelsen 99ebf96cb0 fix allowed version flags on Ep2 BB games; closes #619 2025-03-09 16:11:09 -07:00
Martin Michelsen 311af36632 add HTML drop tables 2025-03-09 00:55:32 -08:00
Martin Michelsen cf46a2cfc1 make salvage-gci --round2 21000x faster 2025-03-08 23:44:57 -08:00
Martin Michelsen 002a504418 describe a few more object params 2025-03-08 23:44:57 -08:00
Martin Michelsen ff9ff218bb fix help text 2025-03-08 23:04:48 -08:00
Martin Michelsen 5f838815ab fix team membership struct 2025-03-08 23:04:48 -08:00
Martin Michelsen c7d606247f describe some more object types 2025-03-05 22:37:50 -08:00
Martin Michelsen 546e8a3801 gcc should be able to handle this 2025-03-01 20:02:39 -08:00
Martin Michelsen f53604f49c start documenting map object types 2025-03-01 19:50:36 -08:00
Martin Michelsen 84c62b33a4 update comments on 6x93 and 6xB2 2025-03-01 19:50:36 -08:00
Martin Michelsen ddc52c06ae fix $where in the lobby 2025-03-01 19:50:36 -08:00
Martin Michelsen d02a3d7d64 add extract-ppk action 2025-03-01 19:50:36 -08:00
Martin Michelsen 21a0efa8ac update comment on get_random quest opcode 2025-03-01 19:50:36 -08:00
Martin Michelsen 4d7a3395ba refine quest header format; use metadata from .bin.txt file if present 2025-03-01 19:50:36 -08:00
Martin Michelsen 78fe4ebf98 refine 24 and 25 command structs 2025-02-27 23:14:46 -08:00
Martin Michelsen c596a18b3a support .include in quest scripts 2025-02-26 21:01:55 -08:00
Martin Michelsen f3b547f93c fix v1 itemrt conversion 2025-02-25 14:51:52 -08:00
Martin Michelsen ef53a3b269 fix signed comparison 2025-02-24 10:20:20 -08:00
Martin Michelsen 4f364f56d0 update html rare table generator 2025-02-24 10:14:37 -08:00
Martin Michelsen 4e77ff7ab1 add --decompress option in decode-qst 2025-02-24 10:14:15 -08:00
Martin Michelsen 81ad01891a update version code notes 2025-02-24 10:13:33 -08:00
Martin Michelsen 03d303b2bb add encode/decode options for bitmap fonts 2025-02-23 17:05:16 -08:00
Martin Michelsen 52bca977c3 fix enemy type conditions to match what the client does 2025-02-23 11:24:43 -08:00
Martin Michelsen f9cac45996 allow including shared files via .include_native 2025-02-23 11:20:55 -08:00
Martin Michelsen 04dbcef2cf recompile extended item info AR code for v1.2 2025-02-22 20:53:08 -08:00
Martin Michelsen 66e00d5136 add $nativecall command 2025-02-22 20:52:47 -08:00
Martin Michelsen 11d539042c fix ExtendedItemInfo patch and add AR code 2025-02-22 17:18:30 -08:00
Martin Michelsen 104e31028b fix incorrect box drop areas in rare tables 2025-02-22 16:50:18 -08:00
Martin Michelsen fa22c3563d add HTML rare table generator 2025-02-22 14:01:33 -08:00
Martin Michelsen 2cd4e5cf27 add file caches in non-server ServerState constructor 2025-02-20 22:31:39 -08:00
Martin Michelsen d9744a696e implement item translation table 2025-02-20 22:31:26 -08:00
Martin Michelsen 813bd2e0fa fix definition of give_s_rank_weapon opcode 2025-02-20 21:29:57 -08:00
Martin Michelsen 2d42d1ce07 update some item-related notes 2025-02-20 21:29:45 -08:00
Martin Michelsen 9001af38cd fix patch flags on BB 2025-02-20 21:29:02 -08:00
Martin Michelsen 67a56a369f fix corruption loader AR code 2025-02-17 23:16:18 -08:00
Martin Michelsen f4da9c8cb2 add enemy count generator 2025-02-17 19:34:36 -08:00
Martin Michelsen 963788af33 add enemy count computation in load-maps-test 2025-02-17 18:13:44 -08:00
Martin Michelsen d0e0e59762 add ReturnTokenX86 function 2025-02-17 10:36:53 -08:00
Martin Michelsen caf41c99de add stub for new address translator function 2025-02-17 00:19:03 -08:00
Martin Michelsen 9185dc0b62 fix overly long option names 2025-02-17 00:14:58 -08:00
Martin Michelsen 83990c6d5f construct supermaps on-demand instead of at startup 2025-02-17 00:14:58 -08:00
Martin Michelsen f53ca31b22 update 6x61 description 2025-02-17 00:14:58 -08:00
Martin Michelsen 44ea82771b update client functions for eventual pc v2 semantics 2025-02-17 00:14:58 -08:00
Martin Michelsen 984d8f0f31 update executable diff action 2025-02-17 00:14:58 -08:00
Martin Michelsen 7570c3ce34 add more ar codes 2025-02-17 00:14:58 -08:00
Martin Michelsen d24a535cd6 write 59NJ version of DisableIdleDisconnect patch 2025-02-17 00:14:58 -08:00
Martin Michelsen f2d36d589b add v1 ports of RaresInQuests patch 2025-02-17 00:14:58 -08:00
Martin Michelsen 2b31656661 update write opcode comments in QuestScript.cc 2025-02-17 00:14:54 -08:00
Martin Michelsen 6e8eecda8b document more of ItemMagEdit.prs format 2025-02-14 22:39:15 -08:00
Martin Michelsen 9ed01ede2d use mag evolution table for fixed-type cell evolution; fixes #608 2025-02-13 21:59:00 -08:00
Martin Michelsen 5ed2503491 fix ExtendedItemInfo in city 2025-02-13 21:00:34 -08:00
Martin Michelsen 2a34d64f00 add 2OJ5 version of RaresInQuests 2025-02-13 07:38:13 -08:00
Martin Michelsen fe4bd3d495 fix print-item-tables 2025-02-13 07:36:52 -08:00
Blst34 7ad5cbd28b Add files via upload 2025-02-13 07:36:36 -08:00
Martin Michelsen 775369345c use semantic hash index to fill in gaps in supermap 2025-02-11 09:37:53 -08:00
Martin Michelsen 17fe80cf85 abstract supermap construction across entity types 2025-02-10 22:44:13 -08:00
Martin Michelsen a3428d33ae update Ep3 Plus description 2025-02-09 23:32:37 -08:00
Martin Michelsen 4a1561ec55 add Ep3 Plus as a client function 2025-02-09 23:22:58 -08:00
Martin Michelsen 405399682f improve diff-dol-files 2025-02-09 23:08:16 -08:00
Martin Michelsen 01e6c5a8fb shorter version of ep3 chat filter code 2025-02-09 23:08:09 -08:00
Martin Michelsen 048b8ba09c fix mericarol type logic; closes #607 2025-02-09 10:40:57 -08:00
Martin Michelsen b451c82943 add GSL archive generation 2025-02-09 08:55:59 -08:00
Martin Michelsen 9d7c71fb26 rewrite common bank patch 2025-02-08 22:47:23 -08:00
Martin Michelsen 07c5a8a4b6 rewrite chat patch 2025-02-08 22:05:44 -08:00
Martin Michelsen 15f923a639 rewrite palette patch 2025-02-08 14:59:24 -08:00
Martin Michelsen 4c55551e12 fix 6xA4 and 6xA5 sizes; closes #605 2025-02-07 08:56:29 -08:00
Martin Michelsen 81d5b23d80 fix $next on proxy server 2025-02-06 22:59:52 -08:00
Martin Michelsen fa7c76b75b add more door types 2025-02-06 22:53:21 -08:00
Martin Michelsen 1a7f219158 write other versions of ExtendedItemInfo patch 2025-02-01 09:29:45 -08:00
Martin Michelsen 4b3bde01e4 add extended item info patch 2025-01-31 22:25:11 -08:00
Martin Michelsen a7fdfbf732 don't print supermap at lobby creation; closes #601 2025-01-31 21:53:43 -08:00
Martin Michelsen c0994b49e5 add change marker AR code 2025-01-31 21:51:17 -08:00
Martin Michelsen 03fc351a35 add 59NJ versions of some patches; closes #598 2025-01-29 23:20:51 -08:00
Martin Michelsen 24722f0a27 more patches 2025-01-28 23:26:12 -08:00
Martin Michelsen b7293e7cb0 write more patches 2025-01-27 23:29:07 -08:00
Martin Michelsen b5104a7bda document many unknown fields 2025-01-26 15:41:54 -08:00
Martin Michelsen 78b7bfac70 refine many subcommand formats 2025-01-26 09:47:19 -08:00
Martin Michelsen 65a1b97093 refine more commands 2025-01-23 09:51:48 -08:00
Martin Michelsen 2e6e1adcf3 refine more commands 2025-01-22 23:26:12 -08:00
Martin Michelsen 7da0da66f1 refine some command formats 2025-01-22 00:41:17 -08:00
Martin Michelsen 4038221d8c fix telepipe desync during BB joinable quest load 2025-01-22 00:00:06 -08:00
Martin Michelsen 5c807fa655 refine some xb voice chat structs 2025-01-22 00:00:03 -08:00
Martin Michelsen aa9e1e7305 enable dcv1 native battle mode 2025-01-20 21:27:09 -08:00
Martin Michelsen 721b01a294 rename section to room 2025-01-19 23:21:56 -08:00
Martin Michelsen aa08e3c183 write xbox draw distance patch 2025-01-19 14:56:53 -08:00
Martin Michelsen 63fb78cc9e use original draw distance patch with fixed callback 2025-01-18 22:54:32 -08:00
Martin Michelsen a39adc593b update link on draw distance patch 2025-01-18 20:25:06 -08:00
Martin Michelsen afc6c44bc6 fix incorrect proxy handler on BB 2025-01-18 11:02:00 -08:00
Martin Michelsen 6f26cf87b1 add comment in SuperMap::add_enemy_and_children 2025-01-18 11:02:00 -08:00
Martin Michelsen 6e9d86a6ca use disconnect_client for the kick and ban commands 2025-01-17 21:05:40 -08:00
Martin Michelsen e2caf81e4b use scrolling message for BB client announcements; closes #593 2025-01-17 10:03:44 -08:00
Martin Michelsen 823fb17f60 replace draw distance patch; fixes #470 2025-01-16 23:42:54 -08:00
Martin Michelsen a30e7438ff fix status icons in enemy HP bars patch 2025-01-16 22:00:12 -08:00
Martin Michelsen 269d2178fb add /y/accounts and /y/data/quests in API 2025-01-15 20:34:56 -08:00
Martin Michelsen 6564db437a update HTTP server section in readme 2025-01-13 10:47:48 -08:00
Martin Michelsen 732f1d5eb6 update cc shell command help text 2025-01-12 16:37:25 -08:00
Martin Michelsen 9033fb6a5d rewrite chat command system 2025-01-12 16:27:02 -08:00
Martin Michelsen b028532db3 add /y/shell-exec in HTTP server 2025-01-11 22:16:26 -08:00
Martin Michelsen 80dda2e1f9 fix slime child count in challenge mode 2025-01-11 20:47:09 -08:00
Martin Michelsen 4d3595640a document hardware_id in login commands 2025-01-10 22:13:57 -08:00
Martin Michelsen 0704590238 add kick command in shell 2025-01-09 20:39:45 -08:00
Martin Michelsen 7c48dc1ff5 add notes about interaction mode 2025-01-08 23:49:03 -08:00
Martin Michelsen 68003b2e2f unify menu item format 2025-01-08 23:35:12 -08:00
Martin Michelsen f6fbba5638 run the HTTP server on the event thread on Windows 2025-01-06 22:38:19 -08:00
Martin Michelsen 4bfe7218f7 update readme 2025-01-06 08:14:16 -08:00
Martin Michelsen 5dbb6c3a27 allow concurrent proxy sessions on the same account 2025-01-06 00:12:00 -08:00
Martin Michelsen 0be056adce factor out shell command execution 2025-01-06 00:12:00 -08:00
Martin Michelsen d51f7a0fe7 fix v2/v3 crossplay quest loading 2025-01-05 10:51:59 -08:00
Martin Michelsen a7b5ea5562 allow v2 and v3 clients to load quests in the same game 2025-01-04 22:53:54 -08:00
Martin Michelsen d833727074 fix issue that caused v3 players to be temporarily invisible to v2 players after joining 2025-01-04 22:53:54 -08:00
Martin Michelsen 149e746e3a support dynamic objects in map state; closes #589 2025-01-04 22:53:54 -08:00
Martin Michelsen 1c5b0e4667 make name-all-items more useful 2025-01-04 19:01:16 -08:00
Martin Michelsen 8508607c87 rename DC_V1_11_2000_PROTOTYPE to DC_11_2000 2025-01-01 20:58:28 -08:00
Martin Michelsen 0862b01770 add missing includes on linux 2025-01-01 18:03:35 -08:00
Martin Michelsen 72ac20e574 rewrite map data model 2025-01-01 17:47:50 -08:00
Martin Michelsen 69f7bb3db9 always send server time at login; closes #586 2024-12-26 16:17:47 -08:00
Martin Michelsen dc7368e4af fix qst file format bug 2024-12-23 00:03:38 -08:00
Martin Michelsen 79c7e5dcb4 add inventory items to API response 2024-12-15 21:44:03 -08:00
Martin Michelsen 56ac0a5057 add offline seasonal rappies code 2024-12-14 19:06:13 -08:00
Martin Michelsen 183e7dbf8a fix incorrect CharClass in API server 2024-12-14 19:06:13 -08:00
Martin Michelsen e3097c5578 update ep3 battle setup debug messages 2024-12-14 19:06:13 -08:00
Martin Michelsen aebc9293ad document api endpoints 2024-12-11 19:38:36 -08:00
Martin Michelsen 4b3dcbb6f4 add item pickup patch 2024-12-07 17:29:10 -08:00
Martin Michelsen 3424d6481b add more log messages around login commands; closes #583 2024-12-03 22:21:12 -08:00
Martin Michelsen 760cec9d1e don't check auxiliary data on XB accounts; fixes #584 2024-12-03 21:37:27 -08:00
Martin Michelsen 0196c866f6 fix namespace 2024-12-01 13:19:34 -08:00
Martin Michelsen 13ee74945b refine option_flags notes 2024-12-01 10:07:21 -08:00
Martin Michelsen c6266ff624 fix checksum in 6xBB/6xBC 2024-11-30 22:13:17 -08:00
Martin Michelsen 9a15433fbf fix error in item comments 2024-11-30 10:21:46 -08:00
Martin Michelsen db2bd9d08f refine quest opcode notes 2024-11-29 23:33:44 -08:00
Martin Michelsen f5ed347734 convert private word select messages to text chat messages 2024-11-29 22:19:05 -08:00
Martin Michelsen 483f6dd3fc add conversion functions for proto and v1 save files 2024-11-24 12:26:12 -08:00
Martin Michelsen 0e5837f79a more quest opcode notes 2024-11-17 18:53:57 -08:00
Martin Michelsen ab1a2373b9 refine quest opcode notes 2024-11-17 13:49:10 -08:00
Martin Michelsen aa2b94b7f5 refine more quest opcodes 2024-11-15 19:30:10 -08:00
Martin Michelsen 55a8207932 refine quest opcode docs 2024-11-14 23:07:04 -08:00
Martin Michelsen 484feed314 update some notes 2024-11-13 23:17:15 -08:00
Martin Michelsen 04a42dc627 update readme 2024-11-13 22:42:10 -08:00
Martin Michelsen 4e9003b061 fix readme
Docker / Build (push) Has been cancelled
2024-11-11 20:29:29 -08:00
Martin Michelsen a59a2d7cd3 fix up local/external address handling 2024-11-10 16:42:02 -08:00
Martin Michelsen 8cb7b465da update quest opcode notes 2024-11-10 10:18:33 -08:00
Martin Michelsen 0279b20bb7 add BB-only NPC skins 2024-11-09 19:19:47 -08:00
Martin Michelsen a140cdbedb make some notes public 2024-11-09 18:26:41 -08:00
Martin Michelsen e7db8f2404 refine many game command formats; $infhp no longer removes positive effects 2024-11-09 18:11:30 -08:00
Martin Michelsen 70dfeeba91 add WordSelectTable::validate 2024-11-08 10:20:11 -08:00
Martin Michelsen a860d29636 name some Ep4 objects 2024-11-08 10:19:55 -08:00
Martin Michelsen a7811429a8 fix trade window bug on non-BB 2024-11-08 10:18:51 -08:00
Martin Michelsen 75be38c38b add DCv2USA in subcommand handler table 2024-11-06 22:18:05 -08:00
Martin Michelsen 75de6f259d add safeties for 6xBB and 6xBC commands 2024-11-05 21:31:30 -08:00
Martin Michelsen e6a6e862db add $battle command for dcv1 2024-11-03 22:51:26 -08:00
Martin Michelsen 2d1544edf4 add dc save file actions to docs 2024-11-03 22:14:26 -08:00
Martin Michelsen 0522b539c4 describe DC save file formats; add decrypt/encrypt actions 2024-11-03 21:33:44 -08:00
Martin Michelsen ac20d0c7d4 refine DC NTE and 11/2000 save file formats 2024-11-02 23:43:13 -07:00
Martin Michelsen 263622cef8 refine many ep3 command structures 2024-11-01 10:19:22 -07:00
Martin Michelsen 461bd3d488 fix incorrect stat computation during mat reset; fixes #578 2024-10-30 23:16:33 -07:00
Martin Michelsen 7baf5ce327 minor cleanup 2024-10-30 18:46:19 -07:00
Martin Michelsen 67c43e803b add Ep3 JP game command handlers 2024-10-30 18:46:19 -07:00
fishscene fb9bd077a8 Update README.md 2024-10-30 08:33:11 -07:00
Martin Michelsen 6e808b8340 add checks for disabled proxy server; fixes #580 2024-10-29 06:32:12 -07:00
Martin Michelsen 996509531c fix enemy_type check in ItemCreator 2024-10-29 06:20:49 -07:00
Martin Michelsen 4e7d6800cd preserve exp when resetting materials; fixes #579 2024-10-27 23:00:03 -07:00
Martin Michelsen 0c9d4bf338 refine validation_flags in save file formats 2024-10-25 22:58:02 -07:00
Martin Michelsen 48641d46a0 fix v1 max stats table; add level table formatter 2024-10-25 22:32:20 -07:00
Martin Michelsen 84159821e9 add Ep3 NTE side-by-side card defs comparison 2024-10-25 22:31:35 -07:00
Martin Michelsen 823199be2e update handler-tables 2024-10-25 22:30:34 -07:00
Martin Michelsen 9eb5601349 add 12/2000 quest opcodes to handler-tables 2024-10-22 22:34:07 -07:00
Martin Michelsen a7604353c3 add rare enemies AR code 2024-10-22 21:01:03 -07:00
Martin Michelsen cfd264e4dc add missing include on linux 2024-10-21 23:03:20 -07:00
Martin Michelsen e7d0739c8b enable quest opcode defs test 2024-10-21 22:58:58 -07:00
Martin Michelsen e5afc1d937 add sender's name to $ann message; closes #547 2024-10-21 22:58:41 -07:00
Martin Michelsen a9a15600b2 add signal handlers; closes #564 2024-10-21 22:45:03 -07:00
Martin Michelsen 086b2d411a add ability to disable rare announcements per account; closes #576 2024-10-20 16:22:26 -07:00
Martin Michelsen c61a13f62e update windows build instructions 2024-10-20 12:57:02 -07:00
Martin Michelsen 0f25af1ab7 fix build 2024-10-18 08:13:24 -07:00
Martin Michelsen 21f1c40408 allow specifying what counts as cheating; closes #572 2024-10-17 21:54:14 -07:00
Martin Michelsen f8e479b4f9 fix minlevel + cheat mode bug 2024-10-17 21:54:14 -07:00
Martin Michelsen 775842dfc5 replace class for Sonic NPC also 2024-10-17 21:54:14 -07:00
Martin Michelsen a7d436a894 use object flags for switch assist; closes #571 2024-10-17 21:54:14 -07:00
Martin Michelsen 47bc37e806 link map objects to constructor args instead of copying them 2024-10-17 21:54:14 -07:00
Martin Michelsen 080a9ebac4 merge debugging branch 2024-10-17 21:50:20 -07:00
Martin Michelsen cac9589b81 add cc shell command 2024-10-16 21:32:29 -07:00
Martin Michelsen 34bd2cd6a7 refine 6x05 a bit 2024-10-15 22:07:35 -07:00
Martin Michelsen 8cc8d804bc refine some Ep3 structures 2024-10-13 22:49:31 -07:00
Martin Michelsen 59124678bf resolve TODO about F94D quest opcode 2024-10-12 08:59:54 -07:00
nolrinale b9fd52c6c1 Fix for Elly spawn in Lab area; fixes fuzziqersoftware/newserv#492 2024-10-11 09:22:53 -07:00
Martin Michelsen 458f5b2d0f allow $edit secid if character is level 1 2024-10-09 00:25:38 -07:00
Martin Michelsen 7139df0265 document most quest opcodes 2024-10-09 00:25:38 -07:00
Martin Michelsen c6490cb3fb fix hang during xbox login when multiple auto patches are enabled 2024-10-05 16:03:38 -07:00
Martin Michelsen b7d37eb169 minor doc fixes 2024-10-05 16:03:38 -07:00
Martin Michelsen 1d26d1a529 expand quest engine documentation 2024-10-05 12:43:53 -07:00
Martin Michelsen 5294a53e1b make it possible to clear file caches 2024-10-05 12:43:38 -07:00
Martin Michelsen 40d8227504 document quest opcode F8B7 2024-10-05 10:16:09 -07:00
Martin Michelsen a734bcf483 describe quest opcode F8F2 2024-10-04 23:25:09 -07:00
Martin Michelsen 23e37b8eb7 rename some quest opcodes 2024-10-04 23:25:09 -07:00
Martin Michelsen 627c0d949c fix login with non-default license on proxy server 2024-10-04 23:24:25 -07:00
Martin Michelsen 096f9e46f4 use native error codes for login errors 2024-10-01 08:28:49 -07:00
Martin Michelsen 7910556ace fix defaults in StackLimits patch 2024-10-01 07:58:48 -07:00
Martin Michelsen 2bfcc32b6b add patch to clear the BB unreleased item list 2024-09-29 19:02:28 -07:00
Martin Michelsen 0af0f8bc53 fix F94D name in handler-tables 2024-09-29 18:57:24 -07:00
Martin Michelsen 46c212f4a1 support qedit names in quest assembler; add Ep3 NTE quest opcodes 2024-09-28 16:20:25 -07:00
Martin Michelsen 1e61415c9e update readme 2024-09-28 09:26:47 -07:00
Martin Michelsen aa4a773095 fix objects not appearing in boss rooms after rejoining persisted game 2024-09-27 22:52:01 -07:00
Martin Michelsen c8b8bf43f7 add actions for generating and parsing pcv2 registry files 2024-09-25 21:48:32 -07:00
Martin Michelsen e50848b52e fix MARKED decoding when string begins with $Cx 2024-09-25 21:48:32 -07:00
Martin Michelsen 9e8f7a1cc5 remove unused lobby flag 2024-09-25 21:48:32 -07:00
Martin Michelsen 39f3a4afa7 make bb_exchange_pc disable drops; closes #562 2024-09-23 00:32:06 -07:00
Martin Michelsen 4831f3649a fix indentation of struct args in quest disassembly 2024-09-23 00:17:10 -07:00
Martin Michelsen a9a524d04a fix asm/dasm of npc_param opcode 2024-09-23 00:16:56 -07:00
Martin Michelsen b773813f10 minor readme changes 2024-09-23 00:16:43 -07:00
Martin Michelsen 00bfae3b62 don't support XB logins on shared ports 2024-09-22 21:35:02 -07:00
Martin Michelsen 4dcb49bb34 clear game-related client flags when leaving games 2024-09-22 21:34:34 -07:00
Martin Michelsen fd25eaadfd allow oversize commands in check_size_vec_t 2024-09-22 21:34:03 -07:00
Martin Michelsen 2d5b70c734 fix xb-v3 version option 2024-09-22 21:33:45 -07:00
Martin Michelsen 1ee3caf640 don't allow dead players to surrender in ep3 2024-09-18 23:07:15 -07:00
Martin Michelsen e6e11794b8 handle out-of-order quest downloads on proxy server 2024-09-18 23:07:15 -07:00
Martin Michelsen 79eabe5ed2 add check_size_vec_t 2024-09-18 23:07:15 -07:00
Martin Michelsen b13e67d491 split team membership struct from base BB system file 2024-09-17 21:54:56 -07:00
Martin Michelsen 16a8f91822 make LocalAddress and ExternalAddress optional 2024-09-08 15:45:03 -07:00
Martin Michelsen 82f036f66f add --no-images for ep3 cards.html generation 2024-09-06 17:32:22 -07:00
Martin Michelsen 3d2b5ebb79 refine Episode3::MapDefinition 2024-09-05 23:28:40 -07:00
Martin Michelsen 302de15c75 write ep3 version of chat patch 2024-09-02 23:35:31 -07:00
Martin Michelsen 18ce96c84b fix download icons on ep3 quests 2024-09-02 23:34:39 -07:00
Martin Michelsen e017279423 don't allow clients to override tournament map 2024-09-02 23:34:27 -07:00
Martin Michelsen dbc252a5d6 only run new ep3 tests when function compiler is available 2024-09-01 16:58:39 -07:00
Martin Michelsen cb0a9dad32 re-record ep3 tests; closes #505 2024-09-01 16:50:56 -07:00
Martin Michelsen 1f6f01a37f make patch descriptions consistent 2024-09-01 15:14:10 -07:00
Martin Michelsen eaa982aae9 update some comments 2024-09-01 15:13:53 -07:00
Martin Michelsen 07308b192c fix p39/p40 range checks; fixes #474 2024-09-01 11:09:41 -07:00
Martin Michelsen 27105a3222 update TOC in readme 2024-09-01 08:33:24 -07:00
Martin Michelsen d915b5e688 write WriteCallToCode-59NL include 2024-08-26 21:39:12 -07:00
Martin Michelsen 089980a6ab fix windows build 2024-08-24 16:18:55 -07:00
548 changed files with 171605 additions and 52825 deletions
+17 -1
View File
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10)
set(CMAKE_POLICY_DEFAULT_CMP0110 NEW)
@@ -65,6 +66,7 @@ set(SOURCES
src/Compression.cc
src/DCSerialNumbers.cc
src/DNSServer.cc
src/DownloadSession.cc
src/EnemyType.cc
src/Episode3/AssistServer.cc
src/Episode3/BattleRecord.cc
@@ -82,8 +84,8 @@ set(SOURCES
src/FileContentsCache.cc
src/FunctionCompiler.cc
src/GSLArchive.cc
src/GVMEncoder.cc
src/HTTPServer.cc
src/ImageEncoder.cc
src/IntegralExpression.cc
src/IPFrameInfo.cc
src/IPStackSimulator.cc
@@ -92,6 +94,7 @@ set(SOURCES
src/ItemData.cc
src/ItemNameIndex.cc
src/ItemParameterTable.cc
src/ItemTranslationTable.cc
src/Items.cc
src/LevelTable.cc
src/Lobby.cc
@@ -104,6 +107,7 @@ set(SOURCES
src/PatchServer.cc
src/PlayerFilesManager.cc
src/PlayerSubordinates.cc
src/PPKArchive.cc
src/ProxyCommands.cc
src/ProxyServer.cc
src/PSOEncryption.cc
@@ -121,6 +125,8 @@ set(SOURCES
src/Server.cc
src/ServerShell.cc
src/ServerState.cc
src/ShellCommands.cc
src/SignalWatcher.cc
src/StaticGameData.cc
src/TeamIndex.cc
src/Text.cc
@@ -155,6 +161,7 @@ add_dependencies(newserv newserv-Revision-cc)
enable_testing()
file(GLOB LogTestCases ${CMAKE_SOURCE_DIR}/tests/*.test.txt)
file(GLOB LogRDTestCases ${CMAKE_SOURCE_DIR}/tests/*.rdtest.txt)
foreach(LogTestCase IN ITEMS ${LogTestCases})
add_test(
@@ -163,6 +170,15 @@ foreach(LogTestCase IN ITEMS ${LogTestCases})
COMMAND ${CMAKE_BINARY_DIR}/newserv --replay-log=${LogTestCase} --config=${CMAKE_SOURCE_DIR}/tests/config.json)
endforeach()
if(resource_file_FOUND)
foreach(LogRDTestCase IN ITEMS ${LogRDTestCases})
add_test(
NAME ${LogRDTestCase}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_BINARY_DIR}/newserv --replay-log=${LogRDTestCase} --config=${CMAKE_SOURCE_DIR}/tests/config.json)
endforeach()
endif()
file(GLOB ScriptTestCases ${CMAKE_SOURCE_DIR}/tests/*.test.sh)
foreach(ScriptTestCase IN ITEMS ${ScriptTestCases})
+322 -132
View File
@@ -1,6 +1,6 @@
# newserv <img align="right" src="static/s-newserv.png" />
newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO).
newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO). **To quickly get started using newserv, just read the [server setup](#server-setup) and [how to connect](#how-to-connect) sections.**
This project includes code that was reverse-engineered by the community in ages long past, and has been included in many projects since then. It also includes some game data from Phantasy Star Online itself, which was originally created by Sega.
@@ -12,6 +12,7 @@ See TODO.md for a list of known issues and future work I've curated, or go to th
* Background
* [History](#history)
* [Other server projects](#other-server-projects)
* [Developer information](#developer-information)
* [Using newserv in other projects](#using-newserv-in-other-projects)
* [Compatibility](#compatibility)
* Setup
@@ -23,10 +24,12 @@ See TODO.md for a list of known issues and future work I've curated, or go to th
* [Installing quests](#installing-quests)
* [Item tables and drop modes](#item-tables-and-drop-modes)
* [Cross-version play](#cross-version-play)
* [Server-side saves](#server-side-saves)
* [Episode 3 features](#episode-3-features)
* [Memory patches, client functions, and DOL files](#memory-patches-client-functions-and-dol-files)
* [Using newserv as a proxy](#using-newserv-as-a-proxy)
* [Chat commands](#chat-commands)
* [REST API](#rest-api)
* [Non-server features](#non-server-features)
# History
@@ -51,11 +54,11 @@ At the time of its inception, Aeon was also called newserv, and you may find som
Independently of this project, there are many other PSO servers out there. Those that I know of that are (or were) public are listed here in approximate chronological order:
* (Early 2000s) **[Schtserv](https://schtserv.com/)**: The first public-access PSO server; written in Delphi by Schthack. Still active and popular as of this writing (early 2024). Schtserv is also the only other unofficial server to support all versions of PSO, including Episode 3.
* (Early 2000s) **[Schtserv](https://schtserv.com/)**: The first public-access PSO server; written in Delphi by Schthack. Still active and popular as of early 2025. Schtserv is also the only other unofficial server to support all versions of PSO, including Episode 3. (Their implementation of Episode 3 is based on newserv's, which is itself based on Sega's.)
* (2005) **Khyller**: An early attempt of mine to support PSO PC, GC, and BB. See above for more details.
* (2006) **Aeon**: My second attempt. Better than Khyller, but still unreliable.
* (2008) **Tethealla**: A fairly extensive implementation of PSOBB, written in C by Sodaboy. The public version of Tethealla has been [officially disowned](https://www.pioneer2.net/community/threads/tethealla-server-forums-removal.26365/) (as it is now more than 15 years old), but closed-source development continues. [Ephinea](https://ephinea.pioneer2.net/), currently the most popular PSOBB server, is the continuation of this project. Several other modern PSOBB servers are forks of the initial public version of Tethealla as well.
* (2008) **[Sylverant](https://sylverant.net/)** [(source)](https://sourceforge.net/projects/sylverant/): The second public-access PSO server; written in C by BlueCrab. Still active and popular as of this writing (early 2024).
* (2008) **[Sylverant](https://sylverant.net/)** [(source)](https://sourceforge.net/projects/sylverant/): The second public-access PSO server; written in C by BlueCrab. Still active and popular as of early 2025.
* (2015) **[Archon](https://github.com/dcrodman/archon)**: A PSOBB server written in Go by Drew Rodman.
* (2015) **[Idola](https://github.com/HybridEidolon/idolapsoserv)**: A PSOBB server written in Rust by HybridEidolon. Functionality status unknown; the project has been archived.
* (2017) **[Aselia](https://github.com/Solybum/Aselia)**: A PSOBB server written written in C# by Soly. It seems this was planned to be open-source at some point, but that has not (yet) happened.
@@ -64,6 +67,22 @@ Independently of this project, there are many other PSO servers out there. Those
* (2021) **[Phantasmal World](https://github.com/DaanVandenBosch/phantasmal-world)**: A set of PSO tools, including a web-based model viewer and quest builder, and a PSO server, written by Daan Vanden Bosch.
* (2021) **[Elseware](http://git.sharnoth.com/jake/elseware)**: A PSOBB server written in Rust by Jake.
## Developer information
There is a lot of code in this project that could be useful as a reference. Some of the more notable files are:
* **src/CommandFormats.hh**: Complete listing of all network commands used in all known versions of the game, and their formats
* **src/CommonItemSet.hh/cc**: Format of ItemPT files, shop definition files, and tekker adjustment tables
* **src/DCSerialNumbers.hh/cc**: PSO DC serial number validation algorithm and serial number generator
* **src/ItemData.hh**: Item format reference
* **src/ItemCreator.hh/cc**: Reverse-engineered item generator from Episodes 1&2 (used for all versions)
* **src/ItemParameterTable.hh**: Format of many structures in ItemPMT.prs
* **src/Map.hh/cc**: Map file (.dat) structure and reverse-engineered Challenge Mode random enemy generation algorithm
* **src/QuestScript.cc**: Complete listing of all quest opcodes on all versions, along with their arguments and behavior
* **src/RareItemSet.hh/cc**: Format of ItemRT files (rare item drop tables)
* **src/SaveFileFormats.hh**: Definitions of save file structures for all versions
* **src/Episode3/DataIndexes.hh**: Episode 3 file structures, including card definition format and map/quest format
* **system/item-tables/names-v4.json**: Names of all items, indexed by the first 3 bytes of data1
## Using newserv in other projects
There is a fair amount of code in this project that could potentially be useful to other projects. You are free to use code from newserv in your own open-source projects; the only condition is that the contents of the LICENSE file must be included in your project if you use code from newserv. Your project does not also have to use the MIT license; you can use any license you want.
@@ -74,7 +93,8 @@ If you want to use parts of newserv in your project, there are two easy ways to
# Compatibility
newserv supports all known versions of PSO, including development prototypes. Specifically:
newserv supports all known versions of PSO, including various development prototypes. This table lists all versions that newserv supports. (NTE stands for Network Trial Edition; the GameCube beta versions were called Trial Edition instead, but we use the NTE abbreviation anyway for consistency.)
| Version | Lobbies | Games | Proxy |
|-----------------|----------|----------|----------|
| DC NTE | Yes | Yes | No |
@@ -84,22 +104,21 @@ newserv supports all known versions of PSO, including development prototypes. Sp
| DC V1 | Yes | Yes | Yes |
| DC 08/2001 | Yes | Yes | Yes |
| DC V2 | Yes | Yes | Yes |
| PC NTE | Yes (3) | Yes | No |
| PC NTE | Yes (1) | Yes | No |
| PC | Yes | Yes | Yes |
| GC Ep1&2 NTE | Yes | Yes | Yes |
| GC Ep1&2 | Yes | Yes | Yes |
| GC Ep1&2 Plus | Yes | Yes | Yes |
| GC Ep3 NTE | Yes | Yes (1) | Yes |
| GC Ep3 NTE | Yes | Yes (2) | Yes |
| GC Ep3 | Yes | Yes | Yes |
| Xbox Ep1&2 Beta | Yes | Yes | Yes |
| Xbox Ep1&2 | Yes | Yes | Yes |
| BB (vanilla) | Yes | Yes (2) | Yes |
| BB (Tethealla) | Yes | Yes (2) | Yes |
| BB (vanilla) | Yes | Yes | Yes |
| BB (Tethealla) | Yes | Yes | Yes |
*Notes:*
1. *Ep3 NTE battles are not well-tested; some things may not work. See notes/ep3-nte-differences.txt for a list of known differences between NTE and the final version. NTE and non-NTE players cannot battle each other.*
2. *Some BB-specific features are not well-tested (for example, some quests that use rare commands may not work properly). Please submit a GitHub issue if you find something that doesn't work.*
3. *This is the only version of PSO that doesn't have any way to identify the player's account - there is no serial number or username. For this reason, AllowUnregisteredUsers must be enabled in config.json to support PC NTE, and PC NTE players receive a random Guild Card number every time they connect. To prevent abuse, PC NTE support can be disabled in config.json.*
1. *This is the only version of PSO that doesn't have any way to identify the player's account - there is no serial number or username. For this reason, AllowUnregisteredUsers must be enabled in config.json to support PC NTE, and PC NTE players receive a random Guild Card number every time they connect. To prevent abuse, PC NTE support can be disabled in config.json.*
2. *Episode 3 NTE battles are not well-tested; some things may not work. See notes/ep3-nte-differences.txt for a list of known differences between NTE and the final version. NTE and non-NTE players cannot battle each other.*
# Setup
@@ -110,26 +129,30 @@ Currently newserv works on macOS, Windows, and Ubuntu Linux. It will likely work
### Windows/macOS
1. Download the latest release-windows-amd64.zip or release-macos-arm64.zip file from the [releases page](https://github.com/fuzziqersoftware/newserv/releases).
2. Extract the contents of the release folder to a location on your computer.
3. Edit the config.example.json file in the system folder as needed, then rename it to config.json.
4. If you plan to play Blue Burst on newserv, set up the patch directory. See [client patch directories](#client-patch-directories) for more information.
2. Extract the contents of the archive to some location on your computer.
3. (Optional) If you want to change any config options, go into the system/ folder, open config.json in a text editor, and edit it to your liking. There are comments in the file that describe what all the options do.
4. (Optional) If you plan to play Blue Burst on newserv, set up the patch directory. See [client patch directories](#client-patch-directories) for details.
5. Run the newserv executable.
### Linux
There are currently no precompiled releases for Linux. To run newserv on Linux, see the "Building from source" section below.
There are currently no precompiled releases for Linux. To run newserv on Linux, you'll have to build it from source - see the "Building from source" section below.
### Building from source
1. Install the packages newserv depends on.
* If you're on Windows, install [Cygwin](https://www.cygwin.com/). While doing so, install the `cmake`, `gcc-core`, `gcc-g++`, `git`, `libevent2.1_7`, `make`, `libiconv-devel`, and `zlib` packages. Do the rest of these steps inside a Cygwin shell (not a Windows cmd shell or PowerShell).
* If you're on Windows, install [Cygwin](https://www.cygwin.com/). While doing so, install the `cmake`, `gcc-core`, `gcc-g++`, `git`, `libevent2.1_7`, `libevent-devel`, `make`, `libiconv-devel`, and `zlib` packages. Do the rest of these steps inside a Cygwin shell (not a Windows cmd shell or PowerShell).
* If you're on macOS, run `brew install cmake libevent libiconv`.
* If you're on Linux, run `sudo apt-get install cmake libevent-dev` (or use your Linux distribution's package manager).
3. Build and install [phosg](https://github.com/fuzziqersoftware/phosg).
4. Optionally, install [resource_dasm](https://github.com/fuzziqersoftware/resource_dasm). This will enable newserv to send memory patches and load DOL files on PSO GC clients. PSO GC clients can play PSO normally on newserv without this.
5. Run `cmake . && make` in the newserv directory.
After building newserv, edit system/config.example.json as needed and rename it to system/config.json, set up [client patch directories](#client-patch-directories) if you're planning to play Blue Burst, then run `./newserv` in newserv's directory.
After building newserv, edit system/config.example.json as needed **and rename it to system/config.json** (note that this step is not necessary for the precompiled releases!), set up [client patch directories](#client-patch-directories) if you're planning to play Blue Burst, then run `./newserv` in newserv's directory.
The server has an interactive shell which can be used to make changes, such as managing user accounts, updating the server's configuration, managing Episode 3 tournaments, and more. Type `help` and press Enter to see all the commands.
On Linux and macOS, the server also responds to SIGUSR1 and SIGUSR2. SIGUSR1 does the equivalent of the shell's `reload config` command, which reloads config.json but not any dependent files (so quests, Episode 3 maps, etc. will not be reloaded). SIGUSR2 does the equivalent of the shell's `reload all` command, which reloads everything.
To use newserv in other ways (e.g. for translating data), see the end of this document.
@@ -143,7 +166,7 @@ For Blue Burst set up, the below is mandatory for a smooth experience:
2. Copy all the `map_*.dat` files, `unitxt_*` files and the `data.gsl` file and place them in `system/patch-bb/data`.
3. If you're using game files from the Tethealla client, make a copy of `unitxt_j.prs` inside system/patch-bb/data and name it `unitxt_e.prs`. (If `unitxt_e.prs` already exists, replace it with the copied file.)
If you do not have a BB client, or using a Tethealla client from another source, Tethealla clients that are compatible with newserv can be found here: [English](https://web.archive.org/web/20240402011115/https://ragol.org/files/bb/TethVer12513_English.zip) / [Japanese](https://web.archive.org/web/20240402013127/https://ragol.org/files/bb/TethVer12513_Japanese.zip). These clients connect to 127.0.0.1 (localhost) automatically.
If you don't have a BB client, or if you're using a Tethealla client from another source, Tethealla clients that are compatible with newserv can be found here: [English](https://web.archive.org/web/20240402011115/https://ragol.org/files/bb/TethVer12513_English.zip) / [Japanese](https://web.archive.org/web/20240402013127/https://ragol.org/files/bb/TethVer12513_Japanese.zip). These clients connect to 127.0.0.1 (localhost) automatically.
For BB clients, newserv reads some files out of the patch data to implement game logic, so it's important that certain game files are synchronized between the server and the client. newserv contains defaults for these files in the system/maps/bb-v4 directory, but if these don't match the client's copies of the files, odd behavior will occur in games.
@@ -212,28 +235,28 @@ Devolution includes modem emulation and is compatible with all PSO GameCube vers
### PSO GC on Dolphin
If you're using the HLE BBA type, set the BBA's DNS server address to newserv's IP address and it should work. (If newserv is on the same machine as Dolphin, you will need to use an action replay code directed at 127.0.0.1 to connect, as PSO rejects DNS queries from the same IP address.) Set PSO's network settings the same as listed below.
If you're using the HLE BBA type, set the BBA's DNS server address to newserv's IP address and it should work. (If newserv is on the same machine as Dolphin, you will need to use an Action Replay code directed at 127.0.0.1 to connect, as PSO rejects DNS queries from the same IP address.) Set PSO's network settings the same as listed below.
If you're using the TAP BBA type, you'll have to set PSO's network settings appropriately for your tap interface. Set the DNS server address in PSO's network settings to newserv's IP address.
If you're using the TAP (not tapserver) BBA type, you'll have to set PSO's network settings appropriately for your tap interface. Set the DNS server address in PSO's network settings to newserv's IP address.
If you're using the tapserver BBA or modem type, you can make it connect to a newserv instance running on the same machine via the tapserver interface. To do this:
1. In the GameCube pane of the Config window, set the SP1 device to Broadband Adapter (tapserver) or Modem Adapter (tapserver).
2. Set IPStackListen (for BBA) or PPPStackListen (for modem) according to the comments in config.json and start newserv.
2. Click the "..." button next to the SP1 menu. If you're using the tapserver BBA, enter `127.0.0.1:5059` in the box. If you're using the tapserver modem, enter `127.0.0.1:5058` in the box. (If newserv isn't running on the same machine as Dolphin, replace 127.0.0.1 with newserv's IP address.)
3. In PSO's network settings, enable DHCP ("Automatically obtain an IP address"), set DNS server address to "Automatic", and leave DHCP Hostname as "Not set". Leave the proxy server settings blank.
4. Start an online game.
### PSO BB
The PSO BB client has been modified and distributed in many different forms. newserv supports most, but not all, of the common distributions. Unlike other versions, it's important that the client and server have the same map files, so make sure to set up the patch directory based on the client you'll be using with newserv. (See the "Client patch directories" section for instructions on setting this up.)
The PSO BB client has been modified and distributed in many different forms. newserv supports most, but not all, of the common distributions. Unlike other versions, it's common for various BB clients to have different map files. It's important that the client and server have the same map files, so make sure to set up the patch directory based on the client you'll be using with newserv. (See the [client patch directories](#client-patch-directories) section for instructions on setting this up.)
The original Japanese and US versions of PSO BB work with newserv (the last Japanese release can be found [here](https://archive.org/details/psobb_jp_setup_12511_20240109/)). To get them to connect to your server, do one of the following:
* Use a drop-in patcher like [AzureFlare](https://github.com/Repflez/AzureFlare).
* Modify your hosts file to redirect the client's destination address to localhost or your server's address.
* Edit your hosts file to redirect the client's destination address to localhost or your server's address.
* Edit psobb.exe to point to your newserv instance. The original clients are packed with various versions of ASProtect, so this is a more involved process than simply opening the executable in a hex editor and finding/replacing some strings.
Alternatively, you can use the Tethealla client ([English](https://web.archive.org/web/20240402011115/https://ragol.org/files/bb/TethVer12513_English.zip) or [Japanese](https://web.archive.org/web/20240402013127/https://ragol.org/files/bb/TethVer12513_Japanese.zip)). If the server is on the same PC as the client and you don't plan to have any external players, these Tethealla clients will automatically connect to the server without any modifications. This version of the client is not packed, and you can find the connection addresses starting at 0x56D724 in psobb.exe. Overwrite these addresses with your server's hostname or IP address, and you should be able to connect.
Alternatively, you can use the Tethealla client ([English](https://web.archive.org/web/20240402011115/https://ragol.org/files/bb/TethVer12513_English.zip) or [Japanese](https://web.archive.org/web/20240402013127/https://ragol.org/files/bb/TethVer12513_Japanese.zip)). If the server is on the same PC as the client and you don't plan to have any external players, these Tethealla clients will automatically connect to the server without any modifications. This version of the client is not packed, and you can find the connection addresses starting at offset 0x56D724 in psobb.exe. Overwrite these addresses with your server's hostname or IP address, and you should be able to connect.
### Connecting external clients
### Allowing external players to connect
If you want to accept connections from outside your local network, you'll need to set ExternalAddress to your public IP address in the configuration file, and you'll likely need to open some ports in your router's NAT configuration - specifically, all the TCP ports listed in PortConfiguration in config.json.
@@ -270,12 +293,12 @@ Within the category directories, quest files should be named like `q###-VERSION-
For .dat files, the `LANGUAGE` token may be omitted. If it's present, then that .dat file will only be used for that language of the quest; if omitted, then that .dat file will be used for all languages of the quest.
Some quests (mostly battle and challenge mode quests) have additional JSON metadata files that describe how the server should handle them. This includes flags that can be used to hide the quest unless a preceding quest has been cleared, or to hide the quest unless purchased as a team reward. These metadata files are generally named similarly to their .bin and .dat counterparts, except the `VERSION` token may also be omitted if the metadata applies to all languages of the quest on all PSO versions. See system/quests/battle/b88001.json for documentation on the exact format of the JSON file.
For example, the GameCube version of Lost HEAT SWORD is in two files named `q058-gc-e.bin` and `q058-gc.dat`. newserv knows these files are quests because they're in the system/quests/ directory, it knows they're for PSO GC because the filenames contain `-gc`, it knows this is the English version of the quest because the .bin filename ends with `-e` (even though the .dat filename does not), and it puts them in the Retrieval category because the files are within the retrieval/ directory within system/quests/.
Some quests (mostly battle and challenge mode quests) have additional JSON metadata files that describe how the server should handle them. These files include flags that can be used to hide the quest unless a preceding quest has been cleared, or to hide the quest unless purchased as a BB team reward. These metadata files are generally named similarly to their .bin and .dat counterparts, except the `VERSION` token may also be omitted if the metadata applies to all languages of the quest on all PSO versions. See system/quests/battle/b88001.json for documentation on the exact format of the JSON file.
Some quests may also include a .pvr file, which contains an image used in the quest. These files are named similarly to their .bin and .dat counterparts.
For example, the GameCube version of Lost HEAT SWORD is in two files named `q058-gc-e.bin` and `q058-gc.dat`. newserv knows these files are quests because they're in the system/quests/ directory, it knows they're for PSO GC because the filenames contain `-gc`, it knows this is the English version of the quest because the .bin filename ends with `-e` (even though the .dat filename does not), and it puts them in the Retrieval category because the files are within the retrieval/ directory within system/quests/.
The GameCube and Xbox quest formats are very similar, but newserv treats them as different. If you want to use the same quest file for GameCube and Xbox clients, you can make one a symbolic link to the other.
There are multiple PSO quest formats out there; newserv supports all of them. It can also decode any known format to standard .bin/.dat format. Specifically:
@@ -303,7 +326,7 @@ There are multiple PSO quest formats out there; newserv supports all of them. It
1. *This is the default format. You can convert these to uncompressed format by running `newserv decompress-prs FILENAME.bin FILENAME.bind` (and similarly for .dat -> .datd)*
2. *Similar to (1), to compress an uncompressed quest file: `newserv compress-prs FILENAME.bind FILENAME.bin` (and likewise for .datd -> .dat)*
3. *Use the decode action to convert these quests to .bin/.dat format before putting them into the server's quests directory. If you know the encryption seed (serial number), pass it in as a hex string with the `--seed=` option. If you don't know the encryption seed, newserv will find it for you, which will likely take a long time.*
4. *Episode 3 quests don't go in the system/quests directory. See the Episode 3 section below.*
4. *Episode 3 quests don't go in the system/quests directory. See the [Episode 3 section](#episode-3-features) section below.*
5. *Quest source can be assembled into a .bin or .bind file with `newserv assemble-quest-script FILENAME.txt`. See system/quests/retrieval/q058-gc-e.bin.txt for an annotated example; this is the English GameCube version of Lost HEAT SWORD.*
Episode 3 download quests consist only of a .bin file - there is no corresponding .dat file. Episode 3 download quest files may be named with the .mnm extension instead of .bin, since the format is the same as the standard map files (in system/ep3/). These files can be encoded in any of the formats described above, except .qst.
@@ -317,13 +340,13 @@ Quest contents are cached in memory, but if you've changed the contents of the q
newserv supports server-side item generation on all game versions, except for the earliest DC prototypes (NTE and 11/2000). By default, the game behaves as it did on the original servers - on all versions except BB, item drops are controlled by the leader client in each game, and on BB, item drops are controlled by the server.
There are five different available behaviors for item drops:
* `DISABLED` (or `NONE`): No items will drop from boxes or enemies.
* `CLIENT`: The game leader generates items, all items are visible to all players, and any player may pick up any item. This is the default mode for all game versions, except this mode cannot be used on BB.
* `SERVER_SHARED`: The server generates items, all items are visible to all players, and any player may pick up any item. This is the default mode for BB.
* `SERVER_PRIVATE`: The server generates items, but each player may get a different item from any box or enemy. If a player isn't in the same area as an enemy at the time it's defeated, they won't get any item from it. Items dropped by players are visible to everyone.
* `SERVER_DUPLICATE`: The server generates items, and each player will get the same item from any box or enemy, but there is one copy of each item for each player (and each player only sees their own copy of the item). If a player isn't in the same area as an enemy at the time it's defeated, they won't get any item from it. Items dropped by players are not duplicated and are visible to everyone.
* `disabled` (or `none`): No items will drop from boxes or enemies.
* `client`: The game leader generates items, all items are visible to all players, and any player may pick up any item. This is the default mode for all game versions, except this mode cannot be used if the game leader is on BB.
* `shared`: The server generates items, all items are visible to all players, and any player may pick up any item. This is the default mode if the game leader is on BB.
* `private`: The server generates items, but each player may get a different item from any box or enemy. If a player isn't in the same area as an enemy at the time it's defeated, they won't get any item from it. Items dropped by players are visible to everyone.
* `duplicate`: The server generates items, and each player will get the same item from any box or enemy, but there is one copy of each item for each player (and each player only sees their own copy of the item). If a player isn't in the same area as an enemy at the time it's defeated, they won't get any item from it. Items dropped by players are not duplicated and are visible to everyone.
In the `SERVER_PRIVATE` and `SERVER_DUPLICATE` modes, there is no incentive to pick up items before another player, since other players cannot pick up the items you see dropped from boxes and enemies. However, if you pick up an item and drop it later, it can then be seen and picked up by any player.
In the `private` and `duplicate` modes, there is no incentive to pick up items before another player, since other players cannot pick up the items you see dropped from boxes and enemies. However, if you pick up an item and drop it later, it can then be seen and picked up by any player.
The drop mode can be changed at any time during a game with the `$dropmode` chat command. If the mode is changed after some items have already been dropped, the existing items retain their visibility (that is, items dropped in private mode still can't be picked up by other players since they were dropped before the mode was changed). You can configure which drop modes are used by default, and which modes players are allowed to choose, in config.json. See the comments above the AllowedDropModes and DefaultDropMode keys.
@@ -331,13 +354,18 @@ In the server drop modes, the item tables used to generate common items are in t
## Cross-version play
All versions of PSO can see and interact with each other in the lobby. newserv also allows some versions to play in-game with each other:
* DC V1 players can join DC V2 games if the difficulty level isn't set to Ultimate and the creator chose to allow V1 players.
* DC V2 players can join DC V1 games.
* If AllowDCPCGames is enabled in config.json, PC and DC players can join each other's games. DC V1 players cannot join PC games with the Ultimate difficulty level.
* If AllowGCXBGames is enabled in config.json, GC and Xbox players can join each other's games.
All versions of PSO can see and interact with each other in the lobby. By default, newserv allows V1 and V2 players to play together, and allows GC and Xbox players to play together. You can change these rules to allow all versions to play together, or to prevent versions from playing together, with the CompatibilityGroups setting in config.json.
In V1/V2 cross-version play, when any of the server drop modes are used, the server uses the drop table corresponding to the version the game was created with. (For example, if a DC V1 player created the game, rare-table-v1.json will be used, even after V2 players join.)
There are several cross-version restrictions that always apply regardless of the compatibility groups setting:
* DC V1 players cannot join DC V2 games if the game creator didn't choose to allow them.
* DC V1 players cannot join games if the difficulty level is set to Ultimate or the game mode is Battle or Challenge.
* Only GC, Xbox, and BB players can join games in Episode 2.
* Only BB players can join games in Episode 4.
* Episode 3 players cannot join non-Episode 3 games, and vice versa.
V1/V2 compatibility and GC/Xbox compatibility are well-tested, but other situations are not. Not much attention has been given yet to how items should be handled across major versions; if you enable V2/GC compatibility, for example, there will likely be bugs. Please report such bugs as GitHub issues.
In cross-version play, when any of the server drop modes are used, the server uses the drop tables corresponding to the leader's version and section ID. (For example, if a DC V1 player is the game leader, rare-table-v1.json will be used, even after V2 players join.) If a BB player is the leader and the `client` drop mode is used, the server generates items as if it were in `shared` mode.
## Server-side saves
@@ -349,7 +377,7 @@ There is a third command, `$bbchar <username> <password> <slot>`, which behaves
Exactly which data is saved and loaded depends on the game version:
| Game | Inventory | Character | Options/chats | Quest flags | Bank | Battle/challenge |
| Game | Inventory | Character | Options/chats | Quest flags | Bank | Battle/Challenge |
|----------------------|-----------|-----------|---------------|-------------|------|------------------|
| PSO DC v1 prototypes | Yes | Yes | No | No | No | N/A |
| PSO DC v1 | Yes | Yes | No | No | No | N/A |
@@ -409,52 +437,56 @@ Like quests, Episode 3 card definitions, maps, and quests are cached in memory.
*Everything in this section requires resource_dasm to be installed, so newserv can use the assemblers and disassemblers from its libresource_file library. If resource_dasm is not installed, newserv will still build and run, but these features will not be available.*
You can put assembly files in the system/client-functions directory with filenames like PatchName.VERS.patch.s and they will appear in the Patches menu for clients that support client functions. Client functions are written in SH-4, PowerPC, or x86 assembly and are compiled when newserv is started. The assembly system's features are documented in the comments in system/client-functions/System/WriteMemory.ppc.s.
You can put assembly files in the system/client-functions directory with filenames like PatchName.VERS.patch.s and they will appear in the Patches menu for clients that support client functions. Client functions are written in SH-4, PowerPC, or x86 assembly and are compiled when newserv is started. The assembly system's features are documented in the comments in system/client-functions/System/WriteMemoryGC.ppc.s.
The VERS token in client function filenames refers to the specific version of the game that the client function applies to. Some versions do not support receiving client functions at all. The specific versions are:
The VERS token in client function filenames refers to the specific version of the game that the client function applies to. Some versions do not support receiving client functions at all. *Note: newserv uses the shorter GameCube versioning convention, where discs labeled DOL-XXXX-0-0Y are version 1.Y. The PSO community seems to use the convention 1.0Y in some places instead, but these are the same version. For example, the version that newserv calls v1.4 is the same as v1.04, and is labeled DOL-GPOJ-0-04 on the underside of the disc.*
| Game | VERS | Architecture |
|-------------------|------|---------------|
| PSO DC NTE | 1OJ1 | Not supported |
| PSO DC 11/2000 | 1OJ2 | Not supported |
| PSO DC 12/2000 | 1OJ3 | Not supported |
| PSO DC 01/2001 | 1OJ4 | Not supported |
| PSO DC v1 JP | 1OJF | Not supported |
| PSO DC v1 US | 1OEF | Not supported |
| PSO DC v1 EU | 1OPF | Not supported |
| PSO DC 08/2001 | 2OJ5 | SH-4 |
| PSO DC v2 JP | 2OJF | SH-4 |
| PSO DC v2 US | 2OEF | SH-4 |
| PSO DC v2 EU | 2OPF | SH-4 |
| PSO PC (v2) | 2OJW | Not supported |
| PSO GC NTE | 3OJT | PowerPC |
| PSO GC v1.2 JP | 3OJ2 | PowerPC |
| PSO GC v1.3 JP | 3OJ3 | PowerPC |
| PSO GC v1.4 JP | 3OJ4 | PowerPC |
| PSO GC v1.5 JP | 3OJ5 | Not supported |
| PSO GC v1.0 US | 3OE0 | PowerPC |
| PSO GC v1.1 US | 3OE1 | PowerPC |
| PSO GC v1.2 US | 3OE2 | Not supported |
| PSO GC v1.0 EU | 3OP0 | PowerPC |
| PSO GC Ep3 NTE | 3SJT | PowerPC |
| PSO GC Ep3 JP | 3SJ0 | PowerPC |
| PSO GC Ep3 US | 3SE0 | Not supported |
| PSO GC Ep3 EU | 3SP0 | Not supported |
| PSO Xbox Beta | 4OJB | x86 |
| PSO Xbox JP Disc | 4OJD | x86 |
| PSO Xbox JP TU | 4OJU | x86 |
| PSO Xbox US Disc | 4OED | x86 |
| PSO Xbox US TU | 4OEU | x86 |
| PSO Xbox EU Disc | 4OPD | x86 |
| PSO Xbox EU TU | 4OPU | x86 |
| PSO BB JP 1.25.13 | 51OC | x86 |
| PSO BB Tethealla | 51OC | x86 |
The specific versions are:
*Note: newserv uses the shorter GameCube versioning convention, where discs labeled DOL-XXXX-0-0Y are version 1.Y. The PSO community seems to use the convention 1.0Y in some places instead, but these are the same version. For example, the version that newserv calls v1.4 is the same as v1.04, and is labeled DOL-GPOJ-0-04 on the underside of the disc.*
| Game | VERS | Architecture |
|------------------------------|------|---------------|
| PSO DC Network Trial Edition | 1OJ1 | Not supported |
| PSO DC 11/2000 prototype | 1OJ2 | Not supported |
| PSO DC 12/2000 prototype | 1OJ3 | Not supported |
| PSO DC 01/2001 prototype | 1OJ4 | Not supported |
| PSO DC v1 JP | 1OJF | Not supported |
| PSO DC v1 US | 1OEF | Not supported |
| PSO DC v1 EU | 1OPF | Not supported |
| PSO DC 08/2001 prototype | 2OJ5 | SH-4 |
| PSO DC v2 JP | 2OJF | SH-4 |
| PSO DC v2 US | 2OEF | SH-4 |
| PSO DC v2 EU | 2OPF | SH-4 |
| PSO PC (v2) | 2OJW | Not supported |
| PSO GC Trial Edition | 3OJT | PowerPC |
| PSO GC v1.2 JP | 3OJ2 | PowerPC |
| PSO GC v1.3 JP | 3OJ3 | PowerPC |
| PSO GC v1.4 (Plus) JP | 3OJ4 | PowerPC |
| PSO GC v1.5 (Plus) JP | 3OJ5 | PowerPC (1) |
| PSO GC v1.0 US | 3OE0 | PowerPC |
| PSO GC v1.1 US | 3OE1 | PowerPC |
| PSO GC v1.2 (Plus) US | 3OE2 | PowerPC (1) |
| PSO GC v1.0 EU | 3OP0 | PowerPC |
| PSO GC Ep3 Trial Edition | 3SJT | PowerPC |
| PSO GC Ep3 JP | 3SJ0 | PowerPC |
| PSO GC Ep3 US | 3SE0 | PowerPC (1) |
| PSO GC Ep3 EU | 3SP0 | PowerPC (1) |
| PSO Xbox Beta | 4OJB | x86 |
| PSO Xbox JP Disc | 4OJD | x86 |
| PSO Xbox JP TU | 4OJU | x86 |
| PSO Xbox US Disc | 4OED | x86 |
| PSO Xbox US TU | 4OEU | x86 |
| PSO Xbox EU Disc | 4OPD | x86 |
| PSO Xbox EU TU | 4OPU | x86 |
| PSO BB JP 1.25.11 | 59NJ | x86 |
| PSO BB JP 1.25.13 | 59NL | x86 |
| PSO BB Tethealla | 59NL | x86 |
newserv comes with a set of patches for some of the above versions, based on AR codes originally made by Ralf at GC-Forever and Aleron Ives. Many of them were originally posted in [this thread](https://www.gc-forever.com/forums/viewtopic.php?f=38&t=2050).
*Notes:*
1. *Client functions are only supported on these versions if EnableSendFunctionCallQuestNumbers is set in config.json. See the comments there for more information.*
You can also put DOL files in the system/dol directory, and they will appear in the Programs menu for GC clients. Selecting a DOL file there will load the file into the GameCube's memory and run it, just like the old homebrew loaders (PSUL and PSOload) did. For this to work, ReadMemoryWord.ppc.s, WriteMemory.ppc.s, and RunDOL.ppc.s must be present in the system/client-functions/System directory. This has been tested on Dolphin but not on a real GameCube, so results may vary.
newserv comes with a set of patches for many of the above versions, based on AR codes originally made by Ralf at GC-Forever and Aleron Ives. Many of them were originally posted in [this thread](https://www.gc-forever.com/forums/viewtopic.php?f=38&t=2050).
You can also put DOL files in the system/dol directory, and they will appear in the Programs menu for GC clients. Selecting a DOL file there will load the file into the GameCube's memory and run it, just like the old homebrew loaders (PSUL and PSOload) did. For this to work, ReadMemoryWordGC.ppc.s, WriteMemoryGC.ppc.s, and RunDOL.ppc.s must be present in the system/client-functions/System directory. This has been tested on Dolphin but not on a real GameCube, so results may vary.
Like other kinds of data, functions and DOL files are cached in memory. If you've changed any of these files, you can run `reload functions` or `reload dol-files` in the interactive shell to make the changes take effect without restarting the server.
@@ -474,17 +506,17 @@ There are many options available when starting a proxy session. All options are
* **Chat commands**: enables chat commands in the proxy session (on by default).
* **Chat filter**: enables escape sequences in chat messages and info board (on by default).
* **Player notifications**: shows a message when any player joins or leaves the game or lobby you're in.
* **Block pings**: blocks automatic pings sent by the client, and responds to ping commands from the server automatically. This works around a bug in Sylverant's login server.
* **Block pings**: blocks automatic pings sent by the client, and responds to ping commands from the server automatically.
* **Infinite HP**: automatically heals you whenever you get hit. An attack that kills you in one hit will still kill you, however.
* **Infinite TP**: automatically restores your TP whenever you use any technique.
* **Switch assist**: attempts to unlock doors that require two or four players in a one-player game.
* **Switch assist**: unlocks doors that require two or four players in a one-player game, when you step on one of the switches.
* **Infinite Meseta** (Episode 3 only): gives you 1,000,000 Meseta, regardless of the value sent by the remote server.
* **Block events**: disables holiday events sent by the remote server.
* **Block patches**: prevents any B2 (patch) commands from reaching the client.
* **Save files**: saves copies of several kinds of files when they're sent by the remote server. The files are written to the current directory (which is usually the directory containing the system/ directory). These kinds of files can be saved:
* Online quests and download quests (saved as .bin/.dat files)
* GBA games (saved as .gba files)
* Patches (saved as .bin files, and disassembled into PowerPC assembly if newserv is built with patch support)
* Patches (saved as .bin files, and disassembled to text files if newserv is built with patch support)
* Player data from BB sessions (saved as .bin files, which are not the same format as .nsc files)
* Episode 3 online quests and maps (saved as .mnmd files)
* Episode 3 download quests (saved as .mnm files)
@@ -512,17 +544,21 @@ Some commands only work on the game server and not on the proxy server. The chat
* `rare`: You are notified when a rare item drops.
* `on`: You are notified when any item drops, except Meseta.
* `every`: You are notified when any item drops, including Meseta.
* `$announcerares`: Enable or disable announcements for your rare item finds. This determines whether rare items you find will be announced to the game and server, not whether you will see announcements for others finding rare items.
* `$what` (game server only): Show the type, name, and stats of the nearest item on the ground.
* `$where` (game server only): Show your current floor number and coordinates. Mainly useful for debugging.
* `$qfread <field-name>` (game server only): Show the value of a quest counter in your player data. The field names are defined in config.json.
* Debugging commands
* `$debug` (game server only): Enable or disable debug. You need the DEBUG flag in your user account to use this command. Enabling debug does several things:
* You'll see in-game messages from the server when you take certain actions, like killing an enemy in BB.
* You'll see in-game messages from the server when you take some actions, like killing enemies, opening boxes, or flipping switches.
* You'll see the rare seed value and floor variations when you join a game.
* You'll be placed into the last available slot in lobbies and games instead of the first, unless you're joining a BB solo-mode game.
* You'll be able to join games with any PSO version, not only those for which crossplay is normally supported. Be prepared for client crashes and other client-side brokenness if you do this. Do not submit any issues for broken behaviors in crossplay, unless the situation is explicitly supported (see the "Cross-version play" section above).
* You'll be able to join games with any PSO version, not only those for which cross-version play is normally enabled. See the "Cross-version play" section above for details on this.
* The rest of the commands in this section are enabled on the game server. (They are always enabled on the proxy server.)
* `$readmem <address>` (game server only): Read 4 bytes from the given address and show you the values.
* `$writemem <address> <data>` (game server only): Write data to the given address. Data is not required to be any specific size.
* `$nativecall <address> [arg1 ...]` (game server only, GC only): Call a native function on your client. Only arguments passed in registers are supported; calling functions that take many arguments is not supported.
* `$quest <number>` (game server only): Load a quest by quest number. Can be used to load battle or challenge quests with only one player present. Debug is not required to be enabled if the specified quest has the AllowStartFromChatCommand field set in its metadata file.
* `$qcall <function-id>`: Call a quest function on your client.
* `$qcheck <flag-num>` (game server only): Show the value of a quest flag. This command can be used without debug mode enabled. If you're in a game, show the value of the flag in that game; if you're in the lobby, show the saved value of that quest flag for your character (BB only).
@@ -537,24 +573,22 @@ Some commands only work on the game server and not on the proxy server. The chat
* `$sc <data>`: Send a command to yourself.
* `$ss <data>`: Send a command to the remote server (if in a proxy session) or to the game server.
* `$sb <data>`: Send a command to yourself, and to the remote server or game server.
* `$meseta <amount>` (game server only; Episode 3 only): Add the given amount to your Meseta total.
* `$auction` (Episode 3 only): Bring up the CARD Auction menu, regardless of how many players are in the game or if you have a VIP card.
* `$ep3battledebug` (game server only; Episode 3 only): Enable or disable TCard00_Select. If enabled, the game will enter the debug menu when you start a battle.
* Personal state commands
* `$arrow <color-id>`: Change your lobby arrow color.
* `$secid <section-id>`: Set your override section ID. After running this command, any games you create will use your override section ID for rare drops instead of your character's actual section ID. If you're in a game and you are the leader of the game, this also immediately changes the item tables used by the server when creating items. To revert to your actual section id, run `$secid` with no name after it. On the proxy server, this will not work if the remote server controls item drops (e.g. on BB, or on Schtserv with server drops enabled). If the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing.
* `$secid <section-id>`: Set your override section ID. After running this command, any games you create will use your override section ID for rare drops instead of your character's actual section ID. If you're in a game and you are the leader of the game, this also immediately changes the item tables used by the server when creating items. To revert to your actual section id, run `$secid` with no name after it. On the proxy server, this will not work if the remote server controls item drops. If the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing.
* `$rand <seed>`: Set your override random seed (specified as a 32-bit hex value). This will make any games you create use the given seed for rare enemies. This also makes item drops deterministic in Blue Burst games hosted by newserv. On the proxy server, this command can cause desyncs with other players in the same game, since they will not see the overridden random seed. To remove the override, run `$rand` with no arguments. If the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing.
* `$ln [name-or-type]`: Set the lobby number. Visible only to you. This command exists because some non-lobby maps can be loaded as lobbies with invalid lobby numbers. See the "GC lobby types" and "Ep3 lobby types" entries in the information menu for acceptable values here. Note that non-lobby maps do not have a lobby counter, so there's no way to exit the lobby without using either `$ln` again or `$exit`. On the game server, `$ln` reloads the lobby immediately; on the proxy server, it doesn't take effect until you load another lobby yourself (which means you'll like have to use `$exit` to escape). Run this command with no argument to return to the default lobby.
* `$swa`: Enable or disable switch assist. When enabled, the server will attempt to automatically unlock two-player and four-player doors in non-quest games if you step on all the required switches sequentially.
* `$swa`: Enable or disable switch assist. When enabled, the server will unlock two-player and four-player doors in non-quest games when you step on any of the required switches.
* `$exit`: If you're in a lobby, send you to the main menu (which ends your proxy session, if you're in one). If you're in a game or spectator team, send you to the lobby (but does not end your proxy session if you're in one). Does nothing if you're in a non-Episode 3 game and no quest is in progress.
* `$patch <name>`: Run a patch on your client. `<name>` must exactly match the name of a patch on the server.
* Character data commands (game server only)
* `$savechar <slot>`: Save your current character data on the server in the specified slot. See the "Server-side saves" section for more details.
* `$loadchar <slot>`: Save your current character data on the server in the specified slot. See the "Server-side saves" section for more details.
* `$bbchar <username> <password> <slot>`: Save your current character data on the server in a different account's BB character slots. See the "Server-side saves" section for more details.
* `$edit <stat> <value>`: Modify your character data. See "Using $edit" below for details.
* `$savechar <slot>`: Save your current character data on the server in the specified slot. See the [server-side saves section](#server-side-saves) for more details.
* `$loadchar <slot>`: Save your current character data on the server in the specified slot. See the [server-side saves section](#server-side-saves) for more details.
* `$bbchar <username> <password> <slot>`: Save your current character data on the server in a different account's BB character slots. See the [server-side saves section](#server-side-saves) for more details.
* `$edit <stat> <value>`: Modify your character data. See the [using $edit](#using-edit) section for details.
* Blue Burst player commands (game server only)
* `$bank [number]`: Switch your current bank, so you can access your other character's banks (if `number` is 1-4) or your shared account bank (if `number` is 0). If `number` is not given, switch back to your current character's bank.
@@ -564,15 +598,15 @@ Some commands only work on the game server and not on the proxy server. The chat
* `$maxlevel <level>`: Set the maximum level for players to join the current game. (This only applies when joining; if a player joins and then levels up past this level during the game, they are not kicked out, but won't be able to rejoin if they leave.)
* `$minlevel <level>`: Set the minimum level for players to join the current game.
* `$password <password>`: Set the game's join password. To unlock the game, run `$password` with nothing after it.
* `$dropmode [mode]`: Change the way item drops behave in the current game. `mode` can be `none`, `client`, `shared`, `private`, or `duplicate`. If `mode` is not given, tells you the current drop mode without changing it. See the "Item tables and drop modes" section for more information.
* `$persist`: Enable or disable persistence for the current game. When persistence is on, the game will not be deleted when the last player leaves. The states of enemies, objects, and switches will be saved, and items left on the floor will not be deleted (except items that were only visible to the leaving player, which are deleted). If the game is empty for too long (15 minutes by default), it is then deleted. There is an edge case with persistence: if the player defeats a boss, leaves the room, joins again, and returns to the boss arena, neither the boss nor the exit warp will appear, so they will be stuck there and have to use $warp or Quit Game to get out. For this reason, `$warp 0` is allowed in boss arenas once the boss is defeated, even if cheat mode is disabled.
* `$dropmode [mode]`: Change the way item drops behave in the current game. `mode` can be `none`, `client`, `shared`, `private`, or `duplicate`. If `mode` is not given, tells you the current drop mode without changing it. See the [item tables and drop modes section](#item-tables-and-drop-modes) for more information.
* `$persist`: Enable or disable persistence for the current game. When persistence is on, the game will not be deleted when the last player leaves. The states of enemies, objects, and switches will be saved, and items left on the floor will not be deleted. (But if you're in the private or duplicate drop mode, items dropped by enemies are deleted - to make sure a certain item won't be deleted, you can pick it up and drop it again.) If the game is empty for too long (15 minutes by default), it is then deleted.
* Episode 3 commands (game server only)
* `$spec`: Toggle the allow spectators flag for Episode 3 games. If any players are spectating when this flag is disabled, they are sent back to the lobby.
* `$inftime`: Toggle infinite-time mode. Must be used before starting a battle. If infinite-time mode is on, the overall and per-phase time limits will be disabled regardless of the values chosen during battle rules setup. After completing a battle, infinite-time mode is reset to the server's default value (which can be set in Episode3BehaviorFlags in config.json).
* `$dicerange [d:L-H] [1:L-H] [a1:L-H] [d1:L-H]`: Set override dice ranges for the next battle. The min and max dice values from the rules setup menu always apply to the ATK dice, but you can specify a different range for the DEF dice with `d:2-4` (for example). The `1:` override applies to the 1-player team in a 2v1 game (so you would set the 2-player team's desired dice range in the rules menu). You can also specify the 1-player team's ATK and DEF ranges separately with the `a1:` and `d1:` overrides. Note that these ranges will only be used if the chosen map or quest does not override them.
* `$stat <what>`: Show a statistic about your player or team in the current battle. `<what>` can be `duration`, `fcs-destroyed`, `cards-destroyed`, `damage-given`, `damage-taken`, `opp-cards-destroyed`, `own-cards-destroyed`, `move-distance`, `cards-set`, `fcs-set`, `attack-actions-set`, `techs-set`, `assists-set`, `defenses-self`, `defenses-ally`, `cards-drawn`, `max-attack-damage`, `max-combo`, `attacks-given`, `attacks-taken`, `sc-damage`, `damage-defended`, or `rank`.
* `$surrender`: Cause your team to immediately lose the current battle.
* `$surrender`: Cause your team to immediately lose the current battle. If your story character is already defeated, you can't surrender - only your teammate can.
* `$saverec <name>`: Save the recording of the last battle.
* `$playrec <name>`: Play a battle recording. This command creates a spectator team immediately but the replay does not start automatically, to give other players a chance to join. To start the battle replay within the spectator team, run `$playrec` again (with no name). There is a bug in Dolphin that makes this command unstable in emulation (see the "Battle records" section above).
@@ -593,9 +627,8 @@ Some commands only work on the game server and not on the proxy server. The chat
* `$song <song-id>` (Episode 3 only): Play a specific song in the current lobby.
* Administration commands (game server only)
* `$ann <message>`: Send an announcement message. The message is sent as temporary on-screen text to all players in all games and lobbies.
* `$ann! <message>`: Send an announcement message. The message is sent as a Simple Mail message to all players in all games and lobbies.
* `$ax <message>`: Send a message to the server's terminal. This cannot be used to run server shell commands; it only prints text to stderr.
* `$ann <message>`: Send an announcement message. The message is sent as temporary on-screen text to all players in all games and lobbies. On BB, the message appears in the scrolling top bar.
* `$ann!`, `$ann?`, `$ann?!`: Same as `$ann`, but with `?`, omits the sender's name, and with `!`, sends the message as a Simple Mail message instead of on-screen text.
* `$silence <identifier>`: Silence a player (remove their ability to chat) or unsilence a player. The identifier may be the player's name or Guild Card number.
* `$kick <identifier>`: Disconnect a player. The identifier may be the player's name or Guild Card number.
* `$ban <duration> <identifier>`: Ban a player. The duration should be of the form `10m` (minutes), `10h` (hours), `10d` (days), `10w` (weeks), `10M` (months), or `10y` (years). (Numbers other than 10 may be used, of course.) As with `$kick`, the identifier may be the player's name or Guild Card number.
@@ -617,7 +650,11 @@ Some subcommands are always available. They are:
* `$edit namecolor AARRGGBB`: Set your name color (AARRGGBB specified in hex)
* `$edit language L`: Set your language (Generally only useful on BB; values for L: J = Japanese, E = English, G = German, F = French, S = Spanish, B = Simplified Chinese, T = Traditional Chinese, K = Korean)
* `$edit name NAME`: Set your character name
* `$edit npc NPC-NAME`: Set or remove an NPC skin on your character (NPC-NAME can be ninja, rico, sonic, knuckles, tails, flowen, elly, or none)
* `$edit npc NPC-NAME`: Set or remove an NPC skin on your character (use `none` to remove a skin). The NPC names are:
* On all versions except DCv1 and early prototypes: `ninja`, `rico`, `sonic`, `knuckles`, `tails`
* On GC, Xbox, and BB: `flowen`, `elly`
* On BB only: `momoka`, `irene`, `guild`, `nurse`
* `$edit secid SECID-NAME`: Set your section ID (cheat mode is required unless your character is Level 1)
The remaining subcommands are only available if cheat mode is enabled on the server. They are:
* `$edit atp N`: Set your ATP to N until stats are updated (e.g. by leveling up)
@@ -626,45 +663,94 @@ The remaining subcommands are only available if cheat mode is enabled on the ser
* `$edit dfp N`: Set your DFP to N until stats are updated
* `$edit ata N`: Set your ATA to N until stats are updated
* `$edit lck N`: Set your LCK to N until stats are updated
* `$edit hp N`: Set your MST to N until stats are updated
* `$edit hp N`: Set your HP to N until stats are updated
* `$edit meseta N`: Set the amount of Meseta in your inventory
* `$edit exp N`: Set your total amount of EXP (does not affect level)
* `$edit level N`: Set your current level (recomputes stats, but does not affect EXP)
* `$edit secid SECID-NAME`: Set your section ID
* `$edit tech TECH-NAME LEVEL`: Set the level of one of your techniques
## REST API
newserv has an optional HTTP server that provides a way to programmatically get data from the server in realtime. This is intended for use with external integrations; for example, a web site could query this API to get the current player count to display on the home page.
The HTTP server is disabled by default, and you have to explicitly enable it in config.json if you want this functionality. **If you enable it, make sure that the HTTP port can't be accessed from the public Internet.** The API provides a lot of internal data about players and games, and it should only be accessed by programs that you've written or that you trust.
To enable the HTTP server, add a port number in the HTTPListen list in config.json. The HTTP server will listen on that port.
All returned data is JSON-encoded, and all request data (for POST requests) must also be JSON-encoded with the `Content-Type: application/json` header.
The HTTP server has the following endpoints:
* `GET /`: Returns the server's build date and revision.
* `GET /y/data/ep3-cards`: Returns the Episode 3 card definitions.
* `GET /y/data/ep3-cards-trial`: Returns the Episode 3 Trial Edition card definitions.
* `GET /y/data/common-tables`: Returns the parameters for generating common items (ItemPT files). This endpoint returns a lot of data and can be slow!
* `GET /y/data/rare-tables`: Returns a list of rare table names.
* `GET /y/data/rare-tables/<TABLE-NAME>` (for example, `/y/data/rare-tables/rare-table-v4`): Returns the contents of a rare item table.
* `GET /y/data/quests`: Returns metadata about all available quests and quest categories.
* `GET /y/data/config`: Returns the server's configuration file.
* `GET /y/accounts`: Returns information about all registered accounts.
* `GET /y/clients`: Returns information about all connected clients on the game server.
* `GET /y/proxy-clients`: Returns information about all connected clients on the proxy server.
* `GET /y/lobbies`: Returns information about all lobbies and games.
* `GET /y/server`: Returns information about the server.
* `GET /y/summary`: Returns a summary of the server's state, connected clients, active games, and proxy sessions.
* `WS /y/rare-drops/stream`: WebSocket endpoint that sends messages whenever an announceable rare item is dropped in any game. See below.
* `POST /y/shell-exec`: Runs a server shell command. Input should be a JSON dict of e.g. `{"command": "announce hello"}`; response will be a JSON dict of `{"result": "<result text>"}` or an HTTP error.
### Rare drop stream endpoint
The `/y/rare-drops/stream` endpoint provides a way to implement a drop log in e.g. Discord. For every announceable rare item, a message is sent to all connected clients on this endpoint. (Announceable rare items are items for which an in-game or server-wide text message is sent announcing the find.)
Upon connecting, you'll get the message `{"ServerType": "newserv"}`. After that, when a rare item announcement is sent, you'll get a message like this:
```
{
"PlayerAccountID", 12345,
"PlayerName", "SONIC",
"PlayerVersion", "GC_V3",
"GameName", "ttf",
"GameDropMode", "SERVER_PRIVATE",
"ItemData", "03000000 00010000 00000000 (0021002C) 00000000",
"ItemDescription", "Monomate x1",
"NotifyGame", true,
"NotifyServer", false,
}
```
# Non-server features
newserv has many CLI options, which can be used to access functionality other than the game and proxy server. Run `newserv help` to see a full list of the options and how to use each one.
The data formats that newserv can convert to/from are:
| Format | Encode/compress action | Decode/extract action |
|--------------------------------|---------------------------|------------------------------|
| PRS compression | `compress-prs` | `decompress-prs` |
| PR2/PRC compression | `compress-pr2` | `decompress-pr2` |
| BC0 compression | `compress-bc0` | `decompress-bc0` |
| Raw encrypted data | `encrypt-data` | `decrypt-data` |
| Episode 3 command mask | `encrypt-trivial-data` | `decrypt-trivial-data` |
| Challenge Mode rank text | `encrypt-challenge-data` | `decrypt-challenge-data` |
| PSO DC quest file (.vms) | None | `decode-vms` |
| PSO GC quest file (.gci) | None | `decode-gci` |
| Download quest file (.dlq) | None | `decode-dlq` |
| Server quest file (.qst) | `encode-qst` | `decode-qst` |
| PSO PC save file | `encrypt-pc-save` | `decrypt-pc-save` |
| PSO GC save file (.gci) | `encrypt-gci-save` | `decrypt-gci-save` |
| PSO GC snapshot file | None | `decode-gci-snapshot` |
| Quest script (.bin) | `assemble-quest-script` | `disassemble-quest-script` |
| Quest map (.dat) | None | `disassemble-quest-map` |
| AFS archive | None | `extract-afs` |
| BML archive | None | `extract-bml` |
| GSL archive | None | `extract-gsl` |
| GVM texture | `encode-gvm` | None |
| Text archive | `encode-text-archive` | `decode-text-archive` |
| Unicode text set | `encode-unicode-text-set` | `decode-unicode-text-set` |
| Word Select data set | None | `decode-word-select-set` |
| Set data table | None | `disassemble-set-data-table` |
| Rare item table (AFS/GSL/JSON) | `convert-rare-item-set` | `convert-rare-item-set` |
| Format | Encode/compress action | Decode/extract action |
|-------------------------------------|---------------------------|------------------------------|
| PRS compression | `compress-prs` | `decompress-prs` |
| PR2/PRC compression | `compress-pr2` | `decompress-pr2` |
| BC0 compression | `compress-bc0` | `decompress-bc0` |
| Raw encrypted data | `encrypt-data` | `decrypt-data` |
| Episode 3 command mask | `encrypt-trivial-data` | `decrypt-trivial-data` |
| Challenge Mode rank text | `encrypt-challenge-data` | `decrypt-challenge-data` |
| PSO DC quest file (.vms) | None | `decode-vms` |
| PSO GC quest file (.gci) | None | `decode-gci` |
| Download quest file (.dlq) | None | `decode-dlq` |
| Server quest file (.qst) | `encode-qst` | `decode-qst` |
| PSO DC save file (.vms) | `encrypt-vms-save` | `decrypt-vms-save` |
| PSO PC save file | `encrypt-pc-save` | `decrypt-pc-save` |
| PSO GC save file (.gci) | `encrypt-gci-save` | `decrypt-gci-save` |
| PSO GC snapshot file | None | `decode-gci-snapshot` |
| Quest script (.bin) | `assemble-quest-script` | `disassemble-quest-script` |
| Quest map (.dat) | None | `disassemble-quest-map` |
| AFS archive (.afs) | None | `extract-afs` |
| BML archive (.bml) | None | `extract-bml` |
| PPK archive (.ppk) | None | `extract-ppk` |
| GSL archive (.gsl) | `generate-gsl` | `extract-gsl` |
| GVM texture (.gvm) | `encode-gvm` | None |
| Bitmap font (.fon) | `encode-bitmap-font` | `decode-bitmap-font` |
| Text archive | `encode-text-archive` | `decode-text-archive` |
| Unicode text set | `encode-unicode-text-set` | `decode-unicode-text-set` |
| Word Select data set | None | `decode-word-select-set` |
| Set data table | None | `disassemble-set-data-table` |
| Rare item table (AFS/GSL/JSON/HTML) | `convert-rare-item-set` | `convert-rare-item-set` |
There are several actions that don't fit well into the table above, which let you do other things:
@@ -673,7 +759,111 @@ There are several actions that don't fit well into the table above, which let yo
* Run a brute-force search for a decryption seed (`find-decryption-seed`)
* Format Episode 3 game data in a human-readable manner (`show-ep3-maps`, `show-ep3-cards`, `generate-ep3-cards-html`)
* Format Blue Burst battle parameter files in a human-readable manner (`show-battle-params`)
* Search for rare enemy seeds that result in rare enemies on console versions (`find-rare-enemy-seeds`)
* Convert item data to a human-readable description, or vice versa (`describe-item`)
* Connect to another PSO server and pretend to be a client (`cat-client`)
* Generate or describe DC serial numbers (`generate-dc-serial-number`, `inspect-dc-serial-number`)
# Docker
Docker is new and mostly unsupported at this time. However, here are some best-effort steps to build and run in a docker container on Ubuntu Linux.
Tested on Ubuntu 22.04.4 LTS.
Note: You cannot have anything except this docker container using port 53 (DNS) on your server.
Install prerequisites
```
sudo apt install -y git
sudo apt install -y cmake. ## minimum version is 3.10. Check installed version with "cmake --version"
```
Clone repository
```
cd ~
git clone https://github.com/fuzziqersoftware/newserv/
cd ~/newserv
```
Build newserv. This will take a while. Don't forget the period at the end!
```
sudo docker build -t newserv .
```
Create persistent directories. Assuming you want to store the persistent data in your home directory
```
mkdir ~/newservPersist
mkdir ~/newservPersist/players
mkdir ~/newservPersist/teams
mkdir ~/newservPersist/licenses
```
Copy config file to config dir
```
cp ~/newserv/system/config.example.json ~/newservPersist/config.json
```
Edit config.json
```
nano ~/newservPersist/config.json
```
Pro tip:
Set "LocalAddress" to the static, LAN IP address of your server. If your server LAN IP is "192.168.0.10":
"LocalAddress": "192.168.0.10",
Set "ExternalAddress" to the WAN IP address of your network. If your WAN IP is "8.8.8.8":
"ExternalAddress": "8.8.8.8",
For Dolphin > Settings. Set SP1 to "Broadband Adapter (HLE)" Click [...] next to this, and set the DNS to the IP address of your server. Then start the game. Changes will not take affect if the game is running.
Docker run. Remember to change /home/changeme/newservPersist to your persistent directory. Do not use aliases such as '~'
```
docker run --name newserv -p 53:53/udp -p 5100:5100 -p 5110:5110 -p 5111:5111 -p 5112:5112 -p 9064:9064 -p 9100:9100 -p 9103:9103 -p 9300:9300 -p 11000:11000 -p 12000:12000 -p 12004:12004 -p 12005:12005 -v /etc/localtime:/etc/localtime:ro -v /home/changeme/newservPersist/config.json:/newserv/system/config.json -v /home/changeme/newservPersist/players:/newserv/system/players -v /home/changeme/newservPersist/teams:/newserv/system/teams -v /home/changeme/newservPersist/licenses:/newserv/system/licenses --restart no newserv:latest
```
Docker run host network mode. Remember to change /home/changeme/newservPersist to your persistent directory. Do not use aliases such as '~'
```
docker run --net host --name newserv -v /etc/localtime:/etc/localtime:ro -v /home/changeme/newservPersist/config.json:/newserv/system/config.json -v /home/changeme/newservPersist/players:/newserv/system/players -v /home/changeme/newservPersist/teams:/newserv/system/teams -v /home/changeme/newservPersist/licenses:/newserv/system/licenses --restart no newserv:latest
```
Docker compose. Remember to change /home/changeme/newservPersist to your persistent directory. Do not use aliases such as '~'
```
name: psonewserv
services:
newserv:
container_name: newserv
ports:
- 53:53/udp
- 5100:5100
- 5110:5110
- 5111:5111
- 5112:5112
- 9064:9064
- 9100:9100
- 9103:9103
- 9300:9300
- 11000:11000
- 12000:12000
- 12004:12004
- 12005:12005
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/changeme/newservPersist/config.json:/newserv/system/config.json
- /home/changeme/newservPersist/players:/newserv/system/players
- /home/changeme/newservPersist/teams:/newserv/system/teams
- /home/changeme/newservPersist/licenses:/newserv/system/licenses
restart: no ## Set to whatever you want.
image: newserv:latest
```
Docker compose host network mode. Remember to change /home/changeme/newservPersist to your persistent directory. Do not use aliases such as '~'
```
name: psonewserv
services:
newserv:
container_name: newserv
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/changeme/newservPersist/config.json:/newserv/system/config.json
- /home/changeme/newservPersist/players:/newserv/system/players
- /home/changeme/newservPersist/teams:/newserv/system/teams
- /home/changeme/newservPersist/licenses:/newserv/system/licenses
restart: no ## Set to whatever you want.
network_mode: host
image: newserv:latest
```
-1
View File
@@ -1,6 +1,5 @@
## General
- Implement decrypt/encrypt actions for VMS files
- Make UI strings localizable (e.g. entries in menus, welcome message, etc.)
- Add an idle connection timeout for proxy sessions
- Clean up ItemParameterTable implementation (see comment at the top of the class definition)
+645 -317
View File
File diff suppressed because it is too large Load Diff
+80
View File
@@ -0,0 +1,80 @@
000F04 LOGiN
006E00 GAME MAGAZNE
00AD00 RAGE DE FEU
00AD01 RAGE DE FEU
00AD02 RAGE DE FEU
00D000 UNKNOWN3
00D100 UNKNOWN4
01013D KROE'S SWEATER
01013F SONICTEAM ARMOR
010230 HUNTER'S SHELL
010233 HUNTER'S SHELL
010234 HUNTER'S SHELL
010236 Barrier
010237 Barrier
010238 Barrier
010239 Barrier
010253 BLUE RING
010254 BLUE RING
010255 BLUE RING
010256 BLUE RING
010257 BLUE RING
010258 BLUE RING
01025A BLUE RING
01025B GREEN RING
01025C GREEN RING
01025D GREEN RING
01025E GREEN RING
010260 GREEN RING
010261 GREEN RING
010262 GREEN RING
010263 YELLOW RING
010264 YELLOW RING
010265 YELLOW RING
010267 YELLOW RING
010268 YELLOW RING
010269 YELLOW RING
01026A YELLOW RING
01026B PURPLE RING
01026D PURPLE RING
01026E PURPLE RING
01026F PURPLE RING
010270 PURPLE RING
010271 PURPLE RING
010272 PURPLE RING
010274 WHITE RING
010276 WHITE RING
010277 WHITE RING
010278 WHITE RING
010279 WHITE RING
01027A WHITE RING
01027C BLACK RING
01027D BLACK RING
01027E BLACK RING
01027F BLACK RING
010281 BLACK RING
01029A UNKNOWN_B
024300 \n
024A00 Yahoo!
024D00 Cell of MAG 0503
024E00 Cell of MAG 0504
024F00 Cell of MAG 0505
025000 Cell of MAG 0506
025100 Cell of MAG 0507
03120B New Year's Card
03120C Christmas Card
03120D Birthday Card
03120E Proof of Sonic Team
03120F Special Event Ticket
03140A Bouquet
03140B Decoction
031603 DISK Vol.4 "Open Your Heart"
031604 DISK Vol.5 "Live & Learn"
031801 UNKNOWN2
031808 Yahoo!'s engine
03180B Cell of MAG 0503
03180C Cell of MAG 0504
03180D Cell of MAG 0505
03180E Cell of MAG 0506
03180F Cell of MAG 0507
200000 (invalid item code)
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
entry counter flags
01 = rules have any non-default values
02 = map number is set
04 = UNKNOWN (something to do with deck selection/verification)
08 = tournament mode (set by 6xB4x3D; shows timer in battle select menu and skips map select and rule select)
10 = UNKNOWN (used by 6xB5x43)
20 = command DC received
40 = tournament result available (6xB4x51 received)
+1 -1
View File
@@ -27,7 +27,7 @@ List of differences in Ep3 NTE compared to Final:
- - Ability Trap prevents all abnormal conditions
- Traps
- - Traps trigger as soon as you move into their tile; on Final, they trigger at the end of the Move phase
- - Traps may use any assist card, and this can be configured in the map definition (TODO: verify this last part)
- - Traps may use any assist card, and this can be configured in the map definition
- Rules
- - Dice Boost does not exist
- - ATK and DEF dice ranges can be set independently, but there are only 7 options for each: 1-6, 1-1, 2-2, 3-3, 4-4, 5-5, 6-6
+18
View File
@@ -0,0 +1,18 @@
Ep1 Ep2
1 Forest 1 Temple
2 Forest 2 Temple
3 Cave 1 Spaceship
4 Cave 2 Spaceship
5 Cave 3 CCA
6 Mine 1 Jungle
7 Mine 2 Jungle
8 Ruins 1 (broken) Mountain
9 Ruins 2 (broken) Seaside
10 Ruins 3 (broken) Void (Seabed doors + Mine music)
11 Dragon Void (doors + Dolmolm + Mine music)
12 De Rol Le Gal Gryphon
13 Vol Opt Olga Flow (unfinished, Flow does no damage)
14 void (Falz music) Barba Ray (unfinished)
15 Lobby Gol Dragon (unfinished)
16 Versus1 crash
17 Versus2 crash
+3 -13
View File
@@ -5,17 +5,7 @@ import sys
from dataclasses import dataclass
version_tokens = ("JP12", "JP13", "JP14", "JP15", "US10", "US11", "US12", "EU")
version_to_specific_version = {
"JP12": "3OJ2",
"JP13": "3OJ3",
"JP14": "3OJ4",
"JP15": "3OJ5",
"US10": "3OE0",
"US11": "3OE1",
"US12": "3OE2",
"EU": "3OP0",
}
version_tokens = ("3OJ2", "3OJ3", "3OJ4", "3OJ5", "3OE0", "3OE1", "3OE2", "3OP0")
@dataclass
@@ -60,7 +50,7 @@ def write_patches_for_code(
if write_regions:
filename = os.path.join(
out_dir,
f'{name.replace(" ", "")}.{version_to_specific_version[v]}.patch.s',
f'{name.replace(" ", "")}.{v}.patch.s',
)
with open(filename, "wt") as f:
if long_name is not None:
@@ -144,7 +134,7 @@ def main():
| (data[z + 2] << 8)
| (data[z + 3] << 0)
)
elif line.startswith("JP12------------"):
elif line.startswith("3OJ2------------"):
reading_code = True
else:
code_name = line
+928 -913
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
patch required in TethVer12513 to get this to work: 0048210D EB
is_hangame callsites:
0040457C - ??? (something in TDataProtocol?)
004820F4 - client version check (use patch above to bypass)
00708318 - patch server domain name
00708348 - patch server port
0070852C - ep4 unlocked setting (always true for hangame)
007085F4 - data server domain name
00708670 - data server port
007618E3 - whether to save user/pass to registry
00761C4C - create title screen menu (only shows Start Game and Exit Game in Hangame mode)
007623B0 - input password length limit?? (does nothing, since both branches of if statement lead to same result)
00762530 - registry account data access
00762708 - input password length limit?? (does nothing, since both branches of if statement lead to same result)
0076296F - input username length limit?? (limits to 12 instead of 16)
00762C30 - input username length limit?? (limits to 12 instead of 16)
00762D00 - password length limit again??
00762D2C - username length limit again??
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+69 -69
View File
@@ -21,7 +21,7 @@ Common Bank Patch
CommonBank
*** name=Common bank
*** desc=Hold L and open\nthe bank to use a\ncommon bank stored\nin temp character\n3's data
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 8000BAB4 281B0002 cmplwi r27, 2
8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 8000BAB8 40820018 bne +0x00000018 /* 8000BAD0 */
8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 8000BABC 3C008000 lis r0, 0x8000
@@ -71,7 +71,7 @@ Item Loss Prevention
ItemLossPrevention
*** name=No item loss
*** desc=Don't lose items if\nyou don't log off\nnormally
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801D33E4 4800004C 801D38EC 4800004C 801D3CC4 4800004C 801D39B8 4800004C 801D381C 4800004C 801D381C 4800004C 801D3A1C 4800004C 801D3ED8 4800004C b +0x0000004C /* 801D3868 */
801FE900 60000000 801FF174 60000000 8020010C 60000000 801FF710 60000000 801FF0FC 60000000 801FF0FC 60000000 801FFA44 60000000 801FF9E0 60000000 nop
801FFE5C 60000000 802006D0 60000000 802016CC 60000000 80200C9C 60000000 80200658 60000000 80200658 60000000 80200FD0 60000000 80200F3C 60000000 nop
@@ -83,7 +83,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Palette
*** name=Palette
*** desc=Press Z to cycle\nthrough 4 customize\nconfigs instead of of\njust one
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 8000CD00 3C808000 lis r4, 0x8000
8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E 8000CD04 6084CF3E ori r4, r4, 0xCF3E
8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 8000CD08 3BE00000 li r31, 0x0000
@@ -123,7 +123,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
"Palette Patch" Part 2
Palette
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 8000CD8C 38600003 li r3, 0x0003
8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 8000CD90 3C808001 lis r4, 0x8001
8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 8000CD94 B064CF78 sth [r4 - 0x3088], r3
@@ -159,7 +159,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
"Palette Patch" Part 3 (this part adds PBs to the customize list)
Palette
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 8000CA40 28030000 cmplwi r3, 0
8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 8000CA44 40820008 bne +0x00000008 /* 8000CA4C */
8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 8000CA48 3BE00000 li r31, 0x0000
@@ -195,12 +195,12 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
"Palette Patch" Part 4 (this disables PBs from overtaking the back palette)
Palette
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801B55F8 38600000 801B5A4C 38600000 801B7BB8 38600000 801B5B18 38600000 801B59E4 38600000 801B59E4 38600000 801B5B7C 38600000 801B6038 38600000 li r3, 0x0000
"Palette Patch" Part 5 (saves palettes to temp slot 3)
Palette
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000B958 906DB93C 8000B958 906DB944 8000B958 906DB964 8000B958 906DB964 8000B958 906DB954 8000B958 906DB954 8000B958 906DB974 8000B958 906DB9B4 stw [r13 - 0x46AC], r3
8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C 8000B95C 1C63003C mulli r3, r3, 60
8000B960 808DB920 8000B960 808DB928 8000B960 808DB948 8000B960 808DB948 8000B960 808DB938 8000B960 808DB938 8000B960 808DB958 8000B960 808DB998 lwz r4, [r13 - 0x46C8]
@@ -244,7 +244,7 @@ Decoction Patch (makes the Decoction item wipe non-HP/TP materials)
Decoction
*** name=Decoction
*** desc=Make the Decoction\nitem reset your\nmaterial usage
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80350740 880300EE 80351B44 880300EE 803530A0 880300EE 80352E54 880300EE 803515F4 880300EE 80351638 880300EE 80353220 880300EE 80352614 880300EE lbz r0, [r3 + 0x00EE]
80350744 2800000B 80351B48 2800000B 803530A4 2800000B 80352E58 2800000B 803515F8 2800000B 8035163C 2800000B 80353224 2800000B 80352618 2800000B cmplwi r0, 11
80350748 40820144 80351B4C 40820144 803530A8 40820144 80352E5C 40820144 803515FC 40820144 80351640 40820144 80353228 40820144 8035261C 40820144 bne +0x00000144 /* 80351740 */
@@ -288,19 +288,19 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Movement
*** name=Movement
*** desc=Allow backsteps and\nmovement when\nenemies are\nnearby
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801CF69C 48000014 801CFBB0 48000014 801D1CEC 48000014 801CFC7C 48000014 801CFAE0 48000014 801CFAE0 48000014 801CFCE0 48000014 801D019C 48000014 b +0x00000014 /* 801CFAF4 */
"Movement Patch" Part 2 (restores backstep functionality on certain movements)
Movement
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801CE7AC 4800000C 801CECC0 4800000C 801D0D10 4800000C 801CED8C 4800000C 801CEBF0 4800000C 801CEBF0 4800000C 801CEDF0 4800000C 801CF2AC 4800000C b +0x0000000C /* 801CEBFC */
Olga Flow Barta Bug Fix (makes barta work on ice weakness Olga Flow instead of damaging player)
BugFixes
*** name=Bug fixes
*** desc=Fix many minor\ngameplay, sound,\nand graphical bugs
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 8000D980 807C0000 lwz r3, [r28]
8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 8000D984 2C030013 cmpwi r3, 19
8000D988 40820008 8000D988 40820008 8000D988 40820008 8000D988 40820008 8000D988 40820008 8000D988 40820008 8000D988 40820008 8000D988 40820008 bne +0x00000008 /* 8000D990 */
@@ -310,7 +310,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Morfos Frozen Player Bug Fix (stops Morfos Laser multi-hitting when player is frozen)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000D9A0 C042FC78 8000D9A0 C042FC80 8000D9A0 C042FC80 8000D9A0 C042FC80 8000D9A0 C042FC88 8000D9A0 C042FC88 8000D9A0 C042FC88 8000D9A0 C042FC88 lfs f2, [r2 - 0x0378]
8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 8000D9A4 807E0030 lwz r3, [r30 + 0x0030]
8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 8000D9A8 70630020 andi. r3, r3, 0x0020
@@ -321,18 +321,18 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Tiny Grass Assassins Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
800BC750 48000010 800BCA58 48000010 800BCBD0 48000010 800BCB80 48000010 800BC9E8 48000010 800BC9E8 48000010 800BCB90 48000010 800BCB58 48000010 b +0x00000010 /* 800BC9F8 */
Bulclaw HP Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80091528 4800024D 80091814 4800024D 8009198C 4800024D 8009193C 4800024D 800917B4 4800024D 800917B4 4800024D 8009194C 4800024D 80091914 4800024D bl +0x0000024C /* 80091A00 */
8009152C B3C3032C 80091818 B3C3032C 80091990 B3C3032C 80091940 B3C3032C 800917B8 B3C3032C 800917B8 B3C3032C 80091950 B3C3032C 80091918 B3C3032C sth [r3 + 0x032C], r30
Control Tower: Delbiter Death SFX Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80301600 48000020 803025CC 48000020 80303A1C 48000020 803037D0 48000020 80301F58 48000020 80301F9C 48000020 8030398C 48000020 80302D64 48000020 b +0x00000020 /* 80301F78 */
80301604 3863A830 803025D0 3863A830 80303A20 3863A830 803037D4 3863A830 80301F5C 3863A830 80301FA0 3863A830 80303990 3863A830 80302D68 3863A830 subi r3, r3, 0x57D0
80301608 800DB98C 803025D4 800DB994 80303A24 800DB9B4 803037D8 800DB9B4 80301F60 800DB9A4 80301FA4 800DB9A4 80303994 800DB9C4 80302D6C 800DBA04 lwz r0, [r13 - 0x465C]
@@ -344,7 +344,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Weapon Attributes Patch (allows attributes to work on minibosses and Olga Flow)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F 8000C8C0 7000000F andi. r0, r0, 0x000F
8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F 8000C8C4 7000004F andi. r0, r0, 0x004F
8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 8000C8C8 2C000004 cmpwi r0, 4
@@ -354,34 +354,34 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Ruins Laser Fence SFX Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80166324 3C604005 801666D8 3C604005 80166848 3C604005 8016679C 3C604005 801666E0 3C604005 801666E0 3C604005 80166800 3C604005 80166CC4 3C604005 lis r3, 0x4005
80166328 4800009C 801666DC 4800009C 8016684C 4800009C 801667A0 4800009C 801666E4 4800009C 801666E4 4800009C 80166804 4800009C 80166CC8 4800009C b +0x0000009C /* 80166780 */
801663C0 4800001C 80166774 4800001C 801668E4 4800001C 80166838 4800001C 8016677C 4800001C 8016677C 4800001C 8016689C 4800001C 80166D60 4800001C b +0x0000001C /* 80166798 */
SFX Cancellation Distance Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
805CB608 46AFC800 805D5C08 46AFC800 805DD0A8 46AFC800 805DCE48 46AFC800 805CBF10 46AFC800 805D2F30 46AFC800 805DC750 46AFC800 805D8990 46AFC800 .invalid sc
805CB8A8 43480000 805D5EA8 43480000 805DD348 43480000 805DD0E8 43480000 805CC1B0 43480000 805D31D0 43480000 805DC9F0 43480000 805D8C30 43480000 bc 26, 8, +0x00000000 /* 805CC1B0 */
Foie SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8022E2A8 3880FF00 8022EC44 3880FF00 8022FB30 3880FF00 8022F8E4 3880FF00 8022EB64 3880FF00 8022EB64 3880FF00 8022FC18 3880FF00 8022F4B0 3880FF00 li r4, 0xFFFFFF00
8022E2D8 3880FE80 8022EC74 3880FE80 8022FB60 3880FE80 8022F914 3880FE80 8022EB94 3880FE80 8022EB94 3880FE80 8022FC48 3880FE80 8022F4E0 3880FE80 li r4, 0xFFFFFE80
8022E308 3880FDB0 8022ECA4 3880FDB0 8022FB90 3880FDB0 8022F944 3880FDB0 8022EBC4 3880FDB0 8022EBC4 3880FDB0 8022FC78 3880FDB0 8022F510 3880FDB0 li r4, 0xFFFFFDB0
Gifoie SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802300B8 3880FF00 80230A54 3880FF00 80231940 3880FF00 802316F4 3880FF00 80230974 3880FF00 80230974 3880FF00 80231A28 3880FF00 802312C0 3880FF00 li r4, 0xFFFFFF00
802300E8 3880FE80 80230A84 3880FE80 80231970 3880FE80 80231724 3880FE80 802309A4 3880FE80 802309A4 3880FE80 80231A58 3880FE80 802312F0 3880FE80 li r4, 0xFFFFFE80
80230118 3880FDB0 80230AB4 3880FDB0 802319A0 3880FDB0 80231754 3880FDB0 802309D4 3880FDB0 802309D4 3880FDB0 80231A88 3880FDB0 80231320 3880FDB0 li r4, 0xFFFFFDB0
Rafoie SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802365AC 3880FF00 80236F68 3880FF00 80237E54 3880FF00 80237C08 3880FF00 80236E88 3880FF00 80236E88 3880FF00 80237F3C 3880FF00 802377D4 3880FF00 li r4, 0xFFFFFF00
802365DC 3880FE80 80236F98 3880FE80 80237E84 3880FE80 80237C38 3880FE80 80236EB8 3880FE80 80236EB8 3880FE80 80237F6C 3880FE80 80237804 3880FE80 li r4, 0xFFFFFE80
8023660C 3880FDB0 80236FC8 3880FDB0 80237EB4 3880FDB0 80237C68 3880FDB0 80236EE8 3880FDB0 80236EE8 3880FDB0 80237F9C 3880FDB0 80237834 3880FDB0 li r4, 0xFFFFFDB0
@@ -391,79 +391,79 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Barta SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80229B54 3880FF00 8022A4F0 3880FF00 8022B3E0 3880FF00 8022B190 3880FF00 8022A410 3880FF00 8022A410 3880FF00 8022B4C4 3880FF00 8022AD5C 3880FF00 li r4, 0xFFFFFF00
80229B84 3880FE80 8022A520 3880FE80 8022B410 3880FE80 8022B1C0 3880FE80 8022A440 3880FE80 8022A440 3880FE80 8022B4F4 3880FE80 8022AD8C 3880FE80 li r4, 0xFFFFFE80
80229BB4 3880FDB0 8022A550 3880FDB0 8022B440 3880FDB0 8022B1F0 3880FDB0 8022A470 3880FDB0 8022A470 3880FDB0 8022B524 3880FDB0 8022ADBC 3880FDB0 li r4, 0xFFFFFDB0
Gibarta SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8022EAB4 3880FF00 8022F450 3880FF00 80230340 3880FF00 802300F0 3880FF00 8022F370 3880FF00 8022F370 3880FF00 80230424 3880FF00 8022FCBC 3880FF00 li r4, 0xFFFFFF00
8022EAE4 3880FE80 8022F480 3880FE80 80230370 3880FE80 80230120 3880FE80 8022F3A0 3880FE80 8022F3A0 3880FE80 80230454 3880FE80 8022FCEC 3880FE80 li r4, 0xFFFFFE80
8022EB14 3880FDB0 8022F4B0 3880FDB0 802303A0 3880FDB0 80230150 3880FDB0 8022F3D0 3880FDB0 8022F3D0 3880FDB0 80230484 3880FDB0 8022FD1C 3880FDB0 li r4, 0xFFFFFDB0
Rabarta SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80235DD4 3880FF00 80236790 3880FF00 8023767C 3880FF00 80237430 3880FF00 802366B0 3880FF00 802366B0 3880FF00 80237764 3880FF00 80236FFC 3880FF00 li r4, 0xFFFFFF00
80235E10 3880FE80 802367CC 3880FE80 802376B8 3880FE80 8023746C 3880FE80 802366EC 3880FE80 802366EC 3880FE80 802377A0 3880FE80 80237038 3880FE80 li r4, 0xFFFFFE80
80235E4C 3880FDB0 80236808 3880FDB0 802376F4 3880FDB0 802374A8 3880FDB0 80236728 3880FDB0 80236728 3880FDB0 802377DC 3880FDB0 80237074 3880FDB0 li r4, 0xFFFFFDB0
Zonde SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8023B2C8 3880FF00 8023BC84 3880FF00 8023CB70 3880FF00 8023C924 3880FF00 8023BBA4 3880FF00 8023BBA4 3880FF00 8023CC58 3880FF00 8023C4F0 3880FF00 li r4, 0xFFFFFF00
8023B2F8 3880FE80 8023BCB4 3880FE80 8023CBA0 3880FE80 8023C954 3880FE80 8023BBD4 3880FE80 8023BBD4 3880FE80 8023CC88 3880FE80 8023C520 3880FE80 li r4, 0xFFFFFE80
8023B328 3880FDB0 8023BCE4 3880FDB0 8023CBD0 3880FDB0 8023C984 3880FDB0 8023BC04 3880FDB0 8023BC04 3880FDB0 8023CCB8 3880FDB0 8023C550 3880FDB0 li r4, 0xFFFFFDB0
Gizonde SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80230E08 3880FF00 802317C4 3880FF00 802326B0 3880FF00 80232464 3880FF00 802316E4 3880FF00 802316E4 3880FF00 80232798 3880FF00 80232030 3880FF00 li r4, 0xFFFFFF00
80230E38 3880FE80 802317F4 3880FE80 802326E0 3880FE80 80232494 3880FE80 80231714 3880FE80 80231714 3880FE80 802327C8 3880FE80 80232060 3880FE80 li r4, 0xFFFFFE80
80230E68 3880FDB0 80231824 3880FDB0 80232710 3880FDB0 802324C4 3880FDB0 80231744 3880FDB0 80231744 3880FDB0 802327F8 3880FDB0 80232090 3880FDB0 li r4, 0xFFFFFDB0
Razonde SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80237998 3880FF00 80238354 3880FF00 80239240 3880FF00 80238FF4 3880FF00 80238274 3880FF00 80238274 3880FF00 80239328 3880FF00 80238BC0 3880FF00 li r4, 0xFFFFFF00
802379C8 3880FE80 80238384 3880FE80 80239270 3880FE80 80239024 3880FE80 802382A4 3880FE80 802382A4 3880FE80 80239358 3880FE80 80238BF0 3880FE80 li r4, 0xFFFFFE80
802379F8 3880FDB0 802383B4 3880FDB0 802392A0 3880FDB0 80239054 3880FDB0 802382D4 3880FDB0 802382D4 3880FDB0 80239388 3880FDB0 80238C20 3880FDB0 li r4, 0xFFFFFDB0
Grants SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802316FC 3880FF00 802320B8 3880FF00 80232FA4 3880FF00 80232D58 3880FF00 80231FD8 3880FF00 80231FD8 3880FF00 8023308C 3880FF00 80232924 3880FF00 li r4, 0xFFFFFF00
80231734 3880FE80 802320F0 3880FE80 80232FDC 3880FE80 80232D90 3880FE80 80232010 3880FE80 80232010 3880FE80 802330C4 3880FE80 8023295C 3880FE80 li r4, 0xFFFFFE80
8023176C 3880FDB0 80232128 3880FDB0 80233014 3880FDB0 80232DC8 3880FDB0 80232048 3880FDB0 80232048 3880FDB0 802330FC 3880FDB0 80232994 3880FDB0 li r4, 0xFFFFFDB0
Megid SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802337A8 3880FF00 80234164 3880FF00 80235050 3880FF00 80234E04 3880FF00 80234084 3880FF00 80234084 3880FF00 80235138 3880FF00 802349D0 3880FF00 li r4, 0xFFFFFF00
802337D8 3880FE80 80234194 3880FE80 80235080 3880FE80 80234E34 3880FE80 802340B4 3880FE80 802340B4 3880FE80 80235168 3880FE80 80234A00 3880FE80 li r4, 0xFFFFFE80
80233808 3880FDB0 802341C4 3880FDB0 802350B0 3880FDB0 80234E64 3880FDB0 802340E4 3880FDB0 802340E4 3880FDB0 80235198 3880FDB0 80234A30 3880FDB0 li r4, 0xFFFFFDB0
Anti SFX Pitch Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80229354 2C000001 80229CF0 2C000001 8022ABDC 2C000001 8022A990 2C000001 80229C10 2C000001 80229C10 2C000001 8022ACC4 2C000001 8022A55C 2C000001 cmpwi r0, 1
Shield DFP/EVP Bug Fix (allows shields to reach true max DFP/EVP values)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801185B0 88040016 801187CC 88040016 8011885C 88040016 80118764 88040016 80118854 88040016 80118854 88040016 80118774 88040016 8011894C 88040016 lbz r0, [r4 + 0x0016]
801185BC 88040017 801187D8 88040017 80118868 88040017 80118770 88040017 80118860 88040017 80118860 88040017 80118780 88040017 80118958 88040017 lbz r0, [r4 + 0x0017]
VR Spaceship Item Drop Bug Fix (allows items to drop from enemies above a certain Y position)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
805C996C 435C0000 805D3F6C 435C0000 805DB40C 435C0000 805DB1AC 435C0000 805CA274 435C0000 805D1294 435C0000 805DAAB4 435C0000 805D6CF4 435C0000 bc 26, 28, +0x00000000 /* 805CA274 */
Invalid Items Bug Fix (something to do with making invalid items correctly display as ???? I think)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8011CA90 7C030378 8011CCD4 7C030378 8011CD0C 7C030378 8011CC6C 7C030378 8011CD34 7C030378 8011CD34 7C030378 8011CC7C 7C030378 8011CE54 7C030378 mr r3, r0
8011CA94 3863FFFF 8011CCD8 3863FFFF 8011CD10 3863FFFF 8011CC70 3863FFFF 8011CD38 3863FFFF 8011CD38 3863FFFF 8011CC80 3863FFFF 8011CE58 3863FFFF subi r3, r3, 0x0001
8011CA98 4BFFFFE8 8011CCDC 4BFFFFE8 8011CD14 4BFFFFE8 8011CC74 4BFFFFE8 8011CD3C 4BFFFFE8 8011CD3C 4BFFFFE8 8011CC84 4BFFFFE8 8011CE5C 4BFFFFE8 b -0x00000018 /* 8011CD24 */
@@ -476,7 +476,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Item Removal Maxed Stats Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 8000B088 7FA3EB78 mr r3, r29
8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 8000B08C 38800000 li r4, 0x0000
8000B090 481AE725 8000B090 481AEB91 8000B090 481B1C09 8000B090 481AEC5D 8000B090 481AEB11 8000B090 481AEB11 8000B090 481AECC1 8000B090 481AF17D bl +0x001AEB10 /* 801B9BA0 */
@@ -537,7 +537,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Unit Present Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C640 54800673 8000C640 54800673 8000C640 54800673 8000C640 54800673 8000C640 54800673 8000C640 54800673 8000C640 54800673 8000C640 54800673 rlwinm. r0, r4, 0, 25, 25
8000C644 41820008 8000C644 41820008 8000C644 41820008 8000C644 41820008 8000C644 41820008 8000C644 41820008 8000C644 41820008 8000C644 41820008 beq +0x00000008 /* 8000C64C */
8000C648 38800000 8000C648 38800000 8000C648 38800000 8000C648 38800000 8000C648 38800000 8000C648 38800000 8000C648 38800000 8000C648 38800000 li r4, 0x0000
@@ -547,7 +547,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Bank Item Stacking Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 8000C6D0 38000001 li r0, 0x0001
8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 8000C6D4 901D0054 stw [r29 + 0x0054], r0
8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 8000C6D8 807D0024 lwz r3, [r29 + 0x0024]
@@ -561,28 +561,28 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Dropped Mag Colour Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80114378 38000012 8011458C 38000012 80114634 38000012 80114524 38000012 8011461C 38000012 8011461C 38000012 80114534 38000012 8011470C 38000012 li r0, 0x0012
Meseta Drop System Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80107478 4800000C 80107654 4800000C 80107708 4800000C 801075D4 4800000C 8010771C 4800000C 8010771C 4800000C 801075E4 4800000C 801077D4 4800000C b +0x0000000C /* 80107728 */
8010748C 7C030378 80107668 7C030378 8010771C 7C030378 801075E8 7C030378 80107730 7C030378 80107730 7C030378 801075F8 7C030378 801077E8 7C030378 mr r3, r0
Present Colour Bug Fix (TODO: which versions need this?)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80101C14 60000000 60000000 60000000 60000000 80101EB8 60000000 80101EB8 60000000 60000000 60000000 nop
Offline Quests Drop Table Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80104B48 4182000C 80104D24 4182000C 80104DE0 4182000C 80104CA4 4182000C 80104DEC 4182000C 80104DEC 4182000C 80104CB4 4182000C 80104EA4 4182000C beq +0x0000000C /* 80104DF8 */
Mag Revival Priority Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A 8000C8A0 1C00000A mulli r0, r0, 10
8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD 8000C8A4 57E407BD rlwinm. r4, r31, 0, 30, 30
8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 8000C8A8 41820008 beq +0x00000008 /* 8000C8B0 */
@@ -592,22 +592,22 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Mag Revival Challenge & Quest Mode Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801CA1F4 48000010 801CA6E0 48000010 801CB5EC 48000010 801CA7AC 48000010 801CA610 48000010 801CA610 48000010 801CA810 48000010 801CACCC 48000010 b +0x00000010 /* 801CA620 */
Chat Bubble Window TAB Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80250264 60000000 80250CB0 60000000 80251CA4 60000000 802519A4 60000000 80250AEC 60000000 80250AEC 60000000 80251C68 60000000 802514B0 60000000 nop
Chat Log Window LF/Tab Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80267DDC 60000000 80268A88 60000000 80269AE4 60000000 80269898 60000000 80268788 60000000 80268788 60000000 80269B5C 60000000 802693A4 60000000 nop
Dark/Hell Special GFX Bug Fix (makes Dark/Hell display graphic on success like in PSO BB)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 8000E1E0 7FC802A6 mflr r30
8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 8000E1E4 38A00000 li r5, 0x0000
8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E 8000E1E8 38C0001E li r6, 0x001E
@@ -622,18 +622,18 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Gol Dragon Camera Bug Fix (makes the camera after Gol Dragon display "normally")
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802FB99C 2C030001 802FC968 2C030001 802FDE60 2C030001 802FDB6C 2C030001 802FC2F4 2C030001 802FC338 2C030001 802FDD28 2C030001 802FD100 2C030001 cmpwi r3, 1
Box/Fence Fadeout Bug Fix (stops boxes and other environmental objects fading in and out as you approach)
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80189A54 60000000 80189E2C 60000000 80189F90 60000000 80189EF0 60000000 80189E20 60000000 80189E20 60000000 80189F54 60000000 8018A418 60000000 nop
801933DC 60000000 801937B0 60000000 80193914 60000000 80193874 60000000 801937A8 60000000 801937A8 60000000 801938D8 60000000 80193D9C 60000000 nop
TP Bar Colour Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8026DA74 3884AAFA 8026E738 3884AAFA 8026F794 3884AAFA 8026F548 3884AAFA 8026E2D4 3884AAFA 8026E2D4 3884AAFA 8026F6FC 3884AAFA 8026EF44 3884AAFA subi r4, r4, 0x5506
8026DB88 3863AAFA 8026E84C 3863AAFA 8026F8A8 3863AAFA 8026F65C 3863AAFA 8026E3E8 3863AAFA 8026E3E8 3863AAFA 8026F810 3863AAFA 8026F058 3863AAFA subi r3, r3, 0x5506
8026DC10 3883AAFA 8026E8D4 3883AAFA 8026F930 3883AAFA 8026F6E4 3883AAFA 8026E470 3883AAFA 8026E470 3883AAFA 8026F898 3883AAFA 8026F0E0 3883AAFA subi r4, r3, 0x5506
@@ -641,12 +641,12 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Devil's and Demon's Special Damage Display Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8001306C 4BFFFCC0 8001309C 4BFFFCC0 80013364 4BFFFCC0 8001304C 4BFFFCC0 80013084 4BFFFCC0 80013084 4BFFFCC0 8001304C 4BFFFCC0 800130C4 4BFFFCC0 b -0x00000340 /* 80012D44 */
Christmas Trees Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 8000B5C8 80630098 lwz r3, [r3 + 0x0098]
8000B5CC 483D46F5 8000B5CC 483D70D1 8000B5CC 483D8F71 8000B5CC 483D8D21 8000B5CC 483D5999 8000B5CC 483D59F1 8000B5CC 483D90F1 8000B5CC 483D7BE1 bl +0x003D5998 /* 803E0F64 */
8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C 8000B5D0 807F042C lwz r3, [r31 + 0x042C]
@@ -657,25 +657,25 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Rain Drops Colour Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
804B3738 70808080 804B6E58 70808080 804B92F8 70808080 804B90B8 70808080 804B3EF0 70808080 804B43D0 70808080 804B8990 70808080 804B8E10 70808080 andi. r0, r4, 0x8080
804B373C 60707070 804B6E5C 60707070 804B92FC 60707070 804B90BC 60707070 804B3EF4 60707070 804B43D4 60707070 804B8994 60707070 804B8E14 60707070 ori r16, r3, 0x7070
Reverser Target Lock Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
801C5EA4 389F02FC 801C6360 389F02FC 801C6604 389F02FC 801C642C 389F02FC 801C62C0 389F02FC 801C62C0 389F02FC 801C6490 389F02FC 801C694C 389F02FC addi r4, r31, 0x02FC
Deband/Shifta/Resta Target Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8022CF84 41810630 8022D920 41810630 8022E85C 41810630 8022E5C0 41810630 8022D840 41810630 8022D840 41810630 8022E8F4 41810630 8022E18C 41810630 bgt +0x00000630 /* 8022DE70 */
8022D278 4181033C 4181033C 4181033C 4181033C 8022DB34 4181033C 8022DB34 4181033C 4181033C 4181033C bgt +0x0000033C /* 8022DE70 */
8022D36C 41810248 41810248 41810248 41810248 8022DC28 41810248 8022DC28 41810248 41810248 41810248 bgt +0x00000248 /* 8022DE70 */
Tech Auto Targetting Bug Fix
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8022C850 60000000 8022D1EC 60000000 8022E128 60000000 8022DE8C 60000000 8022D10C 60000000 8022D10C 60000000 8022E1C0 60000000 8022DA58 60000000 nop
804C6EE4 0000001E 804CA61C 0000001E 804CCB6C 0000001E 804CC90C 0000001E 804C76B4 0000001E 804C7B94 0000001E 804CC1E4 0000001E 804CC5D4 0000001E .invalid
804C6F3C 00000028 804CA674 00000028 804CCBC4 00000028 804CC964 00000028 804C770C 00000028 804C7BEC 00000028 804CC23C 00000028 804CC62C 00000028 .invalid
@@ -686,7 +686,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Enable Trap Animations
BugFixes
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 8000BBD0 809F0370 lwz r4, [r31 + 0x0370]
8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 8000BBD4 3884FC00 subi r4, r4, 0x0400
8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 8000BBD8 909F0370 stw [r31 + 0x0370], r4
@@ -702,12 +702,12 @@ Extended Word Select
ChatFeatures
*** name=Chat
*** desc=Enable extended\nWord Select and\nstop the Log Window\nfrom scrolling by\nholding L+R
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8034445C 38600000 803457AC 38600000 80346CCC 38600000 80346A80 38600000 8034525C 38600000 803452A0 38600000 80346E4C 38600000 8034627C 38600000 li r3, 0x0000
Chat Log Window: Lock Scrolling with L+R
ChatFeatures
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 8000D6A0 3C608051 lis r3, 0x8051
8000D6A4 A0638AD0 8000D6A4 A063C590 8000D6A4 A063EBD0 8000D6A4 A063E970 8000D6A4 A06393B0 8000D6A4 A0639890 8000D6A4 A063E270 8000D6A4 A063F290 lhz r3, [r3 - 0x6C50]
8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 8000D6A8 70600003 andi. r0, r3, 0x0003
@@ -721,7 +721,7 @@ Improved Draw Distance of most objects
Draw Distance
*** name=Draw Distance
*** desc=Extend the draw\ndistance of many\nobjects
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000DFA0 C3C2C1F8 8000DFA0 C3C2C1F8 8000DFA0 C3C2C1F8 8000DFA0 C3C2C1F8 8000DFA0 C3C2C200 8000DFA0 C3C2C200 8000DFA0 C3C2C200 8000DFA0 C3C2C200 lfs f30, [r2 - 0x3E00]
8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 8000DFA4 EFDE0072 fmuls f30, f30, f1
8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 8000DFA8 4E800020 blr
@@ -739,7 +739,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
8000DFD8 3C60804C 8000DFD8 3C60804C 8000DFD8 3C60804D 8000DFD8 3C60804D 8000DFD8 3C60804C 8000DFD8 3C60804C 8000DFD8 3C60804D 8000DFD8 3C60804D lis r3, 0x804C
8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 8000DFDC 4E800020 blr
801008E8 4BF0D6B9 80100AD0 4BF0D4D1 80100B74 4BF0D42D 80100A50 4BF0D551 80100B8C 4BF0D415 80100B8C 4BF0D415 80100A60 4BF0D541 80100C50 4BF0D351 bl -0x000F2BEC /* 8000DFA0 */
80156D00 4BEB72AD 801570B4 4BEB6EF9 80157218 4BEB6D95 80157178 4BEB6E35 801570BC 4BEB6EF1 801570BC 4BEB6EF1 801571DC 4BEB6DD1 801576A0 4BEB690D bl -0x00149110 /* 8000DFAC */
8015671C 4BEB7891 80156AD0 4BEB74DD 80156C34 4BEB7379 80156B94 4BEB7419 80156AD8 4BEB74D5 80156AD8 4BEB74D5 80156BF8 4BEB73B5 801570BC 4BEB6EF1 bl -0x00148C4C /* 8000DFAC */
801A1C64 4BE6C359 801A203C 4BE6BF81 801A21A0 4BE6BE1D 801A2100 4BE6BEBD 801A2040 4BE6BF7D 801A2040 4BE6BF7D 801A2164 4BE6BE59 801A2628 4BE6B995 bl -0x00194084 /* 8000DFBC */
801A1E64 4BE6C13D 801A223C 4BE6BD65 801A23A0 4BE6BC01 801A2300 4BE6BCA1 801A2240 4BE6BD61 801A2240 4BE6BD61 801A2364 4BE6BC3D 801A2828 4BE6B779 bl -0x001942A0 /* 8000DFA0 */
80205044 4BE08F85 802058B8 4BE08711 80206640 4BE07989 802063F4 4BE07BD5 80205840 4BE08789 80205840 4BE08789 80206728 4BE078A1 80206124 4BE07EA5 bl -0x001F7878 /* 8000DFC8 */
@@ -754,7 +754,7 @@ Show Enemy HP Bars
EnemyHPBars
*** name=Enemy HP bars
*** desc=Show HP bars in\nenemy info windows
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US12)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US12)
802612C4 4BFE1541 80261E9C 4BFE1349 80262EE4 4BFE0665 80262C98 4BFE1241 80261B9C 4BFE1545 80261B9C 4BFE1545 80262F5C 4BFE12B1 802627A4 4BFE12B1 bl -0x0001EABC /* 802430E0 */
804CAF00 42780000 804CE650 42780000 804D0BA0 42780000 804D0940 42780000 804CB6D0 42780000 804CBBB0 42780000 804D0218 42780000 804D0608 42780000
804CAF1C FF00FF15 804CE66C FF00FF15 804D0BBC FF00FF15 804D095C FF00FF15 804CB6EC FF00FF15 804CBBCC FF00FF15 804D0234 FF00FF15 804D0624 FF00FF15
@@ -798,7 +798,7 @@ PSO DC Reticle Colours
DCReticleColors
*** name=DC targets
*** desc=Change the target\nreticle colors to\nthose used on the\nDreamcast
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802AB3FC 3C8000FF 802AC2A4 3C8000FF 802AD3D0 3C8000FF 802AD184 3C8000FF 802ABDB8 3C8000FF 802ABDFC 3C8000FF 802AD338 3C8000FF 802ACACC 3C8000FF lis r4, 0x00FF
802AB410 388000FF 802AC2B8 388000FF 802AD3E4 388000FF 802AD198 388000FF 802ABDCC 388000FF 802ABE10 388000FF 802AD34C 388000FF 802ACAE0 388000FF li r4, 0x00FF
802AB424 3884FF00 802AC2CC 3884FF00 802AD3F8 3884FF00 802AD1AC 3884FF00 802ABDE0 3884FF00 802ABE24 3884FF00 802AD360 3884FF00 802ACAF4 3884FF00 subi r4, r4, 0x0100
@@ -819,7 +819,7 @@ PSOX / BB Reticle Colours
PSOXReticleColors
*** name=Xbox/BB targets
*** desc=Change the target\nreticle colors to\nthose used on the\nXbox and Blue Burst
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
802AB424 388000FF 802AC2CC 388000FF 802AD3F8 388000FF 802AD1AC 388000FF 802ABDE0 388000FF 802ABE24 388000FF 802AD360 388000FF 802ACAF4 388000FF li r4, 0x00FF
804A1F38 00000000 804A5658 00000000 804A7AF8 00000000 804A78B8 00000000 804A26E8 00000000 804A2BC8 00000000 804A7188 00000000 804A7608 00000000 .invalid
804A1F3C 00000000 804A565C 00000000 804A7AFC 00000000 804A78BC 00000000 804A26EC 00000000 804A2BCC 00000000 804A718C 00000000 804A760C 00000000 .invalid
@@ -829,7 +829,7 @@ Show Rare Items on Area & Radar Map
RareDropNotifications
*** name=Rare alerts
*** desc=Show rare items on\nthe map and play a\nsound when a rare\nitem drops
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF 8000C660 881F00EF lbz r0, [r31 + 0x00EF]
8000C664 28000004 8000C664 28000004 8000C664 28000004 8000C664 28000004 8000C664 28000004 8000C664 28000004 8000C664 28000004 8000C664 28000004 cmplwi r0, 4
8000C668 40820018 8000C668 40820018 8000C668 40820018 8000C668 40820018 8000C668 40820018 8000C668 40820018 8000C668 40820018 8000C668 40820018 bne +0x00000018 /* 8000C680 */
@@ -844,7 +844,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Rare Item Drops: Play SFX
RareDropNotifications
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000C690 28030000 8000C690 28030000 8000C690 28030000 8000C690 28030000 8000C690 28030000 8000C690 28030000 8000C690 28030000 8000C690 28030000 cmplwi r3, 0
8000C694 41820020 8000C694 41820020 8000C694 41820020 8000C694 41820020 8000C694 41820020 8000C694 41820020 8000C694 41820020 8000C694 41820020 beq +0x00000020 /* 8000C6B4 */
8000C698 880300EF 8000C698 880300EF 8000C698 880300EF 8000C698 880300EF 8000C698 880300EF 8000C698 880300EF 8000C698 880300EF 8000C698 880300EF lbz r0, [r3 + 0x00EF]
@@ -862,7 +862,7 @@ Play SFX for Hungry Mag
HungryMagSound
*** name=MAG alert
*** desc=Play a sound when\nyour MAG is hungry
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 8000BF30 9421FFF0 stwu [r1 - 0x0010], r1
8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 8000BF34 7C0802A6 mflr r0
8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 8000BF38 90010014 stw [r1 + 0x0014], r0
@@ -880,12 +880,12 @@ Invisible Mag
InvisibleMag
*** name=Invisible MAG
*** desc=Make MAGs invisible
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80114F04 480000D4 80115118 480000D4 8011521C 480000D4 801150B0 480000D4 801151A8 480000D4 801151A8 480000D4 801150C0 480000D4 80115298 480000D4 b +0x000000D4 /* 8011527C */
16:9 Aspect Ratio
169AspectRatioV1
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
80000088 C04210F0 80000088 C0421120 80000088 C0421130 80000088 C0421130 80000088 C0421108 80000088 C0421108 80000088 C0421138 80000088 C0421128 lfs f2, [r2 + 0x1108]
8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 8000008C EFBD00B2 fmuls f29, f29, f2
80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 80000090 FC40E890 fmr f2, f29
@@ -894,7 +894,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
16:9 Aspect Ratio V2
169AspectRatioV2
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 8000BE4C C01C0040 lfs f0, [r28 + 0x0040]
8000BE50 C062F7C0 8000BE50 C062F7C8 8000BE50 C062F7C8 8000BE50 C062F7C8 8000BE50 C062F7D0 8000BE50 C062F7D0 8000BE50 C062F7D0 8000BE50 C062F7D0 lfs f3, [r2 - 0x0830]
8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA 8000BE54 EC4100FA fmadds f2, f1, f0, f3
@@ -955,7 +955,7 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
Water & Light Effects Aspect Ratio Fix (for use with a 16:9 code)
169AmbientEffectsFix
JP12------------- JP13------------- JP14------------- JP15------------- US10------------- US11------------- US12------------- EU--------------- DISASSEMBLY (US10)
3OJ2------------- 3OJ3------------- 3OJ4------------- 3OJ5------------- 3OE0------------- 3OE1------------- 3OE2------------- 3OP0------------- DISASSEMBLY (US10)
8000BDF0 C36210F0 8000BDF0 C3621120 8000BDF0 C3621130 8000BDF0 C3621130 8000BDF0 C3621108 8000BDF0 C3621108 8000BDF0 C3621138 8000BDF0 C3621128 lfs f27, [r2 + 0x1108]
8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 8000BDF4 EC4206F2 fmuls f2, f2, f27
8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 8000BDF8 FF601090 fmr f27, f2
+165
View File
@@ -0,0 +1,165 @@
$qfread
00 000003FF Garon points
00 0003FC00 Garon button-mashing game score
00 03FC0000 Garon timing game score
00 04000000 Garon Tier 1 (10 cards) of Guild Card counter
00 08000000 Garon Tier 2 (30 cards) of Guild Card counter
00 10000000 Garon Tier 3 (50 cards) of Guild Card counter
00 20000000 Garon Tier 4 (100 cards) of Guild Card counter
00 C0000000 __UNUSED__
01 00000001 Dream Messenger: NiGHTS
01 00000002 Pioneer Warehouse: ???
01 00000004 Garon's Shop: Puyo Pop
01 00000008 Pioneer Warehouse: Chu Chu Challenge
01 00000010 Reach for the Dream: Chu Chu Puzzle
01 00000020 Seat of the Heart: Checkpoint (Normal)
01 00000040 Seat of the Heart: Checkpoint (Sue path)
01 00000080 Seat of the Heart: Checkpoint (Elly is mad)
01 00000100 Seat of the Heart: Quest complete (no Sue path)
01 00000200 Seat of the Heart: Quest complete (Sue path)
01 00000400 Seat of the Heart: Got Ragol Ring (Normal)
01 00000800 Seat of the Heart: Checkpoint (Hard)
01 00000800 White Day: ???
01 00001000 Blue Star Memories: Future Forecast
01 00001000 Seat of the Heart: Checkpoint (Sue path)
01 00002000 Blue Star Memories: Future Bullet
01 00002000 Seat of the Heart: Checkpoint (Elly is mad)
01 00004000 Seat of the Heart: Quest complete (no Sue path)
01 00008000 Seat of the Heart: Quest complete (Sue path)
01 00010000 Seat of the Heart: Got Ragol Ring (Hard)
01 00020000 Seat of the Heart: Checkpoint (Very Hard)
01 00040000 Seat of the Heart: Checkpoint (Sue path)
01 00080000 Seat of the Heart: Checkpoint (Elly is mad)
01 00100000 Seat of the Heart: Quest complete (no Sue path)
01 00200000 Seat of the Heart: Quest complete (Sue path)
01 003F8000 Beta Lucky Coins
01 00400000 Seat of the Heart: Got Ragol Ring (Very Hard)
01 00800000 Seat of the Heart: Checkpoint (Ultimate)
01 01000000 Seat of the Heart: Checkpoint (Sue path)
01 02000000 Seat of the Heart: Checkpoint (Elly is mad)
01 04000000 Seat of the Heart: Quest complete (no Sue path)
01 08000000 Seat of the Heart: Quest complete (Sue path)
01 10000000 Seat of the Heart: Got Ragol Ring (Ultimate)
01 E0000000 __UNUSED__
02 00000001 Pioneer Halloween: Got Jack-O'-Lantern
02 00000002 Pioneer Halloween: Got cake
02 00000020 East Tower
02 00000020 The East Tower: Paganini side quest
02 00000040 The West Tower: Paganini side quest
02 00000040 West Tower
02 00000080 Labyrinthine Trial: White Ring
02 00000100 Garon's Treachery: Rakonia Stone
02 00000200 Garon's Treachery: Fragment of Friendship
02 00000400 Towards the Future: Purple Ring
02 00000800 Towards the Future: Flower Bouquet
02 00002000 Heart Of Poumn
02 00002000 Rappy's Holiday: Heart of Poumn
02 003FC000 Rappy's Holiday points
02 07000000 Respective Tomorrow: WIS
02 08000000 Respective Tomorrow: S/SS Rank
02 10000000 Towards the Future: Black Ring
02 20000000 Green Ring
02 C0C0101C __UNUSED__
03 000000FF Lucky Tickets
03 003FFF00 Kill count
03 07C00000 Song count
03 08000000 Couple flag
03 7FFFFFFF MA4 kills (Central Dome)
03 80000000 __UNUSED__
04 7FFFFFFF MA4 kills (Gal Da Val)
04 80000000 __UNUSED__
05 00007FFF Principal's Gift: Random Candy ID
05 00008000 Candy ID init flag
05 00200000 Racket
05 00400000 Tree Clippers
05 00800000 Synthesizer
05 01000000 Shichishito
05 02000000 Dirty Life Jacket
05 04000000 Lost Hell Pallasch: Gush Raygun
05 F81F0000 __UNUSED__
06 0FF00000 Lucky Tickets
06 F00FFFFF __UNUSED__
07 00000001 Government 4-5: Normal cleared
07 00000002 Government 4-5: Hard cleared
07 00000004 Government 4-5: Very Hard cleared
07 00000008 Government 4-5: Ultimate cleared
07 00000010 Government 8-3: Normal cleared
07 00000020 Government 8-3: Hard cleared
07 00000040 Government 8-3: Very Hard cleared
07 00000080 Government 8-3: Ultimate cleared
07 FFFFFF00 __UNUSED__
08 7FFFFFFF MA4 kills (Crater)
08 80000000 __UNUSED__
09 00003FFF MA1v2 points
09 00003FFF Maximum Attack 1 Ver.2: points
09 0FFFC000 MA2v2 points
09 0FFFC000 Maximum Attack 2 Ver.2: points
09 10000000 AOL CUP -Sunset Base- (Mag Cell)
09 10000000 Maximum Attack 1 Ver.2: Class Master flag
09 20000000 AOL CUP -Sunset Base- (Ruins)
09 20000000 Maximum Attack 2 Ver.2: ID Master flag
09 40000000 Beach Laughter: Got 5 Photon Spheres & Black Ring
09 40000000 Blue Ring
09 80000000 __UNUSED__
0A 00000001 Heart of HUmar
0A 00000002 Heart of HUnewearl
0A 00000004 Heart of HUcast
0A 00000008 Heart of HUcaseal
0A 00000010 Heart of RAmar
0A 00000020 Heart of RAmarl
0A 00000040 Heart of RAcast
0A 00000080 Heart of RAcaseal
0A 00000100 Heart of FOmar
0A 00000200 Heart of FOmarl
0A 00000400 Heart of FOnewm
0A 00000800 Heart of FOnewearl
0A 00001000 Heart of Viridia
0A 00002000 Heart of Greenill
0A 00004000 Heart of Skyly
0A 00008000 Heart of Bluefull
0A 00010000 Heart of Purplenum
0A 00020000 Heart of Pinkal
0A 00040000 Heart of Redria
0A 00080000 Heart of Oran
0A 00100000 Heart of Yellowboze
0A 00200000 Heart of Whitill
0A 7FC00000 Lucky Tickets
0A 80000000 __UNUSED__
0B 00000001 Garon's Shop: Black Gear
0B 00000001 Roulette (SEIRYU)
0B 00000002 Beta -> Final Lucky Coins init flag
0B 00000002 Roulette (GENBU)
0B 000001FC Lucky Coins
0B 0007FC00 Pioneer Christmas ???
0B 00080000 Cleared 4th Pioneer Christmas tier?
0B 1FF00000 Wrapping Papers
0B 20000000 Pioneer Christmas Present
0B 40000000 Wall
0B 40000000 White Day: Flower Bouquet or Heart Key
0B 80000200 __UNUSED__
0C FFFFFFFF __UNUSED__
0D FFFFFFFF __UNUSED__
0E 7FFFFFFF MA4 kills (Total)
0E 80000000 __UNUSED__
0F 000000FF MA4 Tickets
0F 00000100 MA4 PHOTON CRYSTAL
0F 00000200 MA4 FRIEND RING
0F 00000400 MA4 GIRASOLE
0F 00000800 MA4 SAMURAI ARMOR
0F FFFFF000 __UNUSED__
+188
View File
@@ -0,0 +1,188 @@
0007 = Set by rico capsule in caves
000B = P2 Tyrell Start
000C = P2 Irene Start
000D = P2 Scientist 1 Start
000E = P2 Scientist 2 Start
000F = P2 More Scientist stuff.
0010 = P2 Irene after talking to Tyrell
0011 = Read a rico capsule (any)
0012 = P2 Scientist after talking to Irene.
0013 = P2 Menu 6, quest counter / Tekker talked to
0014 = Entered Forest 1
0015 = Entered Forest 2
0016 = Entered Dragon Area
0017 = Dragon defeated
0018 = Caves unlocked
0018 = P2 Principle after defeating dragon
0019 = P2 Scientist after defeating dragon
001E = Entered Caves 1 (Gov 2-1)
001F = Entered De Rol Le in 2-4
0020 = De Ro lee defeated
0021 = Mines unlocked (P2 Tyrell after defeating De Rol Le)
0028 = Entered Mines 1
0029 = Entered Vol Opt Area
002A = Defeated Vol Opt
002B = Set by rico capsule about the 3 seals (after vol opt).
002C = Activated Forest monument
002D = Activated Caves monument (Gov 2-2)
002E = Activated Mines monument
002F = Activated all monuments
0030 = Entered Ruins 1
0032 = Entered Falz 1
0035 = Hard mode unlocked
0036 = Entered Falz 3 // Very Hard mode unlocked (?)
0037 = Ultimate unlocked
0046 = One CCA door lock unlocked
0047 = One CCA door lock unlocked
0048 = One CCA door lock unlocked
0049 = Entered Laboratory
004A = Lab Assistant Start
004B = Entered Temple Beta
004C = Defeated Barba Ray
004D = Lab Assistant after defeating barba ray
004E = Entered Spaceship Beta
004F = Defeated Gol Dragon
0051 = Entered CCA
0052 = Defeated Gal Gyrphon // Defeated Gol dragon in seat of heart (?)
0054 = Entered Seabed Upper
0057 = Defeated Olga Flow
005B = Lab Natasha Start
005C = Lab Natasha after VR temple
005D = Lab Natasha after VR Spaceship
005E = Lab Assistant after defeating Gal gryphon
005F = After reading the last capsule from flowen
0060 = Lab Natasha after CCA
0065 = Cleared Magnitude of Metal
0067 = Cleared Claiming a Stake
0069 = Cleared Value of Money
006B = Cleared Battle Training
006D = Cleared Journalistic Pursuit
006F = Cleared The Fake in Yellow
0071 = Cleared Native Research
0073 = Cleared Forest of Sorrow
0075 = Cleared Gran Squall
0077 = Cleared Addicting Food
0079 = Cleared The Lost Bride
007B = Cleared Waterfall Tears
007D = Cleared Black Paper
007F = Cleared Secret Delivery
0081 = Cleared Soul of a Blacksmith
0083 = Cleared Letter from Lionel
0085 = Cleared The Grave's Butler
0087 = Cleared Knowing One's Heart
0089 = Cleared The Retired Hunter
008B = Cleared Dr. Osto's Research
008D = Cleared Unsealed Door
008F = Cleared Soul of Steel
0091 = Cleared Doc's Secret Plan (able to make enemy part weapons)
0093 = Cleared Seek my Master
0095 = Cleared From the Depths
0096 = Unknown (set in the fake in yellow)
0097 = Seat of heart unknown
009B = Cleared Central Dome Fire Swirl
00A1 = Cleared Seat of the Heart
00C9 = Got an enemy weapon converted
00CA = unknown Fake In Yellow
00CE = unknown Fake In Yellow
00D3 = Dr.Osto's research black paper subplot. Told Sue your name
00D4 = Dr.Osto's research black paper subplot. Didn't tell Sue your name from before.
00D5 = Dr.Osto's research black paper subplot. Did tell Sue your name from before.
00D6 = Unsealed door. black paper subplot Talked to Sue. Refused to tell her your name
00D7 = Unsealed door. black paper subplot. bernie tells you Sue is part of black paper.
00D8 = Black paper subplot in waterfall of tears talking to Sue
00D9 = Black paper subplot in Black paper talking to Sue (used option 2)
00DB = Black paper subplot in Black paper talking to Sue (used any option)
00DE = Black paper subplot in Black paper talked to Sue at the end of quest?
00DF = Knowing ones heart talked to Bernie?
00E0 = Seek my master. Zoke ,Donoph subplot?
00E2 = Bernie Gran Squall
00E7 = Defeated Kireek in waterfall of tears
00E8 = Black paper subplot in black paper. defeated Kireek...
00EB = Black paper subplot in from the depths. Defeated Kireek and got soul eater!
00F1 = Secret delivery. Started the Weapons subplot //is cleared if quest is left
00F3 = Weapon badge approval for claiming the snake //is cleared if quest is left
00F4 = Weapon badge approval for the lost bride //is cleared if quest is left
00F5 = Weapon badge approval for gran squall //is cleared if quest is left
00F6 = Secret delivery. Got AKIKO's FRYING PAN!
00FB = Got Orochi-agito
00FB = Received OROCHI-AGITO!
00FD = Unknown addicting food
0105 = Central dome fire swirl. Got Glory of the past!
0106 = Central dome fire swirl. Got Mark3.
0107 = Central dome fire swirl. got Sonic knuckles
0108 = Central dome fire swirl. got mail from BOGARDE
0109 = Central dome fire swirl. got mail from ANNA
010A = Central dome fire swirl. got mail from NADJA
010B = Central dome fire swirl. got mail from Lionel
010C = Soul of the blacksmith. Got one of the 3 special weapons!
010D = Donoph Baz dies The Retired Hunter
010E = Seat of heart unknown
010F = Seat of heart unknown
0110 = Seat of heart unknown
0111 = Seat of heart unknown
0112 = Seat of heart unknown
0113 = Seat of heart unknown
0187 = Soul of steel. Got Marina's bag! //dreamcast
0188 = Soul of steel. Unknown.
0191 = Capsule Elly VR
0197 = Cleared VR Temple
01AD = Capsule elly CCA
01AE = Capsule elly CCA
01B3 = After reading a capsule from flowen
01D6 = Set after unlocking vr spaceship
01F5 = Episode1: Cleared government 1-1
01F7 = Episode1: Cleared government 1-2
01F9 = Episode1: Cleared government 1-3
01FB = Episode1: Cleared government 2-1
01FD = Episode1: Cleared government 2-2
01FF = Episode1: Cleared government 2-3
0201 = Episode1: Cleared government 2-4
0203 = Episode1: Cleared government 3-1
0205 = Episode1: Cleared government 3-2
0207 = Episode1: Cleared government 3-3
0209 = Episode1: Cleared government 4-1
020B = Episode1: Cleared government 4-2
020D = Episode1: Cleared government 4-3
020F = Episode1: Cleared government 4-4
0211 = Episode1: Cleared government 4-5
0213 = Episode2: Cleared government 5-1 // Talked to Tekker (?)
0214 = Entered Forest 1
0215 = Episode2: Cleared government 5-2
0217 = Episode2: Cleared government 5-3 // Defeated Dragon (?)
0219 = Episode2: Cleared government 5-4
021B = Episode2: Cleared government 5-5
021D = Episode2: Cleared government 6-1
021F = Episode2: Cleared government 6-2
0220 = Defeated De Rol Le
0221 = Episode2: Cleared government 6-3
0223 = Episode2: Cleared government 6-4
0225 = Episode2: Cleared government 6-5
0227 = Episode2: Cleared government 7-1
0229 = Episode2: Cleared government 7-2
022A = Defeated Vol Opt (002A and 022A together on hard mode)
022B = Episode2: Cleared government 7-3 // Rico capsule after Vol Opt, at Ruins door (?)
022D = Episode2: Cleared government 7-4 // Entered Caves 2 (?)
022F = Episode2: Cleared government 7-5
0230 = Entered Ruins 1
0231 = Episode2: Cleared government 8-1
0233 = Episode2: Cleared government 8-2
0234 = Entered Falz 2
0235 = Episode2: Cleared government 8-3
0246 = Activated Jungle East big door switch
0248 = Activated Seaside big door switch
024F = Defeated Gol Dragon
0252 = Defeated Gal Gryphon
02BD = Episode4: Cleared government 9-1
02BE = Episode4: Cleared government 9-2
02BF = Episode4: Cleared government 9-3
02C0 = Episode4: Cleared government 9-4
02C1 = Episode4: Cleared government 9-5
02C2 = Episode4: Cleared government 9-6
02C3 = Episode4: Cleared government 9-7
02C4 = Episode4: Cleared government 9-8
0314 = Entered Forest 1
0330 = Entered Ruins 1
03FA = P2 Menu 7, G-Counter // Talked to Momoka
03FB = Nol start
03FC = Cleared Ep2 government on ultimate
03FE = Cleared Ep2 government on normal-vh
+21
View File
@@ -0,0 +1,21 @@
import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession() as session:
async with session.ws_connect("ws://localhost:5050/y/rare-drops/stream") as ws:
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
data = msg.json()
print(f"Received message: {data}")
elif msg.type == aiohttp.WSMsgType.BINARY:
print(f"Received binary data: {msg.data}")
elif msg.type == aiohttp.WSMsgType.CLOSE:
break
elif msg.type == aiohttp.WSMsgType.ERROR:
break
if __name__ == "__main__":
asyncio.run(main())
+27
View File
@@ -0,0 +1,27 @@
### T FLAG NAME REQUIREMENTS AVAILABLE_IF ENABLED_IF
001 1 0065 Magnitude of Metal !F_0065 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
002 1 0067 Claiming A Stake !F_0067 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
003 3 0069 The Value of Money T1, Caves F_0065 && F_0067 && F_006B && F_01F9 !F_0069 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
004 1 006B Battle Training !F_006B || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
005 2 006D Journalistic Pursuit T1 F_0065 && F_0067 && F_006B !F_006D || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
006 2 006F The Fake in yellow T1 F_0065 && F_0067 && F_006B !F_006F || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
007 2 0071 Native Research T1 F_0065 && F_0067 && F_006B !F_0071 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
008 2 0073 Forest of Sorrow 007 F_0071 !F_0073 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
009 2 0075 Gran Squall T1 F_0065 && F_0067 && F_006B !F_0075 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
010 3 0077 Addicting Food T1 F_0065 && F_0067 && F_006B !F_0077 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
011 3 0079 The Lost Bride T1 F_0065 && F_0067 && F_006B !F_0079 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
012 3 007B Waterfall tears 010, 011, 014, 017 F_0077 && F_0079 && F_007F && F_0085 !F_007B || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
013 3 007D Black Paper 012 F_007B !F_007D || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
014 3 007F Secret Delivery T1 F_0065 && F_0067 && F_006B !F_007F || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
015 3 0081 Soul of a Blacksmith 010, 011, 014, 017 F_0077 && F_0079 && F_007F && F_0085 !F_0081 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
016 3 0083 Letter from Lionel T1, Mines F_0065 && F_0067 && F_006B && F_0201 !F_0083 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
017 3 0085 The Grave's Butler T1 F_0065 && F_0067 && F_006B !F_0085 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
018 4 0087 Knowing One's Heart T1, Mines F_0065 && F_0067 && F_006B && F_0201 !F_0087 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
019 5 0089 Retired Hunter T1, Ruins F_0065 && F_0067 && F_006B && F_0207 !F_0089 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
020 4 008B Dr. Osto's Research T1, Mines F_0065 && F_0067 && F_006B && F_0201 !F_008B || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
021 4 008D The Unsealed Door 020, 014 F_008B && F_007F !F_008D || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
022 5 008F Soul of Steel 023 F_0091 !F_008F || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
023 5 0091 Doc's Secret Plan 014, Ruins F_007F && F_0207 !F_0091 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
024 5 0093 Seek My Master T1, Ruins F_0065 && F_0067 && F_006B && F_0207 !F_0093 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
025 5 0095 From the Depths 023 F_0091 !F_0095 || (F_0065 && F_0067 && F_0069 && F_006B && F_006D && F_006F && F_0071 && F_0073 && F_0075 && F_0077 && F_0079 && F_007B && F_007D && F_007F && F_0081 && F_0083 && F_0085 && F_0087 && F_0089 && F_008B && F_008D && F_008F && F_0091 && F_0093 && F_0095)
026 2 009B Central Dome Fire Swirl 008 F_0073
+114 -55
View File
@@ -136,6 +136,7 @@ phosg::JSON BBLicense::json() const {
Account::Account(const phosg::JSON& json)
: account_id(0),
flags(0),
user_flags(0),
ban_end_time(0),
ep3_current_meseta(0),
ep3_total_meseta_earned(0),
@@ -184,7 +185,7 @@ Account::Account(const phosg::JSON& json)
lic->gamertag = xb_gamertag;
lic->user_id = xb_user_id;
lic->account_id = xb_account_id;
this->xb_licenses.emplace(lic->gamertag, lic);
this->xb_licenses.emplace(lic->user_id, lic);
}
if (!bb_username.empty() && !bb_password.empty()) {
auto lic = make_shared<BBLicense>();
@@ -213,7 +214,7 @@ Account::Account(const phosg::JSON& json)
}
for (const auto& it : json.get_list("XBLicenses")) {
auto lic = XBLicense::from_json(*it);
this->xb_licenses.emplace(lic->gamertag, lic);
this->xb_licenses.emplace(lic->user_id, lic);
}
for (const auto& it : json.get_list("BBLicenses")) {
auto lic = BBLicense::from_json(*it);
@@ -222,6 +223,7 @@ Account::Account(const phosg::JSON& json)
}
this->flags = json.get_int("Flags", 0);
this->user_flags = json.get_int("UserFlags", 0);
this->ban_end_time = json.get_int("BanEndTime", 0);
this->last_player_name = json.get_string("LastPlayerName", "");
this->auto_reply_message = json.get_string("AutoReplyMessage", "");
@@ -278,6 +280,7 @@ phosg::JSON Account::json() const {
{"XBLicenses", std::move(xb_json)},
{"BBLicenses", std::move(bb_json)},
{"Flags", this->flags},
{"UserFlags", this->user_flags},
{"BanEndTime", this->ban_end_time},
{"LastPlayerName", this->last_player_name},
{"AutoReplyMessage", this->auto_reply_message},
@@ -288,8 +291,8 @@ phosg::JSON Account::json() const {
});
}
void Account::print(FILE* stream) const {
fprintf(stream, "Account: %010" PRIu32 "/%08" PRIX32 "\n", this->account_id, this->account_id);
string Account::str() const {
std::string ret = phosg::string_printf("Account: %010" PRIu32 "/%08" PRIX32 "\n", this->account_id, this->account_id);
if (this->flags) {
string flags_str = "";
@@ -300,34 +303,34 @@ void Account::print(FILE* stream) const {
} else if (this->flags == static_cast<uint32_t>(Flag::MODERATOR)) {
flags_str = "MODERATOR";
} else {
if (this->flags & static_cast<uint32_t>(Flag::KICK_USER)) {
if (this->check_flag(Flag::KICK_USER)) {
flags_str += "KICK_USER,";
}
if (this->flags & static_cast<uint32_t>(Flag::BAN_USER)) {
if (this->check_flag(Flag::BAN_USER)) {
flags_str += "BAN_USER,";
}
if (this->flags & static_cast<uint32_t>(Flag::SILENCE_USER)) {
if (this->check_flag(Flag::SILENCE_USER)) {
flags_str += "SILENCE_USER,";
}
if (this->flags & static_cast<uint32_t>(Flag::CHANGE_EVENT)) {
if (this->check_flag(Flag::CHANGE_EVENT)) {
flags_str += "CHANGE_EVENT,";
}
if (this->flags & static_cast<uint32_t>(Flag::ANNOUNCE)) {
if (this->check_flag(Flag::ANNOUNCE)) {
flags_str += "ANNOUNCE,";
}
if (this->flags & static_cast<uint32_t>(Flag::FREE_JOIN_GAMES)) {
if (this->check_flag(Flag::FREE_JOIN_GAMES)) {
flags_str += "FREE_JOIN_GAMES,";
}
if (this->flags & static_cast<uint32_t>(Flag::DEBUG)) {
if (this->check_flag(Flag::DEBUG)) {
flags_str += "DEBUG,";
}
if (this->flags & static_cast<uint32_t>(Flag::CHEAT_ANYWHERE)) {
if (this->check_flag(Flag::CHEAT_ANYWHERE)) {
flags_str += "CHEAT_ANYWHERE,";
}
if (this->flags & static_cast<uint32_t>(Flag::DISABLE_QUEST_REQUIREMENTS)) {
if (this->check_flag(Flag::DISABLE_QUEST_REQUIREMENTS)) {
flags_str += "ALWAYS_ENABLE_CHAT_COMMANDS,";
}
if (this->flags & static_cast<uint32_t>(Flag::IS_SHARED_ACCOUNT)) {
if (this->check_flag(Flag::IS_SHARED_ACCOUNT)) {
flags_str += "IS_SHARED_ACCOUNT,";
}
}
@@ -336,53 +339,70 @@ void Account::print(FILE* stream) const {
} else if (phosg::ends_with(flags_str, ",")) {
flags_str.pop_back();
}
fprintf(stream, " Flags: %08" PRIX32 " (%s)\n", this->flags, flags_str.c_str());
ret += phosg::string_printf(" Flags: %08" PRIX32 " (%s)\n", this->flags, flags_str.c_str());
}
if (this->user_flags) {
string user_flags_str = "";
if (this->check_user_flag(UserFlag::DISABLE_DROP_NOTIFICATION_BROADCAST)) {
user_flags_str += "DISABLE_DROP_NOTIFICATION_BROADCAST,";
}
if (user_flags_str.empty()) {
user_flags_str = "none";
} else if (phosg::ends_with(user_flags_str, ",")) {
user_flags_str.pop_back();
}
ret += phosg::string_printf(" User flags: %08" PRIX32 " (%s)\n", this->user_flags, user_flags_str.c_str());
}
if (this->ban_end_time) {
string time_str = phosg::format_time(this->ban_end_time);
fprintf(stream, " Banned until: %" PRIu64 " (%s)\n", this->ban_end_time, time_str.c_str());
ret += phosg::string_printf(" Banned until: %" PRIu64 " (%s)\n", this->ban_end_time, time_str.c_str());
}
if (this->ep3_current_meseta || this->ep3_total_meseta_earned) {
fprintf(stream, " Episode 3 meseta: %" PRIu32 " (total earned: %" PRIu32 ")\n", this->ep3_current_meseta, this->ep3_total_meseta_earned);
ret += phosg::string_printf(" Episode 3 meseta: %" PRIu32 " (total earned: %" PRIu32 ")\n",
this->ep3_current_meseta, this->ep3_total_meseta_earned);
}
if (!this->last_player_name.empty()) {
fprintf(stream, " Last player name: \"%s\"\n", this->last_player_name.c_str());
ret += phosg::string_printf(" Last player name: \"%s\"\n", this->last_player_name.c_str());
}
if (!this->auto_reply_message.empty()) {
fprintf(stream, " Auto reply message: \"%s\"\n", this->auto_reply_message.c_str());
ret += phosg::string_printf(" Auto reply message: \"%s\"\n", this->auto_reply_message.c_str());
}
if (this->bb_team_id) {
fprintf(stream, " BB team ID: %08" PRIX32 "\n", this->bb_team_id);
ret += phosg::string_printf(" BB team ID: %08" PRIX32 "\n", this->bb_team_id);
}
if (this->is_temporary) {
fprintf(stream, " Is temporary license: true\n");
ret += phosg::string_printf(" Is temporary license: true\n");
}
for (const auto& it : this->dc_nte_licenses) {
fprintf(stream, " DC NTE license: serial_number=%s access_key=%s\n",
ret += phosg::string_printf(" DC NTE license: serial_number=%s access_key=%s\n",
it.second->serial_number.c_str(), it.second->access_key.c_str());
}
for (const auto& it : this->dc_licenses) {
fprintf(stream, " DC license: serial_number=%" PRIX32 " access_key=%s\n",
ret += phosg::string_printf(" DC license: serial_number=%" PRIX32 " access_key=%s\n",
it.second->serial_number, it.second->access_key.c_str());
}
for (const auto& it : this->pc_licenses) {
fprintf(stream, " PC license: serial_number=%" PRIX32 " access_key=%s\n",
ret += phosg::string_printf(" PC license: serial_number=%" PRIX32 " access_key=%s\n",
it.second->serial_number, it.second->access_key.c_str());
}
for (const auto& it : this->gc_licenses) {
fprintf(stream, " GC license: serial_number=%010" PRIu32 " access_key=%s password=%s\n",
ret += phosg::string_printf(" GC license: serial_number=%010" PRIu32 " access_key=%s password=%s\n",
it.second->serial_number, it.second->access_key.c_str(), it.second->password.c_str());
}
for (const auto& it : this->xb_licenses) {
fprintf(stream, " XB license: gamertag=%s user_id=%016" PRIX64 " account_id=%016" PRIX64 "\n",
ret += phosg::string_printf(" XB license: gamertag=%s user_id=%016" PRIX64 " account_id=%016" PRIX64 "\n",
it.second->gamertag.c_str(), it.second->user_id, it.second->account_id);
}
for (const auto& it : this->bb_licenses) {
fprintf(stream, " BB license: username=%s password=%s\n",
ret += phosg::string_printf(" BB license: username=%s password=%s\n",
it.second->username.c_str(), it.second->password.c_str());
}
phosg::strip_trailing_whitespace(ret);
return ret;
}
void Account::save() const {
@@ -399,6 +419,49 @@ void Account::delete_file() const {
remove(filename.c_str());
}
uint64_t Login::proxy_session_id() const {
uint64_t low_part = 0;
if (this->dc_nte_license) {
low_part = this->dc_nte_license->proxy_session_id_part();
} else if (this->dc_license) {
low_part = this->dc_license->proxy_session_id_part();
} else if (this->pc_license) {
low_part = this->pc_license->proxy_session_id_part();
} else if (this->gc_license) {
low_part = this->gc_license->proxy_session_id_part();
} else if (this->xb_license) {
low_part = this->xb_license->proxy_session_id_part();
} else if (this->bb_license) {
low_part = this->bb_license->proxy_session_id_part();
} else {
throw logic_error("none of the licenses in a Login were present");
}
return (static_cast<uint64_t>(this->account->account_id) << 32) | low_part;
}
string Login::str() const {
string ret = phosg::string_printf("Account:%08" PRIX32, this->account->account_id);
if (this->account_was_created) {
ret += " (new)";
}
if (this->dc_nte_license) {
ret += phosg::string_printf(" via DC NTE serial number %s", this->dc_nte_license->serial_number.c_str());
} else if (this->dc_license) {
ret += phosg::string_printf(" via DC serial number %08" PRIX32, this->dc_license->serial_number);
} else if (this->pc_license) {
ret += phosg::string_printf(" via PC serial number %08" PRIX32, this->pc_license->serial_number);
} else if (this->gc_license) {
ret += phosg::string_printf(" via GC serial number %010" PRIu32, this->gc_license->serial_number);
} else if (this->xb_license) {
ret += phosg::string_printf(" via XB user ID %016" PRIX64, this->xb_license->user_id);
} else if (this->bb_license) {
ret += phosg::string_printf(" via BB username %s", this->bb_license->username.c_str());
} else {
ret += phosg::string_printf(" artificially");
}
return ret;
}
size_t AccountIndex::count() const {
shared_lock g(this->lock);
return this->by_account_id.size();
@@ -421,7 +484,7 @@ shared_ptr<Login> AccountIndex::from_dc_nte_credentials_locked(const string& ser
throw incorrect_access_key();
}
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
return login;
}
@@ -471,7 +534,7 @@ shared_ptr<Login> AccountIndex::from_dc_credentials_locked(
throw incorrect_access_key();
}
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
if (is_shared) {
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
@@ -544,7 +607,7 @@ shared_ptr<Login> AccountIndex::from_pc_credentials_locked(
throw incorrect_access_key();
}
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
if (is_shared) {
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
@@ -600,7 +663,7 @@ shared_ptr<Login> AccountIndex::from_gc_credentials_locked(
throw incorrect_password();
}
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
if (is_shared) {
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
@@ -644,16 +707,12 @@ shared_ptr<Login> AccountIndex::from_gc_credentials(
}
}
shared_ptr<Login> AccountIndex::from_xb_credentials_locked(const string& gamertag, uint64_t user_id, uint64_t account_id) {
shared_ptr<Login> AccountIndex::from_xb_credentials_locked(uint64_t user_id) {
auto login = make_shared<Login>();
login->account = this->by_xb_gamertag.at(gamertag);
login->xb_license = login->account->xb_licenses.at(gamertag);
if ((login->xb_license->user_id && (login->xb_license->user_id != user_id)) ||
(login->xb_license->account_id && (login->xb_license->account_id != account_id))) {
throw incorrect_access_key();
}
login->account = this->by_xb_user_id.at(user_id);
login->xb_license = login->account->xb_licenses.at(user_id);
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
return login;
}
@@ -666,13 +725,13 @@ shared_ptr<Login> AccountIndex::from_xb_credentials(
try {
shared_lock g(this->lock);
return this->from_xb_credentials_locked(gamertag, user_id, account_id);
return this->from_xb_credentials_locked(user_id);
} catch (const out_of_range&) {
}
unique_lock g(this->lock);
try {
return this->from_xb_credentials_locked(gamertag, user_id, account_id);
return this->from_xb_credentials_locked(user_id);
} catch (const out_of_range&) {
}
@@ -685,7 +744,7 @@ shared_ptr<Login> AccountIndex::from_xb_credentials(
lic->gamertag = gamertag;
lic->user_id = user_id;
lic->account_id = account_id;
login->account->xb_licenses.emplace(lic->gamertag, lic);
login->account->xb_licenses.emplace(lic->user_id, lic);
login->xb_license = lic;
this->add_locked(login->account);
return login;
@@ -702,7 +761,7 @@ shared_ptr<Login> AccountIndex::from_bb_credentials_locked(const string& usernam
throw incorrect_password();
}
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
throw invalid_argument("user is banned");
throw account_banned();
}
return login;
}
@@ -782,8 +841,8 @@ void AccountIndex::add_locked(shared_ptr<Account> a) {
}
}
for (const auto& it : a->xb_licenses) {
if (this->by_xb_gamertag.count(it.second->gamertag)) {
throw runtime_error("account already exists with this XB gamertag");
if (this->by_xb_user_id.count(it.second->user_id)) {
throw runtime_error("account already exists with this XB user ID");
}
}
for (const auto& it : a->bb_licenses) {
@@ -810,7 +869,7 @@ void AccountIndex::add_locked(shared_ptr<Account> a) {
this->by_gc_serial_number[it.second->serial_number] = a;
}
for (const auto& it : a->xb_licenses) {
this->by_xb_gamertag[it.second->gamertag] = a;
this->by_xb_user_id[it.second->user_id] = a;
}
for (const auto& it : a->bb_licenses) {
this->by_bb_username[it.second->username] = a;
@@ -839,7 +898,7 @@ void AccountIndex::remove(uint32_t account_id) {
this->by_gc_serial_number.erase(it.second->serial_number);
}
for (const auto& it : a->xb_licenses) {
this->by_xb_gamertag.erase(it.second->gamertag);
this->by_xb_user_id.erase(it.second->user_id);
}
for (const auto& it : a->bb_licenses) {
this->by_bb_username.erase(it.second->username);
@@ -887,12 +946,12 @@ void AccountIndex::add_gc_license(shared_ptr<Account> account, shared_ptr<GCLice
}
void AccountIndex::add_xb_license(shared_ptr<Account> account, shared_ptr<XBLicense> license) {
if (!this->by_xb_gamertag.emplace(license->gamertag, account).second) {
throw runtime_error("gamertag already registered");
if (!this->by_xb_user_id.emplace(license->user_id, account).second) {
throw runtime_error("user ID already registered");
}
if (!account->xb_licenses.emplace(license->gamertag, license).second) {
this->by_xb_gamertag.erase(license->gamertag);
throw logic_error("gamertag registered in account but not in account index");
if (!account->xb_licenses.emplace(license->user_id, license).second) {
this->by_xb_user_id.erase(license->user_id);
throw logic_error("user ID registered in account but not in account index");
}
}
@@ -950,12 +1009,12 @@ void AccountIndex::remove_gc_license(shared_ptr<Account> account, uint32_t seria
account->gc_licenses.erase(it);
}
void AccountIndex::remove_xb_license(shared_ptr<Account> account, const string& gamertag) {
auto it = account->xb_licenses.find(gamertag);
void AccountIndex::remove_xb_license(shared_ptr<Account> account, uint64_t user_id) {
auto it = account->xb_licenses.find(user_id);
if (it == account->xb_licenses.end()) {
throw runtime_error("license not registered to account");
}
if (!this->by_xb_gamertag.erase(it->second->gamertag)) {
if (!this->by_xb_user_id.erase(it->second->user_id)) {
throw runtime_error("license registered in account but not in account index");
}
account->xb_licenses.erase(it);
+51 -8
View File
@@ -2,6 +2,7 @@
#include <memory>
#include <mutex>
#include <phosg/Hash.hh>
#include <phosg/JSON.hh>
#include <shared_mutex>
#include <string>
@@ -16,6 +17,10 @@ struct DCNTELicense {
std::string serial_number;
std::string access_key;
inline uint64_t proxy_session_id_part() const {
return phosg::fnv1a32(this->serial_number);
}
static std::shared_ptr<DCNTELicense> from_json(const phosg::JSON& json);
phosg::JSON json() const;
};
@@ -24,6 +29,10 @@ struct V1V2License {
uint32_t serial_number = 0;
std::string access_key;
inline uint64_t proxy_session_id_part() const {
return this->serial_number;
}
static std::shared_ptr<V1V2License> from_json(const phosg::JSON& json);
phosg::JSON json() const;
};
@@ -33,6 +42,10 @@ struct GCLicense {
std::string access_key;
std::string password;
inline uint64_t proxy_session_id_part() const {
return this->serial_number;
}
static std::shared_ptr<GCLicense> from_json(const phosg::JSON& json);
phosg::JSON json() const;
};
@@ -42,6 +55,10 @@ struct XBLicense {
uint64_t user_id = 0;
uint64_t account_id = 0;
inline uint64_t proxy_session_id_part() const {
return phosg::fnv1a32(this->gamertag);
}
static std::shared_ptr<XBLicense> from_json(const phosg::JSON& json);
phosg::JSON json() const;
};
@@ -50,6 +67,10 @@ struct BBLicense {
std::string username;
std::string password;
inline uint64_t proxy_session_id_part() const {
return phosg::fnv1a32(this->username);
}
static std::shared_ptr<BBLicense> from_json(const phosg::JSON& json);
phosg::JSON json() const;
};
@@ -76,11 +97,15 @@ struct Account {
UNUSED_BITS = 0x70FFFF00,
// clang-format on
};
enum class UserFlag : uint32_t {
DISABLE_DROP_NOTIFICATION_BROADCAST = 0x00000001,
};
// account_id is also the account's guild card number
uint32_t account_id = 0;
uint32_t flags = 0;
uint32_t user_flags = 0;
uint64_t ban_end_time = 0; // 0 = not banned
std::string last_player_name;
std::string auto_reply_message;
@@ -97,7 +122,7 @@ struct Account {
std::unordered_map<uint32_t, std::shared_ptr<V1V2License>> dc_licenses;
std::unordered_map<uint32_t, std::shared_ptr<V1V2License>> pc_licenses;
std::unordered_map<uint32_t, std::shared_ptr<GCLicense>> gc_licenses;
std::unordered_map<std::string, std::shared_ptr<XBLicense>> xb_licenses;
std::unordered_map<uint64_t, std::shared_ptr<XBLicense>> xb_licenses;
std::unordered_map<std::string, std::shared_ptr<BBLicense>> bb_licenses;
Account() = default;
@@ -124,7 +149,20 @@ struct Account {
this->flags = static_cast<uint32_t>(mask);
}
void print(FILE* stream) const;
[[nodiscard]] inline bool check_user_flag(UserFlag flag) const {
return !!(this->user_flags & static_cast<uint32_t>(flag));
}
inline void set_user_flag(UserFlag flag) {
this->user_flags |= static_cast<uint32_t>(flag);
}
inline void clear_user_flag(UserFlag flag) {
this->user_flags &= (~static_cast<uint32_t>(flag));
}
inline void toggle_user_flag(UserFlag flag) {
this->user_flags ^= static_cast<uint32_t>(flag);
}
std::string str() const;
};
struct Login {
@@ -139,6 +177,10 @@ struct Login {
std::shared_ptr<GCLicense> gc_license;
std::shared_ptr<XBLicense> xb_license;
std::shared_ptr<BBLicense> bb_license;
uint64_t proxy_session_id() const;
std::string str() const;
};
class AccountIndex {
@@ -159,6 +201,10 @@ public:
public:
missing_account() : invalid_argument("missing account") {}
};
class account_banned : public std::invalid_argument {
public:
account_banned() : invalid_argument("account is banned") {}
};
explicit AccountIndex(bool force_all_temporary);
virtual ~AccountIndex() = default;
@@ -181,7 +227,7 @@ public:
void remove_dc_license(std::shared_ptr<Account> account, uint32_t serial_number);
void remove_pc_license(std::shared_ptr<Account> account, uint32_t serial_number);
void remove_gc_license(std::shared_ptr<Account> account, uint32_t serial_number);
void remove_xb_license(std::shared_ptr<Account> account, const std::string& gamertag);
void remove_xb_license(std::shared_ptr<Account> account, uint64_t user_id);
void remove_bb_license(std::shared_ptr<Account> account, const std::string& username);
std::shared_ptr<Account> from_account_id(uint32_t account_id) const;
@@ -232,7 +278,7 @@ protected:
std::unordered_map<uint32_t, std::shared_ptr<Account>> by_dc_serial_number;
std::unordered_map<uint32_t, std::shared_ptr<Account>> by_pc_serial_number;
std::unordered_map<uint32_t, std::shared_ptr<Account>> by_gc_serial_number;
std::unordered_map<std::string, std::shared_ptr<Account>> by_xb_gamertag;
std::unordered_map<uint64_t, std::shared_ptr<Account>> by_xb_user_id;
std::unordered_map<std::string, std::shared_ptr<Account>> by_bb_username;
void add_locked(std::shared_ptr<Account> a);
@@ -253,10 +299,7 @@ protected:
const std::string& access_key,
const std::string* password,
const std::string& character_name);
std::shared_ptr<Login> from_xb_credentials_locked(
const std::string& gamertag,
uint64_t user_id,
uint64_t account_id);
std::shared_ptr<Login> from_xb_credentials_locked(uint64_t user_id);
std::shared_ptr<Login> from_bb_credentials_locked(
const std::string& username,
const std::string* password);
+11 -1
View File
@@ -5,10 +5,20 @@
#include <utility>
#include <vector>
struct DiffEntry {
uint32_t address;
std::string a_data;
std::string b_data;
};
inline void run_address_translator(const std::string&, const std::string&, const std::string&) {
throw std::runtime_error("resource_file is not available; install it and rebuild newserv");
}
inline std::vector<std::pair<uint32_t, std::string>> diff_dol_files(const std::string&, const std::string&) {
inline std::vector<DiffEntry> diff_dol_files(const std::string&, const std::string&) {
throw std::runtime_error("resource_file is not available; install it and rebuild newserv");
}
inline std::vector<DiffEntry> diff_xbe_files(const std::string&, const std::string&) {
throw std::runtime_error("resource_file is not available; install it and rebuild newserv");
}
+191 -13
View File
@@ -5,6 +5,7 @@
#include <phosg/Filesystem.hh>
#include <phosg/Strings.hh>
#include <resource_file/ExecutableFormats/DOLFile.hh>
#include <resource_file/ExecutableFormats/PEFile.hh>
#include <resource_file/ExecutableFormats/XBEFile.hh>
using namespace std;
@@ -112,9 +113,13 @@ public:
this->directory.pop_back();
}
for (const auto& filename : phosg::list_directory(this->directory)) {
if (filename.size() < 4) {
continue;
}
string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename;
if (phosg::ends_with(filename, ".dol")) {
string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename;
ResourceDASM::DOLFile dol(path.c_str());
auto mem = make_shared<ResourceDASM::MemoryContext>();
dol.load_into(mem);
@@ -122,16 +127,18 @@ public:
this->enable_ppc = true;
this->log.info("Loaded %s", name.c_str());
} else if (phosg::ends_with(filename, ".xbe")) {
string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename;
ResourceDASM::XBEFile xbe(path.c_str());
auto mem = make_shared<ResourceDASM::MemoryContext>();
xbe.load_into(mem);
this->mems.emplace(name, mem);
this->log.info("Loaded %s", name.c_str());
} else if (phosg::ends_with(filename, ".exe")) {
ResourceDASM::PEFile pe(path.c_str());
auto mem = make_shared<ResourceDASM::MemoryContext>();
pe.load_into(mem);
this->mems.emplace(name, mem);
this->log.info("Loaded %s", name.c_str());
} else if (phosg::ends_with(filename, ".bin")) {
string name = filename.substr(0, filename.size() - 4);
string path = directory + "/" + filename;
string data = phosg::load_file(path);
auto mem = make_shared<ResourceDASM::MemoryContext>();
mem->allocate_at(0x8C010000, data.size());
@@ -246,8 +253,8 @@ public:
phosg::StringReader src_r = this->src_mem->reader(src_section.first + src_offset - match_bytes_before, match_length);
for (const auto& dest_section : dest_mem->allocated_blocks()) {
for (size_t dest_match_offset = 0;
dest_match_offset + match_length < dest_section.second;
dest_match_offset += (is_ppc ? 4 : 1)) {
dest_match_offset + match_length < dest_section.second;
dest_match_offset += (is_ppc ? 4 : 1)) {
src_r.go(0);
phosg::StringReader dest_r = dest_mem->reader(dest_section.first + dest_match_offset, match_length);
size_t z;
@@ -428,6 +435,127 @@ public:
}
}
uint32_t find_be_to_le_data_match(
shared_ptr<const ResourceDASM::MemoryContext> dest_mem,
uint32_t src_addr,
uint32_t src_size) const {
if (src_size == 0) {
src_size = 4;
}
pair<uint32_t, uint32_t> src_section = make_pair(0, 0);
for (const auto& sec : this->src_mem->allocated_blocks()) {
if (src_addr >= sec.first && src_addr + src_size <= sec.first + sec.second) {
src_section = sec;
break;
}
}
if (!src_section.second) {
throw runtime_error("source address not within any section");
}
size_t src_offset = src_addr - src_section.first;
size_t src_bytes_available_before = src_offset;
size_t src_bytes_available_after = src_section.second - src_offset - 4;
size_t match_bytes_before = 0;
size_t match_bytes_after = 0;
while (match_bytes_before + match_bytes_after + 4 < 0x100) {
size_t num_matches = 0;
size_t last_match_address = 0;
size_t match_length = match_bytes_before + match_bytes_after + 4;
uint32_t src_addr = src_section.first + src_offset - match_bytes_before;
phosg::StringReader src_r = this->src_mem->reader(src_addr, match_length);
for (const auto& dest_section : dest_mem->allocated_blocks()) {
for (size_t dest_match_offset = 0;
dest_match_offset + match_length < dest_section.second;
dest_match_offset += 4) {
src_r.go(0);
phosg::StringReader dest_r = dest_mem->reader(dest_section.first + dest_match_offset, match_length);
size_t z;
for (z = 0; z < match_length; z += 4) {
uint32_t src_v = src_r.get_u32b();
uint32_t dest_v = dest_r.get_u32l();
bool src_is_addr = ((src_v & 0xFE000003) == 0x80000000);
bool dest_is_addr = ((dest_v >= 0x00010000) && (dest_v <= 0x00800000));
if (src_is_addr != dest_is_addr) {
break;
} else if (src_v != dest_v) {
break;
}
}
if (z == match_length) {
num_matches++;
last_match_address = dest_section.first + dest_match_offset + match_bytes_before;
}
}
}
this->log.info("... For match length %zX, %zu matches found", match_length, num_matches);
if (num_matches == 1) {
return last_match_address;
} else if (num_matches == 0) {
throw runtime_error("did not find exactly one match");
}
bool can_expand_backward = (src_bytes_available_before >= match_bytes_before + 4);
bool can_expand_forward = (src_bytes_available_after >= match_bytes_after + 4);
if (!can_expand_backward && !can_expand_forward) {
throw runtime_error("no further expansion is allowed");
}
if (can_expand_backward) {
match_bytes_before += 4;
}
if (can_expand_forward) {
match_bytes_after += 4;
}
}
throw runtime_error("scan field too long; too many matches");
}
void find_all_be_to_le_data_matches(uint32_t src_addr, uint32_t src_size) const {
if (!this->src_mem) {
throw runtime_error("no source file selected");
}
map<string, uint32_t> results;
for (const auto& it : this->mems) {
if (it.second == this->src_mem) {
log.info("(%s) %08" PRIX32 " (from source)", it.first.c_str(), src_addr);
results.emplace(it.first, src_addr);
} else {
uint32_t ret = 0;
try {
ret = this->find_be_to_le_data_match(it.second, src_addr, src_size);
log.info("(%s) %08" PRIX32, it.first.c_str(), ret);
} catch (const exception& e) {
log.error("(%s) failed: %s", it.first.c_str(), e.what());
}
if (ret == 0) {
log.error("(%s) no match found", it.first.c_str());
} else {
results.emplace(it.first, ret);
}
}
}
for (const auto& it : results) {
fprintf(stdout, "%s => %08" PRIX32 "\n", it.first.c_str(), it.second);
}
}
void find_data(const std::string& data) const {
for (const auto& [name, mem] : this->mems) {
for (const auto& [sec_addr, sec_size] : mem->allocated_blocks()) {
uint32_t last_addr = sec_addr + sec_size - data.size();
for (uint32_t addr = sec_addr; addr < last_addr; addr++) {
if (!mem->memcmp(addr, data.data(), data.size())) {
fprintf(stderr, "%s => %08" PRIX32 "\n", name.c_str(), addr);
}
}
}
}
}
void handle_command(const string& command) {
auto tokens = phosg::split(command, ' ');
if (tokens.empty()) {
@@ -437,10 +565,16 @@ public:
if (tokens[0] == "use") {
this->set_source_file(tokens.at(1));
} else if (tokens[0] == "find") {
this->find_data(phosg::parse_data_string(tokens.at(1)));
} else if (tokens[0] == "match") {
this->find_all_matches(
stoul(tokens.at(1), nullptr, 16),
tokens.size() >= 3 ? stoul(tokens[2], nullptr, 16) : 0);
} else if (tokens[0] == "match-be-le") {
this->find_all_be_to_le_data_matches(
stoul(tokens.at(1), nullptr, 16),
tokens.size() >= 3 ? stoul(tokens[2], nullptr, 16) : 0);
} else if (tokens[0] == "find-ppc-globals") {
this->find_ppc_rtoc_global_regs();
} else if (!tokens[0].empty()) {
@@ -489,7 +623,7 @@ void run_address_translator(const std::string& directory, const std::string& use
}
}
vector<pair<uint32_t, string>> diff_dol_files(const string& a_filename, const string& b_filename) {
vector<DiffEntry> diff_dol_files(const string& a_filename, const string& b_filename) {
ResourceDASM::DOLFile a(a_filename.c_str());
ResourceDASM::DOLFile b(b_filename.c_str());
auto a_mem = make_shared<ResourceDASM::MemoryContext>();
@@ -508,7 +642,7 @@ vector<pair<uint32_t, string>> diff_dol_files(const string& a_filename, const st
max_addr = max<uint32_t>(max_addr, sec.address + sec.data.size());
}
vector<pair<uint32_t, string>> ret;
vector<DiffEntry> ret;
for (uint32_t addr = min_addr; addr < max_addr; addr += 4) {
bool a_exists = a_mem->exists(addr, 4);
bool b_exists = b_mem->exists(addr, 4);
@@ -516,10 +650,54 @@ vector<pair<uint32_t, string>> diff_dol_files(const string& a_filename, const st
string a_value = a_mem->read(addr, 4);
string b_value = b_mem->read(addr, 4);
if (a_value != b_value) {
if (!ret.empty() && (ret.back().first + ret.back().second.size() == addr)) {
ret.back().second += b_value;
if (!ret.empty() && (ret.back().address + ret.back().b_data.size() == addr)) {
ret.back().a_data += a_value;
ret.back().b_data += b_value;
} else {
ret.emplace_back(make_pair(addr, b_value));
ret.emplace_back(DiffEntry{.address = addr, .a_data = a_value, .b_data = b_value});
}
}
}
}
return ret;
}
vector<DiffEntry> diff_xbe_files(const string& a_filename, const string& b_filename) {
ResourceDASM::XBEFile a(a_filename.c_str());
ResourceDASM::XBEFile b(b_filename.c_str());
auto a_mem = make_shared<ResourceDASM::MemoryContext>();
auto b_mem = make_shared<ResourceDASM::MemoryContext>();
a.load_into(a_mem);
b.load_into(b_mem);
uint32_t min_addr = 0xFFFFFFFF;
uint32_t max_addr = 0x00000000;
for (const auto& sec : a.sections) {
min_addr = min<uint32_t>(min_addr, sec.addr);
max_addr = max<uint32_t>(max_addr, sec.addr + sec.size);
}
for (const auto& sec : b.sections) {
min_addr = min<uint32_t>(min_addr, sec.addr);
max_addr = max<uint32_t>(max_addr, sec.addr + sec.size);
}
vector<DiffEntry> ret;
for (uint32_t addr = min_addr; addr < max_addr; addr++) {
bool a_exists = a_mem->exists(addr, 1);
bool b_exists = b_mem->exists(addr, 1);
if (a_exists && b_exists) {
uint8_t a_value = a_mem->read_u8(addr);
uint8_t b_value = b_mem->read_u8(addr);
if (a_value != b_value) {
if (!ret.empty() && (ret.back().address + ret.back().b_data.size() == addr)) {
auto& entry = ret.back();
entry.a_data.push_back(a_value);
entry.b_data.push_back(b_value);
} else {
auto& entry = ret.emplace_back();
entry.address = addr;
entry.a_data.push_back(a_value);
entry.b_data.push_back(b_value);
}
}
}
+8 -1
View File
@@ -6,5 +6,12 @@
#include <utility>
#include <vector>
struct DiffEntry {
uint32_t address;
std::string a_data;
std::string b_data;
};
void run_address_translator(const std::string& directory, const std::string& use_filename, const std::string& command);
std::vector<std::pair<uint32_t, std::string>> diff_dol_files(const std::string& a_filename, const std::string& b_filename);
std::vector<DiffEntry> diff_dol_files(const std::string& a_filename, const std::string& b_filename);
std::vector<DiffEntry> diff_xbe_files(const std::string& a_filename, const std::string& b_filename);
+1 -1
View File
@@ -92,7 +92,7 @@ public:
private:
struct File {
std::shared_ptr<const std::string> data;
const Table* table;
const Table* table = nullptr;
};
// Indexed as [online/offline][episode]
+2 -2
View File
@@ -263,7 +263,7 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
size_t send_data_size = 0;
switch (this->version) {
case Version::DC_NTE:
case Version::DC_V1_11_2000_PROTOTYPE:
case Version::DC_11_2000:
case Version::DC_V1:
case Version::DC_V2:
case Version::GC_NTE:
@@ -274,7 +274,7 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
PSOCommandHeaderDCV3 header;
if (this->crypt_out.get() &&
(this->version != Version::DC_NTE) &&
(this->version != Version::DC_V1_11_2000_PROTOTYPE) &&
(this->version != Version::DC_11_2000) &&
(this->version != Version::DC_V1)) {
send_data_size = (sizeof(header) + size + 3) & ~3;
} else {
+2770 -2534
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -10,5 +10,5 @@
#include "ProxyServer.hh"
#include "ServerState.hh"
void on_chat_command(std::shared_ptr<Client> c, const std::string& text);
void on_chat_command(std::shared_ptr<ProxyServer::LinkedSession> ses, const std::string& text);
void on_chat_command(std::shared_ptr<Client> c, const std::string& text, bool check_permissions);
void on_chat_command(std::shared_ptr<ProxyServer::LinkedSession> ses, const std::string& text, bool check_permissions);
+1 -1
View File
@@ -108,7 +108,7 @@ const vector<ChoiceSearchCategory> CHOICE_SEARCH_CATEGORIES({
}
switch (target_c->version()) {
case Version::DC_NTE:
case Version::DC_V1_11_2000_PROTOTYPE:
case Version::DC_11_2000:
return (choice_id == 0x0001);
case Version::DC_V1:
return (choice_id == 0x0002);
+58 -76
View File
@@ -33,6 +33,7 @@ void Client::Config::set_flags_for_version(Version version, int64_t sub_version)
this->set_flag(Flag::SAVE_ENABLED);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
return;
}
@@ -44,27 +45,30 @@ void Client::Config::set_flags_for_version(Version version, int64_t sub_version)
this->set_flag(Flag::NO_D6);
break;
case Version::DC_NTE:
case Version::DC_V1_11_2000_PROTOTYPE:
case Version::DC_11_2000:
case Version::DC_V1:
this->set_flag(Flag::NO_D6);
break;
case Version::DC_V2:
this->set_flag(Flag::NO_D6);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
break;
case Version::PC_NTE:
case Version::PC_V2:
this->set_flag(Flag::NO_D6);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_CHECKSUM_ONLY);
// SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE not set here
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
break;
case Version::GC_NTE:
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
break;
case Version::GC_EP3_NTE:
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::ENCRYPTED_SEND_FUNCTION_CALL);
break;
case Version::GC_V3:
@@ -76,6 +80,7 @@ void Client::Config::set_flags_for_version(Version version, int64_t sub_version)
// TODO: Do all versions of XB need this flag? US does, at least.
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
break;
default:
@@ -83,43 +88,48 @@ void Client::Config::set_flags_for_version(Version version, int64_t sub_version)
}
break;
case 0x20: // DCNTE, possibly also DCv1 JP
case 0x20: // DC NTE, 11/2000, DCv1 JP
case 0x21: // DCv1 US
case 0x22: // DCv1 EU, 12/2000, and 01/2001, at 50Hz (presumably)
case 0x23: // DCv1 EU, 12/2000, and 01/2001, at 60Hz (presumably)
case 0x22: // DCv1 EU, 12/2000, and 01/2001, at 50Hz
case 0x23: // DCv1 EU, 12/2000, and 01/2001, at 60Hz
this->set_flag(Flag::NO_D6);
break;
case 0x25: // DCv2 JP
case 0x26: // DCv2 US
case 0x27: // DCv2 EU 50Hz (presumably)
case 0x28: // DCv2 EU 60Hz (presumably)
case 0x26: // DCv2 US and 08/2001
case 0x27: // DCv2 EU 50Hz
case 0x28: // DCv2 EU 60Hz
this->set_flag(Flag::NO_D6);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
break;
case 0x29: // PC
case 0x29: // PCv2
this->set_flag(Flag::NO_D6);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_CHECKSUM_ONLY);
// SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE not set here
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
this->set_flag(Flag::CAN_RECEIVE_ENABLE_B2_QUEST);
break;
case 0x30: // GC Ep1&2 GameJam demo, GC Ep1&2 Trial Edition, GC Ep1&2 JP v1.2, at least one version of XB
case 0x30: // GC Ep1&2 GameJam demo, GC Ep1&2 Trial Edition, GC Ep1&2 JP v1.2, XB JP
case 0x31: // GC Ep1&2 US v1.0, GC US v1.1, XB US
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
break;
case 0x32: // GC Ep1&2 EU 50Hz
case 0x33: // GC Ep1&2 EU 60Hz
case 0x34: // GC Ep1&2 JP v1.3
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
break;
case 0x35: // GC Ep1&2 JP v1.4 (Plus)
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::ENCRYPTED_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
break;
case 0x3A: // GC Ep1&2 US v1.2 (Plus) GMK edition
case 0x3A: // GC Ep1&2 US v1.2 (Plus) Return to Ragol
this->set_flag(Flag::IS_CLIENT_CUSTOMIZATION);
[[fallthrough]];
case 0x36: // GC Ep1&2 US v1.2 (Plus)
@@ -127,15 +137,16 @@ void Client::Config::set_flags_for_version(Version version, int64_t sub_version)
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
this->set_flag(Flag::CAN_RECEIVE_ENABLE_B2_QUEST);
break;
case 0x40: // GC Ep3 JP and Trial Edition (and BB)
case 0x40: // GC Ep3 JP and Trial Edition (and BB, but BB is handled above)
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
this->set_flag(Flag::HAS_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE);
this->set_flag(Flag::ENCRYPTED_SEND_FUNCTION_CALL);
this->set_flag(Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);
// sub_version can't be used to tell JP final and Trial Edition apart; we
// instead look at header.flag in the 61 command and set the version then.
break;
case 0x41: // GC Ep3 US (and BB)
case 0x41: // GC Ep3 US (and BB, but BB is handled above)
case 0x42: // GC Ep3 EU 50Hz
case 0x43: // GC Ep3 EU 60Hz
this->set_flag(Flag::NO_D6_AFTER_LOBBY);
@@ -195,8 +206,6 @@ Client::Client(
bb_connection_phase(0xFF),
ping_start_time(0),
sub_version(-1),
x(0.0f),
z(0.0f),
floor(0),
lobby_client_id(0),
lobby_arrow_color(0),
@@ -274,10 +283,12 @@ void Client::update_channel_name() {
auto player = this->character(false, false);
if (player) {
string name_str = player->disp.name.decode(this->language());
this->channel.name = phosg::string_printf("C-%" PRIX64 " (%s) @ %s", this->id, name_str.c_str(), ip_str.c_str());
size_t level = player->disp.stats.level + 1;
this->channel.name = phosg::string_printf("C-%" PRIX64 " (%s Lv.%zu) @ %s", this->id, name_str.c_str(), level, ip_str.c_str());
} else {
this->channel.name = phosg::string_printf("C-%" PRIX64 " @ %s", this->id, ip_str.c_str());
}
this->log.info("Channel name updated from player data: %s", this->channel.name.c_str());
}
void Client::reschedule_save_game_data_event() {
@@ -405,6 +416,9 @@ bool Client::can_see_quest(
uint8_t difficulty,
size_t num_players,
bool v1_present) const {
if (!q->has_version_any_language(this->version())) {
return false;
}
return this->evaluate_quest_availability_expression(q->available_expression, game, event, difficulty, num_players, v1_present);
}
@@ -415,6 +429,12 @@ bool Client::can_play_quest(
uint8_t difficulty,
size_t num_players,
bool v1_present) const {
if (!q->has_version_any_language(this->version())) {
return false;
}
if (num_players >= q->max_players) {
return false;
}
return this->evaluate_quest_availability_expression(q->enabled_expression, game, event, difficulty, num_players, v1_present);
}
@@ -479,6 +499,14 @@ void Client::suspend_timeouts() {
this->log.info("Timeouts suspended");
}
void Client::set_login(shared_ptr<Login> login) {
this->login = login;
if (this->log.should_log(phosg::LogLevel::INFO)) {
string login_str = this->login->str();
this->log.info("Login: %s", login_str.c_str());
}
}
void Client::create_battle_overlay(shared_ptr<const BattleRules> rules, shared_ptr<const LevelTable> level_table) {
this->overlay_character_data = make_shared<PSOBBCharacterFile>(*this->character(true, false));
@@ -759,32 +787,24 @@ void Client::load_all_files() {
if (this->character_data) {
player_data_log.info("Using loaded character file %s", char_filename.c_str());
} else if (phosg::isfile(char_filename)) {
auto f = phosg::fopen_unique(char_filename, "rb");
auto header = phosg::freadx<PSOCommandHeaderBB>(f.get());
if (header.size != 0x399C) {
throw runtime_error("incorrect size in character file header");
}
if (header.command != 0x00E7) {
throw runtime_error("incorrect command in character file header");
}
if (header.flag != 0x00000000) {
throw runtime_error("incorrect flag in character file header");
}
static_assert(sizeof(PSOBBCharacterFile) + sizeof(PSOBBFullSystemFile) == 0x3994, ".psochar size is incorrect");
this->character_data = make_shared<PSOBBCharacterFile>(phosg::freadx<PSOBBCharacterFile>(f.get()));
auto psochar = PSOCHARFile::load_shared(char_filename, !this->system_data);
this->character_data = psochar.character_file;
files_manager->set_character(char_filename, this->character_data);
player_data_log.info("Loaded character data from %s", char_filename.c_str());
// If there was no .psosys file, load the system file from the .psochar
// If there was no .psosys file, use the system file from the .psochar
// file instead
if (!this->system_data) {
this->system_data = make_shared<PSOBBBaseSystemFile>(phosg::freadx<PSOBBBaseSystemFile>(f.get()));
if (!psochar.system_file) {
throw logic_error("account system data not present, and also not loaded from psochar file");
}
this->system_data = psochar.system_file;
files_manager->set_system(sys_filename, this->system_data);
player_data_log.info("Loaded system data from %s", char_filename.c_str());
}
this->update_character_data_after_load(this->character_data);
this->system_data->base.language = this->language();
this->system_data->language = this->language();
} else {
player_data_log.info("Character file is missing: %s", char_filename.c_str());
@@ -813,7 +833,7 @@ void Client::load_all_files() {
throw runtime_error("account data header is incorrect");
}
if (!this->system_data) {
this->system_data = make_shared<PSOBBBaseSystemFile>(nsa_data->system_file.base);
this->system_data = make_shared<PSOBBBaseSystemFile>(nsa_data->system_file);
files_manager->set_system(sys_filename, this->system_data);
player_data_log.info("Loaded legacy system data from %s", nsa_filename.c_str());
}
@@ -949,23 +969,7 @@ void Client::save_character_file(
const string& filename,
shared_ptr<const PSOBBBaseSystemFile> system,
shared_ptr<const PSOBBCharacterFile> character) {
auto f = phosg::fopen_unique(filename, "wb");
PSOCommandHeaderBB header = {sizeof(PSOCommandHeaderBB) + sizeof(PSOBBCharacterFile) + sizeof(PSOBBBaseSystemFile) + sizeof(PSOBBTeamMembership), 0x00E7, 0x00000000};
phosg::fwritex(f.get(), header);
phosg::fwritex(f.get(), *character);
phosg::fwritex(f.get(), *system);
// TODO: Technically, we should write the actual team membership struct to the
// file here, but that would cause Client to depend on Account, which
// it currently does not. This data doesn't matter at all for correctness
// within newserv, since it ignores this data entirely and instead generates
// the membership struct from the team ID in the Account and the team's state.
// So, writing correct data here would mostly be for compatibility with other
// PSO servers. But if the other server is newserv, then this data would be
// used anyway, and if it's not, then it would presumably have a different set
// of teams with a different set of team IDs anyway, so the membership struct
// here would be useless either way.
static const PSOBBTeamMembership empty_membership;
phosg::fwritex(f.get(), empty_membership);
PSOCHARFile::save(filename, system, character);
player_data_log.info("Saved character file %s", filename.c_str());
}
@@ -1007,18 +1011,7 @@ void Client::save_guild_card_file() const {
void Client::load_backup_character(uint32_t account_id, size_t index) {
string filename = this->backup_character_filename(account_id, index, false);
auto f = phosg::fopen_unique(filename, "rb");
auto header = phosg::freadx<PSOCommandHeaderBB>(f.get());
if (header.size != 0x399C) {
throw runtime_error("incorrect size in character file header");
}
if (header.command != 0x00E7) {
throw runtime_error("incorrect command in character file header");
}
if (header.flag != 0x00000000) {
throw runtime_error("incorrect flag in character file header");
}
this->character_data = make_shared<PSOBBCharacterFile>(phosg::freadx<PSOBBCharacterFile>(f.get()));
this->character_data = PSOCHARFile::load_shared(filename, false).character_file;
this->update_character_data_after_load(this->character_data);
this->v1_v2_last_reported_disp.reset();
}
@@ -1026,7 +1019,7 @@ void Client::load_backup_character(uint32_t account_id, size_t index) {
shared_ptr<PSOGCEp3CharacterFile::Character> Client::load_ep3_backup_character(uint32_t account_id, size_t index) {
string filename = this->backup_character_filename(account_id, index, true);
auto ch = make_shared<PSOGCEp3CharacterFile::Character>(phosg::load_object_file<PSOGCEp3CharacterFile::Character>(filename));
this->character_data = PSOBBCharacterFile::create_from_ep3(*ch);
this->character_data = PSOBBCharacterFile::create_from_file(*ch);
this->ep3_config = make_shared<Episode3::PlayerConfig>(ch->ep3_config);
this->update_character_data_after_load(this->character_data);
this->v1_v2_last_reported_disp.reset();
@@ -1106,18 +1099,7 @@ void Client::use_character_bank(int8_t index) {
this->external_bank_character_index = index;
player_data_log.info("Using loaded character file %s for external bank", filename.c_str());
} else if (phosg::isfile(filename)) {
auto f = phosg::fopen_unique(filename, "rb");
auto header = phosg::freadx<PSOCommandHeaderBB>(f.get());
if (header.size != 0x399C) {
throw runtime_error("incorrect size in character file header");
}
if (header.command != 0x00E7) {
throw runtime_error("incorrect command in character file header");
}
if (header.flag != 0x00000000) {
throw runtime_error("incorrect flag in character file header");
}
this->external_bank_character = make_shared<PSOBBCharacterFile>(phosg::freadx<PSOBBCharacterFile>(f.get()));
this->external_bank_character = PSOCHARFile::load_shared(filename, false).character_file;
this->update_character_data_after_load(this->external_bank_character);
this->external_bank_character_index = index;
files_manager->set_character(filename, this->external_bank_character);
+7 -9
View File
@@ -35,7 +35,7 @@ public:
// TODO: It'd be nice to use a pattern here (e.g. all server-side flags are
// in the high bits) but that would require re-recording or manually
// rewriting all the tests
CLIENT_SIDE_MASK = 0xFF3CFFFF7C0BFFFB,
CLIENT_SIDE_MASK = 0xEF3CFFFF7C0BFFFB,
// Version-related flags
CHECKED_FOR_DC_V1_PROTOTYPE = 0x0000000000000002,
@@ -46,7 +46,7 @@ public:
// Flags describing the behavior for send_function_call
HAS_SEND_FUNCTION_CALL = 0x0000000000001000,
ENCRYPTED_SEND_FUNCTION_CALL = 0x0000000000002000,
SEND_FUNCTION_CALL_CHECKSUM_ONLY = 0x0000000000004000,
SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE = 0x0000000000004000,
SEND_FUNCTION_CALL_NO_CACHE_PATCH = 0x0000000000008000,
CAN_RECEIVE_ENABLE_B2_QUEST = 0x0000000000020000,
AWAITING_ENABLE_B2_QUEST = 0x0000000000040000, // Server-side only
@@ -73,6 +73,7 @@ public:
SHOULD_SEND_ENABLE_SAVE = 0x0004000000000000,
SWITCH_ASSIST_ENABLED = 0x0000000100000000,
IS_CLIENT_CUSTOMIZATION = 0x0100000000000000,
EP3_ALLOW_6xBC = 0x1000000000000000, // Server-side only
// Cheat mode and option flags
INFINITE_HP_ENABLED = 0x0000000200000000,
@@ -204,10 +205,9 @@ public:
// Lobby/positioning
Config config;
Config synced_config;
std::unique_ptr<parray<le_uint32_t, 0x20>> override_variations;
std::unique_ptr<Variations> override_variations;
int32_t sub_version;
float x;
float z;
VectorXZF pos;
uint32_t floor;
std::weak_ptr<Lobby> lobby;
uint8_t lobby_client_id;
@@ -250,7 +250,7 @@ public:
std::unique_ptr<PendingItemTrade> pending_item_trade;
std::unique_ptr<PendingCardTrade> pending_card_trade;
uint32_t telepipe_lobby_id;
G_SetTelepipeState_6x68 telepipe_state;
TelepipeState telepipe_state;
std::shared_ptr<Episode3::PlayerConfig> ep3_config; // Null for non-Ep3
int8_t bb_character_index;
ItemData bb_identify_result;
@@ -258,7 +258,6 @@ public:
// Miscellaneous (used by chat commands)
uint32_t next_exp_value; // next EXP value to give
RecentSwitchFlags recent_switch_flags; // used for switch assist
bool can_chat;
struct PendingCharacterExport {
std::shared_ptr<const Account> dest_account;
@@ -335,8 +334,7 @@ public:
void suspend_timeouts();
const std::string& get_bb_username() const;
void set_bb_username(const std::string& bb_username);
void set_login(std::shared_ptr<Login> login);
void create_battle_overlay(std::shared_ptr<const BattleRules> rules, std::shared_ptr<const LevelTable> level_table);
void create_challenge_overlay(Version version, size_t template_index, std::shared_ptr<const LevelTable> level_table);
+1007 -860
View File
File diff suppressed because it is too large Load Diff
+136
View File
@@ -0,0 +1,136 @@
#pragma once
#include <phosg/Encoding.hh>
#include <phosg/Vector.hh>
#include "Text.hh"
struct VectorXZF {
le_float x = 0.0;
le_float z = 0.0;
inline VectorXZF operator-() const {
return VectorXZF{-this->x, -this->z};
}
inline VectorXZF operator+(const VectorXZF& other) const {
return VectorXZF{this->x + other.x, this->z + other.z};
}
inline VectorXZF operator-(const VectorXZF& other) const {
return VectorXZF{this->x - other.x, this->z - other.z};
}
inline bool operator==(const VectorXZF& other) const {
return ((this->x == other.x) && (this->z == other.z));
}
inline bool operator!=(const VectorXZF& other) const {
return !this->operator==(other);
}
inline double norm() const {
return sqrt(this->norm2());
}
inline double norm2() const {
return ((this->x * this->x) + (this->z * this->z));
}
inline std::string str() const {
return phosg::string_printf("[VectorXZF x=%g z=%g]", this->x.load(), this->z.load());
}
} __packed_ws__(VectorXZF, 0x08);
struct VectorXYZF {
le_float x = 0.0;
le_float y = 0.0;
le_float z = 0.0;
inline operator VectorXZF() const {
return VectorXZF{this->x, this->z};
}
inline VectorXYZF operator-() const {
return VectorXYZF{-this->x, -this->y, -this->z};
}
inline VectorXYZF operator+(const VectorXYZF& other) const {
return VectorXYZF{this->x + other.x, this->y + other.y, this->z + other.z};
}
inline VectorXYZF operator-(const VectorXYZF& other) const {
return VectorXYZF{this->x - other.x, this->y - other.y, this->z - other.z};
}
inline bool operator==(const VectorXYZF& other) const {
return ((this->x == other.x) && (this->y == other.y) && (this->z == other.z));
}
inline bool operator!=(const VectorXYZF& other) const {
return !this->operator==(other);
}
inline double norm() const {
return sqrt(this->norm2());
}
inline double norm2() const {
return ((this->x * this->x) + (this->y * this->y) + (this->z * this->z));
}
inline std::string str() const {
return phosg::string_printf("[VectorXYZF x=%g y=%g z=%g]", this->x.load(), this->y.load(), this->z.load());
}
} __packed_ws__(VectorXYZF, 0x0C);
struct VectorXYZTF {
le_float x = 0.0;
le_float y = 0.0;
le_float z = 0.0;
le_float t = 0.0;
} __packed_ws__(VectorXYZTF, 0x10);
struct VectorXYZI {
le_uint32_t x = 0;
le_uint32_t y = 0;
le_uint32_t z = 0;
} __packed_ws__(VectorXYZI, 0x0C);
template <bool BE>
struct ArrayRefT {
static constexpr bool IsBE = BE;
/* 00 */ U32T<BE> count;
/* 04 */ U32T<BE> offset;
/* 08 */
} __packed__;
using ArrayRef = ArrayRefT<false>;
using ArrayRefBE = ArrayRefT<true>;
check_struct_size(ArrayRef, 8);
check_struct_size(ArrayRefBE, 8);
template <bool BE>
struct RELFileFooterT {
static constexpr bool IsBE = BE;
// Relocations is a list of words (le_uint16_t on DC/PC/XB/BB, be_uint16_t on
// GC) containing the number of doublewords (uint32_t) to skip for each
// relocation. The relocation pointer starts immediately after the
// checksum_size field in the header, and advances by the value of one
// relocation word (times 4) before each relocation. At each relocated
// doubleword, the address of the first byte of the code (after checksum_size)
// is added to the existing value.
// For example, if the code segment contains the following data (where R
// specifies doublewords to relocate):
// RR RR RR RR ?? ?? ?? ?? ?? ?? ?? ?? RR RR RR RR
// RR RR RR RR ?? ?? ?? ?? RR RR RR RR
// then the relocation words should be 0000, 0003, 0001, and 0002.
// If there is a small number of relocations, they may be placed in the unused
// fields of this structure to save space and/or confuse reverse engineers.
// The game never accesses the last 12 bytes of this structure unless
// relocations_offset points there, so those 12 bytes may also be omitted
// entirely in situations (e.g. in the B2 command, without changing code_size,
// so code_size would technically extend beyond the end of the B2 command).
U32T<BE> relocations_offset = 0;
U32T<BE> num_relocations = 0;
parray<U32T<BE>, 2> unused1;
U32T<BE> root_offset = 0;
parray<U32T<BE>, 3> unused2;
} __attribute__((packed));
using RELFileFooter = RELFileFooterT<false>;
using RELFileFooterBE = RELFileFooterT<true>;
check_struct_size(RELFileFooter, 0x20);
check_struct_size(RELFileFooterBE, 0x20);
+9 -9
View File
@@ -1281,15 +1281,15 @@ string bc0_decompress(const void* data, size_t size) {
}
}
// Control bit 0 means to perform a backreference copy. The offset and
// size are stored in two bytes in the input stream, laid out as follows:
// a1 = 0bBBBBBBBB
// a2 = 0bAAAACCCC
// The offset is the concatenation of bits AAAABBBBBBBB, which refers to a
// position in the memo; the number of bytes to copy is (CCCC + 3). The
// decompressor copies that many bytes from that offset in the memo, and
// writes them to the output and to the current position in the memo.
if ((control_stream_bits & 1) == 0) {
// Control bit 0 means to perform a backreference copy. The offset and
// size are stored in two bytes in the input stream, laid out as follows:
// a1 = 0bBBBBBBBB
// a2 = 0bAAAACCCC
// The offset is the concatenation of bits AAAABBBBBBBB, which refers to
// a position in the memo; the number of bytes to copy is (CCCC + 3). The
// decompressor copies that many bytes from that offset in the memo, and
// writes them to the output and to the current position in the memo.
uint8_t a1 = r.get_u8();
if (r.eof()) {
break;
@@ -1304,9 +1304,9 @@ string bc0_decompress(const void* data, size_t size) {
memo_offset = (memo_offset + 1) & 0x0FFF;
}
} else {
// Control bit 1 means to write a byte directly from the input to the
// output. As above, the byte is also written to the memo.
} else {
uint8_t v = r.get_u8();
w.put_u8(v);
memo[memo_offset] = v;
+81 -48
View File
@@ -2,6 +2,7 @@
#include <stdint.h>
#include <mutex>
#include <phosg/Random.hh>
#include <phosg/Strings.hh>
#include <phosg/Time.hh>
@@ -24,6 +25,7 @@ static const uint32_t primes1[] = {
0x313, 0x31D, 0x329, 0x32B, 0x335, 0x337, 0x33B, 0x33D, 0x347, 0x355, 0x359,
0x35B, 0x35F, 0x36D, 0x371, 0x373, 0x377, 0x38B, 0x38F, 0x397, 0x3A1, 0x3A9,
0x3AD, 0x3B3, 0x3B9, 0x3C7, 0x3CB, 0x3D1, 0x3D7, 0x3DF, 0x3E5};
static const uint32_t primes2[] = {
0x3F1, 0x3F5, 0x3FB, 0x3FD, 0x407, 0x409, 0x40F, 0x419, 0x41B, 0x425, 0x427,
0x42D, 0x43F, 0x443, 0x445, 0x449, 0x44F, 0x455, 0x45D, 0x463, 0x469, 0x47F,
@@ -135,6 +137,8 @@ static const uint32_t primes2[] = {
0x2627, 0x2629, 0x2635, 0x263B, 0x263F, 0x264B, 0x2653, 0x2659, 0x2665,
0x2669, 0x266F, 0x267B, 0x2681, 0x2683, 0x268F, 0x269B, 0x269F, 0x26AD,
0x26B3, 0x26C3, 0x26C9, 0x26CB, 0x26D5, 0x26DD, 0x26EF, 0x26F5};
static constexpr size_t num_primes2 = sizeof(primes2) / sizeof(primes2[0]);
static const uint32_t primes3[] = {
0x2717, 0x2719, 0x2735, 0x2737, 0x274D, 0x2753, 0x2755, 0x275F, 0x276B,
0x276D, 0x2773, 0x2777, 0x277F, 0x2795, 0x279B, 0x279D, 0x27A7, 0x27AF,
@@ -1107,15 +1111,19 @@ static const uint32_t primes3[] = {
0x18569, 0x1857B, 0x1857D, 0x18581, 0x18587, 0x18589, 0x18595, 0x185B1,
0x185B7, 0x185CB, 0x185D1, 0x185E1, 0x185E9, 0x185EF, 0x185F5, 0x185F9,
0x185FF, 0x18613, 0x1861F};
static constexpr size_t num_primes3 = sizeof(primes3) / sizeof(primes3[0]);
static bool check_prime3(uint64_t prime3) {
static vector<bool> primes3_set;
static mutex primes3_init_mutex;
if (primes3_set.empty()) {
size_t num_primes3 = sizeof(primes3) / sizeof(primes3[0]);
size_t primes3_set_size = primes3[num_primes3 - 1] - primes3[0] + 1;
primes3_set.resize(primes3_set_size, false);
for (size_t z = 0; z < num_primes3; z++) {
primes3_set[primes3[z] - primes3[0]] = true;
lock_guard g(primes3_init_mutex);
if (primes3_set.empty()) {
size_t primes3_set_size = primes3[num_primes3 - 1] - primes3[0] + 1;
primes3_set.resize(primes3_set_size, false);
for (size_t z = 0; z < num_primes3; z++) {
primes3_set[primes3[z] - primes3[0]] = true;
}
}
}
uint64_t offset = prime3 - primes3[0];
@@ -1227,8 +1235,8 @@ bool dc_serial_number_is_valid_slow(const string& s, uint8_t domain, uint8_t sub
}
for (; offset1 < limit1; offset1++) {
for (size_t offset2 = 0; offset2 < sizeof(primes2) / sizeof(primes2[0]); offset2++) {
for (size_t offset3 = 0; offset3 < sizeof(primes3) / sizeof(primes3[0]); offset3++) {
for (size_t offset2 = 0; offset2 < num_primes2; offset2++) {
for (size_t offset3 = 0; offset3 < num_primes3; offset3++) {
if (primes1[offset1] * primes2[offset2] * primes3[offset3] == serial_number) {
return true;
}
@@ -1251,7 +1259,7 @@ bool decoded_dc_serial_number_is_valid_fast(uint32_t serial_number, uint8_t doma
continue;
}
uint64_t sub1 = sub0 / primes1[offset1];
for (size_t offset2 = 0; offset2 < sizeof(primes2) / sizeof(primes2[0]); offset2++) {
for (size_t offset2 = 0; offset2 < num_primes2; offset2++) {
if (sub1 % primes2[offset2]) {
continue;
}
@@ -1293,8 +1301,8 @@ string generate_dc_serial_number(uint8_t domain, uint8_t subdomain) {
size_t det1 = (subdomain == 0xFF) ? phosg::random_object<uint32_t>() : subdomain;
size_t index1 = offset1 + (det1 % (limit1 - offset1));
size_t index2 = phosg::random_object<uint32_t>() % (sizeof(primes2) / sizeof(primes2[0]));
size_t index3 = phosg::random_object<uint32_t>() % (sizeof(primes3) / sizeof(primes3[0]));
size_t index2 = phosg::random_object<uint32_t>() % num_primes2;
size_t index3 = phosg::random_object<uint32_t>() % num_primes3;
uint32_t value = primes1[index1] * primes2[index2] * primes3[index3];
string s = phosg::string_printf("%08X", value);
@@ -1306,54 +1314,79 @@ string generate_dc_serial_number(uint8_t domain, uint8_t subdomain) {
}
unordered_map<uint32_t, string> generate_all_dc_serial_numbers(uint8_t domain, uint8_t subdomain) {
vector<uint8_t> domains;
if (domain == 0xFF) {
domains.emplace_back(0x00);
domains.emplace_back(0x01);
domains.emplace_back(0x02);
} else {
domains.emplace_back(domain);
DCSerialNumberIterator iter;
if (domain < 3) {
iter.domain = domain;
iter.end_domain = domain + 1;
} else if (domain != 0xFF) {
throw runtime_error("invalid domain");
}
vector<uint8_t> subdomains;
if (subdomain == 0xFF) {
subdomains.emplace_back(0x00);
subdomains.emplace_back(0x01);
subdomains.emplace_back(0x02);
} else {
subdomains.emplace_back(subdomain);
if (subdomain < 3) {
iter.subdomain = subdomain;
iter.start_subdomain = subdomain;
iter.end_subdomain = subdomain + 1;
} else if (subdomain != 0xFF) {
throw runtime_error("invalid subdomain");
}
uint32_t serial_number;
unordered_map<uint32_t, string> ret;
for (uint8_t domain : domains) {
size_t offset1, limit1;
if (domain == 0) {
offset1 = 0x00;
limit1 = 0x03;
} else if (domain == 1) {
offset1 = 0x1E;
limit1 = 0x21;
} else if (domain == 2) {
offset1 = 0x3C;
limit1 = 0x3F;
} else {
throw runtime_error("invalid domain");
}
for (uint8_t subdomain : subdomains) {
size_t index1 = offset1 + (subdomain % (limit1 - offset1));
for (size_t index2 = 0; index2 < sizeof(primes2) / sizeof(primes2[0]); index2++) {
for (size_t index3 = 0; index3 < sizeof(primes3) / sizeof(primes3[0]); index3++) {
uint32_t value = primes1[index1] * primes2[index2] * primes3[index3];
ret[encode_dc_serial_number_int(value)].push_back(((domain << 2) & 3) | (subdomain & 3));
}
fprintf(stderr, "... domain=%hhu subdomain=%hhu index2=%zu results=%zu (0x%zX)\n", domain, subdomain, index2, ret.size(), ret.size());
}
while ((serial_number = iter.next()) != 0) {
ret[serial_number].push_back(((iter.domain << 2) & 3) | (iter.subdomain & 3));
if (iter.index3 == 0) {
fprintf(stderr, "... (it) domain=%hhu subdomain=%hhu index2=%hu results=%zu (0x%zX)\n", iter.domain, iter.subdomain, iter.index2, ret.size(), ret.size());
}
}
return ret;
}
uint32_t DCSerialNumberIterator::next() {
if (!this->started) {
this->started = true;
} else if (!this->complete) {
this->index3++;
if (this->index3 >= num_primes3) {
this->index3 = 0;
this->index2++;
if (this->index2 >= num_primes2) {
this->index2 = 0;
this->subdomain++;
if (this->subdomain >= this->end_subdomain) {
this->subdomain = this->start_subdomain;
this->domain++;
if (this->domain >= this->end_domain) {
this->serial_number = 0;
this->complete = true;
}
}
}
}
}
if (!this->complete) {
size_t index1 = (30 * this->domain) + (this->subdomain % 3);
return encode_dc_serial_number_int(primes1[index1] * primes2[this->index2] * primes3[this->index3]);
} else {
return 0;
}
}
size_t DCSerialNumberIterator::total_count() const {
return (this->end_domain - this->start_domain) * (this->end_subdomain - this->start_subdomain) * num_primes2 * num_primes3;
}
size_t DCSerialNumberIterator::progress() const {
size_t domains_done = this->domain - this->start_domain;
size_t subdomains_per_domain = this->end_subdomain - this->start_subdomain;
size_t subdomains_done = this->subdomain - this->start_subdomain;
return (
(domains_done * subdomains_per_domain * num_primes2 * num_primes3) +
(subdomains_done * num_primes2 * num_primes3) +
(this->index2 * num_primes3) +
this->index3);
}
void dc_serial_number_speed_test(uint64_t seed) {
uint32_t effective_seed = (seed & 0xFFFFFFFF00000000) ? phosg::random_object<uint32_t>() : seed;
fprintf(stderr, "Product speed test with seed=%08" PRIX32 "\n", effective_seed);
+19
View File
@@ -20,6 +20,25 @@ bool decoded_dc_serial_number_is_valid_fast(
std::string generate_dc_serial_number(uint8_t domain, uint8_t subdomain = 0xFF);
std::unordered_map<uint32_t, std::string> generate_all_dc_serial_numbers(uint8_t domain = 0xFF, uint8_t subdomain = 0xFF);
struct DCSerialNumberIterator {
bool started = false;
bool complete = false;
uint8_t domain = 0;
uint8_t start_domain = 0;
uint8_t end_domain = 3;
uint8_t subdomain = 0;
uint8_t start_subdomain = 0;
uint8_t end_subdomain = 3;
uint16_t index2 = 0;
uint16_t index3 = 0;
uint32_t serial_number = 0;
uint32_t next();
size_t total_count() const;
size_t progress() const;
};
void dc_serial_number_speed_test(uint64_t seed = 0xFFFFFFFFFFFFFFFF);
struct EncryptedDCv2Executables {
+877
View File
@@ -0,0 +1,877 @@
#include "DownloadSession.hh"
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <event2/event.h>
#include <event2/listener.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <algorithm>
#include <iostream>
#include <phosg/Encoding.hh>
#include <phosg/Filesystem.hh>
#include <phosg/Network.hh>
#include <phosg/Random.hh>
#include <phosg/Strings.hh>
#include <phosg/Time.hh>
#include "Loggers.hh"
#include "PSOProtocol.hh"
#include "ProxyCommands.hh"
#include "ReceiveCommands.hh"
#include "ReceiveSubcommands.hh"
#include "SendCommands.hh"
using namespace std;
static string random_name() {
string ret;
size_t length = (phosg::random_object<size_t>() % 12) + 4;
static const string alphabet = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890-+<>:\"\',.";
while (ret.size() < length) {
ret.push_back(alphabet[phosg::random_object<size_t>() % alphabet.size()]);
}
return ret;
}
DownloadSession::DownloadSession(
std::shared_ptr<struct event_base> base,
const struct sockaddr_storage& remote,
const std::string& output_dir,
Version version,
uint8_t language,
std::shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file,
uint32_t serial_number2,
uint32_t serial_number,
const std::string& access_key,
const std::string& username,
const std::string& password,
const std::string& xb_gamertag,
uint64_t xb_user_id,
uint64_t xb_account_id,
std::shared_ptr<PSOBBCharacterFile> character,
const std::unordered_set<std::string>& ship_menu_selections,
const std::vector<std::string>& on_request_complete_commands,
bool interactive,
bool show_command_data)
: output_dir(output_dir),
bb_key_file(bb_key_file),
serial_number2(serial_number2),
serial_number(serial_number),
access_key(access_key),
username(username),
password(password),
xb_gamertag(xb_gamertag),
xb_user_id(xb_user_id),
xb_account_id(xb_account_id),
character(character),
ship_menu_selections(ship_menu_selections),
on_request_complete_commands(on_request_complete_commands),
interactive(interactive),
log(phosg::string_printf("[DownloadSession:%s] ", phosg::name_for_enum(version)), proxy_server_log.min_level),
base(base),
channel(
version,
language,
DownloadSession::dispatch_on_channel_input,
DownloadSession::dispatch_on_channel_error,
this,
phosg::render_sockaddr_storage(remote),
show_command_data ? phosg::TerminalFormat::FG_GREEN : phosg::TerminalFormat::END,
show_command_data ? phosg::TerminalFormat::FG_YELLOW : phosg::TerminalFormat::END),
hardware_id(generate_random_hardware_id(this->channel.version)),
guild_card_number(0),
prev_cmd_data(0),
client_config(0),
sent_96(false),
should_request_category_list(true),
current_request(0),
current_game_config_index(0),
in_game(false),
bin_complete(false),
dat_complete(false) {
if (this->output_dir.empty()) {
this->output_dir = ".";
}
switch (this->channel.version) {
case Version::DC_V1:
case Version::DC_V2:
if (this->serial_number2 == 0 || this->serial_number == 0 || this->access_key.empty()) {
throw runtime_error("missing credentials");
}
break;
case Version::PC_V2:
if (this->serial_number == 0 || this->access_key.empty()) {
throw runtime_error("missing credentials");
}
break;
case Version::GC_V3:
if (this->serial_number == 0 || this->access_key.empty() || this->password.empty()) {
throw runtime_error("missing credentials");
}
break;
case Version::XB_V3:
if (this->xb_gamertag.empty() || this->xb_user_id == 0 || this->xb_account_id == 0) {
throw runtime_error("missing credentials");
}
break;
case Version::BB_V4:
if (this->username.empty() || this->password.empty()) {
throw runtime_error("missing credentials");
}
break;
default:
throw runtime_error("unsupported version");
}
this->character->inventory.language = this->channel.language;
if (remote.ss_family != AF_INET) {
throw runtime_error("remote is not AF_INET");
}
string netloc_str = phosg::render_sockaddr_storage(remote);
this->log.info("Connecting to %s", netloc_str.c_str());
struct bufferevent* bev = bufferevent_socket_new(
this->base.get(), -1, BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
throw runtime_error(phosg::string_printf("failed to open socket (%d)", EVUTIL_SOCKET_ERROR()));
}
this->channel.set_bufferevent(bev, 0);
if (bufferevent_socket_connect(this->channel.bev.get(),
reinterpret_cast<const sockaddr*>(&remote), sizeof(struct sockaddr_in)) != 0) {
throw runtime_error(phosg::string_printf("failed to connect (%d)", EVUTIL_SOCKET_ERROR()));
}
}
void DownloadSession::dispatch_on_channel_input(Channel& ch, uint16_t command, uint32_t flag, std::string& data) {
auto* session = reinterpret_cast<DownloadSession*>(ch.context_obj);
session->on_channel_input(command, flag, data);
}
void DownloadSession::send_93_9D_9E(bool extended) {
if (is_v1(this->channel.version)) {
C_LoginExtendedV1_DC_93 ret;
ret.player_tag = this->guild_card_number ? 0xFFFF0000 : 0x00010000;
ret.guild_card_number = this->guild_card_number;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.is_extended = extended ? 1 : 0;
ret.language = this->channel.language;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.serial_number2.encode(phosg::string_printf("%08" PRIX32, this->serial_number2));
ret.name.encode(this->character->disp.name.decode());
this->channel.send(0x93, 0x01, &ret, extended ? sizeof(ret) : sizeof(C_LoginV1_DC_93));
} else if (is_v2(this->channel.version)) {
C_LoginExtended_PC_9D ret;
ret.player_tag = this->guild_card_number ? 0xFFFF0000 : 0x00010000;
ret.guild_card_number = this->guild_card_number;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.is_extended = extended ? 1 : 0;
ret.language = this->channel.language;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.serial_number2 = ret.serial_number;
ret.access_key2 = ret.access_key;
ret.name.encode(this->character->disp.name.decode());
size_t data_size = extended
? ((this->channel.version == Version::PC_V2) ? sizeof(ret) : sizeof(C_LoginExtended_DC_GC_9D))
: sizeof(C_Login_DC_PC_GC_9D);
this->channel.send(0x9D, 0x01, &ret, data_size);
} else if (this->channel.version == Version::GC_V3) {
C_LoginExtended_GC_9E ret;
ret.player_tag = this->guild_card_number ? 0xFFFF0000 : 0x00010000;
ret.guild_card_number = this->guild_card_number;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.is_extended = extended ? 1 : 0;
ret.language = this->channel.language;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.serial_number2 = ret.serial_number;
ret.access_key2 = ret.access_key;
ret.name.encode(this->character->disp.name.decode());
ret.client_config = this->client_config;
this->channel.send(0x9E, 0x01, &ret, extended ? sizeof(ret) : sizeof(C_Login_GC_9E));
} else if (this->channel.version == Version::XB_V3) {
C_LoginExtended_XB_9E ret;
ret.player_tag = this->guild_card_number ? 0xFFFF0000 : 0x00010000;
ret.guild_card_number = this->guild_card_number;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.is_extended = extended ? 1 : 0;
ret.language = this->channel.language;
ret.serial_number.encode(this->xb_gamertag);
ret.access_key.encode(phosg::string_printf("%016" PRIX64, this->xb_user_id));
ret.serial_number2 = ret.serial_number;
ret.access_key2 = ret.access_key;
ret.name.encode(this->character->disp.name.decode());
ret.netloc.internal_ipv4_address = phosg::random_object<uint32_t>();
ret.netloc.external_ipv4_address = phosg::random_object<uint32_t>();
ret.netloc.port = 9500;
phosg::random_data(&ret.netloc.mac_address, sizeof(ret.netloc.mac_address));
ret.netloc.sg_ip_address = phosg::random_object<uint32_t>();
ret.netloc.spi = phosg::random_object<uint32_t>();
ret.netloc.account_id = this->xb_account_id;
ret.netloc.unknown_a3.clear(0);
ret.xb_user_id_high = this->xb_user_id >> 32;
ret.xb_user_id_low = this->xb_user_id;
this->channel.send(0x9E, 0x01, &ret, extended ? sizeof(ret) : sizeof(C_Login_DC_PC_GC_9D));
} else {
throw runtime_error("unsupported version");
}
}
void DownloadSession::send_61_98(bool is_98) {
uint8_t command = is_98 ? 0x98 : 0x61;
if (is_v1(this->channel.version)) {
C_CharacterData_DCv1_61_98 ret;
ret.inventory = this->character->inventory;
ret.disp = convert_player_disp_data<PlayerDispDataDCPCV3, PlayerDispDataBB>(this->character->disp, 1, 1);
this->channel.send(command, 0x01, ret);
} else if (this->channel.version == Version::DC_V2) {
C_CharacterData_DCv2_61_98 ret;
ret.inventory = this->character->inventory;
ret.disp = convert_player_disp_data<PlayerDispDataDCPCV3, PlayerDispDataBB>(this->character->disp, 1, 1);
ret.records.challenge = this->character->challenge_records;
ret.records.battle = this->character->battle_records;
ret.choice_search_config = this->character->choice_search_config;
this->channel.send(command, 0x02, ret);
} else if (this->channel.version == Version::PC_V2) {
C_CharacterData_PC_61_98 ret;
ret.inventory = this->character->inventory;
ret.disp = convert_player_disp_data<PlayerDispDataDCPCV3, PlayerDispDataBB>(this->character->disp, 1, 1);
ret.records.challenge = this->character->challenge_records;
ret.records.battle = this->character->battle_records;
ret.choice_search_config = this->character->choice_search_config;
this->channel.send(command, 0x02, ret);
} else if (is_v3(this->channel.version)) {
C_CharacterData_V3_61_98 ret;
ret.inventory = this->character->inventory;
ret.disp = convert_player_disp_data<PlayerDispDataDCPCV3, PlayerDispDataBB>(this->character->disp, 1, 1);
ret.records.challenge = this->character->challenge_records;
ret.records.battle = this->character->battle_records;
ret.choice_search_config = this->character->choice_search_config;
ret.info_board.encode(this->character->info_board.decode());
this->channel.send(command, 0x03, ret);
} else if (this->channel.version == Version::BB_V4) {
C_CharacterData_BB_61_98 ret;
ret.inventory = this->character->inventory;
ret.disp = this->character->disp;
ret.records.challenge = this->character->challenge_records;
ret.records.battle = this->character->battle_records;
ret.choice_search_config = this->character->choice_search_config;
ret.info_board.encode(this->character->info_board.decode());
this->channel.send(command, 0x04, ret);
} else {
throw runtime_error("unsupported version");
}
}
void DownloadSession::on_channel_input(uint16_t command, uint32_t flag, std::string& data) {
// TODO: Use the iovec form of print_data here instead of
// prepend_command_header (which copies the string)
string full_cmd = prepend_command_header(this->channel.version, this->channel.crypt_in.get(), command, flag, data);
for (size_t z = 0; z < 0x28 && z < data.size(); z++) {
this->prev_cmd_data[z] = data[z];
}
switch (command) {
case 0x03: {
if (this->channel.version != Version::BB_V4) {
throw runtime_error("BB server sent non-BB encryption command");
}
if (!this->bb_key_file) {
throw runtime_error("BB encryption requires a key file");
}
const auto& cmd = check_size_t<S_ServerInitDefault_BB_03_9B>(data, 0xFFFF);
this->channel.crypt_in = make_shared<PSOBBEncryption>(*this->bb_key_file, &cmd.server_key[0], sizeof(cmd.server_key));
this->channel.crypt_out = make_shared<PSOBBEncryption>(*this->bb_key_file, &cmd.client_key[0], sizeof(cmd.client_key));
this->log.info("Enabled BB encryption");
throw runtime_error("not yet implemented"); // Send 93
break;
}
case 0x02:
case 0x17:
case 0x91:
case 0x9B: {
const auto& cmd = check_size_t<S_ServerInitDefault_DC_PC_V3_02_17_91_9B>(data, 0xFFFF);
if (uses_v3_encryption(this->channel.version)) {
this->channel.crypt_in = make_shared<PSOV3Encryption>(cmd.server_key);
this->channel.crypt_out = make_shared<PSOV3Encryption>(cmd.client_key);
this->log.info("Enabled V3 encryption (server key %08" PRIX32 ", client key %08" PRIX32 ")",
cmd.server_key.load(), cmd.client_key.load());
} else if (!uses_v4_encryption(this->channel.version)) {
this->channel.crypt_in = make_shared<PSOV2Encryption>(cmd.server_key);
this->channel.crypt_out = make_shared<PSOV2Encryption>(cmd.client_key);
this->log.info("Enabled V2 encryption (server key %08" PRIX32 ", client key %08" PRIX32 ")",
cmd.server_key.load(), cmd.client_key.load());
} else {
throw runtime_error("BB server sent non-BB encryption command");
}
if (command == 0x02) {
bool is_extended = (this->channel.version == Version::XB_V3);
this->send_93_9D_9E(is_extended);
} else {
if (is_v1(this->channel.version)) {
C_LoginV1_DC_PC_V3_90 ret;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
this->channel.send(0x90, 0x00, ret);
} else if (is_v2(this->channel.version)) {
C_Login_DC_PC_V3_9A ret;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.player_tag = this->guild_card_number ? 0xFFFF0000 : 0x00010000;
ret.guild_card_number = this->guild_card_number;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.serial_number2 = ret.serial_number;
ret.access_key2 = ret.access_key;
this->channel.send(0x9A, 0x00, ret);
} else if (this->channel.version == Version::GC_V3) {
C_VerifyAccount_V3_DB ret;
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.serial_number2 = ret.serial_number;
ret.access_key2 = ret.access_key;
ret.password.encode(this->password);
this->channel.send(0xDB, 0x00, ret);
} else if (this->channel.version == Version::XB_V3) {
this->send_93_9D_9E(true);
} else {
throw runtime_error("unsupported version");
}
}
break;
}
case 0x90:
case 0x9A: {
if (flag == 1) {
if (is_v1(this->channel.version)) {
C_RegisterV1_DC_92 ret;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.language = this->channel.language;
ret.serial_number2.encode(phosg::string_printf("%08" PRIX32, this->serial_number2));
this->channel.send(0x92, 0x00, ret);
} else if (!is_v4(this->channel.version)) {
C_Register_DC_PC_V3_9C ret;
ret.hardware_id = this->hardware_id;
ret.sub_version = default_sub_version_for_version(this->channel.version);
ret.language = this->channel.language;
if (this->channel.version == Version::XB_V3) {
ret.serial_number.encode(this->xb_gamertag);
ret.access_key.encode(phosg::string_printf("%016" PRIX64, this->xb_user_id));
ret.password.encode("xbox-pso");
} else {
ret.serial_number.encode(phosg::string_printf("%08" PRIX32, this->serial_number));
ret.access_key.encode(this->access_key);
ret.password.encode(this->password);
}
this->channel.send(0x9C, 0x00, ret);
} else {
throw runtime_error("unsupported version");
}
} else if (flag == 0 || flag == 2) {
this->send_93_9D_9E(true);
} else {
throw runtime_error("login failed");
}
break;
}
case 0x92:
case 0x9C:
if (flag == 0) {
throw runtime_error("server rejected login credentials");
}
this->send_93_9D_9E(true);
break;
case 0x9F: {
if (is_v1_or_v2(this->channel.version)) {
throw runtime_error("invalid command");
}
this->channel.send(0x9F, 0x00, this->client_config);
break;
}
case 0xB2: {
C_ExecuteCodeResult_B3 ret;
ret.checksum = 0;
ret.return_value = 0;
this->channel.send(0xB3, 0x00, ret);
break;
}
case 0x04: {
const auto& cmd = check_size_t<S_UpdateClientConfig_V3_04>(data, 0x08, sizeof(S_UpdateClientConfig_V3_04));
if (!is_v1_or_v2(this->channel.version)) {
for (size_t z = 0; z < 0x20; z++) {
size_t read_index = z + 8;
this->client_config[z] = (read_index < data.size()) ? data[read_index] : this->prev_cmd_data[read_index];
}
}
this->guild_card_number = cmd.guild_card_number;
if (!this->sent_96) {
C_CharSaveInfo_DCv2_PC_V3_BB_96 ret;
ret.creation_timestamp = this->character->creation_timestamp;
ret.event_counter = this->character->save_count;
this->channel.send(0x96, 0x00, ret);
this->sent_96 = true;
}
break;
}
case 0x97:
this->channel.send(0xB1, 0x00);
break;
case 0x95:
this->send_61_98(false);
break;
case 0xB1:
this->channel.send(0x99, 0x00);
break;
case 0x1A:
case 0xD5:
if (is_v3(this->channel.version)) {
this->channel.send(0xD6, 0x00);
}
break;
case 0x07:
case 0x1F:
case 0xA0:
case 0xA1: {
C_MenuSelection_10_Flag00 ret;
auto handle_command = [&]<typename CmdT>() {
const auto* items = check_size_vec_t<CmdT>(data, flag + 1);
size_t item_index;
this->log.info("Ship Select menu:");
for (item_index = 1; item_index <= flag; item_index++) {
const auto& item = items[item_index];
auto text = strip_color(item.name.decode());
this->log.info("%zu: (%08" PRIX32 " %08" PRIX32 ") %s", item_index, item.menu_id.load(), item.item_id.load(), text.c_str());
if (this->ship_menu_selections.count(text)) {
break;
}
}
if (item_index > flag) {
if (this->interactive) {
while (item_index == 0 || item_index > flag) {
this->log.info("Choose response index:");
string input = phosg::fgets(stdin);
item_index = stoul(input, nullptr, 0);
}
} else {
throw runtime_error("unhandled menu selection");
}
}
ret.menu_id = items[item_index].menu_id;
ret.item_id = items[item_index].item_id;
};
if (uses_utf16(this->channel.version)) {
handle_command.operator()<S_MenuItem_PC_BB_08>();
} else {
handle_command.operator()<S_MenuItem_DC_V3_08_Ep3_E6>();
}
this->channel.send(0x10, 0x00, ret);
break;
}
case 0x01:
case 0x11:
case 0x60:
case 0x62:
case 0x68:
case 0x69:
case 0x6C:
case 0x6D:
case 0x88:
case 0x8A:
case 0xB0:
case 0xC5:
case 0xDA:
break;
case 0x1D:
this->channel.send(0x1D, 0x00);
break;
case 0x19: {
const auto& cmd = check_size_t<S_Reconnect_19>(data, sizeof(S_Reconnect_19), 0xFFFF);
sockaddr_storage ss;
auto* sin = reinterpret_cast<sockaddr_in*>(&ss);
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(cmd.address);
sin->sin_port = htons(cmd.port);
string netloc_str = phosg::render_sockaddr_storage(ss);
this->log.info("Connecting to %s", netloc_str.c_str());
struct bufferevent* bev = bufferevent_socket_new(this->base.get(), -1, BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
throw runtime_error(phosg::string_printf("failed to open socket (%d)", EVUTIL_SOCKET_ERROR()));
}
this->channel.set_bufferevent(bev, 0);
this->channel.crypt_in.reset();
this->channel.crypt_out.reset();
if (bufferevent_socket_connect(this->channel.bev.get(), reinterpret_cast<const sockaddr*>(&ss), sizeof(struct sockaddr_in)) != 0) {
throw runtime_error(phosg::string_printf("failed to connect (%d)", EVUTIL_SOCKET_ERROR()));
}
break;
}
case 0x83: {
const auto* items = check_size_vec_t<S_LobbyListEntry_83>(data, flag, true);
this->lobby_menu_items.clear();
for (size_t z = 0; z < flag; z++) {
this->lobby_menu_items.emplace_back(items[z]);
}
break;
}
case 0x67: {
// Technically we should assign item IDs here, but the server will never
// be able to see that we didn't, so we don't bother
const auto& game_config = this->game_configs[this->current_game_config_index];
if (this->channel.version == Version::PC_V2) {
C_CreateGame_PC_C1 ret;
ret.name.encode(random_name());
ret.password.encode(random_name());
ret.difficulty = 0;
ret.battle_mode = (game_config.mode == GameMode::BATTLE);
ret.challenge_mode = (game_config.mode == GameMode::CHALLENGE);
ret.episode = 1;
this->channel.send(0xC1, 0x00, ret);
} else if (!is_v4(this->channel.version)) {
C_CreateGame_DC_V3_0C_C1_Ep3_EC ret;
ret.name.encode(random_name());
ret.password.encode(random_name());
ret.difficulty = 0;
ret.battle_mode = (game_config.mode == GameMode::BATTLE);
ret.challenge_mode = (game_config.mode == GameMode::CHALLENGE);
if (is_v1(this->channel.version)) {
ret.episode = 0;
} else if (game_config.episode == Episode::EP1) {
ret.episode = 1;
} else if (game_config.episode == Episode::EP2) {
ret.episode = 2;
} else if (game_config.episode == Episode::EP4) {
ret.episode = 4;
} else {
throw std::logic_error("invalid episode");
}
this->channel.send(is_v1(this->channel.version) ? 0x0C : 0xC1, 0x00, ret);
} else {
C_CreateGame_BB_C1 ret;
ret.name.encode(random_name());
ret.password.encode(random_name());
ret.difficulty = 0;
ret.battle_mode = (game_config.mode == GameMode::BATTLE);
ret.challenge_mode = (game_config.mode == GameMode::CHALLENGE);
if (game_config.episode == Episode::EP1) {
ret.episode = 1;
} else if (game_config.episode == Episode::EP2) {
ret.episode = 2;
} else if (game_config.episode == Episode::EP4) {
ret.episode = 4;
} else {
throw std::logic_error("invalid episode");
}
ret.solo_mode = (game_config.mode == GameMode::SOLO);
this->channel.send(is_v1(this->channel.version) ? 0x0C : 0xC1, 0x00, ret);
}
break;
}
case 0x64: {
this->in_game = true;
this->bin_complete = false;
this->dat_complete = false;
for (size_t z = 0; z < this->character->inventory.num_items; z++) {
this->character->inventory.items[z].data.id = 0x00010000 + z;
}
if (!is_v1(this->channel.version)) {
this->channel.send(0x8A, 0x00);
}
this->channel.send(0x6F, 0x00);
this->send_next_request();
break;
}
case 0xA2: {
auto handle_command = [&]<typename CmdT>() {
const auto* items = check_size_vec_t<CmdT>(data, flag);
for (size_t z = 0; z < flag; z++) {
const auto& item = items[z];
uint64_t request = (static_cast<uint64_t>(item.menu_id) << 32) | static_cast<uint64_t>(item.item_id);
if (!this->done_requests.count(request)) {
this->log.info("Adding request %016" PRIX64, request);
this->pending_requests.emplace(request, item.name.decode());
}
}
};
if (this->channel.version == Version::PC_V2) {
handle_command.operator()<S_QuestMenuEntry_PC_A2_A4>();
} else if (this->channel.version == Version::XB_V3) {
handle_command.operator()<S_QuestMenuEntry_XB_A2_A4>();
} else if (this->channel.version == Version::BB_V4) {
handle_command.operator()<S_QuestMenuEntry_BB_A2_A4>();
} else {
handle_command.operator()<S_QuestMenuEntry_DC_GC_A2_A4>();
}
this->send_next_request();
break;
}
case 0x44:
case 0xA6: {
auto handle_command = [&]<typename CmdT>() {
const auto& cmd = check_size_t<CmdT>(data, 0xFFFF);
string internal_name = cmd.filename.decode();
string filtered_name;
for (char ch : internal_name) {
filtered_name.push_back((isalnum(ch) || (ch == '-') || (ch == '.') || (ch == '_')) ? ch : '_');
}
string local_filename = phosg::string_printf(
"%s/%016" PRIX64 "_%" PRIu64 "_%s_%c_%s",
this->output_dir.c_str(),
this->current_request,
phosg::now(),
phosg::name_for_enum(this->channel.version),
char_for_language_code(this->channel.language),
filtered_name.c_str());
this->open_files.emplace(internal_name, OpenFile{.request = this->current_request, .filename = local_filename, .total_size = cmd.file_size, .data = ""});
};
if (is_dc(this->channel.version)) {
handle_command.operator()<S_OpenFile_DC_44_A6>();
} else if (!is_v4(this->channel.version)) {
handle_command.operator()<S_OpenFile_PC_GC_44_A6>();
} else {
handle_command.operator()<S_OpenFile_BB_44_A6>();
}
break;
}
case 0x13:
case 0xA7: {
const auto& cmd = check_size_t<S_WriteFile_13_A7>(data);
string internal_filename = cmd.filename.decode();
if (!is_v1_or_v2(this->channel.version)) {
C_WriteFileConfirmation_V3_BB_13_A7 ret;
ret.filename.encode(internal_filename);
this->channel.send(command, flag, ret);
}
auto f_it = this->open_files.find(internal_filename.c_str());
if (f_it == this->open_files.end()) {
this->log.warning("Received data for non-open file %s", internal_filename.c_str());
break;
}
auto& f = this->open_files.at(cmd.filename.decode());
size_t block_offset = flag * 0x400;
size_t allowed_block_size = (block_offset < f.total_size)
? min<size_t>(f.total_size - block_offset, 0x400)
: 0;
size_t data_size = min<size_t>(cmd.data_size, allowed_block_size);
size_t block_end_offset = block_offset + data_size;
if (block_end_offset > f.data.size()) {
f.data.resize(block_end_offset);
}
memcpy(f.data.data() + block_offset, cmd.data.data(), data_size);
if (cmd.data_size != 0x400) {
phosg::save_file(f.filename, f.data);
this->log.info("Wrote file %s (%zu bytes)", f.filename.c_str(), f.data.size());
this->open_files.erase(internal_filename);
if (phosg::ends_with(internal_filename, ".bin")) {
this->bin_complete = true;
} else if (phosg::ends_with(internal_filename, ".dat")) {
this->dat_complete = true;
}
if (this->open_files.empty() && this->bin_complete && this->dat_complete) {
if (is_v1_or_v2(this->channel.version)) {
this->on_request_complete();
} else {
this->channel.send(0xAC, 0x00);
}
}
}
break;
}
case 0xAC: {
if (is_v1_or_v2(this->channel.version)) {
throw runtime_error("unsupported version");
}
this->on_request_complete();
break;
}
}
}
void DownloadSession::send_next_request() {
if (should_request_category_list) {
this->log.info("Requesting quest list");
this->channel.send(0xA2, 0x00);
if (is_v4(this->channel.version)) {
this->channel.send(0xA2, 0x01);
}
this->should_request_category_list = false;
} else if (!this->pending_requests.empty()) {
if (interactive) {
const auto& config = this->game_configs[this->current_game_config_index];
this->log.info("Items available to expand (mode=%s, episode=%s):", name_for_mode(config.mode), name_for_episode(config.episode));
for (const auto& it : this->pending_requests) {
this->log.info("%016" PRIX64 ": %s", it.first, it.second.c_str());
}
this->log.info("Choose item to expand by ID (q to quit; s to skip to next config):");
string input = phosg::fgets(stdin);
if (input.empty() || (input == "q\n")) {
this->channel.disconnect();
return;
} else if (input == "s\n") {
this->pending_requests.clear();
this->on_request_complete();
} else {
this->current_request = stoull(input, nullptr, 16);
this->done_requests.emplace(this->current_request);
this->pending_requests.erase(this->current_request);
}
} else {
auto item_it = this->pending_requests.begin();
this->current_request = item_it->first;
this->done_requests.emplace(this->current_request);
this->pending_requests.erase(item_it);
this->log.info("Sending request %016" PRIX64, this->current_request);
}
C_MenuSelection_10_Flag00 cmd;
cmd.menu_id = (this->current_request >> 32) & 0xFFFFFFFF;
cmd.item_id = this->current_request & 0xFFFFFFFF;
this->channel.send(0x10, 0x00, cmd);
} else {
this->log.info("No pending requests with current parameters");
this->on_request_complete();
}
}
void DownloadSession::on_request_complete() {
for (const auto& data : this->on_request_complete_commands) {
this->channel.send(data);
}
this->send_61_98(true);
this->in_game = false;
const auto& item = this->lobby_menu_items.at(this->lobby_menu_items.size() / 2);
C_LobbySelection_84 ret84;
ret84.menu_id = item.menu_id;
ret84.item_id = item.item_id;
this->channel.send(0x84, 0x00, ret84);
if (this->pending_requests.empty()) {
// Advance to next mode/episode combination
this->current_game_config_index++;
bool v1 = is_v1(this->channel.version);
bool v2 = is_v2(this->channel.version);
bool v3 = is_v3(this->channel.version);
while ((this->current_game_config_index < this->game_configs.size()) &&
((v1 && !this->game_configs[this->current_game_config_index].v1) ||
(v2 && !this->game_configs[this->current_game_config_index].v2) ||
(v3 && !this->game_configs[this->current_game_config_index].v3))) {
this->current_game_config_index++;
}
if (this->current_game_config_index >= this->game_configs.size()) {
this->log.info("All modes complete");
this->channel.disconnect();
} else {
const auto& config = this->game_configs[this->current_game_config_index];
this->log.info("Advancing to %s mode in %s", name_for_mode(config.mode), name_for_episode(config.episode));
this->should_request_category_list = true;
}
}
}
void DownloadSession::dispatch_on_channel_error(Channel& ch, short events) {
auto* session = reinterpret_cast<DownloadSession*>(ch.context_obj);
session->on_channel_error(events);
}
void DownloadSession::on_channel_error(short events) {
if (events & BEV_EVENT_CONNECTED) {
this->log.info("Server channel connected");
}
if (events & BEV_EVENT_ERROR) {
int err = EVUTIL_SOCKET_ERROR();
this->log.warning("Error %d (%s) in server stream", err, evutil_socket_error_to_string(err));
}
if (events & (BEV_EVENT_ERROR | BEV_EVENT_EOF)) {
this->log.info("Server endpoint has disconnected");
this->channel.disconnect();
event_base_loopexit(this->base.get(), nullptr);
}
}
const std::vector<DownloadSession::GameConfig> DownloadSession::game_configs({
{.mode = GameMode::NORMAL, .episode = Episode::EP1, .v1 = true, .v2 = true, .v3 = true},
{.mode = GameMode::NORMAL, .episode = Episode::EP2, .v1 = false, .v2 = false, .v3 = true},
{.mode = GameMode::NORMAL, .episode = Episode::EP4, .v1 = false, .v2 = false, .v3 = false},
{.mode = GameMode::BATTLE, .episode = Episode::EP1, .v1 = false, .v2 = true, .v3 = true},
{.mode = GameMode::CHALLENGE, .episode = Episode::EP1, .v1 = false, .v2 = true, .v3 = true},
{.mode = GameMode::CHALLENGE, .episode = Episode::EP2, .v1 = false, .v2 = false, .v3 = true},
{.mode = GameMode::SOLO, .episode = Episode::EP1, .v1 = false, .v2 = false, .v3 = false},
{.mode = GameMode::SOLO, .episode = Episode::EP2, .v1 = false, .v2 = false, .v3 = false},
{.mode = GameMode::SOLO, .episode = Episode::EP4, .v1 = false, .v2 = false, .v3 = false},
});
+111
View File
@@ -0,0 +1,111 @@
#pragma once
#include <event2/event.h>
#include <functional>
#include <map>
#include <memory>
#include <phosg/Filesystem.hh>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "PSOEncryption.hh"
#include "PSOProtocol.hh"
#include "ServerState.hh"
class DownloadSession {
public:
DownloadSession(
std::shared_ptr<struct event_base> base,
const struct sockaddr_storage& remote,
const std::string& output_dir,
Version version,
uint8_t language,
std::shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file,
uint32_t serial_number2,
uint32_t serial_number,
const std::string& access_key,
const std::string& username,
const std::string& password,
const std::string& xb_gamertag,
uint64_t xb_user_id,
uint64_t xb_account_id,
std::shared_ptr<PSOBBCharacterFile> character,
const std::unordered_set<std::string>& ship_menu_selections,
const std::vector<std::string>& on_request_complete_commands,
bool interactive,
bool show_command_data);
DownloadSession(const DownloadSession&) = delete;
DownloadSession(DownloadSession&&) = delete;
DownloadSession& operator=(const DownloadSession&) = delete;
DownloadSession& operator=(DownloadSession&&) = delete;
virtual ~DownloadSession() = default;
protected:
// Config (must be set by caller)
std::string output_dir;
std::shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file;
uint32_t serial_number2;
uint32_t serial_number;
std::string access_key;
std::string username;
std::string password;
std::string xb_gamertag;
uint64_t xb_user_id;
uint64_t xb_account_id;
std::shared_ptr<PSOBBCharacterFile> character;
std::unordered_set<std::string> ship_menu_selections;
std::vector<std::string> on_request_complete_commands;
bool interactive;
// State (set during session)
phosg::PrefixedLogger log;
std::shared_ptr<struct event_base> base;
Channel channel;
uint64_t hardware_id;
uint32_t guild_card_number;
parray<uint8_t, 0x28> prev_cmd_data;
parray<uint8_t, 0x20> client_config;
bool sent_96;
std::vector<S_LobbyListEntry_83> lobby_menu_items;
bool should_request_category_list;
uint64_t current_request;
std::map<uint64_t, std::string> pending_requests;
std::unordered_set<uint64_t> done_requests;
struct OpenFile {
uint64_t request;
std::string filename;
size_t total_size;
std::string data;
};
std::unordered_map<std::string, OpenFile> open_files;
struct GameConfig {
GameMode mode;
Episode episode;
bool v1;
bool v2;
bool v3;
};
static const std::vector<GameConfig> game_configs;
size_t current_game_config_index;
bool in_game;
bool bin_complete;
bool dat_complete;
static void dispatch_on_channel_input(Channel& ch, uint16_t command, uint32_t flag, std::string& msg);
static void dispatch_on_channel_error(Channel& ch, short events);
void on_channel_input(uint16_t command, uint32_t flag, std::string& msg);
void on_channel_error(short events);
void send_next_request();
void on_request_complete();
void assign_item_ids(uint32_t base_item_id);
void send_93_9D_9E(bool extended);
void send_61_98(bool is_98);
};
+202 -1079
View File
File diff suppressed because it is too large Load Diff
+54 -22
View File
@@ -7,9 +7,9 @@
#include "StaticGameData.hh"
#include "Types.hh"
enum class EnemyType {
UNKNOWN = -1,
NONE = 0,
enum class EnemyType : uint8_t {
UNKNOWN = 0,
NONE,
NON_ENEMY_NPC,
AL_RAPPY,
ASTARK,
@@ -40,8 +40,8 @@ enum class EnemyType {
DE_ROL_LE_MINE,
DEATH_GUNNER,
DEL_LILY,
DEL_RAPPY,
DEL_RAPPY_ALT,
DEL_RAPPY_CRATER,
DEL_RAPPY_DESERT,
DELBITER,
DELDEPTH,
DELSABER,
@@ -54,10 +54,10 @@ enum class EnemyType {
DUBCHIC,
DUBWITCH, // Has no entry in battle params
EGG_RAPPY,
EPSIGUARD,
EPSIGARD,
EPSILON,
EVIL_SHARK,
GAEL,
GAEL_OR_GIEL,
GAL_GRYPHON,
GARANZ,
GEE,
@@ -80,6 +80,7 @@ enum class EnemyType {
KONDRIEU,
LA_DIMENIAN,
LOVE_RAPPY,
MERICARAND,
MERICAROL,
MERICUS,
MERIKLE,
@@ -97,8 +98,8 @@ enum class EnemyType {
OLGA_FLOW_2,
PAL_SHARK,
PAN_ARMS,
PAZUZU,
PAZUZU_ALT,
PAZUZU_CRATER,
PAZUZU_DESERT,
PIG_RAY,
POFUILLY_SLIME,
POUILLY_SLIME,
@@ -107,12 +108,12 @@ enum class EnemyType {
RAG_RAPPY,
RECOBOX,
RECON,
SAINT_MILLION,
SAINT_MILION,
SAINT_RAPPY,
SAND_RAPPY,
SAND_RAPPY_ALT,
SATELLITE_LIZARD,
SATELLITE_LIZARD_ALT,
SAND_RAPPY_CRATER,
SAND_RAPPY_DESERT,
SATELLITE_LIZARD_CRATER,
SATELLITE_LIZARD_DESERT,
SAVAGE_WOLF,
SHAMBERTIN,
SINOW_BEAT,
@@ -129,22 +130,53 @@ enum class EnemyType {
VOL_OPT_CORE,
VOL_OPT_MONITOR,
VOL_OPT_PILLAR,
YOWIE,
YOWIE_ALT,
YOWIE_CRATER,
YOWIE_DESERT,
ZE_BOOTA,
ZOL_GIBBON,
ZU,
ZU_ALT,
ZU_CRATER,
ZU_DESERT,
MAX_ENEMY_TYPE,
};
struct EnemyTypeDefinition {
enum Flag : uint8_t {
VALID_EP1 = 0x01,
VALID_EP2 = 0x02,
VALID_EP4 = 0x04,
IS_RARE = 0x08,
};
EnemyType type;
uint8_t flags;
uint8_t rt_index; // 0xFF if not valid (e.g. not an enemy)
uint8_t bp_index; // 0xFF if not valid (e.g. not an enemy)
const char* enum_name;
const char* in_game_name;
const char* ultimate_name; // May be null if same as in_game_name
inline bool valid_in_episode(Episode ep) const {
switch (ep) {
case Episode::EP1:
return (this->flags & Flag::VALID_EP1);
case Episode::EP2:
return (this->flags & Flag::VALID_EP2);
case Episode::EP4:
return (this->flags & Flag::VALID_EP4);
default:
throw std::logic_error("invalid episode number");
}
}
inline bool is_rare() const {
return (this->flags & Flag::IS_RARE);
}
EnemyType rare_type(Episode episode, uint8_t event, uint8_t floor) const;
};
const EnemyTypeDefinition& type_definition_for_enemy(EnemyType type);
template <>
const char* phosg::name_for_enum<EnemyType>(EnemyType type);
template <>
EnemyType phosg::enum_for_name<EnemyType>(const char* name);
bool enemy_type_valid_for_episode(Episode episode, EnemyType enemy_type);
uint8_t battle_param_index_for_enemy_type(Episode episode, EnemyType enemy_type);
uint8_t rare_table_index_for_enemy_type(EnemyType enemy_type);
const std::vector<EnemyType>& enemy_types_for_rare_table_index(Episode episode, uint8_t rt_index);
bool enemy_type_is_rare(EnemyType type);
+57 -15
View File
@@ -714,10 +714,10 @@ int32_t Card::move_to_location(const Location& loc) {
uint8_t trap_type = s->overlay_state.tiles[loc.y][loc.x] & 0x0F;
uint16_t trap_card_id = s->overlay_state.trap_card_ids_nte[trap_type];
if (other_ps->replace_assist_card_by_id(trap_card_id)) {
G_Unknown_Ep3_6xB4x2C cmd;
G_EnqueueAnimation_Ep3_6xB4x2C cmd;
cmd.change_type = 1;
cmd.client_id = other_ps->client_id;
cmd.unknown_a2[0] = trap_card_id;
cmd.trap_card_id = trap_card_id;
s->send(cmd);
}
}
@@ -728,7 +728,7 @@ int32_t Card::move_to_location(const Location& loc) {
for (size_t warp_end = 0; warp_end < 2; warp_end++) {
if ((s->warp_positions[warp_type][warp_end][0] == this->loc.x) &&
(s->warp_positions[warp_type][warp_end][1] == this->loc.y)) {
G_Unknown_Ep3_6xB4x2C cmd;
G_EnqueueAnimation_Ep3_6xB4x2C cmd;
cmd.loc.x = this->loc.x;
cmd.loc.y = this->loc.y;
this->loc.x = s->warp_positions[warp_type][warp_end ^ 1][0];
@@ -736,7 +736,8 @@ int32_t Card::move_to_location(const Location& loc) {
cmd.change_type = 0;
cmd.card_refs.clear(0xFFFF);
cmd.card_refs[0] = this->card_ref;
cmd.unknown_a2.clear(0xFFFFFFFF);
cmd.trap_card_id = 0xFFFFFFFF;
cmd.unknown_a3 = 0xFFFFFFFF;
s->send(cmd);
return 0;
}
@@ -1154,6 +1155,11 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor
}
}
}
if (log.should_log(phosg::LogLevel::DEBUG)) {
string chain_str = this->action_chain.str(s);
log.debug("result computed as %s", chain_str.c_str());
}
}
void Card::unknown_802380C0() {
@@ -1222,11 +1228,22 @@ void Card::unknown_80236374(shared_ptr<Card> other_card, const ActionState* as)
auto s = this->server();
auto log = s->log_stack(phosg::string_printf("unknown_80236374(@%04hX #%04hX, @%04hX #%04hX): ", this->get_card_ref(), this->get_card_id(), other_card->get_card_ref(), other_card->get_card_id()));
if (log.should_log(phosg::LogLevel::DEBUG)) {
if (as) {
string as_str = as->str(s);
log.debug("as = %s", as_str.c_str());
} else {
log.debug("as = null");
}
}
auto check_card = [&](shared_ptr<Card> card) -> void {
if (card) {
if (!card->unknown_80236554(other_card, as)) {
log.debug("check_card @%04hX #%04hX => false", card->get_card_ref(), card->get_card_id());
card->action_metadata.clear_flags(0x20);
} else {
log.debug("check_card @%04hX #%04hX => true", card->get_card_ref(), card->get_card_id());
card->action_metadata.set_flags(0x20);
}
}
@@ -1363,11 +1380,13 @@ bool Card::unknown_80236554(shared_ptr<Card> other_card, const ActionState* as)
auto log = s->log_stack(other_card
? phosg::string_printf("unknown_80236554(@%04hX #%04hX, @%04hX #%04hX): ", this->get_card_ref(), this->get_card_id(), other_card->get_card_ref(), other_card->get_card_id())
: phosg::string_printf("unknown_80236554(@%04hX #%04hX, null): ", this->get_card_ref(), this->get_card_id()));
if (as) {
string as_str = as->str(s);
log.debug("as = %s", as_str.c_str());
} else {
log.debug("as = null");
if (log.should_log(phosg::LogLevel::DEBUG)) {
if (as) {
string as_str = as->str(s);
log.debug("as = %s", as_str.c_str());
} else {
log.debug("as = null");
}
}
bool ret = false;
@@ -1402,32 +1421,38 @@ bool Card::unknown_80236554(shared_ptr<Card> other_card, const ActionState* as)
log.debug("last attack damage stats cleared");
if (other_card) {
s->card_special->apply_action_conditions(EffectWhen::BEFORE_ANY_CARD_ATTACK, other_card, this->shared_from_this(), 0x20, as);
s->card_special->apply_action_conditions(EffectWhen::BEFORE_THIS_CARD_ATTACKED, other_card, this->shared_from_this(), 0x40, as);
log.debug("applying BEFORE_ANY_CARD_ATTACK conditions");
s->card_special->apply_action_conditions(
EffectWhen::BEFORE_ANY_CARD_ATTACK, other_card, this->shared_from_this(), 0x20, as);
log.debug("applying BEFORE_THIS_CARD_ATTACKED conditions");
s->card_special->apply_action_conditions(
EffectWhen::BEFORE_THIS_CARD_ATTACKED, other_card, this->shared_from_this(), 0x40, as);
if (other_card->action_chain.check_flag(0x20000)) {
log.debug("attack_bonus cleared due to cancellation");
this->action_metadata.attack_bonus = 0;
return ret;
}
}
if (this->card_flags & 2) {
log.debug("attack_bonus cleared due to destruction");
this->action_metadata.attack_bonus = 0;
}
return ret;
}
void Card::unknown_802362D8(shared_ptr<Card> other_card) {
void Card::execute_attack_on_all_valid_targets(shared_ptr<Card> attacker_card) {
auto s = this->server();
for (size_t client_id = 0; client_id < 4; client_id++) {
auto ps = s->player_states[client_id];
if (ps) {
shared_ptr<Card> card = ps->get_sc_card();
if (card) {
card->execute_attack(other_card);
card->execute_attack(attacker_card);
}
for (size_t set_index = 0; set_index < 8; set_index++) {
shared_ptr<Card> card = ps->get_set_card(set_index);
if (card) {
card->execute_attack(other_card);
card->execute_attack(attacker_card);
}
}
}
@@ -1548,30 +1573,46 @@ void Card::apply_attack_result() {
}
}
if (log.should_log(phosg::LogLevel::DEBUG)) {
string as_str = as.str(s);
log.debug("as constructed as %s", as_str.c_str());
}
for (size_t z = 0; z < this->action_chain.chain.target_card_ref_count; z++) {
shared_ptr<Card> card = s->card_for_set_card_ref(this->action_chain.chain.target_card_refs[z]);
if (card) {
card->current_defense_power = card->action_metadata.attack_bonus;
if (!this->action_chain.check_flag(0x40)) {
log.debug("unknown_8024A6DC(@%04hX #%04hX) ...", card->get_card_ref(), card->get_card_id());
s->card_special->unknown_8024A6DC(this->shared_from_this(), card);
}
}
}
log.debug("compute_action_chain_results 1 ...");
this->compute_action_chain_results(true, false);
if (!this->action_chain.check_flag(0x40)) {
log.debug("apply_effects_before_attack ...");
s->card_special->apply_effects_before_attack(this->shared_from_this());
}
if (!(this->card_flags & 2)) {
log.debug("compute_action_chain_results 2 ...");
this->compute_action_chain_results(true, false);
log.debug("check_for_attack_interference ...");
s->card_special->check_for_attack_interference(this->shared_from_this());
}
log.debug("compute_action_chain_results 3 ...");
this->compute_action_chain_results(true, false);
log.debug("unknown_80236374 ...");
this->unknown_80236374(this->shared_from_this(), nullptr);
this->unknown_802362D8(this->shared_from_this());
log.debug("execute_attack_on_all_valid_targets ...");
this->execute_attack_on_all_valid_targets(this->shared_from_this());
}
if (!this->action_chain.check_flag(0x40)) {
log.debug("apply_effects_after_attack ...");
s->card_special->apply_effects_after_attack(this->shared_from_this());
}
ps->stats.num_attacks_given++;
@@ -1584,6 +1625,7 @@ void Card::apply_attack_result() {
for (size_t client_id = 0; client_id < 4; client_id++) {
auto ps = s->player_states[client_id];
if (ps) {
log.debug("unknown_8023C110(%zu) ...", client_id);
ps->unknown_8023C110();
}
}
+1 -1
View File
@@ -85,7 +85,7 @@ public:
void dice_phase_before();
bool is_guard_item() const;
bool unknown_80236554(std::shared_ptr<Card> other_card, const ActionState* as);
void unknown_802362D8(std::shared_ptr<Card> other_card);
void execute_attack_on_all_valid_targets(std::shared_ptr<Card> attacker_card);
void apply_attack_result();
private:
+153 -41
View File
@@ -244,15 +244,21 @@ void CardSpecial::apply_action_conditions(
shared_ptr<Card> defender_card,
uint32_t flags,
const ActionState* as) {
auto s = this->server();
auto log = s->log_stack("apply_action_conditions: ");
ActionState temp_as;
if (attacker_card == defender_card) {
temp_as = this->create_attack_state_from_card_action_chain(attacker_card);
if (as) {
log.debug("using action state from override");
temp_as = *as;
} else {
log.debug("using action state from attacker card");
}
} else {
temp_as = this->create_defense_state_for_card_pair_action_chains(attacker_card, defender_card);
log.debug("using action state from card pair");
}
this->apply_defense_conditions(temp_as, when, defender_card, flags);
@@ -297,22 +303,47 @@ bool CardSpecial::apply_defense_condition(
shared_ptr<Card> defender_card,
uint32_t flags,
bool unknown_p8) {
auto s = this->server();
bool is_nte = s->options.is_nte();
auto log = s->log_stack("apply_defense_condition: ");
if (log.should_log(phosg::LogLevel::DEBUG)) {
log.debug(
"when=%s, cond_index=%hhu, defender_card=(@%04hX #%04hX), flags=%08" PRIX32 ", p8=%s",
phosg::name_for_enum(when),
cond_index,
defender_card->get_card_ref(),
defender_card->get_card_id(),
flags,
unknown_p8 ? "true" : "false");
auto defender_cond_str = defender_cond->str(s);
auto defense_state_str = defense_state.str(s);
log.debug("defender_cond = %s", defender_cond_str.c_str());
log.debug("defense_state = %s", defense_state_str.c_str());
}
if (defender_cond->type == ConditionType::NONE) {
log.debug("no condition");
return false;
}
auto orig_eff = this->original_definition_for_condition(*defender_cond);
if (log.should_log(phosg::LogLevel::DEBUG)) {
auto orig_eff_str = orig_eff->str();
log.debug("orig_eff = %s", orig_eff_str.c_str());
}
uint16_t attacker_card_ref = defense_state.attacker_card_ref;
if (attacker_card_ref == 0xFFFF) {
attacker_card_ref = defense_state.original_attacker_card_ref;
}
log.debug("attacker_card_ref = @%04hX", attacker_card_ref);
auto s = this->server();
bool is_nte = s->options.is_nte();
bool defender_has_ability_trap = !is_nte && this->card_ref_has_ability_trap(*defender_cond);
log.debug("defender_has_ability_trap = %s", defender_has_ability_trap ? "true" : "false");
if ((is_nte || (flags & 4)) && !this->is_card_targeted_by_condition(*defender_cond, defense_state, defender_card)) {
log.debug("not targeted by condition");
if (defender_cond->type != ConditionType::NONE) {
G_ApplyConditionEffect_Ep3_6xB4x06 cmd;
cmd.effect.flags = 0x04;
@@ -328,6 +359,7 @@ bool CardSpecial::apply_defense_condition(
}
if ((when == EffectWhen::AFTER_ANY_CARD_ATTACK) && (defender_cond->type == ConditionType::GUOM) && (flags & 4)) {
log.debug("deleting guom condition");
CardShortStatus stat = defender_card->get_short_status();
if (stat.card_flags & 4) {
G_ApplyConditionEffect_Ep3_6xB4x06 cmd;
@@ -364,6 +396,7 @@ bool CardSpecial::apply_defense_condition(
}
if ((when == EffectWhen::BEFORE_DICE_PHASE_THIS_TEAM_TURN) && (flags & 4) && !defender_has_ability_trap && (defender_cond->type == ConditionType::ACID)) {
log.debug("applying acid");
int16_t hp = defender_card->get_current_hp();
if (hp > 0) {
this->send_6xB4x06_for_stat_delta(defender_card, defender_cond->card_ref, 0x20, -1, 0, 1);
@@ -373,9 +406,11 @@ bool CardSpecial::apply_defense_condition(
}
if (!orig_eff || (orig_eff->when != when)) {
log.debug("unsetting flag 4");
flags &= ~4;
}
if ((flags == 0) || defender_has_ability_trap) {
log.debug("no condition remains to apply");
return false;
}
@@ -392,8 +427,10 @@ bool CardSpecial::apply_defense_condition(
string expr = orig_eff->expr.decode();
int16_t expr_value = this->evaluate_effect_expr(astats, expr.c_str(), dice_roll);
log.debug("execute_effect ...");
this->execute_effect(*defender_cond, defender_card, expr_value, defender_cond->value, orig_eff->type, flags, attacker_card_ref);
if (flags & 4) {
log.debug("recomputing action chaing results");
if (is_nte || !(defender_card->card_flags & 2)) {
defender_card->compute_action_chain_results(true, false);
}
@@ -403,6 +440,7 @@ bool CardSpecial::apply_defense_condition(
}
if (dice_roll.value_used_in_expr && !(original_cond_flags & 1) && !unknown_p8) {
log.debug("dice roll was used; setting dice display flag");
defender_cond->flags |= 1;
G_ApplyConditionEffect_Ep3_6xB4x06 cmd;
cmd.effect.flags = 0x08;
@@ -3209,17 +3247,27 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
}
break;
case 0x27: // p39
ret = this->find_all_set_cards_with_cost_in_range(4, 99);
if (!s->options.is_nte()) {
ret = this->filter_cards_by_range(ret, card1, card1_loc, card2);
}
break;
case 0x28: // p40
ret = this->find_all_set_cards_with_cost_in_range(0, 3);
case 0x28: { // p40
auto log3940 = log.sub("(p39/p40) ");
ret = this->find_all_set_cards_with_cost_in_range(
(p_target_type == 0x27) ? 4 : 0,
(p_target_type == 0x27) ? 99 : 3);
if (log3940.should_log(phosg::LogLevel::DEBUG)) {
for (const auto& card : ret) {
log3940.debug("found target @%04hX #%04hX", card->get_card_ref(), card->get_card_id());
}
}
if (!s->options.is_nte()) {
log3940.debug("filtering targets");
ret = this->filter_cards_by_range(ret, card1, card1_loc, card2);
if (log3940.should_log(phosg::LogLevel::DEBUG)) {
for (const auto& card : ret) {
log3940.debug("retained target @%04hX #%04hX", card->get_card_ref(), card->get_card_id());
}
}
}
break;
}
case 0x29: { // p41
auto ps = card1->player_state();
if (card1 && ps) {
@@ -3476,41 +3524,62 @@ bool CardSpecial::is_card_targeted_by_condition(
const ActionState& as,
shared_ptr<const Card> card) const {
auto s = this->server();
auto log = s->log_stack("is_card_targeted_by_condition: ");
if (log.should_log(phosg::LogLevel::DEBUG)) {
log.debug("card=(@%04hX #%04hX)", card->get_card_ref(), card->get_card_id());
auto cond_str = cond.str(s);
auto as_str = as.str(s);
log.debug("cond = %s", cond_str.c_str());
log.debug("as = %s", as_str.c_str());
}
if (cond.type == ConditionType::NONE) {
log.debug("condition is NONE (=> true)");
return true;
}
auto ce = s->definition_for_card_ref(cond.card_ref);
auto sc_card = s->card_for_set_card_ref(cond.card_ref);
if (cond.type != ConditionType::NONE) {
if ((!sc_card || ((sc_card != card) && (sc_card->card_flags & 2))) &&
ce &&
((ce->def.type == CardType::ITEM) || ce->def.is_sc()) &&
(cond.remaining_turns != 100) &&
(s->options.is_nte() || (client_id_for_card_ref(card->get_card_ref()) == client_id_for_card_ref(cond.card_ref)))) {
return false;
}
if (cond.remaining_turns == 102) {
if (sc_card && ((sc_card == card) || !(sc_card->card_flags & 2))) {
string arg3_s = ce->def.effects[cond.card_definition_effect_index].arg3.decode();
if (arg3_s.size() < 1) {
throw runtime_error("card definition arg3 is missing");
}
auto target_cards = this->get_targeted_cards_for_condition(
cond.card_ref,
cond.card_definition_effect_index,
cond.condition_giver_card_ref,
as,
atoi(arg3_s.c_str() + 1),
0);
for (auto c : target_cards) {
if (c == card) {
return true;
}
}
}
return false;
} else {
return true;
}
if ((!sc_card || ((sc_card != card) && (sc_card->card_flags & 2))) &&
ce &&
((ce->def.type == CardType::ITEM) || ce->def.is_sc()) &&
(cond.remaining_turns != 100) &&
(s->options.is_nte() || (client_id_for_card_ref(card->get_card_ref()) == client_id_for_card_ref(cond.card_ref)))) {
log.debug("failed item or SC check (=> false)");
return false;
}
if (cond.remaining_turns != 102) {
log.debug("remaining_turns != 102 (=> true)");
return true;
}
if (sc_card && ((sc_card == card) || !(sc_card->card_flags & 2))) {
string arg3_s = ce->def.effects[cond.card_definition_effect_index].arg3.decode();
if (arg3_s.size() < 1) {
throw runtime_error("card definition arg3 is missing");
}
auto target_cards = this->get_targeted_cards_for_condition(
cond.card_ref,
cond.card_definition_effect_index,
cond.condition_giver_card_ref,
as,
atoi(arg3_s.c_str() + 1),
0);
for (auto c : target_cards) {
if (c == card) {
log.debug("targeted by p condition (=> true)");
return true;
}
}
log.debug("not targeted by p condition (=> false)");
return false;
} else {
log.debug("SC check does not apply");
return false;
}
return true;
}
void CardSpecial::on_card_set(shared_ptr<PlayerState> ps, uint16_t card_ref) {
@@ -4641,32 +4710,75 @@ vector<shared_ptr<const Card>> CardSpecial::filter_cards_by_range(
shared_ptr<const Card> card1,
const Location& card1_loc,
shared_ptr<const Card> card2) const {
auto log = this->server()->log_stack("filter_cards_by_range: ");
if (log.should_log(phosg::LogLevel::DEBUG)) {
auto card1_str = card1 ? phosg::string_printf("@%04hX #%04hX", card1->get_card_ref(), card1->get_card_id()) : "null";
auto card2_str = card2 ? phosg::string_printf("@%04hX #%04hX", card2->get_card_ref(), card2->get_card_id()) : "null";
auto loc_str = card1_loc.str();
log.debug("card1=(%s), card2=(%s), loc=%s", card1_str.c_str(), card2_str.c_str(), loc_str.c_str());
for (const auto& card : cards) {
if (card) {
log.debug("input card: @%04hX #%04hX", card->get_card_ref(), card->get_card_id());
} else {
log.debug("input card: null");
}
}
}
vector<shared_ptr<const Card>> ret;
if (!card1 || cards.empty()) {
log.debug("card1 missing or input list is blank");
return ret;
}
auto ps = card1->player_state();
if (!ps) {
log.debug("ps is missing");
return ret;
}
// TODO: Remove hardcoded card ID here (Earthquake)
uint16_t card_id = this->get_card_id_with_effective_range(card1, 0x00ED, card2);
log.debug("card_id = #%04hX", card_id);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->options.card_index, card_id, card1_loc, this->server()->map_and_rules);
if (log.should_log(phosg::LogLevel::DEBUG)) {
auto loc_str = card1_loc.str();
log.debug("compute_effective_range(range, ci, #%04hX, %s, map) =>", card_id, loc_str.c_str());
for (size_t y = 0; y < 9; y++) {
const uint8_t* row = &range[y * 9];
log.debug(" range[%zu] = %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX",
y, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]);
}
}
auto card_refs_in_range = ps->get_card_refs_within_range_from_all_players(range, card1_loc, CardType::ITEM);
if (log.should_log(phosg::LogLevel::DEBUG)) {
for (uint16_t card_ref : card_refs_in_range) {
log.debug("ref in range: @%04hX", card_ref);
}
}
for (auto card : cards) {
if (!card || (card->get_card_ref() == 0xFFFF)) {
if (card) {
log.debug("(@%04hX #%04hX) out of range", card->get_card_ref(), card->get_card_id());
} else {
log.debug("(null) card missing");
}
continue;
}
for (uint16_t card_ref_in_range : card_refs_in_range) {
if (card_ref_in_range == card->get_card_ref()) {
log.debug("(@%04hX #%04hX) in range", card->get_card_ref(), card->get_card_id());
ret.emplace_back(card);
break;
}
}
log.debug("(@%04hX #%04hX) out of range", card->get_card_ref(), card->get_card_id());
}
return ret;
}
+114 -46
View File
@@ -8,6 +8,7 @@
#include <phosg/Random.hh>
#include <phosg/Time.hh>
#include "../CommonFileFormats.hh"
#include "../Compression.hh"
#include "../Loggers.hh"
#include "../PSOEncryption.hh"
@@ -975,9 +976,25 @@ string CardDefinition::str(bool single_line, const TextSet* text_archive) const
}
}
}
string jp_name_s = this->jp_name.decode();
string en_name_short_s = this->en_short_name.decode();
string jp_name_short_s = this->jp_short_name.decode();
string names_str;
if (!en_name_s.empty()) {
names_str += phosg::string_printf(" EN: \"%s\"", en_name_s.c_str());
if (!en_name_short_s.empty() && en_name_short_s != en_name_s) {
names_str += phosg::string_printf(" (Abr. \"%s\")", en_name_short_s.c_str());
}
}
if (!jp_name_s.empty()) {
names_str += phosg::string_printf(" JP: \"%s\"", jp_name_s.c_str());
if (!jp_name_short_s.empty() && jp_name_short_s != jp_name_s) {
names_str += phosg::string_printf(" (Abr. \"%s\")", jp_name_short_s.c_str());
}
}
return phosg::string_printf(
"\
Card: %04" PRIX32 " \"%s\"\n\
Card: %04" PRIX32 "%s\n\
Type: %s, class: %s\n\
Usability condition: %s\n\
Rank: %s\n\
@@ -998,7 +1015,7 @@ Card: %04" PRIX32 " \"%s\"\n\
%s\n\
Effects:%s",
this->card_id.load(),
en_name_s.c_str(),
names_str.c_str(),
type_str.c_str(),
card_class_str.c_str(),
criterion_str.c_str(),
@@ -1177,6 +1194,7 @@ PlayerConfigNTE::PlayerConfigNTE(const PlayerConfig& config)
offline_clv_exp(config.offline_clv_exp),
online_clv_exp(config.online_clv_exp),
recent_human_opponents(config.recent_human_opponents),
recent_battle_start_timestamps(config.recent_battle_start_timestamps),
unknown_a10(config.unknown_a10),
init_timestamp(config.init_timestamp),
last_online_battle_start_timestamp(config.last_online_battle_start_timestamp),
@@ -1206,6 +1224,7 @@ PlayerConfigNTE::operator PlayerConfig() const {
ret.offline_clv_exp = this->offline_clv_exp;
ret.online_clv_exp = this->online_clv_exp;
ret.recent_human_opponents = this->recent_human_opponents;
ret.recent_battle_start_timestamps = this->recent_battle_start_timestamps;
ret.unknown_a10 = this->unknown_a10;
ret.init_timestamp = this->init_timestamp;
ret.last_online_battle_start_timestamp = this->last_online_battle_start_timestamp;
@@ -1584,6 +1603,19 @@ void StateFlags::clear_FF() {
this->client_sc_card_types.clear(CardType::INVALID_FF);
}
OverlayState::OverlayState() {
this->clear();
}
void OverlayState::clear() {
for (size_t y = 0; y < this->tiles.size(); y++) {
this->tiles[y].clear(0);
}
this->unused1.clear(0);
this->trap_tile_colors_nte.clear(0);
this->trap_card_ids_nte.clear(0);
}
void MapDefinition::assert_semantically_equivalent(const MapDefinition& other) const {
if (this->map_number != other.map_number) {
throw runtime_error("map number not equal");
@@ -1603,12 +1635,9 @@ void MapDefinition::assert_semantically_equivalent(const MapDefinition& other) c
if (this->start_tile_definitions != other.start_tile_definitions) {
throw runtime_error("start tile definitions not equal");
}
if (this->modification_tiles != other.modification_tiles) {
if (this->overlay_state.tiles != other.overlay_state.tiles) {
throw runtime_error("modification tiles not equal");
}
if (this->unknown_a5 != other.unknown_a5) {
throw runtime_error("unknown_a5 not equal");
}
if (this->default_rules != other.default_rules) {
throw runtime_error("default rules not equal");
}
@@ -1814,19 +1843,52 @@ string MapDefinition::str(const CardIndex* card_index, uint8_t language) const {
lines.emplace_back(phosg::string_printf(" overview_specs[%zu][team %zu]: %s", w, z, spec_str.c_str()));
}
}
lines.emplace_back(" modification tiles:");
add_map(this->modification_tiles);
for (size_t z = 0; z < 0x70; z += 0x10) {
lines.emplace_back(phosg::string_printf(
" a5[0x%02zX:0x%02zX]: %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX", z, z + 0x10,
this->unknown_a5[z + 0x00], this->unknown_a5[z + 0x01], this->unknown_a5[z + 0x02], this->unknown_a5[z + 0x03],
this->unknown_a5[z + 0x04], this->unknown_a5[z + 0x05], this->unknown_a5[z + 0x06], this->unknown_a5[z + 0x07],
this->unknown_a5[z + 0x08], this->unknown_a5[z + 0x09], this->unknown_a5[z + 0x0A], this->unknown_a5[z + 0x0B],
this->unknown_a5[z + 0x0C], this->unknown_a5[z + 0x0D], this->unknown_a5[z + 0x0E], this->unknown_a5[z + 0x0F]));
}
lines.emplace_back(" overlay tiles:");
add_map(this->overlay_state.tiles);
lines.emplace_back(phosg::string_printf(
" a5[0x70:0x74]: %02hhX %02hhX %02hhX %02hhX",
this->unknown_a5[0x70], this->unknown_a5[0x71], this->unknown_a5[0x72], this->unknown_a5[0x73]));
" unused1: %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32,
this->overlay_state.unused1[0].load(),
this->overlay_state.unused1[1].load(),
this->overlay_state.unused1[2].load(),
this->overlay_state.unused1[3].load(),
this->overlay_state.unused1[4].load()));
lines.emplace_back(phosg::string_printf(
" trap_tile_colors_nte: %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32,
this->overlay_state.trap_tile_colors_nte[0].load(),
this->overlay_state.trap_tile_colors_nte[1].load(),
this->overlay_state.trap_tile_colors_nte[2].load(),
this->overlay_state.trap_tile_colors_nte[3].load(),
this->overlay_state.trap_tile_colors_nte[4].load(),
this->overlay_state.trap_tile_colors_nte[5].load(),
this->overlay_state.trap_tile_colors_nte[6].load(),
this->overlay_state.trap_tile_colors_nte[7].load(),
this->overlay_state.trap_tile_colors_nte[8].load(),
this->overlay_state.trap_tile_colors_nte[9].load(),
this->overlay_state.trap_tile_colors_nte[10].load(),
this->overlay_state.trap_tile_colors_nte[11].load(),
this->overlay_state.trap_tile_colors_nte[12].load(),
this->overlay_state.trap_tile_colors_nte[13].load(),
this->overlay_state.trap_tile_colors_nte[14].load(),
this->overlay_state.trap_tile_colors_nte[15].load()));
lines.emplace_back(phosg::string_printf(
" trap_card_ids_nte: #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX #%04hX",
this->overlay_state.trap_card_ids_nte[0].load(),
this->overlay_state.trap_card_ids_nte[1].load(),
this->overlay_state.trap_card_ids_nte[2].load(),
this->overlay_state.trap_card_ids_nte[3].load(),
this->overlay_state.trap_card_ids_nte[4].load(),
this->overlay_state.trap_card_ids_nte[5].load(),
this->overlay_state.trap_card_ids_nte[6].load(),
this->overlay_state.trap_card_ids_nte[7].load(),
this->overlay_state.trap_card_ids_nte[8].load(),
this->overlay_state.trap_card_ids_nte[9].load(),
this->overlay_state.trap_card_ids_nte[10].load(),
this->overlay_state.trap_card_ids_nte[11].load(),
this->overlay_state.trap_card_ids_nte[12].load(),
this->overlay_state.trap_card_ids_nte[13].load(),
this->overlay_state.trap_card_ids_nte[14].load(),
this->overlay_state.trap_card_ids_nte[15].load()));
lines.emplace_back(" default_rules: " + this->default_rules.str());
lines.emplace_back(" name: " + this->name.decode(language));
lines.emplace_back(" location_name: " + this->location_name.decode(language));
@@ -1868,9 +1930,9 @@ string MapDefinition::str(const CardIndex* card_index, uint8_t language) const {
}
if (entry) {
string name = entry->def.en_name.decode(language);
lines.emplace_back(phosg::string_printf(" cards[%02zu]: %04hX (%s)", w, card_id, name.c_str()));
lines.emplace_back(phosg::string_printf(" cards[%02zu]: #%04hX (%s)", w, card_id, name.c_str()));
} else {
lines.emplace_back(phosg::string_printf(" cards[%02zu]: %04hX", w, card_id));
lines.emplace_back(phosg::string_printf(" cards[%02zu]: #%04hX", w, card_id));
}
}
for (size_t x = 0; x < 0x10; x++) {
@@ -1911,9 +1973,9 @@ string MapDefinition::str(const CardIndex* card_index, uint8_t language) const {
}
if (entry) {
string name = entry->def.en_name.decode(language);
lines.emplace_back(phosg::string_printf(" reward_cards[%02zu]: %04hX (%s)", z, card_id, name.c_str()));
lines.emplace_back(phosg::string_printf(" reward_cards[%02zu]: #%04hX (%s)", z, card_id, name.c_str()));
} else {
lines.emplace_back(phosg::string_printf(" reward_cards[%02zu]: %04hX", z, card_id));
lines.emplace_back(phosg::string_printf(" reward_cards[%02zu]: #%04hX", z, card_id));
}
}
lines.emplace_back(phosg::string_printf(" level_overrides: [win: %" PRId32 ", loss: %" PRId32 "]",
@@ -1921,7 +1983,7 @@ string MapDefinition::str(const CardIndex* card_index, uint8_t language) const {
lines.emplace_back(phosg::string_printf(" field_offset: (x: %hd units, y:%hd units) (x: %lg tiles, y: %lg tiles)", this->field_offset_x.load(), this->field_offset_y.load(), static_cast<double>(this->field_offset_x) / 25.0, static_cast<double>(this->field_offset_y) / 25.0));
lines.emplace_back(phosg::string_printf(" map_category: %02hhX", this->map_category));
lines.emplace_back(phosg::string_printf(" cyber_block_type: %02hhX", this->cyber_block_type));
lines.emplace_back(phosg::string_printf(" a11: %02hhX%02hhX", this->unknown_a11[0], this->unknown_a11[1]));
lines.emplace_back(phosg::string_printf(" a11: %04hX", this->unknown_a11.load()));
static const array<const char*, 0x18> sc_card_entry_names = {
"00 (Guykild; 0005)",
"01 (Kylria; 0006)",
@@ -2022,8 +2084,7 @@ MapDefinitionTrial::MapDefinitionTrial(const MapDefinition& map)
camera_zone_maps(map.camera_zone_maps),
camera_zone_specs(map.camera_zone_specs),
overview_specs(map.overview_specs),
modification_tiles(map.modification_tiles),
unknown_a5(map.unknown_a5),
overlay_state(map.overlay_state),
default_rules(map.default_rules),
name(map.name),
location_name(map.location_name),
@@ -2077,9 +2138,7 @@ MapDefinitionTrial::operator MapDefinition() const {
ret.camera_zone_maps = this->camera_zone_maps;
ret.camera_zone_specs = this->camera_zone_specs;
ret.overview_specs = this->overview_specs;
ret.modification_tiles = this->modification_tiles;
ret.unknown_a5.clear(0xFF);
ret.unknown_a5 = this->unknown_a5;
ret.overlay_state = this->overlay_state;
ret.default_rules = this->default_rules;
ret.name = this->name;
ret.location_name = this->location_name;
@@ -2394,28 +2453,34 @@ CardIndex::CardIndex(
this->compressed_card_definitions = phosg::load_file(filename);
decompressed_data = prs_decompress(this->compressed_card_definitions);
}
// The client can't handle files larger than this
if (decompressed_data.size() > 0x36EC0) {
throw runtime_error("decompressed card list data is too long");
}
// There's a footer after the card definitions (it's a standard-format REL
// file), but we ignore it
if (decompressed_data.size() % sizeof(CardDefinition) != sizeof(CardDefinitionsFooter)) {
throw runtime_error(phosg::string_printf(
"decompressed card update file size %zX is not aligned with card definition size %zX (%zX extra bytes)",
decompressed_data.size(), sizeof(CardDefinition), decompressed_data.size() % sizeof(CardDefinition)));
// The card definitions file is a standard REL file; the root offset points
// to an ArrayRef which specifies an array of CardDefinition structs
phosg::StringReader r(decompressed_data);
const auto& footer = r.pget<RELFileFooterBE>(r.size() - sizeof(RELFileFooterBE));
uint32_t offset = r.pget_u32b(footer.root_offset);
uint32_t count = r.pget_u32b(footer.root_offset + 4);
if (offset > decompressed_data.size() ||
((offset + count * sizeof(CardDefinition)) > decompressed_data.size())) {
throw runtime_error("definitions array reference out of bounds");
}
auto* defs = reinterpret_cast<CardDefinition*>(decompressed_data.data());
size_t max_cards = decompressed_data.size() / sizeof(CardDefinition);
for (size_t x = 0; x < max_cards; x++) {
CardDefinition* defs = reinterpret_cast<CardDefinition*>(decompressed_data.data() + offset);
for (size_t x = 0; x < count; x++) {
auto& def = defs[x];
// The last card entry has the build date and some other metadata (and
// isn't a real card, obviously), so skip it. The game detects this by
// checking for a negative value in type, which we also do here.
if (static_cast<int8_t>(defs[x].type) < 0) {
if (static_cast<int8_t>(def.type) < 0) {
continue;
}
auto entry = make_shared<CardEntry>(CardEntry{defs[x], "", "", "", {}});
auto entry = make_shared<CardEntry>(CardEntry{def, "", "", "", {}});
if (!this->card_definitions.emplace(entry->def.card_id, entry).second) {
throw runtime_error(phosg::string_printf(
"duplicate card id: %08" PRIX32, entry->def.card_id.load()));
@@ -2435,17 +2500,17 @@ CardIndex::CardIndex(
if (!text_filename.empty() || !decompressed_text_filename.empty()) {
try {
entry->text = std::move(card_text.at(defs[x].card_id));
entry->text = std::move(card_text.at(def.card_id));
} catch (const out_of_range&) {
}
try {
entry->debug_tags = std::move(card_tags.at(defs[x].card_id));
entry->debug_tags = std::move(card_tags.at(def.card_id));
} catch (const out_of_range&) {
}
}
if (!dice_text_filename.empty() || !decompressed_dice_text_filename.empty()) {
try {
auto& dice_text_it = card_dice_text.at(defs[x].card_id);
auto& dice_text_it = card_dice_text.at(def.card_id);
entry->dice_caption = std::move(dice_text_it.first);
entry->dice_text = std::move(dice_text_it.second);
} catch (const out_of_range&) {
@@ -2465,7 +2530,7 @@ CardIndex::CardIndex(
if (this->compressed_card_definitions.size() > 0x7BF8) {
// Try to reduce the compressed size by clearing out text
static_game_data_log.info("Compressed card list data is too long (0x%zX bytes); removing text", this->compressed_card_definitions.size());
for (size_t x = 0; x < max_cards; x++) {
for (size_t x = 0; x < count; x++) {
if (static_cast<int8_t>(defs[x].type) < 0) {
continue;
}
@@ -2548,12 +2613,15 @@ MapIndex::VersionedMap::VersionedMap(std::string&& compressed_data, uint8_t lang
: language(language),
compressed_data(std::move(compressed_data)) {
string decompressed = prs_decompress(this->compressed_data);
if (decompressed.size() != sizeof(MapDefinition)) {
if (decompressed.size() == sizeof(MapDefinitionTrial)) {
this->map = make_shared<MapDefinition>(*reinterpret_cast<const MapDefinitionTrial*>(decompressed.data()));
} else if (decompressed.size() == sizeof(MapDefinition)) {
this->map = make_shared<MapDefinition>(*reinterpret_cast<const MapDefinition*>(decompressed.data()));
} else {
throw runtime_error(phosg::string_printf(
"decompressed data size is incorrect (expected %zu bytes, read %zu bytes)",
sizeof(MapDefinition), decompressed.size()));
}
this->map = make_shared<MapDefinition>(*reinterpret_cast<const MapDefinition*>(decompressed.data()));
}
shared_ptr<const MapDefinitionTrial> MapIndex::VersionedMap::trial() const {
@@ -2737,7 +2805,7 @@ const string& MapIndex::get_compressed_list(size_t num_players, uint8_t language
e.width = vm->map->width;
e.height = vm->map->height;
e.map_tiles = vm->map->map_tiles;
e.modification_tiles = vm->map->modification_tiles;
e.modification_tiles = vm->map->overlay_state.tiles;
e.name_offset = strings_w.size();
strings_w.write(vm->map->name.data, vm->map->name.used_chars_8());
+65 -40
View File
@@ -13,6 +13,7 @@
#include <string>
#include <unordered_map>
#include "../CommonFileFormats.hh"
#include "../PlayerSubordinates.hh"
#include "../Text.hh"
#include "../TextIndex.hh"
@@ -523,7 +524,6 @@ struct CardDefinition {
// rules; for example, the expression "4+4//2" results in 4, not 6.
/* 02 */ pstring<TextEncoding::ASCII, 0x0F> expr;
// when specifies in which phase the effect should activate.
// TODO: There are many values that can be used here; document them.
/* 11 */ EffectWhen when;
// arg1 generally specifies how long the effect activates for.
/* 12 */ pstring<TextEncoding::ASCII, 4> arg1;
@@ -815,18 +815,12 @@ struct CardDefinition {
} __packed_ws__(CardDefinition, 0x128);
struct CardDefinitionsFooter {
// Technically the card definitions file is a REL file, so the last 0x20 bytes
// here should be a separate structure.
/* 00 */ be_uint32_t num_cards1;
/* 04 */ be_uint32_t cards_offset; // == 0
/* 08 */ be_uint32_t num_cards2;
/* 0C */ parray<be_uint32_t, 3> unknown_a2;
/* 18 */ parray<be_uint16_t, 0x10> relocations;
/* 38 */ be_uint32_t relocations_offset;
/* 3C */ be_uint32_t num_relocations;
/* 40 */ parray<be_uint32_t, 2> unused1;
/* 48 */ be_uint32_t footer_offset;
/* 4C */ parray<be_uint32_t, 3> unused2;
/* 38 */ RELFileFooterBE rel_footer;
/* 58 */
} __packed_ws__(CardDefinitionsFooter, 0x58);
@@ -918,13 +912,15 @@ struct PlayerConfig {
/* 00 */ be_uint32_t guild_card_number;
/* 04 */ pstring<TextEncoding::MARKED, 0x18> name;
} __packed_ws__(PlayerReference, 0x1C);
// This array is updated when a battle is started (via a 6xB4x05 command). The
// client adds the opposing players' info to ths first two entries here if the
// opponents are human. (The existing entries are always moved back by two
// slots, but if one or both opponents are not humans, one or both of the
// newly-vacated slots is not filled in.)
// These two arrays are updated when a battle is started (via a 6xB4x05
// command). The client adds the opposing players' info to ths first two
// entries in recent_human_opponents if the opponents are human. (The
// existing entries are always moved back by two slots, but if one or both
// opponents are not humans, one or both of the newly-vacated slots is not
// filled in.) Both arrays have the most recent entries at the beginning.
/* 2128:1FD4 */ parray<PlayerReference, 10> recent_human_opponents;
/* 2240:20EC */ parray<uint8_t, 0x28> unknown_a10;
/* 2240:20EC */ parray<be_uint32_t, 5> recent_battle_start_timestamps;
/* 2254:2100 */ parray<uint8_t, 0x14> unknown_a10;
/* 2268:2114 */ be_uint32_t init_timestamp;
/* 226C:2118 */ be_uint32_t last_online_battle_start_timestamp;
// In a certain situation, unknown_t3 is set to init_timestamp plus a multiple
@@ -961,7 +957,8 @@ struct PlayerConfigNTE {
/* 1B70 */ be_uint32_t offline_clv_exp;
/* 1B74 */ be_uint32_t online_clv_exp;
/* 1B78 */ parray<PlayerConfig::PlayerReference, 10> recent_human_opponents;
/* 1C90 */ parray<uint8_t, 0x28> unknown_a10;
/* 1C90 */ parray<be_uint32_t, 5> recent_battle_start_timestamps;
/* 1CA4 */ parray<uint8_t, 0x14> unknown_a10;
/* 1CB8 */ be_uint32_t init_timestamp;
/* 1CBC */ be_uint32_t last_online_battle_start_timestamp;
/* 1CC0 */ be_uint32_t unknown_t3;
@@ -1131,6 +1128,42 @@ struct CompressedMapHeader { // .mnm file format
// Compressed data immediately follows (which decompresses to a MapDefinition)
} __packed_ws__(CompressedMapHeader, 8);
struct OverlayState {
// In the tiles array, the high 4 bits of each value are the tile type, and
// the low 4 bits are the subtype. The types are:
// 10: blocked by rock (as if the corresponding map_tiles value was 00)
// 20: blocked by fence (as if the corresponding map_tiles value was 00)
// 30-34: teleporters (2 of each value may be present)
// 40-4F: traps on NTE
// 40-44: traps on non-NTE (there may be up to 8 of each type, and one of
// each is chosen to be a real trap at battle start); the trap types are:
// 40: Dice Fever, Heavy Fog, Muscular, Immortality, Snail Pace
// 41: Gold Rush, Charity, Requiem
// 42: Powerless Rain, Trash 1, Empty Hand, Skip Draw
// 43: Brave Wind, Homesick, Fly
// 44: Dice+1, Battle Royale, Reverse Card, Giant Garden, Fix
// 50: blocked by metal box (appears as an improperly-z-buffered teal cube in
// preview; behaves like 10 and 20 in game)
// Any other value here will behave like 00 (no special tile behavior).
parray<parray<uint8_t, 0x10>, 0x10> tiles;
// This field appears to be unused in both NTE and the final version. Perhaps
// it had some meaning in a pre-NTE version.
parray<le_uint32_t, 5> unused1;
// TODO: Figure out exactly where these colors are used
parray<le_uint32_t, 0x10> trap_tile_colors_nte; // Unused on non-NTE
// This specifies the assist card IDs that each trap value (40-4F) will set
// when triggered. This only has an effect on NTE; on non-NTE, this is unused
// and a fixed set of assist cards is used instead. (On newserv, the set of
// used assist cards can be overridden in the server configuration.)
parray<le_uint16_t, 0x10> trap_card_ids_nte;
OverlayState();
void clear();
} __packed_ws__(OverlayState, 0x174);
struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
// If tag is not 0x00000100, the game considers the map to be corrupt in
// offline mode and will delete it (if it's a download quest). The tag field
@@ -1181,7 +1214,6 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
// 19 = View Battle waiting room
// 1A = TCard00_Select (debug battle setup menu)
// 1B = nothing (softlocks at black screen)
// TCard00_Select is accessible on newserv with the $ep3battledebug command.
/* 000A */ uint8_t environment_number;
// This field specifies how many of the camera_zone_maps are used.
@@ -1250,24 +1282,10 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
// (it is not yet known what the major index represents).
/* 1AB8 */ parray<parray<CameraSpec, 2>, 3> overview_specs;
// In the modification_tiles array, the values are:
// 10 = blocked by rock (as if the corresponding map_tiles value was 00)
// 20 = blocked by fence (as if the corresponding map_tiles value was 00)
// 30-34 = teleporters (2 of each value may be present)
// 40-4F = traps on NTE
// 40-44 = traps on non-NTE (one of each type is chosen at random to be a real
// trap at battle start time)
// 50 = blocked by metal box (appears as improperly-z-buffered teal cube in
// preview; behaves like 10 and 20 in game)
// The assist cards that each trap type can contain are:
// 40: Dice Fever, Heavy Fog, Muscular, Immortality, Snail Pace
// 41: Gold Rush, Charity, Requiem
// 42: Powerless Rain, Trash 1, Empty Hand, Skip Draw
// 43: Brave Wind, Homesick, Fly
// 44: Dice+1, Battle Royale, Reverse Card, Giant Garden, Fix
/* 1C68 */ parray<parray<uint8_t, 0x10>, 0x10> modification_tiles;
// This specifies the locations of blocked tiles, teleporters, and traps. See
// the comments in OverlayState for details.
/* 1C68 */ OverlayState overlay_state;
/* 1D68 */ parray<uint8_t, 0x74> unknown_a5;
/* 1DDC */ Rules default_rules;
/* 1DF0 */ pstring<TextEncoding::MARKED, 0x14> name;
@@ -1362,7 +1380,13 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
/* 28F0 */ parray<parray<DialogueSet, 0x10>, 3> dialogue_sets;
// These card IDs are always given to the player when they win a battle on
// this map. Unused entries should be set to FFFF.
// this map. Unused entries should be set to FFFF. Cards in this array are
// ignored if they have any of these features (in the card definition):
// - type is HUNTERS_SC or ARKZ_SC
// - card_class is BOSS_ATTACK_ACTION or BOSS_TECH
// - rank is D1, D2, or D3
// - cannot_drop is 1 (specifically 1; other values don't prevent cards from
// appearing)
/* 59B0 */ parray<be_uint16_t, 0x10> reward_card_ids;
// These fields are used when determining which cards to drop after the battle
@@ -1383,10 +1407,12 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
/* 59DC */ uint8_t map_category;
// This field determines block graphics to be used in the Cyber environment.
// There are 10 block types (0-9); if this value is > 9, type 0 is used.
// There are 10 block types (0-9); if this value is > 9, type 0 is used. This
// field has no effect in Ep3 NTE, even though there are 6 different block
// texture files on the NTE disc.
/* 59DD */ uint8_t cyber_block_type;
/* 59DE */ parray<uint8_t, 2> unknown_a11;
/* 59DE */ be_uint16_t unknown_a11;
// This array specifies which SC characters can't participate in the quest
// (that is, the player is not allowed to choose decks with these SC cards).
@@ -1470,9 +1496,8 @@ struct MapDefinitionTrial {
/* 0118 */ parray<parray<parray<parray<uint8_t, 0x10>, 0x10>, 10>, 2> camera_zone_maps;
/* 1518 */ parray<parray<MapDefinition::CameraSpec, 10>, 2> camera_zone_specs;
/* 1AB8 */ parray<parray<MapDefinition::CameraSpec, 2>, 3> overview_specs;
/* 1C68 */ parray<parray<uint8_t, 0x10>, 0x10> modification_tiles;
/* 1D68 */ parray<uint8_t, 0x74> unknown_a5;
/* 1DD4 */ RulesTrial default_rules;
/* 1C68 */ OverlayState overlay_state;
/* 1DDC */ RulesTrial default_rules;
/* 1DE8 */ pstring<TextEncoding::MARKED, 0x14> name;
/* 1DFC */ pstring<TextEncoding::MARKED, 0x14> location_name;
/* 1E10 */ pstring<TextEncoding::MARKED, 0x3C> quest_name;
@@ -1494,7 +1519,7 @@ struct MapDefinitionTrial {
/* 4172 */ be_int16_t field_offset_y;
/* 4174 */ uint8_t map_category;
/* 4175 */ uint8_t cyber_block_type;
/* 4176 */ parray<uint8_t, 2> unknown_a11;
/* 4176 */ be_uint16_t unknown_a11;
// TODO: This field may contain some version of unavailable_sc_cards and/or
// entry_states from MapDefinition, but the format isn't the same
/* 4178 */ parray<uint8_t, 0x28> unknown_t12;
-13
View File
@@ -99,17 +99,4 @@ MapAndRulesStateTrial::operator MapAndRulesState() const {
return ret;
}
OverlayState::OverlayState() {
this->clear();
}
void OverlayState::clear() {
for (size_t y = 0; y < this->tiles.size(); y++) {
this->tiles[y].clear(0);
}
this->unused1.clear(0);
this->unused2.clear(0);
this->trap_card_ids_nte.clear(0);
}
} // namespace Episode3
-10
View File
@@ -67,14 +67,4 @@ struct MapAndRulesStateTrial {
operator MapAndRulesState() const;
} __packed_ws__(MapAndRulesStateTrial, 0x130);
struct OverlayState {
parray<parray<uint8_t, 0x10>, 0x10> tiles;
parray<le_uint32_t, 5> unused1;
parray<le_uint32_t, 0x10> unused2;
parray<le_uint16_t, 0x10> trap_card_ids_nte; // Unused on non-NTE
OverlayState();
void clear();
} __packed_ws__(OverlayState, 0x174);
} // namespace Episode3
+14 -7
View File
@@ -132,6 +132,11 @@ shared_ptr<const Server> PlayerState::server() const {
return s;
}
bool PlayerState::is_alive() const {
auto sc_card = this->get_sc_card();
return (sc_card && !(sc_card->card_flags & 2));
}
bool PlayerState::draw_cards_allowed() const {
if (this->assist_flags & AssistFlag::IS_SKIPPING_TURN) {
return false;
@@ -608,11 +613,12 @@ void PlayerState::discard_and_redraw_hand() {
}
if (!s->options.is_nte()) {
G_Unknown_Ep3_6xB4x2C cmd;
G_EnqueueAnimation_Ep3_6xB4x2C cmd;
cmd.change_type = 3;
cmd.client_id = this->client_id;
cmd.card_refs.clear(0xFFFF);
cmd.unknown_a2.clear(0xFFFFFFFF);
cmd.trap_card_id = 0xFFFFFFFF;
cmd.unknown_a3 = 0xFFFFFFFF;
s->send(cmd);
}
@@ -712,11 +718,12 @@ bool PlayerState::do_mulligan() {
}
if (!s->options.is_nte()) {
G_Unknown_Ep3_6xB4x2C cmd;
G_EnqueueAnimation_Ep3_6xB4x2C cmd;
cmd.change_type = 3;
cmd.client_id = this->client_id;
cmd.card_refs.clear(0xFFFF);
cmd.unknown_a2.clear(0xFFFFFFFF);
cmd.trap_card_id = 0xFFFFFFFF;
cmd.unknown_a3 = 0xFFFFFFFF;
s->send(cmd);
}
@@ -1415,7 +1422,7 @@ bool PlayerState::set_card_from_hand(
s->send_6xB4x05();
if (!is_nte) {
G_AddToSetCardlog_Ep3_6xB4x4A cmd;
G_AddToSetCardLog_Ep3_6xB4x4A cmd;
cmd.card_refs.clear(0xFFFF);
cmd.card_refs[0] = card_ref;
cmd.client_id = this->client_id;
@@ -1782,7 +1789,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) {
card->loc.direction = pa.facing_direction;
log.debug("set facing direction to %s", phosg::name_for_enum(card->loc.direction));
G_AddToSetCardlog_Ep3_6xB4x4A cmd;
G_AddToSetCardLog_Ep3_6xB4x4A cmd;
cmd.card_refs.clear(0xFFFF);
cmd.client_id = this->client_id;
cmd.round_num = s->get_round_num();
@@ -1842,7 +1849,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) {
}
}
if (!is_nte) {
G_AddToSetCardlog_Ep3_6xB4x4A cmd;
G_AddToSetCardLog_Ep3_6xB4x4A cmd;
cmd.card_refs.clear(0xFFFF);
cmd.client_id = this->client_id;
cmd.round_num = s->get_round_num();
+2
View File
@@ -47,6 +47,8 @@ public:
std::shared_ptr<Server> server();
std::shared_ptr<const Server> server() const;
bool is_alive() const;
bool draw_cards_allowed() const;
void apply_assist_card_effect_on_set(std::shared_ptr<PlayerState> setter_ps);
void apply_dice_effects();
+1 -1
View File
@@ -194,7 +194,7 @@ std::string ActionState::str(shared_ptr<const Server> s) const {
string target_refs_s = s->debug_str_for_card_refs(this->target_card_refs);
string action_refs_s = s->debug_str_for_card_refs(this->action_card_refs);
return phosg::string_printf(
"ActionState[client=%hu, u=%hhu, facing=%s, attacker_ref=%s, "
"ActionState[client=%hX, u=%hhu, facing=%s, attacker_ref=%s, "
"def_ref=%s, target_refs=%s, action_refs=%s, "
"orig_attacker_ref=%s]",
this->client_id.load(),
+2 -1
View File
@@ -2076,7 +2076,8 @@ uint32_t RulerServer::get_card_id_with_effective_range(
if (this->card_ref_or_sc_has_fixed_range(card_ref)) {
// Undo the override that may have been passed in
log.debug("@%04hX has FIXED_RANGE", card_ref);
auto orig_ce = this->definition_for_card_id(this->card_id_for_card_ref(card_ref));
card_id = this->card_id_for_card_ref(card_ref);
auto orig_ce = this->definition_for_card_id(card_id);
if (orig_ce && (static_cast<uint8_t>(effective_target_mode) < 6)) {
log.debug("ce valid for #%04hX with effective target mode %s; overriding to %s", card_id, name_for_target_mode(effective_target_mode), name_for_target_mode(orig_ce->def.target_mode));
effective_target_mode = orig_ce->def.target_mode;
+31 -68
View File
@@ -12,7 +12,8 @@ using namespace std;
namespace Episode3 {
// This is (obviously) not the original string. The original string is:
// "[V1][FINAL2.0] 03/09/13 15:30 by K.Toya"
// "03/05/29 18:00 by K.Toya" (NTE)
// "[V1][FINAL2.0] 03/09/13 15:30 by K.Toya" (Final)
static const char* VERSION_SIGNATURE =
"newserv Ep3 based on [V1][FINAL2.0] 03/09/13 15:30 by K.Toya";
static const char* VERSION_SIGNATURE_NTE =
@@ -375,8 +376,7 @@ void Server::send_debug_command_received_message(uint8_t subsubcommand, const ch
this->send_debug_message_printf("$C5*/CAx%02hhX %s", subsubcommand, description);
}
void Server::send_debug_message_if_error_code_nonzero(
uint8_t client_id, int32_t error_code) const {
void Server::send_debug_message_if_error_code_nonzero(uint8_t client_id, int32_t error_code) const {
if (error_code < 0) {
this->send_debug_message_printf("$C4%hhu/ERROR -0x%zX", client_id, static_cast<ssize_t>(-error_code));
} else if (error_code > 0) {
@@ -392,8 +392,7 @@ void Server::add_team_exp(uint8_t team_id, int32_t exp) {
}
}
this->team_exp[team_id] = clamp<int16_t>(
this->team_exp[team_id] + exp, 0, this->team_client_count[team_id] * 96);
this->team_exp[team_id] = clamp<int16_t>(this->team_exp[team_id] + exp, 0, this->team_client_count[team_id] * 96);
uint8_t dice_boost = this->team_exp[team_id] / (this->team_client_count[team_id] * 12);
this->card_special->adjust_dice_boost_if_team_has_condition_52(team_id, &dice_boost, 0);
@@ -475,29 +474,7 @@ shared_ptr<Card> Server::card_for_set_card_ref(uint16_t card_ref) {
}
shared_ptr<const Card> Server::card_for_set_card_ref(uint16_t card_ref) const {
// TODO: It'd be nice to deduplicate this function with the non-const version.
if (card_ref == 0xFFFF) {
return nullptr;
}
uint8_t client_id = client_id_for_card_ref(card_ref);
if (client_id == 0xFF) {
return nullptr;
}
auto ps = this->player_states.at(client_id);
if (!ps) {
return nullptr;
}
auto card = ps->get_sc_card();
if (card && (card->get_card_ref() == card_ref)) {
return card;
}
for (size_t set_index = 0; set_index < 8; set_index++) {
card = ps->get_set_card(set_index);
if (card && (card->get_card_ref() == card_ref)) {
return card;
}
}
return nullptr;
return const_cast<Server*>(this)->card_for_set_card_ref(card_ref);
}
uint16_t Server::card_id_for_card_ref(uint16_t card_ref) const {
@@ -1180,15 +1157,15 @@ void Server::move_phase_after() {
(abs(sc_card->loc.x - trap_x) < 2) &&
(abs(sc_card->loc.y - trap_y) < 2) &&
ps->replace_assist_card_by_id(trap_card_id)) {
G_Unknown_Ep3_6xB4x2C cmd;
G_EnqueueAnimation_Ep3_6xB4x2C cmd;
cmd.change_type = 0x01;
cmd.client_id = client_id;
cmd.card_refs.clear(0xFFFF);
cmd.loc.x = trap_x;
cmd.loc.y = trap_y;
cmd.loc.direction = static_cast<Direction>(trap_type);
cmd.unknown_a2[0] = trap_card_id;
cmd.unknown_a2[1] = 0xFFFFFFFF;
cmd.trap_card_id = trap_card_id;
cmd.unknown_a3 = 0xFFFFFFFF;
this->send(cmd);
}
}
@@ -1860,8 +1837,7 @@ void Server::on_server_data_input(shared_ptr<Client> sender_c, const string& dat
void Server::handle_CAx0B_mulligan_hand(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_RedrawInitialHand_Ep3_CAx0B>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "REDRAW");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "REDRAW");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -1893,8 +1869,7 @@ void Server::handle_CAx0B_mulligan_hand(shared_ptr<Client>, const string& data)
void Server::handle_CAx0C_end_mulligan_phase(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EndInitialRedrawPhase_Ep3_CAx0C>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "SETUP ADV 2");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "HAND READY");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -1975,8 +1950,7 @@ void Server::handle_CAx0D_end_non_action_phase(shared_ptr<Client>, const string&
void Server::handle_CAx0E_discard_card_from_hand(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_DiscardCardFromHand_Ep3_CAx0E>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "DISCARD");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "DISCARD");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2061,8 +2035,7 @@ void Server::handle_CAx0F_set_card_from_hand(shared_ptr<Client>, const string& d
void Server::handle_CAx10_move_fc_to_location(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_MoveFieldCharacter_Ep3_CAx10>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "MOVE");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "MOVE");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2102,8 +2075,7 @@ void Server::handle_CAx10_move_fc_to_location(shared_ptr<Client>, const string&
void Server::handle_CAx11_enqueue_attack_or_defense(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EnqueueAttackOrDefense_Ep3_CAx11>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "ENQUEUE ACT");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "ENQUEUE ACT");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2141,8 +2113,7 @@ void Server::handle_CAx11_enqueue_attack_or_defense(shared_ptr<Client>, const st
void Server::handle_CAx12_end_attack_list(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EndAttackList_Ep3_CAx12>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "END ATK LIST");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "END ATK LIST");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2237,8 +2208,7 @@ void Server::handle_CAx13_update_map_during_setup(shared_ptr<Client> c, const st
void Server::handle_CAx14_update_deck_during_setup(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_SetPlayerDeck_Ep3_CAx14>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "UPDATE DECK");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "UPDATE DECK");
if (!this->battle_in_progress) {
if ((this->setup_phase == SetupPhase::REGISTRATION) &&
@@ -2284,8 +2254,7 @@ void Server::handle_CAx14_update_deck_during_setup(shared_ptr<Client>, const str
void Server::handle_CAx15_unused_hard_reset_server_state(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_HardResetServerState_Ep3_CAx15>(data);
this->send_debug_command_received_message(
in_cmd.header.subsubcommand, "HARD RESET");
this->send_debug_command_received_message(in_cmd.header.subsubcommand, "HARD RESET");
// In the original implementation, this command recreates the server object.
// This is possible because the dispatch function is not part of the server
@@ -2302,8 +2271,7 @@ void Server::handle_CAx15_unused_hard_reset_server_state(shared_ptr<Client>, con
void Server::handle_CAx1B_update_player_name(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_SetPlayerName_Ep3_CAx1B>(data);
this->send_debug_command_received_message(
in_cmd.entry.client_id, in_cmd.header.subsubcommand, "UPDATE NAME");
this->send_debug_command_received_message(in_cmd.entry.client_id, in_cmd.header.subsubcommand, "UPDATE NAME");
if (in_cmd.entry.client_id < 4) {
if (!this->is_registration_complete()) {
@@ -2334,8 +2302,7 @@ void Server::handle_CAx1B_update_player_name(shared_ptr<Client>, const string& d
void Server::handle_CAx1D_start_battle(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_StartBattle_Ep3_CAx1D>(data);
this->send_debug_command_received_message(
in_cmd.header.subsubcommand, "START BATTLE");
this->send_debug_command_received_message(in_cmd.header.subsubcommand, "START BATTLE");
if (!this->battle_in_progress) {
bool is_nte = this->options.is_nte();
@@ -2368,7 +2335,7 @@ void Server::handle_CAx1D_start_battle(shared_ptr<Client>, const string& data) {
if (l) {
// Note: Sega's implementation doesn't set EX results values here; they
// did it at game join time instead. We do it here for code simplicity.
if ((l->base_version != Version::GC_EP3_NTE) && l->ep3_ex_result_values) {
if (!this->options.is_nte() && l->ep3_ex_result_values) {
this->send(*l->ep3_ex_result_values);
}
}
@@ -2381,8 +2348,7 @@ void Server::handle_CAx1D_start_battle(shared_ptr<Client>, const string& data) {
void Server::handle_CAx21_end_battle(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EndBattle_Ep3_CAx21>(data);
this->send_debug_command_received_message(
in_cmd.header.subsubcommand, "END BATTLE");
this->send_debug_command_received_message(in_cmd.header.subsubcommand, "END BATTLE");
if (this->setup_phase == SetupPhase::BATTLE_ENDED) {
this->battle_finished = true;
@@ -2396,8 +2362,7 @@ void Server::handle_CAx21_end_battle(shared_ptr<Client>, const string& data) {
void Server::handle_CAx28_end_defense_list(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EndDefenseList_Ep3_CAx28>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "END DEF LIST");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "END DEF LIST");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2457,8 +2422,7 @@ void Server::handle_CAx34_subtract_ally_atk_points(shared_ptr<Client>, const str
const auto& in_cmd = check_size_t<G_PhotonBlastRequest_Ep3_CAx34>(data);
uint8_t card_ref_client_id = client_id_for_card_ref(in_cmd.card_ref);
this->send_debug_command_received_message(
card_ref_client_id, in_cmd.header.subsubcommand, "SUB ALLY ATK");
this->send_debug_command_received_message(card_ref_client_id, in_cmd.header.subsubcommand, "SUB ALLY ATK");
if (card_ref_client_id >= 4) {
return;
@@ -2531,8 +2495,7 @@ void Server::handle_CAx34_subtract_ally_atk_points(shared_ptr<Client>, const str
void Server::handle_CAx37_client_ready_to_advance_from_starter_roll_phase(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_AdvanceFromStartingRollsPhase_Ep3_CAx37>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "SETUP ADV 1");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "CHOOSE ORDER");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2644,14 +2607,15 @@ void Server::send_6xB6x41_to_all_clients() const {
void Server::handle_CAx41_map_request(shared_ptr<Client>, const string& data) {
const auto& cmd = check_size_t<G_MapDataRequest_Ep3_CAx41>(data);
this->send_debug_command_received_message(cmd.header.subsubcommand, "MAP DATA");
this->last_chosen_map = this->options.map_index->for_number(cmd.map_number);
this->send_6xB6x41_to_all_clients();
if (!this->options.tournament || (this->options.tournament->get_map()->map_number == cmd.map_number)) {
this->last_chosen_map = this->options.map_index->for_number(cmd.map_number);
this->send_6xB6x41_to_all_clients();
}
}
void Server::handle_CAx48_end_turn(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_EndTurn_Ep3_CAx48>(data);
this->send_debug_command_received_message(
in_cmd.client_id, in_cmd.header.subsubcommand, "END TURN");
this->send_debug_command_received_message(in_cmd.client_id, in_cmd.header.subsubcommand, "END TURN");
if (in_cmd.client_id >= 4) {
throw runtime_error("invalid client ID");
}
@@ -2668,8 +2632,7 @@ void Server::handle_CAx48_end_turn(shared_ptr<Client>, const string& data) {
void Server::handle_CAx49_card_counts(shared_ptr<Client>, const string& data) {
const auto& in_cmd = check_size_t<G_CardCounts_Ep3_CAx49>(data);
this->send_debug_command_received_message(
in_cmd.header.sender_client_id, in_cmd.header.subsubcommand, "CARD COUNTS");
this->send_debug_command_received_message(in_cmd.header.sender_client_id, in_cmd.header.subsubcommand, "CARD COUNTS");
// Note: Sega's implmentation completely ignores this command. This
// implementation is not based on the original code.
@@ -2858,8 +2821,8 @@ void Server::unknown_8023EEF4() {
log.debug("a14 (%" PRIu32 ") < num_pending_attacks_with_cards (%" PRIu32 ")", this->unknown_a14, this->num_pending_attacks_with_cards);
this->defense_list_ended_for_client.clear(false);
G_SetActionState_Ep3_6xB4x29 cmd;
cmd.unknown_a1 = this->unknown_a14;
G_UpdateAttackTargets_Ep3_6xB4x29 cmd;
cmd.attack_number = this->unknown_a14;
cmd.state = this->pending_attacks_with_cards[this->unknown_a14];
if (is_nte) {
this->replace_targets_due_to_destruction_nte(&cmd.state);
+32 -27
View File
@@ -717,66 +717,71 @@ void Tournament::send_all_state_updates_on_deletion() const {
}
}
void Tournament::print_bracket(FILE* stream) const {
function<void(shared_ptr<Match>, size_t)> print_match = [&](shared_ptr<Match> m, size_t indent_level) -> void {
for (size_t z = 0; z < indent_level; z++) {
fputc(' ', stream);
fputc(' ', stream);
string Tournament::bracket_str() const {
string ret = phosg::string_printf("Tournament \"%s\"\n", this->name.c_str());
function<void(shared_ptr<Match>, size_t)> add_match = [&](shared_ptr<Match> m, size_t indent_level) -> void {
ret.append(2 * indent_level, ' ');
ret += m->str();
if (this->pending_matches.count(m)) {
ret += " (PENDING)";
}
string match_str = m->str();
fprintf(stream, "%s%s\n", match_str.c_str(), this->pending_matches.count(m) ? " (PENDING)" : "");
ret.push_back('\n');
if (m->preceding_a) {
print_match(m->preceding_a, indent_level + 1);
add_match(m->preceding_a, indent_level + 1);
}
if (m->preceding_b) {
print_match(m->preceding_b, indent_level + 1);
add_match(m->preceding_b, indent_level + 1);
}
};
fprintf(stream, "Tournament \"%s\"\n", this->name.c_str());
auto en_vm = this->map->version(1);
if (en_vm) {
string map_name = en_vm->map->name.decode(en_vm->language);
fprintf(stream, " Map: %08" PRIX32 " (%s)\n", this->map->map_number, map_name.c_str());
ret += phosg::string_printf(" Map: %08" PRIX32 " (%s)\n", this->map->map_number, map_name.c_str());
} else {
fprintf(stream, " Map: %08" PRIX32 "\n", this->map->map_number);
ret += phosg::string_printf(" Map: %08" PRIX32 "\n", this->map->map_number);
}
string rules_str = this->rules.str();
fprintf(stream, " Rules: %s\n", rules_str.c_str());
fprintf(stream, " Structure: %s, %zu entries\n", (this->flags & Flag::IS_2V2) ? "2v2" : "1v1", this->num_teams);
fprintf(stream, " COM teams: %s\n", (this->flags & Flag::HAS_COM_TEAMS) ? "allowed" : "forbidden");
fprintf(stream, " Shuffle entries: %s\n", (this->flags & Flag::SHUFFLE_ENTRIES) ? "yes" : "no");
fprintf(stream, " Resize on start: %s\n", (this->flags & Flag::RESIZE_ON_START) ? "yes" : "no");
ret += phosg::string_printf(" Rules: %s\n", rules_str.c_str());
ret += phosg::string_printf(" Structure: %s, %zu entries\n", (this->flags & Flag::IS_2V2) ? "2v2" : "1v1", this->num_teams);
ret += phosg::string_printf(" COM teams: %s\n", (this->flags & Flag::HAS_COM_TEAMS) ? "allowed" : "forbidden");
ret += phosg::string_printf(" Shuffle entries: %s\n", (this->flags & Flag::SHUFFLE_ENTRIES) ? "yes" : "no");
ret += phosg::string_printf(" Resize on start: %s\n", (this->flags & Flag::RESIZE_ON_START) ? "yes" : "no");
switch (this->current_state) {
case State::REGISTRATION:
fprintf(stream, " State: REGISTRATION\n");
ret += " State: REGISTRATION\n";
break;
case State::IN_PROGRESS:
fprintf(stream, " State: IN_PROGRESS\n");
ret += " State: IN_PROGRESS\n";
break;
case State::COMPLETE:
fprintf(stream, " State: COMPLETE\n");
ret += " State: COMPLETE\n";
break;
default:
fprintf(stream, " State: UNKNOWN\n");
ret += " State: UNKNOWN\n";
break;
}
if (this->final_match) {
fprintf(stream, " Standings:\n");
print_match(this->final_match, 2);
ret += " Standings:\n";
add_match(this->final_match, 2);
}
if (this->current_state == State::REGISTRATION) {
fprintf(stream, " Teams:\n");
ret += " Teams:\n";
for (const auto& team : this->teams) {
string team_str = team->str();
fprintf(stream, " %s\n", team_str.c_str());
ret += phosg::string_printf(" %s\n", team_str.c_str());
}
} else {
fprintf(stream, " Pending matches:\n");
ret += " Pending matches:\n";
for (const auto& match : this->pending_matches) {
string match_str = match->str();
fprintf(stream, " %s\n", match_str.c_str());
ret += phosg::string_printf(" %s\n", match_str.c_str());
}
}
phosg::strip_trailing_whitespace(ret);
return ret;
}
TournamentIndex::TournamentIndex(
+1 -1
View File
@@ -160,7 +160,7 @@ public:
void send_all_state_updates() const;
void send_all_state_updates_on_deletion() const;
void print_bracket(FILE* stream) const;
std::string bracket_str() const;
private:
void create_bracket_matches();
+30 -11
View File
@@ -1,5 +1,6 @@
#include "EventUtils.hh"
#include <event2/buffer.h>
#include <event2/event.h>
#include <deque>
@@ -7,37 +8,55 @@
#include <memory>
#include <stdexcept>
using namespace std;
static void dispatch_forward_to_event_thread(evutil_socket_t, short, void* ctx) {
auto* fn = reinterpret_cast<std::function<void()>*>(ctx);
auto* fn = reinterpret_cast<function<void()>*>(ctx);
(*fn)();
delete fn;
}
void forward_to_event_thread(std::shared_ptr<struct event_base> base, std::function<void()>&& fn) {
void forward_to_event_thread(shared_ptr<struct event_base> base, function<void()>&& fn) {
struct timeval tv = {0, 0};
std::function<void()>* new_fn = new std::function<void()>(std::move(fn));
function<void()>* new_fn = new function<void()>(std::move(fn));
event_base_once(base.get(), -1, EV_TIMEOUT, dispatch_forward_to_event_thread, new_fn, &tv);
}
template <>
void call_on_event_thread<void>(std::shared_ptr<struct event_base> base, std::function<void()>&& compute) {
void call_on_event_thread<void>(shared_ptr<struct event_base> base, function<void()>&& compute) {
bool succeeded = false;
std::string exc_what;
std::mutex ret_lock;
std::condition_variable ret_cv;
std::unique_lock<std::mutex> g(ret_lock);
string exc_what;
mutex ret_lock;
condition_variable ret_cv;
unique_lock<mutex> g(ret_lock);
forward_to_event_thread(base, [&]() -> void {
std::lock_guard<std::mutex> g(ret_lock);
lock_guard<mutex> g(ret_lock);
try {
compute();
succeeded = true;
} catch (const std::exception& e) {
} catch (const exception& e) {
exc_what = e.what();
}
ret_cv.notify_one();
});
ret_cv.wait(g);
if (!succeeded) {
throw std::runtime_error(exc_what);
throw runtime_error(exc_what);
}
}
string evbuffer_remove_str(struct evbuffer* buf, ssize_t size) {
if (!buf) {
return "";
}
if (size < 0) {
size = static_cast<size_t>(evbuffer_get_length(buf));
}
string ret(size, '\0');
ssize_t bytes_removed = evbuffer_remove(buf, ret.data(), ret.size());
if (bytes_removed < 0) {
throw std::runtime_error("can\'t remove data from buffer");
}
ret.resize(bytes_removed);
return ret;
}
+3
View File
@@ -8,6 +8,7 @@
#include <mutex>
#include <optional>
#include <stdexcept>
#include <string>
// Calls a function on the given base's event thread. This function returns
// when the call has been enqueued, not necessarily after it returns.
@@ -40,3 +41,5 @@ T call_on_event_thread(std::shared_ptr<struct event_base> base, std::function<T(
template <>
void call_on_event_thread<void>(std::shared_ptr<struct event_base> base, std::function<void()>&& compute);
std::string evbuffer_remove_str(struct evbuffer* buf, ssize_t size = -1);
+14 -9
View File
@@ -15,6 +15,7 @@
#endif
#include "CommandFormats.hh"
#include "CommonFileFormats.hh"
#include "Compression.hh"
#include "Loggers.hh"
@@ -47,16 +48,18 @@ const char* name_for_architecture(CompiledFunctionCode::Architecture arch) {
}
}
template <typename FooterT>
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.entrypoint_addr_offset = this->entrypoint_offset_offset;
footer.root_offset = this->entrypoint_offset_offset;
footer.unused2.clear(0);
phosg::StringWriter w;
@@ -67,7 +70,7 @@ string CompiledFunctionCode::generate_client_command_t(
if (offset > modified_code.size() - 4) {
throw runtime_error("label out of range");
}
*reinterpret_cast<be_uint32_t*>(modified_code.data() + offset) = it.second;
*reinterpret_cast<U32T<FooterT::IsBE>*>(modified_code.data() + offset) = it.second;
}
w.write(modified_code);
} else {
@@ -108,10 +111,10 @@ string CompiledFunctionCode::generate_client_command(
size_t suffix_size,
uint32_t override_relocations_offset) const {
if (this->arch == Architecture::POWERPC) {
return this->generate_client_command_t<S_ExecuteCode_Footer_GC_B2>(
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<S_ExecuteCode_Footer_DC_PC_XB_BB_B2>(
return this->generate_client_command_t<false>(
label_writes, suffix_data, suffix_size, override_relocations_offset);
} else {
throw logic_error("invalid architecture");
@@ -308,7 +311,9 @@ FunctionCodeIndex::FunctionCodeIndex(const string& directory) {
arch = CompiledFunctionCode::Architecture::SH4;
} else if (specific_version_is_gc(specific_version)) {
arch = CompiledFunctionCode::Architecture::POWERPC;
} else if (specific_version_is_xb(specific_version) || specific_version_is_bb(specific_version)) {
} 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");
@@ -367,7 +372,7 @@ shared_ptr<const Menu> FunctionCodeIndex::patch_menu(uint32_t specific_version)
fn->menu_item_id,
fn->long_name.empty() ? fn->short_name : fn->long_name,
fn->description,
MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL);
MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
}
return ret;
}
@@ -386,7 +391,7 @@ shared_ptr<const Menu> FunctionCodeIndex::patch_switches_menu(
string name;
name.push_back(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);
ret->items.emplace_back(fn->menu_item_id, name, fn->description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
}
return ret;
}
@@ -476,7 +481,7 @@ DOLFileIndex::DOLFileIndex(const string& directory) {
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);
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("Failed to load DOL file %s: %s", filename.c_str(), e.what());
+1 -1
View File
@@ -40,7 +40,7 @@ struct CompiledFunctionCode {
bool is_big_endian() const;
template <typename FooterT>
template <bool BE>
std::string generate_client_command_t(
const std::unordered_map<std::string, uint32_t>& label_writes,
const void* suffix_data = nullptr,
+104 -59
View File
@@ -13,7 +13,9 @@
#include "EventUtils.hh"
#include "Loggers.hh"
#include "ProxyServer.hh"
#include "Revision.hh"
#include "Server.hh"
#include "ShellCommands.hh"
using namespace std;
@@ -162,12 +164,18 @@ const string& HTTPServer::get_url_param(
return range.first->second;
}
HTTPServer::HTTPServer(shared_ptr<ServerState> state)
: state(state),
base(event_base_new(), event_base_free),
http(evhttp_new(this->base.get()), evhttp_free),
th(&HTTPServer::thread_fn, this) {
HTTPServer::HTTPServer(shared_ptr<ServerState> state, shared_ptr<struct event_base> shared_base)
: state(state) {
if (!shared_base) {
this->base.reset(event_base_new(), event_base_free);
} else {
this->base = shared_base;
}
this->http.reset(evhttp_new(this->base.get()), evhttp_free);
evhttp_set_gencb(this->http.get(), this->dispatch_handle_request, this);
if (!shared_base) {
this->th = thread(&HTTPServer::thread_fn, this);
}
}
void HTTPServer::listen(const string& socket_path) {
@@ -434,22 +442,12 @@ void HTTPServer::dispatch_handle_request(struct evhttp_request* req, void* ctx)
reinterpret_cast<HTTPServer*>(ctx)->handle_request(req);
}
phosg::JSON HTTPServer::generate_quest_json_st(shared_ptr<const Quest> q) {
if (!q) {
return nullptr;
}
auto battle_rules_json = q->battle_rules ? q->battle_rules->json() : nullptr;
auto challenge_template_index_json = (q->challenge_template_index >= 0)
? q->challenge_template_index
: phosg::JSON(nullptr);
phosg::JSON HTTPServer::generate_server_version_st() {
return phosg::JSON::dict({
{"Number", q->quest_number},
{"Episode", name_for_episode(q->episode)},
{"Joinable", q->joinable},
{"LockStatusRegister", (q->lock_status_register >= 0) ? q->lock_status_register : phosg::JSON(nullptr)},
{"Name", q->name},
{"BattleRules", std::move(battle_rules_json)},
{"ChallengeTemplateIndex", std::move(challenge_template_index_json)},
{"ServerType", "newserv"},
{"BuildTime", BUILD_TIMESTAMP},
{"BuildTimeStr", phosg::format_time(BUILD_TIMESTAMP)},
{"Revision", GIT_REVISION_HASH},
});
}
@@ -550,8 +548,8 @@ phosg::JSON HTTPServer::generate_game_client_json_st(shared_ptr<const Client> c,
{"SubVersion", c->sub_version},
{"Config", HTTPServer::generate_client_config_json_st(c->config)},
{"Language", name_for_language_code(c->language())},
{"LocationX", c->x},
{"LocationZ", c->z},
{"LocationX", c->pos.x.load()},
{"LocationZ", c->pos.z.load()},
{"LocationFloor", c->floor},
{"CanChat", c->can_chat},
});
@@ -567,9 +565,8 @@ phosg::JSON HTTPServer::generate_game_client_json_st(shared_ptr<const Client> c,
auto p = c->character(false, false);
if (p) {
if (!is_ep3(c->version())) {
ret.emplace("InventoryItems", p->inventory.num_items);
if (c->version() != Version::DC_NTE) {
ret.emplace("InventoryLanguage", p->inventory.language);
ret.emplace("InventoryLanguage", name_for_language_code(p->inventory.language));
ret.emplace("NumHPMaterialsUsed", p->get_material_usage(PSOBBCharacterFile::MaterialType::HP));
ret.emplace("NumTPMaterialsUsed", p->get_material_usage(PSOBBCharacterFile::MaterialType::TP));
if (!is_v1_or_v2(c->version())) {
@@ -593,6 +590,7 @@ phosg::JSON HTTPServer::generate_game_client_json_st(shared_ptr<const Client> c,
}
items_json.emplace_back(std::move(item_dict));
}
ret.emplace("InventoryItems", std::move(items_json));
ret.emplace("ATP", p->disp.stats.char_stats.atp.load());
ret.emplace("MST", p->disp.stats.char_stats.mst.load());
ret.emplace("EVP", p->disp.stats.char_stats.evp.load());
@@ -614,7 +612,7 @@ phosg::JSON HTTPServer::generate_game_client_json_st(shared_ptr<const Client> c,
ret.emplace("NameColor", p->disp.visual.name_color.load());
ret.emplace("ExtraModel", (p->disp.visual.validation_flags & 2) ? p->disp.visual.extra_model : phosg::JSON(nullptr));
ret.emplace("SectionID", name_for_section_id(p->disp.visual.section_id));
ret.emplace("CharClass", name_for_char_class(p->disp.visual.section_id));
ret.emplace("CharClass", name_for_char_class(p->disp.visual.char_class));
ret.emplace("Costume", p->disp.visual.costume.load());
ret.emplace("Skin", p->disp.visual.skin.load());
ret.emplace("Face", p->disp.visual.face.load());
@@ -728,15 +726,15 @@ phosg::JSON HTTPServer::generate_proxy_client_json_st(shared_ptr<const ProxyServ
{"Version", phosg::name_for_enum(ses->version())},
{"SubVersion", ses->sub_version},
{"Name", ses->character_name},
{"DCHardwareID", ses->hardware_id},
{"DCSerialNumber2", ses->serial_number2},
{"RemoteGuildCardNumber", ses->remote_guild_card_number},
{"RemoteClientConfigData", phosg::format_data_string(&ses->remote_client_config_data[0], ses->remote_client_config_data.size())},
{"Config", HTTPServer::generate_client_config_json_st(ses->config)},
{"Language", name_for_language_code(ses->language())},
{"LobbyClientID", ses->lobby_client_id},
{"LeaderClientID", ses->leader_client_id},
{"LocationX", ses->x},
{"LocationZ", ses->z},
{"LocationX", ses->pos.x.load()},
{"LocationZ", ses->pos.z.load()},
{"LocationFloor", ses->floor},
{"IsInGame", ses->is_in_game},
{"IsInQuest", ses->is_in_quest},
@@ -787,7 +785,6 @@ phosg::JSON HTTPServer::generate_lobby_json_st(shared_ptr<const Lobby> l, shared
ret.emplace("CheatsEnabled", l->check_flag(Lobby::Flag::CHEATS_ENABLED));
ret.emplace("MinLevel", l->min_level + 1);
ret.emplace("MaxLevel", l->max_level + 1);
ret.emplace("BaseVersion", l->base_version);
ret.emplace("Episode", name_for_episode(l->episode));
ret.emplace("HasPassword", !l->password.empty());
ret.emplace("Name", l->name);
@@ -796,11 +793,7 @@ phosg::JSON HTTPServer::generate_lobby_json_st(shared_ptr<const Lobby> l, shared
ret.emplace("QuestSelectionInProgress", l->check_flag(Lobby::Flag::QUEST_SELECTION_IN_PROGRESS));
ret.emplace("QuestInProgress", l->check_flag(Lobby::Flag::QUEST_IN_PROGRESS));
ret.emplace("JoinableQuestInProgress", l->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS));
auto variations_json = phosg::JSON::list();
for (size_t z = 0; z < l->variations.size(); z++) {
variations_json.emplace_back(l->variations[z].load());
}
ret.emplace("Variations", std::move(variations_json));
ret.emplace("Variations", l->variations.json());
ret.emplace("SectionID", name_for_section_id(l->effective_section_id()));
ret.emplace("Mode", name_for_mode(l->mode));
ret.emplace("Difficulty", name_for_difficulty(l->difficulty));
@@ -845,8 +838,8 @@ phosg::JSON HTTPServer::generate_lobby_json_st(shared_ptr<const Lobby> l, shared
const auto& item = it.second;
auto item_dict = phosg::JSON::dict({
{"LocationFloor", floor},
{"LocationX", item->x},
{"LocationZ", item->z},
{"LocationX", item->pos.x.load()},
{"LocationZ", item->pos.z.load()},
{"DropNumber", item->drop_number},
{"Flags", item->flags},
{"Data", item->data.hex()},
@@ -859,7 +852,7 @@ phosg::JSON HTTPServer::generate_lobby_json_st(shared_ptr<const Lobby> l, shared
}
}
ret.emplace("FloorItems", std::move(floor_items_json));
ret.emplace("Quest", HTTPServer::generate_quest_json_st(l->quest));
ret.emplace("Quest", l->quest ? l->quest->json() : phosg::JSON(nullptr));
} else {
ret.emplace("BattleInProgress", l->check_flag(Lobby::Flag::BATTLE_IN_PROGRESS));
@@ -964,6 +957,16 @@ phosg::JSON HTTPServer::generate_lobby_json_st(shared_ptr<const Lobby> l, shared
return ret;
}
phosg::JSON HTTPServer::generate_accounts_json() const {
return call_on_event_thread<phosg::JSON>(this->state->base, [&]() {
auto res = phosg::JSON::list();
for (const auto& it : this->state->account_index->all()) {
res.emplace_back(it->json());
}
return res;
});
}
phosg::JSON HTTPServer::generate_game_server_clients_json() const {
return call_on_event_thread<phosg::JSON>(this->state->base, [&]() {
auto res = phosg::JSON::list();
@@ -1016,7 +1019,9 @@ phosg::JSON HTTPServer::generate_lobbies_json() const {
return call_on_event_thread<phosg::JSON>(this->state->base, [&]() {
phosg::JSON res = phosg::JSON::list();
for (const auto& it : this->state->id_to_lobby) {
res.emplace_back(this->generate_lobby_json_st(it.second, this->state->item_name_index_opt(it.second->base_version)));
auto leader = it.second->clients[it.second->leader_id];
Version v = leader ? leader->version() : Version::BB_V4;
res.emplace_back(this->generate_lobby_json_st(it.second, this->state->item_name_index_opt(v)));
}
return res;
});
@@ -1061,7 +1066,6 @@ phosg::JSON HTTPServer::generate_summary_json() const {
auto game_json = phosg::JSON::dict({
{"ID", l->lobby_id},
{"Name", l->name},
{"BaseVersion", phosg::name_for_enum(l->base_version)},
{"Players", l->count_clients()},
{"CheatsEnabled", l->check_flag(Lobby::Flag::CHEATS_ENABLED)},
{"Episode", name_for_episode(l->episode)},
@@ -1080,7 +1084,7 @@ phosg::JSON HTTPServer::generate_summary_json() const {
game_json.emplace("SectionID", name_for_section_id(l->effective_section_id()));
game_json.emplace("Mode", name_for_mode(l->mode));
game_json.emplace("Difficulty", name_for_difficulty(l->difficulty));
game_json.emplace("Quest", this->generate_quest_json_st(l->quest));
game_json.emplace("Quest", l->quest ? l->quest->json() : phosg::JSON(nullptr));
}
games_json.emplace_back(std::move(game_json));
}
@@ -1152,6 +1156,31 @@ phosg::JSON HTTPServer::generate_rare_table_json(const std::string& table_name)
}
}
phosg::JSON HTTPServer::generate_quest_list_json(std::shared_ptr<const QuestIndex> quest_index) {
return call_on_event_thread<phosg::JSON>(this->state->base, [&]() {
return quest_index->json();
});
}
void HTTPServer::require_GET(struct evhttp_request* req) {
if (evhttp_request_get_command(req) != EVHTTP_REQ_GET) {
throw HTTPServer::http_error(405, "GET method required for this endpoint");
}
}
phosg::JSON HTTPServer::require_POST(struct evhttp_request* req) {
if (evhttp_request_get_command(req) != EVHTTP_REQ_POST) {
throw HTTPServer::http_error(405, "POST method required for this endpoint");
}
const evkeyvalq* headers = evhttp_request_get_input_headers(req);
const char* content_type = evhttp_find_header(headers, "Content-Type");
if (!content_type || strcmp(content_type, "application/json")) {
throw HTTPServer::http_error(400, "POST requests must use the application/json content type");
}
struct evbuffer* in_buf = evhttp_request_get_input_buffer(req);
return phosg::JSON::parse(evbuffer_remove_str(in_buf));
}
void HTTPServer::handle_request(struct evhttp_request* req) {
shared_ptr<const phosg::JSON> ret;
uint32_t serialize_options = 0;
@@ -1175,58 +1204,70 @@ void HTTPServer::handle_request(struct evhttp_request* req) {
}
if (uri == "/") {
auto endpoints_json = phosg::JSON::list({
"/y/data/ep3-cards",
"/y/data/ep3-cards-trial",
"/y/data/common-tables",
"/y/data/rare-tables",
"/y/data/rare-tables/<TABLE-NAME>",
"/y/data/config",
"/y/clients",
"/y/proxy-clients",
"/y/lobbies",
"/y/server",
"/y/rare-drops/stream",
"/y/summary",
"/y/all",
});
ret = make_shared<phosg::JSON>(phosg::JSON::dict({{"endpoints", std::move(endpoints_json)}}));
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_server_version_st());
} else if (uri == "/y/shell-exec") {
auto json = this->require_POST(req);
auto command = json.get_string("command");
try {
ret = make_shared<phosg::JSON>(phosg::JSON::dict(
{{"result", phosg::join(ShellCommand::dispatch_str(this->state, command), "\n")}}));
} catch (const exception& e) {
throw http_error(400, e.what());
}
} else if (uri == "/y/rare-drops/stream") {
this->require_GET(req);
auto c = this->enable_websockets(req);
if (!c) {
throw http_error(400, "this path requires a websocket connection");
} else {
this->rare_drop_subscribers.emplace(c);
auto version_message = phosg::JSON::dict({{"ServerType", "newserv"}});
auto version_message = this->generate_server_version_st();
this->send_websocket_message(c, version_message.serialize());
return;
}
} else if (uri == "/y/data/ep3-cards") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_ep3_cards_json(false));
} else if (uri == "/y/data/ep3-cards-trial") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_ep3_cards_json(true));
} else if (uri == "/y/data/common-tables") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_common_tables_json());
} else if (uri == "/y/data/rare-tables") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_rare_tables_json());
} else if (!strncmp(uri.c_str(), "/y/data/rare-tables/", 20)) {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_rare_table_json(uri.substr(20)));
} else if (uri == "/y/data/quests") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_quest_list_json(this->state->quest_index(Version::GC_V3)));
} else if (uri == "/y/data/config") {
this->require_GET(req);
ret = call_on_event_thread<shared_ptr<const phosg::JSON>>(this->state->base, [this]() { return this->state->config_json; });
} else if (uri == "/y/accounts") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_accounts_json());
} else if (uri == "/y/clients") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_game_server_clients_json());
} else if (uri == "/y/proxy-clients") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_proxy_server_clients_json());
} else if (uri == "/y/lobbies") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_lobbies_json());
} else if (uri == "/y/server") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_server_info_json());
} else if (uri == "/y/summary") {
this->require_GET(req);
ret = make_shared<phosg::JSON>(this->generate_summary_json());
} else if (uri == "/y/all") {
ret = make_shared<phosg::JSON>(this->generate_all_json());
} else {
throw http_error(404, "unknown action");
@@ -1246,6 +1287,10 @@ void HTTPServer::handle_request(struct evhttp_request* req) {
return;
}
if (!ret) {
throw logic_error("ret was not set after HTTP handler completed");
}
uint64_t handler_end = phosg::now();
unique_ptr<struct evbuffer, void (*)(struct evbuffer*)> out_buffer(evbuffer_new(), evbuffer_free);
string* serialized = new string(ret->serialize(phosg::JSON::SerializeOption::ESCAPE_CONTROLS_ONLY | serialize_options));
+11 -3
View File
@@ -13,7 +13,10 @@
class HTTPServer {
public:
HTTPServer(std::shared_ptr<ServerState> state);
// shared_base should be null unless the HTTP server should run on the main
// thread (on Windows).
HTTPServer(std::shared_ptr<ServerState> state, std::shared_ptr<struct event_base> shared_base);
HTTPServer(const HTTPServer&) = delete;
HTTPServer(HTTPServer&&) = delete;
HTTPServer& operator=(const HTTPServer&) = delete;
@@ -57,12 +60,15 @@ protected:
std::shared_ptr<ServerState> state;
std::shared_ptr<struct event_base> base;
std::shared_ptr<struct evhttp> http;
std::thread th;
std::thread th; // Not used on Windows
std::unordered_set<std::shared_ptr<WebsocketClient>> rare_drop_subscribers;
std::unordered_map<struct bufferevent*, std::shared_ptr<WebsocketClient>> bev_to_websocket_client;
static void require_GET(struct evhttp_request* req);
static phosg::JSON require_POST(struct evhttp_request* req);
std::shared_ptr<WebsocketClient> enable_websockets(struct evhttp_request* req);
static void dispatch_on_websocket_read(struct bufferevent* bev, void* ctx);
@@ -94,12 +100,13 @@ protected:
const std::string& key,
const std::string* _default = nullptr);
static phosg::JSON generate_quest_json_st(std::shared_ptr<const Quest> q);
static phosg::JSON generate_server_version_st();
static phosg::JSON generate_client_config_json_st(const Client::Config& config);
static phosg::JSON generate_account_json_st(std::shared_ptr<const Account> a);
static phosg::JSON generate_game_client_json_st(std::shared_ptr<const Client> c, std::shared_ptr<const ItemNameIndex> item_name_index);
static phosg::JSON generate_proxy_client_json_st(std::shared_ptr<const ProxyServer::LinkedSession> ses);
static phosg::JSON generate_lobby_json_st(std::shared_ptr<const Lobby> l, std::shared_ptr<const ItemNameIndex> item_name_index);
phosg::JSON generate_accounts_json() const;
phosg::JSON generate_game_server_clients_json() const;
phosg::JSON generate_proxy_server_clients_json() const;
phosg::JSON generate_server_info_json() const;
@@ -111,4 +118,5 @@ protected:
phosg::JSON generate_common_tables_json() const;
phosg::JSON generate_rare_tables_json() const;
phosg::JSON generate_rare_table_json(const std::string& table_name) const;
phosg::JSON generate_quest_list_json(std::shared_ptr<const QuestIndex> q);
};
+48 -2
View File
@@ -1,5 +1,6 @@
#include "GVMEncoder.hh"
#include "ImageEncoder.hh"
#include <array>
#include <phosg/Encoding.hh>
#include <phosg/Image.hh>
#include <phosg/Strings.hh>
@@ -34,7 +35,7 @@ struct GVRHeader {
be_uint16_t height;
} __packed_ws__(GVRHeader, 0x10);
string encode_gvm(const phosg::Image& img, GVRDataFormat data_format, const std::string& internal_name, uint32_t global_index) {
string encode_gvm(const phosg::Image& img, GVRDataFormat data_format, const string& internal_name, uint32_t global_index) {
int8_t dimensions_field = -2;
{
size_t h = img.get_height();
@@ -111,3 +112,48 @@ string encode_gvm(const phosg::Image& img, GVRDataFormat data_format, const std:
return std::move(w.str());
}
static const array<uint32_t, 4> fon_colors = {0x000000FF, 0x555555FF, 0xAAAAAAFF, 0xFFFFFFFF};
phosg::Image decode_fon(const string& data, size_t width) {
size_t num_pixels = data.size() * 4;
size_t height = num_pixels / width;
phosg::Image ret(width, height);
phosg::BitReader r(data);
for (size_t y = 0; y < height; y++) {
for (size_t x = 0; x < width; x++) {
ret.write_pixel(x, y, fon_colors[r.read(2)]);
}
}
return ret;
}
constexpr size_t uabs(size_t a, size_t b) {
return (a > b) ? (a - b) : (b - a);
}
string encode_fon(const phosg::Image& img) {
phosg::BitWriter w;
for (size_t y = 0; y < img.get_height(); y++) {
for (size_t x = 0; x < img.get_width(); x++) {
uint32_t color = img.read_pixel(x, y);
size_t result_delta = 0x400;
size_t result_index = 0;
for (size_t z = 0; z < 4; z++) {
size_t delta = uabs((fon_colors[z] >> 24) & 0xFF, (color >> 24) & 0xFF) +
uabs((fon_colors[z] >> 16) & 0xFF, (color >> 16) & 0xFF) +
uabs((fon_colors[z] >> 8) & 0xFF, (color >> 8) & 0xFF) +
uabs(fon_colors[z] & 0xFF, color & 0xFF);
if (delta < result_delta) {
result_delta = delta;
result_index = z;
}
}
w.write(result_index & 2);
w.write(result_index & 1);
}
}
return w.str();
}
@@ -20,6 +20,8 @@ enum class GVRDataFormat : uint8_t {
};
std::string encode_gvm(const phosg::Image& img, GVRDataFormat data_format, const std::string& internal_name, uint32_t global_index);
phosg::Image decode_fon(const std::string& data, size_t width);
std::string encode_fon(const phosg::Image& img);
constexpr uint16_t encode_rgb565(uint8_t r, uint8_t g, uint8_t b) {
return ((r << 8) & 0xF800) | ((g << 3) & 0x07E0) | ((b >> 3) & 0x001F);
+6 -4
View File
@@ -212,7 +212,9 @@ ItemCreator::DropResult ItemCreator::on_box_item_drop_with_area_norm(uint8_t are
}
ItemCreator::DropResult ItemCreator::on_monster_item_drop_with_area_norm(uint32_t enemy_type, uint8_t area_norm) {
if (enemy_type > 0x58) {
// Note: The original GC implementation uses (enemy_type > 0x58) here; we
// extend it to the full array size for BB
if (enemy_type >= 0x64) {
this->log.warning("Invalid enemy type: %" PRIX32, enemy_type);
return DropResult();
}
@@ -297,7 +299,7 @@ ItemData ItemCreator::check_rare_specs_and_create_rare_box_item(uint8_t area_nor
}
auto rare_specs = this->rare_item_set->get_box_specs(
this->mode, this->episode, this->difficulty, this->section_id, area_norm + 1);
this->mode, this->episode, this->difficulty, this->section_id, area_norm);
for (const auto& spec : rare_specs) {
item = this->check_rate_and_create_rare_item(spec, area_norm);
if (!item.empty()) {
@@ -556,7 +558,7 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
break;
case BattleRules::WeaponAndArmorMode::FORBID_RARES:
if (this->item_parameter_table->is_item_rare(item)) {
this->log.info("Restricted: rare items not allowed");
this->log.info("Restricted: rare weapons and armors not allowed");
item.clear();
}
break;
@@ -867,7 +869,7 @@ void ItemCreator::generate_unit_stars_tables() {
star_base_index = 0x124;
num_units = 0x43;
break;
case Version::DC_V1_11_2000_PROTOTYPE:
case Version::DC_11_2000:
case Version::DC_V1:
star_base_index = 0x128;
num_units = 0x44;
+63 -8
View File
@@ -8,13 +8,20 @@
using namespace std;
const vector<uint8_t> ItemData::StackLimits::DEFAULT_TOOL_LIMITS_DC_11_2000(
const vector<uint8_t> ItemData::StackLimits::DEFAULT_TOOL_LIMITS_DC_NTE(
{10});
const vector<uint8_t> ItemData::StackLimits::DEFAULT_TOOL_LIMITS_V1_V2(
{10, 10, 1, 10, 10, 10, 10, 10, 10, 1});
const vector<uint8_t> ItemData::StackLimits::DEFAULT_TOOL_LIMITS_V3_V4(
{10, 10, 1, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 99, 1});
const ItemData::StackLimits ItemData::StackLimits::DEFAULT_STACK_LIMITS_DC_NTE(
Version::DC_NTE, ItemData::StackLimits::DEFAULT_TOOL_LIMITS_DC_NTE, 999999);
const ItemData::StackLimits ItemData::StackLimits::DEFAULT_STACK_LIMITS_V1_V2(
Version::DC_V1, ItemData::StackLimits::DEFAULT_TOOL_LIMITS_V1_V2, 999999);
const ItemData::StackLimits ItemData::StackLimits::DEFAULT_STACK_LIMITS_V3_V4(
Version::GC_V3, ItemData::StackLimits::DEFAULT_TOOL_LIMITS_V3_V4, 999999);
ItemData::StackLimits::StackLimits(
Version version, const vector<uint8_t>& max_tool_stack_sizes_by_data1_1, uint32_t max_meseta_stack_size)
: version(version),
@@ -126,6 +133,50 @@ uint32_t ItemData::primary_identifier() const {
}
}
void ItemData::change_primary_identifier(uint32_t primary_identifier) {
if (((primary_identifier >> 18) & 0xFF) != this->data1[0]) {
throw std::runtime_error("cannot change item class via change_primary_identifier");
}
switch (this->data1[0]) {
case 0x00: { // Weapon
bool was_s_rank_weapon = this->is_s_rank_weapon();
// Apply data1[1], and data1[2] if it's not an ES weapon
this->data1[1] = (primary_identifier >> 16) & 0xFF;
if (!this->is_s_rank_weapon()) {
this->data1[2] = (primary_identifier >> 8) & 0xFF;
} else if (!was_s_rank_weapon) {
// If it wasn't an S-rank weapon before and now is, clear its special
this->data1[2] = 0;
}
break;
}
case 0x01: // Armor/shield/unit
// Apply data1[1] and data1[2]
this->data1[1] = (primary_identifier >> 16) & 0xFF;
this->data1[2] = (primary_identifier >> 8) & 0xFF;
break;
case 0x02: // Mag
// Apply data1[1] only
this->data1[1] = (primary_identifier >> 16) & 0xFF;
break;
case 0x03: // Tool
// Apply data1[1] and data1[2] (or data1[4] if it's a tech disk)
this->data1[1] = (primary_identifier >> 16) & 0xFF;
if (this->data1[1] == 0x02) {
this->data1[4] = (primary_identifier >> 8) & 0xFF;
this->data1[2] = primary_identifier & 0xFF;
} else {
this->data1[2] = (primary_identifier >> 8) & 0xFF;
}
break;
case 0x04: // Meseta
// Nothing to apply
break;
default:
throw std::runtime_error("invalid item class");
}
}
bool ItemData::is_wrapped(const StackLimits& limits) const {
switch (this->data1[0]) {
case 0:
@@ -142,18 +193,22 @@ bool ItemData::is_wrapped(const StackLimits& limits) const {
}
}
void ItemData::wrap(const StackLimits& limits) {
void ItemData::wrap(const StackLimits& limits, uint8_t present_color) {
switch (this->data1[0]) {
case 0:
case 1:
this->data1[4] |= 0x40;
this->data1[5] = (this->data1[5] & 0xF0) | (present_color & 0x0F);
break;
case 1:
this->data1[4] = (this->data1[4] & 0xF0) | 0x40 | (present_color & 0x0F);
break;
case 2:
// Mags cannot have custom present colors
this->data2[2] |= 0x40;
break;
case 3:
if (!this->is_stackable(limits)) {
this->data1[3] |= 0x40;
this->data1[3] = (this->data1[3] & 0xF0) | 0x40 | (present_color & 0x0F);
}
break;
case 4:
@@ -167,14 +222,14 @@ void ItemData::unwrap(const StackLimits& limits) {
switch (this->data1[0]) {
case 0:
case 1:
this->data1[4] &= 0xBF;
this->data1[4] &= 0xB0;
break;
case 2:
this->data2[2] &= 0xBF;
this->data2[2] &= 0xB0;
break;
case 3:
if (!this->is_stackable(limits)) {
this->data1[3] &= 0xBF;
this->data1[3] &= 0xB0;
}
break;
case 4:
@@ -389,7 +444,6 @@ void ItemData::decode_for_version(Version from_version) {
this->data2[0] = this->data2w[1] & 0x7FFF; // Synchro
this->data2[2] = ((this->data2[3] >> 7) & 1) | ((this->data1w[2] >> 14) & 2) | ((this->data1w[3] >> 13) & 4); // PB flags
this->data2[3] = (this->data1w[2] & 1) | ((this->data1w[3] & 1) << 1) | ((this->data1w[4] & 1) << 2) | ((this->data1w[5] & 1) << 3); // Color
// 01000080
this->data1w[2] &= 0x7FFE;
this->data1w[3] &= 0x7FFE;
this->data1w[4] &= 0xFFFE;
@@ -753,6 +807,7 @@ string ItemData::short_hex() const {
size_t offset = ret.find_last_not_of('0');
if (offset != string::npos) {
offset += (offset & 1) ? 1 : 2;
offset = std::max<size_t>(offset, 6);
if (offset < ret.size()) {
ret.resize(offset);
}
+12 -5
View File
@@ -70,26 +70,30 @@ struct ItemData {
uint8_t get(uint8_t data1_0, uint8_t data1_1) const;
static const std::vector<uint8_t> DEFAULT_TOOL_LIMITS_DC_11_2000;
static const std::vector<uint8_t> DEFAULT_TOOL_LIMITS_DC_NTE; // Also for 11/2000
static const std::vector<uint8_t> DEFAULT_TOOL_LIMITS_V1_V2;
static const std::vector<uint8_t> DEFAULT_TOOL_LIMITS_V3_V4;
static const StackLimits DEFAULT_STACK_LIMITS_DC_NTE;
static const StackLimits DEFAULT_STACK_LIMITS_V1_V2;
static const StackLimits DEFAULT_STACK_LIMITS_V3_V4;
};
// QUICK ITEM FORMAT REFERENCE
// data1/0 data1/4 data1/8 data2
// Weapon: 00ZZZZGG SS00AABB AABBAABB 00000000
// Weapon: 00ZZZZGG SSNNAABB AABBAABB 00000000
// Armor: 0101ZZ00 FFTTDDDD EEEE0000 00000000
// Shield: 0102ZZ00 FFTTDDDD EEEE0000 00000000
// Unit: 0103ZZ00 FF00RRRR 00000000 00000000
// Mag: 02ZZLLWW HHHHIIII JJJJKKKK YYQQPPVV
// Tool: 03ZZZZFF 00CC0000 00000000 00000000
// Tool: 03ZZZZUU 00CC0000 00000000 00000000
// Meseta: 04000000 00000000 00000000 MMMMMMMM
// A = attribute type (for S-ranks, custom name)
// B = attribute amount (for S-ranks, custom name)
// C = stack size (for tools)
// D = DEF bonus
// E = EVP bonus
// F = flags (40=present; for tools, unused if item is stackable)
// F = armor/shield/unit flags (40=present; low 4 bits are present color)
// G = weapon grind
// H = mag DEF
// I = mag POW
@@ -97,11 +101,13 @@ struct ItemData {
// K = mag MIND
// L = mag level
// M = meseta amount
// N = present color (weapon only; for other types this is in the flags field)
// P = mag flags (40=present, 04=has left pb, 02=has right pb, 01=has center pb)
// Q = mag IQ
// R = unit modifier (little-endian)
// S = weapon flags (80=unidentified, 40=present) and special (low 6 bits)
// T = slot count
// U = tool flags (40=present; unused if item is stackable)
// V = mag color
// W = photon blasts
// Y = mag synchro
@@ -148,9 +154,10 @@ struct ItemData {
std::string hex() const;
std::string short_hex() const;
uint32_t primary_identifier() const;
void change_primary_identifier(uint32_t primary_identifier);
bool is_wrapped(const StackLimits& limits) const;
void wrap(const StackLimits& limits);
void wrap(const StackLimits& limits, uint8_t present_color);
void unwrap(const StackLimits& limits);
bool is_stackable(const StackLimits& limits) const;
+6 -6
View File
@@ -97,7 +97,7 @@ const array<const char*, 0x11> name_for_s_rank_special = {
"King\'s",
};
std::string ItemNameIndex::describe_item(const ItemData& item, bool include_color_escapes) const {
std::string ItemNameIndex::describe_item(const ItemData& item, bool include_color_escapes, bool hide_mag_stats) const {
if (item.data1[0] == 0x04) {
return phosg::string_printf("%s%" PRIu32 " Meseta", include_color_escapes ? "$C7" : "", item.data2d.load());
}
@@ -135,7 +135,7 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo
// Armors, shields, and units (0x01) can be wrapped, as can mags (0x02) and
// non-stackable tools (0x03). However, each of these item classes has its
// flags in a different location.
if (((item.data1[1] == 0x01) && (item.data1[4] & 0x40)) ||
if (((item.data1[0] == 0x01) && (item.data1[4] & 0x40)) ||
((item.data1[0] == 0x02) && (item.data2[2] & 0x40)) ||
((item.data1[0] == 0x03) && !item.is_stackable(*this->limits) && (item.data1[3] & 0x40))) {
ret_tokens.emplace_back("Wrapped");
@@ -166,8 +166,8 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo
}
}
// For weapons, add the grind and bonuses, or S-rank name if applicable
if (item.data1[0] == 0x00) {
// For weapons, add the grind and bonuses, or S-rank name if applicable
if (item.data1[3] > 0) {
ret_tokens.emplace_back(phosg::string_printf("+%hhu", item.data1[3]));
}
@@ -232,8 +232,8 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo
}
}
// For armors, add the slots, unit modifiers, and/or DEF/EVP bonuses
} else if (item.data1[0] == 0x01) {
// For armors, add the slots, unit modifiers, and/or DEF/EVP bonuses
if (item.data1[1] == 0x03) { // Units
int16_t modifier = item.data1w[3];
if (modifier == 1 || modifier == 2) {
@@ -266,8 +266,8 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo
}
}
} else if (!hide_mag_stats && (item.data1[0] == 0x02)) {
// For mags, add tons of info
} else if (item.data1[0] == 0x02) {
ret_tokens.emplace_back(phosg::string_printf("LV%hhu", item.data1[2]));
uint16_t def = item.data1w[2];
@@ -327,8 +327,8 @@ std::string ItemNameIndex::describe_item(const ItemData& item, bool include_colo
ret_tokens.emplace_back(phosg::string_printf("(!CL:%02hhX)", item.data2[3]));
}
// For tools, add the amount (if applicable)
} else if (item.data1[0] == 0x03) {
// For tools, add the amount (if applicable)
if (item.max_stack_size(*this->limits) > 1) {
ret_tokens.emplace_back(phosg::string_printf("x%hhu", item.data1[5]));
}
+4 -1
View File
@@ -35,7 +35,10 @@ public:
return this->name_index;
}
std::string describe_item(const ItemData& item, bool include_color_escapes = false) const;
inline bool exists(const ItemData& item) const {
return this->primary_identifier_index.count(item.primary_identifier());
}
std::string describe_item(const ItemData& item, bool include_color_escapes = false, bool hide_mag_stats = false) const;
ItemData parse_item_description(const std::string& description) const;
void print_table(FILE* stream) const;
+45 -9
View File
@@ -1,5 +1,7 @@
#include "ItemParameterTable.hh"
#include "CommonFileFormats.hh"
using namespace std;
ItemParameterTable::ItemParameterTable(shared_ptr<const string> data, Version version)
@@ -28,7 +30,7 @@ ItemParameterTable::ItemParameterTable(shared_ptr<const string> data, Version ve
// TODO: Check if first_rare_mag_index is the same on this version
break;
}
case Version::DC_V1_11_2000_PROTOTYPE: {
case Version::DC_11_2000: {
this->offsets_dc_protos = &this->r.pget<TableOffsetsDCProtos>(offset_table_offset);
this->num_weapon_classes = 0x27;
this->num_tool_classes = 0x0E;
@@ -416,15 +418,12 @@ ItemParameterTable::ToolV4 ItemParameterTable::ToolV3T<BE>::to_v4() const {
template <bool BE>
size_t indirect_lookup_2d_count(const phosg::StringReader& r, size_t root_offset, size_t co_index) {
using ArrayRefT = typename std::conditional_t<BE, ItemParameterTable::ArrayRefBE, ItemParameterTable::ArrayRef>;
return r.pget<ArrayRefT>(root_offset + sizeof(ArrayRefT) * co_index).count;
return r.pget<ArrayRefT<BE>>(root_offset + sizeof(ArrayRefT<BE>) * co_index).count;
}
template <typename T, bool BE>
const T& indirect_lookup_2d(const phosg::StringReader& r, size_t root_offset, size_t co_index, size_t item_index) {
using ArrayRefT = typename std::conditional_t<BE, ItemParameterTable::ArrayRefBE, ItemParameterTable::ArrayRef>;
const auto& co = r.pget<ArrayRefT>(root_offset + sizeof(ArrayRefT) * co_index);
const auto& co = r.pget<ArrayRefT<BE>>(root_offset + sizeof(ArrayRefT<BE>) * co_index);
if (item_index >= co.count) {
throw out_of_range("item ID out of range");
}
@@ -740,6 +739,40 @@ pair<uint8_t, uint8_t> ItemParameterTable::find_tool_by_id(uint32_t item_id) con
}
}
variant<
const ItemParameterTable::WeaponV4*,
const ItemParameterTable::ArmorOrShieldV4*,
const ItemParameterTable::UnitV4*,
const ItemParameterTable::MagV4*,
const ItemParameterTable::ToolV4*>
ItemParameterTable::definition_for_primary_identifier(uint32_t primary_identifier) const {
uint8_t data1_0 = (primary_identifier >> 24) & 0xFF;
uint8_t data1_1 = (primary_identifier >> 16) & 0xFF;
uint8_t data1_2 = (primary_identifier >> 8) & 0xFF;
switch (data1_0) {
case 0:
return &this->get_weapon(data1_1, data1_2);
case 1:
switch (data1_1) {
case 1:
case 2:
return &this->get_armor_or_shield(data1_1, data1_2);
case 3:
return &this->get_unit(data1_2);
default:
throw runtime_error("invalid primary identifier");
}
case 2:
return &this->get_mag(data1_1);
case 3:
// NOTE: Unlike in ItemData, the tech number comes first in primary
// identifiers, so we don't need to special-case 0302XXYY here
return &this->get_tool(data1_1, data1_2);
default:
throw runtime_error("invalid primary identifier");
}
}
template <bool BE, typename OffsetsT>
float ItemParameterTable::get_sale_divisor_t(const OffsetsT* offsets, uint8_t data1_0, uint8_t data1_1) const {
switch (data1_0) {
@@ -1255,14 +1288,17 @@ size_t ItemParameterTable::price_for_item(const ItemData& item) const {
throw logic_error("this should be impossible");
}
MagEvolutionTable::MagEvolutionTable(shared_ptr<const string> data)
MagEvolutionTable::MagEvolutionTable(shared_ptr<const string> data, size_t num_mags)
: data(data),
num_mags(num_mags),
r(*data) {
size_t offset_table_offset = this->r.pget_u32l(this->data->size() - 0x10);
this->offsets = &r.pget<TableOffsets>(offset_table_offset);
}
uint8_t MagEvolutionTable::get_evolution_number(uint8_t data1_1) const {
const auto& table = this->r.pget<EvolutionNumberTable>(this->offsets->evolution_number);
return table.values[data1_1];
if (data1_1 >= this->num_mags) {
throw runtime_error("invalid mag number");
}
return this->r.pget_u8(this->offsets->evolution_number + data1_1);
}
+79 -29
View File
@@ -2,16 +2,19 @@
#include <stdint.h>
#include <array>
#include <map>
#include <memory>
#include <phosg/Encoding.hh>
#include <set>
#include <string>
#include <variant>
#include <vector>
#include "ItemData.hh"
#include "Text.hh"
#include "Types.hh"
#include "Version.hh"
class ItemParameterTable {
public:
@@ -19,18 +22,6 @@ public:
// functions instead of manually branching on various offset table pointers
// being null or not in each public function. Rewrite this and make it better.
template <bool BE>
struct ArrayRefT {
/* 00 */ U32T<BE> count;
/* 04 */ U32T<BE> offset;
/* 08 */
} __packed__;
using ArrayRef = ArrayRefT<false>;
using ArrayRefBE = ArrayRefT<true>;
check_struct_size(ArrayRef, 8);
check_struct_size(ArrayRefBE, 8);
template <bool BE>
struct ItemBaseV2T {
// id specifies several things; notably, it doubles as the index of the
@@ -40,8 +31,8 @@ public:
} __packed__;
template <bool BE>
struct ItemBaseV3T : ItemBaseV2T<BE> {
/* 04 */ U16T<BE> type = 0;
/* 06 */ U16T<BE> skin = 0;
/* 04 */ U16T<BE> type = 0; // "Model" in Soly's ItemPMT editor
/* 06 */ U16T<BE> skin = 0; // "Texture" in Soly's ItemPMT editor
/* 08 */
} __packed__;
template <bool BE>
@@ -450,7 +441,6 @@ public:
ItemParameterTable(std::shared_ptr<const std::string> data, Version version);
~ItemParameterTable() = default;
void print(FILE* stream) const;
std::set<uint32_t> compute_all_valid_primary_identifiers() const;
size_t num_weapons_in_class(uint8_t data1_1) const;
@@ -465,6 +455,9 @@ public:
const ToolV4& get_tool(uint8_t data1_1, uint8_t data1_2) const;
std::pair<uint8_t, uint8_t> find_tool_by_id(uint32_t id) const;
std::variant<const WeaponV4*, const ArmorOrShieldV4*, const UnitV4*, const MagV4*, const ToolV4*>
definition_for_primary_identifier(uint32_t primary_identifier) const;
float get_sale_divisor(uint8_t data1_0, uint8_t data1_1) const;
const MagFeedResult& get_mag_feed_result(uint8_t table_index, uint8_t which) const;
uint8_t get_item_stars(uint32_t id) const;
@@ -496,7 +489,7 @@ public:
size_t num_specials;
size_t first_rare_mag_index;
private:
protected:
struct TableOffsetsDCProtos {
/* ## / NTE / 11/2000 */
/* 00 / 0013 / 0013 */ le_uint32_t unknown_a0;
@@ -635,27 +628,84 @@ private:
class MagEvolutionTable {
public:
// TODO: V1 format is different! Offsets are 0438 0440 0498 0520 054C
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;
} __packed_ws__(Side, 0x06);
parray<Side, 2> sides; // [0] = right side, [1] = left side
} __packed_ws__(MotionReference, 0x0C);
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.
le_uint32_t ref_table; // -> MotionReference[num_mags]
le_uint32_t unused_ref_table; // -> MotionReference[num_mags]
} __packed_ws__(MotionReferenceTables, 0x08);
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+)
le_float alpha;
le_float red;
le_float green;
le_float blue;
} __packed_ws__(ColorEntry, 0x10);
struct UnknownA3Entry {
uint8_t flags;
uint8_t unknown_a2;
le_uint16_t unknown_a3;
le_uint16_t unknown_a4;
le_uint16_t unknown_a5;
} __packed_ws__(UnknownA3Entry, 0x08);
struct TableOffsets {
// num_mags = 0x53 in BB, 0x43 in V3
/* 00 / 0400 */ le_uint32_t unknown_a1; // -> [offset -> (0xC-byte struct)[num_mags], offset -> (same as first offset)]
/* 04 / 0408 */ le_uint32_t unknown_a2; // -> (2-byte struct, or single word)[num_mags]
/* 08 / 04AE */ le_uint32_t unknown_a3; // -> (0xA8 bytes; possibly (8-byte struct)[0x15])
/* 0C / 0556 */ le_uint32_t unknown_a4; // -> (uint8_t)[num_mags]
/* 10 / 05AC */ le_uint32_t unknown_a5; // -> (float)[0x48]
/* 14 / 06CC */ le_uint32_t evolution_number; // -> (uint8_t)[num_mags]
// num_mags = 0x3A in v2 and GC NTE, 0x43 in V3, 0x53 in BB
// num_colors = 0x09 in v2 and GC NTE, 0x12 in V3/BB
// TODO: GC NTE uses the v2 format but is big-endian
/* -- / V2 / V3 / BB */
/* 00 / 05BC / 0340 / 0400 */ le_uint32_t motion_tables; // -> MotionReferenceTables
/* 04 / 0594 / 0348 / 0408 */ le_uint32_t unknown_a2; // -> (uint8_t[2])[num_mags] (references into unknown_a3)
/* 08 / 0608 / 03CE / 04AE */ le_uint32_t unknown_a3; // -> UnknownA3Entry[max(unknown_a2) + 1]
/* 0C / 06B0 / 0476 / 0556 */ le_uint32_t unknown_a4; // -> (uint8_t)[num_mags]
/* 10 / 06EC / 04BC / 05AC */ le_uint32_t color_table; // -> ColorEntry[num_colors]
/* 14 / 077C / 05DC / 06CC */ le_uint32_t evolution_number; // -> uint8_t[num_mags]
} __packed_ws__(TableOffsets, 0x18);
struct EvolutionNumberTable {
parray<uint8_t, 0x53> values;
} __packed_ws__(EvolutionNumberTable, 0x53);
MagEvolutionTable(std::shared_ptr<const std::string> data);
MagEvolutionTable(std::shared_ptr<const std::string> data, size_t num_mags);
~MagEvolutionTable() = default;
uint8_t get_evolution_number(uint8_t data1_1) const;
private:
protected:
std::shared_ptr<const std::string> data;
size_t num_mags;
phosg::StringReader r;
const TableOffsets* offsets;
};
+110
View File
@@ -0,0 +1,110 @@
#include "ItemTranslationTable.hh"
using namespace std;
static constexpr bool is_canonical(uint32_t id) {
return !(id & 0x80000000);
}
static constexpr uint32_t make_canonical(uint32_t id) {
return (id & 0x7FFFFFFF);
}
ItemTranslationTable::ItemTranslationTable(
const phosg::JSON& json,
const std::array<std::shared_ptr<const ItemParameterTable>, NUM_VERSIONS>& item_parameter_tables) {
// Parse the table and build the indexes
const auto& l = json.as_list();
for (size_t z = 0; z < l.size(); z++) {
const auto& e = this->entries.emplace_back(*l[z]);
bool has_any_canonical_id = false;
for (size_t v_s = 0; v_s < NUM_NON_PATCH_VERSIONS; v_s++) {
uint32_t id = e.id_for_version[v_s];
if (is_canonical(id)) {
has_any_canonical_id = true;
if (!this->entry_index_for_version[v_s].emplace(id, z).second) {
throw runtime_error(phosg::string_printf("(row %zu) duplicate canonical ID %08" PRIX32, z, id));
}
}
}
if (!has_any_canonical_id) {
throw runtime_error(phosg::string_printf("(row %zu) no canonical ID present in row", z));
}
}
// Validate the table by checking that:
// - Each non-canonical ID points to an existing canonical ID
// - Each canonical ID has an entry in the item parameter table
// - All items in the parameter tables are represented in the translation table
for (size_t v_s = 0; v_s < NUM_NON_PATCH_VERSIONS; v_s++) {
Version v = static_cast<Version>(v_s + NUM_PATCH_VERSIONS);
auto item_parameter_table = item_parameter_tables.at(v_s + NUM_PATCH_VERSIONS);
auto remaining_identifiers = item_parameter_table->compute_all_valid_primary_identifiers();
const auto& entry_index = this->entry_index_for_version[v_s];
for (size_t z = 0; z < this->entries.size(); z++) {
uint32_t e_id = this->entries[z].id_for_version[v_s];
if (is_canonical(e_id)) {
if (!entry_index.count(e_id)) {
throw logic_error(phosg::string_printf("(row %zu version %s) canonical ID %" PRIX32 " is missing from the index", z, phosg::name_for_enum(v), e_id));
}
try {
item_parameter_table->definition_for_primary_identifier(e_id);
} catch (const out_of_range&) {
throw runtime_error(phosg::string_printf("(row %zu version %s) ID %" PRIX32 " not defined in item parameter table", z, phosg::name_for_enum(v), e_id));
}
if (!remaining_identifiers.erase(e_id)) {
throw runtime_error(phosg::string_printf("(row %zu version %s) ID %" PRIX32 " not in item parameter table's primary identifier list", z, phosg::name_for_enum(v), e_id));
}
} else if (!entry_index.count(make_canonical(e_id))) {
throw runtime_error(phosg::string_printf("(row %zu version %s) ID %" PRIX32 " refers to nonexistent canonical ID", z, phosg::name_for_enum(v), e_id));
}
}
if (!remaining_identifiers.empty()) {
string missing_str = phosg::string_printf("(version %s) not all identifiers in the item parameter table are defined in the translation table; missing:", phosg::name_for_enum(v));
for (uint32_t id : remaining_identifiers) {
missing_str += phosg::string_printf(" %08" PRIX32, id);
}
throw runtime_error(missing_str);
}
}
}
phosg::JSON ItemTranslationTable::json() const {
auto ret = phosg::JSON::list();
for (const auto& entry : this->entries) {
ret.emplace_back(entry.json());
}
return ret;
}
uint32_t ItemTranslationTable::translate(uint32_t primary_identifier, Version from_version, Version to_version) const {
if (from_version == to_version) {
return primary_identifier;
}
const auto& entry_index = this->entry_index_for_version.at(static_cast<size_t>(from_version) - NUM_PATCH_VERSIONS);
size_t entry_num = entry_index.at(primary_identifier);
const auto& entry = this->entries.at(entry_num);
return make_canonical(entry.id_for_version.at(static_cast<size_t>(to_version) - NUM_PATCH_VERSIONS));
}
ItemTranslationTable::Entry::Entry(const phosg::JSON& json) {
const auto& l = json.as_list();
if (l.size() != NUM_NON_PATCH_VERSIONS + 1) {
throw runtime_error("list length is incorrect");
}
for (size_t z = 0; z < NUM_NON_PATCH_VERSIONS; z++) {
this->id_for_version[z] = l[z]->as_int();
}
this->name = l[NUM_NON_PATCH_VERSIONS]->as_string();
}
phosg::JSON ItemTranslationTable::Entry::json() const {
auto ret = phosg::JSON::list();
for (size_t z = 0; z < NUM_NON_PATCH_VERSIONS; z++) {
ret.emplace_back(this->id_for_version[z]);
}
ret.emplace_back(this->name);
return ret;
}
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <stdint.h>
#include <array>
#include <memory>
#include <phosg/JSON.hh>
#include <string>
#include <unordered_map>
#include "ItemParameterTable.hh"
#include "Types.hh"
#include "Version.hh"
class ItemTranslationTable {
public:
ItemTranslationTable(
const phosg::JSON& json,
const std::array<std::shared_ptr<const ItemParameterTable>, NUM_VERSIONS>& item_parameter_tables);
~ItemTranslationTable() = default;
phosg::JSON json() const;
uint32_t translate(uint32_t primary_identifier, Version from_version, Version to_version) const;
private:
struct Entry {
std::array<uint32_t, NUM_NON_PATCH_VERSIONS> id_for_version;
std::string name;
explicit Entry(const phosg::JSON& json);
phosg::JSON json() const;
};
std::vector<Entry> entries;
std::array<std::unordered_map<uint32_t, size_t>, NUM_NON_PATCH_VERSIONS> entry_index_for_version;
};
+34 -31
View File
@@ -135,35 +135,32 @@ void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<PSOLFGE
item.flags &= (~8); // Unequip it
should_delete_item = false;
} else if (primary_identifier == 0x030C0000) {
// Cell of MAG 502
} else if ((primary_identifier & 0xFFFF0000) == 0x030C0000) { // Non-combo mag cells
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = (player->disp.visual.section_id & 1) ? 0x1D : 0x21;
} else if (primary_identifier == 0x030C0100) {
// Cell of MAG 213
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = (player->disp.visual.section_id & 1) ? 0x27 : 0x22;
} else if (primary_identifier == 0x030C0200) {
// Parts of RoboChao
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = 0x28;
} else if (primary_identifier == 0x030C0300) {
// Heart of Opa Opa
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = 0x29;
} else if (primary_identifier == 0x030C0400) {
// Heart of Pian
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = 0x2A;
} else if (primary_identifier == 0x030C0500) {
// Heart of Chao
auto& mag = player->inventory.items[player->inventory.find_equipped_item(EquipSlot::MAG)];
mag.data.data1[1] = 0x2B;
if (s->mag_evolution_table(c->version())->get_evolution_number(mag.data.data1[1]) < 4) {
switch (item.data.data1[2]) {
case 0x00: // Cell of MAG 502
mag.data.data1[1] = (player->disp.visual.section_id & 1) ? 0x1D : 0x21;
break;
case 0x01: // Cell of MAG 213
mag.data.data1[1] = (player->disp.visual.section_id & 1) ? 0x27 : 0x22;
break;
case 0x02: // Parts of RoboChao
mag.data.data1[1] = 0x28;
break;
case 0x03: // Heart of Opa Opa
mag.data.data1[1] = 0x29;
break;
case 0x04: // Heart of Pian
mag.data.data1[1] = 0x2A;
break;
case 0x05: // Heart of Chao
mag.data.data1[1] = 0x2B;
break;
default:
throw runtime_error("invalid mag cell used");
}
}
} else if ((primary_identifier & 0xFFFF0000) == 0x03150000) {
// Christmas Present, etc. - use unwrap_table + probabilities therein
@@ -176,6 +173,10 @@ void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<PSOLFGE
if (sum == 0) {
throw runtime_error("no unwrap results available for event");
}
// TODO: It seems that on non-BB, clients don't synchronize this at all, so
// they could end up thinking the unwrapped item is something completely
// different. (They don't even use a fixed random seed, like for rares;
// they just call rand().) How does this actually work on console PSO?
size_t det = random_from_optional_crypt(opt_rand_crypt) % sum;
for (size_t z = 0; z < table.second; z++) {
const auto& entry = table.first[z];
@@ -190,8 +191,10 @@ void player_use_item(shared_ptr<Client> c, size_t item_index, shared_ptr<PSOLFGE
should_delete_item = false;
auto l = c->require_lobby();
if (l->base_version == Version::BB_V4) {
send_create_inventory_item_to_lobby(c, c->lobby_client_id, item.data);
for (const auto& lc : l->clients) {
if (lc && (lc->version() == Version::BB_V4)) {
send_create_inventory_item_to_client(c, c->lobby_client_id, item.data);
}
}
break;
}
@@ -501,7 +504,7 @@ void player_feed_mag(std::shared_ptr<Client> c, size_t mag_item_index, size_t fe
player->inventory.items[mag_item_index].data,
player->inventory.items[fed_item_index].data,
s->item_parameter_table(c->version()),
s->mag_evolution_table,
s->mag_evolution_table(c->version()),
player->disp.visual.char_class,
player->disp.visual.section_id,
!is_v1_or_v2(c->version()));
+49 -21
View File
@@ -4,6 +4,7 @@
#include <phosg/Filesystem.hh>
#include "CommonFileFormats.hh"
#include "Compression.hh"
#include "PSOEncryption.hh"
@@ -36,22 +37,22 @@ 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; // -> u32[9] -> LevelStatsDelta[200]
le_uint32_t unknown_a1; // -> float[6]
le_uint32_t max_stats; // -> PlayerStats[9]
le_uint32_t level_100_stats; // -> Level100Entry[9]
le_uint32_t base_stats; // -> u32[9] -> CharacterStats
le_uint32_t unknown_a2; // -> (0x120 zero bytes)
le_uint32_t attack_data; // -> AttackData[9]
le_uint32_t unknown_a4; // -> (0x14-byte struct)[9]
le_uint32_t unknown_a5; // -> float[9]
le_uint32_t unknown_a6; // -> (0x30 bytes)
le_uint32_t unknown_a7; // -> (0x2D bytes)
le_uint32_t unknown_a8; // -> u32[3] -> float[0x2D]
le_uint32_t unknown_a9; // -> (0x90 bytes)
le_uint32_t unknown_a10; // -> u32[3] -> (0x10-byte struct)[0x0C]
le_uint32_t unknown_a11; // -> u32[3] -> (0x30-bytes)
le_uint32_t unknown_a12; // -> u32[3] -> (0x14-byte struct)[0x0F]
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;
@@ -63,7 +64,8 @@ LevelTableV2::LevelTableV2(const string& data, bool compressed) {
r = phosg::StringReader(data);
}
const auto& offsets = r.pget<Offsets>(r.pget_u32l(r.size() - 0x10));
const auto& footer = r.pget<RELFileFooter>(r.size() - sizeof(RELFileFooter));
const auto& offsets = r.pget<Offsets>(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++) {
@@ -72,7 +74,7 @@ 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<Level100Entry>(offsets.level_100_stats + char_class * sizeof(Level100Entry));
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]);
}
}
@@ -81,7 +83,7 @@ const CharacterStats& LevelTableV2::base_stats_for_class(uint8_t char_class) con
return this->base_stats.at(char_class);
}
const LevelTableV2::Level100Entry& LevelTableV2::level_100_stats_for_class(uint8_t char_class) const {
const PlayerStats& LevelTableV2::level_100_stats_for_class(uint8_t char_class) const {
return this->level_100_stats.at(char_class);
}
@@ -112,7 +114,8 @@ LevelTableV3BE::LevelTableV3BE(const string& data, bool encrypted) {
// u32 offset:
// u32[12] offsets:
// LevelStatsDeltaBE[200] level_deltas
const auto& offsets = r.pget<parray<be_uint32_t, 12>>(r.pget_u32b(r.pget_u32b(r.size() - 0x10)));
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++) {
@@ -150,6 +153,26 @@ const CharacterStats& LevelTableV3BE::base_stats_for_class(uint8_t char_class) c
return data.at(char_class);
}
static const array<PlayerStats, 12> max_stats_v3_v4 = {
// ATP MST EVP HP DFP ATA LCK ESP PRX PRY L E M
PlayerStats{{0x056B, 0x02DC, 0x02F4, 0x0265, 0x0243, 0x054B, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x04CB, 0x0499, 0x032B, 0x0254, 0x024D, 0x056C, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x065D, 0x0000, 0x0294, 0x0379, 0x0259, 0x0514, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x04E7, 0x0299, 0x02CB, 0x02D5, 0x0203, 0x06CB, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x0541, 0x0000, 0x02BB, 0x0430, 0x025E, 0x05FA, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x0492, 0x0000, 0x0313, 0x0439, 0x02B0, 0x062C, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x0365, 0x0504, 0x024C, 0x0302, 0x01F2, 0x0440, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x032B, 0x05DC, 0x02A7, 0x02E3, 0x01CF, 0x04B0, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x0244, 0x06D6, 0x0373, 0x02BE, 0x0186, 0x04EC, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x050B, 0x0000, 0x036D, 0x02EE, 0x020D, 0x05DC, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
PlayerStats{{0x03E7, 0x053C, 0x028B, 0x02CC, 0x01D6, 0x03F2, 0x0064}, 0x0064, 0.0f, 0.0f, 0, 0, 0},
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 {
return max_stats_v3_v4.at(char_class);
}
const LevelStatsDelta& LevelTableV3BE::stats_delta_for_level(uint8_t char_class, uint8_t level) const {
return this->level_deltas.at(char_class).at(level);
}
@@ -169,7 +192,8 @@ LevelTableV4::LevelTableV4(const string& data, bool compressed) {
r = phosg::StringReader(data);
}
const auto& offsets = r.pget<Offsets>(r.pget_u32l(r.size() - 0x10));
const auto& footer = r.pget<RELFileFooter>(r.size() - sizeof(RELFileFooter));
const auto& offsets = r.pget<Offsets>(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++) {
@@ -185,6 +209,10 @@ const CharacterStats& LevelTableV4::base_stats_for_class(uint8_t char_class) con
return this->base_stats.at(char_class);
}
const PlayerStats& LevelTableV4::max_stats_for_class(uint8_t char_class) const {
return max_stats_v3_v4.at(char_class);
}
const LevelStatsDelta& LevelTableV4::stats_delta_for_level(uint8_t char_class, uint8_t level) const {
return this->level_deltas.at(char_class).at(level);
}
+6 -12
View File
@@ -104,6 +104,7 @@ class LevelTable {
public:
virtual ~LevelTable() = default;
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;
void reset_to_base(PlayerStats& stats, uint8_t char_class) const;
@@ -115,26 +116,17 @@ protected:
class LevelTableV2 : public LevelTable { // from PlayerTable.prs (PC)
public:
struct Level100Entry {
/* 00 */ CharacterStats char_stats;
/* 0E */ le_uint16_t unknown_a1 = 0;
/* 10 */ le_float height = 0.0;
/* 14 */ le_float unknown_a3 = 0.0;
/* 18 */ le_uint32_t level = 0;
/* 1C */
} __packed_ws__(Level100Entry, 0x1C);
LevelTableV2(const std::string& data, bool compressed);
virtual ~LevelTableV2() = default;
virtual const CharacterStats& base_stats_for_class(uint8_t char_class) const;
const Level100Entry& level_100_stats_for_class(uint8_t char_class) const;
const PlayerStats& max_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::array<CharacterStats, 9> base_stats;
std::array<Level100Entry, 9> level_100_stats;
std::array<PlayerStats, 9> level_100_stats;
std::array<PlayerStats, 9> max_stats;
std::array<std::array<LevelStatsDelta, 200>, 9> level_deltas;
};
@@ -145,6 +137,7 @@ public:
virtual ~LevelTableV3BE() = default;
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:
@@ -157,6 +150,7 @@ public:
virtual ~LevelTableV4() = default;
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:
+67 -226
View File
@@ -27,12 +27,18 @@ shared_ptr<Lobby::FloorItem> Lobby::FloorItemManager::find(uint32_t item_id) con
return this->items.at(item_id);
}
void Lobby::FloorItemManager::add(const ItemData& item, float x, float z, uint16_t flags) {
void Lobby::FloorItemManager::add(
const ItemData& item,
const VectorXZF& pos,
shared_ptr<const MapState::ObjectState> from_obj,
shared_ptr<const MapState::EnemyState> from_ene,
uint16_t flags) {
auto fi = make_shared<FloorItem>();
fi->data = item;
fi->x = x;
fi->z = z;
fi->pos = pos;
fi->drop_number = this->next_drop_number++;
fi->from_obj = from_obj;
fi->from_ene = from_ene;
fi->flags = flags;
this->add(fi);
}
@@ -52,7 +58,7 @@ void Lobby::FloorItemManager::add(shared_ptr<Lobby::FloorItem> fi) {
}
}
this->log.info("Added floor item %08" PRIX32 " at %g, %g with drop number %" PRIu64 " with flags %03hX",
fi->data.id.load(), fi->x, fi->z, fi->drop_number, fi->flags);
fi->data.id.load(), fi->pos.x.load(), fi->pos.z.load(), fi->drop_number, fi->flags);
}
std::shared_ptr<Lobby::FloorItem> Lobby::FloorItemManager::remove(uint32_t item_id, uint8_t client_id) {
@@ -71,7 +77,7 @@ std::shared_ptr<Lobby::FloorItem> Lobby::FloorItemManager::remove(uint32_t item_
}
this->items.erase(item_it);
this->log.info("Removed floor item %08" PRIX32 " at %g, %g with drop number %" PRIu64 " with flags %03hX",
fi->data.id.load(), fi->x, fi->z, fi->drop_number, fi->flags);
fi->data.id.load(), fi->pos.x.load(), fi->pos.z.load(), fi->drop_number, fi->flags);
return fi;
}
@@ -142,7 +148,6 @@ Lobby::Lobby(shared_ptr<ServerState> s, uint32_t id, bool is_game)
min_level(0),
max_level(0xFFFFFFFF),
next_game_item_id(0xCC000000),
base_version(Version::GC_V3),
allowed_versions(0x0000),
override_section_id(0xFF),
episode(Episode::NONE),
@@ -196,31 +201,29 @@ shared_ptr<Lobby::ChallengeParameters> Lobby::require_challenge_params() const {
return this->challenge_params;
}
void Lobby::set_drop_mode(DropMode new_mode) {
this->drop_mode = new_mode;
bool should_have_item_creator = (this->base_version == Version::BB_V4) ||
((new_mode != DropMode::DISABLED) && (new_mode != DropMode::CLIENT));
if (should_have_item_creator && !this->item_creator) {
this->create_item_creator();
} else if (!should_have_item_creator && this->item_creator) {
void Lobby::create_item_creator(Version logic_version) {
if (!this->is_game() || this->episode == Episode::EP3) {
this->item_creator.reset();
return;
}
}
void Lobby::create_item_creator() {
auto s = this->require_server_state();
if (logic_version == Version::UNKNOWN) {
auto leader_c = this->clients[this->leader_id];
logic_version = leader_c ? leader_c->version() : Version::BB_V4;
}
shared_ptr<const RareItemSet> rare_item_set;
shared_ptr<const CommonItemSet> common_item_set;
switch (this->base_version) {
switch (logic_version) {
case Version::PC_PATCH:
case Version::BB_PATCH:
case Version::GC_EP3_NTE:
case Version::GC_EP3:
throw runtime_error("cannot create item creator for this base version");
case Version::DC_NTE:
case Version::DC_V1_11_2000_PROTOTYPE:
case Version::DC_11_2000:
case Version::DC_V1:
// TODO: We should probably have a v1 common item set at some point too
common_item_set = s->common_item_set_v2;
@@ -245,6 +248,7 @@ void Lobby::create_item_creator() {
default:
throw logic_error("invalid lobby base version");
}
this->item_creator = make_shared<ItemCreator>(
common_item_set,
rare_item_set,
@@ -252,8 +256,8 @@ void Lobby::create_item_creator() {
s->tool_random_set,
s->weapon_random_sets.at(this->difficulty),
s->tekker_adjustment_set,
s->item_parameter_table(this->base_version),
s->item_stack_limits(this->base_version),
s->item_parameter_table(logic_version),
s->item_stack_limits(logic_version),
this->episode,
(this->mode == GameMode::SOLO) ? GameMode::NORMAL : this->mode,
this->difficulty,
@@ -262,21 +266,6 @@ void Lobby::create_item_creator() {
this->quest ? this->quest->battle_rules : nullptr);
}
void Lobby::change_section_id() {
if (this->item_creator) {
uint8_t new_section_id = this->effective_section_id();
if (this->item_creator->get_section_id() != new_section_id) {
this->log.info("Changing section ID to %s", name_for_section_id(new_section_id));
this->item_creator->set_section_id(new_section_id);
for (const auto& c : this->clients) {
if (c && c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
send_text_message_printf(c, "$C5Section ID changed\nto %s (%hhu)", name_for_section_id(new_section_id), new_section_id);
}
}
}
}
}
uint8_t Lobby::effective_section_id() const {
if (this->override_section_id != 0xFF) {
return this->override_section_id;
@@ -291,205 +280,50 @@ uint8_t Lobby::effective_section_id() const {
return 0;
}
shared_ptr<Map> Lobby::load_maps(
Version version,
Episode episode,
uint8_t difficulty,
uint8_t event,
uint32_t lobby_id,
shared_ptr<const Map::RareEnemyRates> rare_rates,
uint32_t random_seed,
shared_ptr<PSOLFGEncryption> opt_rand_crypt,
shared_ptr<const string> quest_dat_contents_decompressed) {
auto map = make_shared<Map>(version, lobby_id, random_seed, opt_rand_crypt);
map->add_entities_from_quest_data(
episode,
difficulty,
event,
quest_dat_contents_decompressed->data(),
quest_dat_contents_decompressed->size(),
rare_rates);
return map;
}
shared_ptr<Map> Lobby::load_maps(
Version version,
Episode episode,
GameMode mode,
uint8_t difficulty,
uint8_t event,
uint32_t lobby_id,
shared_ptr<const SetDataTableBase> sdt,
function<shared_ptr<const string>(Version, const string&)> get_file_data,
shared_ptr<const Map::RareEnemyRates> rare_rates,
uint32_t random_seed,
shared_ptr<PSOLFGEncryption> opt_rand_crypt,
const parray<le_uint32_t, 0x20>& variations,
const phosg::PrefixedLogger* log) {
auto enemy_filenames = sdt->map_filenames_for_variations(variations, episode, mode, SetDataTable::FilenameType::ENEMIES);
auto object_filenames = sdt->map_filenames_for_variations(variations, episode, mode, SetDataTable::FilenameType::OBJECTS);
auto event_filenames = sdt->map_filenames_for_variations(variations, episode, mode, SetDataTable::FilenameType::EVENTS);
return Lobby::load_maps(
enemy_filenames,
object_filenames,
event_filenames,
version,
episode,
mode,
difficulty,
event,
lobby_id,
get_file_data,
rare_rates,
random_seed,
opt_rand_crypt,
log);
}
shared_ptr<Map> Lobby::load_maps(
const vector<string>& enemy_filenames,
const vector<string>& object_filenames,
const vector<string>& event_filenames,
Version version,
Episode episode,
GameMode mode,
uint8_t difficulty,
uint8_t event,
uint32_t lobby_id,
function<shared_ptr<const string>(Version, const string&)> get_file_data,
shared_ptr<const Map::RareEnemyRates> rare_rates,
uint32_t rare_seed,
shared_ptr<PSOLFGEncryption> opt_rand_crypt,
const phosg::PrefixedLogger* log) {
auto map = make_shared<Map>(version, lobby_id, rare_seed, opt_rand_crypt);
// Don't load free-roam maps in Challenge mode, since players can't go to
// Ragol without a quest loaded
if (mode == GameMode::CHALLENGE) {
return map;
}
for (size_t floor = 0; floor < 0x12; floor++) {
const auto& floor_enemy_filename = enemy_filenames.at(floor);
if (!floor_enemy_filename.empty()) {
auto map_data = get_file_data(version, floor_enemy_filename);
if (map_data) {
map->add_enemies_from_map_data(
episode,
difficulty,
event,
floor,
map_data->data(),
map_data->size(),
rare_rates);
if (log) {
log->info("Loaded enemies map %s for floor %02zX", floor_enemy_filename.c_str(), floor);
}
} else if (log) {
log->info("Enemies map %s for floor %02zX cannot be used; skipping", floor_enemy_filename.c_str(), floor);
}
} else if (log) {
log->info("No enemies to load for floor %02zX", floor);
}
const auto& floor_object_filename = object_filenames.at(floor);
if (!floor_object_filename.empty()) {
auto map_data = get_file_data(version, floor_object_filename);
if (map_data) {
map->add_objects_from_map_data(floor, map_data->data(), map_data->size());
if (log) {
log->info("Loaded objects map %s for floor %02zX", floor_object_filename.c_str(), floor);
}
} else if (log) {
log->info("Objects map %s for floor %02zX cannot be used; skipping", floor_object_filename.c_str(), floor);
}
} else if (log) {
log->info("No objects to load for floor %02zX", floor);
}
const auto& floor_event_filename = event_filenames.at(floor);
if (!floor_event_filename.empty()) {
auto map_data = get_file_data(version, floor_event_filename);
if (map_data) {
map->add_events_from_map_data(floor, map_data->data(), map_data->size());
if (log) {
log->info("Loaded events map %s for floor %02zX", floor_event_filename.c_str(), floor);
}
} else if (log) {
log->info("Events map %s for floor %02zX cannot be used; skipping", floor_event_filename.c_str(), floor);
}
} else if (log) {
log->info("No events to load for floor %02zX", floor);
uint16_t Lobby::quest_version_flags() const {
uint16_t ret = 0;
for (auto lc : this->clients) {
if (lc) {
ret |= (1 << static_cast<size_t>(lc->version()));
}
}
return map;
return ret;
}
void Lobby::load_maps() {
auto rare_rates = ((this->base_version == Version::BB_V4) && this->rare_enemy_rates)
? this->rare_enemy_rates
: Map::DEFAULT_RARE_ENEMIES;
auto rare_rates = this->rare_enemy_rates ? this->rare_enemy_rates : MapState::DEFAULT_RARE_ENEMIES;
if (this->quest) {
auto leader_c = this->clients.at(this->leader_id);
if (!leader_c) {
throw logic_error("lobby leader is missing");
}
auto vq = this->quest->version(this->base_version, leader_c->language());
if (!vq->dat_contents_decompressed) {
throw runtime_error("quest does not have DAT data");
}
this->map = this->load_maps(
this->base_version,
this->episode,
if (this->episode == Episode::EP3) {
this->map_state = make_shared<MapState>();
} else if (this->quest) {
this->map_state = make_shared<MapState>(
this->lobby_id,
this->difficulty,
this->event,
this->lobby_id,
rare_rates,
this->random_seed,
this->rare_enemy_rates,
this->opt_rand_crypt,
vq->dat_contents_decompressed);
} else if (this->mode != GameMode::CHALLENGE) {
auto s = this->require_server_state();
this->map = this->load_maps(
this->base_version,
this->episode,
this->mode,
this->difficulty,
this->event,
this->lobby_id,
s->set_data_table(this->base_version, this->episode, this->mode, this->difficulty),
bind(&ServerState::load_map_file, s.get(), placeholders::_1, placeholders::_2),
rare_rates,
this->random_seed,
this->opt_rand_crypt,
this->variations,
&this->log);
this->quest->get_supermap(this->random_seed));
} else {
this->map = make_shared<Map>(this->base_version, this->lobby_id, this->random_seed, this->opt_rand_crypt);
auto s = this->require_server_state();
this->map_state = make_shared<MapState>(
this->lobby_id,
this->difficulty,
this->event,
this->random_seed,
this->rare_enemy_rates,
this->opt_rand_crypt,
s->supermaps_for_variations(this->episode, this->mode, this->difficulty, this->variations));
}
}
this->log.info("Generated objects list (%zu entries):", this->map->objects.size());
for (size_t z = 0; z < this->map->objects.size(); z++) {
string o_str = this->map->objects[z].str();
this->log.info("(K-%zX) %s", z, o_str.c_str());
[[nodiscard]] bool Lobby::is_ep3_nte() const {
for (const auto& lc : this->clients) {
if (lc && (lc->version() != Version::GC_EP3_NTE)) {
return false;
}
}
this->log.info("Generated enemies list (%zu entries):", this->map->enemies.size());
for (size_t z = 0; z < this->map->enemies.size(); z++) {
string e_str = this->map->enemies[z].str();
this->log.info("(E-%zX) %s", z, e_str.c_str());
}
this->log.info("Generated events list (%zu entries):", this->map->events.size());
for (size_t z = 0; z < this->map->events.size(); z++) {
string e_str = this->map->events[z].str();
this->log.info("%s", e_str.c_str());
}
this->log.info("Loaded maps contain %zu object entries and %zu enemy entries overall (%zu as rares)",
this->map->objects.size(), this->map->enemies.size(), this->map->rare_enemy_indexes.size());
return true;
}
void Lobby::create_ep3_server() {
@@ -500,7 +334,8 @@ void Lobby::create_ep3_server() {
this->log.info("Recreating Episode 3 server state");
}
auto tourn = this->tournament_match ? this->tournament_match->tournament.lock() : nullptr;
bool is_nte = this->base_version == Version::GC_EP3_NTE;
bool is_nte = this->is_ep3_nte();
Episode3::Server::Options options = {
.card_index = is_nte ? s->ep3_card_index_trial : s->ep3_card_index,
.map_index = s->ep3_map_index,
@@ -510,7 +345,7 @@ void Lobby::create_ep3_server() {
.tournament = tourn,
.trap_card_ids = s->ep3_trap_card_ids,
};
if (this->base_version == Version::GC_EP3_NTE) {
if (is_nte) {
options.behavior_flags |= Episode3::BehaviorFlag::IS_TRIAL_EDITION;
} else {
options.behavior_flags &= (~Episode3::BehaviorFlag::IS_TRIAL_EDITION);
@@ -526,7 +361,7 @@ void Lobby::reassign_leader_on_client_departure(size_t leaving_client_index) {
}
if (this->clients[x]) {
this->leader_id = x;
this->change_section_id();
this->create_item_creator();
return;
}
}
@@ -617,7 +452,7 @@ void Lobby::add_client(shared_ptr<Client> c, ssize_t required_client_id) {
}
if (leader_index >= this->max_clients) {
this->leader_id = c->lobby_client_id;
this->change_section_id();
this->create_item_creator();
}
// If this is a lobby or no one was here before this, reassign all the floor
@@ -856,9 +691,15 @@ shared_ptr<Lobby::FloorItem> Lobby::find_item(uint8_t floor, uint32_t item_id) c
return this->floor_item_managers.at(floor).find(item_id);
}
void Lobby::add_item(uint8_t floor, const ItemData& data, float x, float z, uint16_t flags) {
void Lobby::add_item(
uint8_t floor,
const ItemData& data,
const VectorXZF& pos,
std::shared_ptr<const MapState::ObjectState> from_obj,
std::shared_ptr<const MapState::EnemyState> from_ene,
uint16_t flags) {
auto& m = this->floor_item_managers.at(floor);
m.add(data, x, z, flags);
m.add(data, pos, from_obj, from_ene, flags);
this->evict_items_from_floor(floor);
}

Some files were not shown because too many files have changed in this diff Show More