project-slippi / slippi-js

Parse slp files and compute stats
GNU Lesser General Public License v3.0
148 stars 79 forks source link

Can't get metadata when player's name has a special character #126

Open Sheepolution opened 1 year ago

Sheepolution commented 1 year ago

Today I noticed slippi-js not working on certain matches. Later on I realized that this specifically happened on the matches with the player who has ェnoonェ as their display name. My guess is that because of the special character (ェ) Slippi-js somehow fails.

Here are some .slp files of matches with this player.

slippi_files.zip

cnkeats commented 1 year ago

Can you be more specific about how to reproduce the issue? The replays process fine for me

const game = new SlippiGame("./Game_20230523T215817.slp");
const settings = game.getSettings();
console.info(settings);
{
      slpVersion: '3.14.0',
      timerType: 2,
      inGameMode: 32,
      friendlyFireEnabled: true,
      isTeams: false,
      itemSpawnBehavior: 255,
      stageId: 8,
      startingTimerSeconds: 480,
      enabledItems: 1099511627775,
      players: [
        {
          playerIndex: 0,
          port: 1,
          characterId: 8,
          type: 0,
          startStocks: 4,
          characterColor: 2,
          teamShade: 0,
          handicap: 9,
          teamId: 0,
          staminaMode: false,
          silentCharacter: false,
          lowGravity: false,
          invisible: false,
          blackStockIcon: false,
          metal: false,
          startOnAngelPlatform: false,
          rumbleEnabled: false,
          cpuLevel: 1,
          offenseRatio: 1,
          defenseRatio: 1,
          modelScale: 1,
          controllerFix: 'UCF',
          nametag: '',
          displayName: 'ェnoonェ',
          connectCode: 'NOON#888',
          userId: '8YEJcBGEIqc54Dzk1t68K1audW13'
        },
        {
          playerIndex: 1,
          port: 2,
          characterId: 13,
          type: 0,
          startStocks: 4,
          characterColor: 2,
          teamShade: 0,
          handicap: 9,
          teamId: 1,
          staminaMode: false,
          silentCharacter: false,
          lowGravity: false,
          invisible: false,
          blackStockIcon: false,
          metal: false,
          startOnAngelPlatform: false,
          rumbleEnabled: false,
          cpuLevel: 1,
          offenseRatio: 1,
          defenseRatio: 1,
          modelScale: 1,
          controllerFix: 'UCF',
          nametag: '',
          displayName: 'xin',
          connectCode: 'XIN#484',
          userId: 'cJeLclrRp9R6jbQmaHd2oeHvOdx2'
        }
      ],
      scene: 2,
      gameMode: 8,
      language: 1,
      gameInfoBlock: {
        gameBitfield1: 50,
        gameBitfield2: 1,
        gameBitfield3: 134,
        gameBitfield4: 76,
        bombRainEnabled: false,
        itemSpawnBehavior: -1,
        selfDestructScoreValue: -1,
        itemSpawnBitfield1: 255,
        itemSpawnBitfield2: 255,
        itemSpawnBitfield3: 255,
        itemSpawnBitfield4: 255,
        itemSpawnBitfield5: 255,
        damageRatio: 1
      },
      randomSeed: 14584,
      isPAL: false,
      isFrozenPS: false,
      matchInfo: {
        matchId: 'mode.direct-2023-05-23T19:52:22.37-2',
        gameNumber: 5,
        tiebreakerNumber: 0
      }
}

image image

Sheepolution commented 1 year ago

Yes, my apologies. I was specifically talking about getMetadata().

const { SlippiGame } = require("@slippi/slippi-js");

const game1 = new SlippiGame("./Game_20230523T204542.slp"); // ェnoonェ vs Danubi
const metadata1 = game1.getMetadata();
console.info(metadata1); // null

const game2 = new SlippiGame("./Game_20230523T215817.slp"); // ェnoonェ vs Xin
const metadata2 = game2.getMetadata();
console.info(metadata2); // null

const game3 = new SlippiGame("./Game_20230523T214550.slp"); // Xin vs Lily
const metadata3 = game3.getMetadata();
console.info(metadata3); // Data!
NikhilNarayana commented 1 year ago

summary: these characters are unsupported in UBJSON's non binary types. for now try to use fallbacks when possible.

the parse error occurs at the decode stage in slippi-js image

i'm inclined to believe this is a UBJSON limitation because peppi also fails like slippi-js image

here's a quick screenshot of the metadata decoded in HxD, not sure how helpful that is, but it is possible wide characters are being decoded similarly image