From b112d71dcfca6bac0710727d7f2d7f7ddfd36fb3 Mon Sep 17 00:00:00 2001 From: cracrayol Date: Wed, 16 Jun 2021 00:41:02 +0200 Subject: [PATCH 1/5] Initial support for MGA --- mga@asphyxia/README.md | 11 ++++++ mga@asphyxia/index.ts | 84 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 mga@asphyxia/README.md create mode 100644 mga@asphyxia/index.ts diff --git a/mga@asphyxia/README.md b/mga@asphyxia/README.md new file mode 100644 index 0000000..ff0ef2c --- /dev/null +++ b/mga@asphyxia/README.md @@ -0,0 +1,11 @@ +# Metal Gear Arcade + +Plugin Version: **v1.0.0** + +## Changelog + +#### 1.0.0 +Initial Release. + +## Known limitations +* No network capabilities \ No newline at end of file diff --git a/mga@asphyxia/index.ts b/mga@asphyxia/index.ts new file mode 100644 index 0000000..3404e5e --- /dev/null +++ b/mga@asphyxia/index.ts @@ -0,0 +1,84 @@ +interface PlayerData { + collection: 'data', + str: string[], + bin: string[] +} + +export function register() { + R.GameCode('I36'); + + R.Route(`eventlog.write`, async (req, data, send) => { + send.object({ + gamesession: K.ITEM('s64', BigInt(1)), + logsendflg: K.ITEM('s32', 0), + logerrlevel: K.ITEM('s32', 0), + evtidnosendflg: K.ITEM('s32', 0), + }) + }); + + R.Route(`system.getmaster`, async (req, data, send) => { + send.object({ + result: K.ITEM('s32', 1), + strdata1: K.ITEM('str', Buffer.from('2011081000:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1', 'utf-8').toString('base64')), + strdata2: K.ITEM('str', Buffer.from('1,1,1,1,1,1,1,1,1,1,1,1,1,1', 'utf-8').toString('base64')), + updatedate: K.ITEM('u64', BigInt('1120367223')), + }) + }); + + R.Route(`playerdata.usergamedata_send`, async (req, data, send) => { + const refid = $(data).element('data').str('eaid'); + const datanum = $(data).element('data').number('datanum'); + let playerData: PlayerData = { + collection: 'data', + str: [], + bin: [] + }; + + const record = $(data).element('data').element('record').obj; + + for (let i = 0; i < datanum; i++) { + playerData.str[i] = Buffer.from(_.get(record.d[i], '@content'), 'base64').toString('utf-8'); + playerData.bin[i] = _.get(record.d[i].bin1, '@content'); + } + + DB.Upsert(refid, { collection: 'data' }, playerData); + + send.object({ + result: K.ITEM('s32', 0), + }); + }); + + R.Route(`playerdata.usergamedata_recv`, async (req, data, send) => { + const refid = $(data).element('data').str('eaid'); + + const playerData = await DB.FindOne(refid, { collection: 'data' }); + + let player = { + record_num: K.ITEM('u32', playerData.str.length), + record: { + d: [] + } + }; + + for(let i = 0; i < playerData.str.length; i++) { + let data = playerData.str[i].split(','); + player.record.d[i] = K.ITEM('str', Buffer.from(data.slice(2).join(','), 'utf-8').toString('base64') + playerData.bin[i]); + player.record.d[i].bin1 = K.ITEM('str', playerData.bin[i]); + } + + send.object({ + player, + result: K.ITEM('s32', 0) + }); + }); + + R.Route(`playerdata.usergamedata_scorerank`, async (req, data, send) => { + send.object({ + result: K.ITEM('s32', 0) + }); + }); + + R.Unhandled((req: EamuseInfo, data: any, send: EamuseSend) => { + return send.success(); + }); +} \ No newline at end of file From 9f0b2521fa822d18235f4bf13f4314f889927c61 Mon Sep 17 00:00:00 2001 From: cracrayol Date: Sat, 19 Jun 2021 10:33:39 +0200 Subject: [PATCH 2/5] MGA : Add comments --- mga@asphyxia/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mga@asphyxia/index.ts b/mga@asphyxia/index.ts index 3404e5e..c937f2b 100644 --- a/mga@asphyxia/index.ts +++ b/mga@asphyxia/index.ts @@ -8,6 +8,7 @@ export function register() { R.GameCode('I36'); R.Route(`eventlog.write`, async (req, data, send) => { + // Don't save event log. send.object({ gamesession: K.ITEM('s64', BigInt(1)), logsendflg: K.ITEM('s32', 0), @@ -17,6 +18,8 @@ export function register() { }); R.Route(`system.getmaster`, async (req, data, send) => { + // Called at game startup + // Unlock all contents send.object({ result: K.ITEM('s32', 1), strdata1: K.ITEM('str', Buffer.from('2011081000:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1', 'utf-8').toString('base64')), @@ -26,6 +29,7 @@ export function register() { }); R.Route(`playerdata.usergamedata_send`, async (req, data, send) => { + // Save user data const refid = $(data).element('data').str('eaid'); const datanum = $(data).element('data').number('datanum'); let playerData: PlayerData = { @@ -49,6 +53,7 @@ export function register() { }); R.Route(`playerdata.usergamedata_recv`, async (req, data, send) => { + // Load user data const refid = $(data).element('data').str('eaid'); const playerData = await DB.FindOne(refid, { collection: 'data' }); @@ -61,7 +66,9 @@ export function register() { }; for(let i = 0; i < playerData.str.length; i++) { + // Remove the 2 firsts elements of player data let data = playerData.str[i].split(','); + player.record.d[i] = K.ITEM('str', Buffer.from(data.slice(2).join(','), 'utf-8').toString('base64') + playerData.bin[i]); player.record.d[i].bin1 = K.ITEM('str', playerData.bin[i]); } @@ -73,6 +80,7 @@ export function register() { }); R.Route(`playerdata.usergamedata_scorerank`, async (req, data, send) => { + // Not implemented send.object({ result: K.ITEM('s32', 0) }); From e84a66aee53dc979385ccc3755bc39122426f217 Mon Sep 17 00:00:00 2001 From: cracrayol Date: Sat, 19 Jun 2021 12:17:24 +0200 Subject: [PATCH 3/5] All: Send 0 if clear_type is not existing. --- popn@asphyxia/handler/eclale.ts | 2 +- popn@asphyxia/handler/fantasia.ts | 2 +- popn@asphyxia/handler/lapistoria.ts | 6 +++--- popn@asphyxia/handler/sunny.ts | 2 +- popn@asphyxia/handler/tunestreet.ts | 6 +++--- popn@asphyxia/handler/usaneko.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/popn@asphyxia/handler/eclale.ts b/popn@asphyxia/handler/eclale.ts index 6213953..9335b2a 100644 --- a/popn@asphyxia/handler/eclale.ts +++ b/popn@asphyxia/handler/eclale.ts @@ -169,7 +169,7 @@ const getScores = async (refid: string, forFriend: boolean = false) => { 900: 9, 1000: 10, 1100: 11, - }[score.clear_type]; + }[score.clear_type] || 0; if (music > GAME_MAX_MUSIC_ID) { continue; diff --git a/popn@asphyxia/handler/fantasia.ts b/popn@asphyxia/handler/fantasia.ts index 045338b..8cd98c0 100644 --- a/popn@asphyxia/handler/fantasia.ts +++ b/popn@asphyxia/handler/fantasia.ts @@ -261,7 +261,7 @@ const getScores = async (refid: string) => { 900: 10, 1000: 11, 1100: 15, - }[score.clear_type]; + }[score.clear_type] || 0; clear_medal[music] = clear_medal[music] | (medal << (sheet * 4)); const hiscore_index = (music * 4) + sheet; diff --git a/popn@asphyxia/handler/lapistoria.ts b/popn@asphyxia/handler/lapistoria.ts index a90eb07..6111600 100644 --- a/popn@asphyxia/handler/lapistoria.ts +++ b/popn@asphyxia/handler/lapistoria.ts @@ -208,7 +208,7 @@ const getProfile = async (refid: string, name?: string) => { 900: 9, 1000: 10, 1100: 11, - }[score.clear_type]), + }[score.clear_type] || 0), old_score: K.ITEM('s32', 0), old_clear_type: K.ITEM('u8', 0), }); @@ -416,7 +416,7 @@ const friend = async (req: EamuseInfo, data: any, send: EamuseSend): Promise { 900: 10, 1000: 11, 1100: 15, - }[score.clear_type]; + }[score.clear_type] || 0; clear_medal[music] = clear_medal[music] | (medal << (sheet * 4)); const hiscore_index = (music * 4) + sheet; diff --git a/popn@asphyxia/handler/tunestreet.ts b/popn@asphyxia/handler/tunestreet.ts index 63c58b3..2c88970 100644 --- a/popn@asphyxia/handler/tunestreet.ts +++ b/popn@asphyxia/handler/tunestreet.ts @@ -397,7 +397,7 @@ const __format_flags_for_score = (sheet: number, clear_type: number) => { 3: 0x4000, 7: 0, 8: 0, - }[sheet] + }[sheet]; const shift = { 9: 4, 4: 0, @@ -408,7 +408,7 @@ const __format_flags_for_score = (sheet: number, clear_type: number) => { 3: 6, 7: 9, 8: 8, - }[sheet] + }[sheet]; const flags = { 100: 0, 200: 0, @@ -421,7 +421,7 @@ const __format_flags_for_score = (sheet: number, clear_type: number) => { 900: 2, 1000: 2, 1100: 3, - }[clear_type] + }[clear_type] || 0; return (flags << shift) | playedflag } diff --git a/popn@asphyxia/handler/usaneko.ts b/popn@asphyxia/handler/usaneko.ts index 314fa94..0fc0c85 100644 --- a/popn@asphyxia/handler/usaneko.ts +++ b/popn@asphyxia/handler/usaneko.ts @@ -185,7 +185,7 @@ const getScores = async (refid: string, version: string, forFriend: boolean = fa 900: 9, 1000: 10, 1100: 11, - }[score.clear_type]; + }[score.clear_type] || 0; if (music > maxMusicId) { continue; From 0d02572bef24249c5974b3af77d093cebcb88f55 Mon Sep 17 00:00:00 2001 From: cracrayol Date: Sat, 19 Jun 2021 13:53:56 +0200 Subject: [PATCH 4/5] MGA: Update README --- mga@asphyxia/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mga@asphyxia/README.md b/mga@asphyxia/README.md index ff0ef2c..6392bae 100644 --- a/mga@asphyxia/README.md +++ b/mga@asphyxia/README.md @@ -2,10 +2,12 @@ Plugin Version: **v1.0.0** +Important : require minimum Asphyxia Core **v1.40c** + ## Changelog #### 1.0.0 Initial Release. ## Known limitations -* No network capabilities \ No newline at end of file +* No network/online capabilities \ No newline at end of file From 1c3f01c1099a681e2995d18ee1977211c406633c Mon Sep 17 00:00:00 2001 From: cracrayol Date: Sat, 19 Jun 2021 16:01:57 +0200 Subject: [PATCH 5/5] Update PnM README. --- popn@asphyxia/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/popn@asphyxia/README.md b/popn@asphyxia/README.md index 6eb1f2b..fcce465 100644 --- a/popn@asphyxia/README.md +++ b/popn@asphyxia/README.md @@ -1,6 +1,6 @@ # Pop'n Music -Plugin Version: **v2.2.2** +Plugin Version: **v2.2.3** ## Supported Versions - pop'n music 19 Tune Street @@ -15,6 +15,9 @@ Important : require minimum Asphyxia Core **v1.31** ## Changelog +### 2.2.3 +* All : Send 0 if clear_type is not existing. + ### 2.2.2 * Usaneko/Peace : Add Omnimix support (songs with id >= 3000).