@@ -63,22 +63,29 @@ public static String decodeInternetCode(String code) {
6363 bytes [byteInd ] ^= (1 << bitInd );
6464 }
6565
66- return Decoder .readInternetCode (bytes );
66+ return Decoder .getGameInfo (bytes );
6767 }
6868
69- private static String readInternetCode (byte [] bytes ) {
69+ public static String getGameInfo (byte [] bytes ) {
70+ String resultLabel = I18N .getString ("resultLabel" );
71+ String [] internetCodes = Decoder .readInternetCode (bytes ).split ("_" );
72+ String totalPlaytime = Decoder .readTotalPlaytime (bytes );
73+ return String .format (resultLabel , internetCodes [0 ], internetCodes [1 ], totalPlaytime );
74+ }
75+
76+ public static String readInternetCode (byte [] bytes ) {
7077 int intCode = 0 ;
71- intCode |= (bytes [8 ] & (0x1E000000 >> 25 )) << 25 ;
72- intCode |= (bytes [9 ] & (0x01000000 >> 19 )) << 19 ;
73- intCode |= (bytes [9 ] & (0x00001F00 >> 8 )) << 8 ;
78+ intCode |= (bytes [8 ] & (0x1E000000 >> 25 )) << 25 ;
79+ intCode |= (bytes [9 ] & (0x01000000 >> 19 )) << 19 ;
80+ intCode |= (bytes [9 ] & (0x00001F00 >> 8 )) << 8 ;
7481 intCode |= (bytes [10 ] & (0x001F0000 >> 14 )) << 14 ;
75- intCode |= (bytes [10 ] & (0x0000000C >> 2 )) << 2 ;
76- intCode |= (bytes [11 ] & (0x00000003 << 4 )) >> 4 ;
82+ intCode |= (bytes [10 ] & (0x0000000C >> 2 )) << 2 ;
83+ intCode |= (bytes [11 ] & (0x00000003 << 4 )) >> 4 ;
7784
7885 int l1 = (intCode >> 24 ) & 0xFF ;
7986 int d1 = (intCode >> 16 ) & 0xFF ;
80- int l2 = (intCode >> 8 ) & 0xFF ;
81- int d2 = (intCode >> 0 ) & 0xFF ;
87+ int l2 = (intCode >> 8 ) & 0xFF ;
88+ int d2 = (intCode >> 0 ) & 0xFF ;
8289
8390 String [] letters1 = DecodingData .BYTES_TO_CODE .get (Integer .valueOf (l1 ).byteValue ());
8491 String [] letters2 = DecodingData .BYTES_TO_CODE .get (Integer .valueOf (l2 ).byteValue ());
@@ -89,9 +96,12 @@ private static String readInternetCode(byte[] bytes) {
8996 String russianCode = letters1 [1 ] + d1 + letters2 [1 ] + d2 ;
9097 String englishCode = letters1 [0 ] + d1 + letters2 [0 ] + d2 ;
9198
92- // I could put this in PRSF (private static final), but it might be not initialized yet
93- String russianLabel = I18N .getString ("codeLabelRu" );
94- String englishLabel = I18N .getString ("codeLabelEn" );
95- return String .format ("%s: %s %s %s: %s" , russianLabel , russianCode , I18N .getString ("andText" ), englishLabel , englishCode );
99+ return russianCode + "_" + englishCode ;
100+ }
101+
102+ public static String readTotalPlaytime (byte [] bytes ) {
103+ return (bytes [14 ] < 10 ? "0" + bytes [14 ] : "" + bytes [14 ]) + ":" +
104+ (bytes [13 ] < 10 ? "0" + bytes [13 ] : "" + bytes [13 ]) + ":" +
105+ (bytes [15 ] < 10 ? "0" + bytes [15 ] : "" + bytes [15 ]);
96106 }
97107}
0 commit comments