public static unsafe MapString[] getStrings(String filePath, String encoding) { TranslationStructure es = new TranslationStructure(); es.action = (byte)2; es.outputFilePath = (byte *)0; es.inputFilePath = toByteArray(filePath, Settings.defaultEncoding); try { run(&es); // Run extraction killByteArray(es.inputFilePath); UnsafeReadBuffer rb = new UnsafeReadBuffer(es.stringData); int totalStrings = rb.readInt(); MapString[] result = new MapString[totalStrings]; for (int i = 0; i < totalStrings; i++) { result[i] = readMapString(rb, encoding); } // Sort by index bool changed = true; while (changed) { changed = false; for (int i = 1; i < result.Length; i++) { MapString p0 = result[i - 1]; MapString p1 = result[i]; if (p0.mapIndex > p1.mapIndex) { changed = true; result[i - 1] = p1; result[i] = p0; } } } for (int i = 0; i < result.Length; i++) { //result[i].storageIndex = i; } es.action = (byte)3; run(&es); // Free the array data string return(result); } catch (Exception) { } return(null); }
private static MapString readMapString(UnsafeReadBuffer rb, String encoding) { MapString ms = new MapString(); ms.mapIndex = rb.readInt(); ms.str = rb.readString(encoding); ms.isMapDescription = rb.readByte() == 1 ? true : false; ms.isMapName = rb.readByte() == 1 ? true : false; ms.unitIndexs = rb.readIntArray(rb.readInt()); ms.switchIndexes = rb.readIntArray(rb.readInt()); ms.locationIndexes = rb.readIntArray(rb.readInt()); ms.triggerActionIndexes = rb.readIntArray(rb.readInt()); ms.triggerCommentIndexes = rb.readIntArray(rb.readInt()); ms.briefingActionIndexes = rb.readIntArray(rb.readInt()); ms.briefingCommentsIndexes = rb.readIntArray(rb.readInt()); ms.forceNamesIndexes = rb.readIntArray(rb.readInt()); return(ms); }