Compare commits
755 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e88ed98318
|
|||
| 211d08710b | |||
| ee40425393 | |||
| 12f9a045ca | |||
| 8134243fb1 | |||
| c869ed27f1 | |||
| 321ba64016 | |||
| a8606d26a8 | |||
| a57cca6c12 | |||
|
86a46df442
|
|||
|
cdb397f5ea
|
|||
|
2b73d58033
|
|||
|
5abd47ff72
|
|||
|
261cb5c76f
|
|||
|
ea1044c271
|
|||
|
a1c358e13a
|
|||
|
1f00bf1d9b
|
|||
|
8bc602012e
|
|||
|
e0c34fe700
|
|||
|
cbe9747fd4
|
|||
|
de0104eec8
|
|||
|
c454068715
|
|||
| b8e7d81a22 | |||
|
d98e1f7478
|
|||
| d384cf4f11 | |||
| 681ce135f8 | |||
|
c497f64376
|
|||
|
5d43acd9a2
|
|||
|
90a1f0f938
|
|||
|
db52a15888
|
|||
|
71fc272133
|
|||
|
bef656077c
|
|||
|
fff0f3a71d
|
|||
|
e94fcf035e
|
|||
|
0abdb50eca
|
|||
|
a0306ecaee
|
|||
|
ce0aea1518
|
|||
|
1c3e8ca53c
|
|||
| e19c0b8bc9 | |||
| 6b636c4694 | |||
| 1fa3d18430 | |||
| 2f4a9462ea | |||
|
f05e68492d
|
|||
| 826eb88e2e | |||
| 80391df8b7 | |||
| 7f68d41bac | |||
| 75e7232096 | |||
| 7a29b39771 | |||
| cfcb56b13f | |||
| 9e6740b778 | |||
| 590f937959 | |||
| 31abc24e81 | |||
| 507fbf0451 | |||
| 1fa660129d | |||
| 67082f7b6b | |||
| b34c9a7c88 | |||
| 87e85932a4 | |||
| b704d827ed | |||
| 598ecf88e3 | |||
| a05971017d | |||
| b7819413b0 | |||
| 80e4b0e6fe | |||
| daee47b722 | |||
| 5724fb9a12 | |||
| 983753f840 | |||
| 53d2318873 | |||
| 83291d5501 | |||
| 55be92a56f | |||
| 6a23e5da0a | |||
| 4571cf7fdc | |||
| 4e3549ba6b | |||
| 3cbf64dda2 | |||
| 382bc6b7ce | |||
| e05991ffb3 | |||
| ffda97222d | |||
| 8f21604367 | |||
| 4045504b61 | |||
| 4aad1514c2 | |||
| a649a4a146 | |||
| 7e21d8a9a1 | |||
| c0fc3014cf | |||
| 08dff98948 | |||
| d1c1228308 | |||
| b5fd58722b | |||
| f0e8e35e2b | |||
| 68b495b4b4 | |||
| 1e459edfc4 | |||
| c6d7025f43 | |||
| ccf4b723f5 | |||
| 8717f00106 | |||
| 99630c999d | |||
| e8c262223b | |||
| 3d7215d591 | |||
| ba48236200 | |||
| 8065300fae | |||
| e9dfa5d1de | |||
| d38be2f360 | |||
| 2429c4d341 | |||
| ef2d9fae03 | |||
| 7016d65313 | |||
| bdd066edb2 | |||
| 1bd305d4e7 | |||
| 890014b223 | |||
| e4ef96fcc5 | |||
| 641b3a7bef | |||
| 6f9f684cc9 | |||
| 2602196279 | |||
| ec16cb0ae3 | |||
| 6da7b26c9f | |||
| 8663e6682a | |||
| 9b14e5d400 | |||
| a1e067cc52 | |||
| a469b4355e | |||
| 4aa206bd4b | |||
| d9540ba414 | |||
| cb7c45ef27 | |||
| f98db20618 | |||
| 8fbf2246e6 | |||
| 6b1726c1b5 | |||
| cac61e6763 | |||
| 227e88f906 | |||
| 7ab3175f80 | |||
| cd0d13e98c | |||
| 8eeb487bc7 | |||
| d79d551c68 | |||
| 4b43333ce9 | |||
| b228ea847f | |||
| 4d97bdec7f | |||
| 8133b20598 | |||
| 73ced9d229 | |||
| 6e765fe1ed | |||
| 26f9b90ef8 | |||
| 668c687d68 | |||
| 87b048dc15 | |||
| ea23f18aa2 | |||
| a0a7231d67 | |||
| e5a03b7e9b | |||
| a013b8c9d3 | |||
| 894ac6b8ff | |||
| a462a774f5 | |||
| a9fa138213 | |||
| 0a4c9a0a61 | |||
| f99bba67d0 | |||
| 849cca37c8 | |||
| 9ebaaacd46 | |||
| c1968dad27 | |||
| 2732f9c9f8 | |||
| 1bd2e6cf62 | |||
| 1ab7a851be | |||
| 342b4df8c4 | |||
| 8953ffc2b5 | |||
| af796a418a | |||
| 60203bdfba | |||
| 6677908354 | |||
| 96079700f7 | |||
| 976a281e93 | |||
| 6291e42ba9 | |||
| a89423e9f5 | |||
| 81169ba9d3 | |||
| e715a8461a | |||
| 1ee6b21398 | |||
| 9524020aaa | |||
| 194bb5b393 | |||
| 779ec9df3b | |||
| 82ed175a5c | |||
| 68f96129fe | |||
| c482324a97 | |||
| 800c70c401 | |||
| f26c543977 | |||
| 23e31749e9 | |||
| ad91b6f6b7 | |||
| 2c333b51d2 | |||
| 80f8ee1b09 | |||
| 1498a6e68d | |||
| 1fc313505a | |||
| 435ac82c18 | |||
| 7ec267a7c0 | |||
| 81293255b5 | |||
| 4fe225a302 | |||
| 3ef91b0159 | |||
| e02a006b60 | |||
| 23eb6b29a5 | |||
| afe48e7034 | |||
| bd1cdfdb97 | |||
| a783177420 | |||
| 9d42f849c5 | |||
| 566de06fd1 | |||
| 474ad99396 | |||
| b53847d1b5 | |||
| d827c1bf5d | |||
| 886daa5880 | |||
| cc72092b05 | |||
| c6f74e74c4 | |||
| 328980628a | |||
| 886e9b9f4f | |||
| 26d2ae416e | |||
| 62c4c82fcc | |||
| 11cc19fe3e | |||
| d1d045a70e | |||
| 54c790a63c | |||
| f1f5c1036a | |||
| 77d5436b15 | |||
| 678c60dd14 | |||
| d40d231584 | |||
| 00ddff7e46 | |||
| 5725af0f6b | |||
| 87248e7e67 | |||
| 712cfc9ac4 | |||
| 1d8befde8e | |||
| fb036cda37 | |||
| 136e2730de | |||
| ae47d92016 | |||
| b80ed0021b | |||
| 1d11879142 | |||
| a122b27b1f | |||
| cbba724ba1 | |||
| 2c51571ea4 | |||
| e1d774ce49 | |||
| b9e3973c76 | |||
| c878093c5f | |||
| 7210441878 | |||
| 36eeee5641 | |||
| 8d2ffba3e1 | |||
| 766d4e0c7a | |||
| a99f552e7c | |||
| 540a41a583 | |||
| 8cb7d2b2fe | |||
| 293f25d579 | |||
| 64763e76af | |||
| 69b7e7f998 | |||
| 5579bce5d9 | |||
| 0dd5e2ac10 | |||
| 155ed6bcf9 | |||
| 4e2f62bc73 | |||
| bf36a185a2 | |||
| 4c4c54c536 | |||
| e79e6944df | |||
| f6079e3078 | |||
| 31b49a71fb | |||
| 83260d5037 | |||
| 648da83aa1 | |||
| adf1db92c7 | |||
| 662ee48a64 | |||
| 446b521898 | |||
| d6db731149 | |||
| 9106a11be8 | |||
| 7bc58a757e | |||
| 27b5556e4b | |||
| b39b4197ed | |||
| a99647d4c7 | |||
| 10a6bafb2f | |||
| b4f7688b82 | |||
| 08e6b882f3 | |||
| 4adc174674 | |||
| 01b1f42bac | |||
| be4c7f80cb | |||
| 790363adb5 | |||
| 09b96a4a86 | |||
| 6ffa656ad4 | |||
| 3f2df68ac5 | |||
| a7f2ecefe5 | |||
| 46c2260d0f | |||
| 052dcf8c6e | |||
| cd5863fcde | |||
| 90de571457 | |||
| d9d33c2d65 | |||
| 09962696b7 | |||
| d143cbb461 | |||
| db7f7abfc4 | |||
| 6ba92d3a7a | |||
| 36a1e0dfae | |||
| 47f7e71ae9 | |||
| c2008f1f9c | |||
| 3c32a66064 | |||
| 41026fbd93 | |||
| d49750aa02 | |||
| 54f309030e | |||
| 093c25fce4 | |||
| a777dc8236 | |||
| 4044e4e5a6 | |||
| 036b4e9456 | |||
| 4074530a71 | |||
| 31eedd7e7e | |||
| df2dfd21e3 | |||
| 00b0f71bf4 | |||
| 1450a5acd3 | |||
| 2a138ea0b6 | |||
| 2534ff37de | |||
| d61cb1106d | |||
| d5f0c6aceb | |||
| 2bab3f2f8f | |||
| fdd0bfea08 | |||
| 48c225366f | |||
| 0d88253334 | |||
| d7b17aa383 | |||
| ba131ab94a | |||
| 648d9c5164 | |||
| 60487daf6f | |||
| e0c43836b3 | |||
| 719a403b1d | |||
| 6f88c3d31a | |||
| 7114798e69 | |||
| 65384435a3 | |||
| 4236ff62b1 | |||
| 277be9bcd6 | |||
| 9493e2d3e7 | |||
| 16b15162d5 | |||
| 9854b93d02 | |||
| d02ab1e7a5 | |||
| e0c8ca677f | |||
| 2cea44f790 | |||
| fb783034bc | |||
| 40a6f49b29 | |||
| dea0ac99c3 | |||
| 24cf8e73c6 | |||
| c301a921e6 | |||
| 22d7825ba3 | |||
| 526bfb64e5 | |||
| 55cbf6e20b | |||
| 0b86ffb227 | |||
| e28596c825 | |||
| 716676b87d | |||
| 5ca0265c37 | |||
| c7a0873ca8 | |||
| b1d51cdbbe | |||
| 5a7151bc63 | |||
| 49d861919f | |||
| 3f20c4239f | |||
| 038f306661 | |||
| 0575f3c9cf | |||
| e37307acb3 | |||
| 4b32b41183 | |||
| c8f8a6f65b | |||
| 0c93275e88 | |||
| c44ab27c7e | |||
| 3f09a7b57b | |||
| 0b4d5b2f89 | |||
| 45824b46fe | |||
| e78f3142e3 | |||
| 4166149841 | |||
| 45131dabc0 | |||
| b235644575 | |||
| 377d8beac3 | |||
| 16bff52575 | |||
| 49fb7eba60 | |||
| 00b46d7161 | |||
| 5bea9d3a2b | |||
| a9dcd4b87e | |||
| 5c84581978 | |||
| ab38a58e39 | |||
| d430112a94 | |||
| 0cf59f874d | |||
| bf028ed0f6 | |||
| 1ecc41dea9 | |||
| 648e15a016 | |||
| 1729edc1d2 | |||
| bbcc03f832 | |||
| 6827229c83 | |||
| 60291993b6 | |||
| 118512ebb2 | |||
| ae9eaccd29 | |||
| 3025420aea | |||
| 3c4ad43e71 | |||
| 9e02b6c666 | |||
| fe435c13d3 | |||
| 3b5145880c | |||
| d965ff5031 | |||
| 22a89deb8b | |||
| c9ba61a4b0 | |||
| 0cdf2784cc | |||
| 76a948a45d | |||
| fd39a89957 | |||
| 0a5065707c | |||
| 072e647c7b | |||
| 148db03a9a | |||
| cff5ad23fc | |||
| 3e174b7397 | |||
| e9bf51f3f7 | |||
| 28ab1bea9c | |||
| 923cc4ebb0 | |||
| e24a0e3c40 | |||
| a857cc9d03 | |||
| 8746b544b6 | |||
| ccd5baedf1 | |||
| 9621e89cd7 | |||
| 3844c9881c | |||
| 6999694f89 | |||
| 54acd931da | |||
| 9bc9e219b5 | |||
| e8b2765a71 | |||
| d4bc880018 | |||
| c1a2742617 | |||
| ebaeb2f70a | |||
| 0366e36edb | |||
| a0f52f01bb | |||
| bee4c55446 | |||
| 1a6b26e56b | |||
| 1047d089d5 | |||
| 2d6096cfda | |||
| 7cbd9402d0 | |||
| 0396337994 | |||
| 6fbc0829ae | |||
| 4f41cbc9ce | |||
| d1e6d75d70 | |||
| 067f2439ca | |||
| 2d2edbd7be | |||
| f5f457aa6f | |||
| aabbafb749 | |||
| e72e37f713 | |||
| f884893b18 | |||
| c74c0e2250 | |||
| 5f4d2ec891 | |||
| 33b0ab3ed3 | |||
| 2e158a1df8 | |||
| 6a89f18580 | |||
| b3e757dcdc | |||
| 9c675a14ab | |||
| cc99050964 | |||
| f65b1f1c14 | |||
| 1ad2c47444 | |||
| ebef2f2bd1 | |||
| afa23f03c7 | |||
| 9d7b6c6341 | |||
| 4199f7bb23 | |||
| 140d488239 | |||
| 22e9314e18 | |||
| c8a3b3ba31 | |||
| 8b7e4014ae | |||
| 13b94e7ba1 | |||
| ab2a8d5fa9 | |||
| a01d8206e1 | |||
| 61570a2563 | |||
| 822c0e0670 | |||
| c5b5ab3815 | |||
| b28e9a5d54 | |||
| e5e61d189c | |||
| 8b35d07fc9 | |||
| 2f462d391e | |||
| 09d3b90169 | |||
| a329db3036 | |||
| 711fa742be | |||
| d9c549bef5 | |||
| e0d1db0363 | |||
| 1723a4152c | |||
| c212b2987c | |||
| 488a5b201e | |||
| 4770297cd0 | |||
| 3297df580a | |||
| 936b914cbc | |||
| ad51dcf16f | |||
| c8f330e2c8 | |||
| 6467693df9 | |||
| 07716fd301 | |||
| b30cd3bb8e | |||
| a4a8389add | |||
| 7f2fca3a79 | |||
| cfea8a2712 | |||
| 3e59f9a91e | |||
| 69edba036e | |||
| ca1dc6ad7d | |||
| dcd8d3b650 | |||
| 1bc668f72f | |||
| 52d019a321 | |||
| 02c3d35d78 | |||
| 6328453d38 | |||
| 595675df20 | |||
| 4489bca037 | |||
| 333b62b884 | |||
| f06b07a7c4 | |||
| b52a2e4a5b | |||
| 26c3a87a73 | |||
| 73eef4815b | |||
| d85737b1a7 | |||
| ed05bbe2e3 | |||
| f0c492abea | |||
| 2cff04943f | |||
| 1df7b821e8 | |||
| 5fb842761d | |||
| 3cddb99c20 | |||
| e27426dc16 | |||
| 4cf650fb98 | |||
| 3857cda4e5 | |||
| 99ebf96cb0 | |||
| 311af36632 | |||
| cf46a2cfc1 | |||
| 002a504418 | |||
| ff9ff218bb | |||
| 5f838815ab | |||
| c7d606247f | |||
| 546e8a3801 | |||
| f53604f49c | |||
| 84c62b33a4 | |||
| ddc52c06ae | |||
| d02a3d7d64 | |||
| 21a0efa8ac | |||
| 4d7a3395ba | |||
| 78fe4ebf98 | |||
| c596a18b3a | |||
| f3b547f93c | |||
| ef53a3b269 | |||
| 4f364f56d0 | |||
| 4e77ff7ab1 | |||
| 81ad01891a | |||
| 03d303b2bb | |||
| 52bca977c3 | |||
| f9cac45996 | |||
| 04dbcef2cf | |||
| 66e00d5136 | |||
| 11d539042c | |||
| 104e31028b | |||
| fa22c3563d | |||
| 2cd4e5cf27 | |||
| d9744a696e | |||
| 813bd2e0fa | |||
| 2d42d1ce07 | |||
| 9001af38cd | |||
| 67a56a369f | |||
| f4da9c8cb2 | |||
| 963788af33 | |||
| d0e0e59762 | |||
| caf41c99de | |||
| 9185dc0b62 | |||
| 83990c6d5f | |||
| f53ca31b22 | |||
| 44ea82771b | |||
| 984d8f0f31 | |||
| 7570c3ce34 | |||
| d24a535cd6 | |||
| f2d36d589b | |||
| 2b31656661 | |||
| 6e8eecda8b | |||
| 9ed01ede2d | |||
| 5ed2503491 | |||
| 2a34d64f00 | |||
| fe4bd3d495 | |||
| 7ad5cbd28b | |||
| 775369345c | |||
| 17fe80cf85 | |||
| a3428d33ae | |||
| 4a1561ec55 | |||
| 405399682f | |||
| 01e6c5a8fb | |||
| 048b8ba09c | |||
| b451c82943 | |||
| 9d7c71fb26 | |||
| 07c5a8a4b6 | |||
| 15f923a639 | |||
| 4c55551e12 | |||
| 81d5b23d80 | |||
| fa7c76b75b | |||
| 1a7f219158 | |||
| 4b3bde01e4 | |||
| a7fdfbf732 | |||
| c0994b49e5 | |||
| 03fc351a35 | |||
| 24722f0a27 | |||
| b7293e7cb0 | |||
| b5104a7bda | |||
| 78b7bfac70 | |||
| 65a1b97093 | |||
| 2e6e1adcf3 | |||
| 7da0da66f1 | |||
| 4038221d8c | |||
| 5c807fa655 | |||
| aa9e1e7305 | |||
| 721b01a294 | |||
| aa08e3c183 | |||
| 63fb78cc9e | |||
| a39adc593b | |||
| afc6c44bc6 | |||
| 6f26cf87b1 | |||
| 6e9d86a6ca | |||
| e2caf81e4b | |||
| 823fb17f60 | |||
| a30e7438ff | |||
| 269d2178fb | |||
| 6564db437a | |||
| 732f1d5eb6 | |||
| 9033fb6a5d | |||
| b028532db3 | |||
| 80dda2e1f9 | |||
| 4d3595640a | |||
| 0704590238 | |||
| 7c48dc1ff5 | |||
| 68003b2e2f | |||
| f6fbba5638 | |||
| 4bfe7218f7 | |||
| 5dbb6c3a27 | |||
| 0be056adce | |||
| d51f7a0fe7 | |||
| a7b5ea5562 | |||
| d833727074 | |||
| 149e746e3a | |||
| 1c5b0e4667 | |||
| 8508607c87 | |||
| 0862b01770 | |||
| 72ac20e574 | |||
| 69f7bb3db9 | |||
| dc7368e4af | |||
| 79c7e5dcb4 | |||
| 56ac0a5057 | |||
| 183e7dbf8a | |||
| e3097c5578 | |||
| aebc9293ad | |||
| 4b3dcbb6f4 | |||
| 3424d6481b | |||
| 760cec9d1e | |||
| 0196c866f6 | |||
| 13ee74945b | |||
| c6266ff624 | |||
| 9a15433fbf | |||
| db2bd9d08f | |||
| f5ed347734 | |||
| 483f6dd3fc | |||
| 0e5837f79a | |||
| ab1a2373b9 | |||
| aa2b94b7f5 | |||
| 55a8207932 | |||
| 484feed314 | |||
| 04a42dc627 | |||
| 4e9003b061 | |||
| a59a2d7cd3 | |||
| 8cb7b465da | |||
| 0279b20bb7 | |||
| a140cdbedb | |||
| e7db8f2404 | |||
| 70dfeeba91 | |||
| a860d29636 | |||
| a7811429a8 | |||
| 75be38c38b | |||
| 75de6f259d | |||
| e6a6e862db | |||
| 2d1544edf4 | |||
| 0522b539c4 | |||
| ac20d0c7d4 | |||
| 263622cef8 | |||
| 461bd3d488 | |||
| 7baf5ce327 | |||
| 67c43e803b | |||
| fb9bd077a8 | |||
| 6e808b8340 | |||
| 996509531c | |||
| 4e7d6800cd | |||
| 0c9d4bf338 | |||
| 48641d46a0 | |||
| 84159821e9 | |||
| 823199be2e | |||
| 9eb5601349 | |||
| a7604353c3 | |||
| cfd264e4dc | |||
| e7d0739c8b | |||
| e5afc1d937 | |||
| a9a15600b2 | |||
| 086b2d411a | |||
| c61a13f62e | |||
| 0f25af1ab7 | |||
| 21f1c40408 | |||
| f8e479b4f9 | |||
| 775842dfc5 | |||
| a7d436a894 | |||
| 47bc37e806 | |||
| 080a9ebac4 | |||
| cac9589b81 | |||
| 34bd2cd6a7 | |||
| 8cc8d804bc | |||
| 59124678bf | |||
| b9fd52c6c1 | |||
| 458f5b2d0f | |||
| 7139df0265 | |||
| c6490cb3fb | |||
| b7d37eb169 | |||
| 1d26d1a529 | |||
| 5294a53e1b | |||
| 40d8227504 | |||
| a734bcf483 | |||
| 23e37b8eb7 | |||
| 627c0d949c | |||
| 096f9e46f4 | |||
| 7910556ace | |||
| 2bfcc32b6b | |||
| 0af0f8bc53 | |||
| 46c212f4a1 | |||
| 1e61415c9e | |||
| aa4a773095 | |||
| c8b8bf43f7 | |||
| e50848b52e | |||
| 9e8f7a1cc5 | |||
| 39f3a4afa7 | |||
| 4831f3649a | |||
| a9a524d04a | |||
| b773813f10 | |||
| 00bfae3b62 | |||
| 4dcb49bb34 | |||
| fd25eaadfd | |||
| 2d5b70c734 | |||
| 1ee3caf640 | |||
| e6e11794b8 | |||
| 79eabe5ed2 | |||
| b13e67d491 | |||
| 16a8f91822 | |||
| 82f036f66f | |||
| 3d2b5ebb79 | |||
| 302de15c75 | |||
| 18ce96c84b | |||
| e017279423 | |||
| dbc252a5d6 | |||
| cb0a9dad32 | |||
| 1f6f01a37f | |||
| eaa982aae9 | |||
| 07308b192c | |||
| 27105a3222 | |||
| d915b5e688 | |||
| 089980a6ab | |||
| 49992be60a | |||
| 7414b6ce8e | |||
| 591f3c7b36 | |||
| de2df5f6cf | |||
| 4a40dfd361 | |||
| b760bf5066 | |||
| 8e85167cb6 | |||
| af27ea080f | |||
| 65de5d0060 | |||
| a9b816c548 | |||
| 075c576116 | |||
| f9986f5ac5 | |||
| a9a28aa71b | |||
| c6bbd5daa3 | |||
| c89c3c27ad | |||
| 3205afbcdb | |||
| 61003b509a | |||
| ce3f25be7b | |||
| a8fd1bdada | |||
| 4426476a15 | |||
| 7d775a38d1 | |||
| a7d3720050 | |||
| 596ea40bc0 | |||
| f8f194e19b | |||
| 170111422b | |||
| 81969fc91b | |||
| f0366a3550 | |||
| d676e9bb38 | |||
| 188aac48eb | |||
| 24be0d8195 | |||
| fbc5cd5967 | |||
| d11329b2c9 | |||
| 3a74dbf04e | |||
| 299e187380 | |||
| 0f29b1801d | |||
| f8162d442a | |||
| cd09bfa7e8 | |||
| 1bfbf09891 | |||
| 5523388ad4 | |||
| a3cc0bd13f | |||
| 70ada6669d | |||
| 4d76229527 |
@@ -16,41 +16,48 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
with_resource_file: ["true", "false"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install libraries (Linux)
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: sudo apt-get install -y libevent-dev
|
||||
run: sudo apt-get install -y cmake libasio-dev
|
||||
|
||||
- name: Install libraries (macOS)
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
run: brew install libevent
|
||||
run: |
|
||||
brew install asio libiconv
|
||||
|
||||
cat << EOF > nproc
|
||||
#!/bin/sh
|
||||
sysctl -n hw.logicalcpu
|
||||
EOF
|
||||
chmod a+x nproc
|
||||
sudo cp nproc /usr/local/bin/nproc
|
||||
rm -f nproc
|
||||
|
||||
- name: Install phosg
|
||||
run: |
|
||||
git clone https://github.com/fuzziqersoftware/phosg.git
|
||||
cd phosg
|
||||
cmake .
|
||||
make
|
||||
make -j $(nproc)
|
||||
sudo make install
|
||||
|
||||
- name: Install resource_file
|
||||
if: ${{ matrix.with_resource_file == 'true' }}
|
||||
run: |
|
||||
git clone https://github.com/fuzziqersoftware/resource_dasm.git
|
||||
cd resource_dasm
|
||||
cmake .
|
||||
make
|
||||
make -j $(nproc)
|
||||
sudo make install
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j $(nproc)
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Docker
|
||||
|
||||
on:
|
||||
# After build passes with tests
|
||||
workflow_run:
|
||||
workflows: [CMake]
|
||||
types: [completed]
|
||||
branches:
|
||||
- master
|
||||
|
||||
push:
|
||||
tags:
|
||||
- 'v**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=sha
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
+26
-11
@@ -2,43 +2,58 @@
|
||||
.DS_Store
|
||||
|
||||
# Build products
|
||||
src/Revision.cc
|
||||
newserv
|
||||
newserv.exe
|
||||
src/Revision.cc
|
||||
|
||||
# CMake files
|
||||
build
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CTestTestFile.cmake
|
||||
CTestTestfile.cmake
|
||||
CTestTestFile.cmake
|
||||
install_manifest.txt
|
||||
Makefile
|
||||
Testing
|
||||
|
||||
# Files modified by the user and/or server that don't have defaults
|
||||
system/config.json
|
||||
system/ep3/battle-records/*.mzr
|
||||
system/ep3/battle-records/*.mzrd
|
||||
system/ep3/tournament-state.json
|
||||
system/licenses.nsi
|
||||
system/licenses/*.json
|
||||
system/patch-bb/.metadata-cache.json
|
||||
system/patch-pc/.metadata-cache.json
|
||||
system/players/*.nsa
|
||||
system/players/*.nsc
|
||||
system/players/*.psobank
|
||||
system/players/*.psocard
|
||||
system/players/*.psochar
|
||||
system/players/*.psosys
|
||||
system/players/*.psocard
|
||||
system/players/*.nsc
|
||||
system/players/*.nsa
|
||||
system/teams/*.json
|
||||
system/teams/*.bmp
|
||||
system/patch-pc/.metadata-cache.json
|
||||
system/patch-bb/.metadata-cache.json
|
||||
system/teams/*.json
|
||||
|
||||
# Files fuzziqersoftware uses that don't make sense to be committed to the main
|
||||
# repository
|
||||
*.dec
|
||||
*.WIP-s
|
||||
files
|
||||
make_release.py
|
||||
notes-private
|
||||
old-khyller
|
||||
old-newserv
|
||||
release
|
||||
release.zip
|
||||
system/patch-bb/data
|
||||
system/patch-bb/psobb.pat
|
||||
all-quests
|
||||
system/dol
|
||||
system/patch-bb/data
|
||||
system/client-functions/Debug-Private
|
||||
system/config.2.json
|
||||
system/ep3/banners
|
||||
system/ep3/cardtex
|
||||
system/ep3/cardtex-trial
|
||||
system/players
|
||||
system/quests/includes
|
||||
system/quests/private
|
||||
.vscode
|
||||
|
||||
+36
-41
@@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0110 NEW)
|
||||
|
||||
|
||||
|
||||
@@ -14,29 +15,19 @@ else()
|
||||
add_compile_options(-Wall -Wextra -Werror -Wno-address-of-packed-member)
|
||||
endif()
|
||||
|
||||
set(LOCAL_INCLUDE_DIR "/usr/local/include")
|
||||
set(LOCAL_LIB_DIR "/usr/local/lib")
|
||||
list(APPEND CMAKE_PREFIX_PATH ${LOCAL_LIB_DIR})
|
||||
include_directories(${LOCAL_INCLUDE_DIR})
|
||||
link_directories(${LOCAL_LIB_DIR})
|
||||
|
||||
|
||||
|
||||
# Library search
|
||||
|
||||
find_path (LIBEVENT_INCLUDE_DIR NAMES event.h)
|
||||
find_library (LIBEVENT_LIBRARY NAMES event)
|
||||
find_library (LIBEVENT_CORE NAMES event_core)
|
||||
find_library (LIBEVENT_PTHREADS NAMES event_pthreads)
|
||||
set (LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
|
||||
set (LIBEVENT_LIBRARIES
|
||||
${LIBEVENT_LIBRARY}
|
||||
${LIBEVENT_CORE}
|
||||
${LIBEVENT_PTHREADS})
|
||||
|
||||
find_path(ASIO_INCLUDE_DIR NAMES asio.hpp HINTS "${WINDOWS_ENV}/include" REQUIRED)
|
||||
if(WIN32)
|
||||
find_path(Iconv_INCLUDE_DIRS NAMES iconv.h HINTS "${WINDOWS_ENV}/include" REQUIRED)
|
||||
find_library(Iconv_LIBRARIES NAMES iconv HINTS "${WINDOWS_ENV}/lib" REQUIRED)
|
||||
else()
|
||||
find_package(Iconv REQUIRED)
|
||||
endif()
|
||||
find_package(phosg REQUIRED)
|
||||
find_package(Iconv REQUIRED)
|
||||
find_package(resource_file QUIET)
|
||||
find_package(resource_file REQUIRED)
|
||||
|
||||
|
||||
|
||||
@@ -59,10 +50,12 @@ add_custom_target(
|
||||
set(SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Revision.cc
|
||||
src/Account.cc
|
||||
src/AddressTranslator.cc
|
||||
src/AFSArchive.cc
|
||||
src/AsyncHTTPServer.cc
|
||||
src/AsyncUtils.cc
|
||||
src/BattleParamsIndex.cc
|
||||
src/BMLArchive.cc
|
||||
src/CatSession.cc
|
||||
src/Channel.cc
|
||||
src/ChatCommands.cc
|
||||
src/ChoiceSearch.cc
|
||||
@@ -71,6 +64,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
|
||||
@@ -84,12 +78,12 @@ set(SOURCES
|
||||
src/Episode3/RulerServer.cc
|
||||
src/Episode3/Server.cc
|
||||
src/Episode3/Tournament.cc
|
||||
src/EventUtils.cc
|
||||
src/FileContentsCache.cc
|
||||
src/FunctionCompiler.cc
|
||||
src/GameServer.cc
|
||||
src/GSLArchive.cc
|
||||
src/GVMEncoder.cc
|
||||
src/HTTPServer.cc
|
||||
src/ImageEncoder.cc
|
||||
src/IntegralExpression.cc
|
||||
src/IPFrameInfo.cc
|
||||
src/IPStackSimulator.cc
|
||||
@@ -99,34 +93,38 @@ set(SOURCES
|
||||
src/ItemNameIndex.cc
|
||||
src/ItemParameterTable.cc
|
||||
src/Items.cc
|
||||
src/ItemTranslationTable.cc
|
||||
src/LevelTable.cc
|
||||
src/Lobby.cc
|
||||
src/Loggers.cc
|
||||
src/MagEvolutionTable.cc
|
||||
src/Main.cc
|
||||
src/Map.cc
|
||||
src/Menu.cc
|
||||
src/NetworkAddresses.cc
|
||||
src/PatchDownloadSession.cc
|
||||
src/PatchFileIndex.cc
|
||||
src/PatchServer.cc
|
||||
src/PlayerFilesManager.cc
|
||||
src/PlayerInventory.cc
|
||||
src/PlayerSubordinates.cc
|
||||
src/PPKArchive.cc
|
||||
src/ProxyCommands.cc
|
||||
src/ProxyServer.cc
|
||||
src/ProxySession.cc
|
||||
src/PSOEncryption.cc
|
||||
src/PSOGCObjectGraph.cc
|
||||
src/PSOProtocol.cc
|
||||
src/Quest.cc
|
||||
src/QuestMetadata.cc
|
||||
src/QuestScript.cc
|
||||
src/RareItemSet.cc
|
||||
src/ReceiveCommands.cc
|
||||
src/ReceiveSubcommands.cc
|
||||
src/ReplaySession.cc
|
||||
src/Revision.cc
|
||||
src/SaveFileFormats.cc
|
||||
src/SendCommands.cc
|
||||
src/Server.cc
|
||||
src/ServerShell.cc
|
||||
src/ServerState.cc
|
||||
src/ShellCommands.cc
|
||||
src/SignalWatcher.cc
|
||||
src/StaticGameData.cc
|
||||
src/TeamIndex.cc
|
||||
src/Text.cc
|
||||
@@ -135,26 +133,20 @@ set(SOURCES
|
||||
src/WordSelectTable.cc
|
||||
)
|
||||
|
||||
if(resource_file_FOUND)
|
||||
set(SOURCES ${SOURCES} src/AddressTranslator.cc)
|
||||
endif()
|
||||
|
||||
add_executable(newserv ${SOURCES})
|
||||
target_include_directories(newserv PUBLIC ${LIBEVENT_INCLUDE_DIR} ${Iconv_INCLUDE_DIRS})
|
||||
target_link_libraries(newserv phosg ${LIBEVENT_LIBRARIES} ${Iconv_LIBRARIES} pthread)
|
||||
target_include_directories(newserv PUBLIC ${ASIO_INCLUDE_DIR} ${Iconv_INCLUDE_DIRS})
|
||||
target_link_libraries(newserv phosg::phosg ${Iconv_LIBRARIES} resource_file::resource_file)
|
||||
if (WIN32)
|
||||
target_compile_definitions(newserv PUBLIC WINVER=0x0A00 _WIN32_WINNT=0x0A00)
|
||||
target_compile_options(newserv PRIVATE -Wa,-mbig-obj -Wno-mismatched-new-delete)
|
||||
target_link_options(newserv PRIVATE -static -static-libgcc -static-libstdc++)
|
||||
target_link_libraries(newserv ws2_32 mswsock bcrypt iphlpapi)
|
||||
endif()
|
||||
add_dependencies(newserv newserv-Revision-cc)
|
||||
|
||||
# target_compile_options(newserv PRIVATE -fsanitize=address)
|
||||
# target_link_options(newserv PRIVATE -fsanitize=address)
|
||||
|
||||
if(resource_file_FOUND)
|
||||
target_compile_definitions(newserv PUBLIC HAVE_RESOURCE_FILE)
|
||||
target_link_libraries(newserv resource_file)
|
||||
message(STATUS "libresource_file found; enabling patch support")
|
||||
else()
|
||||
message(WARNING "libresource_file not found; disabling patch support")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Test configuration
|
||||
@@ -162,6 +154,7 @@ endif()
|
||||
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(
|
||||
@@ -179,6 +172,8 @@ foreach(ScriptTestCase IN ITEMS ${ScriptTestCases})
|
||||
COMMAND ${ScriptTestCase} ${CMAKE_BINARY_DIR}/newserv)
|
||||
endforeach()
|
||||
|
||||
|
||||
|
||||
# Installation configuration
|
||||
|
||||
install(TARGETS newserv DESTINATION bin)
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG BASE_IMAGE=ubuntu:24.04
|
||||
FROM ${BASE_IMAGE} AS builder
|
||||
|
||||
RUN apt update && apt install -y --no-install-recommends \
|
||||
python3 \
|
||||
git \
|
||||
ca-certificates \
|
||||
sudo \
|
||||
make \
|
||||
cmake \
|
||||
g++ \
|
||||
libasio-dev \
|
||||
zlib1g-dev
|
||||
|
||||
# ---
|
||||
|
||||
FROM builder AS deps
|
||||
|
||||
ARG PHOSG_TARGET=master
|
||||
ARG RESOURCE_DASM_TARGET=master
|
||||
ARG BUILD_RESOURCE_DASM=true
|
||||
|
||||
RUN git clone --depth 1 -b ${PHOSG_TARGET} https://github.com/fuzziqersoftware/phosg.git && \
|
||||
cd phosg && \
|
||||
cmake . && \
|
||||
make -j$(nproc) && \
|
||||
sudo make install
|
||||
|
||||
RUN \
|
||||
if [ "$BUILD_RESOURCE_DASM" = "true" ] ; then \
|
||||
git clone --depth 1 -b ${RESOURCE_DASM_TARGET} https://github.com/fuzziqersoftware/resource_dasm.git && \
|
||||
cd resource_dasm && \
|
||||
cmake . && \
|
||||
make -j$(nproc) && \
|
||||
sudo make install \
|
||||
; fi
|
||||
|
||||
# ---
|
||||
|
||||
FROM builder AS newserv
|
||||
|
||||
ARG BUILD_TYPE=Release
|
||||
ARG BUILD_STRIP=true
|
||||
|
||||
WORKDIR /usr/src/newserv
|
||||
COPY . .
|
||||
COPY --from=deps /usr/local /usr/local
|
||||
|
||||
RUN cmake -B $PWD/build -DCMAKE_BUILD_TYPE=${BUILD_TYPE} && \
|
||||
cmake --build $PWD/build --config ${BUILD_TYPE} -j $(nproc) && \
|
||||
sudo make -C build install
|
||||
|
||||
RUN \
|
||||
if [ "$BUILD_STRIP" = "true" ] ; then \
|
||||
strip /usr/local/lib/*.a && \
|
||||
strip /usr/local/bin/* \
|
||||
; fi
|
||||
|
||||
# ---
|
||||
|
||||
FROM ${BASE_IMAGE} AS data
|
||||
|
||||
WORKDIR /newserv
|
||||
COPY system/ ./system
|
||||
RUN cp -f system/config.example.json system/config.json && \
|
||||
sed -i 's/"ExternalAddress": "[^"]*"/"ExternalAddress": "0.0.0.0"/' system/config.json
|
||||
|
||||
# ---
|
||||
|
||||
FROM ${BASE_IMAGE} AS final
|
||||
|
||||
RUN apt update && apt install -y --no-install-recommends \
|
||||
libasio-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
||||
|
||||
WORKDIR /newserv
|
||||
COPY --from=data /newserv .
|
||||
COPY --from=newserv /usr/local /usr/local
|
||||
|
||||
USER root
|
||||
VOLUME /newserv/system
|
||||
|
||||
# does not allow receiving any signal at the moment, so force kill the app
|
||||
STOPSIGNAL SIGKILL
|
||||
CMD ["newserv"]
|
||||
@@ -1,645 +1,33 @@
|
||||
# newserv <img align="right" src="static/s-newserv.png" />
|
||||
# PSO Peeps newserv
|
||||
|
||||
newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO).
|
||||
This is the PSO Peeps maintained version of [newserv](https://github.com/fuzziqersoftware/newserv), a game server, proxy, and reverse-engineering tool for Phantasy Star Online.
|
||||
|
||||
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.
|
||||
The original project was created by fuzziqersoftware and contains years of reverse-engineering, documentation, and implementation work for PSO. This repository keeps that work as the foundation while carrying local changes used by PSO Peeps.
|
||||
|
||||
Feel free to submit GitHub issues if you find bugs or have feature requests. I'd like to make the server as stable and complete as possible, but I can't promise that I'll respond to issues in a timely manner, because this is a personal project undertaken primarily for the fun of reverse-engineering. If you want to contribute to newserv yourself, pull requests are welcome as well.
|
||||
For the original upstream project, see:
|
||||
|
||||
See TODO.md for a list of known issues and future work I've curated, or go to the GitHub issue tracker for issues and requests submitted by the community.
|
||||
https://github.com/fuzziqersoftware/newserv
|
||||
|
||||
**Table of contents**
|
||||
* Background
|
||||
* [History](#history)
|
||||
* [Other server projects](#other-server-projects)
|
||||
* [Using newserv in other projects](#using-newserv-in-other-projects)
|
||||
* [Compatibility](#compatibility)
|
||||
* Setup
|
||||
* [Server setup](#server-setup)
|
||||
* [Client patch directories for PC and BB](#client-patch-directories)
|
||||
* [How to connect](#how-to-connect)
|
||||
* Features and configuration
|
||||
* [User accounts](#user-accounts)
|
||||
* [Installing quests](#installing-quests)
|
||||
* [Item tables and drop modes](#item-tables-and-drop-modes)
|
||||
* [Cross-version play](#cross-version-play)
|
||||
* [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)
|
||||
* [Non-server features](#non-server-features)
|
||||
## About this repository
|
||||
|
||||
# History
|
||||
This repository is used for PSO Peeps server development and deployment. Changes here may include server configuration support, compatibility fixes, event behavior, gameplay experiments, operational tooling, and other changes specific to PSO Peeps.
|
||||
|
||||
The history of this project essentially mirrors my development as a software engineer from the beginning of my hobby until now. If you don't care about the story, skip to the "Compatibility" or "Setup" sections below.
|
||||
Some changes may not be appropriate for upstream newserv or for general newserv deployments.
|
||||
|
||||
I originally purchased PSO GC when I heard about PSUL, and wanted to play around with running homebrew on my GameCube. This pathway eventually led to [GCARS-CS](https://github.com/fuzziqersoftware/gcars-cs), but that's another story.
|
||||
## Original README
|
||||
|
||||
<img align="left" src="static/s-khyps.png" /> After playing PSO for a while, both offline and online, I wrote a proxy called Khyps sometime in 2003. This was back in the days of the official Sega servers, where vulnerabilities weren't addressed in a timely manner or at all. It was common for malicious players using their own proxies or Action Replay codes (a story for another time) to send invalid commands that the servers would blindly forward, and cause the receiving clients to crash. These crashes were more than simply inconvenient; they could also corrupt your save data, destroying the hours of work you may have put into hunting items and leveling up your character.
|
||||
A copy of the upstream README is preserved here:
|
||||
|
||||
For a while it was essentially necessary to use a proxy to go online at all, so the proxy could block these invalid commands. Khyps was designed primarily with this function in mind, though it also implemented some convenient cheats, like the ability to give yourself or other players infinite HP and allow you to teleport to different places without using an in-game teleporter.
|
||||
[docs/upstream-README.md](docs/upstream-README.md)
|
||||
|
||||
<img align="left" src="static/s-khyller.png" /> After Khyps I took on the larger challenge of writing a server, which resulted in Khyller sometime in 2005. This was the first server of any type I had ever written. This project eventually evolved into a full-featured environment supporting all versions of the game that I had access to - at the time, PC, GC, and BB. (However, I suspect from reading the ancient source files that Khyller's BB support was very buggy.) As Khyller evolved, the code became increasingly cumbersome, littered with debugging filth that I never cleaned up and odd coding patterns I had picked up over the years. My understanding of the C++ language was woefully incomplete as well (as opposed to now, when it is still incomplete but not woefully so), which resulted in Khyller being essentially a C project that had a couple of classes in it.
|
||||
That document contains the original newserv history, setup notes, compatibility information, connection instructions, feature documentation, and technical reference material.
|
||||
|
||||
<img align="left" src="static/s-aeon.png" /> Sometime in 2006 or 2007, I abandoned Khyller and rebuilt the entire thing from scratch, resulting in Aeon. Aeon was substantially cleaner in code than Khyller but still fairly hard to work with, and it lacked a few of the more arcane features I had originally written (for example, the ability to convert any quest into a download quest). In addition, the code still had some stability problems... it turns out that Aeon's concurrency primitives were simply incorrect. I had derived the concept of a mutex myself, before taking any real computer engineering classes, but had implemented it incorrectly. I made the race window as small as possible, but Aeon would still randomly crash after running seemingly fine for a few days.
|
||||
## Building
|
||||
|
||||
At the time of its inception, Aeon was also called newserv, and you may find some beta releases floating around the Internet with filenames like `newserv-b3.zip`. I had released betas 1, 2, and 3 before I released the entire source of beta 5 and stopped working on the project when I went to college. This was around the time when I switched from writing software primarily on Windows to primarily on macOS and Linux, so Aeon beta 5 was the last server I wrote that specifically targeted Windows. (newserv, which you're looking at now, is a bit tedious to compile on Windows but does work.)
|
||||
Build instructions are currently the same as upstream unless noted otherwise. See the original README for dependency and build details.
|
||||
|
||||
<img align="left" src="static/s-newserv.png" /> After a long hiatus from PSO and much professional and personal development in my technical abilities, I was reminiscing sometime in October 2018 by reading my old code archives. Somehow inspired when I came across Aeon, I spent a weekend and a couple more evenings rewriting the entire project again, cleaning up ancient patterns I had used eleven years ago, replacing entire modules with simple STL containers, and eliminating even more support files in favor of configuration autodetection. The code is now suitably modern and stable, and I'm not embarrassed by its existence, as I am by Aeon beta 5's source code and my archive of Khyller (which, thankfully, no one else ever saw).
|
||||
## License and attribution
|
||||
|
||||
## Other server projects
|
||||
This project remains based on newserv by fuzziqersoftware.
|
||||
|
||||
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.
|
||||
* (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).
|
||||
* (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.
|
||||
* (2018) **newserv**: This project right here.
|
||||
* (2019) **[Mechonis](https://gitlab.com/sora3087/mechonis)**: A PSOBB server with a microservice architecture written in TypeScript by TrueVision.
|
||||
* (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.
|
||||
|
||||
## 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.
|
||||
|
||||
If you want to use parts of newserv in your project, there are two easy ways to do so with proper licensing:
|
||||
* If you're using a lot of code from newserv, you can put a copy of newserv's LICENSE file in your repository alongside your own license file, or include the contents of newserv's license in your own license file.
|
||||
* If you're only using a few files from newserv, you can copy and paste the contents of the LICENSE file into a comment at the beginning of each copied file.
|
||||
|
||||
# Compatibility
|
||||
|
||||
newserv supports all known versions of PSO, including development prototypes. Specifically:
|
||||
| Version | Lobbies | Games | Proxy |
|
||||
|-----------------|----------|----------|----------|
|
||||
| DC NTE | Yes | Yes | No |
|
||||
| DC 11/2000 | Yes | Yes | No |
|
||||
| DC 12/2000 | Yes | Yes | Yes |
|
||||
| DC 01/2001 | Yes | Yes | Yes |
|
||||
| DC V1 | Yes | Yes | Yes |
|
||||
| DC 08/2001 | Yes | Yes | Yes |
|
||||
| DC V2 | Yes | Yes | Yes |
|
||||
| PC NTE | Yes (3) | 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 | 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 |
|
||||
|
||||
*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.*
|
||||
|
||||
# Setup
|
||||
|
||||
## Server setup
|
||||
|
||||
Currently newserv works on macOS, Windows, and Ubuntu Linux. It will likely work on other Linux flavors too.
|
||||
|
||||
### 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.
|
||||
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.
|
||||
|
||||
### 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 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.
|
||||
|
||||
To use newserv in other ways (e.g. for translating data), see the end of this document.
|
||||
|
||||
## Client patch directories
|
||||
|
||||
newserv implements a patch server for PSO PC and PSO BB game data. Any file or directory you put in the system/patch-bb or system/patch-pc directories will be synced to clients when they connect to the patch server.
|
||||
|
||||
For Blue Burst set up, the below is mandatory for a smooth experience:
|
||||
|
||||
1. Browse to your chosen client's data directory.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
To make server startup faster, newserv caches the modification times, sizes, and checksums of the files in the patch directories. If the patch server appears to be misbehaving, try deleting the .metadata-cache.json file in the relevant patch directory to force newserv to recompute all the checksums. Also, in the case when checksums are cached, newserv may not actually load the data for a patch file until it's needed by a client. Therefore, modifying any part of the patch tree while newserv is running can cause clients to see an inconsistent view of it.
|
||||
|
||||
Patch directory contents are cached in memory. If you've changed any of these files, you can run `reload patch-indexes` in the interactive shell to make the changes take effect without restarting the server.
|
||||
|
||||
## How to connect
|
||||
|
||||
### PSO DC
|
||||
|
||||
Depending on the version of PSO DC that you have, the instructions to connect to a newserv instance will vary.
|
||||
|
||||
If you have NTE, USv1, EUv1, or EUv2 and a Broadband Adapter, edit the broadband DNS address to newserv's IP address with newserv's DNS server running. Otherwise, it is necessary to patch the disc or use a codebreaker code to remove the Hunter License server check and/or redirect PSO to the newserv instance. Patching the disc or creating a codebreaker code is beyond the scope of this document.
|
||||
|
||||
### PSO DC on Flycast
|
||||
|
||||
If you're emulating PSO DC, the NTE, USv1, EUv1, and EUv2 versions will connect to newserv by setting the following options in Flycast's `emu.cfg` file under `[network]`:
|
||||
- DNS = Your newserv's server address (newserv's DNS server must be running on port 53)
|
||||
- EmulateBBA = yes
|
||||
- Enable = yes
|
||||
|
||||
It is also necessary to save any DNS information to the flash memory of the Dreamcast to use the BBA - the easiest way to do this is to use the website option in USv2 and then choose the save to flash option.
|
||||
|
||||
If the server is running on the same machine as Flycast, this might not work, even if you point Flycast's DNS queries at your local IP address (instead of 127.0.0.1). In this case, you can modify the loaded executable in memory to make it connect anywhere you want. There is a script included with newserv that can do this on macOS; a similar technique could be done manually using scanmem on Linux or Cheat Engine on Windows. To use the script, do this:
|
||||
1. Build and install [memwatch](https://github.com/fuzziqersoftware/memwatch).
|
||||
2. Start Flycast and run PSO. (You must start PSO before running the script; it won't work if you run the script before loading the game.)
|
||||
3. Run `sudo patch_flycast_memory.py <original-destination>`. Replace `<original-destination>` with the hostname that PSO wants to connect to (you can find this out by using Wireshark and looking for DNS queries). The script may take up to a minute; you can continue using Flycast while it runs, but don't start an online game until the script is done.
|
||||
4. Run newserv and start an online game in PSO.
|
||||
|
||||
If you use this method, you'll have to run the script every time you start PSO in Flycast, but you won't have to run it again if you start another online game without restarting emulation.
|
||||
|
||||
If using JPv1, JPv2, or USv2, it is also necessary to remove the Hunter Licence server check, either with a disc patch or codebreaker code. Patching the disc or creating a codebreaker code is beyond the scope of this document.
|
||||
|
||||
### PSO PC
|
||||
|
||||
PSO PC has its connection addresses in `pso.exe`. Hex edit the executable with the connection address you want to connect to. Common server addresses to search for to replace are:
|
||||
- pso20.sonic.isao.net
|
||||
- sg207634.sonicteam.com
|
||||
- pso-mp01.sonic.isao.net
|
||||
- gsproduc.ath.cx
|
||||
- sylverant.net
|
||||
|
||||
The version of PSO PC I have has the server addresses starting at offset 0x29CB34 in pso.exe. Change those addresses to "localhost" (without quotes) if you just want to connect to a locally-running newserv instance. Alternatively, you can add an entry to the Windows hosts file (C:\Windows\System32\drivers\etc\hosts) to redirect the connection to 127.0.0.1 (localhost) or any other IP address.
|
||||
|
||||
### PSO GC on a real GameCube
|
||||
|
||||
You can make PSO connect to newserv by setting the default gateway and DNS server addresses in the game's network settings to newserv's address. newserv's DNS server must be running on port 53 and must be accessible to the GameCube. If you're not playing PSO Plus or Episode III, this should be all you need to do, assuming you already set LocalAddress in config.json to your PC's private IP address.
|
||||
|
||||
If you have PSO Plus or Episode III, it won't want to connect to a server on the same local network as the GameCube itself, as determined by the GameCube's IP address and subnet mask. There are a couple of ways to get around this.
|
||||
|
||||
Sodaboy described a fairly easy method, which is to forward the PSO and DNS ports in your router's configuration to your PC's private IP address (the PSO ports are in config.json, and are all TCP; the DNS port is 53 and is UDP). Then, set LocalAddress and ExternalAddress in config.json to your external IP address (from e.g. whatismyip.com). Most routers will let you connect to your public IP address even from within the local network, but the GameCube will think it's connecting to a different network, so it won't reject the connection. If you're concerned about security and don't want your server to be publicly accessible, you can use Windows Firewall or UFW on Linux block incoming connections on the ports you opened, except for connections from the IP addresses you specify.
|
||||
|
||||
Another method is to use two network interfaces on the same PC, and tell the GameCube to connect to the one that appears to be on a different network. For example, if your GameCube is on the 10.0.0.x subnet and your PC's address is 10.0.0.5, you can create a fake network adapter on your PC (or use an existing real one) that has an IP address on a different subnet than the GameCube, such as 192.168.0.8. Then, in PSO's network config, set the default gateway and DNS server addresses to 192.168.0.8, and set LocalAddress in config.json to 192.168.0.8, and PSO should connect. This is what I did back in the old days when I primarily developed software on Windows, but I haven't tried it in many years.
|
||||
|
||||
### PSO GC on a Wii or Wii U
|
||||
|
||||
Using a Wii or Wii U to connect to newserv requires the Wii or vWii to be softmodded. How to do this is beyond the scope of this document.
|
||||
|
||||
Nintendont includes BBA emulation and is compatible with all PSO GameCube versions except Episodes I&II Trial Edition. To use Nintendont, enable BBA emulation in Nintendont's settings and follow the instructions in the above section (PSO GC on a real GameCube).
|
||||
|
||||
Devolution includes modem emulation and is compatible with all PSO GameCube versions including Episodes I&II Trial Edition. newserv can act as a PPP server, which Devolution can directly connect to. To do this:
|
||||
1. Enable the PPPRawListen option according to the comments in config.json.
|
||||
2. Start newserv.
|
||||
3. In the game's network settings, set the username and password to anything (they cannot be blank), and set the phone number to the number that newserv outputs to the console during startup. (It will be near the end of all the startup log messages.) If your Wii is on the same network as newserv, use the local number; otherwise, use the external number.
|
||||
|
||||
### 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 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 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.
|
||||
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 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 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.
|
||||
|
||||
### Connecting external clients
|
||||
|
||||
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.
|
||||
|
||||
For GC clients, you'll have to use newserv's built-in DNS server or set up your own DNS server as well. If you want external clients to be able to use your DNS server, you'll have to forward UDP port 53 to your newserv instance. Remote players can then connect to your server by entering your DNS server's IP address in their client's network configuration.
|
||||
|
||||
# Server feature configuration
|
||||
|
||||
## User accounts
|
||||
|
||||
By default, newserv does not require users to pre-register before playing; the server will instead automatically create an account the first time each player connects. These accounts have no special permissions. You can view, create, edit, and delete user accounts in the server's shell (run `help` in the shell to see how to do this).
|
||||
|
||||
A license is a set of credentials that a player can use to log in. There are six types of licenses:
|
||||
* *DC NTE licenses* consist of a 16-character serial number and 16-character access key.
|
||||
* *DC licenses* consist of an 8-character hex serial number and an 8-character access key.
|
||||
* *PC licenses* are the same format as DC licenses, but are used for PC v2.
|
||||
* *GC licenses* consist of a 10-digit decimal serial number, a 12-character access key, and a password of up to 8 characters.
|
||||
* *XB licenses* consist of a gamertag of up to 16 characters, a 16-character hex user ID, and a 16-character hex account ID.
|
||||
* *BB licenses* consist of a username of up to 16 characters and a password of up to 16 characters.
|
||||
Each account may have multiple licenses. To add a license to an account, use `add-license` in the shell.
|
||||
|
||||
On BB, character data is scoped to the license, but system and Guild Card data is scoped to the account. That is, an account with multiple BB licenses can have more than 4 characters (up to 4 per license), but they will all share the same team membership and Guild Card lists.
|
||||
|
||||
You may want to give your account elevated privileges. To do so, run `update-account ACCOUNT-ID flags=root` (replacing ACCOUNT-ID with your actual account-id). You can also use update-account to edit other parts of the account; see the help text for more information.
|
||||
|
||||
## Installing quests
|
||||
|
||||
newserv automatically finds quests in the subdirectories of the system/quests/ directory. To install your own quests, or to use quests you've saved using the proxy's Save Files option, just put them in one of the subdirectories there and name them appropriately. The subdirectories and their behaviors (e.g. in which game modes they should appear and for which PSO versions) is defined in the QuestCategories field in config.json.
|
||||
|
||||
Within the category directories, quest files should be named like `q###-VERSION-LANGUAGE.EXT` (although the `q` is ignored, and can be any letter). The fields in each filename are:
|
||||
- `###`: quest number (this doesn't really matter; it should just be unique across the PSO version)
|
||||
- `VERSION`: dn = Dreamcast NTE, dp = Dreamcast 11/2000 prototype, d1 = Dreamcast v1, dc = Dreamcast v2, pcn = PC NTE, pc = PC, gcn = GameCube NTE, gc = GameCube Episodes 1 & 2, gc3 = Episode 3 (see below), xb = Xbox, bb = Blue Burst
|
||||
- `LANGUAGE`: j = Japanese, e = English, g = German, f = French, s = Spanish
|
||||
- `EXT`: file extension (see table below)
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
| Format | Extension | Supported | Decode action |
|
||||
|------------------|-----------------------|------------|------------------|
|
||||
| Compressed | .bin and .dat | Yes | None (1) |
|
||||
| Compressed Ep3 | .bin or .mnm | Yes (4) | None (1) |
|
||||
| Uncompressed | .bind and .datd | Yes | compress-prs (2) |
|
||||
| Uncompressed Ep3 | .bind or .mnmd | Yes (4) | compress-prs (2) |
|
||||
| Source | .bin.txt and .dat | Yes | None (5) |
|
||||
| VMS (DCv1) | .bin.vms and .dat.vms | Yes | decode-vms |
|
||||
| VMS (DCv2) | .bin.vms and .dat.vms | Decode (3) | decode-vms (3) |
|
||||
| GCI (decrypted) | .bin.gci and .dat.gci | Yes | decode-gci |
|
||||
| GCI (with key) | .bin.gci and .dat.gci | Yes | decode-gci |
|
||||
| GCI (no key) | .bin.gci and .dat.gci | Decode (3) | decode-gci (3) |
|
||||
| GCI (Ep3 NTE) | .bin.gci or .mnm.gci | Decode (3) | decode-gci (3) |
|
||||
| GCI (Ep3) | .bin.gci or .mnm.gci | Yes | decode-gci |
|
||||
| DLQ | .bin.dlq and .dat.dlq | Yes | decode-dlq |
|
||||
| DLQ (Ep3) | .bin.dlq or .mnm.dlq | Yes | decode-dlq |
|
||||
| QST (online) | .qst | Yes | decode-qst |
|
||||
| QST (download) | .qst | Yes | decode-qst |
|
||||
|
||||
*Notes:*
|
||||
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.*
|
||||
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.
|
||||
|
||||
When newserv indexes the quests during startup, it will warn (but not fail) if any quests are corrupt or in unrecognized formats.
|
||||
|
||||
Quest contents are cached in memory, but if you've changed the contents of the quests directory, you can re-index the quests without restarting the server by running `reload quest-index` in the interactive shell. The new quests will be available immediately, but any games with quests already in progress will continue using the old versions of the quests until those quests end.
|
||||
|
||||
## Item tables and drop modes
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
In the server drop modes, the item tables used to generate common items are in the `system/item-tables/ItemPT-*` files. (The V2 files are used for V1 as well.) The rare item tables are in the `rare-table-*.json` files. Unlike the original formats, it's possible to make each enemy drop multiple different rare items at different rates, though the default tables never do this.
|
||||
|
||||
## 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.
|
||||
|
||||
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.)
|
||||
|
||||
## Server-side saves
|
||||
|
||||
newserv has the ability to save character data on the server side. For PSO BB, this is required of course, but this feature can also be used on other PSO versions.
|
||||
|
||||
Each account has 4 BB character slots and 16 non-BB character file slots. The non-BB slots are independent of the BB slots, and can be accessed with the `$savechar <slot>` and `$loadchar <slot>` commands (slots are numbered 1 through 16). `$savechar` copies the character you're currently playing as and saves the data on the server, and `$loadchar` does the reverse, overwriting your current character with the data saved on the server. Note that you can load a character that was saved from a different version of PSO, which allows you to easily transfer characters between games. On v1 and v2, changes done by `$loadchar` will be undone if you join a game; to permanently save your changes, disconnect from the lobby after using the command.
|
||||
|
||||
There is a third command, `$bbchar <username> <password> <slot>`, which behaves similarly to `$savechar` but writes the character data to a BB character slot in a different account instead (slots are numbered 1 through 4). This can be used to "upgrade" a character to BB from an earlier version.
|
||||
|
||||
Exactly which data is saved and loaded depends on the game version:
|
||||
|
||||
| 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 |
|
||||
| PSO DC v2 | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO PC (v2) | Yes | Yes | No | No | No | Save only |
|
||||
| PSO GC NTE | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO GC (not Plus) | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO GC Plus (1) | Save only | Save only | No | No | No | Save only |
|
||||
| PSO GC Ep3 (1) | No | Save only | No | No | No | Save only |
|
||||
| PSO Xbox | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO BB | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
|
||||
*Notes*:
|
||||
1. *If EnableSendFunctionCallQuestNumber is enabled in config.json, then $savechar and $loadchar can save and restore all character data on these versions, just like on GC non-Plus. Episode 3 characters exist in a separate namespace; that is, you can't use $savechar and $loadchar to convert an Ep3 character to non-Ep3, or vice versa.*
|
||||
|
||||
## Episode 3 features
|
||||
|
||||
newserv supports many features unique to Episode 3:
|
||||
* CARD battles. Not every combination of abilities has been tested yet, so if you find a feature or card ability that doesn't work like it's supposed to, please make a GitHub issue and describe the situation (the attacking card(s), defending card(s), and ability or condition that didn't work).
|
||||
* Spectator teams.
|
||||
* Tournaments. (But they work differently than Sega's tournaments did - see below)
|
||||
* Downloading quests.
|
||||
* Trading cards.
|
||||
* Participating in card auctions. (The auction contents must be configured in config.json.)
|
||||
* Decorations in lobbies. Currently only images are supported; the game also supports loading custom 3D models in lobbies, but newserv does not implement this (yet).
|
||||
|
||||
### Battle records
|
||||
|
||||
After playing a battle, you can save the record of the battle with the `$saverec` command. You can then replay the battle later by using the `$playrec` command in a lobby - this will create a spectator team and play the recording of the battle as if it were happening in realtime. Note that there is a bug in older versions of Dolphin that seems to be frequently triggered when playing battle records, which causes the emulator to crash with the message `QObject::~QObject: Timers cannot be stopped from another thread`. To avoid this, use the latest version of Dolphin.
|
||||
|
||||
### Tournaments
|
||||
|
||||
Tournaments work differently than they did on Sega's servers. Tournaments can be created with the `create-tournament` shell command, which enables players to register for them. (Use `help` to see all the arguments - there are many!) The `start-tournament` shell command starts the tournament (and prevents further registrations), but this doesn't schedule any matches. Instead, players who are ready to play their next match can all stand at the 4-player battle table near the lobby warp in the same CARD lobby, and the tournament match will start automatically.
|
||||
|
||||
These tournament semantics mean that there can be multiple matches in the same tournament in play simultaneously, and not all matches in a round must be complete before the next round can begin - only the matches preceding each individual match must be complete for that match to be playable.
|
||||
|
||||
The Meseta rewards for winning tournament matches can be configured in config.json.
|
||||
|
||||
### Episode 3 files
|
||||
|
||||
Episode 3 state and game data is stored in the system/ep3 directory. The files in there are:
|
||||
* card-definitions.mnr: Compressed card definition list, sent to Episode 3 clients at connect time. Card stats and abilities can be changed by editing this file.
|
||||
* card-definitions.mnrd: Decompressed version of the above. If present, newserv will use this instead of the compressed version, since this is easier to edit.
|
||||
* card-text.mnr: Compressed card text archive. Generally only used for debugging.
|
||||
* card-text.mnrd: Decompressed card text archive; same format as TextCardE.bin. Generally only used for debugging.
|
||||
* com-decks.json: COM decks used in tournaments. The default decks in this file come from logs from Sega's servers, so the file doesn't include every COM deck Sega ever made - the rest are probably lost to time.
|
||||
* maps/: Online free battle and quest maps (.mnm/.bin/.mnmd/.bind files). newserv comes with the default online maps, as well as some fan-made variations and quests to help new players get up to speed.
|
||||
* maps-download/: Download maps and quests (.mnm/.bin/.mnmd/.bind files). There are two subcategories by default (download maps and Trial Edition download maps), but you can add more by editing QuestCategories in config.json. Categories that have flag 0x40 (Ep3 download) set are indexed from this directory; all others are indexed from system/quests/. Files in maps-download/ subdirectories have the same format as those in the maps/ directory, but should be named like `e###-gc3-LANGUAGE.EXT` (similar to how non-Episode 3 quests are named in the system/quests/ directory). If you want a map to be available for online play and for downloading, the file must exist in both maps/ and in a maps-download/ subdirectory (a symbolic link is acceptable).
|
||||
* maps-offline/: Offline map files. These are all the offline quests and free battle maps from the client, including some debugging/test maps that were inaccessible during normal play. To make them playable online, put the files in the maps/ directory.
|
||||
* tournament-state.json: State of all active tournaments. This file is automatically written when any tournament changes state for any reason (e.g. a tournament is created/started/deleted or a match is resolved).
|
||||
|
||||
There is no public editor for Episode 3 maps and quests, but the format is described fairly thoroughly in src/Episode3/DataIndexes.hh (see the MapDefinition structure). You'll need to use `newserv decompress-prs ...` to decompress a .bin or .mnm file before editing it, but you don't need to compress it again to use it - just put the .bind or .mnmd file in the maps directory and newserv will make it available.
|
||||
|
||||
Like quests, Episode 3 card definitions, maps, and quests are cached in memory. If you've changed any of these files, you can run `reload ep3-cards` or `reload ep3-maps` in the interactive shell to make the changes take effect without restarting the server.
|
||||
|
||||
## Memory patches, client functions, and DOL files
|
||||
|
||||
*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.
|
||||
|
||||
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:
|
||||
|
||||
| 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 |
|
||||
|
||||
*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.*
|
||||
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
I mainly built the DOL loading functionality for documentation purposes. By now, there are many better ways to load homebrew code on an unmodified GameCube, but to my knowledge there isn't another open-source implementation of this method in existence.
|
||||
|
||||
## Using newserv as a proxy
|
||||
|
||||
If you want to play online on remote servers rather than running your own server, newserv also includes a PSO proxy. Currently this works with PSO GC and may work with PC and DC; it also works with some BB clients in specific situations.
|
||||
|
||||
To use the proxy for PSO DC, PC, or GC, add an entry to the corresponding ProxyDestinations dictionary in config.json, then run newserv and connect to it as normal (see below). You'll see a "Proxy server" option in the main menu, and you can pick which remote server to connect to.
|
||||
|
||||
To use the proxy for PSO BB, set the ProxyDestination-BB entry in config.json. If this option is set, it essentially disables the game server for all PSO BB clients - all clients will be proxied to the specified destination instead. Unfortunately, because PSO BB uses a different set of handlers for the data server phase and character selection, there's no in-game way to present the player with a list of options, like there is on PSO PC and PSO GC.
|
||||
|
||||
When you're on PSO DC, PC, or GC and are connected to a remote server through newserv's proxy, choosing the Change Ship or Change Block action from the lobby counter will send you back to newserv's main menu instead of the remote server's ship or block select menu. You can go back to the server you were just on by choosing it from the proxy server menu again.
|
||||
|
||||
There are many options available when starting a proxy session. All options are off by default unless otherwise noted. The 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.
|
||||
* **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.
|
||||
* **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)
|
||||
* 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)
|
||||
* Episode 3 card definitions (saved as .mnr files)
|
||||
* Episode 3 media updates (saved as .gvm, .bml, or .bin files)
|
||||
|
||||
The remote server will probably try to assign you a Guild Card number that doesn't match the one you have on newserv. On PSO DC, PC and GC, the proxy server rewrites the commands in transit to make it look like the remote server assigned you the same Guild Card number as you have on newserv, but if the remote server has some external integrations (e.g. forum or Discord bots), they will use the Guild Card number that the remote server believes it has assigned to you. The number assigned by the remote server is shown to you when you first connect to the remote server, and you can retrieve it in lobbies or during games with the `$li` command.
|
||||
|
||||
Some chat commands (see below) have the same basic function on the proxy server but have different effects or conditions. In addition, there are some server shell commands that affect clients on the proxy (run `help` in the shell to see what they are). If there's only one proxy session open, the shell's proxy commands will affect that session. Otherwise, you'll have to specify which session to affect with the `on` prefix - to send a chat message in LinkedSession:17205AE4, for example, you would run `on 17205AE4 chat ...`.
|
||||
|
||||
## Chat commands
|
||||
|
||||
newserv supports a variety of commands players can use by chatting in-game. Any chat message that begins with `$` is treated as a chat command. (If you actually want to send a chat message starting with `$`, type `$$` instead.) On the DC 11/2000 prototype, `@` is used instead of `$` for all chat commands, since `$` does not appear on the English virtual keyboard.
|
||||
|
||||
Some commands only work on the game server and not on the proxy server. The chat commands are:
|
||||
|
||||
* Information commands
|
||||
* `$li`: Show basic information about the lobby or game you're in. If you're on the proxy server, show information about your connection instead (remote Guild Card number, client ID, etc.).
|
||||
* `$si` (game server only): Show basic information about the server.
|
||||
* `$ping`: Show round-trip ping time from the server to you. On the proxy server, show the ping time from you to the proxy and from the proxy to the server.
|
||||
* `$matcount` (game server only): Show how many of each type of material you've used.
|
||||
* `$itemnotifs <mode>`: Enable item drop notification messages. If the game has private drops enabled, you will only see a notification if the dropped item is visible to you; you won't be notified of other players' drops. The modes are:
|
||||
* `off`: No notifications are shown.
|
||||
* `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.
|
||||
* `$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 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).
|
||||
* The rest of the commands in this section are enabled on the game server. (They are always enabled on the proxy server.)
|
||||
* `$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).
|
||||
* `$qset <flag-num>` or `$qclear <flag-num>`: Set or clear a quest flag for everyone in the game. If you're in the lobby and on BB, set or clear the saved value of a quest flag in your character file.
|
||||
* `$qgread <flag-num>` (game server only): Show the value of a quest counter ("global flag"). This command can be used without debug mode enabled.
|
||||
* `$qgwrite <flag-num> <value>` (game server only): Set the value of a quest counter ("global flag") for yourself.
|
||||
* `$qsync <reg-num> <value>`: Set a quest register's value for yourself only. `<reg-num>` should be either rXX (e.g. r60) or fXX (e.g. f60); if the latter, `<value>` is parsed as a floating-point value instead of as an integer.
|
||||
* `$qsyncall <reg-num> <value>`: Set a quest register's value for everyone in the game. `<reg-num>` should be either rXX (e.g. r60) or fXX (e.g. f60); if the latter, `<value>` is parsed as a floating-point value instead of as an integer.
|
||||
* `$swset [floor] <flag-num>` and `$swclear [floor] <flag-num>`: Set or clear a switch flag. If floor is not given, sets or clears the flag on your current floor.
|
||||
* `$swsetall`: Set all switch flags on your current floor. This unlocks all doors, disables all laser fences, triggers all light/poison switches, etc.
|
||||
* `$gc` (game server only): Send your own Guild Card to yourself.
|
||||
* `$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.
|
||||
* `$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.
|
||||
* `$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. If you are on V3 (GameCube/Xbox), this command does nothing. If you are on V1 or V2 (DC or PC, not BB), your changes will be undone if you join a game - to save your changes, disconnect from the lobby. If cheats are allowed on the server, `<stat>` can be any of `atp`, `mst`, `evp`, `hp`, `dfp`, `ata`, `lck`, `meseta`, `exp`, `level`, `namecolor`, `secid`, `name`, `language`, `npc`, or `tech`. If cheats are not allowed, only `namecolor`, `name`, `language`, and `npc` can be used. Changing your character's language is only useful on BB; to do so, use a single-character language code (e.g. to switch your character to English, use `$edit language E`; for Japanese, use `$edit language J`).
|
||||
|
||||
* 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.
|
||||
* `$save`: Save your character, system, and Guild Card data immediately. (By default, your character is saved every 60 seconds while online, and your account and Guild Card data are saved whenever they change.)
|
||||
|
||||
* Game state commands (game server only)
|
||||
* `$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.
|
||||
|
||||
* 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.
|
||||
* `$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).
|
||||
|
||||
* Cheat mode commands
|
||||
* `$cheat` (game server only): Enable or disable cheat mode for the current game. All other cheat mode commands do nothing if cheat mode is disabled. By default, cheat mode is off in new games but can be enabled; there is an option in config.json that allows you to disable cheat mode entirely, or set it to on by default in new games. Cheat mode is always enabled on the proxy server, unless cheat mode is disabled on the entire server.
|
||||
* `$infhp`: Enable or disable infinite HP mode. Applies to only you; does not affect other players. When enabled, one-hit KO attacks will still kill you, but on most versions of the game (not DCv1, GC US 1.2, or GC JP 1.5), the server will automatically revive you if you die. On all versions except GC US 1.2 and GC JP 1.5, infinite HP also automatically cures status ailments.
|
||||
* `$inftp`: Enable or disable infinite TP mode. Applies to only you; does not affect other players.
|
||||
* `$warpme <floor-id>` (or `$warp <floor-id>`): Warp yourself to the given floor.
|
||||
* `$warpall <floor-id>`: Warp everyone in the game to the given floor. You must be the leader to use this command, unless you're on the proxy server.
|
||||
* `$next`: Warp yourself to the next floor.
|
||||
* `$item <desc>` (or `$i <desc>`): Create an item. `desc` may be a description of the item (e.g. "Hell Saber +5 0/10/25/0/10") or a string of hex data specifying the item code. Item codes are 16 hex bytes; at least 2 bytes must be specified, and all unspecified bytes are zeroes. If you are on the proxy server, you must not be using Blue Burst for this command to work. On the game server, this command works for all versions.
|
||||
* `$unset <index>` (game server only): In an Episode 3 battle, removes one of your set cards from the field. `<index>` is the index of the set card as it appears on your screen - 1 is the card next to your SC's icon, 2 is the card to the right of 1, etc. This does not cause a Hunters-side SC to lose HP, as they normally do when their items are destroyed.
|
||||
* `$dropmode [mode]` (proxy server): Change the way item drops behave in the current game, if you are not on BB. Unlike the game server version of this command, using this on the proxy server requires cheats to be enabled. This works by intercepting the drop requests sent to and from the leader. (So, if you are the leader and not using server drop mode on the remote server, it affects the entire game; otherwise, it affects only items generated by your actions.) `mode` can be `none` (no drops), `default` (normal drops), or `proxy` (use newserv's drop tables instead of the remote server's). If `mode` is not given, tells you the current drop mode without changing it.
|
||||
|
||||
* Aesthetic commands
|
||||
* `$event <event>`: Set the current holiday event in the current lobby. Holiday events are documented in the "Using $event" item in the information menu. If you're on the proxy server, this applies to all lobbies and games you join, but only you will see the new event - other players will not.
|
||||
* `$allevent <event>` (game server only): Set the current holiday event in all lobbies.
|
||||
* `$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.
|
||||
* `$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.
|
||||
|
||||
# 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` |
|
||||
|
||||
There are several actions that don't fit well into the table above, which let you do other things:
|
||||
|
||||
* Compute the decompressed size of compressed PRS data without decompressing it (`prs-size`)
|
||||
* Find the likely round1 or round2 seed for a corrupt save file (`salvage-gci`)
|
||||
* 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`)
|
||||
See `LICENSE` for license details. Any copied or modified upstream code retains the original license attribution.
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
## 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
|
||||
- Make a server patch version of story flag fixer quest
|
||||
- Fix enemy flag mapping in v2/v3 crossplay and test
|
||||
- Handle items in crossplay - use the replacement table
|
||||
- Make proxy server handle all login commands on non-BB, including sending 9C when needed
|
||||
- Add $switchit command (activates switch flag(s) for nearest object, e.g. laser fence, door, fog collision)
|
||||
- Add a way to persist flags across connections, at least on v3, because of Meet User + B2 enable quest interactions - maybe update the quest to patch one of the login commands so the server can tell it's enabled
|
||||
- Handle MeetUserExtensions properly in 41 and C4 commands on the proxy (rewrite the embedded 19 command and put some metadata in the persistent config, perhaps)
|
||||
- Clean up ItemParameterTable implementation (see comment at the top of the class definition)
|
||||
- Handle MeetUserExtensions properly in 41 and C4 commands on the proxy (rewrite the embedded 19 command and store a map of received destinations)
|
||||
- Make UI strings localizable (e.g. entries in menus, welcome message, etc.)
|
||||
|
||||
## PSO DC
|
||||
|
||||
- Investigate if https://crates.io/crates/blaze-ssl-async can be used to implement the HL check server
|
||||
- v2 challenge data in $savechar/$loadchar doesn't work properly
|
||||
|
||||
## Episode 3
|
||||
|
||||
@@ -25,6 +30,6 @@
|
||||
|
||||
## PSOBB
|
||||
|
||||
- Figure out why Pouilly Slime EXP doesn't work
|
||||
- Make server-specified rare enemies work with maps loaded by the proxy
|
||||
- Implement serialization for various table types (ItemPMT, ItemPT, etc.)
|
||||
- Record some BB tests
|
||||
- Add all necessary Guild Card number rewrites in BB commands on the proxy
|
||||
|
||||
@@ -0,0 +1,926 @@
|
||||
# newserv <img align="right" src="static/s-newserv.png" />
|
||||
|
||||
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.
|
||||
|
||||
Feel free to submit GitHub issues if you find bugs or have feature requests. I'd like to make the server as stable and complete as possible, but I can't promise that I'll respond to issues in a timely manner, because this is a personal project undertaken primarily for the fun of reverse-engineering. If you want to contribute to newserv yourself, pull requests are welcome as well.
|
||||
|
||||
See TODO.md for a list of known issues and future work I've curated, or go to the GitHub issue tracker for issues and requests submitted by the community.
|
||||
|
||||
**Table of contents**
|
||||
* Background
|
||||
* [History](#history)
|
||||
* [Other server projects](#other-server-projects)
|
||||
* [Using newserv in other projects](#using-newserv-in-other-projects)
|
||||
* [Contributing to newserv](#contributing-to-newserv)
|
||||
* [Compatibility](#compatibility)
|
||||
* Setup
|
||||
* [Server setup](#server-setup)
|
||||
* [Client patch directories for PC and BB](#client-patch-directories)
|
||||
* [How to connect](#how-to-connect)
|
||||
* Features and configuration
|
||||
* [User accounts](#user-accounts)
|
||||
* [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-and-client-functions)
|
||||
* [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
|
||||
|
||||
The history of this project essentially mirrors my development as a software engineer from the beginning of my hobby until now. If you don't care about the story, skip to the "Compatibility" or "Setup" sections below.
|
||||
|
||||
I originally purchased PSO GC when I heard about PSUL, and wanted to play around with running homebrew on my GameCube. This pathway eventually led to [GCARS-CS](https://github.com/fuzziqersoftware/gcars-cs), but that's another story.
|
||||
|
||||
<img align="left" src="static/s-khyps.png" /> After playing PSO for a while, both offline and online, I wrote a proxy called Khyps sometime in 2003. This was back in the days of the official Sega servers, where vulnerabilities weren't addressed in a timely manner or at all. It was common for malicious players using their own proxies or Action Replay codes (a story for another time) to send invalid commands that the servers would blindly forward, and cause the receiving clients to crash. These crashes were more than simply inconvenient; they could also corrupt your save data, destroying the hours of work you may have put into hunting items and leveling up your character.
|
||||
|
||||
For a while it was essentially necessary to use a proxy to go online at all, so the proxy could block these invalid commands. Khyps was designed primarily with this function in mind, though it also implemented some convenient cheats, like the ability to give yourself or other players infinite HP and allow you to teleport to different places without using an in-game teleporter.
|
||||
|
||||
<img align="left" src="static/s-khyller.png" /> After Khyps I took on the larger challenge of writing a server, which resulted in Khyller sometime in 2005. This was the first server of any type I had ever written. This project eventually evolved into a full-featured environment supporting all versions of the game that I had access to - at the time, PC, GC, and BB. (However, I suspect from reading the ancient source files that Khyller's BB support was very buggy.) As Khyller evolved, the code became increasingly cumbersome, littered with debugging filth that I never cleaned up and odd coding patterns I had picked up over the years. My understanding of the C++ language was woefully incomplete as well (as opposed to now, when it is still incomplete but not woefully so), which resulted in Khyller being essentially a C project that had a couple of classes in it.
|
||||
|
||||
<img align="left" src="static/s-aeon.png" /> Sometime in 2006 or 2007, I abandoned Khyller and rebuilt the entire thing from scratch, resulting in Aeon. Aeon was substantially cleaner in code than Khyller but still fairly hard to work with, and it lacked a few of the more arcane features I had originally written (for example, the ability to convert any quest into a download quest). In addition, the code still had some stability problems... it turns out that Aeon's concurrency primitives were simply incorrect. I had derived the concept of a mutex myself, before taking any real computer engineering classes, but had implemented it incorrectly. I made the race window as small as possible, but Aeon would still randomly crash after running seemingly fine for a few days.
|
||||
|
||||
At the time of its inception, Aeon was also called newserv, and you may find some beta releases floating around the Internet with filenames like `newserv-b3.zip`. I had released betas 1, 2, and 3 before I released the entire source of beta 5 and stopped working on the project when I went to college. This was around the time when I switched from writing software primarily on Windows to primarily on macOS and Linux, so Aeon beta 5 was the last server I wrote that specifically targeted Windows. (newserv, which you're looking at now, is difficult to compile on Windows but does work.)
|
||||
|
||||
<img align="left" src="static/s-newserv.png" /> After a long hiatus from PSO and much professional and personal development in my technical abilities, I was reminiscing sometime in October 2018 by reading my old code archives. Somehow inspired when I came across Aeon, I spent a weekend and a couple more evenings rewriting the entire project again, cleaning up ancient patterns I had used eleven years ago, replacing entire modules with simple STL containers, and eliminating even more support files in favor of configuration autodetection. The code is now suitably modern and stable, and I'm not embarrassed by its existence, as I am by Aeon beta 5's source code and my archive of Khyller (which, thankfully, no one else ever saw).
|
||||
|
||||
## Other server projects
|
||||
|
||||
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. Schtserv is the only other unofficial server to support Episode 3, their implementation of which is based on newserv's (which is 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/) 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.
|
||||
* (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 in C# by Soly. It seems this was planned to be open-source at some point, but that has not (yet) happened.
|
||||
* (2018) **newserv**: This project right here.
|
||||
* (2019) **[Mechonis](https://gitlab.com/sora3087/mechonis)**: A PSOBB server with a microservice architecture written in TypeScript by TrueVision.
|
||||
* (2020) **[Booma.Server](https://github.com/HelloKitty/Booma.Server)**: A PSOBB server written in C# by Glader, with Soly's help.
|
||||
* (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.
|
||||
|
||||
## Using newserv in 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.
|
||||
|
||||
If you want to use parts of newserv in your project, there are two easy ways to do so with proper licensing:
|
||||
* If you're using a lot of code from newserv, you can put a copy of newserv's LICENSE file in your repository alongside your own license file, or include the contents of newserv's license in your own license file.
|
||||
* If you're only using a few files from newserv, you can copy and paste the contents of the LICENSE file into a comment at the beginning of each copied file.
|
||||
|
||||
Some of the more likely useful 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/.evt) structure, listing of object/enemy types and parameters, 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
|
||||
|
||||
## Contributing to newserv
|
||||
|
||||
The goals of this project are:
|
||||
* Build stable, extensible PSO server software that includes all vanilla functionality as well as optional modern conveniences, features, and cheats.
|
||||
* Document the internals of PSO's network protocol, file formats, and game mechanics. This is mainly done through comments in the code.
|
||||
|
||||
This is a personal project; there is no official development team, official website, or official instance of newserv. Issues and pull requests are certainly welcome, but please only add content (e.g. quests or patches) that you've created, is already public, or you have permission to release publicly.
|
||||
|
||||
# Compatibility
|
||||
|
||||
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 | Yes |
|
||||
| DC 11/2000 | Yes | Yes | Yes |
|
||||
| DC 12/2000 | Yes | Yes | Yes |
|
||||
| DC 01/2001 | Yes | Yes | Yes |
|
||||
| DC V1 | Yes | Yes | Yes |
|
||||
| DC 08/2001 | Yes | Yes | Yes |
|
||||
| DC V2 | Yes | Yes | Yes |
|
||||
| PC NTE | Yes (1) | Yes | Yes |
|
||||
| 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 (2) | Yes |
|
||||
| GC Ep3 | Yes | Yes | Yes |
|
||||
| Xbox Ep1&2 Beta | Yes (3) | Yes (3) | Yes (3) |
|
||||
| Xbox Ep1&2 | Yes (3) | Yes (3) | Yes (3) |
|
||||
| BB (vanilla) | Yes | Yes | Yes |
|
||||
| BB (Tethealla) | Yes | Yes | Yes |
|
||||
|
||||
*Notes:*
|
||||
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.*
|
||||
3. *PSO Xbox connects through Xbox Live, so you can't easily host a private server for this version of the game. See the [How to connect](#pso-xbox) section.*
|
||||
|
||||
# Setup
|
||||
|
||||
## Server setup
|
||||
|
||||
Currently newserv works on macOS, Windows, and Ubuntu Linux. It will likely work on other Linux flavors too.
|
||||
|
||||
### Windows/macOS
|
||||
|
||||
1. Download the latest release.zip file from the [releases page](https://github.com/fuzziqersoftware/newserv/releases).
|
||||
2. Extract the contents of the archive to some location on your computer.
|
||||
3. 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. Most of the options can be left alone if you want default behavior, but on Windows, you must change LocalAddress and ExternalAddress.
|
||||
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, you'll have to build it from source - see the section below.
|
||||
|
||||
### Building from source (macOS/Linux)
|
||||
|
||||
To build on macOS or Linux:
|
||||
|
||||
1. Install the dependencies needed for your platform:
|
||||
* macOS: `brew install cmake asio libiconv`
|
||||
* Linux: `sudo apt-get install cmake libasio-dev` (or use your Linux distribution's package manager)
|
||||
2. Build and install [phosg](https://github.com/fuzziqersoftware/phosg) and [resource_dasm](https://github.com/fuzziqersoftware/resource_dasm).
|
||||
3. Run `cmake . && make` in the newserv 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.
|
||||
|
||||
### Building from source (Windows)
|
||||
|
||||
The current version of newserv is cross-compiled using mingw-w64 on a macOS build machine, with the necessary libraries manually installed. Setting up such a build environment is tedious and not recommended; it's recommended to just use a release version instead.
|
||||
|
||||
Here is a rough outline of the Windows build process. You should only attempt this yourself if you're familiar with setting up build environments and can deal with issues you may encounter along the way.
|
||||
1. Install recent versions of MinGW and CMake.
|
||||
2. Build and install zlib, libiconv, asio, phosg, and resource_dasm into your MinGW environment.
|
||||
3. Clone the newserv repository with symlinks enabled: `git clone -c core.symlinks=true https://github.com/fuzziqersoftware/newserv.git`
|
||||
4. Build newserv via CMake.
|
||||
|
||||
## Client patch directories
|
||||
|
||||
newserv implements a patch server for PSO PC and PSO BB game data. Any file or directory you put in the system/patch-bb or system/patch-pc directories will be synced to clients when they connect to the patch server.
|
||||
|
||||
For Blue Burst set up, the below is mandatory for a smooth experience:
|
||||
|
||||
1. Browse to your chosen client's data directory.
|
||||
2. Copy all the `map_*.dat` files, `map_*.evt`, `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 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.
|
||||
|
||||
To make server startup faster, newserv caches the modification times, sizes, and checksums of the files in the patch directories. If the patch server appears to be misbehaving, try deleting the .metadata-cache.json file in the relevant patch directory to force newserv to recompute all the checksums. Also, in the case when checksums are cached, newserv may not actually load the data for a patch file until it's needed by a client. Therefore, modifying any part of the patch tree while newserv is running can cause clients to see an inconsistent view of it.
|
||||
|
||||
Patch directory contents are cached in memory. If you've changed any of these files, you can run `reload patch-indexes` in the interactive shell to make the changes take effect without restarting the server.
|
||||
|
||||
## How to connect
|
||||
|
||||
### PSO DC
|
||||
|
||||
Depending on the version of PSO DC that you have, the instructions to connect to a newserv instance will vary.
|
||||
|
||||
If you have NTE, USv1, EUv1, or EUv2 and a Broadband Adapter, edit the broadband DNS address to newserv's IP address with newserv's DNS server running. Otherwise, it is necessary to patch the disc or use a codebreaker code to remove the Hunter License server check and/or redirect PSO to the newserv instance. Patching the disc or creating a codebreaker code is beyond the scope of this document.
|
||||
|
||||
### PSO DC on Flycast
|
||||
|
||||
If you're emulating PSO DC, the NTE, USv1, EUv1, and EUv2 versions will connect to newserv by setting the following options in Flycast's `emu.cfg` file under `[network]`:
|
||||
- DNS = Your newserv's server address (newserv's DNS server must be running on port 53)
|
||||
- EmulateBBA = yes
|
||||
- Enable = yes
|
||||
|
||||
It is also necessary to save any DNS information to the flash memory of the Dreamcast to use the BBA - the easiest way to do this is to use the website option in USv2 and then choose the save to flash option.
|
||||
|
||||
If the server is running on the same machine as Flycast, this might not work, even if you point Flycast's DNS queries at your local IP address (instead of 127.0.0.1). In this case, you can modify the loaded executable in memory to make it connect anywhere you want. There is a script included with newserv that can do this on macOS; a similar technique could be done manually using scanmem on Linux or Cheat Engine on Windows. To use the script, do this:
|
||||
1. Build and install [memwatch](https://github.com/fuzziqersoftware/memwatch).
|
||||
2. Start Flycast and run PSO. (You must start PSO before running the script; it won't work if you run the script before loading the game.)
|
||||
3. Run `sudo patch_flycast_memory.py <original-destination>`. Replace `<original-destination>` with the hostname that PSO wants to connect to (you can find this out by using Wireshark and looking for DNS queries). The script may take up to a minute; you can continue using Flycast while it runs, but don't start an online game until the script is done.
|
||||
4. Run newserv and start an online game in PSO.
|
||||
|
||||
If you use this method, you'll have to run the script every time you start PSO in Flycast, but you won't have to run it again if you start another online game without restarting emulation.
|
||||
|
||||
If using JPv1, JPv2, or USv2, it is also necessary to remove the Hunter Licence server check, either with a disc patch or codebreaker code. Patching the disc or creating a codebreaker code is beyond the scope of this document.
|
||||
|
||||
### PSO PC
|
||||
|
||||
PSO PC has its connection addresses in `pso.exe`. Hex edit the executable with the connection address you want to connect to. Common server addresses to search for to replace are:
|
||||
- pso20.sonic.isao.net
|
||||
- sg207634.sonicteam.com
|
||||
- pso-mp01.sonic.isao.net
|
||||
- gsproduc.ath.cx
|
||||
- sylverant.net
|
||||
|
||||
The version of PSO PC I have has the server addresses starting at offset 0x29CB34 in pso.exe. Change those addresses to "localhost" (without quotes) if you just want to connect to a locally-running newserv instance. Alternatively, you can add an entry to the Windows hosts file (C:\Windows\System32\drivers\etc\hosts) to redirect the connection to 127.0.0.1 (localhost) or any other IP address.
|
||||
|
||||
### PSO GC on a real GameCube
|
||||
|
||||
You can make PSO connect to newserv by setting the default gateway and DNS server addresses in the game's network settings to newserv's address. newserv's DNS server must be running on port 53 and must be accessible to the GameCube. If you're not playing PSO Plus or Episode III, this should be all you need to do, assuming you already set LocalAddress in config.json to your PC's private IP address.
|
||||
|
||||
If you have PSO Plus or Episode III, it won't want to connect to a server on the same local network as the GameCube itself, as determined by the GameCube's IP address and subnet mask. There are a couple of ways to get around this.
|
||||
|
||||
Sodaboy described a fairly easy method, which is to forward the PSO and DNS ports in your router's configuration to your PC's private IP address (the PSO ports are in config.json, and are all TCP; the DNS port is 53 and is UDP). Then, set LocalAddress and ExternalAddress in config.json to your external IP address (from e.g. whatismyip.com). Most routers will let you connect to your public IP address even from within the local network, but the GameCube will think it's connecting to a different network, so it won't reject the connection. If you're concerned about security and don't want your server to be publicly accessible, you can use Windows Firewall or UFW on Linux block incoming connections on the ports you opened, except for connections from the IP addresses you specify.
|
||||
|
||||
Another method is to use two network interfaces on the same PC, and tell the GameCube to connect to the one that appears to be on a different network. For example, if your GameCube is on the 10.0.0.x subnet and your PC's address is 10.0.0.5, you can create a fake network adapter on your PC (or use an existing real one) that has an IP address on a different subnet than the GameCube, such as 192.168.0.8. Then, in PSO's network config, set the default gateway and DNS server addresses to 192.168.0.8, and set LocalAddress in config.json to 192.168.0.8, and PSO should connect. This is what I did back in the old days when I primarily developed software on Windows, but I haven't tried it in many years.
|
||||
|
||||
### PSO GC on a Wii or Wii U
|
||||
|
||||
Using a Wii or Wii U to connect to newserv requires the Wii or vWii to be softmodded. How to do this is beyond the scope of this document.
|
||||
|
||||
Nintendont includes BBA emulation and is compatible with all PSO GameCube versions except Episodes I&II Trial Edition. To use Nintendont, enable BBA emulation in Nintendont's settings and follow the instructions in the above section (PSO GC on a real GameCube).
|
||||
|
||||
Devolution includes modem emulation and is compatible with all PSO GameCube versions including Episodes I&II Trial Edition. newserv can act as a PPP server, which Devolution can directly connect to. To do this:
|
||||
1. Enable the PPPRawListen option according to the comments in config.json.
|
||||
2. Start newserv.
|
||||
3. In the game's network settings, set the username and password to anything (they cannot be blank), and set the phone number to the number that newserv outputs to the console during startup. (It will be near the end of all the startup log messages.) If your Wii is on the same network as newserv, use the local number; otherwise, use the external number.
|
||||
|
||||
### 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 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. 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 Xbox
|
||||
|
||||
Unfortunately, you can't easily host a private server for PSO Xbox because the Xbox version of the game tunnels its connections through Xbox Live. There is a modern replacement for Xbox Live named [Insignia](https://insignia.live/), which supports the three main PSO Xbox servers, but as of now does not support other private PSO servers.
|
||||
|
||||
### 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 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).
|
||||
* 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 offset 0x56D724 in psobb.exe. Overwrite these addresses with your server's hostname or IP address, and you should be able to connect.
|
||||
|
||||
### 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.
|
||||
|
||||
For GC clients, you'll have to use newserv's built-in DNS server or set up your own DNS server as well. If you want external clients to be able to use your DNS server, you'll have to forward UDP port 53 to your newserv instance. Remote players can then connect to your server by entering your DNS server's IP address in their client's network configuration.
|
||||
|
||||
# Server feature configuration
|
||||
|
||||
## User accounts
|
||||
|
||||
By default, newserv does not require users to pre-register before playing; the server will instead automatically create an account the first time each player connects. These accounts have no special permissions. You can view, create, edit, and delete user accounts in the server's shell (run `help` in the shell to see how to do this).
|
||||
|
||||
A license is a set of credentials that a player can use to log in. There are six types of licenses:
|
||||
* *DC NTE licenses* consist of a 16-character serial number and 16-character access key.
|
||||
* *DC licenses* consist of an 8-character hex serial number and an 8-character access key.
|
||||
* *PC licenses* are the same format as DC licenses, but are used for PC v2.
|
||||
* *GC licenses* consist of a 10-digit decimal serial number, a 12-character access key, and a password of up to 8 characters.
|
||||
* *XB licenses* consist of a gamertag of up to 16 characters, a 16-character hex user ID, and a 16-character hex account ID.
|
||||
* *BB licenses* consist of a username of up to 16 characters and a password of up to 16 characters.
|
||||
|
||||
Each account may have multiple licenses. To add a license to an existing account, use `add-license` in the shell.
|
||||
|
||||
On BB, character data is scoped to the license, but system and Guild Card data is scoped to the account. That is, an account with multiple BB licenses can have more than 4 characters (up to 4 per license), but they will all share the same team membership and Guild Card lists.
|
||||
|
||||
You may want to give your account elevated privileges. To do so, run `update-account ACCOUNT-ID flags=root` (replacing ACCOUNT-ID with your actual account-id). You can also use update-account to edit other parts of the account; see the help text for more information.
|
||||
|
||||
## Installing quests
|
||||
|
||||
newserv automatically finds quests in the subdirectories of the system/quests/ directory. To install your own quests, or to use quests you've saved using the proxy's Save Files option, just put them in one of the subdirectories there and name them appropriately. The subdirectories and their behaviors (e.g. in which game modes they should appear and for which PSO versions) is defined in the QuestCategories field in config.json.
|
||||
|
||||
Within the category directories, quest files should be named like `q###-VERSION-LANGUAGE.EXT` (although the `q` is ignored, and can be any letter). The fields in each filename are:
|
||||
- `###`: quest number (this doesn't really matter; it should just be unique across the PSO version)
|
||||
- `VERSION`: dn = Dreamcast NTE, dp = Dreamcast 11/2000 prototype, d1 = Dreamcast v1, dc = Dreamcast v2, pcn = PC NTE, pc = PC, gcn = GameCube NTE, gc = GameCube Episodes 1 & 2, gc3 = Episode 3 (see below), xb = Xbox, bb = Blue Burst
|
||||
- `LANGUAGE`: j = Japanese, e = English, g = German, f = French, s = Spanish
|
||||
- `EXT`: file extension (see table below)
|
||||
|
||||
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.
|
||||
|
||||
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 have additional JSON metadata files that describe how the server should handle them. 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 the comments in system/quests/retrieval/q058.json for all of the available options and how to use them. Some of the options are:
|
||||
- Disable or hide the quest if certain preceding quests aren't cleared or other conditions aren't met
|
||||
- Enable the quest to be joined while in progress
|
||||
- Override the common and/or rare item tables and set the allowed drop modes
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
| Format | Extension | Supported | Decode action |
|
||||
|------------------|-----------------------|------------|------------------|
|
||||
| Compressed | .bin and .dat | Yes | None (1) |
|
||||
| Compressed Ep3 | .bin or .mnm | Yes (4) | None (1) |
|
||||
| Uncompressed | .bind and .datd | Yes | compress-prs (2) |
|
||||
| Uncompressed Ep3 | .bind or .mnmd | Yes (4) | compress-prs (2) |
|
||||
| Source | .bin.txt and .dat | Yes | None (5) |
|
||||
| VMS (DCv1) | .bin.vms and .dat.vms | Yes | decode-vms |
|
||||
| VMS (DCv2) | .bin.vms and .dat.vms | Decode (3) | decode-vms (3) |
|
||||
| GCI (decrypted) | .bin.gci and .dat.gci | Yes | decode-gci |
|
||||
| GCI (with key) | .bin.gci and .dat.gci | Yes | decode-gci |
|
||||
| GCI (no key) | .bin.gci and .dat.gci | Decode (3) | decode-gci (3) |
|
||||
| GCI (Ep3 NTE) | .bin.gci or .mnm.gci | Decode (3) | decode-gci (3) |
|
||||
| GCI (Ep3) | .bin.gci or .mnm.gci | Yes | decode-gci |
|
||||
| DLQ | .bin.dlq and .dat.dlq | Yes | decode-dlq |
|
||||
| DLQ (Ep3) | .bin.dlq or .mnm.dlq | Yes | decode-dlq |
|
||||
| QST (online) | .qst | Yes | decode-qst |
|
||||
| QST (download) | .qst | Yes | decode-qst |
|
||||
|
||||
*Notes:*
|
||||
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](#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/maps/). These files can be encoded in any of the formats described above, except .qst.
|
||||
|
||||
When newserv indexes the quests during startup, it will warn (but not fail) if any quests are corrupt or in unrecognized formats.
|
||||
|
||||
Quest contents are cached in memory, but if you've changed the contents of the quests directory, you can re-index the quests without restarting the server by running `reload quest-index` in the interactive shell. The new quests will be available immediately, but any games with quests already in progress will continue using the old versions of the quests until those quests end.
|
||||
|
||||
## Item tables and drop modes
|
||||
|
||||
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 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 `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.
|
||||
|
||||
In the server drop modes, the item tables used to generate common items are in the `system/item-tables/ItemPT-*` files. (The V2 files are used for V1 as well.) The rare item tables are in the `rare-table-*.json` files. Unlike the original formats, it's possible to make each enemy drop multiple different rare items at different rates, though the default tables never do this.
|
||||
|
||||
## Cross-version play
|
||||
|
||||
All versions of PSO can see and interact with each other in the lobby. By default, newserv allows V1 and V2 players to play in games together, and allows GC and Xbox players to play in games together. You can change these rules to allow all versions to play in games together, or to prevent versions from playing in games together, with the CompatibilityGroups setting in config.json.
|
||||
|
||||
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
|
||||
|
||||
newserv has the ability to save character data on the server side. For PSO BB, this is required of course, but this feature can also be used on other PSO versions.
|
||||
|
||||
Each account has 4 BB character slots and 16 non-BB character file slots. The non-BB slots are independent of the BB slots, and can be accessed with the `$savechar <slot>` and `$loadchar <slot>` commands (slots are numbered 1 through 16). `$savechar` copies the character you're currently playing as and saves the data on the server, and `$loadchar` does the reverse, overwriting your current character with the data saved on the server. Note that you can load a character that was saved from a different version of PSO, which allows you to easily transfer characters between games. On v1 and v2, changes done by `$loadchar` will be undone if you join a game; to permanently save your changes, disconnect from the lobby after using the command.
|
||||
|
||||
You can see basic information about a character saved on the server (without affecting your current character) by using `$checkchar <slot>`. You can delete a previously-saved character with `$deletechar <slot>`.
|
||||
|
||||
There is also the command `$bbchar <username> <password> <slot>`, which behaves similarly to `$savechar` but writes the character data to a BB character slot in a different account instead (slots are numbered 1 through 4). This can be used to "upgrade" a character to BB from an earlier version.
|
||||
|
||||
Exactly which data is saved and loaded depends on the game version:
|
||||
|
||||
| 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 |
|
||||
| PSO DC v2 | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO PC (v2) | Yes | Yes | No | No | No | Save only |
|
||||
| PSO GC NTE | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO GC (not Plus) | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO GC Plus (1) | Save only | Save only | No | No | No | Save only |
|
||||
| PSO GC Ep3 (1) | No | Save only | No | No | No | Save only |
|
||||
| PSO Xbox | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
| PSO BB | Yes | Yes | Yes | Yes | Yes | Yes |
|
||||
|
||||
*Notes*:
|
||||
1. *If EnableSendFunctionCallQuestNumber is enabled in config.json, then $savechar and $loadchar can save and restore all character data on these versions, just like on GC non-Plus. Episode 3 characters exist in a separate namespace; that is, you can't use $savechar and $loadchar to convert an Ep3 character to non-Ep3, or vice versa.*
|
||||
|
||||
## Episode 3 features
|
||||
|
||||
newserv supports many features unique to Episode 3:
|
||||
* CARD battles. Not every combination of abilities has been tested yet, so if you find a feature or card ability that doesn't work like it's supposed to, please make a GitHub issue and describe the situation (the attacking card(s), defending card(s), and ability or condition that didn't work).
|
||||
* Spectator teams.
|
||||
* Tournaments. (But they work differently than Sega's tournaments did - see below)
|
||||
* Downloading quests.
|
||||
* Trading cards.
|
||||
* Participating in card auctions. (The auction contents must be configured in config.json.)
|
||||
* Decorations in lobbies. Currently only images are supported; the game also supports loading custom 3D models in lobbies, but newserv does not implement this (yet).
|
||||
|
||||
### Battle records
|
||||
|
||||
After playing a battle, you can save the record of the battle with the `$saverec` command. You can then replay the battle later by using the `$playrec` command in a lobby - this will create a spectator team and play the recording of the battle as if it were happening in realtime. Note that there is a bug in older versions of Dolphin that seems to be frequently triggered when playing battle records, which causes the emulator to crash with the message `QObject::~QObject: Timers cannot be stopped from another thread`. To avoid this, use the latest version of Dolphin.
|
||||
|
||||
### Tournaments
|
||||
|
||||
Tournaments work differently than they did on Sega's servers. Tournaments can be created with the `create-tournament` shell command, which enables players to register for them. (Use `help` to see all the arguments - there are many!) The `start-tournament` shell command starts the tournament (and prevents further registrations), but this doesn't schedule any matches. Instead, players who are ready to play their next match can all stand at the 4-player battle table near the lobby warp in the same CARD lobby, and the tournament match will start automatically.
|
||||
|
||||
These tournament semantics mean that there can be multiple matches in the same tournament in play simultaneously, and not all matches in a round must be complete before the next round can begin - only the matches preceding each individual match must be complete for that match to be playable.
|
||||
|
||||
The Meseta rewards for winning tournament matches can be configured in config.json.
|
||||
|
||||
### Episode 3 files
|
||||
|
||||
Episode 3 state and game data is stored in the system/ep3 directory. The files in there are:
|
||||
* card-definitions.mnr: Compressed card definition list, sent to Episode 3 clients at connect time. Card stats and abilities can be changed by editing this file.
|
||||
* card-definitions.mnrd: Decompressed version of the above. If present, newserv will use this instead of the compressed version, since this is easier to edit.
|
||||
* card-text.mnr: Compressed card text archive. Generally only used for debugging.
|
||||
* card-text.mnrd: Decompressed card text archive; same format as TextCardE.bin. Generally only used for debugging.
|
||||
* com-decks.json: COM decks used in tournaments. The default decks in this file come from logs from Sega's servers, so the file doesn't include every COM deck Sega ever made - the rest are probably lost to time.
|
||||
* maps/: Online free battle and quest maps (.mnm/.bin/.mnmd/.bind files). newserv comes with the default online maps, as well as some fan-made variations and quests to help new players get up to speed. Within the maps/ directory, each subdirectory is treated as a separate category and may be optionally downloadable or available at the battle setup counter. The category.json file in each subdirectory specifies the category's behavior; see system/ep3/maps/online/category.json for a documented example.
|
||||
* tournament-state.json: State of all active tournaments. This file is automatically written when any tournament changes state for any reason (e.g. a tournament is created/started/deleted or a match is resolved).
|
||||
|
||||
There is no public editor for Episode 3 maps and quests, but the format is described fairly thoroughly in src/Episode3/DataIndexes.hh (see the MapDefinition structure). You'll need to use `newserv decompress-prs ...` to decompress a .bin or .mnm file before editing it, but you don't need to compress it again to use it - just put the .bind or .mnmd file in the maps directory and newserv will make it available.
|
||||
|
||||
Like quests, Episode 3 card definitions, maps, and quests are cached in memory. If you've changed any of these files, you can run `reload ep3-cards` or `reload ep3-maps` in the interactive shell to make the changes take effect without restarting the server.
|
||||
|
||||
## Memory patches and client functions
|
||||
|
||||
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. *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.*
|
||||
|
||||
The specific versions are:
|
||||
|
||||
| Game | VERS | CPU architecture |
|
||||
|------------------------------|------|--------------------------------|
|
||||
| PSO DC Network Trial Edition | 1OJ1 | Client functions not supported |
|
||||
| PSO DC 11/2000 prototype | 1OJ2 | Client functions not supported |
|
||||
| PSO DC 12/2000 prototype | 1OJ3 | Client functions not supported |
|
||||
| PSO DC 01/2001 prototype | 1OJ4 | Client functions not supported |
|
||||
| PSO DC v1 JP | 1OJF | Client functions not supported |
|
||||
| PSO DC v1 US | 1OEF | Client functions not supported |
|
||||
| PSO DC v1 EU | 1OPF | Client functions not supported |
|
||||
| PSO DC 08/06/2001 prototype | 2OJ4 | SH-4 |
|
||||
| PSO DC 08/22/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) Trial Edition | 2OJT | Client functions not supported |
|
||||
| PSO PC (v2) 04/2002 | 2OJW | Client functions not supported |
|
||||
| PSO PC (v2) 02/2003 | 2OJZ | Client functions 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 |
|
||||
|
||||
*Notes:*
|
||||
1. *Client functions are only supported on these versions if EnableSendFunctionCallQuestNumbers is set in config.json. See the comments there for more information.*
|
||||
|
||||
newserv comes with a set of patches for many of the above versions. These are organized in subdirectories within system/client-functions/.
|
||||
|
||||
### DOL loader
|
||||
|
||||
You can 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.
|
||||
|
||||
I mainly built the DOL loading functionality for documentation purposes. By now, there are many better ways to load homebrew code on an unmodified GameCube, but to my knowledge there isn't another open-source implementation of this method in existence.
|
||||
|
||||
## Using newserv as a proxy
|
||||
|
||||
If you want to play online on remote servers rather than running your own server, newserv also includes a PSO proxy. Currently this works with PSO GC and may work with PC and DC; it also works with some BB clients in specific situations.
|
||||
|
||||
To use the proxy for PSO DC, PC, or GC, add an entry to the corresponding ProxyDestinations dictionary in config.json, then run newserv and connect to it as normal (see below). You'll see a "Proxy server" option in the main menu, and you can pick which remote server to connect to.
|
||||
|
||||
To use the proxy for PSO BB, set the ProxyDestination-BB entry in config.json. If this option is set, it essentially disables the game server for all BB clients - all BB clients will be proxied to the specified destination instead. Unfortunately, because PSO BB uses a different set of handlers for the data server phase and character selection, there's no in-game way to present the player with a list of options, like there is on PSO PC and PSO GC.
|
||||
|
||||
When you're on PSO DC, PC, GC, or Xbox and are connected to a remote server through newserv's proxy, choosing the Change Ship or Change Block action from the lobby counter will send you back to newserv's main menu instead of the remote server's ship or block select menu. You can go back to the server you were just on by choosing it from the proxy server menu again.
|
||||
|
||||
There are many options available when starting a proxy session. All options are off by default unless otherwise noted. The 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.
|
||||
* **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**: 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). Saved files can then be used with newserv by just moving the file into the appropriate place in the system/ directory and renaming it appropriately. 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 as .txt files)
|
||||
* Player, system, and Guild Card data from BB sessions (saved as .psochar, .psosys, .psosysteam, and .psocard files)
|
||||
* Stream file data from BB sessions (saved as ItemPMT, BattleParamEntry, ItemMagEdit, and PlyLevelTbl files)
|
||||
* Episode 3 online quests and maps (saved as .mnmd files)
|
||||
* Episode 3 download quests (saved as .mnm files)
|
||||
* Episode 3 card definitions (saved as .mnr files)
|
||||
* Episode 3 media updates (saved as .gvm, .bml, or .bin files)
|
||||
|
||||
The remote server will probably try to assign you a Guild Card number that doesn't match the one you have on newserv. The proxy rewrites the commands in transit to make it look like the remote server assigned you the same Guild Card number as you have on newserv, but if the remote server has some external integrations (e.g. forum or Discord bots), they will use the Guild Card number that the remote server believes it has assigned to you. The number assigned by the remote server is shown to you when you first connect to the remote server, and you can retrieve it in lobbies or during games with the `$li` command.
|
||||
|
||||
Some chat commands (see below) have the same basic function on the proxy but have different effects or conditions. In addition, there are some server shell commands that affect clients on the proxy (run `help` in the shell to see what they are). If there's only one proxy session open, the shell's proxy commands will affect that session. Otherwise, you'll have to specify which session to affect with the `on` prefix - to send a chat message in C-17's session, for example, you would run `on C-17 chat ...`.
|
||||
|
||||
## Chat commands
|
||||
|
||||
newserv supports a variety of commands players can use by chatting in-game. Any chat message that begins with `$` is treated as a chat command. (If you actually want to send a chat message starting with `$`, type `$$` instead.) On the DC 11/2000 prototype, `@` is used instead of `$` for all chat commands, since `$` does not appear on the English virtual keyboard.
|
||||
|
||||
Some commands only work for clients not in proxy sessions. The chat commands are:
|
||||
|
||||
* Information commands
|
||||
* `$li`: Show basic information about the lobby or game you're in. If you're on the proxy, show information about your connection instead (remote Guild Card number, client ID, etc.).
|
||||
* `$si`: Show basic information about the server.
|
||||
* `$ping`: Show round-trip ping time from the server to you. On the proxy, show the ping time from you to the proxy and from the proxy to the server.
|
||||
* `$matcount` (non-proxy only): Show how many of each type of material you've used.
|
||||
* `$killcount` (non-proxy only): Show the kill count on your currently-equipped weapon. If you're in a game and not on BB, the value is only accurate at the time the item enters the game.
|
||||
* `$itemnotifs <mode>`: Enable item drop notification messages. If the game has private drops enabled, you will only see a notification if the dropped item is visible to you; you won't be notified of other players' drops. The modes are:
|
||||
* `off`: No notifications are shown.
|
||||
* `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` (non-proxy only): Show the type, name, and stats of the nearest item on the ground.
|
||||
* `$where`: Show your current floor number and coordinates. Mainly useful for debugging.
|
||||
* `$qfread <field-name>` (non-proxy only): Show the value of a quest counter in your player data. The field names are defined in config.json.
|
||||
|
||||
* Basic debugging commands (special permissions not required)
|
||||
* `$whatobj` and `$whatene` (non-proxy only): Tells you what the closest object or enemy spawn point is to your position, along with its coordinates and object or enemy ID. The full definition is also printed to the server's log.
|
||||
* `$qcheck <flag-num>` (non-proxy only): Show the value of a quest flag. 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).
|
||||
* `$qgread <flag-num>` (non-proxy only): Show the value of a quest counter ("global flag").
|
||||
* `$sound <sound-id>`: Play the given sound (GC only).
|
||||
|
||||
* Restricted debugging commands (`$debug` permission required)
|
||||
* `$debug`: Enable debug mode. You need the DEBUG flag in your user account to use this command. Enabling debug does several things:
|
||||
* You'll be able to use the rest of the commands in this section.
|
||||
* 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 cross-version play is normally enabled. See the "Cross-version play" section above for details on this.
|
||||
* `$readmem <address>`: Read 4 bytes from the given address and show you the values.
|
||||
* `$writemem <address> <data>`: Write data to the given address. Data is not required to be any specific size.
|
||||
* `$nativecall <address> [arg1 ...]` (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>` (non-proxy 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 for this command if the specified quest has the AllowStartFromChatCommand field set in its metadata file.
|
||||
* `$qcall <function-id>`: Call a quest function on your client.
|
||||
* `$qset <flag-num>` or `$qclear <flag-num>`: Set or clear a quest flag for everyone in the game. If you're in the lobby and on BB, set or clear the saved value of a quest flag in your character file.
|
||||
* `$qgwrite <flag-num> <value>` (non-proxy only): Set the value of a quest counter ("global flag") for yourself.
|
||||
* `$qsync <reg-num> <value>`: Set a quest register's value for yourself only. `<reg-num>` should be either rXX (e.g. r60) or fXX (e.g. f60); if the latter, `<value>` is parsed as a floating-point value instead of as an integer.
|
||||
* `$qsyncall <reg-num> <value>`: Set a quest register's value for everyone in the game. `<reg-num>` should be either rXX (e.g. r60) or fXX (e.g. f60); if the latter, `<value>` is parsed as a floating-point value instead of as an integer.
|
||||
* `$swset [floor] <flag-num>` and `$swclear [floor] <flag-num>`: Set or clear a switch flag. If floor is not given, sets or clears the flag on your current floor.
|
||||
* `$swsetall`: Set all switch flags on your current floor. This unlocks all doors, disables all laser fences, triggers all light/poison switches, etc.
|
||||
* `$allrare`: Make all enemies and boxes drop their rare items every time.
|
||||
* `$gc` (non-proxy only): Send your own Guild Card to yourself.
|
||||
* `$sc <data>`: Send a command to yourself.
|
||||
* `$scp <data>`: Send a protected 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.
|
||||
* `$auction` (Episode 3 only): Bring up the CARD Auction menu, even if there are fewer than 4 players are in the game or you don't have a VIP card.
|
||||
* `$makeobj <type> [coords...] [angles...] [params...]`: Create a map object. This is only implemented for a few specific client versions. The type is an integer like `273` or `0x0107`. Coordinates are specified as e.g. `x:30 y:0 z:-25.5`; if coordinates are not specified, the object is created at the player's coordinates. Angles are specified as e.g. `r:0 p:0x1000 w:-0x400` (for roll, pitch, and yaw, respectively). Parameters are specified as e.g. `1:2.0 2:0.0 5:0x4000`; any unspecified parameters are set to zero. The object is only created for the calling player and is not added to the server's map state; if the object ever sends update commands (e.g. 6x0B), it will likely result in a disconnection.
|
||||
|
||||
* Personal state commands
|
||||
* `$arrow <color-id>`: Change your lobby arrow color. The color may be specified by number (0-12) or by name (red, blue, green, yellow, purple, cyan, orange, pink, white, white2, white3, or black).
|
||||
* `$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, 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 and item drops. On the proxy, 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, 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 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 (non-proxy only)
|
||||
* `$switchchar <slot>` (BB only): Switch to a different character from your account without logging out.
|
||||
* `$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>`: Load character data from the specified slot on the server, and replace your current character with it. 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.
|
||||
* `$checkchar [slot]`: Tells you basic information about a server-side character previously saved using `$savechar`. If `slot` is not given, tells you which slots are used and which are free.
|
||||
* `$deletechar <slot>`: Deletes a server-side character previously saved using `$savechar`.
|
||||
* `$edit <stat> <value>`: Modify your character data. See the [using $edit](#using-edit) section for details.
|
||||
|
||||
* Blue Burst player commands (non-proxy 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.
|
||||
* `$save`: Save your character, system, and Guild Card data immediately. (By default, your character is saved every 60 seconds while online, and your account and Guild Card data are saved whenever they change.)
|
||||
|
||||
* Game state commands (non-proxy only)
|
||||
* `$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](#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 (non-proxy 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. 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 and plays the specified recording as if it were happening in real time. By default, playback will start immediately when the spectator team is ready; you can delay this to allow others to join by prepending a `!` to the recording name. In that case, using `$playrec` again (with no argument) within the spectator team will start playback.
|
||||
|
||||
* Cheat mode commands
|
||||
* `$cheat` (non-proxy only): Enable or disable cheat mode for the current game. All other cheat mode commands do nothing if cheat mode is disabled. By default, cheat mode is off in new games but can be enabled; there is an option in config.json that allows you to disable cheat mode entirely, or set it to on by default in new games. Cheat mode is always enabled on the proxy, unless cheat mode is disabled on the entire server.
|
||||
* `$infhp`: Enable or disable infinite HP mode. Applies to only you; does not affect other players. When enabled, one-hit KO attacks will still kill you, but on most versions of the game, the server will automatically revive you if you die. Infinite HP also automatically cures status ailments.
|
||||
* `$inftp`: Enable or disable infinite TP mode. Applies to only you; does not affect other players. Does not work on DCv1 or earlier versions.
|
||||
* `$fastkill`: Enable or disable fast kills. Applies to only you; does not affect other players. When enabled, the server will kill any enemy after you hit it once. Bosses are not affected by fast kills.
|
||||
* `$warpme <floor-id>` (or `$warp <floor-id>`): Warp yourself to the given floor.
|
||||
* `$warpall <floor-id>`: Warp everyone in the game to the given floor. You must be the leader to use this command, unless you're on the proxy.
|
||||
* `$next`: Warp yourself to the next floor.
|
||||
* `$item <desc>` (or `$i <desc>`): Create an item. `desc` may be a description of the item or a string of hex data specifying the item code. Item codes are 16 hex bytes; at least 2 bytes must be specified, and all unspecified bytes are zeroes. If you are on the proxy, you must not be using Blue Burst for this command to work. On the game server, this command works for all versions. Here are some examples to illustrate the syntax (nothing is case-sensitive, and everything except the item name itself is optional):
|
||||
* `$item Saber +5 0/10/25/0/10` (weapon with special, grind and attributes)
|
||||
* `$item ???? Draw Autogun` (untekked weapon with special; can have grind/attributes too, as above)
|
||||
* `$item SEALED J-SWORD K:2000` (weapon with kill count)
|
||||
* `$item ES APHEX ZALURE TWIN +200` (ES weapon must be prefixed with "ES"; name comes before special)
|
||||
* `$item DF FIELD +10DEF +20EVP +4` (armor with DFP bonus, EVP bonus, and slot count)
|
||||
* `$item RED MERGE +10DFP +20EVP` (shield; same as armor except without slot count)
|
||||
* `$item Knight/Power +9` (unit with specific modifier)
|
||||
* `$item Knight/Power++` (unit with normal modifier; ++/-- are +4/-4 and +/- are +2/-2)
|
||||
* `$item LIMITER K:1000` (sealed unit with kill count)
|
||||
* `$item Tapas PB:F,G,M&Y 120% 200IQ 5/195/0/0 green` (mag with PBs, synchro, IO, stats, and color)
|
||||
* `$item Trimate x10` (tool with stack size)
|
||||
* `$item Disk:Reverser` (technique disk without level)
|
||||
* `$item Disk:Razonde Lv.30` (technique disk with level)
|
||||
* `$item 1000 Meseta`
|
||||
* `$unset <index>` (non-proxy only): In an Episode 3 battle, removes one of your set cards from the field. `<index>` is the index of the set card as it appears on your screen - 1 is the card next to your SC's icon, 2 is the card to the right of 1, etc. This does not cause a Hunters-side SC to lose HP, as they normally do when their items are destroyed. You can also destroy the assist card set on yourself with `$unset 0`.
|
||||
* `$dropmode [mode]` (proxy only): Change the way item drops behave in the current game, if you are not on BB. Unlike the game server version of this command, using this on the proxy requires cheats to be enabled. This works by intercepting the drop requests sent to and from the leader. (So, if you are the leader and not using server drop mode on the remote server, it affects the entire game; otherwise, it affects only items generated by your actions.) `mode` can be `none` (no drops), `default` (normal drops), or `proxy` (use newserv's drop tables instead of the remote server's). If `mode` is not given, tells you the current drop mode without changing it.
|
||||
|
||||
* Aesthetic commands
|
||||
* `$event <event>`: Set the current holiday event in the current lobby. Holiday events are documented in the "Using $event" item in the information menu. If you're on the proxy, this applies to all lobbies and games you join, but only you will see the new event - other players will not.
|
||||
* `$allevent <event>` (non-proxy only): Set the current holiday event in all lobbies.
|
||||
* `$song <song-id>` (Episode 3 only): Play a specific song in the current lobby.
|
||||
|
||||
* Administration commands (non-proxy only)
|
||||
* `$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.
|
||||
|
||||
### Using $edit
|
||||
|
||||
The $edit command modifies your character data. This command doesn't work on V3 (GameCube/Xbox). If you are on V1 or V2 (DC or PC, not BB), your changes will be undone if you join a game - to save your changes, disconnect from the lobby.
|
||||
|
||||
Some subcommands are always available. They are:
|
||||
* `$edit mat reset power`: Clear your usage of power materials (BB only)
|
||||
* `$edit mat reset mind`: Clear your usage of mind materials (BB only)
|
||||
* `$edit mat reset evade`: Clear your usage of evade materials (BB only)
|
||||
* `$edit mat reset def`: Clear your usage of def materials (BB only)
|
||||
* `$edit mat reset luck`: Clear your usage of luck materials (BB only)
|
||||
* `$edit mat reset hp`: Clear your usage of HP materials (BB only)
|
||||
* `$edit mat reset tp`: Clear your usage of TP materials (BB only)
|
||||
* `$edit mat reset all`: Clear your usage of all materials except HP and TP (BB only)
|
||||
* `$edit mat reset every`: Clear your usage of all materials including HP and TP (BB only)
|
||||
* `$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 (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)
|
||||
* `$edit mst N`: Set your MST to N until stats are updated
|
||||
* `$edit evp N`: Set your EVP to N until stats are updated
|
||||
* `$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 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 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.
|
||||
* `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 server and proxy. 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 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 Xbox save file | None | `decrypt-xbox-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:
|
||||
|
||||
* Compute the decompressed size of compressed PRS data without decompressing it (`prs-size`)
|
||||
* Find the likely round1 or round2 seed for a corrupt save file (`salvage-gci`)
|
||||
* 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`)
|
||||
* Convert item data to a human-readable description, or vice versa (`describe-item`)
|
||||
* Show the server's item and level tables (`show-item-tables`, `show-level-tables`)
|
||||
* 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
|
||||
```
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def filter_directory(dir: str, predicate: Callable[[str], bool]):
|
||||
for filename in os.listdir(dir):
|
||||
if not predicate(filename):
|
||||
path = os.path.join(dir, filename)
|
||||
if os.path.isfile(path):
|
||||
os.remove(path)
|
||||
else:
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
def main():
|
||||
print("Deleting existing release directory")
|
||||
if os.path.exists("release"):
|
||||
shutil.rmtree("release")
|
||||
if os.path.exists("release.zip"):
|
||||
os.remove("release.zip")
|
||||
os.mkdir("release")
|
||||
|
||||
print("Adding executables")
|
||||
shutil.copy("newserv", "release/newserv-macos")
|
||||
shutil.copy("newserv.exe", "release/newserv-windows.exe")
|
||||
shutil.copy("README.md", "release/README.md")
|
||||
|
||||
print("Adding system directory")
|
||||
shutil.copytree("system", "release/system")
|
||||
|
||||
print("Removing instance-based and temporary files")
|
||||
filter_directory(
|
||||
"release/system",
|
||||
lambda filename: (not filename.endswith(".json"))
|
||||
or filename == "config.example.json",
|
||||
)
|
||||
filter_directory(
|
||||
"release/system/ep3", lambda filename: not filename.startswith("cardtex")
|
||||
)
|
||||
filter_directory(
|
||||
"release/system/client-functions",
|
||||
lambda filename: filename not in ("Debug-Private", "FastLoading", "notes.txt"),
|
||||
)
|
||||
filter_directory("release/system/dol", lambda filename: False)
|
||||
filter_directory("release/system/ep3/banners", lambda filename: False)
|
||||
filter_directory("release/system/ep3/battle-records", lambda filename: False)
|
||||
filter_directory("release/system/licenses", lambda filename: False)
|
||||
filter_directory("release/system/players", lambda filename: False)
|
||||
filter_directory(
|
||||
"release/system/quests",
|
||||
lambda filename: filename not in ("private", "includes"),
|
||||
)
|
||||
filter_directory("release/system/teams", lambda filename: filename == "base.json")
|
||||
subprocess.check_call(["find", "release", "-name", ".DS_Store", "-delete"])
|
||||
subprocess.check_call(["find", "release", "-name", "*.WIP-s", "-delete"])
|
||||
|
||||
print("Setting up configuration")
|
||||
os.rename("release/system/config.example.json", "release/system/config.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+1066
-309
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
+451
-453
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
DC NTE: pso02.dricas.ne.jp
|
||||
Nov 2000 proto: test1.st-pso.games.sega.net
|
||||
Dec 2000 proto: sg107634.csrd.sega.co.jp OR master.pso.dream-key.com
|
||||
Jan 2001 proto: master.pso.dream-key.com
|
||||
Aug 2001 proto (v2): game01.st-pso.games.sega.net
|
||||
1OJ1 (DC NTE): pso02.dricas.ne.jp
|
||||
1OJ2 (11/2000): test1.st-pso.games.sega.net
|
||||
1OJ3 (12/2000): sg107634.csrd.sega.co.jp OR master.pso.dream-key.com
|
||||
1OJ4 (01/2001): master.pso.dream-key.com
|
||||
2OJ4 (08/06/2001; v2): game01.st-pso.games.sega.net
|
||||
2OJ5 (08/22/2001; v2): game01.st-pso.games.sega.net
|
||||
|
||||
@@ -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,4 +1,6 @@
|
||||
List of differences in Ep3 NTE compared to Final:
|
||||
- COMs can play more than one defense card per turn
|
||||
- The battle setup menu allows 1v2 battles
|
||||
- Assist cards
|
||||
- - Dice Fever sets dice to 6, not 5, and there is no Dice Fever +
|
||||
- - Rich + and Charity + also don't exist
|
||||
@@ -27,7 +29,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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+996
-981
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
patch required in 59NL to get this to work: 0048210D EB
|
||||
|
||||
is_hangame callsites in 59NL:
|
||||
0040457C - don't save password on disconnect
|
||||
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??
|
||||
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
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
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
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
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
+206
File diff suppressed because one or more lines are too long
@@ -0,0 +1,586 @@
|
||||
NOTE: The NNF descriptions are from Kayak's movement data notes: https://qedit.info/index.php?title=Get_movement_data
|
||||
|
||||
|
||||
|
||||
MOVEMENT DATA 00 (BOOTA)
|
||||
MOVEMENT DATA 01 (ZE_BOOTA)
|
||||
MOVEMENT DATA 03 (BA_BOOTA)
|
||||
MOVEMENT DATA 11 (GORAN)
|
||||
MOVEMENT DATA 12 (PYRO_GORAN)
|
||||
MOVEMENT DATA 13 (GORAN_DETONATOR)
|
||||
MOVEMENT DATA 4A (BOOMA, MERILLIA)
|
||||
MOVEMENT DATA 4B (GOBOOMA, MERILTAS)
|
||||
MOVEMENT DATA 4C (GIGOBOOMA)
|
||||
MOVEMENT DATA 4E (EVIL_SHARK, DOLMOLM)
|
||||
MOVEMENT DATA 4F (PAL_SHARK, DOLMDARL)
|
||||
MOVEMENT DATA 50 (GUIL_SHARK)
|
||||
MOVEMENT DATA 52 (DIMENIAN)
|
||||
MOVEMENT DATA 53 (LA_DIMENIAN)
|
||||
MOVEMENT DATA 54 (SO_DIMENIAN)
|
||||
fparam1 = idle move speed (when returning to initial position)
|
||||
fparam2 = idle walking animation speed
|
||||
fparam3 = engaged move speed (when approaching a player)
|
||||
fparam4 = engaged animation speed
|
||||
fparam5 = MERILLIA, MERILTAS; TODO: 3OE1:800D5750; poison cloud damage
|
||||
fparam5 = DOLMOLM, DOLMDARL; TODO: 3OE1:802FFA70; max distance to notice player?; NNF: Possibly frames before getting trapped
|
||||
fparam5 = BOOTA, ZE_BOOTA, BA_BOOTA; TODO: 59NL:005A56B5, 59NL:005A5361
|
||||
fparam5 = GORAN, PYRO_GORAN, GORAN_DETONATOR; TODO: 59NL:005ACDD2
|
||||
fparam6 = MERILLIA, MERILTAS; TODO: 3OE1:800D7074; NNF: run away speed
|
||||
fparam6 = GORAN, PYRO_GORAN, GORAN_DETONATOR; TODO: 59NL:005AD31E, 59NL:005ACC23, 59NL:005ACB4A; length of a vector (speed?)
|
||||
iparam1 = MERILLIA, MERILTAS; low HP threshold percentage (0-100); controls how often it runs away
|
||||
iparam1 = DOLMOLM, DOLMDARL; TODO: 3OE1:802FFFBC; NNF: Angle to use Trap (Cannot exceed Attack data angle)
|
||||
iparam1 = BOOTA, ZE_BOOTA, BA_BOOTA; TODO: 59NL:005A53D7, 59NL:005A531C, 59NL:005A5092 (special case for 01 only apparently?)
|
||||
iparam1 = GORAN, PYRO_GORAN, GORAN_DETONATOR; TODO: 59NL:005AD0CF, 59NL:005ACE95; looks like an angle in degrees (range [0, 359])
|
||||
iparam2 = DOLMOLM, DOLMDARL; TODO: 3OE1:80300154; NNF: Length of time in seconds Dolmolm trap lasts
|
||||
iparam2 = BOOTA, ZE_BOOTA, BA_BOOTA; TODO: 59NL:005A5580
|
||||
iparam2 = GORAN, PYRO_GORAN, GORAN_DETONATOR; TODO: 59NL:005ACD0F
|
||||
|
||||
MOVEMENT DATA 00 (MOTHMANT)
|
||||
fparam1 = speed when low to the ground (chase mode)
|
||||
iparam2 = delay before attack (applies when in chase mode and reached target, or between attacks when near target)
|
||||
|
||||
MOVEMENT DATA 01 (MONEST)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 02 (SAVAGE_WOLF)
|
||||
MOVEMENT DATA 03 (BARBAROUS_WOLF)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 04 (POISON_LILY)
|
||||
MOVEMENT DATA 05 (NAR_LILY)
|
||||
MOVEMENT DATA 25 (DEL_LILY)
|
||||
fparam1 = DEL_LILY; TODO: 3OE1:800C25C8; damage for some kind of attack
|
||||
iparam1 = POISON_LILY, NAR_LILY; Megid level, only used in Ultimate
|
||||
|
||||
MOVEMENT DATA 05 (SAND_RAPPY_CRATER)
|
||||
MOVEMENT DATA 06 (DEL_RAPPY_CRATER)
|
||||
MOVEMENT DATA 17 (SAND_RAPPY_DESERT)
|
||||
MOVEMENT DATA 18 (RAG_RAPPY, DEL_RAPPY_DESERT)
|
||||
MOVEMENT DATA 19 (AL_RAPPY, LOVE_RAPPY, SAINT_RAPPY, EGG_RAPPY, HALLO_RAPPY)
|
||||
fparam1 = hitbox radius
|
||||
fparam2 = TODO: 3OE1:TObjEneLappy_set_params_from_movement_data, 59NL:FUN_00526A7C; NNF: Flinch time (higher number is less flinch time)
|
||||
fparam3 = TODO: 3OE1:TObjEneLappy_set_params_from_movement_data, 59NL:FUN_00526A7C; NNF: Animation speed at which their legs move after getting hit once they fake die (negative values make them run underground, 0 makes it so their legs don't move along and they just slide across the ground lol.)
|
||||
|
||||
MOVEMENT DATA 06 (SINOW_BEAT, SINOW_BERILL)
|
||||
MOVEMENT DATA 10 (SINOW_GOLD, SINOW_SPIGELL)
|
||||
fparam1 = TODO: 3OE1:800E63F0, 3OE1:800F38D8; NNF: Movement speed
|
||||
fparam2 = SINOW_BEAT, SINOW_GOLD; TODO: 3OE1:800E6410; NNF: Clone movement speed (invisible flag must be set to 0 to get clones)
|
||||
fparam3 = TODO: 3OE1:800E5D0C, 3OE1:800F3234; NNF: The speed (and amount) it moves forward right when it is about to attack you
|
||||
fparam4 = TODO: 3OE1:800E7BA0, 3OE1:800E7DA8, 3OE1:800F53E4
|
||||
fparam5 = TODO: 3OE1:800E7BA8, 3OE1:800F53EC
|
||||
fparam6 = SINOW_BERILL, SINOW_SPIGELL; TODO: 3OE1:800F21D4, 3OE1:800F2E84; probability of something (0-1)
|
||||
iparam1 = Shifta/Deband/Resta level
|
||||
iparam2 = TODO: 3OE1:800E5200, 3OE1:800F2B8C
|
||||
iparam3 = TODO: 3OE1:800E5D78, 3OE1:800F32A0; NNF: Amount of time (in frames) that the sinow pauses after it attacks
|
||||
iparam4 = SINOW_BERILL, SINOW_SPIGELL; attack tech level (Rafoie in Ultimate, Gifoie otherwise)
|
||||
|
||||
MOVEMENT DATA 07 (CANADINE)
|
||||
MOVEMENT DATA 08 (CANADINE_RING)
|
||||
MOVEMENT DATA 09 (CANANE)
|
||||
fparam1 = TODO: 3OE1:8009CEF4; NNF: Movement speed of animation perfomed just before melee attack
|
||||
fparam2 = electrical attack damage
|
||||
fparam3 = explosion damage
|
||||
iparam1 = TODO: 3OE1:8009D4AC; NNF: Zonde attack charge time (higher is longer)
|
||||
iparam2 = TODO: 3OE1:8009D508; NNF: Delay after laser targetting ends before shooting Zonde
|
||||
iparam3 = TODO: 3OE1:8009D59C; NNF: Delay after casting Zonde
|
||||
iparam4 = TODO: 3OE1:8009D5B8; NNF: Number of times Zonde is cast before they go to the next cycle
|
||||
iparam5 = TODO: 3OE1:8009C5C8; NNF: stun frames after being hit
|
||||
iparam6 = CANANE; TODO: 3OE1:8009B148; number of out-fighters (see CANADINE description in Map.cc); NNF: How many of the 8 ring Canadines will cast Zonde (numbers greater than 8 are treated as 8). The remaining number out of 8 will perform melee attacks instead. Value of 0 causes FSOD.
|
||||
|
||||
MOVEMENT DATA 07 (GEE)
|
||||
iparam5 = TODO: 3OE1:800C9778; probably same as CANADINE (movement data 07 iparam5)
|
||||
|
||||
MOVEMENT DATA 07 (ZU_CRATER)
|
||||
MOVEMENT DATA 08 (PAZUZU_CRATER)
|
||||
MOVEMENT DATA 1B (ZU_CRATER)
|
||||
MOVEMENT DATA 1C (PAZUZU_CRATER)
|
||||
fparam1 = TODO: 59NL:005B4A3C
|
||||
|
||||
MOVEMENT DATA 08 (PIG_RAY)
|
||||
MOVEMENT DATA 09 (UL_RAY)
|
||||
fparam1 = TODO: 3OE1:803072B0, 3OE1:80307354; speed?
|
||||
iparam1 = TODO: 3OE1:803075FC; frame count for something
|
||||
|
||||
MOVEMENT DATA 09 (ASTARK)
|
||||
fparam1 = TODO: 59NL:005A2B8F
|
||||
fparam2 = TODO: 59NL:005A2E1E
|
||||
fparam3 = TODO: 59NL:005A31D1
|
||||
fparam4 = TODO: 59NL:005A3124
|
||||
fparam5 = TODO: 59NL:005A4992
|
||||
fparam6 = TODO: 59NL:005A2B79
|
||||
iparam1 = TODO: 59NL:005A4947
|
||||
iparam2 = TODO: 59NL:005A499D
|
||||
|
||||
MOVEMENT DATA 0A (CHAOS_SORCERER)
|
||||
iparam1 = attack tech 1 level (Grants in Ultimate, Gizonde in non-Ultimate Ep2, Rafoie in non-Ultimate Ep1)
|
||||
iparam2 = attack teck 2 level (Megid in Ultimate, Gibarta otherwise)
|
||||
iparam3 = Resta level
|
||||
|
||||
MOVEMENT DATA 0B (BEE_R)
|
||||
MOVEMENT DATA 0C (BEE_L)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 0D (SATELLITE_LIZARD_CRATER)
|
||||
MOVEMENT DATA 0E (YOWIE_CRATER)
|
||||
MOVEMENT DATA 1D (SATELLITE_LIZARD_DESERT)
|
||||
MOVEMENT DATA 1E (YOWIE_DESERT)
|
||||
fparam1 = TODO: 59NL:005AEBC5; looks like an angle in degrees (range [0, 359])
|
||||
fparam2 = TODO: 59NL:005AEBEE
|
||||
|
||||
MOVEMENT DATA 0D (DARK_BRINGER)
|
||||
fparam1 = TODO: 3OE1:FUN_80097F98; NNF: charge speed
|
||||
fparam2 = TODO: 3OE1:FUN_800983F8; NNF: movement speed
|
||||
fparam6 = TODO: 3OE1:80097F3C; NNF: Regular attack cooldown. Delay between going red and shooting.
|
||||
iparam2 = TODO: 3OE1:FUN_80097F98; NNF: cooldown time after shooting
|
||||
iparam3 = damage for charge attack; 3OE1:80099128
|
||||
iparam4 = TODO: 3OE1:80097A30; NNF: laser attack damage
|
||||
iparam5 = TODO: 3OE1:FUN_800983F8; NNF: swing attack radius
|
||||
iparam6 = TODO: 3OE1:FUN_800983F8; NNF: charge attack radius (if player is outside this range)
|
||||
|
||||
MOVEMENT DATA 0D (DELBITER)
|
||||
fparam1 = TODO: 3OE1:80302D1C, 3OE1:80302B38, 3OE1:803033C8, 3OE1:8030344C; NNF: Charge speed
|
||||
fparam2 = TODO: 3OE1:80303124; NNF: Walking speed
|
||||
fparam3 = TODO: 3OE1:80304F00
|
||||
fparam4 = TODO: 3OE1:80304F10
|
||||
fparam5 = TODO: 3OE1:80302E34
|
||||
fparam6 = TODO: 3OE1:80302FD8; NNF: Charge radius (how far away you have to be before it charges).
|
||||
iparam1 = TODO: 3OE1:80302A6C
|
||||
iparam2 = TODO: 3OE1:803042F8
|
||||
iparam3 = TODO: 3OE1:80304368; NNF: Charge damage.
|
||||
iparam4 = TODO: 3OE1:80302414; related to TP absorption; NNF: Laser damage.
|
||||
iparam5 = TODO: 3OE1:803030A4; NNF: Radius at which Delbiter attempts foot stomp attack (the range at which that attack can hit you, however, is not modified).
|
||||
iparam6 = TODO: 3OE1:8030267C
|
||||
|
||||
MOVEMENT DATA 0E (DARK_BELRA)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 0F (DE_ROL_LE, BARBA_RAY)
|
||||
fparam1 = DE_ROL_LE; TODO: damage amount; 3OE1:800304A4
|
||||
fparam1 = BARBA_RAY; TODO: 3OE1:802E7980; damage for some attack; NNF: laser damage
|
||||
fparam2 = DE_ROL_LE; TODO: TObjectV8047ec78 which has no constructor, so this is unused?; 3OE1:80038FD8
|
||||
fparam2 = BARBA_RAY; TODO: 3OE1:802EDA38; TBoss7PhotonBullet_update; NNF: missile damage
|
||||
fparam3 = DE_ROL_LE; TODO: TBoss2Mine, appears to be mine explosion damage; 3OE1:800385E4; NNF: Missile damage
|
||||
fparam4 = DE_ROL_LE; TODO: multiplied by a random number in range [-1, 1] and added to pos.x; only happens if param5 passes
|
||||
fparam5 = DE_ROL_LE; TODO: probability of some kind (range [0, 1]); 3OE1:80030C80
|
||||
iparam1 = total HP
|
||||
iparam2 = HP until armor on joints falls off
|
||||
iparam3 = HP until mask falls off
|
||||
iparam4 = DE_ROL_LE; TODO: only used in Ultimate, in other difficulties 180 is used instead
|
||||
iparam5 = DE_ROL_LE; TODO: only used in Ultimate, in other difficulties 120 is used instead
|
||||
|
||||
MOVEMENT DATA 0F (DORPHON)
|
||||
MOVEMENT DATA 10 (DORPHON_ECLAIR)
|
||||
fparam1 = TODO: 59NL:005A832F, 59NL:005A8364, 59NL:005A8388, 59NL:005A8A9A, 59NL:005A9643, 59NL:005A96E5
|
||||
fparam2 = TODO: 59NL:005A8EC2, 59NL:005A903D
|
||||
fparam3 = TODO: 59NL:FUN_005A9ADC; minimum 0.1
|
||||
fparam4 = TODO: 59NL:FUN_005A9ADC; minimum 0.1
|
||||
fparam5 = TODO: 59NL:005A85AB
|
||||
fparam6 = TODO: 59NL:005A8F2D
|
||||
iparam1 = TODO: 59NL:005A8082
|
||||
iparam2 = TODO: 59NL:005A89C6 and many others
|
||||
iparam3 = TODO: 59NL:005A8477 and many others
|
||||
iparam4 = TODO: 59NL:005A79E6; looks like same as for DELBITER
|
||||
iparam5 = TODO: 59NL:005A8E4D
|
||||
iparam6 = TODO: 59NL:005A71DA; multiplied by 30
|
||||
|
||||
MOVEMENT DATA 11 (DRAGON, GOL_DRAGON)
|
||||
fparam1 = DRAGON; TODO: TBoss1DragonEffBreath
|
||||
fparam1 = GOL_DRAGON; TODO: 3OE1:802F98EC; damage for some attack
|
||||
fparam2 = DRAGON; TODO: TObjBoss1Crater_update, multiplied by 0.666 internally; TBoss1Dragon @ 3OE1:800276E0
|
||||
fparam2 = GOL_DRAGON; TODO: 3OE1:802F987C; damage for some attack
|
||||
fparam3 = DRAGON; TODO: 3OE1:8002787C
|
||||
fparam3 = GOL_DRAGON; TODO: 3OE1:802F9810; damage for some attack
|
||||
fparam4 = DRAGON; TODO: hitbox radius for something
|
||||
fparam4 = GOL_DRAGON; TODO: 3OE1:802F9DBC; range for some attack
|
||||
fparam5 = DRAGON; TODO: only used in Ultimate, in other difficulties 0.8 is used instead
|
||||
fparam5 = GOL_DRAGON; TODO: 3OE1:802F2FDC, 3OE1:802F38A8, 3OE1:802F3AFC, 3OE1:802F8800
|
||||
fparam6 = DRAGON; TODO: only used in Ultimate, in other difficulties 2.0 is used instead
|
||||
fparam6 = GOL_DRAGON; TODO: 3OE1:802F7BBC, 3OE1:802F7C34
|
||||
iparam1 = TODO: 3OE1:TBoss8Dragon_v58; damage amount for 1 hitbox
|
||||
iparam2 = TODO: 3OE1:TBoss8Dragon_v58; damage amount for 2 hitboxes
|
||||
iparam3 = TODO: 3OE1:TBoss8Dragon_v58; damage amount for 4 hitboxes
|
||||
iparam4 = GOL_DRAGON; clone HP
|
||||
iparam5 = GOL_DRAGON; TODO: 3OE1:802F32C8; which clone to create? (should be in range [0, 5])
|
||||
|
||||
MOVEMENT DATA 12 (GOL_DRAGON)
|
||||
fparam1 = TODO: 3OE1:FUN_802FC22C
|
||||
fparam2 = TODO: 3OE1:FUN_802FC22C
|
||||
fparam3 = TODO: 3OE1:FUN_802FC22C
|
||||
fparam4 = TODO: 3OE1:FUN_802FC22C
|
||||
fparam5 = TODO: 3OE1:FUN_802FC22C; same function as fparam1 but used when no clones exist?
|
||||
fparam6 = TODO: 3OE1:FUN_802FC22C; same function as fparam2 but used when no clones exist?
|
||||
|
||||
MOVEMENT DATA 13 (GOL_DRAGON)
|
||||
fparam1 = TODO: 3OE1:FUN_802FC22C; same function as movement data 12 fparam3 but used when no clones exist?
|
||||
fparam2 = TODO: 3OE1:FUN_802FC22C; same function as movement data 12 fparam4 but used when no clones exist?
|
||||
fparam3 = TODO: 3OE1:802FBDBC; HP for phase 2 to begin?
|
||||
fparam4 = TODO: 3OE1:802F6F24; scaling factor for a vector (speed/range?)
|
||||
|
||||
MOVEMENT DATA 19 (MERISSA_A)
|
||||
MOVEMENT DATA 1A (MERISSA_AA)
|
||||
fparam1 = TODO: 59NL:005B70AC
|
||||
fparam2 = TODO: 59NL:005B70AC
|
||||
fparam3 = TODO: 59NL:005B70AC
|
||||
fparam4 = TODO: 59NL:005B5750, 59NL:005B6101
|
||||
iparam1 = TODO: 59NL:005B56F8, 59NL:005B61DE; looks like an angle in degrees (range [0, 359])
|
||||
iparam2 = TODO: 59NL:005B5824; looks like an angle in degrees (range [0, 359])
|
||||
|
||||
MOVEMENT DATA 1A (NANO_DRAGON)
|
||||
fparam1 = horizontal flight speed
|
||||
fparam2 = straight laser speed
|
||||
fparam3 = homing laser speed (if set too low, it will go backwards)
|
||||
fparam4 = TODO: 3OE1:800D9C70; NNF: Homing laser projectile count (projectile number = number given).
|
||||
fparam5 = TODO: 3OE1:800D9C70; NNF: Homing laser arc.
|
||||
iparam1 = straight laser damage
|
||||
iparam2 = homing laser damage
|
||||
|
||||
MOVEMENT DATA 1A (GI_GUE)
|
||||
fparam1 = TODO: 3OE1:802CA8F4, 3OE1:802CAA04; looks like a scape factor; NNF: Speed when flying away.
|
||||
fparam2 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC; NNF: missile speed
|
||||
fparam3 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC; NNF: confuse projectile speed
|
||||
fparam4 = TODO: 3OE1:802CCA18
|
||||
fparam5 = TODO: 3OE1:802CC640
|
||||
fparam6 = TODO: 3OE1:802CA274; probability in range [0, 1]
|
||||
iparam1 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC; minimum value 40; NNF: Rafoie bomb attack damage
|
||||
iparam2 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC; NNF: Confusion projectile damage (affected by EFR).
|
||||
iparam3 = Jellen/Zalure level
|
||||
iparam4 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC
|
||||
iparam5 = TODO: 3OE1:TObjEneMe1GiGue_FUN_802C98FC; minimum value 20 in one scenario, 40 in another
|
||||
|
||||
MOVEMENT DATA 1B (DUBCHIC)
|
||||
MOVEMENT DATA 1C (GILLCHIC)
|
||||
fparam1 = TODO: 3OE1:FUN_800A89D4; NNF: Punch speed. Higher values means faster punches.
|
||||
fparam2 = punch attack range when not damaged
|
||||
fparam3 = TODO: 3OE1:800A8B64, 3OE1:800A9E98; only used when damaged, values when not damaged are 0.37037036 for DUBCHIC, 0.57037038 for GILLCHIC (unused since GILLCHIC dies instead of being damaged)
|
||||
fparam4 = TODO: 3OE1:FUN_800A89D4
|
||||
fparam5 = TODO: 3OE1:FUN_800A89D4; NNF: Punch speed and movement speed when damaged
|
||||
fparam6 = punch attack range when damaged
|
||||
iparam1 = number of frames after kill before revive sequence starts (Dubchic only)
|
||||
iparam2 = TODO: 3OE1:800A8F9C; NNF: Laser charge time
|
||||
iparam3 = TODO: 3OE1:800A9B40; NNF: Number of invicibility frames after knockdown
|
||||
iparam4 = laser damage
|
||||
|
||||
MOVEMENT DATA 1D (GARANZ)
|
||||
fparam1 = TODO: 3OE1:800D320C; NNF: Distance travelled every movement phase. Speed is unaffected, so it can take a long time before it stops to shoot.
|
||||
fparam2 = TODO: 3OE1:TObjEneGyaranzo_set_movement_params; NNF: Movement speed. This not only makes the Garanz faster, but ends the movement phase sooner, so it gets around to shooting missiles faster too. Doesn't work well without a value in fparam1.
|
||||
fparam3 = TODO: 3OE1:TObjEneGyaranzo_set_movement_params; NNF: TODO
|
||||
fparam4 = missile speed
|
||||
fparam5 = TODO: 3OE1:TObjEneGyaranzo_set_movement_params; NNF: Missile launch arc. Defines how tight the downward curve of the missile (once launched) towards the player is. Set to 0, missiles travel straight into the ceiling and cannot hit the player.
|
||||
iparam1 = TODO: 3OE1:800D2C4C; NNF: Number of frames waited after shooting before commencing movement again. Garanz does have a lower limit and will not wait 0 frames before starting again.
|
||||
iparam2 = TODO: 3OE1:800D2254; NNF: Missile launch cooldown
|
||||
iparam3 = TODO: 3OE1:800D46A8; missile damage
|
||||
iparam4 = TODO: 3OE1:800D40FC; NNF: Mine Damage
|
||||
|
||||
MOVEMENT DATA 1E (DARK_GUNNER)
|
||||
fparam1 = TODO: 3OE1:800A0F44, 3OE1:800A11D0
|
||||
fparam2 = TODO: 3OE1:800A24F8
|
||||
fparam3 = TODO: 3OE1:800A1C4C; seems to be a distance limit / radius of some sort
|
||||
fparam4 = TODO: 3OE1:800A1104; NNF: laser speed
|
||||
iparam1 = charge time after windup sound and before laser shot
|
||||
iparam2 = TODO: 3OE1:800A12A4; NNF: Length of time vulnerability remains after being damaged (lower=shorter)
|
||||
iparam3 = TODO: 3OE1:800A3190; NNF: Duration of invincibility (close to 0 will be no invincibility).
|
||||
iparam4 = laser shot damage
|
||||
|
||||
MOVEMENT DATA 1E (GAL_GRYPHON)
|
||||
fparam1 = TODO: 3OE1:80065DEC; NNF: Y Value Camera adjustment when Gal lands
|
||||
fparam2 = TODO: 3OE1:80065DEC; NNF: X Value Camera adjustment when Gal lands
|
||||
fparam3 = TODO: 3OE1:80065DEC; NNF: Y Value Camera adjustment when Gal lands (cam location)
|
||||
fparam4 = TODO: 3OE1:80065DEC; NNF: Adjusts Camera near or far to player
|
||||
fparam5 = TODO: 3OE1:80065DEC; same as fparam1 but for a different situation (A); NNF: Lowers/Raises the Camera when Gal is flying
|
||||
fparam6 = TODO: 3OE1:80065DEC; same as fparam2 but for a different situation (A)
|
||||
|
||||
MOVEMENT DATA 1F (BULCLAW)
|
||||
iparam1 = TODO: 3OE1:8008F8C8; percentage (0-100) of max HP; NNF: % chance it does it's suicide attack once split into a Bulk, you need to attack it once
|
||||
|
||||
MOVEMENT DATA 1F (GAL_GRYPHON)
|
||||
fparam1 = TODO: 3OE1:80065DEC; same as data 1E fparam3 but for a different situation (A); NNF: (BULCLAW) Aggro Range?
|
||||
fparam2 = TODO: 3OE1:80065DEC; same as data 1E fparam4 but for a different situation (A)
|
||||
fparam3 = TODO: 3OE1:80065DEC; same as data 1E fparam1 but for a different situation (B)
|
||||
fparam4 = TODO: 3OE1:80065DEC; same as data 1E fparam2 but for a different situation (B)
|
||||
fparam5 = TODO: 3OE1:80065DEC; same as data 1E fparam3 but for a different situation (B)
|
||||
fparam6 = TODO: 3OE1:80065DEC; same as data 1E fparam4 but for a different situation (B)
|
||||
|
||||
MOVEMENT DATA 1F (GIRTABLULU)
|
||||
fparam1 = TODO: 59NL:005ABDBD
|
||||
fparam2 = TODO: 59NL:005ABDB1
|
||||
fparam4 = TODO: 59NL:005ABD3C
|
||||
fparam5 = TODO: 59NL:005ABD45
|
||||
fparam6 = TODO: 59NL:005ABD08; looks like an angle in degrees (range [0, 359])
|
||||
iparam1 = TODO: 59NL:005AAB66, 59NL:005AAD18
|
||||
iparam3 = TODO: 59NL:005AA9FA
|
||||
iparam4 = TODO: 59NL:005AA85B
|
||||
iparam5 = TODO: 59NL:005AAF20; length of time in frames?
|
||||
iparam6 = TODO: 59NL:005AA5FD
|
||||
|
||||
MOVEMENT DATA 20 (BULCLAW)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 20 (GAL_GRYPHON)
|
||||
fparam1 = TODO: 3OE1:FUN_80064064; damage scaling factor for some attack (TBoss5GryphonSnarl)
|
||||
fparam2 = TODO: 3OE1:80064130; damage amount for shock wave attack (TBoss5GryphonShockWave)
|
||||
fparam3 = TODO: 3OE1:80064130; damage amount for tornado attack (TBoss5GryphonTornado)
|
||||
fparam4 = TODO: 3OE1:80064044; damage amount for some attack
|
||||
fparam5 = TODO: 3OE1:8006475C; hitbox radius for some attack?
|
||||
iparam1 = TODO: 3OE1:TBoss5Gryphon_V58; damage amount for 1 hitbox
|
||||
iparam2 = TODO: 3OE1:TBoss5Gryphon_V58; damage amount for 4 hitboxes
|
||||
iparam3 = TODO: 3OE1:TBoss5Gryphon_V58; damage amount for 1 hitbox
|
||||
iparam4 = TODO: 3OE1:TBoss5Gryphon_V58; damage amount for 4 hitboxes
|
||||
iparam5 = TODO: 3OE1:TBoss5Gryphon_FUN_8005F0F0, 3OE1:800609D0
|
||||
|
||||
MOVEMENT DATA 20 (SAINT_MILLION_1)
|
||||
MOVEMENT DATA 22 (SAINT_MILLION_2)
|
||||
MOVEMENT DATA 24 (SHAMBERTIN_1)
|
||||
MOVEMENT DATA 26 (SHAMBERTIN_2)
|
||||
MOVEMENT DATA 28 (KONDRIEU_1)
|
||||
MOVEMENT DATA 2A (KONDRIEU_2)
|
||||
iparam1 = TODO: 59NL:00768990, 59NL:00768A84
|
||||
iparam2 = TODO: 59NL:00768990, 59NL:00768A84
|
||||
iparam3 = TODO: 59NL:00768990, 59NL:00768A84
|
||||
iparam4 = TODO: 59NL:00768990, 59NL:00768A84
|
||||
iparam5 = TODO: 59NL:00768990, 59NL:00768A84
|
||||
|
||||
MOVEMENT DATA 21 (SAINT_MILION_SPINNER, 0/4/8/12)
|
||||
MOVEMENT DATA 23 (SAINT_MILION_SPINNER, other indexes)
|
||||
MOVEMENT DATA 25 (SHAMBERTIN_SPINNER, 0/4/8/12)
|
||||
MOVEMENT DATA 27 (SHAMBERTIN_SPINNER, other indexes)
|
||||
MOVEMENT DATA 29 (KONDRIEU_SPINNER, 0/4/8/12)
|
||||
MOVEMENT DATA 2B (KONDRIEU_SPINNER, other indexes)
|
||||
iparam1 = TODO: 59NL:0076D40D
|
||||
|
||||
MOVEMENT DATA 21 (VOL_OPT_1)
|
||||
iparam1 = speed of moving around in the screens
|
||||
|
||||
MOVEMENT DATA 22 (VOL_OPT_1)
|
||||
iparam1 = damage for electrical attack
|
||||
|
||||
MOVEMENT DATA 23 (VOL_OPT_1)
|
||||
iparam1 = large monitors' HP
|
||||
iparam2 = small monitors' HP
|
||||
|
||||
MOVEMENT DATA 23 (EPSILON)
|
||||
fparam2 = TODO: 3OE1:8035FDB4; scale factor for vector; NNF: Laser tracking speed.
|
||||
fparam3 = TODO: 3OE1:8035FF08; NNF: Rafoie damage (based on MST).
|
||||
iparam1 = TODO: 3OE1:8035FD60; NNF: Controls how long the laser tracks players before casting Rafoie (number of Rafoies shot is tied to this - shorter tracking time means more Rafoies).
|
||||
iparam2 = TODO: 3OE1:8035FE40; NNF: Delay between when Rafoie stops and next laser begins.
|
||||
iparam3 = TODO: 3OE1:8035E44C, 3OE1:803608C0; NNF: Cooldown on Epsigard tech activation.
|
||||
iparam4 = TODO: 3OE1:8035F850; NNF: Epsigard attack radius.
|
||||
|
||||
MOVEMENT DATA 24 (VOL_OPT)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 24 (EPSIGARD)
|
||||
fparam1 = TODO: 3OE1:8035CB58, 3OE1:8035CD1C, 3OE1:8035D3B4; NNF: Epsigard circle radius.
|
||||
fparam2 = TODO: 3OE1:8035CD20; NNF: Speed at which Epsigards eject from Epsilon. Epsigards always eject for a second, so fast eject speeds will project them far. They will then spin come back in to fparam1 radius.
|
||||
fparam3 = TODO: 3OE1:8035CB50, 3OE1:8035CBFC; NNF: Epsigard rotation speed.
|
||||
fparam4 = TODO: 3OE1:8035D0CC; NNF: Damage dealt per Epsigard hit.
|
||||
iparam1 = TODO: 3OE1:8035CF28; NNF: Seems to affect Epsigard damage radius. At 120, can't get hit from the front, can only gt hit from a specific position from the back and to the side.
|
||||
|
||||
MOVEMENT DATA 25 (VOL_OPT_2)
|
||||
fparam1 = TODO: specifies length of a vector; NNF: missile speed; 3OE1:80049CB0
|
||||
fparam2 = TODO: specifies length of a vector; 3OE1:80049C94
|
||||
fparam3 = TODO: NNF: knockback distance when hit by pillar; player gets rotated in a random direction, and then moved backwards from that direction
|
||||
fparam4 = TODO: 3OE1:80049FE0; NNF: Homing pillar stomp: Affects cooldown of third pillar ('fast' pillar variants only).
|
||||
fparam5 = TODO: add param for random generation for pillar stomp; NNF: Homing pillar stomp: Affects cooldown of second pillar ('fast' pillar variants only).
|
||||
fparam6 = TODO: mult param for random generation for pillar stomp; final value is (random(0, 1) * fparam5) + fparam4; 3 values generated in total; NNF: Homing pillar stomp: Affects cooldown of first pillar ('fast' pillar variants only).
|
||||
iparam1 = TODO: NNF: missile damage
|
||||
iparam2 = TODO: NNF: pillar damage
|
||||
iparam3 = TODO: NNF: trap laser damage
|
||||
iparam4 = HP recovery amount * 5 (so e.g. 2500 here means 500HP)
|
||||
iparam5 = TODO: NNF: Charge time of trap laser attack; value used is max(10, iparam5 + 120); but used in multiple places! which is which? 3OE1:800490D0 3OE1:8004661C
|
||||
iparam6 = TODO: related to TObjVoloptPillar; 3OE1:80044ACC, 3OE1:80047110, 3OE1:8004A24C; NNF: Homing pillar stomp: Cooldown for each pillar drop. Longer is higher.
|
||||
|
||||
MOVEMENT DATA 26 (VOL_OPT_2)
|
||||
fparam1 = TODO: specifies length of a vector; 3OE1:80049778, 3OE1:800499E8; NNF: Ball speed for laser floor trap
|
||||
fparam2 = TODO: specifies length of a vector; 3OE1:8004975C
|
||||
iparam1 = TODO: looks like lifetime in frames for a subordinate; 3OE1:80049A14; NNF: Ball chase duration
|
||||
iparam2 = TODO: 3OE1:8004490C; looks like an angular velocity?; NNF: Amount of wait time taken for rotating pillars to first attack
|
||||
|
||||
MOVEMENT DATA 26 (ILL_GILL)
|
||||
fparam1 = TODO: 3OE1:803642E8, 3OE1:80363DBC, 3OE1:80363FCC; NNF: Affects charge speed and cooldown time.
|
||||
fparam2 = TODO: 3OE1:80364F3C; NNF: Scythe attack speed.
|
||||
iparam1 = TODO: 3OE1:80365324, 3OE1:803652CC; weapon special amount; NNF: Seems to affect how much damage the lightning scythe attack does, and how effective the megid scythe attack is (lower is less effective)
|
||||
iparam2 = TODO: 3OE1:8036537C; weapon special amount; NNF: Seems to affect how much damage the lightning scythe attack does, and how effective the megid scythe attack is (lower is less effective)
|
||||
|
||||
MOVEMENT DATA 27 (VOL_OPT; used in Vol Opt phase 1?)
|
||||
MOVEMENT DATA 28 (VOL_OPT; used when no player is caught by the Vol Opt cage)
|
||||
MOVEMENT DATA 29 (VOL_OPT; used when any player is caught by the Vol Opt cage)
|
||||
fparam1 = TODO: param to some camera logic
|
||||
fparam2 = TODO: param to some camera logic
|
||||
fparam3 = TODO: param to some camera logic
|
||||
fparam4 = TODO: param to some camera logic
|
||||
iparam1 = TODO: entire movement data is unused if this is zero; 3OE1:TBoss3Volopt_FUN_8003EB6C
|
||||
|
||||
MOVEMENT DATA 2A (VOL_OPT_2)
|
||||
iparam1 = TODO: only has effect if nonzero; 3OE1:80048074
|
||||
|
||||
MOVEMENT DATA 2B (OLGA_FLOW_1)
|
||||
fparam1 = TODO: 3OE1:802B6190, 3OE1:803547F4; must be >0, default 20; NNF: sword damage
|
||||
fparam2 = TODO: 3OE1:80320F84; NNF: Olga Flow 1 shot (ball) damage
|
||||
fparam3 = TODO: 3OE1:802B5DD0; must be >0, default 20; NNF: tail swipe damage
|
||||
fparam4 = TODO: 3OE1:802B5980; must be >0, default 20; NNF: shot (beam) damage
|
||||
fparam5 = TODO: 3OE1:802B5668; must be >0, default 20; NNF: gravity trap attack damage
|
||||
fparam6 = TODO: 3OE1:802B2620; must be >0, default 7; NNF: delay between attacks (lower is faster)
|
||||
iparam1 = TODO: 3OE1:802B4970; looks like damage threshold; must be >0, default 200; NNF: Docile Mode HP Threshold
|
||||
iparam2 = TODO: 3OE1:802B4A50; looks like damage threshold; must be >0, default 200; NNF: Sky/Floor Sword HP to trigger
|
||||
iparam3 = TODO: 3OE1:802B49C0; must be >0, default 200; NNF: Sky/Floor Sword HP to cancel
|
||||
iparam4 = TODO: 3OE1:802B4924; must be >0, default 200; NNF: Gravity Trap Attack HP Threshold
|
||||
iparam5 = TODO: 3OE1:802B694C; seems to not be read - missing label?; must be >0, default 90; NNF: Shot charge-up duration (lower is shorter)
|
||||
iparam6 = TODO: 3OE1:TBoss6Type1_FUN_802B1CA8; must be >0, default 180; NNF: Movement speed and duration during charge-up shot (lower is faster/shorter)
|
||||
|
||||
MOVEMENT DATA 2C (OLGA_FLOW_2)
|
||||
fparam1 = TODO: 3OE1:80354FBC; NNF: Olga Flow 2 sword damage (lower is less)
|
||||
fparam2 = TODO: 3OE1:802BB218; must be >0, default is 20; NNF: Foot damage
|
||||
fparam5 = TODO: 3OE1:802BB218; must be >0, default is 20; NNF: Wrong attribute damage dealt during soul steal (physical - lower is less)
|
||||
fparam3 = TODO: 3OE1:80354FEC, 3OE1:8035BF80; NNF: Olga Flow 2 Divine Punishment damage (lower is less)
|
||||
fparam4 = rock damage; must be > 0; default 20
|
||||
fparam6 = TODO: 3OE1:802BB218; must be >0, default is 60; NNF: Rock fall duration during soul steal (lower is less)
|
||||
iparam1 = TODO: 3OE1:802BB218; must be >0, default is 200; NNF: Amount of damage to trigger Divine Punishment
|
||||
iparam2 = TODO: 3OE1:802BB218; must be >0, default is 200; NNF: Amount of damage it takes to go into soul steal state
|
||||
iparam3 = TODO: 3OE1:802BB218; must be >0, default is 200; NNF: Amount of damage to knock Olga Flow out of soul steal state
|
||||
iparam4 = TODO: 3OE1:802BB218; must be >0, default is 60; NNF: Delay between attacks (lower is faster)
|
||||
iparam5 = TODO: 3OE1:802BB218; must be in range [0, 100] with iparam5 + iparam6 <= 100, default is 25, used as a probability along with iparam6; NNF: Form 1's Total HP% Trigger to halve Attack delays
|
||||
iparam6 = TODO: 3OE1:802BB218; must be in range [0, 100] with iparam5 + iparam6 <= 100, default is 10, used as a probability along with iparam5
|
||||
|
||||
MOVEMENT DATA 2D (OLGA_FLOW_1, OLGA_FLOW_2)
|
||||
fparam1 = OLGA_FLOW_1; TODO: 3OE1:80323128; TBoss6Mine; default 20; NNF: Trap damage Form 1
|
||||
fparam2 = OLGA_FLOW_2; TODO: 3OE1:8036773C; TBoss6MagMine; must be >0, default 20; NNF: Trap damage Form 2
|
||||
fparam3 = OLGA_FLOW_2; TODO: 3OE1:8036778C; TBoss6MagMine; must be in range [0, 100], default 0
|
||||
|
||||
MOVEMENT DATA 2E (OLGA_FLOW_2)
|
||||
fparam1 = TODO: 3OE1:8032EE24; TBoss6Mag; NNF: Amount of time Gael/Giel stays dead (lower is shorter)
|
||||
fparam2 = TODO: 3OE1:8032EE74; TBoss6Mag; NNF: Gael/Giel Chase speed during Divine Punishment
|
||||
fparam3 = TODO: 3OE1:802BB218; must be >0, default 1; used instead of movement data 2F fparam1 if a certain flag is set; NNF: Olga Flow's normal movement speed after some threshold
|
||||
fparam4 = TODO: 3OE1:802BB218; must be >0, default 1; used instead of movement data 2F fparam2 if a certain flag is set; NNF: Olga Flow's movement speed during soul steal after some threshold
|
||||
|
||||
MOVEMENT DATA 2F (OLGA_FLOW_1, OLGA_FLOW_2)
|
||||
fparam1 = OLGA_FLOW_2; TODO: 3OE1:802BB218; must be >0, default 1
|
||||
fparam2 = OLGA_FLOW_2; TODO: 3OE1:802BB218; must be >0, default 1
|
||||
fparam3 = OLGA_FLOW_2; TODO: 3OE1:802BB218, 3OE1:8035BFB0; must be >0, default 1; damage reduction for movement data 2C fparam2?, only applies if a certain flag is set
|
||||
fparam4 = OLGA_FLOW_2; TODO: 3OE1:802BB218; must be >0, default 120; looks like duration for something
|
||||
fparam5 = OLGA_FLOW_1; TODO: 3OE1:80320FB4; also related to shot/ball attack
|
||||
fparam6 = OLGA_FLOW_1; TODO: 3OE1:802B694C; must be >0, default 7; same as movement data 2B fparam6 but used when a certain flag is enabled
|
||||
|
||||
MOVEMENT DATA 30 (POFUILLY_SLIME)
|
||||
MOVEMENT DATA 34 (POUILLY_SLIME)
|
||||
fparam1 = spit attack damage * 5 (so e.g. 1000 here means 200 damange)
|
||||
|
||||
MOVEMENT DATA 30 (DELDEPTH)
|
||||
fparam1 = TODO: 3OE1:80312E04; NNF: Movement speed (Disk form).
|
||||
fparam2 = TODO: 3OE1:80312E1C; NNF: Distance travelled per movement (Disk form).
|
||||
iparam1 = attack tech level (Megid in Ultimate; Barta in other difficulties); also bomb power? (TODO: 3OE1:80312490)
|
||||
iparam2 = TODO: 3OE1:80312AE0; NNF: Rotation speed (Unfolded form) - lower is slower.
|
||||
|
||||
MOVEMENT DATA 31 (PAN_ARMS)
|
||||
fparam1 = TODO: 3OE1:800DF31C
|
||||
fparam2 = TODO: 3OE1:800E36DC; NNF: Blue laser damage
|
||||
fparam3 = TODO: 3OE1:800E36DC; NNF: Red laser damage
|
||||
iparam1 = TODO: 3OE1:800DF32C; value is max(iparam1, 5); NNF: spawn radius
|
||||
iparam2 = TODO: 3OE1:800DF350; value is max(iparam2, 0); NNF: spawn speed in frames
|
||||
|
||||
MOVEMENT DATA 32 (HIDOOM)
|
||||
MOVEMENT DATA 33 (MIGIUM)
|
||||
fparam1 = TODO: 3OE1:800E2640
|
||||
fparam2 = TODO: 3OE1:800E2650; NNF: stab damage
|
||||
fparam3 = MIGIUM; TODO: 3OE1:800E26AC
|
||||
iparam1 = MIGIUM; Resta level, must be in range [0, 14]; NNF: Jellen level
|
||||
iparam2 = MIGIUM; Jellen level, must be in range [0, 14]; NNF: Zalure level
|
||||
iparam3 = MIGIUM; Zalure level, must be in range [0, 14]; NNF: Resta level
|
||||
|
||||
MOVEMENT DATA 35 (DARVANT)
|
||||
fparam1 = TODO: must be in range [0.33333334, 5.833333]; 3OE1:8005D5E0; NNF: Attack speed
|
||||
iparam1 = number of Darvants that must be killed before phase ends (actual value is player count * iparam1); must be in range [1, 19]
|
||||
|
||||
MOVEMENT DATA 36 (DARK_FALZ_1)
|
||||
fparam1 = NNF: movement speed; must be in range [1, 60]; used as reciprocal (see 3OE1:80052F60) so lower is faster
|
||||
iparam1 = Rafoie level, expected to be in range [0, 14]
|
||||
iparam2 = Rabarta level, expected to be in range [0, 14]
|
||||
iparam3 = TODO: 3OE1:FUN_80054DE0; NNF: Dark Falz 1 Divine Punishment strength (Also based on MST)
|
||||
|
||||
MOVEMENT DATA 37 (DARK_FALZ_2)
|
||||
fparam1 = TODO: 3OE1:80057BE4; value used is clamp(floor(fparam1), 1, 25) * 75 - 7; appears angle-related; 3OE1:8005653C; NNF: Movement speed (backwards, lower is faster).
|
||||
iparam1 = TODO: must be in range [1, 4], chooses between 4 different actions in a certain situation, named MD_STOP1 through MD_STOP4; 3OE1:80056358
|
||||
iparam2 = TODO: Resta level; 3OE1:80056994
|
||||
|
||||
MOVEMENT DATA 38 (DARK_FALZ_3)
|
||||
fparam1 = TODO: 3OE1:80050CA4
|
||||
iparam1 = Grants level
|
||||
iparam2 = Megid level
|
||||
iparam3 = number of pairs of homing attacks (TObjDFHorming) to launch at once; must be in range [1, 8]
|
||||
iparam4 = TODO: 3OE1:8005B14C; NNF: HP threshold to soul steal
|
||||
iparam5 = TODO: 3OE1:80050C94; NNF: Ball attack damage. (with 3000/10 MST, does 700 Damage)
|
||||
|
||||
MOVEMENT DATA 39 (DARVANT, DARK_FALZ_1)
|
||||
fparam1 = DARVANT; TODO: must be in range [0.33333334, 10.208332]; 3OE1:8005D618; NNF: Attack speed
|
||||
iparam1 = DARK_FALZ_1; TODO: number of Darvants to spawn at a time?; clamped to [1, 6]; 3OE1:80054CF0
|
||||
|
||||
MOVEMENT DATA 3A (MERICAROL)
|
||||
MOVEMENT DATA 45 (MERIKLE)
|
||||
MOVEMENT DATA 46 (MERICUS)
|
||||
fparam1 = TODO: 3OE1:802CE110; NNF: rush damage
|
||||
fparam2 = poison cloud damage
|
||||
fparam3 = TODO: 3OE1:802CEAA8; NNF: Spit 'attack capability'. Set to 1, attack does nothing and does not register as a hit.
|
||||
fparam4 = TODO: 3OE1:802CEAB0; NNF: Projectile speed; also affects the cooldown time between each shot.
|
||||
fparam5 = poison cloud radius
|
||||
fparam6 = TODO: 3OE1:802CD890; probability in range [0, 1]; NNF: Level of 'Megidness'. Value of 1 treats the attack as megid, despite fparam3.
|
||||
iparam3 = TODO: 3OE1:802CED14; NNF: Projectile fire rate.
|
||||
iparam4 = TODO: 3OE1:802CD7FC; NNF: Charge up time for poison cloud attack.
|
||||
iparam5 = TODO: 3OE1:802CE850; NNF: Melee attack cooldown time.
|
||||
iparam6 = TODO: 3OE1:802CEA30
|
||||
|
||||
MOVEMENT DATA 3B (UL_GIBBON)
|
||||
MOVEMENT DATA 3C (ZOL_GIBBON)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 3D (GIBBLES)
|
||||
fparam2 = TODO: 3OE1:802D7F5C; NNF: Triple-punch attack cooldown.
|
||||
fparam3 = TODO: 3OE1:802D8BC0; NNF: Movement speed.
|
||||
fparam4 = TODO: 3OE1:802D7490; NNF: Jump cooldown time (Higher value = less waiting time).
|
||||
iparam1 = TODO: 3OE1:802D7484
|
||||
|
||||
MOVEMENT DATA 40 (MORFOS)
|
||||
fparam1 = laser speed; hitbox radius is fparam1 * 1.5
|
||||
fparam2 = laser damage
|
||||
iparam1 = TODO: 3OE1:80332298, 3OE1:803321C4; NNF: Firing rate of regular laser attack. Laser attack when aggressive (charging) is unaffected.
|
||||
iparam2 = TODO: 3OE1:8033161C, 3OE1:8033192C, 3OE1:80331B4C, 3OE1:80331D00, 3OE1:80331FA0; NNF: Speed at which Morphos spins after firing laser.
|
||||
iparam3 = TODO: 3OE1:80331F04; NNF: Interval in frames of attacks
|
||||
iparam4 = TODO: 3OE1:803318EC; NNF: Charge frames before attacking without hitstun.
|
||||
iparam5 = TODO: 3OE1:803318CC; NNF: Affects charge laser tracking. Too high and doesnt lock-on. Need Research
|
||||
|
||||
MOVEMENT DATA 41 (RECOBOX)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 42 (RECON)
|
||||
fparam1 = TODO: 3OE1:8031C31C; NNF: Chase speed for buzzsaw attack
|
||||
fparam2 = bomb explosion radius
|
||||
fparam3 = bomb damage
|
||||
fparam4 = TODO: 3OE1:8031A144; NNF: bomb throw distance
|
||||
iparam1 = TODO: 3OE1:80319DCC; bomb frames until explosion?; NNF: Speed recon comes out of the recobox. As it always takes the same amount of 'time' to come out, higher values make it go high up as well as fast.
|
||||
iparam2 = TODO: 3OE1:8031B68C; NNF: Frame delay from when Recon gets in position to when it activates buzzsaw.
|
||||
|
||||
MOVEMENT DATA 43 (SINOW_ZOA)
|
||||
MOVEMENT DATA 44 (SINOW_ZELE)
|
||||
fparam1 = TODO: 3OE1:80317B7C; NNF: Movement speed
|
||||
fparam3 = TODO: 3OE1:803173F4; NNF: Speed at which Sinow Zoa/Zele reappears after warping.
|
||||
fparam4 = TODO: 3OE1:80319960; NNF: Attack speed
|
||||
fparam5 = TODO: 3OE1:80319968
|
||||
fparam6 = TODO: 3OE1:80316F84
|
||||
iparam1 = Resta/Shifta/Deband/Jellen/Zalure level
|
||||
iparam2 = TODO: 3OE1:80316BE8
|
||||
iparam3 = TODO: 3OE1:80317458; NNF: Cooldown time for all attacks.
|
||||
iparam4 = attack tech level (Rabarta in Ultimate, Gibarta otherwise)
|
||||
|
||||
MOVEMENT DATA 48 (HILDEBEAR)
|
||||
MOVEMENT DATA 49 (HILDEBLUE)
|
||||
fparam1 = punch attack speed
|
||||
fparam2 = TODO: 3OE1:800ADBE0; NNF: tech range
|
||||
fparam3 = movement speed (does not affect animation speed)
|
||||
fparam4 = walking animation speed
|
||||
|
||||
MOVEMENT DATA 4D (GRASS_ASSASSIN)
|
||||
(loaded with assets but not used)
|
||||
|
||||
MOVEMENT DATA 51 (DELSABER)
|
||||
fparam1 = TODO: 3OE1:800A5454
|
||||
fparam2 = TODO: 3OE1:800A5708
|
||||
fparam3 = TODO: 3OE1:800A5CA4
|
||||
fparam4 = TODO: 3OE1:800A5D04
|
||||
+70
-70
@@ -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]
|
||||
@@ -557,32 +557,32 @@ JP12------------- JP13------------- JP14------------- JP15------------- US10----
|
||||
8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 8000C6E8 807F0024 lwz r3, [r31 + 0x0024]
|
||||
8000C6EC 48165AA0 8000C6EC 482147D4 8000C6EC 482156C0 8000C6EC 48215474 8000C6EC 482146F4 8000C6EC 482146F4 8000C6EC 482157A8 8000C6EC 48215040 b +0x002146F4 /* 80220DE0 */
|
||||
8021D098 4BDEF638 8021D9FC 4BDEECD4 8021E8E8 4BDEDDE8 8021E69C 4BDEE034 8021D91C 4BDEEDB4 8021D91C 4BDEEDB4 8021E9D0 4BDEDD00 8021E268 4BDEE468 b -0x0021124C /* 8000C6D0 */
|
||||
80172188 4BE9A558 80220EBC 4BDEB824 80221DA8 4BDEA938 80221B5C 4BDEAB84 80220DDC 4BDEB904 80220DDC 4BDEB904 80221E90 4BDEA850 80221728 4BDEAFB8 b -0x002146FC /* 8000C6E0 */
|
||||
80220528 4BE9A558 80220EBC 4BDEB824 80221DA8 4BDEA938 80221B5C 4BDEAB84 80220DDC 4BDEB904 80220DDC 4BDEB904 80221E90 4BDEA850 80221728 4BDEAFB8 b -0x002146FC /* 8000C6E0 */
|
||||
|
||||
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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Binary file not shown.
Binary file not shown.
Executable → Regular
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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__
|
||||
@@ -0,0 +1,187 @@
|
||||
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 Rol Le 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
|
||||
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
|
||||
@@ -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())
|
||||
@@ -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
|
||||
+10
-12
@@ -23,7 +23,7 @@ AFSArchive::AFSArchive(shared_ptr<const string> data)
|
||||
le_uint32_t size;
|
||||
} __packed_ws__(FileEntry, 8);
|
||||
|
||||
StringReader r(*this->data);
|
||||
phosg::StringReader r(*this->data);
|
||||
const auto& header = r.get<FileHeader>();
|
||||
if (header.magic != 0x41465300) { // 'AFS\0'
|
||||
throw runtime_error("file is not an AFS archive");
|
||||
@@ -52,29 +52,27 @@ string AFSArchive::get_copy(size_t index) const {
|
||||
return string(reinterpret_cast<const char*>(ret.first), ret.second);
|
||||
}
|
||||
|
||||
StringReader AFSArchive::get_reader(size_t index) const {
|
||||
phosg::StringReader AFSArchive::get_reader(size_t index) const {
|
||||
auto ret = this->get(index);
|
||||
return StringReader(ret.first, ret.second);
|
||||
return phosg::StringReader(ret.first, ret.second);
|
||||
}
|
||||
|
||||
string AFSArchive::generate(const vector<string>& files, bool big_endian) {
|
||||
return big_endian ? AFSArchive::generate_t<true>(files) : AFSArchive::generate_t<false>(files);
|
||||
}
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
string AFSArchive::generate_t(const vector<string>& files) {
|
||||
using U32T = typename std::conditional<IsBigEndian, be_uint32_t, le_uint32_t>::type;
|
||||
|
||||
StringWriter w;
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(0x41465300); // 'AFS\0'
|
||||
w.put<U32T>(files.size());
|
||||
w.put<U32T<BE>>(files.size());
|
||||
|
||||
// It seems entries are aligned to 0x800-byte boundaries, and the file's
|
||||
// header is always 0x80000 (!) bytes, most of which is unused
|
||||
// It seems entries are aligned to 0x800-byte boundaries, and the file's header is always 0x80000 (!) bytes, most of
|
||||
// which is unused
|
||||
uint32_t data_offset = 0x80000;
|
||||
for (const auto& file : files) {
|
||||
w.put<U32T>(data_offset);
|
||||
w.put<U32T>(file.size());
|
||||
w.put<U32T<BE>>(data_offset);
|
||||
w.put<U32T<BE>>(file.size());
|
||||
data_offset = (data_offset + file.size() + 0x7FF) & (~0x7FF);
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -8,6 +8,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Types.hh"
|
||||
|
||||
class AFSArchive {
|
||||
public:
|
||||
AFSArchive(std::shared_ptr<const std::string> data);
|
||||
@@ -21,14 +23,18 @@ public:
|
||||
return this->entries;
|
||||
}
|
||||
|
||||
inline size_t num_entries() const {
|
||||
return this->entries.size();
|
||||
}
|
||||
|
||||
std::pair<const void*, size_t> get(size_t index) const;
|
||||
std::string get_copy(size_t index) const;
|
||||
StringReader get_reader(size_t index) const;
|
||||
phosg::StringReader get_reader(size_t index) const;
|
||||
|
||||
static std::string generate(const std::vector<std::string>& files, bool big_endian);
|
||||
|
||||
private:
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
static std::string generate_t(const std::vector<std::string>& files);
|
||||
|
||||
std::shared_ptr<const std::string> data;
|
||||
|
||||
+162
-125
@@ -2,6 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/Random.hh>
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
shared_ptr<DCNTELicense> DCNTELicense::from_json(const JSON& json) {
|
||||
shared_ptr<DCNTELicense> DCNTELicense::from_json(const phosg::JSON& json) {
|
||||
auto ret = make_shared<DCNTELicense>();
|
||||
ret->serial_number = json.get_string("SerialNumber");
|
||||
ret->access_key = json.get_string("AccessKey");
|
||||
@@ -30,14 +31,11 @@ shared_ptr<DCNTELicense> DCNTELicense::from_json(const JSON& json) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON DCNTELicense::json() const {
|
||||
return JSON::dict({
|
||||
{"SerialNumber", this->serial_number},
|
||||
{"AccessKey", this->access_key},
|
||||
});
|
||||
phosg::JSON DCNTELicense::json() const {
|
||||
return phosg::JSON::dict({{"SerialNumber", this->serial_number}, {"AccessKey", this->access_key}});
|
||||
}
|
||||
|
||||
shared_ptr<V1V2License> V1V2License::from_json(const JSON& json) {
|
||||
shared_ptr<V1V2License> V1V2License::from_json(const phosg::JSON& json) {
|
||||
auto ret = make_shared<V1V2License>();
|
||||
ret->serial_number = json.get_int("SerialNumber");
|
||||
ret->access_key = json.get_string("AccessKey");
|
||||
@@ -50,14 +48,11 @@ shared_ptr<V1V2License> V1V2License::from_json(const JSON& json) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON V1V2License::json() const {
|
||||
return JSON::dict({
|
||||
{"SerialNumber", this->serial_number},
|
||||
{"AccessKey", this->access_key},
|
||||
});
|
||||
phosg::JSON V1V2License::json() const {
|
||||
return phosg::JSON::dict({{"SerialNumber", this->serial_number}, {"AccessKey", this->access_key}});
|
||||
}
|
||||
|
||||
shared_ptr<GCLicense> GCLicense::from_json(const JSON& json) {
|
||||
shared_ptr<GCLicense> GCLicense::from_json(const phosg::JSON& json) {
|
||||
auto ret = make_shared<GCLicense>();
|
||||
ret->serial_number = json.get_int("SerialNumber");
|
||||
ret->access_key = json.get_string("AccessKey");
|
||||
@@ -74,15 +69,15 @@ shared_ptr<GCLicense> GCLicense::from_json(const JSON& json) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON GCLicense::json() const {
|
||||
return JSON::dict({
|
||||
phosg::JSON GCLicense::json() const {
|
||||
return phosg::JSON::dict({
|
||||
{"SerialNumber", this->serial_number},
|
||||
{"AccessKey", this->access_key},
|
||||
{"Password", this->password},
|
||||
});
|
||||
}
|
||||
|
||||
shared_ptr<XBLicense> XBLicense::from_json(const JSON& json) {
|
||||
shared_ptr<XBLicense> XBLicense::from_json(const phosg::JSON& json) {
|
||||
auto ret = make_shared<XBLicense>();
|
||||
ret->gamertag = json.get_string("GamerTag");
|
||||
ret->user_id = json.get_int("UserID");
|
||||
@@ -99,15 +94,11 @@ shared_ptr<XBLicense> XBLicense::from_json(const JSON& json) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON XBLicense::json() const {
|
||||
return JSON::dict({
|
||||
{"GamerTag", this->gamertag},
|
||||
{"UserID", this->user_id},
|
||||
{"AccountID", this->account_id},
|
||||
});
|
||||
phosg::JSON XBLicense::json() const {
|
||||
return phosg::JSON::dict({{"GamerTag", this->gamertag}, {"UserID", this->user_id}, {"AccountID", this->account_id}});
|
||||
}
|
||||
|
||||
shared_ptr<BBLicense> BBLicense::from_json(const JSON& json) {
|
||||
shared_ptr<BBLicense> BBLicense::from_json(const phosg::JSON& json) {
|
||||
auto ret = make_shared<BBLicense>();
|
||||
ret->username = json.get_string("UserName");
|
||||
ret->password = json.get_string("Password");
|
||||
@@ -126,16 +117,14 @@ shared_ptr<BBLicense> BBLicense::from_json(const JSON& json) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON BBLicense::json() const {
|
||||
return JSON::dict({
|
||||
{"UserName", this->username},
|
||||
{"Password", this->password},
|
||||
});
|
||||
phosg::JSON BBLicense::json() const {
|
||||
return phosg::JSON::dict({{"UserName", this->username}, {"Password", this->password}});
|
||||
}
|
||||
|
||||
Account::Account(const JSON& json)
|
||||
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 +173,7 @@ Account::Account(const 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 +202,7 @@ Account::Account(const 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 +211,7 @@ Account::Account(const 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", "");
|
||||
@@ -237,38 +227,38 @@ Account::Account(const JSON& json)
|
||||
}
|
||||
}
|
||||
|
||||
JSON Account::json() const {
|
||||
JSON dc_nte_json = JSON::list();
|
||||
phosg::JSON Account::json() const {
|
||||
phosg::JSON dc_nte_json = phosg::JSON::list();
|
||||
for (const auto& it : this->dc_nte_licenses) {
|
||||
dc_nte_json.emplace_back(it.second->json());
|
||||
}
|
||||
JSON dc_json = JSON::list();
|
||||
phosg::JSON dc_json = phosg::JSON::list();
|
||||
for (const auto& it : this->dc_licenses) {
|
||||
dc_json.emplace_back(it.second->json());
|
||||
}
|
||||
JSON pc_json = JSON::list();
|
||||
phosg::JSON pc_json = phosg::JSON::list();
|
||||
for (const auto& it : this->pc_licenses) {
|
||||
pc_json.emplace_back(it.second->json());
|
||||
}
|
||||
JSON gc_json = JSON::list();
|
||||
phosg::JSON gc_json = phosg::JSON::list();
|
||||
for (const auto& it : this->gc_licenses) {
|
||||
gc_json.emplace_back(it.second->json());
|
||||
}
|
||||
JSON xb_json = JSON::list();
|
||||
phosg::JSON xb_json = phosg::JSON::list();
|
||||
for (const auto& it : this->xb_licenses) {
|
||||
xb_json.emplace_back(it.second->json());
|
||||
}
|
||||
JSON bb_json = JSON::list();
|
||||
phosg::JSON bb_json = phosg::JSON::list();
|
||||
for (const auto& it : this->bb_licenses) {
|
||||
bb_json.emplace_back(it.second->json());
|
||||
}
|
||||
|
||||
JSON auto_patches_json = JSON::list();
|
||||
phosg::JSON auto_patches_json = phosg::JSON::list();
|
||||
for (const auto& it : this->auto_patches_enabled) {
|
||||
auto_patches_json.emplace_back(it);
|
||||
}
|
||||
|
||||
return JSON::dict({
|
||||
return phosg::JSON::dict({
|
||||
{"FormatVersion", 1},
|
||||
{"AccountID", this->account_id},
|
||||
{"DCNTELicenses", std::move(dc_nte_json)},
|
||||
@@ -278,6 +268,7 @@ 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 +279,8 @@ 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 = std::format("Account: {:010}/{:08X}\n", this->account_id, this->account_id);
|
||||
|
||||
if (this->flags) {
|
||||
string flags_str = "";
|
||||
@@ -300,105 +291,149 @@ 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 += "DISABLE_QUEST_REQUIREMENTS,";
|
||||
}
|
||||
if (this->check_flag(Flag::ALWAYS_ENABLE_CHAT_COMMANDS)) {
|
||||
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,";
|
||||
}
|
||||
}
|
||||
if (flags_str.empty()) {
|
||||
flags_str = "none";
|
||||
} else if (ends_with(flags_str, ",")) {
|
||||
} else if (flags_str.ends_with(",")) {
|
||||
flags_str.pop_back();
|
||||
}
|
||||
fprintf(stream, " Flags: %08" PRIX32 " (%s)\n", this->flags, flags_str.c_str());
|
||||
ret += std::format(" Flags: {:08X} ({})\n", this->flags, flags_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 (user_flags_str.ends_with(",")) {
|
||||
user_flags_str.pop_back();
|
||||
}
|
||||
ret += std::format(" User flags: {:08X} ({})\n", this->user_flags, user_flags_str);
|
||||
}
|
||||
|
||||
if (this->ban_end_time) {
|
||||
string time_str = format_time(this->ban_end_time);
|
||||
fprintf(stream, " Banned until: %" PRIu64 " (%s)\n", this->ban_end_time, time_str.c_str());
|
||||
string time_str = phosg::format_time(this->ban_end_time);
|
||||
ret += std::format(" Banned until: {} ({})\n", this->ban_end_time, time_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 += std::format(" Episode 3 meseta: {} (total earned: {})\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 += std::format(" Last player name: \"{}\"\n", this->last_player_name);
|
||||
}
|
||||
if (!this->auto_reply_message.empty()) {
|
||||
fprintf(stream, " Auto reply message: \"%s\"\n", this->auto_reply_message.c_str());
|
||||
ret += std::format(" Auto reply message: \"{}\"\n", this->auto_reply_message);
|
||||
}
|
||||
if (this->bb_team_id) {
|
||||
fprintf(stream, " BB team ID: %08" PRIX32 "\n", this->bb_team_id);
|
||||
ret += std::format(" BB team ID: {:08X}\n", this->bb_team_id);
|
||||
}
|
||||
if (this->is_temporary) {
|
||||
fprintf(stream, " Is temporary license: true\n");
|
||||
ret += std::format(" 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",
|
||||
it.second->serial_number.c_str(), it.second->access_key.c_str());
|
||||
ret += std::format(" DC NTE license: serial_number={} access_key={}\n",
|
||||
it.second->serial_number, it.second->access_key);
|
||||
}
|
||||
for (const auto& it : this->dc_licenses) {
|
||||
fprintf(stream, " DC license: serial_number=%" PRIX32 " access_key=%s\n",
|
||||
it.second->serial_number, it.second->access_key.c_str());
|
||||
ret += std::format(" DC license: serial_number={:X} access_key={}\n",
|
||||
it.second->serial_number, it.second->access_key);
|
||||
}
|
||||
for (const auto& it : this->pc_licenses) {
|
||||
fprintf(stream, " PC license: serial_number=%" PRIX32 " access_key=%s\n",
|
||||
it.second->serial_number, it.second->access_key.c_str());
|
||||
ret += std::format(" PC license: serial_number={:X} access_key={}\n",
|
||||
it.second->serial_number, it.second->access_key);
|
||||
}
|
||||
for (const auto& it : this->gc_licenses) {
|
||||
fprintf(stream, " 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());
|
||||
ret += std::format(" GC license: serial_number={:010} access_key={} password={}\n",
|
||||
it.second->serial_number, it.second->access_key, it.second->password);
|
||||
}
|
||||
for (const auto& it : this->xb_licenses) {
|
||||
fprintf(stream, " 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);
|
||||
ret += std::format(" XB license: gamertag={} user_id={:016X} account_id={:016X}\n",
|
||||
it.second->gamertag, it.second->user_id, it.second->account_id);
|
||||
}
|
||||
for (const auto& it : this->bb_licenses) {
|
||||
fprintf(stream, " BB license: username=%s password=%s\n",
|
||||
it.second->username.c_str(), it.second->password.c_str());
|
||||
ret += std::format(" BB license: username={} password={}\n",
|
||||
it.second->username, it.second->password);
|
||||
}
|
||||
|
||||
phosg::strip_trailing_whitespace(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Account::save() const {
|
||||
if (!this->is_temporary) {
|
||||
auto json = this->json();
|
||||
string json_data = json.serialize(JSON::SerializeOption::FORMAT | JSON::SerializeOption::HEX_INTEGERS);
|
||||
string filename = string_printf("system/licenses/%010" PRIu32 ".json", this->account_id);
|
||||
save_file(filename, json_data);
|
||||
string json_data = json.serialize(
|
||||
phosg::JSON::SerializeOption::FORMAT | phosg::JSON::SerializeOption::HEX_INTEGERS);
|
||||
string filename = std::format("system/licenses/{:010}.json", this->account_id);
|
||||
phosg::save_file(filename, json_data);
|
||||
}
|
||||
}
|
||||
|
||||
void Account::delete_file() const {
|
||||
string filename = string_printf("system/licenses/%010" PRIu32 ".json", this->account_id);
|
||||
string filename = std::format("system/licenses/{:010}.json", this->account_id);
|
||||
remove(filename.c_str());
|
||||
}
|
||||
|
||||
string Login::str() const {
|
||||
string ret = std::format("Account:{:08X}", this->account->account_id);
|
||||
if (this->account_was_created) {
|
||||
ret += " (new)";
|
||||
}
|
||||
if (this->dc_nte_license) {
|
||||
ret += std::format(" via DC NTE serial number {}", this->dc_nte_license->serial_number);
|
||||
} else if (this->dc_license) {
|
||||
ret += std::format(" via DC serial number {:08X}", this->dc_license->serial_number);
|
||||
} else if (this->pc_license) {
|
||||
ret += std::format(" via PC serial number {:08X}", this->pc_license->serial_number);
|
||||
} else if (this->gc_license) {
|
||||
ret += std::format(" via GC serial number {:010}", this->gc_license->serial_number);
|
||||
} else if (this->xb_license) {
|
||||
ret += std::format(" via XB user ID {:016X}", this->xb_license->user_id);
|
||||
} else if (this->bb_license) {
|
||||
ret += std::format(" via BB username {}", this->bb_license->username);
|
||||
} else {
|
||||
ret += std::format(" artificially");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t AccountIndex::count() const {
|
||||
shared_lock g(this->lock);
|
||||
return this->by_account_id.size();
|
||||
@@ -420,8 +455,8 @@ shared_ptr<Login> AccountIndex::from_dc_nte_credentials_locked(const string& ser
|
||||
if (login->dc_nte_license->access_key != access_key) {
|
||||
throw incorrect_access_key();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
|
||||
throw account_banned();
|
||||
}
|
||||
return login;
|
||||
}
|
||||
@@ -448,7 +483,7 @@ shared_ptr<Login> AccountIndex::from_dc_nte_credentials(
|
||||
auto login = make_shared<Login>();
|
||||
login->account_was_created = true;
|
||||
login->account = make_shared<Account>();
|
||||
login->account->account_id = fnv1a32(serial_number) & 0x7FFFFFFF;
|
||||
login->account->account_id = phosg::fnv1a32(serial_number) & 0x7FFFFFFF;
|
||||
auto lic = make_shared<DCNTELicense>();
|
||||
lic->serial_number = serial_number;
|
||||
lic->access_key = access_key;
|
||||
@@ -470,8 +505,8 @@ shared_ptr<Login> AccountIndex::from_dc_credentials_locked(
|
||||
if (!is_shared && (login->dc_license->access_key != access_key)) {
|
||||
throw incorrect_access_key();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
|
||||
throw account_banned();
|
||||
}
|
||||
if (is_shared) {
|
||||
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
|
||||
@@ -519,7 +554,7 @@ shared_ptr<Login> AccountIndex::from_pc_nte_credentials(uint32_t guild_card_numb
|
||||
throw missing_account();
|
||||
}
|
||||
if (guild_card_number == 0xFFFFFFFF) {
|
||||
guild_card_number = random_object<uint32_t>() & 0x7FFFFFFF;
|
||||
guild_card_number = phosg::random_object<uint32_t>() & 0x7FFFFFFF;
|
||||
}
|
||||
auto login = make_shared<Login>();
|
||||
login->account_was_created = true;
|
||||
@@ -543,8 +578,8 @@ shared_ptr<Login> AccountIndex::from_pc_credentials_locked(
|
||||
if (!is_shared && (login->pc_license->access_key != access_key)) {
|
||||
throw incorrect_access_key();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
|
||||
throw account_banned();
|
||||
}
|
||||
if (is_shared) {
|
||||
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
|
||||
@@ -599,8 +634,8 @@ shared_ptr<Login> AccountIndex::from_gc_credentials_locked(
|
||||
if (password && (login->gc_license->password != *password)) {
|
||||
throw incorrect_password();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
|
||||
throw account_banned();
|
||||
}
|
||||
if (is_shared) {
|
||||
login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name);
|
||||
@@ -609,7 +644,11 @@ shared_ptr<Login> AccountIndex::from_gc_credentials_locked(
|
||||
}
|
||||
|
||||
shared_ptr<Login> AccountIndex::from_gc_credentials(
|
||||
uint32_t serial_number, const string& access_key, const string* password, const string& character_name, bool allow_create) {
|
||||
uint32_t serial_number,
|
||||
const string& access_key,
|
||||
const string* password,
|
||||
const string& character_name,
|
||||
bool allow_create) {
|
||||
if (serial_number == 0) {
|
||||
throw no_username();
|
||||
}
|
||||
@@ -644,16 +683,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();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
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 account_banned();
|
||||
}
|
||||
return login;
|
||||
}
|
||||
@@ -666,13 +701,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&) {
|
||||
}
|
||||
|
||||
@@ -680,12 +715,12 @@ shared_ptr<Login> AccountIndex::from_xb_credentials(
|
||||
auto login = make_shared<Login>();
|
||||
login->account_was_created = true;
|
||||
login->account = make_shared<Account>();
|
||||
login->account->account_id = fnv1a32(gamertag) & 0x7FFFFFFF;
|
||||
login->account->account_id = phosg::fnv1a32(gamertag) & 0x7FFFFFFF;
|
||||
auto lic = make_shared<XBLicense>();
|
||||
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;
|
||||
@@ -701,13 +736,14 @@ shared_ptr<Login> AccountIndex::from_bb_credentials_locked(const string& usernam
|
||||
if (password && (login->bb_license->password != *password)) {
|
||||
throw incorrect_password();
|
||||
}
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= now())) {
|
||||
throw invalid_argument("user is banned");
|
||||
if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) {
|
||||
throw account_banned();
|
||||
}
|
||||
return login;
|
||||
}
|
||||
|
||||
shared_ptr<Login> AccountIndex::from_bb_credentials(const string& username, const string* password, bool allow_create) {
|
||||
shared_ptr<Login> AccountIndex::from_bb_credentials(
|
||||
const string& username, const string* password, bool allow_create) {
|
||||
if (username.empty() || (password && password->empty())) {
|
||||
throw no_username();
|
||||
}
|
||||
@@ -728,7 +764,7 @@ shared_ptr<Login> AccountIndex::from_bb_credentials(const string& username, cons
|
||||
auto login = make_shared<Login>();
|
||||
login->account_was_created = true;
|
||||
login->account = make_shared<Account>();
|
||||
login->account->account_id = fnv1a32(username) & 0x7FFFFFFF;
|
||||
login->account->account_id = phosg::fnv1a32(username) & 0x7FFFFFFF;
|
||||
auto lic = make_shared<BBLicense>();
|
||||
lic->username = username;
|
||||
lic->password = *password;
|
||||
@@ -782,8 +818,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 +846,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 +875,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 +923,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 +986,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);
|
||||
@@ -976,24 +1012,25 @@ shared_ptr<Account> AccountIndex::create_temporary_account_for_shared_account(
|
||||
shared_ptr<const Account> src_a, const string& variation_data) const {
|
||||
auto ret = make_shared<Account>(*src_a);
|
||||
ret->is_temporary = true;
|
||||
ret->account_id = fnv1a32(&src_a->account_id, sizeof(src_a->account_id));
|
||||
ret->account_id = fnv1a32(variation_data, ret->account_id);
|
||||
ret->account_id = phosg::fnv1a32(&src_a->account_id, sizeof(src_a->account_id));
|
||||
ret->account_id = phosg::fnv1a32(variation_data, ret->account_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
AccountIndex::AccountIndex(bool force_all_temporary)
|
||||
: force_all_temporary(force_all_temporary) {
|
||||
if (!this->force_all_temporary) {
|
||||
if (!isdir("system/licenses")) {
|
||||
mkdir("system/licenses", 0755);
|
||||
if (!std::filesystem::is_directory("system/licenses")) {
|
||||
std::filesystem::create_directories("system/licenses");
|
||||
} else {
|
||||
for (const auto& item : list_directory("system/licenses")) {
|
||||
if (ends_with(item, ".json")) {
|
||||
for (const auto& item : std::filesystem::directory_iterator("system/licenses")) {
|
||||
string filename = item.path().filename().string();
|
||||
if (filename.ends_with(".json")) {
|
||||
try {
|
||||
JSON json = JSON::parse(load_file("system/licenses/" + item));
|
||||
phosg::JSON json = phosg::JSON::parse(phosg::load_file("system/licenses/" + filename));
|
||||
this->add(make_shared<Account>(json));
|
||||
} catch (const exception& e) {
|
||||
log_error("Failed to index account %s", item.c_str());
|
||||
phosg::log_error_f("Failed to index account {}", filename);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
+53
-58
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/JSON.hh>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
@@ -16,16 +17,16 @@ struct DCNTELicense {
|
||||
std::string serial_number;
|
||||
std::string access_key;
|
||||
|
||||
static std::shared_ptr<DCNTELicense> from_json(const JSON& json);
|
||||
JSON json() const;
|
||||
static std::shared_ptr<DCNTELicense> from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
};
|
||||
|
||||
struct V1V2License {
|
||||
uint32_t serial_number = 0;
|
||||
std::string access_key;
|
||||
|
||||
static std::shared_ptr<V1V2License> from_json(const JSON& json);
|
||||
JSON json() const;
|
||||
static std::shared_ptr<V1V2License> from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
};
|
||||
|
||||
struct GCLicense {
|
||||
@@ -33,8 +34,8 @@ struct GCLicense {
|
||||
std::string access_key;
|
||||
std::string password;
|
||||
|
||||
static std::shared_ptr<GCLicense> from_json(const JSON& json);
|
||||
JSON json() const;
|
||||
static std::shared_ptr<GCLicense> from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
};
|
||||
|
||||
struct XBLicense {
|
||||
@@ -42,16 +43,16 @@ struct XBLicense {
|
||||
uint64_t user_id = 0;
|
||||
uint64_t account_id = 0;
|
||||
|
||||
static std::shared_ptr<XBLicense> from_json(const JSON& json);
|
||||
JSON json() const;
|
||||
static std::shared_ptr<XBLicense> from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
};
|
||||
|
||||
struct BBLicense {
|
||||
std::string username;
|
||||
std::string password;
|
||||
|
||||
static std::shared_ptr<BBLicense> from_json(const JSON& json);
|
||||
JSON json() const;
|
||||
static std::shared_ptr<BBLicense> from_json(const phosg::JSON& json);
|
||||
phosg::JSON json() const;
|
||||
};
|
||||
|
||||
struct Account {
|
||||
@@ -71,16 +72,19 @@ struct Account {
|
||||
ADMINISTRATOR = 0x000000FF,
|
||||
ROOT = 0x7FFFFFFF,
|
||||
IS_SHARED_ACCOUNT = 0x80000000,
|
||||
// NOTE: When adding or changing license flags, don't forget to change the
|
||||
// documentation in the shell's help text.
|
||||
// NOTE: When adding or changing license flags, don't forget to change the documentation in the shell's help text.
|
||||
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,14 +101,14 @@ 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;
|
||||
explicit Account(const JSON& json);
|
||||
explicit Account(const phosg::JSON& json);
|
||||
virtual ~Account() = default;
|
||||
|
||||
JSON json() const;
|
||||
phosg::JSON json() const;
|
||||
virtual void save() const;
|
||||
virtual void delete_file() const;
|
||||
|
||||
@@ -124,21 +128,35 @@ 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 {
|
||||
bool account_was_created = false;
|
||||
// This field will never be null
|
||||
std::shared_ptr<Account> account;
|
||||
// Exactly one of the following will be non-null, representing the license
|
||||
// that the client logged in with
|
||||
// Exactly one of the following will be non-null, representing the license that the client logged in with
|
||||
std::shared_ptr<DCNTELicense> dc_nte_license;
|
||||
std::shared_ptr<V1V2License> dc_license;
|
||||
std::shared_ptr<V1V2License> pc_license;
|
||||
std::shared_ptr<GCLicense> gc_license;
|
||||
std::shared_ptr<XBLicense> xb_license;
|
||||
std::shared_ptr<BBLicense> bb_license;
|
||||
|
||||
std::string str() const;
|
||||
};
|
||||
|
||||
class AccountIndex {
|
||||
@@ -159,6 +177,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,27 +203,17 @@ 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;
|
||||
std::shared_ptr<Login> from_dc_nte_credentials(
|
||||
const std::string& serial_number,
|
||||
const std::string& access_key,
|
||||
bool allow_create);
|
||||
const std::string& serial_number, const std::string& access_key, bool allow_create);
|
||||
std::shared_ptr<Login> from_dc_credentials(
|
||||
uint32_t serial_number,
|
||||
const std::string& access_key,
|
||||
const std::string& character_name,
|
||||
bool allow_create);
|
||||
std::shared_ptr<Login> from_pc_nte_credentials(
|
||||
uint32_t guild_card_number,
|
||||
bool allow_create);
|
||||
uint32_t serial_number, const std::string& access_key, const std::string& character_name, bool allow_create);
|
||||
std::shared_ptr<Login> from_pc_nte_credentials(uint32_t guild_card_number, bool allow_create);
|
||||
std::shared_ptr<Login> from_pc_credentials(
|
||||
uint32_t serial_number,
|
||||
const std::string& access_key,
|
||||
const std::string& character_name,
|
||||
bool allow_create);
|
||||
uint32_t serial_number, const std::string& access_key, const std::string& character_name, bool allow_create);
|
||||
std::shared_ptr<Login> from_gc_credentials(
|
||||
uint32_t serial_number,
|
||||
const std::string& access_key,
|
||||
@@ -209,14 +221,9 @@ public:
|
||||
const std::string& character_name,
|
||||
bool allow_create);
|
||||
std::shared_ptr<Login> from_xb_credentials(
|
||||
const std::string& gamertag,
|
||||
uint64_t user_id,
|
||||
uint64_t account_id,
|
||||
bool allow_create);
|
||||
const std::string& gamertag, uint64_t user_id, uint64_t account_id, bool allow_create);
|
||||
std::shared_ptr<Login> from_bb_credentials(
|
||||
const std::string& username,
|
||||
const std::string* password,
|
||||
bool allow_create);
|
||||
const std::string& username, const std::string* password, bool allow_create);
|
||||
|
||||
std::shared_ptr<Account> create_temporary_account_for_shared_account(
|
||||
std::shared_ptr<const Account> src_a, const std::string& variation_data) const;
|
||||
@@ -224,40 +231,28 @@ public:
|
||||
protected:
|
||||
bool force_all_temporary;
|
||||
|
||||
// This class must be thread-safe because it's used by both the patch server
|
||||
// and game server threads
|
||||
mutable std::shared_mutex lock;
|
||||
std::unordered_map<uint32_t, std::shared_ptr<Account>> by_account_id;
|
||||
std::unordered_map<std::string, std::shared_ptr<Account>> by_dc_nte_serial_number;
|
||||
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);
|
||||
|
||||
std::shared_ptr<Login> from_dc_nte_credentials_locked(
|
||||
const std::string& serial_number,
|
||||
const std::string& access_key);
|
||||
const std::string& serial_number, const std::string& access_key);
|
||||
std::shared_ptr<Login> from_dc_credentials_locked(
|
||||
uint32_t serial_number,
|
||||
const std::string& access_key,
|
||||
const std::string& character_name);
|
||||
uint32_t serial_number, const std::string& access_key, const std::string& character_name);
|
||||
std::shared_ptr<Login> from_pc_credentials_locked(
|
||||
uint32_t serial_number,
|
||||
const std::string& access_key,
|
||||
const std::string& character_name);
|
||||
uint32_t serial_number, const std::string& access_key, const std::string& character_name);
|
||||
std::shared_ptr<Login> from_gc_credentials_locked(
|
||||
uint32_t serial_number,
|
||||
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_bb_credentials_locked(
|
||||
const std::string& username,
|
||||
const std::string* password);
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
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&) {
|
||||
throw std::runtime_error("resource_file is not available; install it and rebuild newserv");
|
||||
}
|
||||
+557
-66
@@ -1,12 +1,19 @@
|
||||
#include "AddressTranslator.hh"
|
||||
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <future>
|
||||
#include <phosg/Filesystem.hh>
|
||||
#include <phosg/Strings.hh>
|
||||
#include <resource_file/Emulators/X86Emulator.hh>
|
||||
#include <resource_file/ExecutableFormats/DOLFile.hh>
|
||||
#include <resource_file/ExecutableFormats/PEFile.hh>
|
||||
#include <resource_file/ExecutableFormats/XBEFile.hh>
|
||||
|
||||
#include "Map.hh"
|
||||
#include "Text.hh"
|
||||
#include "Types.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AddressTranslator {
|
||||
@@ -106,38 +113,44 @@ public:
|
||||
|
||||
AddressTranslator(const string& directory)
|
||||
: log("[addr-trans] "),
|
||||
directory(directory),
|
||||
enable_ppc(false) {
|
||||
while (ends_with(this->directory, "/")) {
|
||||
directory(directory) {
|
||||
while (this->directory.ends_with("/")) {
|
||||
this->directory.pop_back();
|
||||
}
|
||||
for (const auto& filename : list_directory(this->directory)) {
|
||||
if (ends_with(filename, ".dol")) {
|
||||
string name = filename.substr(0, filename.size() - 4);
|
||||
string path = directory + "/" + filename;
|
||||
DOLFile dol(path.c_str());
|
||||
auto mem = make_shared<MemoryContext>();
|
||||
for (const auto& item : std::filesystem::directory_iterator(this->directory)) {
|
||||
string filename = item.path().filename().string();
|
||||
if (filename.size() < 4) {
|
||||
continue;
|
||||
}
|
||||
string name = filename.substr(0, filename.size() - 4);
|
||||
string path = directory + "/" + filename;
|
||||
|
||||
if (filename.ends_with(".dol")) {
|
||||
ResourceDASM::DOLFile dol(path.c_str());
|
||||
auto mem = make_shared<ResourceDASM::MemoryContext>();
|
||||
dol.load_into(mem);
|
||||
this->mems.emplace(name, mem);
|
||||
this->enable_ppc = true;
|
||||
this->log.info("Loaded %s", name.c_str());
|
||||
} else if (ends_with(filename, ".xbe")) {
|
||||
string name = filename.substr(0, filename.size() - 4);
|
||||
string path = directory + "/" + filename;
|
||||
XBEFile xbe(path.c_str());
|
||||
auto mem = make_shared<MemoryContext>();
|
||||
this->ppc_mems.emplace(mem);
|
||||
this->log.info_f("Loaded {}", name);
|
||||
} else if (filename.ends_with(".xbe")) {
|
||||
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 (ends_with(filename, ".bin")) {
|
||||
string name = filename.substr(0, filename.size() - 4);
|
||||
string path = directory + "/" + filename;
|
||||
string data = load_file(path);
|
||||
auto mem = make_shared<MemoryContext>();
|
||||
this->log.info_f("Loaded {}", name);
|
||||
} else if (filename.ends_with(".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_f("Loaded {}", name);
|
||||
} else if (filename.ends_with(".bin")) {
|
||||
string data = phosg::load_file(path);
|
||||
auto mem = make_shared<ResourceDASM::MemoryContext>();
|
||||
mem->allocate_at(0x8C010000, data.size());
|
||||
mem->memcpy(0x8C010000, data.data(), data.size());
|
||||
this->mems.emplace(name, mem);
|
||||
this->log.info("Loaded %s", name.c_str());
|
||||
this->log.info_f("Loaded {}", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +173,7 @@ public:
|
||||
uint32_t r2 = 0;
|
||||
uint32_t r13 = 0;
|
||||
for (const auto& block : it.second->allocated_blocks()) {
|
||||
StringReader r = it.second->reader(block.first, block.second);
|
||||
phosg::StringReader r = it.second->reader(block.first, block.second);
|
||||
while (!r.eof() && r.where()) {
|
||||
uint32_t opcode = r.get_u32b();
|
||||
if ((opcode & 0xFFFF0000) == 0x3DA00000) {
|
||||
@@ -191,20 +204,269 @@ public:
|
||||
}
|
||||
}
|
||||
if (r2_low_found && r2_high_found) {
|
||||
fprintf(stderr, "(%s) r2 = %08" PRIX32 "\n", it.first.c_str(), r2);
|
||||
phosg::fwrite_fmt(stderr, "({}) r2 = {:08X}\n", it.first, r2);
|
||||
} else {
|
||||
fprintf(stderr, "(%s) r2 = __MISSING__\n", it.first.c_str());
|
||||
phosg::fwrite_fmt(stderr, "({}) r2 = __MISSING__\n", it.first);
|
||||
}
|
||||
if (r13_low_found && r13_high_found) {
|
||||
fprintf(stderr, "(%s) r13 = %08" PRIX32 "\n", it.first.c_str(), r13);
|
||||
phosg::fwrite_fmt(stderr, "({}) r13 = {:08X}\n", it.first, r13);
|
||||
} else {
|
||||
fprintf(stderr, "(%s) r13 = __MISSING__\n", it.first.c_str());
|
||||
phosg::fwrite_fmt(stderr, "({}) r13 = __MISSING__\n", it.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ParseDATConstructorTableSpec {
|
||||
string src_name;
|
||||
uint32_t index_addr;
|
||||
size_t num_areas;
|
||||
bool has_names;
|
||||
vector<uint32_t> x86_constructor_calls;
|
||||
|
||||
ParseDATConstructorTableSpec(const phosg::JSON& json) {
|
||||
this->src_name = json.at("SourceName").as_string();
|
||||
this->index_addr = json.at("IndexAddress").as_int();
|
||||
this->num_areas = json.at("AreaCount").as_int();
|
||||
this->has_names = json.at("HasNames").as_bool();
|
||||
for (const auto& z : json.at("X86ConstructorCalls").as_list()) {
|
||||
this->x86_constructor_calls.emplace_back(z->as_int());
|
||||
}
|
||||
}
|
||||
|
||||
static vector<ParseDATConstructorTableSpec> from_json_list(const phosg::JSON& json) {
|
||||
vector<ParseDATConstructorTableSpec> ret;
|
||||
for (const auto& z : json.as_list()) {
|
||||
ret.emplace_back(*z);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool BE>
|
||||
struct DATConstructorTableEntry {
|
||||
static constexpr bool IsBE = BE;
|
||||
|
||||
U16T<BE> type;
|
||||
U16T<BE> unused;
|
||||
U32T<BE> constructor_addr;
|
||||
F32T<BE> max_dist2; // Only applies for objects
|
||||
U32T<BE> default_num_children;
|
||||
} __attribute__((packed));
|
||||
|
||||
template <bool BE>
|
||||
struct DATConstructorTableEntryWithName {
|
||||
static constexpr bool IsBE = BE;
|
||||
|
||||
pstring<TextEncoding::ASCII, 0x10> debug_name;
|
||||
U16T<BE> type;
|
||||
U16T<BE> unused;
|
||||
U32T<BE> constructor_addr;
|
||||
F32T<BE> max_dist2; // Only applies for objects
|
||||
U32T<BE> default_num_children;
|
||||
} __attribute__((packed));
|
||||
|
||||
// Returns {type: {constructor_addr: [(start_area, end_area), ...]}}
|
||||
template <typename EntryT>
|
||||
map<uint32_t, map<uint32_t, vector<pair<size_t, size_t>>>> parse_dat_constructor_table_t(
|
||||
shared_ptr<const ResourceDASM::MemoryContext>& mem, const ParseDATConstructorTableSpec& spec) {
|
||||
if (!mem) {
|
||||
throw runtime_error("no file selected");
|
||||
}
|
||||
|
||||
// On some of the x86 builds of the game (PCv2 and Xbox), the constructor tables aren't entirely static in the data
|
||||
// sections - some parts are written during static initialization instead. To handle this, we make a copy of the
|
||||
// immutable MemoryContext and run the static initialization functions using resource_dasm's emulator before
|
||||
// parsing the constructor table.
|
||||
shared_ptr<const ResourceDASM::MemoryContext> effective_mem = mem;
|
||||
if (!spec.x86_constructor_calls.empty()) {
|
||||
auto constructed_mem = make_shared<ResourceDASM::MemoryContext>(mem->duplicate());
|
||||
uint32_t esp = constructed_mem->allocate(0x1000) + 0x1000;
|
||||
for (uint32_t constructor_addr : spec.x86_constructor_calls) {
|
||||
ResourceDASM::X86Emulator emu(constructed_mem);
|
||||
|
||||
// Uncomment for debugging
|
||||
// auto debugger = make_shared<ResourceDASM::EmulatorDebugger<ResourceDASM::X86Emulator>>();
|
||||
// debugger->bind(emu);
|
||||
// debugger->state.mode = ResourceDASM::DebuggerMode::TRACE;
|
||||
|
||||
auto& regs = emu.registers();
|
||||
regs.eip = constructor_addr;
|
||||
regs.esp().u = esp - 4;
|
||||
constructed_mem->write_u32l(esp - 4, 0xFFFFFFFF); // Return addr
|
||||
try {
|
||||
emu.execute();
|
||||
} catch (const out_of_range&) {
|
||||
if (regs.eip != 0xFFFFFFFF) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
effective_mem = constructed_mem;
|
||||
}
|
||||
|
||||
map<uint32_t, map<uint32_t, vector<pair<size_t, size_t>>>> table;
|
||||
|
||||
auto index_r = effective_mem->reader(spec.index_addr, spec.num_areas * sizeof(uint32_t));
|
||||
for (size_t area = 0; area < spec.num_areas; area++) {
|
||||
uint32_t entries_addr = EntryT::IsBE ? index_r.get_u32b() : index_r.get_u32l();
|
||||
if (!entries_addr) {
|
||||
continue;
|
||||
}
|
||||
auto entries_r = effective_mem->reader(entries_addr, 0x4000); // 0x4000 is probably enough
|
||||
while (!entries_r.eof()) {
|
||||
const auto& entry = entries_r.get<EntryT>();
|
||||
if (entry.type == 0xFFFF) {
|
||||
break;
|
||||
}
|
||||
auto& group = table[entry.type][entry.constructor_addr];
|
||||
if (!group.empty() && (group.back().second == (area - 1))) {
|
||||
group.back().second = area;
|
||||
} else {
|
||||
group.emplace_back(make_pair(area, area));
|
||||
}
|
||||
}
|
||||
if (entries_r.eof()) {
|
||||
throw runtime_error("did not find end-of-entries marker");
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
static uint64_t area_mask_for_ranges(const vector<pair<size_t, size_t>>& ranges) {
|
||||
uint64_t ret = 0;
|
||||
for (const auto& [start, end] : ranges) {
|
||||
for (size_t z = start; z <= end; z++) {
|
||||
ret |= static_cast<uint64_t>(1ULL << z);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void parse_dat_constructor_table(const ParseDATConstructorTableSpec& spec) {
|
||||
map<uint32_t, map<uint32_t, vector<pair<size_t, size_t>>>> table;
|
||||
auto spec_mem = this->mems.at(spec.src_name);
|
||||
if (this->ppc_mems.count(spec_mem)) {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntry<true>>(spec_mem, spec);
|
||||
} else if (!spec.has_names) {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntry<false>>(spec_mem, spec);
|
||||
} else {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntryWithName<false>>(spec_mem, spec);
|
||||
}
|
||||
|
||||
for (const auto& [type, constructor_to_area_ranges] : table) {
|
||||
phosg::fwrite_fmt(stdout, "{:04X} =>", type);
|
||||
for (const auto& [constructor, area_ranges] : constructor_to_area_ranges) {
|
||||
phosg::fwrite_fmt(stdout, " {:08X}", constructor);
|
||||
bool is_first = true;
|
||||
for (const auto& [start, end] : area_ranges) {
|
||||
fputc(is_first ? ':' : ',', stdout);
|
||||
if (start == end) {
|
||||
phosg::fwrite_fmt(stdout, "{:02X}", start);
|
||||
} else {
|
||||
phosg::fwrite_fmt(stdout, "{:02X}-{:02X}", start, end);
|
||||
}
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
|
||||
void parse_dat_constructor_table_multi(
|
||||
const vector<ParseDATConstructorTableSpec>& specs, bool is_enemies, bool print_area_masks) {
|
||||
map<string, map<uint32_t, map<uint32_t, vector<pair<size_t, size_t>>>>> all_tables;
|
||||
for (const auto& spec : specs) {
|
||||
map<uint32_t, map<uint32_t, vector<pair<size_t, size_t>>>> table;
|
||||
auto spec_mem = this->mems.at(spec.src_name);
|
||||
if (this->ppc_mems.count(spec_mem)) {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntry<true>>(spec_mem, spec);
|
||||
} else if (!spec.has_names) {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntry<false>>(spec_mem, spec);
|
||||
} else {
|
||||
table = this->parse_dat_constructor_table_t<DATConstructorTableEntryWithName<false>>(spec_mem, spec);
|
||||
}
|
||||
all_tables.emplace(spec.src_name, std::move(table));
|
||||
}
|
||||
|
||||
map<string, size_t> version_widths;
|
||||
map<uint32_t, map<string, string>> formatted_cells_for_type;
|
||||
for (const auto& spec : specs) {
|
||||
const auto& table = all_tables.at(spec.src_name);
|
||||
size_t max_width = 0;
|
||||
|
||||
for (const auto& [type, constructor_to_area_ranges] : table) {
|
||||
string cell_data;
|
||||
for (const auto& [constructor, area_ranges] : constructor_to_area_ranges) {
|
||||
if (!cell_data.empty()) {
|
||||
cell_data.push_back(' ');
|
||||
}
|
||||
cell_data += std::format("{:08X}", constructor);
|
||||
if (print_area_masks) {
|
||||
cell_data += std::format(":{:016X}", this->area_mask_for_ranges(area_ranges));
|
||||
} else {
|
||||
bool is_first = true;
|
||||
for (const auto& [start, end] : area_ranges) {
|
||||
cell_data.push_back(is_first ? ':' : ',');
|
||||
if (start == end) {
|
||||
cell_data += std::format("{:02X}", start);
|
||||
} else {
|
||||
cell_data += std::format("{:02X}-{:02X}", start, end);
|
||||
}
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
max_width = max<size_t>(max_width, cell_data.size());
|
||||
formatted_cells_for_type[type][spec.src_name] = std::move(cell_data);
|
||||
}
|
||||
version_widths[spec.src_name] = max_width;
|
||||
}
|
||||
|
||||
vector<string> formatted_lines;
|
||||
string header_line = "TYPE =>";
|
||||
for (const auto& spec : specs) {
|
||||
size_t width = version_widths.at(spec.src_name);
|
||||
header_line.push_back(' ');
|
||||
header_line += spec.src_name;
|
||||
if (width > spec.src_name.size()) {
|
||||
header_line.resize(header_line.size() + (width - spec.src_name.size()), '-');
|
||||
}
|
||||
}
|
||||
header_line += " NAME";
|
||||
|
||||
for (const auto& [type, formatted_cells] : formatted_cells_for_type) {
|
||||
string line = std::format("{:04X} =>", type);
|
||||
for (const auto& spec : specs) {
|
||||
size_t width = version_widths.at(spec.src_name);
|
||||
try {
|
||||
const auto& cell_data = formatted_cells.at(spec.src_name);
|
||||
line.push_back(' ');
|
||||
line += cell_data;
|
||||
if (width > cell_data.size()) {
|
||||
line.resize(line.size() + (width - cell_data.size()), ' ');
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
line.resize(line.size() + (width + 1), ' ');
|
||||
}
|
||||
}
|
||||
line.push_back(' ');
|
||||
line += is_enemies ? MapFile::name_for_enemy_type(type) : MapFile::name_for_object_type(type);
|
||||
|
||||
if ((formatted_lines.size() % 40) == 0) {
|
||||
formatted_lines.emplace_back(header_line);
|
||||
}
|
||||
formatted_lines.emplace_back(std::move(line));
|
||||
}
|
||||
|
||||
for (auto& line : formatted_lines) {
|
||||
phosg::strip_trailing_whitespace(line);
|
||||
phosg::fwrite_fmt(stdout, "{}\n", line);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t find_match(
|
||||
shared_ptr<const MemoryContext> dest_mem,
|
||||
shared_ptr<const ResourceDASM::MemoryContext> dest_mem,
|
||||
uint32_t src_addr,
|
||||
uint32_t src_size,
|
||||
ExpandMethod expand_method) const {
|
||||
@@ -234,7 +496,7 @@ public:
|
||||
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;
|
||||
this->log.info("(find_match/%s) Source offset = %08zX with %zX/%zX bytes available before/after",
|
||||
this->log.info_f("(find_match/{}) Source offset = {:08X} with {:X}/{:X} bytes available before/after",
|
||||
method_token, src_offset, src_bytes_available_before, src_bytes_available_after);
|
||||
|
||||
size_t match_bytes_before = 0;
|
||||
@@ -243,13 +505,13 @@ public:
|
||||
size_t num_matches = 0;
|
||||
size_t last_match_address = 0;
|
||||
size_t match_length = match_bytes_before + match_bytes_after + 4;
|
||||
StringReader src_r = this->src_mem->reader(src_section.first + src_offset - match_bytes_before, match_length);
|
||||
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);
|
||||
StringReader dest_r = dest_mem->reader(dest_section.first + dest_match_offset, match_length);
|
||||
phosg::StringReader dest_r = dest_mem->reader(dest_section.first + dest_match_offset, match_length);
|
||||
size_t z;
|
||||
if (is_ppc) {
|
||||
for (z = 0; z < match_length; z += 4) {
|
||||
@@ -304,7 +566,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
this->log.info("(find_match/%s) For match length %zX, %zu matches found", method_token, match_length, num_matches);
|
||||
this->log.info_f("(find_match/{}) For match length {:X}, {} matches found", method_token, match_length, num_matches);
|
||||
if (num_matches == 1) {
|
||||
return last_match_address;
|
||||
} else if (num_matches == 0) {
|
||||
@@ -367,7 +629,13 @@ public:
|
||||
throw runtime_error("scan field too long; too many matches");
|
||||
}
|
||||
|
||||
void find_all_matches(uint32_t src_addr, uint32_t src_size) const {
|
||||
enum class MatchType {
|
||||
ANY = 0,
|
||||
TEXT,
|
||||
DATA,
|
||||
};
|
||||
|
||||
void find_all_matches(uint32_t src_addr, uint32_t src_size, MatchType type) const {
|
||||
if (!this->src_mem) {
|
||||
throw runtime_error("no source file selected");
|
||||
}
|
||||
@@ -375,7 +643,7 @@ public:
|
||||
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);
|
||||
log.info_f("({}) {:08X} (from source)", it.first, src_addr);
|
||||
results.emplace(it.first, src_addr);
|
||||
|
||||
} else {
|
||||
@@ -392,57 +660,236 @@ public:
|
||||
ExpandMethod::PPC_DATA_BACKWARD,
|
||||
ExpandMethod::PPC_DATA_BOTH,
|
||||
};
|
||||
static const vector<ExpandMethod> ppc_text_methods = {
|
||||
ExpandMethod::PPC_TEXT_FORWARD,
|
||||
ExpandMethod::PPC_TEXT_FORWARD_WITH_BARRIER,
|
||||
ExpandMethod::PPC_TEXT_BACKWARD,
|
||||
ExpandMethod::PPC_TEXT_BACKWARD_WITH_BARRIER,
|
||||
ExpandMethod::PPC_TEXT_BOTH,
|
||||
ExpandMethod::PPC_TEXT_BOTH_WITH_BARRIER,
|
||||
ExpandMethod::PPC_TEXT_BOTH_IGNORE_ORIGIN,
|
||||
};
|
||||
static const vector<ExpandMethod> ppc_data_methods = {
|
||||
ExpandMethod::PPC_DATA_FORWARD,
|
||||
ExpandMethod::PPC_DATA_BACKWARD,
|
||||
ExpandMethod::PPC_DATA_BOTH,
|
||||
};
|
||||
static const vector<ExpandMethod> raw_methods = {
|
||||
ExpandMethod::RAW_FORWARD,
|
||||
ExpandMethod::RAW_BACKWARD,
|
||||
ExpandMethod::RAW_BOTH,
|
||||
};
|
||||
const auto& methods = this->enable_ppc ? ppc_methods : raw_methods;
|
||||
for (size_t z = 0; z < methods.size(); z++) {
|
||||
futures.emplace_back(async(&AddressTranslator::find_match, this, it.second, src_addr, src_size, methods[z]));
|
||||
|
||||
const vector<ExpandMethod>* methods;
|
||||
if (this->ppc_mems.count(it.second)) {
|
||||
if (type == MatchType::ANY) {
|
||||
methods = &ppc_methods;
|
||||
} else if (type == MatchType::TEXT) {
|
||||
methods = &ppc_text_methods;
|
||||
} else if (type == MatchType::DATA) {
|
||||
methods = &ppc_data_methods;
|
||||
} else {
|
||||
throw logic_error("invalid match type");
|
||||
}
|
||||
} else {
|
||||
methods = &raw_methods;
|
||||
}
|
||||
|
||||
for (size_t z = 0; z < methods->size(); z++) {
|
||||
futures.emplace_back(async(&AddressTranslator::find_match, this, it.second, src_addr, src_size, methods->at(z)));
|
||||
}
|
||||
|
||||
unordered_set<uint32_t> match_addrs;
|
||||
for (size_t z = 0; z < futures.size(); z++) {
|
||||
const char* method_name = this->name_for_expand_method(methods[z]);
|
||||
const char* method_name = this->name_for_expand_method(methods->at(z));
|
||||
try {
|
||||
uint32_t ret = futures[z].get();
|
||||
log.info("(%s) (%s) %08" PRIX32, it.first.c_str(), method_name, ret);
|
||||
log.info_f("({}) ({}) {:08X}", it.first, method_name, ret);
|
||||
match_addrs.emplace(ret);
|
||||
} catch (const exception& e) {
|
||||
log.error("(%s) (%s) failed: %s", it.first.c_str(), method_name, e.what());
|
||||
log.error_f("({}) ({}) failed: {}", it.first, method_name, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
if (match_addrs.empty()) {
|
||||
log.error("(%s) no match found", it.first.c_str());
|
||||
log.error_f("({}) no match found", it.first);
|
||||
} else if (match_addrs.size() > 1) {
|
||||
log.error("(%s) different matches found by different methods", it.first.c_str());
|
||||
log.error_f("({}) different matches found by different methods", it.first);
|
||||
} else {
|
||||
results.emplace(it.first, *match_addrs.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& it : results) {
|
||||
fprintf(stdout, "%s => %08" PRIX32 "\n", it.first.c_str(), it.second);
|
||||
phosg::fwrite_fmt(stdout, "{} => {:08X}\n", it.first, it.second);
|
||||
}
|
||||
}
|
||||
|
||||
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_f("... For match length {:X}, {} 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_f("({}) {:08X} (from source)", it.first, 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_f("({}) {:08X}", it.first, ret);
|
||||
} catch (const exception& e) {
|
||||
log.error_f("({}) failed: {}", it.first, e.what());
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
log.error_f("({}) no match found", it.first);
|
||||
} else {
|
||||
results.emplace(it.first, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& it : results) {
|
||||
phosg::fwrite_fmt(stdout, "{} => {:08X}\n", it.first, it.second);
|
||||
}
|
||||
}
|
||||
|
||||
void find_data(const 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())) {
|
||||
phosg::fwrite_fmt(stderr, "{} => {:08X}\n", name, addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handle_command(const string& command) {
|
||||
auto tokens = split(command, ' ');
|
||||
auto tokens = phosg::split(command, ' ');
|
||||
if (tokens.empty()) {
|
||||
throw runtime_error("no command given");
|
||||
}
|
||||
strip_trailing_whitespace(tokens[tokens.size() - 1]);
|
||||
phosg::strip_trailing_whitespace(tokens[tokens.size() - 1]);
|
||||
|
||||
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] == "only") {
|
||||
unordered_set<string> to_keep{tokens.begin() + 1, tokens.end()};
|
||||
for (auto it = this->mems.begin(); it != this->mems.end();) {
|
||||
if (to_keep.count(it->first)) {
|
||||
it++;
|
||||
} else {
|
||||
it = this->mems.erase(it);
|
||||
}
|
||||
}
|
||||
} else if (tokens[0] == "match") {
|
||||
this->find_all_matches(
|
||||
stoul(tokens.at(1), nullptr, 16),
|
||||
tokens.size() >= 3 ? stoul(tokens[2], nullptr, 16) : 0,
|
||||
MatchType::ANY);
|
||||
} else if (tokens[0] == "match-text") {
|
||||
this->find_all_matches(
|
||||
stoul(tokens.at(1), nullptr, 16),
|
||||
tokens.size() >= 3 ? stoul(tokens[2], nullptr, 16) : 0,
|
||||
MatchType::TEXT);
|
||||
} else if (tokens[0] == "match-data") {
|
||||
this->find_all_matches(
|
||||
stoul(tokens.at(1), nullptr, 16),
|
||||
tokens.size() >= 3 ? stoul(tokens[2], nullptr, 16) : 0,
|
||||
MatchType::DATA);
|
||||
} 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] == "parse-dat-object-constructor-tables") ||
|
||||
(tokens[0] == "parse-dat-enemy-constructor-tables")) {
|
||||
bool is_enemies = (tokens[0] == "parse-dat-enemy-constructor-tables");
|
||||
auto specs = ParseDATConstructorTableSpec::from_json_list(phosg::JSON::parse(phosg::load_file(tokens.at(1))));
|
||||
this->parse_dat_constructor_table_multi(specs, is_enemies, true);
|
||||
} else if (!tokens[0].empty()) {
|
||||
throw runtime_error("unknown command");
|
||||
}
|
||||
@@ -451,32 +898,32 @@ public:
|
||||
void run_shell() {
|
||||
while (!feof(stdin)) {
|
||||
if (!this->src_filename.empty()) {
|
||||
fprintf(stdout, "addr-trans:%s/%s> ", this->directory.c_str(), this->src_filename.c_str());
|
||||
phosg::fwrite_fmt(stdout, "addr-trans:{}/{}> ", this->directory, this->src_filename);
|
||||
} else {
|
||||
fprintf(stdout, "addr-trans:%s> ", this->directory.c_str());
|
||||
phosg::fwrite_fmt(stdout, "addr-trans:{}> ", this->directory);
|
||||
}
|
||||
fflush(stdout);
|
||||
|
||||
string command = fgets(stdin);
|
||||
string command = phosg::fgets(stdin);
|
||||
try {
|
||||
this->handle_command(command);
|
||||
} catch (const exception& e) {
|
||||
this->log.error("Failed: %s", e.what());
|
||||
this->log.error_f("Failed: {}", e.what());
|
||||
}
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
private:
|
||||
PrefixedLogger log;
|
||||
phosg::PrefixedLogger log;
|
||||
string directory;
|
||||
unordered_map<string, shared_ptr<const MemoryContext>> mems;
|
||||
unordered_map<string, shared_ptr<const ResourceDASM::MemoryContext>> mems;
|
||||
unordered_set<shared_ptr<const ResourceDASM::MemoryContext>> ppc_mems;
|
||||
string src_filename;
|
||||
shared_ptr<const MemoryContext> src_mem;
|
||||
bool enable_ppc;
|
||||
shared_ptr<const ResourceDASM::MemoryContext> src_mem;
|
||||
};
|
||||
|
||||
void run_address_translator(const std::string& directory, const std::string& use_filename, const std::string& command) {
|
||||
void run_address_translator(const string& directory, const string& use_filename, const string& command) {
|
||||
AddressTranslator trans(directory);
|
||||
if (!use_filename.empty()) {
|
||||
trans.set_source_file(use_filename);
|
||||
@@ -489,11 +936,11 @@ 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) {
|
||||
DOLFile a(a_filename.c_str());
|
||||
DOLFile b(b_filename.c_str());
|
||||
auto a_mem = make_shared<MemoryContext>();
|
||||
auto b_mem = make_shared<MemoryContext>();
|
||||
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>();
|
||||
auto b_mem = make_shared<ResourceDASM::MemoryContext>();
|
||||
a.load_into(a_mem);
|
||||
b.load_into(b_mem);
|
||||
|
||||
@@ -508,7 +955,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 +963,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
#include "AsyncHTTPServer.hh"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <phosg/Encoding.hh>
|
||||
#include <phosg/Network.hh>
|
||||
#include <phosg/Time.hh>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "AsyncUtils.hh"
|
||||
#include "Loggers.hh"
|
||||
#include "Revision.hh"
|
||||
#include "Server.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static const unordered_map<int, const char*> explanation_for_response_code{
|
||||
{100, "Continue"},
|
||||
{101, "Switching Protocols"},
|
||||
{102, "Processing"},
|
||||
{200, "OK"},
|
||||
{201, "Created"},
|
||||
{202, "Accepted"},
|
||||
{203, "Non-Authoritative Information"},
|
||||
{204, "No Content"},
|
||||
{205, "Reset Content"},
|
||||
{206, "Partial Content"},
|
||||
{207, "Multi-Status"},
|
||||
{208, "Already Reported"},
|
||||
{226, "IM Used"},
|
||||
{300, "Multiple Choices"},
|
||||
{301, "Moved Permanently"},
|
||||
{302, "Found"},
|
||||
{303, "See Other"},
|
||||
{304, "Not Modified"},
|
||||
{305, "Use Proxy"},
|
||||
{307, "Temporary Redirect"},
|
||||
{308, "Permanent Redirect"},
|
||||
{400, "Bad Request"},
|
||||
{401, "Unathorized"},
|
||||
{402, "Payment Required"},
|
||||
{403, "Forbidden"},
|
||||
{404, "Not Found"},
|
||||
{405, "Method Not Allowed"},
|
||||
{406, "Not Acceptable"},
|
||||
{407, "Proxy Authentication Required"},
|
||||
{408, "Request Timeout"},
|
||||
{409, "Conflict"},
|
||||
{410, "Gone"},
|
||||
{411, "Length Required"},
|
||||
{412, "Precondition Failed"},
|
||||
{413, "Request Entity Too Large"},
|
||||
{414, "Request-URI Too Long"},
|
||||
{415, "Unsupported Media Type"},
|
||||
{416, "Requested Range Not Satisfiable"},
|
||||
{417, "Expectation Failed"},
|
||||
{418, "I\'m a Teapot"},
|
||||
{420, "Enhance Your Calm"},
|
||||
{422, "Unprocessable Entity"},
|
||||
{423, "Locked"},
|
||||
{424, "Failed Dependency"},
|
||||
{426, "Upgrade Required"},
|
||||
{428, "Precondition Required"},
|
||||
{429, "Too Many Requests"},
|
||||
{431, "Request Header Fields Too Large"},
|
||||
{444, "No Response"},
|
||||
{449, "Retry With"},
|
||||
{451, "Unavailable For Legal Reasons"},
|
||||
{500, "Internal Server Error"},
|
||||
{501, "Not Implemented"},
|
||||
{502, "Bad Gateway"},
|
||||
{503, "Service Unavailable"},
|
||||
{504, "Gateway Timeout"},
|
||||
{505, "HTTP Version Not Supported"},
|
||||
{506, "Variant Also Negotiates"},
|
||||
{507, "Insufficient Storage"},
|
||||
{508, "Loop Detected"},
|
||||
{509, "Bandwidth Limit Exceeded"},
|
||||
{510, "Not Extended"},
|
||||
{511, "Network Authentication Required"},
|
||||
{598, "Network Read Timeout Error"},
|
||||
{599, "Network Connect Timeout Error"},
|
||||
};
|
||||
|
||||
HTTPError::HTTPError(int code, const std::string& what)
|
||||
: std::runtime_error(what), code(code) {}
|
||||
|
||||
const std::string* HTTPRequest::get_header(const std::string& name) const {
|
||||
auto its = this->headers.equal_range(name);
|
||||
if (its.first == its.second) {
|
||||
return nullptr;
|
||||
}
|
||||
const string* ret = &its.first->second;
|
||||
its.first++;
|
||||
if (its.first != its.second) {
|
||||
throw std::out_of_range("Header appears multiple times: " + name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::string* HTTPRequest::get_query_param(const std::string& name) const {
|
||||
auto its = this->query_params.equal_range(name);
|
||||
if (its.first == its.second) {
|
||||
return nullptr;
|
||||
}
|
||||
const string* ret = &its.first->second;
|
||||
its.first++;
|
||||
if (its.first != its.second) {
|
||||
throw std::out_of_range("Query parameter appears multiple times: " + name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void url_decode_inplace(string& s) {
|
||||
size_t write_offset = 0, read_offset = 0;
|
||||
for (; read_offset < s.size(); write_offset++) {
|
||||
if ((s[read_offset] == '%') && (read_offset < s.size() - 2)) {
|
||||
s[write_offset] =
|
||||
static_cast<char>(phosg::value_for_hex_char(s[read_offset + 1]) << 4) |
|
||||
static_cast<char>(phosg::value_for_hex_char(s[read_offset + 2]));
|
||||
read_offset += 3;
|
||||
} else if (s[write_offset] == '+') {
|
||||
s[write_offset] = ' ';
|
||||
read_offset++;
|
||||
} else {
|
||||
s[write_offset] = s[read_offset];
|
||||
read_offset++;
|
||||
}
|
||||
}
|
||||
s.resize(write_offset);
|
||||
}
|
||||
|
||||
HTTPClient::HTTPClient(asio::ip::tcp::socket&& sock) : r(std::move(sock)) {}
|
||||
|
||||
asio::awaitable<HTTPRequest> HTTPClient::recv_http_request(size_t max_line_size, size_t max_body_size) {
|
||||
HTTPRequest req;
|
||||
std::string request_line = co_await this->r.read_line("\r\n", max_line_size);
|
||||
auto line_tokens = phosg::split(request_line, ' ');
|
||||
if (line_tokens.size() != 3) {
|
||||
throw runtime_error("invalid HTTP request line");
|
||||
}
|
||||
const auto& method_token = line_tokens[0];
|
||||
if (method_token == "GET") {
|
||||
req.method = HTTPRequest::Method::GET;
|
||||
} else if (method_token == "POST") {
|
||||
req.method = HTTPRequest::Method::POST;
|
||||
} else if (method_token == "DELETE") {
|
||||
req.method = HTTPRequest::Method::DELETE;
|
||||
} else if (method_token == "HEAD") {
|
||||
req.method = HTTPRequest::Method::HEAD;
|
||||
} else if (method_token == "PATCH") {
|
||||
req.method = HTTPRequest::Method::PATCH;
|
||||
} else if (method_token == "PUT") {
|
||||
req.method = HTTPRequest::Method::PUT;
|
||||
} else if (method_token == "UPDATE") {
|
||||
req.method = HTTPRequest::Method::UPDATE;
|
||||
} else if (method_token == "OPTIONS") {
|
||||
req.method = HTTPRequest::Method::OPTIONS;
|
||||
} else if (method_token == "CONNECT") {
|
||||
req.method = HTTPRequest::Method::CONNECT;
|
||||
} else if (method_token == "TRACE") {
|
||||
req.method = HTTPRequest::Method::TRACE;
|
||||
} else {
|
||||
throw HTTPError(400, "Unknown request method");
|
||||
}
|
||||
|
||||
req.http_version = std::move(line_tokens[2]);
|
||||
|
||||
size_t fragment_start_offset = line_tokens[1].find('#');
|
||||
if (fragment_start_offset != string::npos) {
|
||||
req.fragment = line_tokens[1].substr(fragment_start_offset + 1);
|
||||
line_tokens[1].resize(fragment_start_offset);
|
||||
}
|
||||
|
||||
size_t query_start_offset = line_tokens[1].find('?');
|
||||
string query;
|
||||
if (query_start_offset != string::npos) {
|
||||
query = line_tokens[1].substr(query_start_offset + 1);
|
||||
line_tokens[1].resize(query_start_offset);
|
||||
}
|
||||
|
||||
req.path = std::move(line_tokens[1]);
|
||||
if (req.path.empty()) {
|
||||
throw std::runtime_error("request path is missing");
|
||||
}
|
||||
|
||||
auto query_tokens = phosg::split(query, '&');
|
||||
for (auto& token : query_tokens) {
|
||||
size_t equals_pos = token.find('=');
|
||||
if (equals_pos == string::npos) {
|
||||
url_decode_inplace(token);
|
||||
req.query_params.emplace(std::move(token), "");
|
||||
} else {
|
||||
string key = token.substr(0, equals_pos);
|
||||
string value = token.substr(equals_pos + 1);
|
||||
url_decode_inplace(key);
|
||||
url_decode_inplace(value);
|
||||
req.query_params.emplace(std::move(key), std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
auto prev_header_it = req.headers.end();
|
||||
for (;;) {
|
||||
std::string line = co_await this->r.read_line("\r\n", max_line_size);
|
||||
if (line.empty()) {
|
||||
break;
|
||||
}
|
||||
if (line[0] == ' ' || line[0] == '\t') {
|
||||
if (prev_header_it == req.headers.end()) {
|
||||
throw std::runtime_error("received header continuation line before any header");
|
||||
} else {
|
||||
phosg::strip_whitespace(line);
|
||||
prev_header_it->second.append(1, ' ');
|
||||
prev_header_it->second += line;
|
||||
}
|
||||
} else {
|
||||
size_t colon_pos = line.find(':');
|
||||
if (colon_pos == string::npos) {
|
||||
throw runtime_error("malformed header line");
|
||||
}
|
||||
string key = line.substr(0, colon_pos);
|
||||
string value = line.substr(colon_pos + 1);
|
||||
phosg::strip_whitespace(key);
|
||||
phosg::strip_whitespace(value);
|
||||
prev_header_it = req.headers.emplace(phosg::tolower(key), std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
auto transfer_encoding_header = req.get_header("transfer-encoding");
|
||||
if (transfer_encoding_header && phosg::tolower(*transfer_encoding_header) == "chunked") {
|
||||
deque<string> chunks;
|
||||
size_t total_data_bytes = 0;
|
||||
for (;;) {
|
||||
auto line = co_await this->r.read_line("\r\n", 0x20);
|
||||
size_t parse_offset = 0;
|
||||
size_t chunk_size = stoull(line, &parse_offset, 16);
|
||||
if (parse_offset != line.size()) {
|
||||
throw HTTPError(400, "Invalid chunk header during chunked encoding");
|
||||
}
|
||||
if (chunk_size == 0) {
|
||||
break;
|
||||
}
|
||||
total_data_bytes += chunk_size;
|
||||
if (total_data_bytes > max_body_size) {
|
||||
throw HTTPError(400, "Request data size too large");
|
||||
}
|
||||
chunks.emplace_back(co_await this->r.read_data(chunk_size));
|
||||
auto after_chunk_data = co_await this->r.read_line("\r\n", 0x20);
|
||||
if (!after_chunk_data.empty()) {
|
||||
throw HTTPError(400, "Incorrect trailing sequence after chunk data");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto content_length_header = req.get_header("content-length");
|
||||
size_t content_length = content_length_header ? stoull(*content_length_header) : 0;
|
||||
if (content_length > max_body_size) {
|
||||
throw HTTPError(400, "Request data size too large");
|
||||
} else if (content_length > 0) {
|
||||
req.data = co_await this->r.read_data(content_length);
|
||||
}
|
||||
}
|
||||
|
||||
co_return req;
|
||||
}
|
||||
|
||||
asio::awaitable<void> HTTPClient::send_http_response(const HTTPResponse& resp) {
|
||||
AsyncWriteCollector w;
|
||||
w.add(std::format("{} {} {}\r\n",
|
||||
resp.http_version, resp.response_code, explanation_for_response_code.at(resp.response_code)));
|
||||
for (const auto& it : resp.headers) {
|
||||
w.add(it.first + ": " + it.second + "\r\n");
|
||||
}
|
||||
if (!resp.data.empty()) {
|
||||
w.add(std::format("Content-Length: {}\r\n", resp.data.size()));
|
||||
}
|
||||
w.add("\r\n");
|
||||
if (!resp.data.empty()) {
|
||||
w.add_reference(resp.data.data(), resp.data.size());
|
||||
}
|
||||
co_await w.write(this->r.get_socket());
|
||||
}
|
||||
|
||||
asio::awaitable<WebSocketMessage> HTTPClient::recv_websocket_message(size_t max_data_size) {
|
||||
WebSocketMessage prev_msg;
|
||||
bool prev_msg_present = false;
|
||||
|
||||
while (this->r.get_socket().is_open()) {
|
||||
WebSocketMessage msg;
|
||||
|
||||
// We need at most 10 bytes to determine if there's a valid frame, or as little as 2
|
||||
co_await this->r.read_data_into(msg.header, 2);
|
||||
|
||||
// Get the payload size
|
||||
bool has_mask = msg.header[1] & 0x80;
|
||||
size_t payload_size = msg.header[1] & 0x7F;
|
||||
if (payload_size == 0x7F) {
|
||||
phosg::be_uint64_t wire_size;
|
||||
co_await this->r.read_data_into(&wire_size, sizeof(wire_size));
|
||||
payload_size = wire_size;
|
||||
} else if (payload_size == 0x7E) {
|
||||
phosg::be_uint16_t wire_size;
|
||||
co_await this->r.read_data_into(&wire_size, sizeof(wire_size));
|
||||
payload_size = wire_size;
|
||||
}
|
||||
|
||||
if (payload_size > max_data_size) {
|
||||
throw runtime_error("Incoming WebSocket message exceeds size limit");
|
||||
}
|
||||
|
||||
// Read the masking key if present
|
||||
if (has_mask) {
|
||||
co_await this->r.read_data_into(msg.mask_key, sizeof(msg.mask_key));
|
||||
}
|
||||
|
||||
// Read and unmask message data
|
||||
msg.data = co_await this->r.read_data(payload_size);
|
||||
if (has_mask) {
|
||||
for (size_t x = 0; x < msg.data.size(); x++) {
|
||||
msg.data[x] ^= msg.mask_key[x & 3];
|
||||
}
|
||||
}
|
||||
|
||||
this->last_communication_time = phosg::now();
|
||||
|
||||
// If the current message is a control message, respond appropriately (these can be sent in the middle of
|
||||
// fragmented messages)
|
||||
uint8_t opcode = msg.header[0] & 0x0F;
|
||||
if (opcode & 0x08) {
|
||||
if (opcode == 0x0A) {
|
||||
// Ping response; ignore it
|
||||
|
||||
} else if (opcode == 0x08) {
|
||||
// Close message
|
||||
co_await this->send_websocket_message(msg.data, msg.opcode);
|
||||
this->r.close();
|
||||
|
||||
} else if (opcode == 0x09) {
|
||||
// Ping message
|
||||
co_await this->send_websocket_message(msg.data, 0x0A);
|
||||
|
||||
} else {
|
||||
// Unknown control message type
|
||||
this->r.close();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's an existing fragment, the current message's opcode should be zero; if there's no pending message, it
|
||||
// must not be zero
|
||||
if (prev_msg_present == (opcode != 0)) {
|
||||
this->r.close();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Save the message opcode, if present, and append the frame data
|
||||
if (!prev_msg_present) {
|
||||
prev_msg = std::move(msg);
|
||||
} else {
|
||||
prev_msg.header[0] = msg.header[0];
|
||||
prev_msg.header[1] = msg.header[1];
|
||||
if (opcode) {
|
||||
prev_msg.opcode = msg.opcode;
|
||||
}
|
||||
if (has_mask) {
|
||||
prev_msg.mask_key[0] = msg.mask_key[0];
|
||||
prev_msg.mask_key[1] = msg.mask_key[1];
|
||||
prev_msg.mask_key[2] = msg.mask_key[2];
|
||||
prev_msg.mask_key[3] = msg.mask_key[3];
|
||||
}
|
||||
prev_msg.data += msg.data;
|
||||
}
|
||||
|
||||
// If the FIN bit is set, then the frame is complete - append the payload to any pending payloads and call the
|
||||
// message handler. If the FIN bit isn't set, we need to receive at least one continuation frame to complete the
|
||||
// message.
|
||||
if (prev_msg.header[0] & 0x80) {
|
||||
co_return prev_msg;
|
||||
}
|
||||
}
|
||||
|
||||
throw logic_error("failed to receive websocket message");
|
||||
}
|
||||
|
||||
asio::awaitable<void> HTTPClient::send_websocket_message(const void* data, size_t size, uint8_t opcode) {
|
||||
phosg::StringWriter w;
|
||||
w.put_u8(0x80 | (opcode & 0x0F));
|
||||
if (size > 0xFFFF) {
|
||||
w.put_u8(0x7F);
|
||||
w.put_u64b(size);
|
||||
} else if (size > 0x7D) {
|
||||
w.put_u8(0x7E);
|
||||
w.put_u16b(size);
|
||||
} else {
|
||||
w.put_u8(size);
|
||||
}
|
||||
|
||||
array<asio::const_buffer, 2> bufs = {asio::const_buffer(w.data(), w.size()), asio::const_buffer(data, size)};
|
||||
co_await asio::async_write(this->r.get_socket(), bufs, asio::use_awaitable);
|
||||
}
|
||||
|
||||
asio::awaitable<void> HTTPClient::send_websocket_message(const std::string& data, uint8_t opcode) {
|
||||
return this->send_websocket_message(data.data(), data.size(), opcode);
|
||||
}
|
||||
|
||||
const HTTPServerLimits DEFAULT_HTTP_LIMITS;
|
||||
@@ -0,0 +1,348 @@
|
||||
#pragma once
|
||||
|
||||
#include "WindowsPlatform.hh"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <phosg/Encoding.hh>
|
||||
#include <phosg/Hash.hh>
|
||||
#include <phosg/Time.hh>
|
||||
#include <string>
|
||||
|
||||
#include "AsyncUtils.hh"
|
||||
#include "Server.hh"
|
||||
|
||||
struct HTTPRequest {
|
||||
enum class Method {
|
||||
GET = 0,
|
||||
POST,
|
||||
DELETE,
|
||||
HEAD,
|
||||
PATCH,
|
||||
PUT,
|
||||
UPDATE,
|
||||
OPTIONS,
|
||||
CONNECT,
|
||||
TRACE,
|
||||
};
|
||||
std::string http_version;
|
||||
Method method;
|
||||
std::string path;
|
||||
std::string fragment;
|
||||
std::unordered_multimap<std::string, std::string> headers; // Header names converted to all lowercase
|
||||
std::unordered_multimap<std::string, std::string> query_params;
|
||||
std::string data;
|
||||
|
||||
// Header name should be entirely lowercase for this function. Returns nullptr if the header doesn't exist; throws
|
||||
// http_error(400) if multiple instances of it exist.
|
||||
const std::string* get_header(const std::string& name) const;
|
||||
|
||||
const std::string* get_query_param(const std::string& name) const;
|
||||
};
|
||||
|
||||
struct HTTPResponse {
|
||||
std::string http_version;
|
||||
int response_code = 200;
|
||||
// Content-Length should NOT be specified in headers; it is automatically added in async_write() if data isn't blank.
|
||||
std::unordered_multimap<std::string, std::string> headers;
|
||||
std::string data;
|
||||
};
|
||||
|
||||
struct WebSocketMessage {
|
||||
uint8_t header[2] = {0, 0};
|
||||
uint8_t opcode = 0x01;
|
||||
uint8_t mask_key[4] = {0, 0, 0, 0};
|
||||
std::string data;
|
||||
};
|
||||
|
||||
class HTTPError : public std::runtime_error {
|
||||
public:
|
||||
HTTPError(int code, const std::string& what);
|
||||
int code;
|
||||
};
|
||||
|
||||
struct HTTPClient {
|
||||
AsyncSocketReader r;
|
||||
uint64_t last_communication_time = 0;
|
||||
bool is_websocket = false;
|
||||
|
||||
HTTPClient(asio::ip::tcp::socket&& sock);
|
||||
|
||||
asio::awaitable<HTTPRequest> recv_http_request(size_t max_line_size, size_t max_body_size);
|
||||
asio::awaitable<void> send_http_response(const HTTPResponse& resp);
|
||||
|
||||
asio::awaitable<WebSocketMessage> recv_websocket_message(size_t max_data_size);
|
||||
asio::awaitable<void> send_websocket_message(const void* data, size_t size, uint8_t opcode = 0x01);
|
||||
asio::awaitable<void> send_websocket_message(const std::string& data, uint8_t opcode = 0x01);
|
||||
};
|
||||
|
||||
template <typename RetT>
|
||||
class HTTPRouter {
|
||||
public:
|
||||
struct Args {
|
||||
std::shared_ptr<HTTPClient> client;
|
||||
const HTTPRequest& req;
|
||||
std::unordered_map<std::string, std::string> params;
|
||||
phosg::JSON post_data;
|
||||
|
||||
template <typename T>
|
||||
requires(std::is_integral_v<T>)
|
||||
T get_param(const char* name, bool hex = false) const {
|
||||
const auto& value_str = this->params.at(name);
|
||||
size_t conversion_end;
|
||||
int64_t v = std::stoull(value_str, &conversion_end, hex ? 16 : 0);
|
||||
if (conversion_end != value_str.size()) {
|
||||
throw HTTPError(400, "Invalid integer value");
|
||||
}
|
||||
|
||||
uint64_t uv = static_cast<uint64_t>(v);
|
||||
if constexpr (std::is_unsigned_v<T>) {
|
||||
if (uv & (~phosg::mask_for_type<T>)) {
|
||||
throw HTTPError(400, "Unsigned value out of range");
|
||||
}
|
||||
return uv;
|
||||
} else {
|
||||
if (((uv & (~(phosg::mask_for_type<T> >> 1))) != 0) && ((uv & (~(phosg::mask_for_type<T> >> 1))) != (~(phosg::mask_for_type<T> >> 1)))) {
|
||||
throw HTTPError(400, "Signed value out of range");
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using Handler = std::function<asio::awaitable<RetT>(Args&&)>;
|
||||
|
||||
static std::vector<std::string> split_and_normalize_path(const std::string& path) {
|
||||
auto path_tokens = phosg::split(path, '/');
|
||||
while (!path_tokens.empty() && path_tokens.back().empty()) {
|
||||
path_tokens.pop_back();
|
||||
}
|
||||
return path_tokens;
|
||||
}
|
||||
|
||||
void add(HTTPRequest::Method method, const std::string& path_pattern, Handler handler) {
|
||||
this->routes.emplace_back(Route{
|
||||
.method = method, .path_tokens = this->split_and_normalize_path(path_pattern), .handler = handler});
|
||||
}
|
||||
|
||||
asio::awaitable<RetT> call_handler(std::shared_ptr<HTTPClient> c, const HTTPRequest& req) {
|
||||
Args args = {.client = c, .req = req, .params = {}, .post_data = phosg::JSON()};
|
||||
|
||||
auto tokens = this->split_and_normalize_path(req.path);
|
||||
for (const auto& route : this->routes) {
|
||||
if (route.path_tokens.size() != tokens.size()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool matched = true;
|
||||
args.params.clear();
|
||||
for (size_t z = 0; z < tokens.size(); z++) {
|
||||
if (route.path_tokens[z].starts_with(':')) {
|
||||
args.params.emplace(route.path_tokens[z].substr(1), tokens[z]);
|
||||
} else if (route.path_tokens[z] != tokens[z]) {
|
||||
matched = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matched) {
|
||||
if (req.method != route.method) {
|
||||
throw HTTPError(405, "Incorrect HTTP method");
|
||||
}
|
||||
if (req.method == HTTPRequest::Method::POST) {
|
||||
auto* content_type = req.get_header("content-type");
|
||||
if (!content_type || (*content_type != "application/json")) {
|
||||
throw HTTPError(400, "POST requests must use the application/json content type");
|
||||
}
|
||||
try {
|
||||
args.post_data = phosg::JSON::parse(req.data);
|
||||
} catch (const std::exception& e) {
|
||||
throw HTTPError(400, std::format("Invalid JSON: {}", e.what()));
|
||||
}
|
||||
}
|
||||
co_return co_await route.handler(std::move(args));
|
||||
}
|
||||
}
|
||||
|
||||
throw HTTPError(404, "Request path did not match any route");
|
||||
}
|
||||
|
||||
private:
|
||||
struct Route {
|
||||
HTTPRequest::Method method;
|
||||
std::vector<std::string> path_tokens;
|
||||
Handler handler;
|
||||
};
|
||||
std::vector<Route> routes;
|
||||
};
|
||||
|
||||
struct HTTPServerLimits {
|
||||
size_t max_http_request_line_size = 0x1000; // 4KB
|
||||
size_t max_http_data_size = 0x200000; // 2MB
|
||||
size_t max_http_keepalive_idle_usecs = 300 * 1000 * 1000; // 5 minutes (0 = no limit)
|
||||
size_t max_websocket_message_size = 0x200000; // 2MB
|
||||
size_t max_websocket_idle_usecs = 0; // No limit by default
|
||||
};
|
||||
|
||||
extern const HTTPServerLimits DEFAULT_HTTP_LIMITS;
|
||||
|
||||
template <typename ClientT = HTTPClient>
|
||||
class AsyncHTTPServer : public Server<ClientT, ServerSocket> {
|
||||
public:
|
||||
explicit AsyncHTTPServer(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
const std::string& log_prefix = "[AsyncHTTPServer] ",
|
||||
const HTTPServerLimits& limits = DEFAULT_HTTP_LIMITS)
|
||||
: Server<ClientT, ServerSocket>(io_context, log_prefix), limits(limits) {}
|
||||
AsyncHTTPServer(const AsyncHTTPServer&) = delete;
|
||||
AsyncHTTPServer(AsyncHTTPServer&&) = delete;
|
||||
AsyncHTTPServer& operator=(const AsyncHTTPServer&) = delete;
|
||||
AsyncHTTPServer& operator=(AsyncHTTPServer&&) = delete;
|
||||
virtual ~AsyncHTTPServer() = default;
|
||||
|
||||
void listen(const std::string& addr, int port) {
|
||||
if (port == 0) {
|
||||
throw std::runtime_error("Listening port cannot be zero");
|
||||
}
|
||||
asio::ip::address asio_addr = addr.empty() ? asio::ip::address_v4::any() : asio::ip::make_address(addr);
|
||||
auto sock = std::make_shared<ServerSocket>();
|
||||
sock->name = std::format("http:{}:{}", addr, port);
|
||||
sock->endpoint = asio::ip::tcp::endpoint(asio_addr, port);
|
||||
this->add_socket(std::move(sock));
|
||||
}
|
||||
|
||||
protected:
|
||||
HTTPServerLimits limits;
|
||||
|
||||
void require_GET(const HTTPRequest& req) {
|
||||
if (req.method != HTTPRequest::Method::GET) {
|
||||
throw HTTPError(405, "GET method required for this endpoint");
|
||||
}
|
||||
}
|
||||
|
||||
phosg::JSON require_JSON_POST(const HTTPRequest& req) {
|
||||
if (req.method != HTTPRequest::Method::POST) {
|
||||
throw HTTPError(405, "POST method required for this endpoint");
|
||||
}
|
||||
|
||||
auto* content_type = req.get_header("content-type");
|
||||
if (!content_type || (*content_type != "application/json")) {
|
||||
throw HTTPError(400, "POST requests must use the application/json content type");
|
||||
}
|
||||
|
||||
try {
|
||||
return phosg::JSON::parse(req.data);
|
||||
} catch (const std::exception& e) {
|
||||
throw HTTPError(400, std::format("Invalid JSON: {}", e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to switch the client to WebSockets. Returns true if this is done successfully (and the caller should then
|
||||
// receive/send WebSocket messages), or false if this failed (and the caller should send an HTTP response).
|
||||
asio::awaitable<bool> enable_websockets(std::shared_ptr<ClientT> c, const HTTPRequest& req) {
|
||||
if (req.method != HTTPRequest::Method::GET) {
|
||||
co_return false;
|
||||
}
|
||||
|
||||
auto connection_header = req.get_header("connection");
|
||||
if (!connection_header || phosg::tolower(*connection_header) != "upgrade") {
|
||||
co_return false;
|
||||
}
|
||||
auto upgrade_header = req.get_header("upgrade");
|
||||
if (!upgrade_header || phosg::tolower(*upgrade_header) != "websocket") {
|
||||
co_return false;
|
||||
}
|
||||
auto sec_websocket_key_header = req.get_header("sec-websocket-key");
|
||||
if (!sec_websocket_key_header) {
|
||||
co_return false;
|
||||
}
|
||||
|
||||
std::string sec_websocket_accept_data = *sec_websocket_key_header + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
std::string sec_websocket_accept = phosg::base64_encode(phosg::SHA1(sec_websocket_accept_data).bin());
|
||||
|
||||
HTTPResponse resp;
|
||||
resp.http_version = req.http_version;
|
||||
resp.response_code = 101;
|
||||
resp.headers.emplace("Upgrade", "websocket");
|
||||
resp.headers.emplace("Connection", "upgrade");
|
||||
resp.headers.emplace("Sec-WebSocket-Accept", std::move(sec_websocket_accept));
|
||||
co_await c->send_http_response(resp);
|
||||
|
||||
c->is_websocket = true;
|
||||
co_return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual std::shared_ptr<ClientT> create_client(
|
||||
std::shared_ptr<ServerSocket>, asio::ip::tcp::socket&& client_sock) {
|
||||
return std::make_shared<HTTPClient>(std::move(client_sock));
|
||||
}
|
||||
|
||||
// handle_request must do one of the following three things:
|
||||
// 1. Return an HTTP response.
|
||||
// 2. Call enable_websockets, and if it returns true, return nullptr. After this point, handle_request will not be
|
||||
// called again for this client; handle_websocket_message will be called instead when any WebSocket messages are
|
||||
// received. If enable_websockets returns false, handle_request must still return an HTTP response.
|
||||
// 3. Throw an exception. In this case, the client receives an HTTP 500 response.
|
||||
virtual asio::awaitable<std::unique_ptr<HTTPResponse>> handle_request(std::shared_ptr<ClientT> c, HTTPRequest&& req) = 0;
|
||||
virtual asio::awaitable<void> handle_websocket_message(std::shared_ptr<ClientT>, WebSocketMessage&&) {
|
||||
co_return;
|
||||
}
|
||||
|
||||
virtual asio::awaitable<void> handle_client(std::shared_ptr<ClientT> c) {
|
||||
asio::steady_timer idle_timer(*this->io_context);
|
||||
while (c->r.get_socket().is_open()) {
|
||||
if (c->is_websocket) {
|
||||
WebSocketMessage msg = co_await c->recv_websocket_message(this->limits.max_websocket_message_size);
|
||||
idle_timer.cancel();
|
||||
try {
|
||||
co_await this->handle_websocket_message(c, std::move(msg));
|
||||
} catch (const std::exception& e) {
|
||||
c->r.close();
|
||||
}
|
||||
|
||||
} else {
|
||||
HTTPRequest req = co_await c->recv_http_request(
|
||||
this->limits.max_http_request_line_size, this->limits.max_http_data_size);
|
||||
idle_timer.cancel();
|
||||
std::unique_ptr<HTTPResponse> resp;
|
||||
try {
|
||||
resp = co_await this->handle_request(c, std::move(req));
|
||||
} catch (const std::exception& e) {
|
||||
resp = std::make_unique<HTTPResponse>();
|
||||
resp->http_version = req.http_version;
|
||||
resp->response_code = 500;
|
||||
resp->headers.emplace("Content-Type", "text/plain");
|
||||
resp->data = "Internal server error:\n";
|
||||
resp->data += e.what();
|
||||
}
|
||||
if (resp) {
|
||||
co_await c->send_http_response(*resp);
|
||||
}
|
||||
if (!c->is_websocket) {
|
||||
auto* conn_header = req.get_header("connection");
|
||||
if (!conn_header || (*conn_header != "keep-alive")) {
|
||||
c->r.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t idle_usecs_limit = c->is_websocket
|
||||
? this->limits.max_websocket_idle_usecs
|
||||
: this->limits.max_http_keepalive_idle_usecs;
|
||||
if (idle_usecs_limit && c->r.get_socket().is_open()) {
|
||||
idle_timer.expires_after(std::chrono::microseconds(idle_usecs_limit));
|
||||
idle_timer.async_wait([c](std::error_code ec) {
|
||||
if (!ec) {
|
||||
c->r.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
idle_timer.cancel();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,162 @@
|
||||
#include "AsyncUtils.hh"
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <phosg/Strings.hh>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
AsyncEvent::AsyncEvent(asio::any_io_executor ex)
|
||||
: executor(ex), is_set(false) {}
|
||||
|
||||
void AsyncEvent::set() {
|
||||
std::vector<std::unique_ptr<asio::detail::awaitable_handler<asio::any_io_executor>>> waiters_to_resume;
|
||||
{
|
||||
lock_guard g(this->lock);
|
||||
this->is_set = true;
|
||||
this->waiters.swap(waiters_to_resume);
|
||||
}
|
||||
for (auto& waiter : waiters_to_resume) {
|
||||
asio::post(this->executor,
|
||||
[handler = std::move(waiter)]() mutable {
|
||||
(*handler)();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncEvent::clear() {
|
||||
lock_guard g(this->lock);
|
||||
this->is_set = false;
|
||||
}
|
||||
|
||||
asio::awaitable<void> AsyncEvent::wait() {
|
||||
auto token = asio::use_awaitable_t<>{};
|
||||
co_await asio::async_initiate<asio::use_awaitable_t<>, void()>(
|
||||
[this](auto&& handler) -> void {
|
||||
lock_guard g(this->lock);
|
||||
if (this->is_set) {
|
||||
handler();
|
||||
} else {
|
||||
this->waiters.emplace_back(make_unique<asio::detail::awaitable_handler<asio::any_io_executor>>(std::move(handler)));
|
||||
}
|
||||
},
|
||||
token);
|
||||
}
|
||||
|
||||
AsyncSocketReader::AsyncSocketReader(asio::ip::tcp::socket&& sock)
|
||||
: sock(std::move(sock)) {}
|
||||
|
||||
asio::awaitable<string> AsyncSocketReader::read_line(const char* delimiter, size_t max_length) {
|
||||
size_t delimiter_size = strlen(delimiter);
|
||||
if (delimiter_size == 0) {
|
||||
throw logic_error("delimiter is empty");
|
||||
}
|
||||
size_t delimiter_backup_bytes = delimiter_size - 1;
|
||||
|
||||
size_t delimiter_pos = this->pending_data.find(delimiter);
|
||||
while ((delimiter_pos == string::npos) && (!max_length || (this->pending_data.size() < max_length))) {
|
||||
size_t pre_size = this->pending_data.size();
|
||||
this->pending_data.resize(min(max_length, this->pending_data.size() + 0x400));
|
||||
|
||||
auto buf = asio::buffer(this->pending_data.data() + pre_size, this->pending_data.size() - pre_size);
|
||||
size_t bytes_read = co_await this->sock.async_read_some(buf, asio::use_awaitable);
|
||||
this->pending_data.resize(pre_size + bytes_read);
|
||||
delimiter_pos = this->pending_data.find(
|
||||
delimiter,
|
||||
(delimiter_backup_bytes > pre_size) ? 0 : (pre_size - delimiter_backup_bytes));
|
||||
}
|
||||
|
||||
if (delimiter_pos == string::npos) {
|
||||
throw runtime_error("line exceeds max length");
|
||||
}
|
||||
|
||||
// TODO: It's not great that we copy the data here. There's probably a more idiomatic and efficient way to do this.
|
||||
string ret = this->pending_data.substr(0, delimiter_pos);
|
||||
this->pending_data = this->pending_data.substr(delimiter_pos + delimiter_size);
|
||||
co_return ret;
|
||||
}
|
||||
|
||||
asio::awaitable<string> AsyncSocketReader::read_data(size_t size) {
|
||||
string ret;
|
||||
if (this->pending_data.size() == size) {
|
||||
this->pending_data.swap(ret);
|
||||
} else if (this->pending_data.size() > size) {
|
||||
ret = this->pending_data.substr(0, size);
|
||||
this->pending_data = this->pending_data.substr(size);
|
||||
} else {
|
||||
size_t bytes_to_read = size - this->pending_data.size();
|
||||
this->pending_data.swap(ret);
|
||||
ret.resize(size);
|
||||
co_await asio::async_read(this->sock, asio::buffer(ret.data() + size - bytes_to_read, bytes_to_read), asio::use_awaitable);
|
||||
}
|
||||
co_return ret;
|
||||
}
|
||||
|
||||
asio::awaitable<void> AsyncSocketReader::read_data_into(void* data, size_t size) {
|
||||
if (this->pending_data.size() == size) {
|
||||
memcpy(data, this->pending_data.data(), size);
|
||||
this->pending_data.clear();
|
||||
} else if (this->pending_data.size() > size) {
|
||||
memcpy(data, this->pending_data.data(), size);
|
||||
this->pending_data = this->pending_data.substr(size);
|
||||
} else {
|
||||
memcpy(data, this->pending_data.data(), this->pending_data.size());
|
||||
size_t bytes_to_read = size - this->pending_data.size();
|
||||
this->pending_data.clear();
|
||||
void* read_buf = reinterpret_cast<uint8_t*>(data) + size - bytes_to_read;
|
||||
co_await asio::async_read(this->sock, asio::buffer(read_buf, bytes_to_read), asio::use_awaitable);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncWriteCollector::add(string&& data) {
|
||||
const auto& item = this->owned_data.emplace_back(std::move(data));
|
||||
bufs.emplace_back(asio::buffer(item.data(), item.size()));
|
||||
}
|
||||
|
||||
void AsyncWriteCollector::add_reference(const void* data, size_t size) {
|
||||
bufs.emplace_back(asio::buffer(data, size));
|
||||
}
|
||||
|
||||
asio::awaitable<void> AsyncWriteCollector::write(asio::ip::tcp::socket& sock) {
|
||||
deque<string> local_owned_data;
|
||||
local_owned_data.swap(this->owned_data);
|
||||
vector<asio::const_buffer> local_bufs;
|
||||
local_bufs.swap(this->bufs);
|
||||
co_await asio::async_write(sock, local_bufs, asio::use_awaitable);
|
||||
}
|
||||
|
||||
asio::awaitable<void> async_sleep(chrono::steady_clock::duration duration) {
|
||||
asio::steady_timer timer(co_await asio::this_coro::executor, duration);
|
||||
co_await timer.async_wait(asio::use_awaitable);
|
||||
}
|
||||
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(uint32_t ipv4_addr, uint16_t port) {
|
||||
uint8_t octets[4] = {
|
||||
static_cast<uint8_t>(ipv4_addr >> 24),
|
||||
static_cast<uint8_t>(ipv4_addr >> 16),
|
||||
static_cast<uint8_t>(ipv4_addr >> 8),
|
||||
static_cast<uint8_t>(ipv4_addr)};
|
||||
return async_connect_tcp(std::format("{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]), port);
|
||||
}
|
||||
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(const std::string& host, uint16_t port) {
|
||||
auto executor = co_await asio::this_coro::executor;
|
||||
|
||||
asio::ip::tcp::resolver resolver(executor);
|
||||
auto endpoints = co_await resolver.async_resolve(host, std::format("{}", port), asio::use_awaitable);
|
||||
|
||||
asio::ip::tcp::socket sock(executor);
|
||||
co_await asio::async_connect(sock, endpoints, asio::use_awaitable);
|
||||
|
||||
co_return sock;
|
||||
}
|
||||
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(const asio::ip::tcp::endpoint& ep) {
|
||||
auto executor = co_await asio::this_coro::executor;
|
||||
asio::ip::tcp::socket sock(executor);
|
||||
co_await sock.async_connect(ep, asio::use_awaitable);
|
||||
co_return sock;
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
#pragma once
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <asio/experimental/parallel_group.hpp>
|
||||
#include <asio/experimental/promise.hpp>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <phosg/Strings.hh>
|
||||
|
||||
template <typename T>
|
||||
class AsyncPromise {
|
||||
public:
|
||||
AsyncPromise() = default;
|
||||
|
||||
asio::awaitable<T> get() {
|
||||
if (!this->exc && !this->val.has_value()) {
|
||||
auto executor = co_await asio::this_coro::executor;
|
||||
co_await asio::async_initiate<decltype(asio::use_awaitable), void(std::error_code)>(
|
||||
[this, &executor](auto&& new_handler) {
|
||||
this->resolver_ref.emplace(ResolverRef{.resolve = std::move(new_handler), .executor = &executor});
|
||||
},
|
||||
asio::use_awaitable);
|
||||
}
|
||||
|
||||
if (this->exc) {
|
||||
std::rethrow_exception(this->exc);
|
||||
} else if (this->val.has_value()) {
|
||||
co_return *this->val;
|
||||
} else {
|
||||
throw std::logic_error("AsyncPromise await resolved but did not have a value or exception");
|
||||
}
|
||||
}
|
||||
|
||||
void set_value(T&& result) {
|
||||
if (this->done()) {
|
||||
throw std::logic_error("attempted to set value on completed promise");
|
||||
}
|
||||
this->val = result;
|
||||
this->resolve();
|
||||
}
|
||||
|
||||
void set_exception(std::exception_ptr ex) {
|
||||
if (this->done()) {
|
||||
throw std::logic_error("attempted to set value on completed promise");
|
||||
}
|
||||
this->exc = ex;
|
||||
this->resolve();
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
this->set_exception(std::make_exception_ptr(std::runtime_error("AsyncPromise cancelled")));
|
||||
}
|
||||
|
||||
bool done() const {
|
||||
return this->exc || this->val.has_value();
|
||||
}
|
||||
|
||||
private:
|
||||
struct ResolverRef {
|
||||
asio::detail::awaitable_handler<asio::any_io_executor, std::error_code> resolve;
|
||||
asio::any_io_executor* executor;
|
||||
};
|
||||
std::optional<T> val;
|
||||
std::exception_ptr exc;
|
||||
std::optional<ResolverRef> resolver_ref;
|
||||
|
||||
void resolve() {
|
||||
if (this->resolver_ref) {
|
||||
auto* executor = this->resolver_ref->executor;
|
||||
ResolverRef ref = std::move(*this->resolver_ref);
|
||||
this->resolver_ref.reset();
|
||||
asio::post(*executor, [ref = std::move(ref)]() mutable -> void {
|
||||
ref.resolve(std::error_code{});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class AsyncPromise<void> {
|
||||
public:
|
||||
AsyncPromise() = default;
|
||||
|
||||
asio::awaitable<void> get() {
|
||||
if (!this->exc && !this->returned) {
|
||||
auto executor = co_await asio::this_coro::executor;
|
||||
co_await asio::async_initiate<decltype(asio::use_awaitable), void(std::error_code)>(
|
||||
[this, &executor](auto&& new_handler) {
|
||||
this->resolver_ref.emplace(ResolverRef{.resolve = std::move(new_handler), .executor = &executor});
|
||||
},
|
||||
asio::use_awaitable);
|
||||
}
|
||||
|
||||
if (this->exc) {
|
||||
std::rethrow_exception(this->exc);
|
||||
} else if (this->returned) {
|
||||
co_return;
|
||||
} else {
|
||||
throw std::logic_error("AsyncPromise await resolved but did not have a value or exception");
|
||||
}
|
||||
}
|
||||
|
||||
void set_value() {
|
||||
if (this->done()) {
|
||||
throw std::logic_error("attempted to set value on completed promise");
|
||||
}
|
||||
this->returned = true;
|
||||
this->resolve();
|
||||
}
|
||||
|
||||
void set_exception(std::exception_ptr ex) {
|
||||
if (this->done()) {
|
||||
throw std::logic_error("attempted to set value on completed promise");
|
||||
}
|
||||
this->exc = ex;
|
||||
this->resolve();
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
this->set_exception(std::make_exception_ptr(std::runtime_error("AsyncPromise cancelled")));
|
||||
}
|
||||
|
||||
bool done() const {
|
||||
return this->exc || this->returned;
|
||||
}
|
||||
|
||||
private:
|
||||
struct ResolverRef {
|
||||
asio::detail::awaitable_handler<asio::any_io_executor, std::error_code> resolve;
|
||||
asio::any_io_executor* executor;
|
||||
};
|
||||
bool returned = false;
|
||||
std::exception_ptr exc;
|
||||
std::optional<ResolverRef> resolver_ref;
|
||||
|
||||
void resolve() {
|
||||
if (this->resolver_ref) {
|
||||
auto* executor = this->resolver_ref->executor;
|
||||
ResolverRef ref = std::move(*this->resolver_ref);
|
||||
this->resolver_ref.reset();
|
||||
asio::post(*executor, [ref = std::move(ref)]() mutable -> void {
|
||||
ref.resolve(std::error_code{});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class AsyncEvent {
|
||||
public:
|
||||
AsyncEvent(asio::any_io_executor ex);
|
||||
AsyncEvent(const AsyncEvent&) = delete;
|
||||
AsyncEvent(AsyncEvent&&) = delete;
|
||||
AsyncEvent& operator=(const AsyncEvent&) = delete;
|
||||
AsyncEvent& operator=(AsyncEvent&&) = delete;
|
||||
|
||||
void set();
|
||||
void clear();
|
||||
asio::awaitable<void> wait();
|
||||
|
||||
private:
|
||||
asio::any_io_executor executor;
|
||||
bool is_set;
|
||||
std::mutex lock;
|
||||
std::vector<std::unique_ptr<asio::detail::awaitable_handler<asio::any_io_executor>>> waiters;
|
||||
};
|
||||
|
||||
class AsyncSocketReader {
|
||||
public:
|
||||
explicit AsyncSocketReader(asio::ip::tcp::socket&& sock);
|
||||
AsyncSocketReader(const AsyncSocketReader&) = delete;
|
||||
AsyncSocketReader(AsyncSocketReader&&) = delete;
|
||||
AsyncSocketReader& operator=(const AsyncSocketReader&) = delete;
|
||||
AsyncSocketReader& operator=(AsyncSocketReader&&) = delete;
|
||||
~AsyncSocketReader() = default;
|
||||
|
||||
// Reads one line from the socket, buffering any extra data read. The delimiter is not included in the returned line.
|
||||
// max_length = 0 means no maximum length is enforced.
|
||||
asio::awaitable<std::string> read_line(
|
||||
const char* delimiter = "\n", size_t max_length = 0);
|
||||
asio::awaitable<std::string> read_data(size_t size);
|
||||
asio::awaitable<void> read_data_into(void* data, size_t size);
|
||||
|
||||
// The caller cannot know what the socket's read state is, so this should only be used when the caller intends to
|
||||
// write to the socket, not read
|
||||
inline asio::ip::tcp::socket& get_socket() {
|
||||
return this->sock;
|
||||
}
|
||||
|
||||
inline bool is_open() const {
|
||||
return this->sock.is_open();
|
||||
}
|
||||
|
||||
inline void close() {
|
||||
if (this->sock.is_open()) {
|
||||
this->sock.close();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::string pending_data; // Data read but not yet returned to the caller
|
||||
asio::ip::tcp::socket sock;
|
||||
};
|
||||
|
||||
class AsyncWriteCollector {
|
||||
public:
|
||||
AsyncWriteCollector() = default;
|
||||
AsyncWriteCollector(const AsyncWriteCollector&) = delete;
|
||||
AsyncWriteCollector(AsyncWriteCollector&&) = delete;
|
||||
AsyncWriteCollector& operator=(const AsyncWriteCollector&) = delete;
|
||||
AsyncWriteCollector& operator=(AsyncWriteCollector&&) = delete;
|
||||
~AsyncWriteCollector() = default;
|
||||
|
||||
void add(std::string&& data);
|
||||
|
||||
// When using add_reference, it is the caller's responsibility to ensure that the buffer is valid until *this is
|
||||
// destroyed or write() returns.
|
||||
void add_reference(const void* data, size_t size);
|
||||
|
||||
asio::awaitable<void> write(asio::ip::tcp::socket& sock);
|
||||
|
||||
private:
|
||||
std::deque<std::string> owned_data;
|
||||
std::vector<asio::const_buffer> bufs;
|
||||
};
|
||||
|
||||
asio::awaitable<void> async_sleep(std::chrono::steady_clock::duration duration);
|
||||
|
||||
inline asio::ip::tcp::endpoint make_endpoint_ipv4(uint32_t addr, uint16_t port) {
|
||||
return asio::ip::tcp::endpoint(asio::ip::address_v4(addr), port);
|
||||
}
|
||||
|
||||
inline asio::ip::tcp::endpoint make_endpoint_ipv6(const void* addr, uint16_t port) {
|
||||
std::array<uint8_t, 0x10> bytes;
|
||||
for (size_t z = 0; z < 0x10; z++) {
|
||||
bytes[z] = reinterpret_cast<const uint8_t*>(addr)[z];
|
||||
}
|
||||
return asio::ip::tcp::endpoint(asio::ip::address_v6(bytes), port);
|
||||
}
|
||||
|
||||
inline std::string str_for_endpoint(const asio::ip::tcp::endpoint& ep) {
|
||||
return ep.address().to_string() + std::format(":{}", ep.port());
|
||||
}
|
||||
|
||||
inline uint32_t ipv4_addr_for_asio_addr(const asio::ip::address& addr) {
|
||||
if (!addr.is_v4()) {
|
||||
throw std::runtime_error("Address is not IPv4");
|
||||
}
|
||||
return addr.to_v4().to_uint();
|
||||
}
|
||||
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(uint32_t ipv4_addr, uint16_t port);
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(const std::string& host, uint16_t port);
|
||||
asio::awaitable<asio::ip::tcp::socket> async_connect_tcp(const asio::ip::tcp::endpoint& ep);
|
||||
|
||||
template <typename FnT, typename... ArgTs>
|
||||
asio::awaitable<std::invoke_result_t<FnT, ArgTs...>> call_on_thread_pool(asio::thread_pool& pool, FnT&& f, ArgTs&&... args) {
|
||||
using ReturnT = std::invoke_result_t<FnT, ArgTs...>;
|
||||
auto bound = std::bind(std::forward<FnT>(f), std::forward<ArgTs>(args)...);
|
||||
|
||||
// We have to use a shared_ptr here in case call_on_thread_pool is canceled (in that case, the posted callback will
|
||||
// try to use promise after the call_on_thread_pool coroutine has been destroyed)
|
||||
auto promise = std::make_shared<AsyncPromise<ReturnT>>();
|
||||
asio::post(pool, [bound = std::move(bound), promise]() mutable {
|
||||
try {
|
||||
promise->set_value(bound());
|
||||
} catch (...) {
|
||||
promise->set_exception(std::current_exception());
|
||||
}
|
||||
});
|
||||
co_return co_await promise->get();
|
||||
}
|
||||
+16
-25
@@ -5,50 +5,41 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Text.hh"
|
||||
#include "Types.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
struct BMLHeaderT {
|
||||
using U32T = typename std::conditional<IsBigEndian, be_uint32_t, le_uint32_t>::type;
|
||||
|
||||
parray<uint8_t, 0x04> unknown_a1;
|
||||
U32T num_entries;
|
||||
U32T<BE> num_entries;
|
||||
parray<uint8_t, 0x38> unknown_a2;
|
||||
} __packed__;
|
||||
|
||||
} __packed_ws_be__(BMLHeaderT, 0x40);
|
||||
using BMLHeader = BMLHeaderT<false>;
|
||||
using BMLHeaderBE = BMLHeaderT<true>;
|
||||
check_struct_size(BMLHeader, 0x40);
|
||||
check_struct_size(BMLHeaderBE, 0x40);
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
struct BMLHeaderEntryT {
|
||||
using U32T = typename std::conditional<IsBigEndian, be_uint32_t, le_uint32_t>::type;
|
||||
|
||||
pstring<TextEncoding::ASCII, 0x20> filename;
|
||||
U32T compressed_size;
|
||||
U32T<BE> compressed_size;
|
||||
parray<uint8_t, 0x04> unknown_a1;
|
||||
U32T decompressed_size;
|
||||
U32T compressed_gvm_size;
|
||||
U32T decompressed_gvm_size;
|
||||
U32T<BE> decompressed_size;
|
||||
U32T<BE> compressed_gvm_size;
|
||||
U32T<BE> decompressed_gvm_size;
|
||||
parray<uint8_t, 0x0C> unknown_a2;
|
||||
} __packed__;
|
||||
|
||||
} __packed_ws_be__(BMLHeaderEntryT, 0x40);
|
||||
using BMLHeaderEntry = BMLHeaderEntryT<false>;
|
||||
using BMLHeaderEntryBE = BMLHeaderEntryT<true>;
|
||||
check_struct_size(BMLHeaderEntry, 0x40);
|
||||
check_struct_size(BMLHeaderEntryBE, 0x40);
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
void BMLArchive::load_t() {
|
||||
StringReader r(*this->data);
|
||||
phosg::StringReader r(*this->data);
|
||||
|
||||
const auto& header = r.get<BMLHeaderT<IsBigEndian>>();
|
||||
const auto& header = r.get<BMLHeaderT<BE>>();
|
||||
|
||||
size_t offset = 0x800;
|
||||
while (this->entries.size() < header.num_entries) {
|
||||
const auto& entry = r.get<BMLHeaderEntryT<IsBigEndian>>();
|
||||
const auto& entry = r.get<BMLHeaderEntryT<BE>>();
|
||||
|
||||
if (offset + entry.compressed_size > this->data->size()) {
|
||||
throw runtime_error("BML data entry extends beyond end of data");
|
||||
@@ -106,10 +97,10 @@ string BMLArchive::get_copy(const string& name) const {
|
||||
}
|
||||
}
|
||||
|
||||
StringReader BMLArchive::get_reader(const string& name) const {
|
||||
phosg::StringReader BMLArchive::get_reader(const string& name) const {
|
||||
try {
|
||||
const auto& entry = this->entries.at(name);
|
||||
return StringReader(this->data->data() + entry.offset, entry.size);
|
||||
return phosg::StringReader(this->data->data() + entry.offset, entry.size);
|
||||
} catch (const out_of_range&) {
|
||||
throw out_of_range("BML does not contain file: " + name);
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,10 +24,10 @@ public:
|
||||
std::pair<const void*, size_t> get(const std::string& name) const;
|
||||
std::pair<const void*, size_t> get_gvm(const std::string& name) const;
|
||||
std::string get_copy(const std::string& name) const;
|
||||
StringReader get_reader(const std::string& name) const;
|
||||
phosg::StringReader get_reader(const std::string& name) const;
|
||||
|
||||
private:
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
void load_t();
|
||||
|
||||
std::shared_ptr<const std::string> data;
|
||||
|
||||
+63
-23
@@ -9,28 +9,68 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void BattleParamsIndex::Table::print(FILE* stream) const {
|
||||
auto print_entry = +[](FILE* stream, const PlayerStats& e) {
|
||||
fprintf(stream,
|
||||
"%5hu %5hu %5hu %5hu %5hu %5hu %5hu %5hu %5" PRIu32 " %5" PRIu32,
|
||||
e.char_stats.atp.load(),
|
||||
e.char_stats.mst.load(),
|
||||
e.char_stats.evp.load(),
|
||||
e.char_stats.hp.load(),
|
||||
e.char_stats.dfp.load(),
|
||||
e.char_stats.ata.load(),
|
||||
e.char_stats.lck.load(),
|
||||
e.esp.load(),
|
||||
e.experience.load(),
|
||||
e.meseta.load());
|
||||
};
|
||||
|
||||
for (size_t diff = 0; diff < 4; diff++) {
|
||||
fprintf(stream, "%c ZZ ATP PSV EVP HP DFP ATA LCK ESP EXP DIFF\n",
|
||||
abbreviation_for_difficulty(diff));
|
||||
void BattleParamsIndex::Table::print(FILE* stream, Episode episode) const {
|
||||
phosg::fwrite_fmt(stream, "========== STATS\n");
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
phosg::fwrite_fmt(stream, "{} ZZ ATP PSV EVP HP DFP ATA LCK ESP EXP DIFF NAMES\n",
|
||||
abbreviation_for_difficulty(difficulty));
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
fprintf(stream, " %02zX ", z);
|
||||
print_entry(stream, this->stats[diff][z]);
|
||||
const auto& e = this->stats[static_cast<size_t>(difficulty)][z];
|
||||
phosg::fwrite_fmt(stream, " {:02X} ", z);
|
||||
string names_str;
|
||||
for (auto type : enemy_types_for_battle_param_stats_index(episode, z)) {
|
||||
if (!names_str.empty()) {
|
||||
names_str += ", ";
|
||||
}
|
||||
names_str += phosg::name_for_enum(type);
|
||||
}
|
||||
phosg::fwrite_fmt(stream,
|
||||
"{:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {}",
|
||||
e.char_stats.atp, e.char_stats.mst, e.char_stats.evp, e.char_stats.hp, e.char_stats.dfp, e.char_stats.ata,
|
||||
e.char_stats.lck, e.esp, e.experience, e.meseta, names_str);
|
||||
fputc('\n', stream);
|
||||
}
|
||||
}
|
||||
|
||||
phosg::fwrite_fmt(stream, "========== ATTACK DATA\n");
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
phosg::fwrite_fmt(stream, "{} ZZ ATP- ATP+ ATA- ATA+ -DIST-X- -ANGLE-- -DIST-Y- -A8- -A9- A10- A11- --A12--- --A13--- --A14--- --A15--- --A16---\n",
|
||||
abbreviation_for_difficulty(difficulty));
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
const auto& e = this->attack_data[static_cast<size_t>(difficulty)][z];
|
||||
phosg::fwrite_fmt(stream,
|
||||
" {:02X} {:04X} {:04X} {:04X} {:04X} {:8.3f} {:08X} {:8.3f} {:04X} {:04X} {:04X} {:04X} {:08X} {:08X} {:08X} {:08X} {:08X}",
|
||||
z, e.min_atp, e.max_atp, e.min_ata, e.max_ata, e.distance_x, e.angle, e.distance_y, e.unknown_a8,
|
||||
e.unknown_a9, e.unknown_a10, e.unknown_a11, e.unknown_a12, e.unknown_a13, e.unknown_a14, e.unknown_a15,
|
||||
e.unknown_a16);
|
||||
fputc('\n', stream);
|
||||
}
|
||||
}
|
||||
|
||||
phosg::fwrite_fmt(stream, "========== RESIST DATA\n");
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
phosg::fwrite_fmt(stream, "{} ZZ EVP- EFR- EIC- ETH- ELT- EDK- ---A6--- ---A7--- ---A8--- ---A9--- --DFP---\n",
|
||||
abbreviation_for_difficulty(difficulty));
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
const auto& e = this->resist_data[static_cast<size_t>(difficulty)][z];
|
||||
phosg::fwrite_fmt(stream,
|
||||
" {:02X} {:04X} {:04X} {:04X} {:04X} {:04X} {:04X} {:08X} {:08X} {:08X} {:08X} {:08X}",
|
||||
z, e.evp_bonus, e.efr, e.eic, e.eth, e.elt, e.edk, e.unknown_a6, e.unknown_a7, e.unknown_a8, e.unknown_a9,
|
||||
e.dfp_bonus);
|
||||
fputc('\n', stream);
|
||||
}
|
||||
}
|
||||
|
||||
phosg::fwrite_fmt(stream, "========== MOVEMENT DATA\n");
|
||||
for (Difficulty difficulty : ALL_DIFFICULTIES_V234) {
|
||||
phosg::fwrite_fmt(stream, "{} ZZ FPARAM-1 FPARAM-2 FPARAM-3 FPARAM-4 FPARAM-5 FPARAM-6 IPARAM-1 IPARAM-2 IPARAM-3 IPARAM-4 IPARAM-5 IPARAM-6\n",
|
||||
abbreviation_for_difficulty(difficulty));
|
||||
for (size_t z = 0; z < 0x60; z++) {
|
||||
const auto& e = this->movement_data[static_cast<size_t>(difficulty)][z];
|
||||
phosg::fwrite_fmt(stream,
|
||||
" {:02X} {:8.3f} {:8.3f} {:8.3f} {:8.3f} {:8.3f} {:8.3f} {:08X} {:08X} {:08X} {:08X} {:08X} {:08X}",
|
||||
z, e.fparam1, e.fparam2, e.fparam3, e.fparam4, e.fparam5, e.fparam6,
|
||||
e.iparam1, e.iparam2, e.iparam3, e.iparam4, e.iparam5, e.iparam6);
|
||||
fputc('\n', stream);
|
||||
}
|
||||
}
|
||||
@@ -54,8 +94,8 @@ BattleParamsIndex::BattleParamsIndex(
|
||||
for (uint8_t episode = 0; episode < 3; episode++) {
|
||||
auto& file = this->files[is_solo][episode];
|
||||
if (file.data->size() < sizeof(Table)) {
|
||||
throw runtime_error(string_printf(
|
||||
"battle params table size is incorrect (expected %zX bytes, have %zX bytes; is_solo=%hhu, episode=%hhu)",
|
||||
throw runtime_error(std::format(
|
||||
"battle params table size is incorrect (expected {:X} bytes, have {:X} bytes; is_solo={}, episode={})",
|
||||
sizeof(Table), file.data->size(), is_solo, episode));
|
||||
}
|
||||
file.table = reinterpret_cast<const Table*>(file.data->data());
|
||||
|
||||
+36
-23
@@ -19,12 +19,12 @@ public:
|
||||
// These files are little-endian, even on PSO GC.
|
||||
|
||||
struct AttackData {
|
||||
/* 00 */ le_int16_t unknown_a1;
|
||||
/* 02 */ le_int16_t atp;
|
||||
/* 04 */ le_int16_t ata_bonus;
|
||||
/* 06 */ le_uint16_t unknown_a4;
|
||||
/* 00 */ le_int16_t min_atp;
|
||||
/* 02 */ le_int16_t max_atp;
|
||||
/* 04 */ le_int16_t min_ata;
|
||||
/* 06 */ le_int16_t max_ata;
|
||||
/* 08 */ le_float distance_x;
|
||||
/* 0C */ le_uint32_t angle_x; // Out of 0x10000 (high 16 bits are unused)
|
||||
/* 0C */ le_uint32_t angle; // Out of 0x10000 (high 16 bits are unused)
|
||||
/* 10 */ le_float distance_y;
|
||||
/* 14 */ le_uint16_t unknown_a8;
|
||||
/* 16 */ le_uint16_t unknown_a9;
|
||||
@@ -54,29 +54,42 @@ public:
|
||||
} __packed_ws__(ResistData, 0x20);
|
||||
|
||||
struct MovementData {
|
||||
/* 00 */ le_float idle_move_speed;
|
||||
/* 04 */ le_float idle_animation_speed;
|
||||
/* 08 */ le_float move_speed;
|
||||
/* 0C */ le_float animation_speed;
|
||||
/* 10 */ le_float unknown_a1;
|
||||
/* 14 */ le_float unknown_a2;
|
||||
/* 18 */ le_uint32_t unknown_a3;
|
||||
/* 1C */ le_uint32_t unknown_a4;
|
||||
/* 20 */ le_uint32_t unknown_a5;
|
||||
/* 24 */ le_uint32_t unknown_a6;
|
||||
/* 28 */ le_uint32_t unknown_a7;
|
||||
/* 2C */ le_uint32_t unknown_a8;
|
||||
/* 00 */ le_float fparam1;
|
||||
/* 04 */ le_float fparam2;
|
||||
/* 03 */ le_float fparam3;
|
||||
/* 0C */ le_float fparam4;
|
||||
/* 10 */ le_float fparam5;
|
||||
/* 14 */ le_float fparam6;
|
||||
/* 18 */ le_uint32_t iparam1;
|
||||
/* 1C */ le_uint32_t iparam2;
|
||||
/* 20 */ le_uint32_t iparam3;
|
||||
/* 24 */ le_uint32_t iparam4;
|
||||
/* 28 */ le_uint32_t iparam5;
|
||||
/* 2C */ le_uint32_t iparam6;
|
||||
/* 30 */
|
||||
} __packed_ws__(MovementData, 0x30);
|
||||
|
||||
struct Table {
|
||||
/* 0000 */ parray<parray<PlayerStats, 0x60>, 4> stats;
|
||||
/* 3600 */ parray<parray<AttackData, 0x60>, 4> attack_data;
|
||||
/* 7E00 */ parray<parray<ResistData, 0x60>, 4> resist_data;
|
||||
/* AE00 */ parray<parray<MovementData, 0x60>, 4> movement_data;
|
||||
/* 0000 */ parray<parray<PlayerStats, 0x60>, 4> stats; // [difficulty][bp_index]
|
||||
/* 3600 */ parray<parray<AttackData, 0x60>, 4> attack_data; // [difficulty][bp_index]
|
||||
/* 7E00 */ parray<parray<ResistData, 0x60>, 4> resist_data; // [difficulty][bp_index]
|
||||
/* AE00 */ parray<parray<MovementData, 0x60>, 4> movement_data; // [difficulty][bp_index]
|
||||
/* F600 */
|
||||
|
||||
void print(FILE* stream) const;
|
||||
const PlayerStats& stats_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->stats.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const AttackData& attack_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->attack_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const ResistData& resist_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->resist_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
const MovementData& movement_data_for_index(Difficulty difficulty, uint8_t index) const {
|
||||
return this->movement_data.at(static_cast<size_t>(difficulty)).at(index);
|
||||
}
|
||||
|
||||
void print(FILE* stream, Episode episode) const;
|
||||
} __packed_ws__(Table, 0xF600);
|
||||
|
||||
BattleParamsIndex(
|
||||
@@ -92,7 +105,7 @@ public:
|
||||
private:
|
||||
struct File {
|
||||
std::shared_ptr<const std::string> data;
|
||||
const Table* table;
|
||||
const Table* table = nullptr;
|
||||
};
|
||||
|
||||
// Indexed as [online/offline][episode]
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
#include "CatSession.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;
|
||||
|
||||
CatSession::exit_shell::exit_shell() : runtime_error("shell exited") {}
|
||||
|
||||
CatSession::CatSession(
|
||||
shared_ptr<struct event_base> base,
|
||||
const struct sockaddr_storage& remote,
|
||||
Version version,
|
||||
shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file)
|
||||
: log(string_printf("[CatSession:%s] ", name_for_enum(version)), proxy_server_log.min_level),
|
||||
base(base),
|
||||
read_event(event_new(this->base.get(), 0, EV_READ | EV_PERSIST, CatSession::dispatch_read_stdin, this), event_free),
|
||||
channel(version, 1, CatSession::dispatch_on_channel_input, CatSession::dispatch_on_channel_error, this, "CatSession"),
|
||||
bb_key_file(bb_key_file) {
|
||||
|
||||
if (remote.ss_family != AF_INET) {
|
||||
throw runtime_error("remote is not AF_INET");
|
||||
}
|
||||
|
||||
string netloc_str = 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(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(string_printf("failed to connect (%d)", EVUTIL_SOCKET_ERROR()));
|
||||
}
|
||||
|
||||
event_add(this->read_event.get(), nullptr);
|
||||
this->poll.add(0, POLLIN);
|
||||
}
|
||||
|
||||
void CatSession::execute_command(const std::string& command) {
|
||||
string full_cmd = parse_data_string(command, nullptr, ParseDataFlags::ALLOW_FILES);
|
||||
send_command_with_header(this->channel, full_cmd.data(), full_cmd.size());
|
||||
}
|
||||
|
||||
void CatSession::dispatch_on_channel_input(
|
||||
Channel& ch, uint16_t command, uint32_t flag, std::string& data) {
|
||||
auto* session = reinterpret_cast<CatSession*>(ch.context_obj);
|
||||
session->on_channel_input(command, flag, data);
|
||||
}
|
||||
|
||||
void CatSession::on_channel_input(
|
||||
uint16_t command, uint32_t flag, std::string& data) {
|
||||
if (!uses_v4_encryption(this->channel.version)) {
|
||||
if (command == 0x02 || command == 0x17 || command == 0x91 || command == 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 { // PC, DC, or patch server
|
||||
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 { // BB
|
||||
if (command == 0x03 || command == 0x9B) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
print_data(stdout, full_cmd, 0, nullptr, PrintDataFlags::PRINT_ASCII | PrintDataFlags::OFFSET_16_BITS);
|
||||
}
|
||||
|
||||
void CatSession::dispatch_on_channel_error(Channel& ch, short events) {
|
||||
auto* session = reinterpret_cast<CatSession*>(ch.context_obj);
|
||||
session->on_channel_error(events);
|
||||
}
|
||||
|
||||
void CatSession::on_channel_error(short events) {
|
||||
if (events & BEV_EVENT_CONNECTED) {
|
||||
this->log.info("Channel connected");
|
||||
}
|
||||
if (events & BEV_EVENT_ERROR) {
|
||||
int err = EVUTIL_SOCKET_ERROR();
|
||||
this->log.warning("Error %d (%s) in unlinked client stream", err,
|
||||
evutil_socket_error_to_string(err));
|
||||
}
|
||||
if (events & (BEV_EVENT_ERROR | BEV_EVENT_EOF)) {
|
||||
this->log.info("Session endpoint has disconnected");
|
||||
this->channel.disconnect();
|
||||
event_base_loopexit(this->base.get(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CatSession::dispatch_read_stdin(evutil_socket_t, short, void* ctx) {
|
||||
reinterpret_cast<CatSession*>(ctx)->read_stdin();
|
||||
}
|
||||
|
||||
void CatSession::read_stdin() {
|
||||
bool any_command_read = false;
|
||||
for (;;) {
|
||||
auto poll_result = this->poll.poll();
|
||||
short fd_events = 0;
|
||||
try {
|
||||
fd_events = poll_result.at(0);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
|
||||
if (!(fd_events & POLLIN)) {
|
||||
break;
|
||||
}
|
||||
|
||||
string command(2048, '\0');
|
||||
if (!fgets(command.data(), command.size(), stdin)) {
|
||||
if (!any_command_read) {
|
||||
// ctrl+d probably; we should exit
|
||||
fputc('\n', stderr);
|
||||
event_base_loopexit(this->base.get(), nullptr);
|
||||
return;
|
||||
} else {
|
||||
break; // probably not EOF; just no more commands for now
|
||||
}
|
||||
}
|
||||
|
||||
// trim the extra data off the string
|
||||
size_t len = strlen(command.c_str());
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
if (command[len - 1] == '\n') {
|
||||
len--;
|
||||
}
|
||||
command.resize(len);
|
||||
any_command_read = true;
|
||||
|
||||
try {
|
||||
execute_command(command);
|
||||
} catch (const exit_shell&) {
|
||||
event_base_loopexit(this->base.get(), nullptr);
|
||||
return;
|
||||
} catch (const exception& e) {
|
||||
fprintf(stderr, "FAILED: %s\n", e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#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 CatSession {
|
||||
public:
|
||||
CatSession(
|
||||
std::shared_ptr<struct event_base> base,
|
||||
const struct sockaddr_storage& remote,
|
||||
Version version,
|
||||
std::shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file);
|
||||
CatSession(const CatSession&) = delete;
|
||||
CatSession(CatSession&&) = delete;
|
||||
CatSession& operator=(const CatSession&) = delete;
|
||||
CatSession& operator=(CatSession&&) = delete;
|
||||
virtual ~CatSession() = default;
|
||||
|
||||
protected:
|
||||
PrefixedLogger log;
|
||||
std::shared_ptr<struct event_base> base;
|
||||
std::unique_ptr<struct event, void (*)(struct event*)> read_event;
|
||||
Poll poll;
|
||||
|
||||
Channel channel;
|
||||
std::shared_ptr<const PSOBBEncryption::KeyFile> bb_key_file;
|
||||
|
||||
class exit_shell : public std::runtime_error {
|
||||
public:
|
||||
exit_shell();
|
||||
~exit_shell() = default;
|
||||
};
|
||||
|
||||
virtual void execute_command(const std::string& command);
|
||||
|
||||
static void dispatch_read_stdin(evutil_socket_t fd, short events, void* ctx);
|
||||
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 read_stdin();
|
||||
};
|
||||
+242
-272
@@ -1,9 +1,6 @@
|
||||
#include "Channel.hh"
|
||||
|
||||
#include <errno.h>
|
||||
#include <event2/buffer.h>
|
||||
#include <event2/bufferevent.h>
|
||||
#include <event2/event.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -11,245 +8,34 @@
|
||||
#include <phosg/Time.hh>
|
||||
|
||||
#include "Loggers.hh"
|
||||
#include "StaticGameData.hh"
|
||||
#include "Version.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern bool use_terminal_colors;
|
||||
|
||||
static void flush_and_free_bufferevent(struct bufferevent* bev) {
|
||||
bufferevent_flush(bev, EV_READ | EV_WRITE, BEV_FINISHED);
|
||||
bufferevent_free(bev);
|
||||
}
|
||||
|
||||
Channel::Channel(
|
||||
Version version,
|
||||
uint8_t language,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
Language language,
|
||||
const string& name,
|
||||
TerminalFormat terminal_send_color,
|
||||
TerminalFormat terminal_recv_color)
|
||||
: bev(nullptr, flush_and_free_bufferevent),
|
||||
virtual_network_id(0),
|
||||
version(version),
|
||||
phosg::TerminalFormat terminal_send_color,
|
||||
phosg::TerminalFormat terminal_recv_color)
|
||||
: version(version),
|
||||
language(language),
|
||||
name(name),
|
||||
terminal_send_color(terminal_send_color),
|
||||
terminal_recv_color(terminal_recv_color),
|
||||
on_command_received(on_command_received),
|
||||
on_error(on_error),
|
||||
context_obj(context_obj) {
|
||||
}
|
||||
|
||||
Channel::Channel(
|
||||
struct bufferevent* bev,
|
||||
uint64_t virtual_network_id,
|
||||
Version version,
|
||||
uint8_t language,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
const string& name,
|
||||
TerminalFormat terminal_send_color,
|
||||
TerminalFormat terminal_recv_color)
|
||||
: bev(nullptr, flush_and_free_bufferevent),
|
||||
version(version),
|
||||
language(language),
|
||||
name(name),
|
||||
terminal_send_color(terminal_send_color),
|
||||
terminal_recv_color(terminal_recv_color),
|
||||
on_command_received(on_command_received),
|
||||
on_error(on_error),
|
||||
context_obj(context_obj) {
|
||||
this->set_bufferevent(bev, virtual_network_id);
|
||||
}
|
||||
|
||||
void Channel::replace_with(
|
||||
Channel&& other,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
const std::string& name) {
|
||||
this->set_bufferevent(other.bev.release(), other.virtual_network_id);
|
||||
this->local_addr = other.local_addr;
|
||||
this->remote_addr = other.remote_addr;
|
||||
this->version = other.version;
|
||||
this->language = other.language;
|
||||
this->crypt_in = other.crypt_in;
|
||||
this->crypt_out = other.crypt_out;
|
||||
this->name = name;
|
||||
this->terminal_send_color = other.terminal_send_color;
|
||||
this->terminal_recv_color = other.terminal_recv_color;
|
||||
this->on_command_received = on_command_received;
|
||||
this->on_error = on_error;
|
||||
this->context_obj = context_obj;
|
||||
other.disconnect(); // Clears crypts, addrs, etc.
|
||||
}
|
||||
|
||||
void Channel::set_bufferevent(struct bufferevent* bev, uint64_t virtual_network_id) {
|
||||
this->bev.reset(bev);
|
||||
this->virtual_network_id = virtual_network_id;
|
||||
|
||||
if (this->bev.get()) {
|
||||
int fd = bufferevent_getfd(this->bev.get());
|
||||
if (fd < 0) {
|
||||
memset(&this->local_addr, 0, sizeof(this->local_addr));
|
||||
memset(&this->remote_addr, 0, sizeof(this->remote_addr));
|
||||
} else {
|
||||
get_socket_addresses(fd, &this->local_addr, &this->remote_addr);
|
||||
}
|
||||
|
||||
bufferevent_setcb(this->bev.get(), &Channel::dispatch_on_input, nullptr, &Channel::dispatch_on_error, this);
|
||||
bufferevent_enable(this->bev.get(), EV_READ | EV_WRITE);
|
||||
|
||||
} else {
|
||||
memset(&this->local_addr, 0, sizeof(this->local_addr));
|
||||
memset(&this->remote_addr, 0, sizeof(this->remote_addr));
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::disconnect() {
|
||||
if (this->bev.get()) {
|
||||
// If the output buffer is not empty, move the bufferevent into the draining
|
||||
// pool instead of disconnecting it, to make sure all the data gets sent.
|
||||
struct evbuffer* out_buffer = bufferevent_get_output(this->bev.get());
|
||||
if (evbuffer_get_length(out_buffer) == 0) {
|
||||
this->bev.reset(); // Destructor flushes and frees the bufferevent
|
||||
} else {
|
||||
// The callbacks will free it when all the data is sent or the client
|
||||
// disconnects
|
||||
|
||||
auto on_output = +[](struct bufferevent* bev, void*) -> void {
|
||||
flush_and_free_bufferevent(bev);
|
||||
};
|
||||
|
||||
auto on_error = +[](struct bufferevent* bev, short events, void*) -> void {
|
||||
if (events & BEV_EVENT_ERROR) {
|
||||
int err = EVUTIL_SOCKET_ERROR();
|
||||
channel_exceptions_log.warning(
|
||||
"Disconnecting channel caused error %d (%s)", err,
|
||||
evutil_socket_error_to_string(err));
|
||||
}
|
||||
if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
|
||||
bufferevent_flush(bev, EV_WRITE, BEV_FINISHED);
|
||||
bufferevent_free(bev);
|
||||
}
|
||||
};
|
||||
|
||||
struct bufferevent* bev = this->bev.release();
|
||||
bufferevent_setcb(bev, nullptr, on_output, on_error, bev);
|
||||
bufferevent_disable(bev, EV_READ);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&this->local_addr, 0, sizeof(this->local_addr));
|
||||
memset(&this->remote_addr, 0, sizeof(this->remote_addr));
|
||||
this->virtual_network_id = false;
|
||||
this->crypt_in.reset();
|
||||
this->crypt_out.reset();
|
||||
}
|
||||
|
||||
Channel::Message Channel::recv() {
|
||||
struct evbuffer* buf = bufferevent_get_input(this->bev.get());
|
||||
|
||||
size_t header_size = (this->version == Version::BB_V4) ? 8 : 4;
|
||||
PSOCommandHeader header;
|
||||
if (evbuffer_copyout(buf, &header, header_size) < static_cast<ssize_t>(header_size)) {
|
||||
throw out_of_range("no command available");
|
||||
}
|
||||
|
||||
if (this->crypt_in.get()) {
|
||||
this->crypt_in->decrypt(&header, header_size, false);
|
||||
}
|
||||
|
||||
size_t command_logical_size = header.size(version);
|
||||
|
||||
// If encryption is enabled, BB pads commands to 8-byte boundaries, and this
|
||||
// is not reflected in the size field. This logic does not occur if encryption
|
||||
// is not yet enabled.
|
||||
size_t command_physical_size = (this->crypt_in.get() && (version == Version::BB_V4))
|
||||
? ((command_logical_size + 7) & ~7)
|
||||
: command_logical_size;
|
||||
if (evbuffer_get_length(buf) < command_physical_size) {
|
||||
throw out_of_range("no command available");
|
||||
}
|
||||
|
||||
// If we get here, then there is a full command in the buffer. Some encryption
|
||||
// algorithms' advancement depends on the decrypted data, so we have to
|
||||
// actually decrypt the header again (with advance=true) to keep them in a
|
||||
// consistent state.
|
||||
|
||||
string header_data(header_size, '\0');
|
||||
if (evbuffer_remove(buf, header_data.data(), header_data.size()) < static_cast<ssize_t>(header_data.size())) {
|
||||
throw logic_error("enough bytes available, but could not remove them");
|
||||
}
|
||||
if (this->crypt_in.get()) {
|
||||
this->crypt_in->decrypt(header_data.data(), header_data.size());
|
||||
}
|
||||
|
||||
string command_data(command_physical_size - header_size, '\0');
|
||||
if (evbuffer_remove(buf, command_data.data(), command_data.size()) < static_cast<ssize_t>(command_data.size())) {
|
||||
throw logic_error("enough bytes available, but could not remove them");
|
||||
}
|
||||
|
||||
if (this->crypt_in.get()) {
|
||||
// Some versions of PSO DC can send commands whose sizes are not a multiple
|
||||
// of 4, but the server is expected to always use a multiple of 4 bytes when
|
||||
// decrypting (the extra cipher bytes are lost). To emulate this behavior,
|
||||
// we have to round up the size for DC commands here.
|
||||
size_t orig_size = command_data.size();
|
||||
command_data.resize((orig_size + 3) & (~3), 0);
|
||||
this->crypt_in->decrypt(command_data.data(), command_data.size());
|
||||
command_data.resize(orig_size);
|
||||
}
|
||||
command_data.resize(command_logical_size - header_size);
|
||||
|
||||
if (command_data_log.should_log(LogLevel::INFO) && (this->terminal_recv_color != TerminalFormat::END)) {
|
||||
if (use_terminal_colors && this->terminal_recv_color != TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, this->terminal_recv_color, TerminalFormat::BOLD, TerminalFormat::END);
|
||||
}
|
||||
|
||||
if (version == Version::BB_V4) {
|
||||
command_data_log.info(
|
||||
"Received from %s (version=BB command=%04hX flag=%08" PRIX32 ")",
|
||||
this->name.c_str(),
|
||||
header.command(this->version),
|
||||
header.flag(this->version));
|
||||
} else {
|
||||
command_data_log.info(
|
||||
"Received from %s (version=%s command=%02hX flag=%02" PRIX32 ")",
|
||||
this->name.c_str(),
|
||||
name_for_enum(this->version),
|
||||
header.command(this->version),
|
||||
header.flag(this->version));
|
||||
}
|
||||
|
||||
vector<struct iovec> iovs;
|
||||
iovs.emplace_back(iovec{.iov_base = header_data.data(), .iov_len = header_data.size()});
|
||||
iovs.emplace_back(iovec{.iov_base = command_data.data(), .iov_len = command_data.size()});
|
||||
print_data(stderr, iovs, 0, nullptr, PrintDataFlags::PRINT_ASCII | PrintDataFlags::DISABLE_COLOR | PrintDataFlags::OFFSET_16_BITS);
|
||||
|
||||
if (use_terminal_colors && this->terminal_recv_color != TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, TerminalFormat::NORMAL, TerminalFormat::END);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
.command = header.command(this->version),
|
||||
.flag = header.flag(this->version),
|
||||
.data = std::move(command_data),
|
||||
};
|
||||
terminal_recv_color(terminal_recv_color) {
|
||||
}
|
||||
|
||||
void Channel::send(uint16_t cmd, uint32_t flag, bool silent) {
|
||||
this->send(cmd, flag, nullptr, 0, silent);
|
||||
}
|
||||
|
||||
void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<const void*, size_t>> blocks, bool silent) {
|
||||
void Channel::send(
|
||||
uint16_t cmd, uint32_t flag, const std::vector<std::pair<const void*, size_t>> blocks, bool silent) {
|
||||
if (!this->connected()) {
|
||||
channel_exceptions_log.warning("Attempted to send command on closed channel; dropping data");
|
||||
channel_exceptions_log.warning_f("Attempted to send command on closed channel; dropping data");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,7 +49,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:
|
||||
@@ -272,10 +58,7 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
|
||||
case Version::GC_EP3:
|
||||
case Version::XB_V3: {
|
||||
PSOCommandHeaderDCV3 header;
|
||||
if (this->crypt_out.get() &&
|
||||
(this->version != Version::DC_NTE) &&
|
||||
(this->version != Version::DC_V1_11_2000_PROTOTYPE) &&
|
||||
(this->version != Version::DC_V1)) {
|
||||
if (this->crypt_out.get() && !is_v1(this->version)) {
|
||||
send_data_size = (sizeof(header) + size + 3) & ~3;
|
||||
} else {
|
||||
send_data_size = (sizeof(header) + size);
|
||||
@@ -305,13 +88,11 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
|
||||
break;
|
||||
}
|
||||
case Version::BB_V4: {
|
||||
// BB has an annoying behavior here: command lengths must be multiples of
|
||||
// 4, but the actual data length must be a multiple of 8. If the size
|
||||
// field is not divisible by 8, 4 extra bytes are sent anyway. This
|
||||
// behavior only applies when encryption is enabled - any commands sent
|
||||
// before encryption is enabled have no size restrictions (except they
|
||||
// must include a full header and must fit in the client's receive
|
||||
// buffer), and no implicit extra bytes are sent.
|
||||
// BB has an annoying behavior here: command lengths must be multiples of 4, but the actual data length must be a
|
||||
// multiple of 8. If the size field is not divisible by 8, 4 extra bytes are sent anyway. This behavior only
|
||||
// applies when encryption is enabled - any commands sent before encryption is enabled have no size restrictions
|
||||
// (except they must include a full header and must fit in the client's receive buffer), and no implicit extra
|
||||
// bytes are sent.
|
||||
PSOCommandHeaderBB header;
|
||||
if (this->crypt_out.get()) {
|
||||
send_data_size = (sizeof(header) + size + 7) & ~7;
|
||||
@@ -330,8 +111,7 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
|
||||
throw logic_error("unimplemented game version in send_command");
|
||||
}
|
||||
|
||||
// All versions of PSO I've seen (so far) have a receive buffer 0x7C00
|
||||
// bytes in size
|
||||
// All versions of PSO I've seen (so far) have a receive buffer 0x7C00 bytes in size
|
||||
if (send_data_size > 0x7C00) {
|
||||
throw runtime_error("outbound command too large");
|
||||
}
|
||||
@@ -342,20 +122,19 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
|
||||
}
|
||||
send_data.resize(send_data_size, '\0');
|
||||
|
||||
if (!silent && (command_data_log.should_log(LogLevel::INFO)) && (this->terminal_send_color != TerminalFormat::END)) {
|
||||
if (use_terminal_colors && this->terminal_send_color != TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, TerminalFormat::FG_YELLOW, TerminalFormat::BOLD, TerminalFormat::END);
|
||||
if (!silent && (command_data_log.should_log(phosg::LogLevel::L_INFO)) && (this->terminal_send_color != phosg::TerminalFormat::END)) {
|
||||
if (use_terminal_colors && this->terminal_send_color != phosg::TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, phosg::TerminalFormat::FG_YELLOW, phosg::TerminalFormat::BOLD, phosg::TerminalFormat::END);
|
||||
}
|
||||
if (version == Version::BB_V4) {
|
||||
command_data_log.info("Sending to %s (version=BB command=%04hX flag=%08" PRIX32 ")",
|
||||
this->name.c_str(), cmd, flag);
|
||||
command_data_log.info_f("Sending to {} (version=BB command={:04X} flag={:08X})", this->name, cmd, flag);
|
||||
} else {
|
||||
command_data_log.info("Sending to %s (version=%s command=%02hX flag=%02" PRIX32 ")",
|
||||
this->name.c_str(), name_for_enum(version), cmd, flag);
|
||||
command_data_log.info_f("Sending to {} (version={} command={:02X} flag={:02X})",
|
||||
this->name, phosg::name_for_enum(version), cmd, flag);
|
||||
}
|
||||
print_data(stderr, send_data.data(), logical_size, 0, nullptr, PrintDataFlags::PRINT_ASCII | PrintDataFlags::DISABLE_COLOR | PrintDataFlags::OFFSET_16_BITS);
|
||||
if (use_terminal_colors && this->terminal_send_color != TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, TerminalFormat::NORMAL, TerminalFormat::END);
|
||||
phosg::print_data(stderr, send_data.data(), logical_size, 0, nullptr, phosg::PrintDataFlags::PRINT_ASCII | phosg::PrintDataFlags::DISABLE_COLOR | phosg::PrintDataFlags::OFFSET_16_BITS);
|
||||
if (use_terminal_colors && this->terminal_send_color != phosg::TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, phosg::TerminalFormat::NORMAL, phosg::TerminalFormat::END);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +142,7 @@ void Channel::send(uint16_t cmd, uint32_t flag, const std::vector<std::pair<cons
|
||||
this->crypt_out->encrypt(send_data.data(), send_data.size());
|
||||
}
|
||||
|
||||
struct evbuffer* buf = bufferevent_get_output(this->bev.get());
|
||||
evbuffer_add(buf, send_data.data(), send_data.size());
|
||||
this->send_raw(std::move(send_data));
|
||||
}
|
||||
|
||||
void Channel::send(uint16_t cmd, uint32_t flag, const void* data, size_t size, bool silent) {
|
||||
@@ -387,35 +165,227 @@ void Channel::send(const void* data, size_t size, bool silent) {
|
||||
}
|
||||
|
||||
void Channel::send(const string& data, bool silent) {
|
||||
return this->send(data.data(), data.size(), silent);
|
||||
this->send(data.data(), data.size(), silent);
|
||||
}
|
||||
|
||||
void Channel::dispatch_on_input(struct bufferevent*, void* ctx) {
|
||||
Channel* ch = reinterpret_cast<Channel*>(ctx);
|
||||
// The client can be disconnected during on_command_received, so we have to
|
||||
// make sure ch->bev is valid every time before calling recv()
|
||||
while (ch->bev.get()) {
|
||||
Message msg;
|
||||
try {
|
||||
msg = ch->recv();
|
||||
} catch (const out_of_range&) {
|
||||
break;
|
||||
} catch (const exception& e) {
|
||||
channel_exceptions_log.warning("Error receiving on channel: %s", e.what());
|
||||
ch->on_error(*ch, BEV_EVENT_ERROR);
|
||||
break;
|
||||
asio::awaitable<Channel::Message> Channel::recv() {
|
||||
size_t header_size = (this->version == Version::BB_V4) ? 8 : 4;
|
||||
PSOCommandHeader header;
|
||||
co_await this->recv_raw(&header, header_size);
|
||||
if (this->crypt_in.get()) {
|
||||
this->crypt_in->decrypt(&header, header_size);
|
||||
}
|
||||
|
||||
size_t command_logical_size = header.size(version);
|
||||
if (command_logical_size < header_size) {
|
||||
throw runtime_error("header size field is smaller than header");
|
||||
}
|
||||
|
||||
// If encryption is enabled, BB pads commands to 8-byte boundaries, and this is not reflected in the size field. This
|
||||
// logic does not occur if encryption is not yet enabled.
|
||||
size_t command_physical_size = (this->crypt_in.get() && (version == Version::BB_V4))
|
||||
? ((command_logical_size + 7) & ~7)
|
||||
: command_logical_size;
|
||||
|
||||
string command_data(command_physical_size - header_size, '\0');
|
||||
co_await this->recv_raw(command_data.data(), command_data.size());
|
||||
|
||||
if (this->crypt_in.get()) {
|
||||
// Some versions of PSO DC can send commands whose sizes are not a multiple of 4, but the server is expected to
|
||||
// always use a multiple of 4 bytes when decrypting (the extra cipher bytes are lost). To emulate this behavior, we
|
||||
// have to round up the size for DC commands here.
|
||||
size_t orig_size = command_data.size();
|
||||
command_data.resize((orig_size + 3) & (~3), 0);
|
||||
this->crypt_in->decrypt(command_data.data(), command_data.size());
|
||||
command_data.resize(orig_size);
|
||||
}
|
||||
command_data.resize(command_logical_size - header_size);
|
||||
|
||||
if (command_data_log.should_log(phosg::LogLevel::L_INFO) && (this->terminal_recv_color != phosg::TerminalFormat::END)) {
|
||||
if (use_terminal_colors && this->terminal_recv_color != phosg::TerminalFormat::NORMAL) {
|
||||
print_color_escape(stderr, this->terminal_recv_color, phosg::TerminalFormat::BOLD, phosg::TerminalFormat::END);
|
||||
}
|
||||
if (ch->on_command_received) {
|
||||
ch->on_command_received(*ch, msg.command, msg.flag, msg.data);
|
||||
|
||||
if (version == Version::BB_V4) {
|
||||
command_data_log.info_f(
|
||||
"Received from {} (version=BB command={:04X} flag={:08X})",
|
||||
this->name,
|
||||
header.command(this->version),
|
||||
header.flag(this->version));
|
||||
} else {
|
||||
command_data_log.info_f(
|
||||
"Received from {} (version={} command={:02X} flag={:02X})",
|
||||
this->name,
|
||||
phosg::name_for_enum(this->version),
|
||||
header.command(this->version),
|
||||
header.flag(this->version));
|
||||
}
|
||||
|
||||
vector<struct iovec> iovs;
|
||||
iovs.emplace_back(iovec{.iov_base = &header, .iov_len = header_size});
|
||||
iovs.emplace_back(iovec{.iov_base = command_data.data(), .iov_len = command_data.size()});
|
||||
phosg::print_data(stderr, iovs, 0, nullptr, phosg::PrintDataFlags::PRINT_ASCII | phosg::PrintDataFlags::DISABLE_COLOR | phosg::PrintDataFlags::OFFSET_16_BITS);
|
||||
|
||||
if (use_terminal_colors && this->terminal_recv_color != phosg::TerminalFormat::NORMAL) {
|
||||
phosg::print_color_escape(stderr, phosg::TerminalFormat::NORMAL, phosg::TerminalFormat::END);
|
||||
}
|
||||
}
|
||||
|
||||
co_return Message{
|
||||
.command = header.command(this->version),
|
||||
.flag = header.flag(this->version),
|
||||
.data = std::move(command_data),
|
||||
};
|
||||
}
|
||||
|
||||
shared_ptr<SocketChannel> SocketChannel::create(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
std::unique_ptr<asio::ip::tcp::socket>&& sock,
|
||||
Version version,
|
||||
Language language,
|
||||
const string& name,
|
||||
phosg::TerminalFormat terminal_send_color,
|
||||
phosg::TerminalFormat terminal_recv_color) {
|
||||
shared_ptr<SocketChannel> ret(new SocketChannel(
|
||||
io_context, std::move(sock), version, language, name, terminal_send_color, terminal_recv_color));
|
||||
asio::co_spawn(*io_context, ret->send_task(), asio::detached);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SocketChannel::SocketChannel(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
std::unique_ptr<asio::ip::tcp::socket>&& sock,
|
||||
Version version,
|
||||
Language language,
|
||||
const string& name,
|
||||
phosg::TerminalFormat terminal_send_color,
|
||||
phosg::TerminalFormat terminal_recv_color)
|
||||
: Channel(version, language, name, terminal_send_color, terminal_recv_color),
|
||||
sock(std::move(sock)),
|
||||
local_addr(this->sock->local_endpoint()),
|
||||
remote_addr(this->sock->remote_endpoint()),
|
||||
send_buffer_nonempty_signal(io_context->get_executor()) {}
|
||||
|
||||
std::string SocketChannel::default_name() const {
|
||||
return "ip:" + str_for_endpoint(this->remote_addr);
|
||||
}
|
||||
|
||||
bool SocketChannel::connected() const {
|
||||
return !this->should_disconnect && this->sock && this->sock->is_open();
|
||||
}
|
||||
|
||||
void SocketChannel::disconnect() {
|
||||
this->should_disconnect = true;
|
||||
this->send_buffer_nonempty_signal.set();
|
||||
}
|
||||
|
||||
void SocketChannel::send_raw(string&& data) {
|
||||
if (this->sock && !this->should_disconnect) {
|
||||
this->outbound_data.emplace_back(std::move(data));
|
||||
this->send_buffer_nonempty_signal.set();
|
||||
}
|
||||
}
|
||||
|
||||
asio::awaitable<void> SocketChannel::recv_raw(void* data, size_t size) {
|
||||
if (!this->sock || this->should_disconnect) {
|
||||
throw runtime_error("Cannot receive on closed channel");
|
||||
}
|
||||
co_await asio::async_read(*this->sock, asio::buffer(data, size), asio::use_awaitable);
|
||||
}
|
||||
|
||||
asio::awaitable<void> SocketChannel::send_task() {
|
||||
// Ensure *this doesn't get deleted while the socket is open
|
||||
auto this_sh = this->shared_from_this();
|
||||
|
||||
while (this->sock->is_open()) {
|
||||
deque<string> to_send;
|
||||
to_send.swap(this->outbound_data);
|
||||
|
||||
if (!to_send.empty()) {
|
||||
vector<asio::const_buffer> bufs;
|
||||
bufs.reserve(to_send.size());
|
||||
for (const auto& it : to_send) {
|
||||
bufs.emplace_back(asio::buffer(it.data(), it.size()));
|
||||
}
|
||||
co_await asio::async_write(*this->sock, bufs, asio::use_awaitable);
|
||||
}
|
||||
|
||||
if (this->outbound_data.empty()) {
|
||||
if (this->should_disconnect) {
|
||||
this->sock->close();
|
||||
} else {
|
||||
this->send_buffer_nonempty_signal.clear();
|
||||
co_await this->send_buffer_nonempty_signal.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::dispatch_on_error(struct bufferevent*, short events, void* ctx) {
|
||||
Channel* ch = reinterpret_cast<Channel*>(ctx);
|
||||
if (ch->on_error) {
|
||||
ch->on_error(*ch, events);
|
||||
} else {
|
||||
ch->disconnect();
|
||||
PeerChannel::PeerChannel(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
Version version,
|
||||
Language language,
|
||||
const std::string& name,
|
||||
phosg::TerminalFormat terminal_send_color,
|
||||
phosg::TerminalFormat terminal_recv_color)
|
||||
: Channel(version, language, name, terminal_send_color, terminal_recv_color),
|
||||
send_buffer_nonempty_signal(io_context->get_executor()) {}
|
||||
|
||||
void PeerChannel::link_peers(std::shared_ptr<PeerChannel> peer1, std::shared_ptr<PeerChannel> peer2) {
|
||||
if (peer1->connected() || peer2->connected()) {
|
||||
throw logic_error("Cannot link already-connected peer channels");
|
||||
}
|
||||
peer1->peer = peer2;
|
||||
peer2->peer = peer1;
|
||||
}
|
||||
|
||||
std::string PeerChannel::default_name() const {
|
||||
return std::format("peer:{}->{}", reinterpret_cast<const void*>(this), reinterpret_cast<const void*>(this->peer.lock().get()));
|
||||
}
|
||||
|
||||
bool PeerChannel::connected() const {
|
||||
return (!this->inbound_data.empty()) || (this->peer.lock() != nullptr);
|
||||
}
|
||||
|
||||
void PeerChannel::disconnect() {
|
||||
auto peer = this->peer.lock();
|
||||
if (peer) {
|
||||
peer->peer.reset();
|
||||
peer->send_buffer_nonempty_signal.set();
|
||||
}
|
||||
this->peer.reset();
|
||||
this->send_buffer_nonempty_signal.set();
|
||||
}
|
||||
|
||||
void PeerChannel::send_raw(string&& data) {
|
||||
auto peer = this->peer.lock();
|
||||
if (peer) {
|
||||
peer->inbound_data.emplace_back(std::move(data));
|
||||
peer->send_buffer_nonempty_signal.set();
|
||||
}
|
||||
}
|
||||
|
||||
asio::awaitable<void> PeerChannel::recv_raw(void* data, size_t size) {
|
||||
while (size > 0) {
|
||||
while (this->inbound_data.empty() && this->peer.lock()) {
|
||||
this->send_buffer_nonempty_signal.clear();
|
||||
co_await this->send_buffer_nonempty_signal.wait();
|
||||
}
|
||||
|
||||
if (!this->inbound_data.empty()) {
|
||||
auto& front_block = this->inbound_data.front();
|
||||
if (size < front_block.size()) {
|
||||
memcpy(data, front_block.data(), size);
|
||||
front_block = front_block.substr(size);
|
||||
size = 0;
|
||||
} else {
|
||||
memcpy(data, front_block.data(), front_block.size());
|
||||
size -= front_block.size();
|
||||
data = reinterpret_cast<uint8_t*>(data) + front_block.size();
|
||||
this->inbound_data.pop_front();
|
||||
}
|
||||
} else if (!this->peer.lock()) {
|
||||
throw runtime_error("Channel peer has disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+132
-63
@@ -1,85 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "AsyncUtils.hh"
|
||||
#include "PSOEncryption.hh"
|
||||
#include "PSOProtocol.hh"
|
||||
#include "Version.hh"
|
||||
|
||||
struct Channel {
|
||||
std::unique_ptr<struct bufferevent, void (*)(struct bufferevent*)> bev;
|
||||
struct sockaddr_storage local_addr;
|
||||
struct sockaddr_storage remote_addr;
|
||||
uint64_t virtual_network_id; // 0 = normal TCP connection
|
||||
|
||||
class Channel {
|
||||
public:
|
||||
Version version;
|
||||
uint8_t language;
|
||||
Language language;
|
||||
std::shared_ptr<PSOEncryption> crypt_in;
|
||||
std::shared_ptr<PSOEncryption> crypt_out;
|
||||
|
||||
std::string name;
|
||||
TerminalFormat terminal_send_color;
|
||||
TerminalFormat terminal_recv_color;
|
||||
phosg::TerminalFormat terminal_send_color;
|
||||
phosg::TerminalFormat terminal_recv_color;
|
||||
|
||||
struct Message {
|
||||
uint16_t command;
|
||||
uint32_t flag;
|
||||
std::string data;
|
||||
|
||||
template <typename T>
|
||||
const T& check_size_t(size_t min_size, size_t max_size) const {
|
||||
return ::check_size_t<const T>(this->data.data(), this->data.size(), min_size, max_size);
|
||||
}
|
||||
template <typename T>
|
||||
T& check_size_t(size_t min_size, size_t max_size) {
|
||||
return ::check_size_t<T>(this->data.data(), this->data.size(), min_size, max_size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& check_size_t(size_t max_size) const {
|
||||
return ::check_size_t<const T>(this->data.data(), this->data.size(), sizeof(T), max_size);
|
||||
}
|
||||
template <typename T>
|
||||
T& check_size_t(size_t max_size) {
|
||||
return ::check_size_t<T>(this->data.data(), this->data.size(), sizeof(T), max_size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& check_size_t() const {
|
||||
return ::check_size_t<const T>(this->data.data(), this->data.size(), sizeof(T), sizeof(T));
|
||||
}
|
||||
template <typename T>
|
||||
T& check_size_t() {
|
||||
return ::check_size_t<T>(this->data.data(), this->data.size(), sizeof(T), sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
typedef void (*on_command_received_t)(Channel&, uint16_t, uint32_t, std::string&);
|
||||
typedef void (*on_error_t)(Channel&, short);
|
||||
virtual ~Channel() = default;
|
||||
|
||||
on_command_received_t on_command_received;
|
||||
on_error_t on_error;
|
||||
void* context_obj;
|
||||
virtual std::string default_name() const = 0;
|
||||
|
||||
// Creates an unconnected channel
|
||||
Channel(
|
||||
Version version,
|
||||
uint8_t language,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
const std::string& name,
|
||||
TerminalFormat terminal_send_color = TerminalFormat::END,
|
||||
TerminalFormat terminal_recv_color = TerminalFormat::END);
|
||||
// Creates a connected channel
|
||||
Channel(
|
||||
struct bufferevent* bev,
|
||||
uint64_t virtual_network_id,
|
||||
Version version,
|
||||
uint8_t language,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
const std::string& name = "",
|
||||
TerminalFormat terminal_send_color = TerminalFormat::END,
|
||||
TerminalFormat terminal_recv_color = TerminalFormat::END);
|
||||
Channel(const Channel& other) = delete;
|
||||
Channel(Channel&& other) = delete;
|
||||
Channel& operator=(const Channel& other) = delete;
|
||||
Channel& operator=(Channel&& other) = delete;
|
||||
// Returns whether the channel is connected or not.
|
||||
virtual bool connected() const = 0;
|
||||
|
||||
void replace_with(
|
||||
Channel&& other,
|
||||
on_command_received_t on_command_received,
|
||||
on_error_t on_error,
|
||||
void* context_obj,
|
||||
const std::string& name = "");
|
||||
|
||||
void set_bufferevent(struct bufferevent* bev, uint64_t virtual_network_id);
|
||||
|
||||
inline bool connected() const {
|
||||
return this->bev.get() != nullptr;
|
||||
}
|
||||
void disconnect();
|
||||
|
||||
// Receives a message. Throws std::out_of_range if no messages are available.
|
||||
Message recv();
|
||||
// Disconnects the channel. Any pending data will still be sent before the underlying transport (e.g. socket) is
|
||||
// closed, but further send calls will do nothing.
|
||||
virtual void disconnect() = 0;
|
||||
|
||||
// Sends a message with an automatically-constructed header.
|
||||
void send(uint16_t cmd, uint32_t flag = 0, bool silent = false);
|
||||
@@ -92,12 +75,98 @@ struct Channel {
|
||||
this->send(cmd, flag, &data, sizeof(data), silent);
|
||||
}
|
||||
|
||||
// Sends a message with a pre-existing header (as the first few bytes in the
|
||||
// data)
|
||||
// Sends a message with a pre-existing header (as the first few bytes in the data)
|
||||
void send(const void* data, size_t size, bool silent = false);
|
||||
void send(const std::string& data, bool silent = false);
|
||||
|
||||
private:
|
||||
static void dispatch_on_input(struct bufferevent*, void* ctx);
|
||||
static void dispatch_on_error(struct bufferevent*, short events, void* ctx);
|
||||
// Receives a message. Throws std::out_of_range if no messages are available.
|
||||
asio::awaitable<Message> recv();
|
||||
|
||||
protected:
|
||||
Channel(
|
||||
Version version,
|
||||
Language language,
|
||||
const std::string& name,
|
||||
phosg::TerminalFormat terminal_send_color = phosg::TerminalFormat::END,
|
||||
phosg::TerminalFormat terminal_recv_color = phosg::TerminalFormat::END);
|
||||
Channel(const Channel& other) = delete;
|
||||
Channel(Channel&& other) = delete;
|
||||
Channel& operator=(const Channel& other) = delete;
|
||||
Channel& operator=(Channel&& other) = delete;
|
||||
|
||||
// Sends raw data on the underlying transport. If the channel is already disconnected, silently drops the data.
|
||||
virtual void send_raw(std::string&& data) = 0;
|
||||
// Receives raw data on the underlying transport. Raises when the channel is disconnected.
|
||||
virtual asio::awaitable<void> recv_raw(void* data, size_t size) = 0;
|
||||
};
|
||||
|
||||
// Standard channel type, used for most PSO clients. Represents an open TCP socket.
|
||||
class SocketChannel : public Channel, public std::enable_shared_from_this<SocketChannel> {
|
||||
public:
|
||||
std::unique_ptr<asio::ip::tcp::socket> sock;
|
||||
asio::ip::tcp::endpoint local_addr;
|
||||
asio::ip::tcp::endpoint remote_addr;
|
||||
|
||||
// SocketChannel has a static constructor because it has an internal task, which is necessary to support flushing
|
||||
// before disconnection (for example) and also to make send_raw not a coroutine, which keeps the rest of the code
|
||||
// cleaner.
|
||||
static std::shared_ptr<SocketChannel> create(std::shared_ptr<asio::io_context> io_context,
|
||||
std::unique_ptr<asio::ip::tcp::socket>&& sock,
|
||||
Version version,
|
||||
Language language,
|
||||
const std::string& name = "",
|
||||
phosg::TerminalFormat terminal_send_color = phosg::TerminalFormat::END,
|
||||
phosg::TerminalFormat terminal_recv_color = phosg::TerminalFormat::END);
|
||||
|
||||
virtual std::string default_name() const;
|
||||
|
||||
virtual bool connected() const;
|
||||
virtual void disconnect();
|
||||
|
||||
virtual void send_raw(std::string&& data);
|
||||
virtual asio::awaitable<void> recv_raw(void* data, size_t size);
|
||||
|
||||
private:
|
||||
SocketChannel(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
std::unique_ptr<asio::ip::tcp::socket>&& sock,
|
||||
Version version,
|
||||
Language language,
|
||||
const std::string& name,
|
||||
phosg::TerminalFormat terminal_send_color,
|
||||
phosg::TerminalFormat terminal_recv_color);
|
||||
|
||||
std::deque<std::string> outbound_data;
|
||||
bool should_disconnect = false;
|
||||
AsyncEvent send_buffer_nonempty_signal;
|
||||
|
||||
asio::awaitable<void> send_task();
|
||||
};
|
||||
|
||||
// In-process peer channel, used for replay testing.
|
||||
class PeerChannel : public Channel {
|
||||
public:
|
||||
std::weak_ptr<PeerChannel> peer;
|
||||
|
||||
PeerChannel(
|
||||
std::shared_ptr<asio::io_context> io_context,
|
||||
Version version,
|
||||
Language language,
|
||||
const std::string& name = "",
|
||||
phosg::TerminalFormat terminal_send_color = phosg::TerminalFormat::END,
|
||||
phosg::TerminalFormat terminal_recv_color = phosg::TerminalFormat::END);
|
||||
|
||||
static void link_peers(std::shared_ptr<PeerChannel> peer1, std::shared_ptr<PeerChannel> peer2);
|
||||
|
||||
virtual std::string default_name() const;
|
||||
|
||||
virtual bool connected() const;
|
||||
virtual void disconnect();
|
||||
|
||||
virtual void send_raw(std::string&& data);
|
||||
virtual asio::awaitable<void> recv_raw(void* data, size_t size);
|
||||
|
||||
private:
|
||||
AsyncEvent send_buffer_nonempty_signal;
|
||||
std::deque<std::string> inbound_data;
|
||||
};
|
||||
|
||||
+3105
-2441
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -2,13 +2,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Client.hh"
|
||||
#include "Lobby.hh"
|
||||
#include "ProxyServer.hh"
|
||||
#include "ProxySession.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);
|
||||
asio::awaitable<void> on_chat_command(std::shared_ptr<Client> c, const std::string& text, bool check_permissions);
|
||||
|
||||
+8
-8
@@ -28,10 +28,10 @@ const vector<ChoiceSearchCategory> CHOICE_SEARCH_CATEGORIES({
|
||||
if (choice_id == 0x0000) {
|
||||
return true;
|
||||
}
|
||||
uint32_t target_level = target_c->character()->disp.stats.level + 1;
|
||||
uint32_t target_level = target_c->character_file()->disp.stats.level + 1;
|
||||
switch (choice_id) {
|
||||
case 0x0001:
|
||||
return (labs(static_cast<int32_t>(target_level - searcher_c->character()->disp.stats.level)) <= 5);
|
||||
return (labs(static_cast<int32_t>(target_level - searcher_c->character_file()->disp.stats.level)) <= 5);
|
||||
case 0x0002:
|
||||
return (target_level <= 10);
|
||||
case 0x0003:
|
||||
@@ -80,13 +80,13 @@ const vector<ChoiceSearchCategory> CHOICE_SEARCH_CATEGORIES({
|
||||
case 0x0000:
|
||||
return true;
|
||||
case 0x0010:
|
||||
return target_c->character()->disp.visual.class_flags & 0x20;
|
||||
return target_c->character_file()->disp.visual.class_flags & 0x20;
|
||||
case 0x0011:
|
||||
return target_c->character()->disp.visual.class_flags & 0x40;
|
||||
return target_c->character_file()->disp.visual.class_flags & 0x40;
|
||||
case 0x0012:
|
||||
return target_c->character()->disp.visual.class_flags & 0x80;
|
||||
return target_c->character_file()->disp.visual.class_flags & 0x80;
|
||||
default:
|
||||
return ((choice_id - 1) == target_c->character()->disp.visual.char_class);
|
||||
return ((choice_id - 1) == target_c->character_file()->disp.visual.char_class);
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -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);
|
||||
@@ -143,7 +143,7 @@ const vector<ChoiceSearchCategory> CHOICE_SEARCH_CATEGORIES({
|
||||
{0x0006, "Challenge"},
|
||||
},
|
||||
.client_matches = +[](shared_ptr<Client>, shared_ptr<Client> target_c, uint16_t choice_id) -> bool {
|
||||
uint16_t target_choice_id = target_c->character()->choice_search_config.get_setting(0x0204);
|
||||
uint16_t target_choice_id = target_c->character_file()->choice_search_config.get_setting(0x0204);
|
||||
return (choice_id == 0) || (target_choice_id == 0) || (choice_id == target_choice_id);
|
||||
},
|
||||
},
|
||||
|
||||
+11
-16
@@ -7,18 +7,16 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Text.hh"
|
||||
#include "Types.hh"
|
||||
|
||||
class Client;
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
struct ChoiceSearchConfigT {
|
||||
using U16T = typename std::conditional<IsBigEndian, be_uint16_t, le_uint16_t>::type;
|
||||
using U32T = typename std::conditional<IsBigEndian, be_uint32_t, le_uint32_t>::type;
|
||||
|
||||
U32T disabled = 1; // 0 = enabled, 1 = disabled. Unused in command C3
|
||||
U32T<BE> disabled = 1; // 0 = enabled, 1 = disabled. Unused in command C3
|
||||
struct Entry {
|
||||
U16T parent_choice_id = 0;
|
||||
U16T choice_id = 0;
|
||||
U16T<BE> parent_choice_id = 0;
|
||||
U16T<BE> choice_id = 0;
|
||||
} __packed_ws__(Entry, 4);
|
||||
parray<Entry, 5> entries;
|
||||
|
||||
@@ -31,23 +29,20 @@ struct ChoiceSearchConfigT {
|
||||
return -1;
|
||||
}
|
||||
|
||||
operator ChoiceSearchConfigT<!IsBigEndian>() const {
|
||||
ChoiceSearchConfigT<!IsBigEndian> ret;
|
||||
ret.disabled = this->disabled.load();
|
||||
operator ChoiceSearchConfigT<!BE>() const {
|
||||
ChoiceSearchConfigT<!BE> ret;
|
||||
ret.disabled = this->disabled;
|
||||
for (size_t z = 0; z < this->entries.size(); z++) {
|
||||
auto& ret_e = ret.entries[z];
|
||||
const auto& this_e = this->entries[z];
|
||||
ret_e.parent_choice_id = this_e.parent_choice_id.load();
|
||||
ret_e.choice_id = this_e.choice_id.load();
|
||||
ret_e.parent_choice_id = this_e.parent_choice_id;
|
||||
ret_e.choice_id = this_e.choice_id;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} __packed__;
|
||||
|
||||
} __packed_ws_be__(ChoiceSearchConfigT, 0x18);
|
||||
using ChoiceSearchConfig = ChoiceSearchConfigT<false>;
|
||||
using ChoiceSearchConfigBE = ChoiceSearchConfigT<true>;
|
||||
check_struct_size(ChoiceSearchConfig, 0x18);
|
||||
check_struct_size(ChoiceSearchConfigBE, 0x18);
|
||||
|
||||
struct ChoiceSearchCategory {
|
||||
struct Choice {
|
||||
|
||||
+643
-636
File diff suppressed because it is too large
Load Diff
+199
-253
@@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Account.hh"
|
||||
#include "AsyncUtils.hh"
|
||||
#include "Channel.hh"
|
||||
#include "CommandFormats.hh"
|
||||
#include "Episode3/BattleRecord.hh"
|
||||
@@ -15,6 +14,7 @@
|
||||
#include "PSOEncryption.hh"
|
||||
#include "PSOProtocol.hh"
|
||||
#include "PatchFileIndex.hh"
|
||||
#include "ProxySession.hh"
|
||||
#include "Quest.hh"
|
||||
#include "QuestScript.hh"
|
||||
#include "TeamIndex.hh"
|
||||
@@ -22,79 +22,77 @@
|
||||
|
||||
extern const uint64_t CLIENT_CONFIG_MAGIC;
|
||||
|
||||
class Server;
|
||||
class GameServer;
|
||||
struct Lobby;
|
||||
class Parsed6x70Data;
|
||||
|
||||
struct GetPlayerInfoResult {
|
||||
// Exactly one of the following two shared_ptrs is not null
|
||||
std::shared_ptr<PSOBBCharacterFile> character;
|
||||
std::shared_ptr<PSOGCEp3CharacterFile::Character> ep3_character;
|
||||
bool is_full_info; // True if the client sent 30; false if it was 61 or 98
|
||||
};
|
||||
|
||||
class Client : public std::enable_shared_from_this<Client> {
|
||||
public:
|
||||
enum class Flag : uint64_t {
|
||||
// clang-format off
|
||||
|
||||
// This mask specifies which flags are sent to the client
|
||||
// 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,
|
||||
|
||||
// Version-related flags
|
||||
CHECKED_FOR_DC_V1_PROTOTYPE = 0x0000000000000002,
|
||||
NO_D6_AFTER_LOBBY = 0x0000000000000100,
|
||||
NO_D6 = 0x0000000000000200,
|
||||
FORCE_ENGLISH_LANGUAGE_BB = 0x0000000000000400,
|
||||
CHECKED_FOR_DC_V1_PROTOTYPE = 0x0000000000000001,
|
||||
NO_D6_AFTER_LOBBY = 0x0000000000000002,
|
||||
NO_D6 = 0x0000000000000004,
|
||||
FORCE_ENGLISH_LANGUAGE_BB = 0x0000000000000008,
|
||||
|
||||
// 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_NO_CACHE_PATCH = 0x0000000000008000,
|
||||
CAN_RECEIVE_ENABLE_B2_QUEST = 0x0000000000020000,
|
||||
AWAITING_ENABLE_B2_QUEST = 0x0000000000040000, // Server-side only
|
||||
HAS_SEND_FUNCTION_CALL = 0x0000000000000010,
|
||||
ENCRYPTED_SEND_FUNCTION_CALL = 0x0000000000000020,
|
||||
SEND_FUNCTION_CALL_ACTUALLY_RUNS_CODE = 0x0000000000000040,
|
||||
SEND_FUNCTION_CALL_NO_CACHE_PATCH = 0x0000000000000080,
|
||||
CAN_RECEIVE_ENABLE_B2_QUEST = 0x0000000000000100,
|
||||
AWAITING_ENABLE_B2_QUEST = 0x0000000000000200,
|
||||
|
||||
// State flags
|
||||
LOADING = 0x0000000000100000, // Server-side only
|
||||
LOADING_QUEST = 0x0000000000200000, // Server-side only
|
||||
LOADING_RUNNING_JOINABLE_QUEST = 0x0000000000400000, // Server-side only
|
||||
LOADING_TOURNAMENT = 0x0000000000800000, // Server-side only
|
||||
IN_INFORMATION_MENU = 0x0000000001000000, // Server-side only
|
||||
AT_WELCOME_MESSAGE = 0x0000000002000000, // Server-side only
|
||||
SAVE_ENABLED = 0x0000000004000000,
|
||||
HAS_EP3_CARD_DEFS = 0x0000000008000000,
|
||||
HAS_EP3_MEDIA_UPDATES = 0x0000000010000000,
|
||||
USE_OVERRIDE_RANDOM_SEED = 0x0000000020000000,
|
||||
HAS_GUILD_CARD_NUMBER = 0x0000000040000000,
|
||||
HAS_AUTO_PATCHES = 0x0000004000000000,
|
||||
AT_BANK_COUNTER = 0x0000000080000000, // Server-side only
|
||||
SHOULD_SEND_ARTIFICIAL_ITEM_STATE = 0x0001000000000000, // Server-side only
|
||||
SHOULD_SEND_ARTIFICIAL_ENEMY_AND_SET_STATE = 0x0040000000000000, // Server-side only
|
||||
SHOULD_SEND_ARTIFICIAL_OBJECT_STATE = 0x0080000000000000, // Server-side only
|
||||
SHOULD_SEND_ARTIFICIAL_FLAG_STATE = 0x0002000000000000, // Server-side only
|
||||
SHOULD_SEND_ARTIFICIAL_PLAYER_STATES = 0x0200000000000000, // Server-side only
|
||||
SHOULD_SEND_ENABLE_SAVE = 0x0004000000000000,
|
||||
SWITCH_ASSIST_ENABLED = 0x0000000100000000,
|
||||
IS_CLIENT_CUSTOMIZATION = 0x0100000000000000,
|
||||
LOADING = 0x0000000000000400,
|
||||
LOADING_QUEST = 0x0000000000000800,
|
||||
LOADING_RUNNING_JOINABLE_QUEST = 0x0000000000001000,
|
||||
LOADING_TOURNAMENT = 0x0000000000002000,
|
||||
IN_INFORMATION_MENU = 0x0000000000004000,
|
||||
AT_WELCOME_MESSAGE = 0x0000000000008000,
|
||||
SAVE_ENABLED = 0x0000000000010000,
|
||||
HAS_EP3_CARD_DEFS = 0x0000000000020000,
|
||||
HAS_EP3_MEDIA_UPDATES = 0x0000000000040000,
|
||||
HAS_AUTO_PATCHES = 0x0000000000080000,
|
||||
AT_BANK_COUNTER = 0x0000000000100000,
|
||||
SHOULD_SEND_ARTIFICIAL_ITEM_STATE = 0x0000000000200000,
|
||||
SHOULD_SEND_ARTIFICIAL_ENEMY_AND_SET_STATE = 0x0000000000400000,
|
||||
SHOULD_SEND_ARTIFICIAL_OBJECT_STATE = 0x0000000000800000,
|
||||
SHOULD_SEND_ARTIFICIAL_FLAG_STATE = 0x0000000001000000,
|
||||
SHOULD_SEND_ARTIFICIAL_PLAYER_STATES = 0x0000000002000000,
|
||||
SHOULD_SEND_ENABLE_SAVE = 0x0000000004000000,
|
||||
SWITCH_ASSIST_ENABLED = 0x0000000008000000,
|
||||
IS_CLIENT_CUSTOMIZATION = 0x0000000010000000,
|
||||
EP3_ALLOW_6xBC = 0x0000000020000000,
|
||||
|
||||
// Cheat mode and option flags
|
||||
INFINITE_HP_ENABLED = 0x0000000200000000,
|
||||
INFINITE_TP_ENABLED = 0x0000000400000000,
|
||||
DEBUG_ENABLED = 0x0000000800000000,
|
||||
ITEM_DROP_NOTIFICATIONS_1 = 0x0010000000000000,
|
||||
ITEM_DROP_NOTIFICATIONS_2 = 0x0020000000000000,
|
||||
INFINITE_HP_ENABLED = 0x0000000040000000,
|
||||
INFINITE_TP_ENABLED = 0x0000000080000000,
|
||||
FAST_KILLS_ENABLED = 0x0000000100000000,
|
||||
ALL_RARES_ENABLED = 0x0000100000000000,
|
||||
DEBUG_ENABLED = 0x0000000200000000,
|
||||
ITEM_DROP_NOTIFICATIONS_1 = 0x0000000400000000,
|
||||
ITEM_DROP_NOTIFICATIONS_2 = 0x0000000800000000,
|
||||
HAS_ENEMY_DAMAGE_SYNC_PATCH = 0x0000001000000000, // Must be same as in EnemyDamageSync*.s
|
||||
HAS_PSO_PEEPS_XP_PATCH = 0x0000200000000000, // Must be same as in PSO Peeps XP patches
|
||||
|
||||
// Proxy option flags
|
||||
PROXY_SAVE_FILES = 0x0000001000000000,
|
||||
PROXY_CHAT_COMMANDS_ENABLED = 0x0000002000000000,
|
||||
PROXY_SAVE_FILES = 0x0000002000000000,
|
||||
PROXY_CHAT_COMMANDS_ENABLED = 0x0000004000000000,
|
||||
PROXY_PLAYER_NOTIFICATIONS_ENABLED = 0x0000008000000000,
|
||||
PROXY_SUPPRESS_CLIENT_PINGS = 0x0000010000000000,
|
||||
PROXY_SUPPRESS_REMOTE_LOGIN = 0x0000020000000000,
|
||||
PROXY_ZERO_REMOTE_GUILD_CARD = 0x0000040000000000,
|
||||
PROXY_EP3_INFINITE_MESETA_ENABLED = 0x0000080000000000,
|
||||
PROXY_EP3_INFINITE_TIME_ENABLED = 0x0000100000000000,
|
||||
PROXY_RED_NAME_ENABLED = 0x0000200000000000,
|
||||
PROXY_BLANK_NAME_ENABLED = 0x0000400000000000,
|
||||
PROXY_BLOCK_FUNCTION_CALLS = 0x0000800000000000,
|
||||
PROXY_EP3_UNMASK_WHISPERS = 0x0008000000000000,
|
||||
PROXY_VIRTUAL_CLIENT = 0x0400000000000000,
|
||||
PROXY_EP3_INFINITE_MESETA_ENABLED = 0x0000010000000000,
|
||||
PROXY_EP3_INFINITE_TIME_ENABLED = 0x0000020000000000,
|
||||
PROXY_BLOCK_FUNCTION_CALLS = 0x0000040000000000,
|
||||
PROXY_EP3_UNMASK_WHISPERS = 0x0000080000000000,
|
||||
// clang-format on
|
||||
};
|
||||
enum class ItemDropNotificationMode {
|
||||
@@ -106,124 +104,73 @@ public:
|
||||
|
||||
static constexpr uint64_t DEFAULT_FLAGS = static_cast<uint64_t>(Flag::PROXY_CHAT_COMMANDS_ENABLED);
|
||||
|
||||
struct Config {
|
||||
uint64_t enabled_flags = DEFAULT_FLAGS; // Client::Flag enum
|
||||
uint32_t specific_version = 0;
|
||||
int32_t override_random_seed = 0;
|
||||
uint8_t override_section_id = 0xFF; // FF = no override
|
||||
uint8_t override_lobby_event = 0xFF; // FF = no override
|
||||
uint8_t override_lobby_number = 0x80; // 80 = no override
|
||||
uint32_t proxy_destination_address = 0;
|
||||
uint16_t proxy_destination_port = 0;
|
||||
|
||||
Config() = default;
|
||||
|
||||
bool operator==(const Config& other) const = default;
|
||||
bool operator!=(const Config& other) const = default;
|
||||
|
||||
bool should_update_vs(const Config& other) const;
|
||||
|
||||
[[nodiscard]] static inline bool check_flag(uint64_t enabled_flags, Flag flag) {
|
||||
return !!(enabled_flags & static_cast<uint64_t>(flag));
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool check_flag(Flag flag) const {
|
||||
return this->check_flag(this->enabled_flags, flag);
|
||||
}
|
||||
inline void set_flag(Flag flag) {
|
||||
this->enabled_flags |= static_cast<uint64_t>(flag);
|
||||
}
|
||||
inline void clear_flag(Flag flag) {
|
||||
this->enabled_flags &= (~static_cast<uint64_t>(flag));
|
||||
}
|
||||
inline void toggle_flag(Flag flag) {
|
||||
this->enabled_flags ^= static_cast<uint64_t>(flag);
|
||||
}
|
||||
|
||||
void set_flags_for_version(Version version, int64_t sub_version);
|
||||
|
||||
ItemDropNotificationMode get_drop_notification_mode() const;
|
||||
void set_drop_notification_mode(ItemDropNotificationMode new_mode);
|
||||
|
||||
template <size_t Bytes>
|
||||
void parse_from(const parray<uint8_t, Bytes>& data) {
|
||||
StringReader r(data.data(), data.size());
|
||||
if (r.get_u32l() != CLIENT_CONFIG_MAGIC) {
|
||||
throw std::invalid_argument("config signature is incorrect");
|
||||
}
|
||||
this->specific_version = r.get_u32l();
|
||||
this->enabled_flags = r.get_u64l();
|
||||
this->override_random_seed = r.get_u32l();
|
||||
this->proxy_destination_address = r.get_u32b();
|
||||
this->proxy_destination_port = r.get_u16l();
|
||||
this->override_section_id = r.get_u8();
|
||||
this->override_lobby_event = r.get_u8();
|
||||
this->override_lobby_number = r.get_u8();
|
||||
}
|
||||
|
||||
template <size_t Bytes>
|
||||
void serialize_into(parray<uint8_t, Bytes>& data) const {
|
||||
StringWriter w;
|
||||
w.put_u32l(CLIENT_CONFIG_MAGIC);
|
||||
w.put_u32l(this->specific_version);
|
||||
w.put_u64l(this->enabled_flags & static_cast<uint64_t>(Flag::CLIENT_SIDE_MASK));
|
||||
w.put_u32l(this->override_random_seed);
|
||||
w.put_u32b(this->proxy_destination_address);
|
||||
w.put_u16l(this->proxy_destination_port);
|
||||
w.put_u8(this->override_section_id);
|
||||
w.put_u8(this->override_lobby_event);
|
||||
w.put_u8(this->override_lobby_number);
|
||||
|
||||
const auto& s = w.str();
|
||||
for (size_t z = 0; z < s.size(); z++) {
|
||||
data[z] = s[z];
|
||||
}
|
||||
data.clear_after(s.size(), 0xFF);
|
||||
}
|
||||
};
|
||||
|
||||
std::weak_ptr<Server> server;
|
||||
std::weak_ptr<GameServer> server;
|
||||
uint64_t id;
|
||||
PrefixedLogger log;
|
||||
phosg::PrefixedLogger log;
|
||||
|
||||
// Account information (not all of these are used; depends on game version)
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string email_address;
|
||||
uint64_t hardware_id = 0;
|
||||
int32_t sub_version = 0;
|
||||
uint8_t bb_client_code = 0;
|
||||
uint8_t bb_connection_phase = 0xFF;
|
||||
ssize_t bb_character_index = -1; // -1 = not set
|
||||
ssize_t bb_bank_character_index = -1; // -1 = shared bank
|
||||
uint32_t bb_security_token = 0;
|
||||
parray<uint8_t, 0x28> bb_client_config;
|
||||
std::string login_character_name;
|
||||
std::string serial_number;
|
||||
std::string access_key;
|
||||
std::string serial_number2;
|
||||
std::string access_key2;
|
||||
std::string v1_serial_number;
|
||||
std::string v1_access_key;
|
||||
XBNetworkLocation xb_netloc;
|
||||
parray<le_uint32_t, 3> xb_unknown_a1a;
|
||||
uint64_t xb_user_id = 0;
|
||||
uint32_t xb_unknown_a1b = 0;
|
||||
std::shared_ptr<Login> login;
|
||||
std::shared_ptr<ProxySession> proxy_session;
|
||||
|
||||
// Patch server state (only used for PC_PATCH and BB_PATCH versions)
|
||||
std::vector<PatchFileChecksumRequest> patch_file_checksum_requests;
|
||||
|
||||
// Network
|
||||
Channel channel;
|
||||
struct sockaddr_storage next_connection_addr;
|
||||
std::shared_ptr<Channel> channel;
|
||||
std::shared_ptr<PSOBBMultiKeyDetectorEncryption> bb_detector_crypt;
|
||||
ServerBehavior server_behavior;
|
||||
bool should_disconnect;
|
||||
bool should_send_to_lobby_server;
|
||||
bool should_send_to_proxy_server;
|
||||
uint16_t listener_port = 0;
|
||||
std::unordered_map<std::string, std::function<void()>> disconnect_hooks;
|
||||
std::shared_ptr<XBNetworkLocation> xb_netloc;
|
||||
parray<le_uint32_t, 3> xb_9E_unknown_a1a;
|
||||
uint8_t bb_connection_phase;
|
||||
uint64_t ping_start_time;
|
||||
uint64_t ping_start_time = 0;
|
||||
|
||||
// Lobby/positioning
|
||||
Config config;
|
||||
Config synced_config;
|
||||
std::unique_ptr<parray<le_uint32_t, 0x20>> override_variations;
|
||||
int32_t sub_version;
|
||||
float x;
|
||||
float z;
|
||||
uint32_t floor;
|
||||
// Basic state
|
||||
uint64_t enabled_flags = DEFAULT_FLAGS; // Client::Flag enum
|
||||
uint32_t specific_version = 0;
|
||||
uint8_t override_section_id = 0xFF; // FF = no override
|
||||
uint8_t override_lobby_event = 0xFF; // FF = no override
|
||||
uint8_t override_lobby_number = 0x80; // 80 = no override
|
||||
int64_t override_random_seed = -1;
|
||||
int8_t selected_blueballz_tier = -1; // -1 = normal lobby/game; 0..10 = requested Blueballz tier
|
||||
std::unique_ptr<Variations> override_variations;
|
||||
VectorXYZF pos;
|
||||
uint32_t floor = 0x0F;
|
||||
std::weak_ptr<Lobby> lobby;
|
||||
uint8_t lobby_client_id;
|
||||
uint8_t lobby_arrow_color;
|
||||
int64_t preferred_lobby_id; // <0 = no preference
|
||||
uint8_t lobby_client_id = 0;
|
||||
uint8_t lobby_arrow_color = 0;
|
||||
int64_t preferred_lobby_id = -1; // <0 = none chosen
|
||||
|
||||
std::unique_ptr<struct event, void (*)(struct event*)> save_game_data_event;
|
||||
std::unique_ptr<struct event, void (*)(struct event*)> send_ping_event;
|
||||
std::unique_ptr<struct event, void (*)(struct event*)> idle_timeout_event;
|
||||
int16_t card_battle_table_number;
|
||||
uint16_t card_battle_table_seat_number;
|
||||
uint16_t card_battle_table_seat_state;
|
||||
asio::steady_timer save_game_data_timer;
|
||||
asio::steady_timer send_ping_timer;
|
||||
asio::steady_timer idle_timeout_timer;
|
||||
int16_t card_battle_table_number = -1;
|
||||
uint16_t card_battle_table_seat_number = 0;
|
||||
uint16_t card_battle_table_seat_state = 0;
|
||||
std::weak_ptr<Episode3::Tournament::Team> ep3_tournament_team;
|
||||
std::shared_ptr<const Episode3::BattleRecord> ep3_prev_battle_record;
|
||||
std::shared_ptr<const Menu> last_menu_sent;
|
||||
uint32_t last_game_info_requested;
|
||||
uint32_t last_game_info_requested = 0;
|
||||
struct JoinCommand {
|
||||
uint16_t command;
|
||||
uint32_t flag;
|
||||
@@ -249,54 +196,66 @@ public:
|
||||
// These are null unless the client is within the trade sequence (D0-D4 or EE commands)
|
||||
std::unique_ptr<PendingItemTrade> pending_item_trade;
|
||||
std::unique_ptr<PendingCardTrade> pending_card_trade;
|
||||
uint32_t telepipe_lobby_id;
|
||||
G_SetTelepipeState_6x68 telepipe_state;
|
||||
uint32_t telepipe_lobby_id = 0;
|
||||
TelepipeState telepipe_state;
|
||||
std::shared_ptr<Episode3::PlayerConfig> ep3_config; // Null for non-Ep3
|
||||
int8_t bb_character_index;
|
||||
ItemData bb_identify_result;
|
||||
std::array<std::vector<ItemData>, 3> bb_shop_contents;
|
||||
|
||||
// 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;
|
||||
ssize_t character_index = -1;
|
||||
std::shared_ptr<const BBLicense> dest_bb_license; // Only used for $bbchar; null for $savechar
|
||||
};
|
||||
std::unique_ptr<PendingCharacterExport> pending_character_export;
|
||||
std::deque<std::function<void(uint32_t, uint32_t)>> function_call_response_queue;
|
||||
// Miscellaneous (used by chat commands / quest opcodes)
|
||||
uint8_t schtserv_response_register = 0;
|
||||
uint32_t next_exp_value = 0;
|
||||
bool can_chat = true;
|
||||
// NOTE: If you add any new optional promises here, make sure to also add them to cancel_pending_promises.
|
||||
// NOTE: Entries in this queue can be nullptr; that represents a B2 command sent by the remote server during a proxy
|
||||
// session. We can't just omit those from the queue entirely, because if we did, we could end up sending the wrong B3
|
||||
// response back.
|
||||
std::deque<std::shared_ptr<AsyncPromise<C_ExecuteCodeResult_B3>>> function_call_response_queue;
|
||||
std::shared_ptr<AsyncPromise<GetPlayerInfoResult>> character_data_ready_promise;
|
||||
std::shared_ptr<AsyncPromise<void>> enable_save_promise;
|
||||
|
||||
// File loading state
|
||||
uint32_t dol_base_addr;
|
||||
std::shared_ptr<DOLFileIndex::File> loading_dol_file;
|
||||
std::unordered_map<std::string, std::shared_ptr<const std::string>> sending_files;
|
||||
|
||||
Client(
|
||||
std::shared_ptr<Server> server,
|
||||
struct bufferevent* bev,
|
||||
uint64_t virtual_network_id,
|
||||
Version version,
|
||||
ServerBehavior server_behavior);
|
||||
Client(std::shared_ptr<GameServer> server, std::shared_ptr<Channel> channel, ServerBehavior server_behavior);
|
||||
~Client();
|
||||
|
||||
void update_channel_name();
|
||||
|
||||
void reschedule_save_game_data_event();
|
||||
void reschedule_ping_and_timeout_events();
|
||||
void reschedule_save_game_data_timer();
|
||||
void reschedule_ping_and_timeout_timers();
|
||||
|
||||
inline Version version() const {
|
||||
return this->channel.version;
|
||||
return this->channel->version;
|
||||
}
|
||||
inline uint8_t language() const {
|
||||
return this->channel.language;
|
||||
inline Language language() const {
|
||||
return this->channel->language;
|
||||
}
|
||||
|
||||
[[nodiscard]] static inline bool check_flag(uint64_t enabled_flags, Flag flag) {
|
||||
return !!(enabled_flags & static_cast<uint64_t>(flag));
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool check_flag(Flag flag) const {
|
||||
return this->check_flag(this->enabled_flags, flag);
|
||||
}
|
||||
inline void set_flag(Flag flag) {
|
||||
this->enabled_flags |= static_cast<uint64_t>(flag);
|
||||
}
|
||||
inline void clear_flag(Flag flag) {
|
||||
this->enabled_flags &= (~static_cast<uint64_t>(flag));
|
||||
}
|
||||
inline void toggle_flag(Flag flag) {
|
||||
this->enabled_flags ^= static_cast<uint64_t>(flag);
|
||||
}
|
||||
|
||||
void set_flags_for_version(Version version, int64_t sub_version);
|
||||
|
||||
ItemDropNotificationMode get_drop_notification_mode() const;
|
||||
void set_drop_notification_mode(ItemDropNotificationMode new_mode);
|
||||
|
||||
void convert_account_to_temporary_if_nte();
|
||||
|
||||
void sync_config();
|
||||
|
||||
std::shared_ptr<ServerState> require_server_state() const;
|
||||
std::shared_ptr<Lobby> require_lobby() const;
|
||||
|
||||
@@ -306,38 +265,58 @@ public:
|
||||
std::shared_ptr<const IntegralExpression> expr,
|
||||
std::shared_ptr<const Lobby> game,
|
||||
uint8_t event,
|
||||
uint8_t difficulty,
|
||||
Difficulty difficulty,
|
||||
size_t num_players,
|
||||
bool v1_present) const;
|
||||
bool can_see_quest(
|
||||
std::shared_ptr<const Quest> q,
|
||||
std::shared_ptr<const Lobby> game,
|
||||
uint8_t event,
|
||||
uint8_t difficulty,
|
||||
Difficulty difficulty,
|
||||
size_t num_players,
|
||||
bool v1_present) const;
|
||||
bool can_play_quest(
|
||||
std::shared_ptr<const Quest> q,
|
||||
std::shared_ptr<const Lobby> game,
|
||||
uint8_t event,
|
||||
uint8_t difficulty,
|
||||
Difficulty difficulty,
|
||||
size_t num_players,
|
||||
bool v1_present) const;
|
||||
|
||||
bool can_use_chat_commands() const;
|
||||
|
||||
static void dispatch_save_game_data(evutil_socket_t, short, void* ctx);
|
||||
void save_game_data();
|
||||
static void dispatch_send_ping(evutil_socket_t, short, void* ctx);
|
||||
void send_ping();
|
||||
static void dispatch_idle_timeout(evutil_socket_t, short, void* ctx);
|
||||
void idle_timeout();
|
||||
void set_login(std::shared_ptr<Login> login);
|
||||
|
||||
void suspend_timeouts();
|
||||
void import_blocked_senders(const parray<le_uint32_t, 30>& blocked_senders);
|
||||
|
||||
const std::string& get_bb_username() const;
|
||||
void set_bb_username(const std::string& bb_username);
|
||||
static std::string system_filename(const std::string& bb_username);
|
||||
std::string system_filename() const;
|
||||
std::shared_ptr<PSOBBBaseSystemFile> system_file(bool allow_load = true);
|
||||
std::shared_ptr<const PSOBBBaseSystemFile> system_file(bool throw_if_missing = true) const;
|
||||
void save_system_file() const;
|
||||
|
||||
static std::string guild_card_filename(const std::string& bb_username);
|
||||
std::string guild_card_filename() const;
|
||||
std::shared_ptr<PSOBBGuildCardFile> guild_card_file(bool allow_load = true);
|
||||
std::shared_ptr<const PSOBBGuildCardFile> guild_card_file(bool allow_load = true) const;
|
||||
void save_guild_card_file() const;
|
||||
|
||||
static std::string character_filename(const std::string& bb_username, ssize_t index);
|
||||
static std::string backup_character_filename(uint32_t account_id, size_t index, bool is_ep3);
|
||||
std::string character_filename() const;
|
||||
std::shared_ptr<PSOBBCharacterFile> character_file(bool allow_load = true, bool allow_overlay = true);
|
||||
std::shared_ptr<const PSOBBCharacterFile> character_file(bool throw_if_missing = true, bool allow_overlay = true) const;
|
||||
static void save_character_file(
|
||||
const std::string& filename,
|
||||
std::shared_ptr<const PSOBBBaseSystemFile> sys,
|
||||
std::shared_ptr<const PSOBBCharacterFile> character);
|
||||
static void save_ep3_character_file(const std::string& filename, const PSOGCEp3CharacterFile::Character& character);
|
||||
void save_character_file();
|
||||
void create_character_file(
|
||||
uint32_t guild_card_number,
|
||||
Language language,
|
||||
const PlayerDispDataBBPreview& preview,
|
||||
std::shared_ptr<const LevelTable> level_table);
|
||||
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);
|
||||
inline void delete_overlay() {
|
||||
@@ -347,72 +326,39 @@ public:
|
||||
return this->overlay_character_data.get() != nullptr;
|
||||
}
|
||||
|
||||
void import_blocked_senders(const parray<le_uint32_t, 30>& blocked_senders);
|
||||
static std::string bank_filename(const std::string& bb_username, ssize_t index);
|
||||
std::string bank_filename() const;
|
||||
std::shared_ptr<PlayerBank> bank_file(bool allow_load = true);
|
||||
std::shared_ptr<const PlayerBank> bank_file(bool throw_if_missing = true) const;
|
||||
static void save_bank_file(const std::string& filename, const PlayerBank& bank);
|
||||
void save_bank_file() const;
|
||||
void change_bank(ssize_t bb_character_index); // -1 = use shared bank
|
||||
|
||||
std::shared_ptr<PSOBBBaseSystemFile> system_file(bool allow_load = true);
|
||||
std::shared_ptr<PSOBBCharacterFile> character(bool allow_load = true, bool allow_overlay = true);
|
||||
std::shared_ptr<PSOBBGuildCardFile> guild_card_file(bool allow_load = true);
|
||||
std::shared_ptr<const PSOBBBaseSystemFile> system_file(bool allow_load = true) const;
|
||||
std::shared_ptr<const PSOBBCharacterFile> character(bool allow_load = true, bool allow_overlay = true) const;
|
||||
std::shared_ptr<const PSOBBGuildCardFile> guild_card_file(bool allow_load = true) const;
|
||||
|
||||
void create_character_file(
|
||||
uint32_t guild_card_number,
|
||||
uint8_t language,
|
||||
const PlayerDispDataBBPreview& preview,
|
||||
std::shared_ptr<const LevelTable> level_table);
|
||||
|
||||
std::string system_filename() const;
|
||||
static std::string character_filename(const std::string& bb_username, int8_t index);
|
||||
static std::string backup_character_filename(uint32_t account_id, size_t index, bool is_ep3);
|
||||
std::string character_filename(int8_t index = -1) const;
|
||||
std::string guild_card_filename() const;
|
||||
std::string shared_bank_filename() const;
|
||||
|
||||
std::string legacy_player_filename() const;
|
||||
std::string legacy_account_filename() const;
|
||||
std::string legacy_player_filename() const;
|
||||
|
||||
void save_all();
|
||||
void save_system_file() const;
|
||||
static void save_character_file(
|
||||
const std::string& filename,
|
||||
std::shared_ptr<const PSOBBBaseSystemFile> sys,
|
||||
std::shared_ptr<const PSOBBCharacterFile> character);
|
||||
static void save_ep3_character_file(
|
||||
const std::string& filename,
|
||||
const PSOGCEp3CharacterFile::Character& character);
|
||||
// Note: This function is not const because it updates the player's play time.
|
||||
void save_character_file();
|
||||
void save_guild_card_file() const;
|
||||
|
||||
void load_backup_character(uint32_t account_id, size_t index);
|
||||
std::shared_ptr<PSOGCEp3CharacterFile::Character> load_ep3_backup_character(uint32_t account_id, size_t index);
|
||||
void save_and_unload_character();
|
||||
void unload_character(bool save);
|
||||
|
||||
PlayerBank200& current_bank();
|
||||
std::shared_ptr<PSOBBCharacterFile> current_bank_character();
|
||||
bool use_shared_bank(); // Returns true if the bank exists; false if it was created
|
||||
void use_character_bank(int8_t bb_character_index);
|
||||
void use_default_bank();
|
||||
void print_inventory() const;
|
||||
void print_bank() const;
|
||||
|
||||
void print_inventory(FILE* stream) const;
|
||||
void print_bank(FILE* stream) const;
|
||||
void cancel_pending_promises();
|
||||
|
||||
private:
|
||||
// The overlay character data is used in battle and challenge modes, when
|
||||
// character data is temporarily replaced in-game. In other play modes and in
|
||||
// lobbies, overlay_character_data is null.
|
||||
// The overlay character data is used in battle and challenge modes, when character data is temporarily replaced
|
||||
// in-game. In other play modes and in lobbies, overlay_character_data is null.
|
||||
std::shared_ptr<PSOBBBaseSystemFile> system_data;
|
||||
std::shared_ptr<PSOBBCharacterFile> overlay_character_data;
|
||||
std::shared_ptr<PSOBBCharacterFile> character_data;
|
||||
std::shared_ptr<PSOBBGuildCardFile> guild_card_data;
|
||||
std::shared_ptr<PlayerBank200> external_bank;
|
||||
std::shared_ptr<PSOBBCharacterFile> external_bank_character;
|
||||
int8_t external_bank_character_index;
|
||||
uint64_t last_play_time_update;
|
||||
|
||||
void save_and_clear_external_bank();
|
||||
std::shared_ptr<PlayerBank> bank_data;
|
||||
uint64_t last_play_time_update = 0;
|
||||
|
||||
void load_all_files();
|
||||
void update_character_data_after_load(std::shared_ptr<PSOBBCharacterFile> character_data);
|
||||
void update_bank_data_after_load(std::shared_ptr<PlayerBank> bank_data);
|
||||
};
|
||||
|
||||
+2648
-2781
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,162 @@
|
||||
#pragma once
|
||||
|
||||
#include <phosg/Encoding.hh>
|
||||
#include <phosg/Vector.hh>
|
||||
|
||||
#include "Text.hh"
|
||||
|
||||
constexpr double radians_for_fixed_point_angle(uint16_t angle) {
|
||||
return static_cast<double>(angle * 2 * M_PI) / 0x10000;
|
||||
}
|
||||
|
||||
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 double dist(const VectorXZF& other) const {
|
||||
return sqrt(this->dist2(other));
|
||||
}
|
||||
inline double dist2(const VectorXZF& other) const {
|
||||
double x = this->x - other.x;
|
||||
double z = this->z - other.z;
|
||||
return ((x * x) + (z * z));
|
||||
}
|
||||
|
||||
inline VectorXZF rotate_y(double angle) const {
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
return VectorXZF{this->x * c - this->z * s, this->x * s + this->z * c};
|
||||
}
|
||||
|
||||
inline std::string str() const {
|
||||
return std::format("[VectorXZF x={:g} z={:g}]", this->x, this->z);
|
||||
}
|
||||
} __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 VectorXYZF rotate_x(double angle) const {
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
return VectorXYZF{this->x, this->y * c - this->z * s, this->y * s + this->z * c};
|
||||
}
|
||||
inline VectorXYZF rotate_y(double angle) const {
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
return VectorXYZF{this->x * c + this->z * s, this->y, -this->x * s + this->z * c};
|
||||
}
|
||||
inline VectorXYZF rotate_z(double angle) const {
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
return VectorXYZF{this->x * c - this->y * s, this->x * s + this->y * c, this->z};
|
||||
}
|
||||
|
||||
inline std::string str() const {
|
||||
return std::format("[VectorXYZF x={:g} y={:g} z={:g}]", this->x, this->y, this->z);
|
||||
}
|
||||
} __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_ws_be__(ArrayRefT, 8);
|
||||
using ArrayRef = ArrayRefT<false>;
|
||||
using ArrayRefBE = ArrayRefT<true>;
|
||||
|
||||
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 at the beginning of the file
|
||||
// data, 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 file is added to the existing value.
|
||||
//
|
||||
// For example, if the file data 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 some 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;
|
||||
} __packed_ws_be__(RELFileFooterT, 0x20);
|
||||
using RELFileFooter = RELFileFooterT<false>;
|
||||
using RELFileFooterBE = RELFileFooterT<true>;
|
||||
+592
-286
File diff suppressed because it is too large
Load Diff
+167
-181
@@ -4,24 +4,36 @@
|
||||
#include <phosg/Encoding.hh>
|
||||
#include <phosg/JSON.hh>
|
||||
|
||||
#include "EnemyType.hh"
|
||||
#include "GSLArchive.hh"
|
||||
#include "PSOEncryption.hh"
|
||||
#include "StaticGameData.hh"
|
||||
#include "Text.hh"
|
||||
#include "Types.hh"
|
||||
|
||||
class CommonItemSet {
|
||||
public:
|
||||
class Table {
|
||||
public:
|
||||
Table() = delete;
|
||||
Table(const JSON& json, Episode episode);
|
||||
Table(const StringReader& r, bool big_endian, bool is_v3, Episode episode);
|
||||
Table(std::shared_ptr<const Table> prev_table, const phosg::JSON& json, Episode episode);
|
||||
Table(const phosg::StringReader& r, bool big_endian, bool is_v3, Episode episode);
|
||||
|
||||
bool operator==(const Table& other) const = default;
|
||||
bool operator!=(const Table& other) const = default;
|
||||
|
||||
template <typename IntT>
|
||||
struct Range {
|
||||
IntT min;
|
||||
IntT max;
|
||||
} __packed__;
|
||||
IntT min = 0;
|
||||
IntT max = 0;
|
||||
|
||||
bool operator==(const Range& other) const = default;
|
||||
bool operator!=(const Range& other) const = default;
|
||||
|
||||
inline bool empty() const {
|
||||
return ((this->min | this->max) == 0);
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
Episode episode;
|
||||
parray<uint8_t, 0x0C> base_weapon_type_prob_table;
|
||||
@@ -30,9 +42,10 @@ public:
|
||||
parray<parray<uint8_t, 4>, 9> grind_prob_table;
|
||||
parray<uint8_t, 0x05> armor_shield_type_index_prob_table;
|
||||
parray<uint8_t, 0x05> armor_slot_count_prob_table;
|
||||
parray<Range<uint16_t>, 0x64> enemy_meseta_ranges;
|
||||
parray<uint8_t, 0x64> enemy_type_drop_probs;
|
||||
parray<uint8_t, 0x64> enemy_item_classes;
|
||||
// Note: PSO originally uses arrays indexed by rt_index here, but we index enemies by the EnemyType enum instead
|
||||
std::unordered_map<EnemyType, Range<uint16_t>> enemy_type_meseta_ranges;
|
||||
std::unordered_map<EnemyType, uint8_t> enemy_type_drop_probs;
|
||||
std::unordered_map<EnemyType, uint8_t> enemy_type_item_classes;
|
||||
parray<Range<uint16_t>, 0x0A> box_meseta_ranges;
|
||||
bool has_rare_bonus_value_prob_table;
|
||||
parray<parray<uint16_t, 6>, 0x17> bonus_value_prob_table;
|
||||
@@ -47,66 +60,53 @@ public:
|
||||
parray<uint8_t, 0x0A> unit_max_stars_table;
|
||||
parray<parray<uint8_t, 10>, 7> box_item_class_prob_table;
|
||||
|
||||
JSON json() const;
|
||||
phosg::JSON json(std::shared_ptr<const Table> prev_table) const;
|
||||
void print(FILE* stream) const;
|
||||
void print_diff(FILE* stream, const Table& other) const;
|
||||
|
||||
private:
|
||||
template <bool IsBigEndian>
|
||||
void parse_itempt_t(const StringReader& r, bool is_v3);
|
||||
template <bool BE>
|
||||
void parse_itempt_t(const phosg::StringReader& r, bool is_v3);
|
||||
|
||||
template <bool IsBigEndian>
|
||||
template <bool BE>
|
||||
struct OffsetsT {
|
||||
using U16T = typename std::conditional<IsBigEndian, be_uint16_t, le_uint16_t>::type;
|
||||
using U32T = typename std::conditional<IsBigEndian, be_uint32_t, le_uint32_t>::type;
|
||||
// This data structure uses index probability tables in multiple places. An index probability table is a table
|
||||
// where each entry holds the probability that that entry's index is used. For example, if the armor slot count
|
||||
// probability table contains [77, 17, 5, 1, 0], this means there is a 77% chance of no slots, 17% chance of 1
|
||||
// slot, 5% chance of 2 slots, 1% chance of 3 slots, and no chance of 4 slots. The values in index probability
|
||||
// tables do not have to add up to 100; the game sums all of them and chooses a random number less than that
|
||||
// maximum.
|
||||
|
||||
// This data structure uses index probability tables in multiple places. An
|
||||
// index probability table is a table where each entry holds the probability
|
||||
// that that entry's index is used. For example, if the armor slot count
|
||||
// probability table contains [77, 17, 5, 1, 0], this means there is a 77%
|
||||
// chance of no slots, 17% chance of 1 slot, 5% chance of 2 slots, 1% chance
|
||||
// of 3 slots, and no chance of 4 slots. The values in index probability
|
||||
// tables do not have to add up to 100; the game sums all of them and
|
||||
// chooses a random number less than that maximum.
|
||||
// The area (floor) number is used in many places as well. Unlike the normal area numbers, which start with
|
||||
// Pioneer 2, the area numbers in this structure start with Forest 1, and boss areas are treated as the first
|
||||
// area of the next section (so De Rol Le has Mines 1 drops, for example). Final boss areas are treated as the
|
||||
// last non-boss area (so Dark Falz boxes are like Ruins 3 boxes). We refer to these adjusted area numbers as
|
||||
// (area - 1), or area_norm.
|
||||
|
||||
// The area (floor) number is used in many places as well. Unlike the normal
|
||||
// area numbers, which start with Pioneer 2, the area numbers in this
|
||||
// structure start with Forest 1, and boss areas are treated as the first
|
||||
// area of the next section (so De Rol Le has Mines 1 drops, for example).
|
||||
// Final boss areas are treated as the last non-boss area (so Dark Falz
|
||||
// boxes are like Ruins 3 boxes). We refer to these adjusted area numbers as
|
||||
// (area - 1).
|
||||
|
||||
// This index probability table determines the types of non-rare weapons.
|
||||
// The indexes in this table correspond to the non-rare weapon types 01
|
||||
// through 0C (Saber through Wand).
|
||||
// This index probability table determines the types of non-rare weapons. The indexes in this table correspond to
|
||||
// the non-rare weapon types 01 through 0C (Saber through Wand).
|
||||
// V2/V3: -> parray<uint8_t, 0x0C>
|
||||
/* 00 */ U32T base_weapon_type_prob_table_offset;
|
||||
/* 00 */ U32T<BE> base_weapon_type_prob_table_offset;
|
||||
|
||||
// This table specifies the base subtype for each weapon type. Negative
|
||||
// values here mean that the weapon cannot be found in the first N areas (so
|
||||
// -2, for example, means that the weapon never appears in Forest 1 or 2 at
|
||||
// all). Nonnegative values here mean the subtype can be found in all areas,
|
||||
// and specify the base subtype (usually in the range [0, 4]). The subtype
|
||||
// of weapon that actually appears depends on this value and a value from
|
||||
// the following table.
|
||||
// This table specifies the base subtype for each weapon type. Negative values here mean that the weapon cannot
|
||||
// be found in the first N areas (so -2, for example, means that the weapon never appears in Forest 1 or 2 at
|
||||
// all). Nonnegative values here mean the subtype can be found in all areas, and specify the base subtype
|
||||
// (usually in the range [0, 4]). The subtype of weapon that actually appears depends on this value and a value
|
||||
// from the following table.
|
||||
// V2/V3: -> parray<int8_t, 0x0C>
|
||||
/* 04 */ U32T subtype_base_table_offset;
|
||||
/* 04 */ U32T<BE> subtype_base_table_offset;
|
||||
|
||||
// This table specifies how many areas each weapon subtype appears in. For
|
||||
// example, if Sword (subtype 02, which is index 1 in this table and the
|
||||
// table above) has a subtype base of -2 and a subtype area length of 4,
|
||||
// then Sword items can be found when area - 1 is 2, 3, 4, or 5 (Cave 1
|
||||
// through Mine 1), and Gigush (the next sword subtype) can be found in Mine
|
||||
// 1 through Ruins 3.
|
||||
// This table specifies how many areas each weapon subtype appears in. For example, if Sword (subtype 02, which
|
||||
// is index 1 in this table and the table above) has a subtype base of -2 and a subtype area length of 4, then
|
||||
// Sword items can be found when area - 1 is 2, 3, 4, or 5 (Cave 1 through Mine 1), and Gigush (the next sword
|
||||
// subtype) can be found in Mine 1 through Ruins 3.
|
||||
// V2/V3: -> parray<uint8_t, 0x0C>
|
||||
/* 08 */ U32T subtype_area_length_table_offset;
|
||||
/* 08 */ U32T<BE> subtype_area_length_table_offset;
|
||||
|
||||
// This index probability table specifies how likely each possible grind
|
||||
// value is. The table is indexed as [grind][subtype_area_index], where the
|
||||
// subtype area index is how many areas the player is beyond the first area
|
||||
// in which the subtype can first be found (clamped to [0, 3]). To continue
|
||||
// the example above, in Cave 3, subtype_area_index would be 2, since Swords
|
||||
// can first be found two areas earlier in Cave 1.
|
||||
// This index probability table specifies how likely each possible grind value is. The table is indexed as
|
||||
// [grind][subtype_area_index], where the subtype area index is how many areas the player is beyond the first
|
||||
// area in which the subtype can first be found (clamped to [0, 3]). To continue the example above, in Cave 3,
|
||||
// subtype_area_index would be 2, since Swords can first be found two areas earlier in Cave 1.
|
||||
// For example, this table could look like this:
|
||||
// [64 1E 19 14] // Chance of getting a grind +0
|
||||
// [00 1E 17 0F] // Chance of getting a grind +1
|
||||
@@ -114,76 +114,68 @@ public:
|
||||
// ...
|
||||
// C1 C2 C3 M1 // (Episode 1 area values from the example for reference)
|
||||
// V2/V3: -> parray<parray<uint8_t, 4>, 9>
|
||||
/* 0C */ U32T grind_prob_table_offset;
|
||||
/* 0C */ U32T<BE> grind_prob_table_offset;
|
||||
|
||||
// TODO: Figure out exactly how this table is used. Anchor: 80106D34
|
||||
// This index probability table specifies how likely each type of armor or shield is. The general formula is:
|
||||
// data1[2] = max((area_norm + (result from this table) + armor_or_shield_type_bias - 3), 0)
|
||||
// In this way, (armor_or_shield_type_bias + area_norm - 3) can be thought of as the "base" value for each area,
|
||||
// and this table specifies how likely the armor/shield is to be "upgraded" from that value.
|
||||
// V2/V3: -> parray<uint8_t, 0x05>
|
||||
/* 10 */ U32T armor_shield_type_index_prob_table_offset;
|
||||
/* 10 */ U32T<BE> armor_shield_type_index_prob_table_offset;
|
||||
|
||||
// This index probability table specifies how common each possible slot
|
||||
// count is for armor drops.
|
||||
// This index probability table specifies how common each possible slot count is for armor drops.
|
||||
// V2/V3: -> parray<uint8_t, 0x05>
|
||||
/* 14 */ U32T armor_slot_count_prob_table_offset;
|
||||
/* 14 */ U32T<BE> armor_slot_count_prob_table_offset;
|
||||
|
||||
// This array (indexed by enemy_type) specifies the range of meseta values
|
||||
// that each enemy can drop.
|
||||
// V2/V3: -> parray<Range<U16T>, 0x64>
|
||||
/* 18 */ U32T enemy_meseta_ranges_offset;
|
||||
// This array (indexed by rt_index) specifies the range of meseta values that each enemy can drop.
|
||||
// V2/V3: -> parray<Range<U16T>, NUM_RT_INDEXES_V3>
|
||||
/* 18 */ U32T<BE> enemy_rt_index_meseta_ranges_offset;
|
||||
|
||||
// Each byte in this table (indexed by enemy_type) represents the percent
|
||||
// chance that the enemy drops anything at all. (This check is done before
|
||||
// the rare drop check, so the chance of getting a rare item from an enemy
|
||||
// is essentially this probability multiplied by the rare drop rate.)
|
||||
// V2/V3: -> parray<uint8_t, 0x64>
|
||||
/* 1C */ U32T enemy_type_drop_probs_offset;
|
||||
// Each byte in this table (indexed by rt_index) represents the percent chance that the enemy drops anything at
|
||||
// all. (This check is done before the rare drop check, so the chance of getting a rare item from an enemy is
|
||||
// essentially this probability multiplied by the rare drop rate.)
|
||||
// V2/V3: -> parray<uint8_t, NUM_RT_INDEXES_V3>
|
||||
/* 1C */ U32T<BE> enemy_rt_index_drop_probs_offset;
|
||||
|
||||
// Each byte in this table (indexed by enemy_type) represents the class of
|
||||
// item that the enemy can drop. The values are:
|
||||
// 00 = weapon
|
||||
// 01 = armor
|
||||
// 02 = shield
|
||||
// 03 = unit
|
||||
// 04 = tool
|
||||
// 05 = meseta
|
||||
// Anything else = no item
|
||||
// V2/V3: -> parray<uint8_t, 0x64>
|
||||
/* 20 */ U32T enemy_item_classes_offset;
|
||||
// Each byte in this table (indexed by rt_index) represents the class of item that can drop. The values are:
|
||||
// 00 = weapon
|
||||
// 01 = armor
|
||||
// 02 = shield
|
||||
// 03 = unit
|
||||
// 04 = tool
|
||||
// 05 = meseta
|
||||
// Anything else = no item
|
||||
// V2/V3: -> parray<uint8_t, NUM_RT_INDEXES_V3>
|
||||
/* 20 */ U32T<BE> enemy_rt_index_item_classes_offset;
|
||||
|
||||
// This table (indexed by area - 1) specifies the ranges of meseta values
|
||||
// that can drop from boxes.
|
||||
// This table (indexed by area - 1) specifies the ranges of meseta values that can drop from boxes.
|
||||
// V2/V3: -> parray<Range<U16T>, 0x0A>
|
||||
/* 24 */ U32T box_meseta_ranges_offset;
|
||||
/* 24 */ U32T<BE> box_meseta_ranges_offset;
|
||||
|
||||
// This array specifies the chance that a rare weapon will have each
|
||||
// possible bonus value. This is indexed as [(bonus_value - 10 / 5)][spec],
|
||||
// so the first row refers the probability of getting a -10% bonus, the next
|
||||
// row is the chance of getting -5%, etc., all the way up to +100%. For
|
||||
// non-rare items, spec is determined randomly based on the following field;
|
||||
// for rare items, spec is always 5.
|
||||
// This array specifies the chance that a rare weapon will have each possible bonus value. This is indexed as
|
||||
// [(bonus_value - 10 / 5)][spec], so the first row refers the probability of getting a -10% bonus, the next row
|
||||
// is the chance of getting -5%, etc., all the way up to +100%. For non-rare items (or all items on v1/v2), spec
|
||||
// is determined randomly based on the following field; for rare items on v3+, spec is always 5.
|
||||
// V2: -> parray<parray<uint8_t, 5>, 0x17>
|
||||
// V3: -> parray<parray<U16T, 6>, 0x17>
|
||||
/* 28 */ U32T bonus_value_prob_table_offset;
|
||||
/* 28 */ U32T<BE> bonus_value_prob_table_offset;
|
||||
|
||||
// This array specifies the value of spec to be used in the above lookup for
|
||||
// non-rare items. This is NOT an index probability table; this is a direct
|
||||
// lookup with indexes [bonus_index][area - 1]. A value of 0xFF in any byte
|
||||
// of this array prevents any weapon from having a bonus in that slot.
|
||||
// For example, the array might look like this:
|
||||
// This array specifies the value of spec to be used in the above lookup for non-rare items. This is NOT an index
|
||||
// probability table; this is a direct lookup with indexes [bonus_index][area - 1]. A value of 0xFF in any byte
|
||||
// of this array prevents any weapon from having a bonus in that slot. An example table might look like this:
|
||||
// [00 00 00 01 01 01 01 02 02 02]
|
||||
// [FF FF FF 00 00 00 01 01 01 01]
|
||||
// [FF FF FF FF FF FF FF FF FF 00]
|
||||
// F1 F2 C1 C2 C3 M1 M2 R1 R2 R3 // (Episode 1 areas, for reference)
|
||||
// In this example, spec is 0, 1, or 2 in all cases where a weapon can have
|
||||
// a bonus. In Forest 1 and 2 and Cave 1, weapons may have at most one
|
||||
// bonus; in all other areas except Ruins 3, they can have at most two
|
||||
// bonuses, and in Ruins 3, they can have up to three bonuses.
|
||||
// In this example, spec is 0, 1, or 2 in all cases where a weapon can have a bonus. In Forest 1 and 2 and Cave
|
||||
// 1, weapons may have at most one bonus; in all other areas except Ruins 3, they can have at most two bonuses,
|
||||
// and in Ruins 3, they can have up to three bonuses.
|
||||
// V2/V3: // -> parray<parray<uint8_t, 10>, 3>
|
||||
/* 2C */ U32T nonrare_bonus_prob_spec_offset;
|
||||
/* 2C */ U32T<BE> nonrare_bonus_prob_spec_offset;
|
||||
|
||||
// This array specifies the chance that a weapon will have each bonus type.
|
||||
// The table is indexed as [bonus_type][area - 1] for non-rare items; for
|
||||
// rare items, a random value in the range [0, 9] is used instead of
|
||||
// (area - 1).
|
||||
// This array specifies the chance that a weapon will have each bonus type. The table is indexed as
|
||||
// [bonus_type][area - 1] for non-rare items; for rare items, a random value in the range [0, 9] is used instead
|
||||
// of (area - 1).
|
||||
// For example, the table might look like this:
|
||||
// [46 46 3F 3E 3E 3D 3C 3C 3A 3A] // Chance of getting no bonus
|
||||
// [14 14 0A 0A 09 02 02 04 05 05] // Chance of getting Native bonus
|
||||
@@ -193,56 +185,52 @@ public:
|
||||
// [00 00 00 00 00 01 01 01 01 01] // Chance of getting Hit bonus
|
||||
// F1 F2 C1 C2 C3 M1 M2 R1 R2 R3 // (Episode 1 areas, for reference)
|
||||
// V2/V3: -> parray<parray<uint8_t, 10>, 6>
|
||||
/* 30 */ U32T bonus_type_prob_table_offset;
|
||||
/* 30 */ U32T<BE> bonus_type_prob_table_offset;
|
||||
|
||||
// This array (indexed by area - 1) specifies a multiplier of used in
|
||||
// special ability determination. It seems this uses the star values from
|
||||
// ItemPMT, but not yet clear exactly in what way.
|
||||
// TODO: Figure out exactly what this does. Anchor: 80106FEC
|
||||
// This array (indexed by area - 1) specifies a parameter used in weapon special generation. If the sampled value
|
||||
// from this table is 0, no special is generated. Otherwise, a random floating-point value W in the range [0,
|
||||
// special_mult] is generated and truncated to an integer. If this value is greater than 3, no special is
|
||||
// generated; otherwise, a random special worth (W + 1) stars is chosen. It seems Sega only intended special_mult
|
||||
// to be in the range [0, 4], but values greater than 4 will work, and will simply increase the probability of
|
||||
// getting no special.
|
||||
// V2/V3: -> parray<uint8_t, 0x0A>
|
||||
/* 34 */ U32T special_mult_offset;
|
||||
/* 34 */ U32T<BE> special_mult_offset;
|
||||
|
||||
// This array (indexed by area - 1) specifies the probability that any
|
||||
// non-rare weapon will have a special ability.
|
||||
// This array (indexed by area - 1) specifies the probability that a non-rare weapon will have a special ability.
|
||||
// V2/V3: -> parray<uint8_t, 0x0A>
|
||||
/* 38 */ U32T special_percent_offset;
|
||||
/* 38 */ U32T<BE> special_percent_offset;
|
||||
|
||||
// This index probability table is indexed by [tool_class][area - 1]. The
|
||||
// tool class refers to an entry in ItemPMT, which links it to the actual
|
||||
// item code.
|
||||
// This index probability table is indexed by [tool_class][area - 1]. The tool class refers to an entry in
|
||||
// ItemPMT, which links it to the actual item code.
|
||||
// V2/V3: -> parray<parray<U16T, 0x0A>, 0x1C>
|
||||
/* 3C */ U32T tool_class_prob_table_offset;
|
||||
/* 3C */ U32T<BE> tool_class_prob_table_offset;
|
||||
|
||||
// This index probability table determines how likely each technique is to
|
||||
// appear. The table is indexed as [technique_num][area - 1].
|
||||
// This index probability table determines how likely each technique is to appear. The table is indexed as
|
||||
// [technique_num][area - 1].
|
||||
// V2/V3: -> parray<parray<uint8_t, 0x0A>, 0x13>
|
||||
/* 40 */ U32T technique_index_prob_table_offset;
|
||||
/* 40 */ U32T<BE> technique_index_prob_table_offset;
|
||||
|
||||
// This table specifies the ranges for technique disk levels. The table is
|
||||
// indexed as [technique_num][area - 1]. If either min or max in the range
|
||||
// is 0xFF, or if max < min, technique disks are not dropped for that
|
||||
// technique and area pair.
|
||||
// This table specifies the ranges for technique disk levels. The table is indexed as [technique_num][area - 1].
|
||||
// If either min or max in the range is 0xFF, or if max < min, technique disks are not dropped for that technique
|
||||
// and area pair.
|
||||
// V2/V3: -> parray<parray<Range<uint8_t>, 0x0A>, 0x13>
|
||||
/* 44 */ U32T technique_level_ranges_offset;
|
||||
/* 44 */ U32T<BE> technique_level_ranges_offset;
|
||||
|
||||
// See comments on armor_shield_type_index_prob_table_offset for how this is used.
|
||||
/* 48 */ uint8_t armor_or_shield_type_bias;
|
||||
/* 49 */ parray<uint8_t, 3> unused1;
|
||||
|
||||
// These values specify the maximum number of stars any generated unit can
|
||||
// have in each area. The values here are not inclusive; that is, a value
|
||||
// of 7 means that only units with 1-6 stars can drop in that area. The
|
||||
// game uniformly chooses a random number of stars in the acceptable
|
||||
// range, then uniformly chooses a random unit with that many stars.
|
||||
// These values specify the maximum number of stars any generated unit can have in each area. The values here are
|
||||
// not inclusive; that is, a value of 7 means that only units with 1-6 stars can drop in that area. The game
|
||||
// uniformly chooses a random number of stars in the acceptable range, then uniformly chooses a random unit with
|
||||
// that many stars.
|
||||
// V2/V3: -> parray<uint8_t, 0x0A>
|
||||
/* 4C */ U32T unit_max_stars_offset;
|
||||
/* 4C */ U32T<BE> unit_max_stars_offset;
|
||||
|
||||
// This index probability table determines which type of items drop from
|
||||
// boxes. The table is indexed as [item_class][area - 1], with item_class
|
||||
// as the result value (that is, in the example below, the game looks at a
|
||||
// single column and sums the values going down, then the chosen item
|
||||
// class is one of the row indexes based on the weight values in the
|
||||
// column.) The resulting item_class value has the same meaning as in
|
||||
// enemy_item_classes above.
|
||||
// This index probability table determines which type of items drop from boxes. The table is indexed as
|
||||
// [item_class][area - 1], with item_class as the result value (that is, in the example below, the game looks at
|
||||
// a single column and sums the values going down, then the chosen item class is one of the row indexes based on
|
||||
// the weight values in the column.) The resulting value has the same meaning as in enemy_rt_index_item_classes.
|
||||
// For example, this array might look like the following:
|
||||
// [07 07 08 08 06 07 08 09 09 0A] // Chances per area of a weapon drop
|
||||
// [02 02 02 02 03 02 02 02 03 03] // Chances per area of an armor drop
|
||||
@@ -253,24 +241,31 @@ public:
|
||||
// [16 16 11 11 11 11 11 0F 0C 0B] // Chances per area of an empty box
|
||||
// F1 F2 C1 C2 C3 M1 M2 R1 R2 R3 // (Episode 1 areas, for reference)
|
||||
// V2/V3: -> parray<parray<uint8_t, 10>, 7>
|
||||
/* 50 */ U32T box_item_class_prob_table_offset;
|
||||
/* 50 */ U32T<BE> box_item_class_prob_table_offset;
|
||||
|
||||
// There are several unused fields here.
|
||||
} __packed__;
|
||||
} __packed_ws_be__(OffsetsT, 0x54);
|
||||
using Offsets = OffsetsT<false>;
|
||||
using OffsetsBE = OffsetsT<true>;
|
||||
check_struct_size(Offsets, 0x54);
|
||||
check_struct_size(OffsetsBE, 0x54);
|
||||
};
|
||||
|
||||
std::shared_ptr<const Table> get_table(Episode episode, GameMode mode, uint8_t difficulty, uint8_t secid) const;
|
||||
JSON json() const;
|
||||
bool operator==(const CommonItemSet& other) const = default;
|
||||
bool operator!=(const CommonItemSet& other) const = default;
|
||||
|
||||
std::shared_ptr<const Table> get_table(
|
||||
Episode episode, GameMode mode, Difficulty difficulty, uint8_t section_id) const;
|
||||
std::shared_ptr<const Table> get_prev_table(
|
||||
Episode episode, GameMode mode, Difficulty difficulty, uint8_t section_id) const;
|
||||
|
||||
phosg::JSON json() const;
|
||||
void print(FILE* stream) const;
|
||||
void print_diff(FILE* stream, const CommonItemSet& other) const;
|
||||
|
||||
protected:
|
||||
CommonItemSet() = default;
|
||||
|
||||
static uint16_t key_for_table(Episode episode, GameMode mode, uint8_t difficulty, uint8_t secid);
|
||||
static uint16_t key_for_table(Episode episode, GameMode mode, Difficulty difficulty, uint8_t section_id);
|
||||
static std::string json_key_for_table(Episode episode, GameMode mode, Difficulty difficulty, uint8_t section_id);
|
||||
|
||||
std::unordered_map<uint16_t, std::shared_ptr<Table>> tables;
|
||||
};
|
||||
@@ -287,11 +282,11 @@ public:
|
||||
|
||||
class JSONCommonItemSet : public CommonItemSet {
|
||||
public:
|
||||
explicit JSONCommonItemSet(const JSON& json);
|
||||
explicit JSONCommonItemSet(const phosg::JSON& json);
|
||||
};
|
||||
|
||||
// Note: There are clearly better ways of doing this, but this implementation
|
||||
// closely follows what the original code in the client does.
|
||||
// Note: There are clearly better ways of doing this, but this implementation closely follows what the original code in
|
||||
// the client does.
|
||||
template <typename ItemT, size_t MaxCount>
|
||||
struct ProbabilityTable {
|
||||
ItemT items[MaxCount];
|
||||
@@ -313,22 +308,22 @@ struct ProbabilityTable {
|
||||
return this->items[--this->count];
|
||||
}
|
||||
|
||||
void shuffle(std::shared_ptr<PSOLFGEncryption> opt_rand_crypt) {
|
||||
void shuffle(std::shared_ptr<RandomGenerator> rand_crypt) {
|
||||
for (size_t z = 1; z < this->count; z++) {
|
||||
size_t other_z = random_from_optional_crypt(opt_rand_crypt) % (z + 1);
|
||||
size_t other_z = rand_crypt->next() % (z + 1);
|
||||
ItemT t = this->items[z];
|
||||
this->items[z] = this->items[other_z];
|
||||
this->items[other_z] = t;
|
||||
}
|
||||
}
|
||||
|
||||
ItemT sample(std::shared_ptr<PSOLFGEncryption> opt_rand_crypt) const {
|
||||
ItemT sample(std::shared_ptr<RandomGenerator> rand_crypt) const {
|
||||
if (this->count == 0) {
|
||||
throw std::runtime_error("sample from empty probability table");
|
||||
} else if (this->count == 1) {
|
||||
return this->items[0];
|
||||
} else {
|
||||
return this->items[random_from_optional_crypt(opt_rand_crypt) % this->count];
|
||||
return this->items[rand_crypt->next() % this->count];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -339,8 +334,7 @@ public:
|
||||
struct WeightTableEntry {
|
||||
ValueT value;
|
||||
WeightT weight;
|
||||
} __packed__;
|
||||
|
||||
} __attribute__((packed));
|
||||
using WeightTableEntry8 = WeightTableEntry<uint8_t>;
|
||||
using WeightTableEntry32 = WeightTableEntry<be_uint32_t>;
|
||||
check_struct_size(WeightTableEntry8, 2);
|
||||
@@ -348,7 +342,7 @@ public:
|
||||
|
||||
protected:
|
||||
std::shared_ptr<const std::string> data;
|
||||
StringReader r;
|
||||
phosg::StringReader r;
|
||||
|
||||
struct TableSpec {
|
||||
be_uint32_t offset;
|
||||
@@ -359,11 +353,9 @@ protected:
|
||||
RELFileSet(std::shared_ptr<const std::string> data);
|
||||
|
||||
template <typename T>
|
||||
std::pair<const T*, size_t> get_table(
|
||||
const TableSpec& spec, size_t index) const {
|
||||
std::pair<const T*, size_t> get_table(const TableSpec& spec, size_t index) const {
|
||||
const T* entries = &r.pget<T>(
|
||||
spec.offset + index * spec.entries_per_table * sizeof(T),
|
||||
spec.entries_per_table * sizeof(T));
|
||||
spec.offset + index * spec.entries_per_table * sizeof(T), spec.entries_per_table * sizeof(T));
|
||||
return std::make_pair(entries, spec.entries_per_table);
|
||||
}
|
||||
};
|
||||
@@ -463,7 +455,7 @@ private:
|
||||
int8_t get_luck(uint32_t start_offset, uint8_t delta_index) const;
|
||||
|
||||
std::shared_ptr<const std::string> data;
|
||||
StringReader r;
|
||||
phosg::StringReader r;
|
||||
|
||||
struct DeltaProbabilityEntry {
|
||||
uint8_t delta_index;
|
||||
@@ -476,17 +468,14 @@ private:
|
||||
} __packed_ws__(LuckTableEntry, 2);
|
||||
|
||||
struct Offsets {
|
||||
// Each section ID's favored weapon class has different probabilities than
|
||||
// those used for all other weapons. The tables are labeled with (D) for the
|
||||
// default values and (F) for the favored-class values.
|
||||
// Each section ID's favored weapon class has different probabilities than those used for all other weapons. The
|
||||
// tables are labeled with (D) for the default values and (F) for the favored-class values.
|
||||
|
||||
// Note that the favored bonuses for Redria are all zero; these values are
|
||||
// unused because Redria does not have a favored weapon type. Curiously,
|
||||
// Yellowboze also does not have a favored weapon type, but the values for
|
||||
// Note that the favored bonuses for Redria are all zero; these values are unused because Redria does not have a
|
||||
// favored weapon type. Curiously, Yellowboze also does not have a favored weapon type, but the values for
|
||||
// Yellowboze are not all zero.
|
||||
|
||||
// This table specifies how likely a special is to be upgraded or
|
||||
// downgraded by one level.
|
||||
// This table specifies how likely a special is to be upgraded or downgraded by one level.
|
||||
// In PSO V3, the special upgrade table is:
|
||||
// Viridia => (D) +1=10%, 0=60%, -1=30%
|
||||
// Viridia => (F) +1=25%, 0=50%, -1=25%
|
||||
@@ -510,9 +499,8 @@ private:
|
||||
// Whitill => (F) +1=25%, 0=50%, -1=25%
|
||||
be_uint32_t special_upgrade_prob_table_offset; // [{c, o -> (DeltaProbabilityEntry)[10][c]})
|
||||
|
||||
// This table specifies how likely a weapon's grind is to be upgraded or
|
||||
// downgraded, and by how much. The final grind value is clamped to the
|
||||
// range between 0 and the weapon's maximum grind from ItemPMT, inclusive.
|
||||
// This table specifies how likely a weapon's grind is to be upgraded or downgraded, and by how much. The final
|
||||
// grind value is clamped to the range between 0 and the weapon's maximum grind from ItemPMT, inclusive.
|
||||
// In PSO V3, the grind delta table is:
|
||||
// Viridia => (D) +3=3%, +2=7%, +1=13%, 0=60%, -1=10%, -2=7%, -3=0%
|
||||
// Viridia => (F) +3=5%, +2=13%, +1=25%, 0=50%, -1=7%, -2=0%, -3=0%
|
||||
@@ -536,9 +524,8 @@ private:
|
||||
// Whitill => (F) +3=5%, +2=13%, +1=25%, 0=50%, -1=7%, -2=0%, -3=0%
|
||||
be_uint32_t grind_delta_prob_table_offset; // [{c, o -> (DeltaProbabilityEntry)[10][c]})
|
||||
|
||||
// This table specifies how likely a weapon's bonuses are to be upgraded
|
||||
// or downgraded, and by how much. The final bonuses are capped above at
|
||||
// 100, but there is no lower limit (so negative results are possible).
|
||||
// This table specifies how likely a weapon's bonuses are to be upgraded or downgraded, and by how much. The final
|
||||
// bonuses are capped above at 100, but there is no lower limit (so negative results are possible).
|
||||
// In PSO V3, the bonus delta table is:
|
||||
// Viridia => (D) +10=5%, +5=15%, 0=60%, -5=15%, -10=5%
|
||||
// Viridia => (F) +10=8%, +5=20%, 0=60%, -5=10%, -10=2%
|
||||
@@ -562,11 +549,10 @@ private:
|
||||
// Whitill => (F) +10=8%, +5=20%, 0=60%, -5=10%, -10=2%
|
||||
be_uint32_t bonus_delta_prob_table_offset; // [{c, o -> (DeltaProbabilityEntry)[10][c]})
|
||||
|
||||
// There is a secondary computation done during weapon adjustment that
|
||||
// appears to determine how "good" the resulting weapon is compared to its
|
||||
// original state. If the result of this computation is positive, the game
|
||||
// plays a jingle when the tekker result is accepted. These tables describe
|
||||
// how much each delta affects this value, which we call luck.
|
||||
// There is a secondary computation done during weapon adjustment that appears to determine how "good" the
|
||||
// resulting weapon is compared to its original state. If the result of this computation is positive, the game
|
||||
// plays a jingle when the tekker result is accepted. These tables describe how much each delta affects this value,
|
||||
// which we call luck.
|
||||
|
||||
// In PSO V3, the special upgrade luck table is:
|
||||
// +1 => +20, 0 => 0, -1 => -20
|
||||
|
||||
+107
-159
@@ -14,7 +14,7 @@
|
||||
using namespace std;
|
||||
|
||||
template <>
|
||||
const char* name_for_enum<CompressPhase>(CompressPhase v) {
|
||||
const char* phosg::name_for_enum<CompressPhase>(CompressPhase v) {
|
||||
switch (v) {
|
||||
case CompressPhase::INDEX:
|
||||
return "INDEX";
|
||||
@@ -63,14 +63,11 @@ struct WindowIndex {
|
||||
return match_iter - match_offset;
|
||||
};
|
||||
|
||||
// The data structure we want is a binary-searchable set of all strings
|
||||
// starting at all possible offsets within the sliding window, and we need
|
||||
// to be able to search lexicographically but insert and delete by offset.
|
||||
// A std::map<std::string, size_t> would accomplish this, but would be
|
||||
// horrendously inefficient: we'd have to copy strings far too much. We can
|
||||
// solve this by instead storing the offset of each string as keys in a set
|
||||
// and using a custom comparator to treat them as references to binary
|
||||
// strings within the data.
|
||||
// The data structure we want is a binary-searchable set of all strings starting at all possible offsets within the
|
||||
// sliding window, and we need to be able to search lexicographically but insert and delete by offset. A
|
||||
// std::map<std::string, size_t> would accomplish this, but would be horrendously inefficient: we'd have to copy
|
||||
// strings far too much. We can solve this by instead storing the offset of each string as keys in a set and using a
|
||||
// custom comparator to treat them as references to binary strings within the data.
|
||||
bool set_comparator(size_t a, size_t b) const {
|
||||
size_t max_length = min<size_t>(MaxMatchLength, this->size - max<size_t>(a, b));
|
||||
size_t end_a = a + max_length;
|
||||
@@ -87,11 +84,9 @@ struct WindowIndex {
|
||||
};
|
||||
|
||||
pair<size_t, size_t> get_best_match() const {
|
||||
// Find the best match from the index. It's unlikely that we'll get an
|
||||
// exact match, so check the entry before the upper_bound result too.
|
||||
// Note: We use upper_bound rather than lower_bound because in PRS, a
|
||||
// backreference can be encoded with fewer bits if it's close to the
|
||||
// decompression offset, and this makes us pick the latest match by
|
||||
// Find the best match from the index. It's unlikely that we'll get an exact match, so check the entry before the
|
||||
// upper_bound result too. Note: We use upper_bound rather than lower_bound because in PRS, a backreference can be
|
||||
// encoded with fewer bits if it's close to the decompression offset, and this makes us pick the latest match by
|
||||
// default.
|
||||
size_t match_offset = 0;
|
||||
size_t match_size = 0;
|
||||
@@ -118,14 +113,12 @@ struct WindowIndex {
|
||||
};
|
||||
|
||||
struct LZSSInterleavedWriter {
|
||||
StringWriter w;
|
||||
phosg::StringWriter w;
|
||||
size_t buf_offset;
|
||||
uint8_t next_control_bit;
|
||||
uint8_t buf[0x19];
|
||||
|
||||
LZSSInterleavedWriter()
|
||||
: buf_offset(1),
|
||||
next_control_bit(1) {
|
||||
LZSSInterleavedWriter() : buf_offset(1), next_control_bit(1) {
|
||||
this->buf[0] = 0;
|
||||
}
|
||||
|
||||
@@ -166,9 +159,7 @@ struct LZSSInterleavedWriter {
|
||||
|
||||
class ControlStreamReader {
|
||||
public:
|
||||
ControlStreamReader(StringReader& r)
|
||||
: r(r),
|
||||
bits(0x0000) {}
|
||||
ControlStreamReader(phosg::StringReader& r) : r(r), bits(0x0000) {}
|
||||
|
||||
bool read() {
|
||||
if (!(this->bits & 0x0100)) {
|
||||
@@ -188,7 +179,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
StringReader& r;
|
||||
phosg::StringReader& r;
|
||||
uint16_t bits;
|
||||
};
|
||||
|
||||
@@ -285,8 +276,7 @@ string prs_compress_optimal(const void* in_data_v, size_t in_size, ProgressCallb
|
||||
long_window_thread.join();
|
||||
extended_window_thread.join();
|
||||
|
||||
// For each node, populate the literal value, and the best ways to get to the
|
||||
// following nodes
|
||||
// For each node, populate the literal value, and the best ways to get to the following nodes
|
||||
for (size_t z = 0; z < in_size; z++) {
|
||||
if ((z & 0xFFF) == 0 && progress_fn) {
|
||||
progress_fn(CompressPhase::CONSTRUCT_PATHS, z, in_size, 0);
|
||||
@@ -441,9 +431,8 @@ string prs_compress_optimal(const string& data, ProgressCallback progress_fn) {
|
||||
string prs_compress_pessimal(const void* vdata, size_t size) {
|
||||
const uint8_t* in_data = reinterpret_cast<const uint8_t*>(vdata);
|
||||
|
||||
// The worst possible encoding we can do is a literal byte when no byte with
|
||||
// the same value is within the window, or an extended copy if there is a byte
|
||||
// with the same value in the window.
|
||||
// The worst possible encoding we can do is a literal byte when no byte with the same value is within the window, or
|
||||
// an extended copy if there is a byte with the same value in the window.
|
||||
WindowIndex<0x1FFF, 1> window(in_data, size);
|
||||
LZSSInterleavedWriter w;
|
||||
for (size_t z = 0; z < size; z++) {
|
||||
@@ -493,7 +482,7 @@ void PRSCompressor::add(const void* data, size_t size) {
|
||||
throw logic_error("compressor is closed");
|
||||
}
|
||||
|
||||
StringReader r(data, size);
|
||||
phosg::StringReader r(data, size);
|
||||
while (!r.eof()) {
|
||||
this->add_byte(r.get_u8());
|
||||
}
|
||||
@@ -539,9 +528,8 @@ void PRSCompressor::advance() {
|
||||
match_size++;
|
||||
}
|
||||
|
||||
// If there are multiple matches of the longest length, use the latest one,
|
||||
// since it's more likely that it can be expressed as a short copy instead
|
||||
// of a long copy.
|
||||
// If there are multiple matches of the longest length, use the latest one, since it's more likely that it can be
|
||||
// expressed as a short copy instead of a long copy.
|
||||
if (match_size >= (best_match_size + best_match_literals)) {
|
||||
best_match_offset = match_offset;
|
||||
best_match_size = match_size;
|
||||
@@ -558,15 +546,13 @@ void PRSCompressor::advance() {
|
||||
this->advance_literal();
|
||||
}
|
||||
|
||||
// If there is a suitable match, write a backreference; otherwise, write a
|
||||
// literal. The backreference should be encoded:
|
||||
// If there is a match, write a backreference; otherwise, write a literal. The backreference should be encoded:
|
||||
// - As a short copy if offset in [-0x100, -1] and size in [2, 5]
|
||||
// - As a long copy if offset in [-0x1FFF, -1] and size in [3, 9]
|
||||
// - As an extended copy if offset in [-0x1FFF, -1] and size in [10, 0x100]
|
||||
// Technically an extended copy can be used for sizes 1-9 as well, but if
|
||||
// size is 1 or 2, writing literals is better (since it uses fewer data
|
||||
// bytes and control bits), and a long copy can cover sizes 3-9 (and also
|
||||
// uses fewer data bytes and control bits).
|
||||
// Technically an extended copy can be used for sizes 1-9 as well, but if size is 1 or 2, writing literals is better
|
||||
// (since it uses fewer data bytes and control bits), and a long copy can cover sizes 3-9 (and also uses fewer data
|
||||
// bytes and control bits).
|
||||
ssize_t backreference_offset = best_match_offset - this->reverse_log.end_offset();
|
||||
if (best_match_size < 2) {
|
||||
// The match is too small; a literal would use fewer bits
|
||||
@@ -576,8 +562,8 @@ void PRSCompressor::advance() {
|
||||
this->advance_short_copy(backreference_offset, best_match_size);
|
||||
|
||||
} else if (best_match_size < 3) {
|
||||
// We can't use a long copy for size 2, and it's not worth it to use an
|
||||
// extended copy for this either (as noted above), so write a literal
|
||||
// We can't use a long copy for size 2, and it's not worth it to use an extended copy for this either (as noted
|
||||
// above), so write a literal
|
||||
this->advance_literal();
|
||||
|
||||
} else if ((backreference_offset >= -0x1FFF) && (best_match_size <= 9)) {
|
||||
@@ -655,14 +641,12 @@ string& PRSCompressor::close() {
|
||||
|
||||
void PRSCompressor::write_control(bool z) {
|
||||
if (this->pending_control_bits & 0x0100) {
|
||||
this->output.pput_u8(
|
||||
this->control_byte_offset, this->pending_control_bits & 0xFF);
|
||||
this->output.pput_u8(this->control_byte_offset, this->pending_control_bits & 0xFF);
|
||||
this->control_byte_offset = this->output.size();
|
||||
this->output.put_u8(0);
|
||||
this->pending_control_bits = z ? 0x8080 : 0x8000;
|
||||
} else {
|
||||
this->pending_control_bits =
|
||||
(this->pending_control_bits >> 1) | (z ? 0x8080 : 0x8000);
|
||||
this->pending_control_bits = (this->pending_control_bits >> 1) | (z ? 0x8080 : 0x8000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +655,7 @@ void PRSCompressor::flush_control() {
|
||||
while (!(this->pending_control_bits & 0x0100)) {
|
||||
this->pending_control_bits >>= 1;
|
||||
}
|
||||
this->output.pput_u8(
|
||||
this->control_byte_offset, this->pending_control_bits & 0xFF);
|
||||
this->output.pput_u8(this->control_byte_offset, this->pending_control_bits & 0xFF);
|
||||
} else {
|
||||
if (this->control_byte_offset != this->output.size() - 1) {
|
||||
throw logic_error("data written without control bits");
|
||||
@@ -681,25 +664,17 @@ void PRSCompressor::flush_control() {
|
||||
}
|
||||
}
|
||||
|
||||
string prs_compress(
|
||||
const void* vdata,
|
||||
size_t size,
|
||||
ssize_t compression_level,
|
||||
ProgressCallback progress_fn) {
|
||||
string prs_compress(const void* vdata, size_t size, ssize_t compression_level, ProgressCallback progress_fn) {
|
||||
PRSCompressor prs(compression_level, progress_fn);
|
||||
prs.add(vdata, size);
|
||||
return std::move(prs.close());
|
||||
}
|
||||
|
||||
string prs_compress(
|
||||
const string& data,
|
||||
ssize_t compression_level,
|
||||
ProgressCallback progress_fn) {
|
||||
string prs_compress(const string& data, ssize_t compression_level, ProgressCallback progress_fn) {
|
||||
return prs_compress(data.data(), data.size(), compression_level, progress_fn);
|
||||
}
|
||||
|
||||
string prs_compress_indexed(
|
||||
const void* in_data_v, size_t in_size, ProgressCallback progress_fn) {
|
||||
string prs_compress_indexed(const void* in_data_v, size_t in_size, ProgressCallback progress_fn) {
|
||||
const uint8_t* in_data = reinterpret_cast<const uint8_t*>(in_data_v);
|
||||
|
||||
LZSSInterleavedWriter w;
|
||||
@@ -718,14 +693,11 @@ string prs_compress_indexed(
|
||||
auto m_long = w_long.get_best_match();
|
||||
auto m_extended = w_extended.get_best_match();
|
||||
|
||||
// Write the match that achieves the best ratio of output bytes to
|
||||
// compressed bits used. To do this without floating-point math, we multiply
|
||||
// the output byte count for each type of command by 468 / (command_bits),
|
||||
// since 468 is the least common multiple of the number of bits for each
|
||||
// command type. The command type with the highest score is the one we'll
|
||||
// use, breaking ties by choosing the shorter command type. Note that the
|
||||
// size of any copy type can be zero if no match was found; if no matches
|
||||
// were found at all, then we can always write a literal.
|
||||
// Write the match that achieves the best ratio of output bytes to compressed bits used. To do this without
|
||||
// floating-point math, we multiply the output byte count for each type of command by 468 / (command_bits), since
|
||||
// 468 is the least common multiple of the number of bits for each command type. The command type with the highest
|
||||
// score is the one we'll use, breaking ties by choosing the shorter command type. Note that the size of any copy
|
||||
// type can be zero if no match was found; if no matches were found at all, then we can always write a literal.
|
||||
size_t score_literal = 52;
|
||||
size_t score_short = m_short.second * 39;
|
||||
size_t score_long = m_long.second * 26;
|
||||
@@ -838,44 +810,33 @@ string prs_compress_indexed(const string& data, ProgressCallback progress_fn) {
|
||||
|
||||
PRSDecompressResult prs_decompress_with_meta(
|
||||
const void* data, size_t size, size_t max_output_size, bool allow_unterminated) {
|
||||
// PRS is an LZ77-based compression algorithm. Compressed data is split into
|
||||
// two streams: a control stream and a data stream. The control stream is read
|
||||
// one bit at a time, and the data stream is read one byte at a time. The
|
||||
// streams are interleaved such that the decompressor never has to move
|
||||
// backward in the input stream - when the decompressor needs a control bit
|
||||
// and there are no unused bits from the previous byte of the control stream,
|
||||
// it reads a byte from the input and treats it as the next 8 control bits.
|
||||
// PRS is an LZ77-based compression algorithm. Compressed data is split into two streams: a control stream and a data
|
||||
// stream. The control stream is read one bit at a time, and the data stream is read one byte at a time. The streams
|
||||
// are interleaved such that the decompressor never has to move backward in the input stream - when the decompressor
|
||||
// needs a control bit and there are no unused bits from the previous byte of the control stream, it reads a byte
|
||||
// from the input and treats it as the next 8 control bits.
|
||||
|
||||
// There are 3 distinct commands in PRS, labeled here with their control bits:
|
||||
// 1 - Literal byte. The decompressor copies one byte from the input data
|
||||
// stream to the output.
|
||||
// 00 - Short backreference. The decompressor reads two control bits and adds
|
||||
// 2 to this value to determine the number of bytes to copy, then reads
|
||||
// one byte from the data stream to determine how far back in the output
|
||||
// to copy from. This byte is treated as an 8-bit negative number - so
|
||||
// 0xF7, for example, means to start copying data from 9 bytes before the
|
||||
// end of the output. The range must start before the end of the output,
|
||||
// but the end of the range may be beyond the end of the output. In this
|
||||
// case, the bytes between the beginning of the range and original end of
|
||||
// the output are simply repeated.
|
||||
// 01 - Long backreference. The decompressor reads two bytes from the data and
|
||||
// byteswaps the resulting 16-bit value (that is, the low byte is read
|
||||
// first). The start offset (again, as a negative number) is the top 13
|
||||
// bits of this value; the size is the low 3 bits of this value, plus 2.
|
||||
// If the size bits are all zero, an additional byte is read from the
|
||||
// data stream and 1 is added to it to determine the backreference size
|
||||
// (we call this an extended backreference). Therefore, the maximum
|
||||
// backreference size is 256 bytes.
|
||||
// Decompression ends when either there are no more input bytes to read, or
|
||||
// when a long backreference is read with all zeroes in its offset field. The
|
||||
// original implementation stops decompression successfully when any attempt
|
||||
// to read from the input encounters the end of the stream, but newserv's
|
||||
// implementation only allows this at the end of an opcode - if end-of-stream
|
||||
// is encountered partway through an opcode, we throw instead, because it's
|
||||
// likely the input has been truncated or is malformed in some way.
|
||||
// 1 - Literal byte. The decompressor copies one byte from the input data stream to the output.
|
||||
// 00 - Short backreference. The decompressor reads two control bits and adds 2 to this value to determine the number
|
||||
// of bytes to copy, then reads one byte from the data stream to determine how far back in the output to copy
|
||||
// from. This byte is treated as an 8-bit negative number - so 0xF7, for example, means to start copying data
|
||||
// from 9 bytes before the end of the output. The range must start before the end of the output, but the end of
|
||||
// the range may be beyond the end of the output. In this case, the bytes between the beginning of the range and
|
||||
// original end of the output are simply repeated.
|
||||
// 01 - Long backreference. The decompressor reads two bytes from the data and byteswaps the resulting 16-bit value
|
||||
// (that is, the low byte is read first). The start offset (again, as a negative number) is the top 13 bits of
|
||||
// this value; the size is the low 3 bits of this value, plus 2. If the size bits are all zero, an additional
|
||||
// byte is read from the data stream and 1 is added to it to determine the backreference size (we call this an
|
||||
// extended backreference). Therefore, the maximum backreference size is 256 bytes.
|
||||
// Decompression ends when either there are no more input bytes to read, or when a long backreference is read with
|
||||
// all zeroes in its offset field. The original implementation stops decompression successfully when any attempt to
|
||||
// read from the input encounters the end of the stream, but newserv's implementation only allows this at the end of
|
||||
// an opcode - if end-of-stream is encountered partway through an opcode, we throw instead, because it's likely the
|
||||
// input has been truncated or is malformed in some way.
|
||||
|
||||
StringWriter w;
|
||||
StringReader r(data, size);
|
||||
phosg::StringWriter w;
|
||||
phosg::StringReader r(data, size);
|
||||
ControlStreamReader cr(r);
|
||||
|
||||
while (!r.eof()) {
|
||||
@@ -894,10 +855,9 @@ PRSDecompressResult prs_decompress_with_meta(
|
||||
ssize_t offset;
|
||||
size_t count;
|
||||
|
||||
// Control 01 = long backreference
|
||||
if (cr.read()) {
|
||||
// The bits stored in the data stream are AAAAABBBCCCCCCCC, which we
|
||||
// rearrange into offset = CCCCCCCCAAAAA and size = BBB.
|
||||
// Control 01 = long backreference
|
||||
// The bits from the data stream are AAAAABBBCCCCCCCC, which we rearrange as offset=CCCCCCCCAAAAA and size=BBB.
|
||||
uint16_t a = r.get_u8();
|
||||
a |= (r.get_u8() << 8);
|
||||
offset = (a >> 3) | (~0x1FFF);
|
||||
@@ -905,24 +865,21 @@ PRSDecompressResult prs_decompress_with_meta(
|
||||
if (offset == ~0x1FFF) {
|
||||
break;
|
||||
}
|
||||
// If the size field is zero, it's an extended backreference (size comes
|
||||
// from another byte in the data stream)
|
||||
// If the size field is zero, it's an extended backreference (size comes from another byte in the data stream)
|
||||
count = (a & 7) ? ((a & 7) + 2) : (r.get_u8() + 1);
|
||||
|
||||
// Control 00 = short backreference
|
||||
} else {
|
||||
// Count comes from 2 bits in the control stream instead of from the
|
||||
// data stream (and 2 is added). Importantly, the control stream bits
|
||||
// are read first - this may involve reading another control stream
|
||||
// byte, which happens before the offset is read from the data stream.
|
||||
// Control 00 = short backreference
|
||||
// Count comes from 2 bits in the control stream instead of from the data stream (and 2 is added). Importantly,
|
||||
// the control stream bits are read first - this may involve reading another control stream byte, which happens
|
||||
// before the offset is read from the data stream.
|
||||
count = cr.read() << 1;
|
||||
count = (count | cr.read()) + 2;
|
||||
offset = r.get_u8() | (~0xFF);
|
||||
}
|
||||
|
||||
// Copy bytes from the referenced location in the output. Importantly,
|
||||
// copy only one byte at a time, in order to support ranges that cover the
|
||||
// current end of the output.
|
||||
// Copy bytes from the referenced location in the output. Importantly, copy only one byte at a time, in order to
|
||||
// support ranges that cover the current end of the output.
|
||||
size_t read_offset = w.size() + offset;
|
||||
if (read_offset >= w.size()) {
|
||||
throw runtime_error("backreference offset beyond beginning of output");
|
||||
@@ -959,7 +916,7 @@ string prs_decompress(const string& data, size_t max_output_size, bool allow_unt
|
||||
|
||||
size_t prs_decompress_size(const void* data, size_t size, size_t max_output_size, bool allow_unterminated) {
|
||||
size_t ret = 0;
|
||||
StringReader r(data, size);
|
||||
phosg::StringReader r(data, size);
|
||||
ControlStreamReader cr(r);
|
||||
|
||||
while (!r.eof()) {
|
||||
@@ -1011,14 +968,14 @@ size_t prs_decompress_size(const string& data, size_t max_output_size, bool allo
|
||||
|
||||
void prs_disassemble(FILE* stream, const void* data, size_t size) {
|
||||
size_t output_bytes = 0;
|
||||
StringReader r(data, size);
|
||||
phosg::StringReader r(data, size);
|
||||
ControlStreamReader cr(r);
|
||||
|
||||
while (!r.eof()) {
|
||||
uint8_t buffered_bits = cr.buffered_bits();
|
||||
if (cr.read()) {
|
||||
uint8_t literal_value = r.get_u8();
|
||||
fprintf(stream, "[%zX] %hhu> 1 %02hhX literal %02hhX\n",
|
||||
phosg::fwrite_fmt(stream, "[{:X}] {}> 1 {:02X} literal {:02X}\n",
|
||||
output_bytes, buffered_bits, literal_value, literal_value);
|
||||
output_bytes++;
|
||||
|
||||
@@ -1030,19 +987,19 @@ void prs_disassemble(FILE* stream, const void* data, size_t size) {
|
||||
uint16_t a = (a_high << 8) | a_low;
|
||||
ssize_t offset = (a >> 3) | (~0x1FFF);
|
||||
if (offset == ~0x1FFF) {
|
||||
fprintf(stream, "[%zX] end\n", output_bytes);
|
||||
phosg::fwrite_fmt(stream, "[{:X}] end\n", output_bytes);
|
||||
break;
|
||||
}
|
||||
if (a & 7) {
|
||||
count = (a & 7) + 2;
|
||||
read_offset = output_bytes + offset;
|
||||
fprintf(stream, "[%zX] %hhu> 01 %02hhX %02hhX long copy from %zd (offset=%zX) size=%zX\n",
|
||||
phosg::fwrite_fmt(stream, "[{:X}] {}> 01 {:02X} {:02X} long copy from {} (offset={:X}) size={:X}\n",
|
||||
output_bytes, buffered_bits, a_low, a_high, offset, read_offset, count);
|
||||
} else {
|
||||
uint8_t count_u8 = r.get_u8();
|
||||
count = count_u8 + 1;
|
||||
read_offset = output_bytes + offset;
|
||||
fprintf(stream, "[%zX] %hhu> 01 %02hhX %02hhX %02hhX extended copy from %zd (offset=%zX) size=%zX\n",
|
||||
phosg::fwrite_fmt(stream, "[{:X}] {}> 01 {:02X} {:02X} {:02X} extended copy from {} (offset={:X}) size={:X}\n",
|
||||
output_bytes, buffered_bits, a_low, a_high, count_u8, offset, read_offset, count);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1010,7 @@ void prs_disassemble(FILE* stream, const void* data, size_t size) {
|
||||
count = ((first_bit ? 2 : 0) | (second_bit ? 1 : 0)) + 2;
|
||||
ssize_t offset = offset_u8 | (~0xFF);
|
||||
read_offset = output_bytes + offset;
|
||||
fprintf(stream, "[%zX] %hhu> 00%c%c %02hhX short copy from %zd (offset=%zX) size=%zX\n",
|
||||
phosg::fwrite_fmt(stream, "[{:X}] {}> 00{}{} {:02X} short copy from {} (offset={:X}) size={:X}\n",
|
||||
output_bytes, buffered_bits, first_bit ? '1' : '0', second_bit ? '1' : '0', offset_u8, offset, read_offset, count);
|
||||
}
|
||||
|
||||
@@ -1069,11 +1026,10 @@ void prs_disassemble(FILE* stream, const std::string& data) {
|
||||
return prs_disassemble(stream, data.data(), data.size());
|
||||
}
|
||||
|
||||
// BC0 is a compression algorithm fairly similar to PRS, but with a simpler set
|
||||
// of commands. Like PRS, there is a control stream, indicating when to copy a
|
||||
// literal byte from the input and when to copy from a backreference; unlike
|
||||
// PRS, there is only one type of backreference. Also, there is no stop opcode;
|
||||
// the decompressor simply stops when there are no more input bytes to read.
|
||||
// BC0 is a compression algorithm fairly similar to PRS, but with a simpler set of commands. Like PRS, there is a
|
||||
// control stream, indicating when to copy a literal byte from the input and when to copy from a backreference; unlike
|
||||
// PRS, there is only one type of backreference. Also, there is no stop opcode; the decompressor simply stops when
|
||||
// there are no more input bytes to read.
|
||||
|
||||
struct BC0PathNode {
|
||||
uint16_t memo_offset = 0;
|
||||
@@ -1112,8 +1068,7 @@ string bc0_compress_optimal(
|
||||
}
|
||||
}
|
||||
|
||||
// For each node, populate the literal value, and the best ways to get to the
|
||||
// following nodes
|
||||
// For each node, populate the literal value, and the best ways to get to the following nodes
|
||||
for (size_t z = 0; z < in_size; z++) {
|
||||
if ((z & 0xFFF) == 0 && progress_fn) {
|
||||
progress_fn(CompressPhase::CONSTRUCT_PATHS, z, in_size, 0);
|
||||
@@ -1238,36 +1193,30 @@ string bc0_encode(const void* in_data_v, size_t in_size) {
|
||||
return std::move(w.close());
|
||||
}
|
||||
|
||||
// The BC0 decompression implementation in PSO GC is vulnerable to overflow
|
||||
// attacks - there is no bounds checking on the output buffer. It is unlikely
|
||||
// that this can be usefully exploited (e.g. for RCE) because the output pointer
|
||||
// is loaded from memory before every byte is written, so we cannot change the
|
||||
// output pointer to any arbitrary address.
|
||||
// The BC0 decompression implementation in PSO GC is vulnerable to overflow attacks - there is no bounds checking on
|
||||
// the output buffer. It is unlikely that this can be usefully exploited (e.g. for RCE) because the output pointer is
|
||||
// loaded from memory before every byte is written, so we cannot change the output pointer to any arbitrary address.
|
||||
|
||||
string bc0_decompress(const string& data) {
|
||||
return bc0_decompress(data.data(), data.size());
|
||||
}
|
||||
|
||||
string bc0_decompress(const void* data, size_t size) {
|
||||
StringReader r(data, size);
|
||||
StringWriter w;
|
||||
phosg::StringReader r(data, size);
|
||||
phosg::StringWriter w;
|
||||
|
||||
// Unlike PRS, BC0 uses a memo which "rolls over" every 0x1000 bytes. The
|
||||
// boundaries of these "memo pages" are offset by -0x12 bytes for some reason,
|
||||
// so the first output byte corresponds to position 0xFEE on the first memo
|
||||
// page. Backreferences refer to offsets based on the start of memo pages; for
|
||||
// example, if the current output offset is 0x1234, a backreference with
|
||||
// offset 0x123 refers to the byte that was written at offset 0x1111 (because
|
||||
// that byte is at offset 0x111 in the memo, because the memo rolls over every
|
||||
// 0x1000 bytes and the first memo byte was 0x12 bytes before the beginning of
|
||||
// the next page). The memo is initially zeroed from 0 to 0xFEE; it seems PSO
|
||||
// GC doesn't initialize the last 0x12 bytes of the first memo page.
|
||||
// Unlike PRS, BC0 uses a memo which "rolls over" every 0x1000 bytes. The boundaries of these "memo pages" are offset
|
||||
// by -0x12 bytes for some reason, so the first output byte corresponds to position 0xFEE on the first memo page.
|
||||
// Backreferences refer to offsets based on the start of memo pages; for example, if the current output offset is
|
||||
// 0x1234, a backreference with offset 0x123 refers to the byte that was written at offset 0x1111 (because that byte
|
||||
// is at offset 0x111 in the memo, because the memo rolls over every 0x1000 bytes and the first memo byte was 0x12
|
||||
// bytes before the beginning of the next page). The memo is initially zeroed from 0 to 0xFEE; it seems PSO GC
|
||||
// doesn't initialize the last 0x12 bytes of the first memo page.
|
||||
parray<uint8_t, 0x1000> memo;
|
||||
uint16_t memo_offset = 0x0FEE;
|
||||
|
||||
// The low byte of this value contains the control stream data; the high bits
|
||||
// specify which low bits are valid. When the last 1 is shifted out of the
|
||||
// high byte, we need to read a new control stream byte to get the next set of
|
||||
// The low byte of this value contains the control stream data; the high bits specify which low bits are valid. When
|
||||
// the last 1 is shifted out of the high byte, we need to read a new control stream byte to get the next set of
|
||||
// control bits.
|
||||
uint16_t control_stream_bits = 0x0000;
|
||||
|
||||
@@ -1281,15 +1230,14 @@ 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 +1252,9 @@ string bc0_decompress(const void* data, size_t size) {
|
||||
memo_offset = (memo_offset + 1) & 0x0FFF;
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// 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.
|
||||
uint8_t v = r.get_u8();
|
||||
w.put_u8(v);
|
||||
memo[memo_offset] = v;
|
||||
@@ -1322,7 +1270,7 @@ void bc0_disassemble(FILE* stream, const string& data) {
|
||||
}
|
||||
|
||||
void bc0_disassemble(FILE* stream, const void* data, size_t size) {
|
||||
StringReader r(data, size);
|
||||
phosg::StringReader r(data, size);
|
||||
uint16_t control_stream_bits = 0x0000;
|
||||
|
||||
size_t output_bytes = 0;
|
||||
@@ -1346,11 +1294,11 @@ void bc0_disassemble(FILE* stream, const void* data, size_t size) {
|
||||
uint8_t a2 = r.get_u8();
|
||||
size_t count = (a2 & 0x0F) + 3;
|
||||
// size_t backreference_offset = a1 | ((a2 << 4) & 0xF00);
|
||||
fprintf(stream, "[%zX] backreference %02zX\n", output_bytes, count);
|
||||
phosg::fwrite_fmt(stream, "[{:X}] backreference {:02X}\n", output_bytes, count);
|
||||
output_bytes += count;
|
||||
|
||||
} else {
|
||||
fprintf(stream, "[%zX] literal %02hhX\n", output_bytes, r.get_u8());
|
||||
phosg::fwrite_fmt(stream, "[{:X}] literal {:02X}\n", output_bytes, r.get_u8());
|
||||
output_bytes++;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user