Skip to content

Commit

Permalink
Support for La-Mulana version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thezerothcat committed Jul 30, 2022
1 parent f3a6e16 commit 0c8a8bc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>lmr.randomizer</groupId>
<artifactId>fools-quest</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>La-Mulana Fool's Quest</name>
<description>La-Mulana Fool's Quest</description>
<packaging>jar</packaging>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/lmr/randomizer/DataFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public final class DataFromFile {
private static List<String> winRequirements;
private static List<String> chestOnlyLocations;

private static String laMulanaVersion;

private static List<Integer> removedTabletGlowFlags;

private static CustomPlacementData customPlacementData;
Expand Down Expand Up @@ -546,6 +548,22 @@ public static List<String> getAllCoinChests() {
return allCoinChests;
}

public static boolean isLaMulanaVersionBefore(String expectedVersion) {
if (expectedVersion.equals(laMulanaVersion)) {
return false;
}
int actualNumber = Integer.parseInt("" + laMulanaVersion.charAt(2));
int expectedNumber = Integer.parseInt("" + expectedVersion.charAt(2));
if (actualNumber < expectedNumber) {
return true;
}
return false;
}

public static void setLaMulanaVersion(String version) {
laMulanaVersion = version;
}

public static List<Integer> getRemovedTabletGlowFlags() {
if(removedTabletGlowFlags == null ) {
removedTabletGlowFlags = getFlagsForRemovedTabletGlow();
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/lmr/randomizer/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* Created by thezerothcat on 7/10/2017.
*/
public class FileUtils {
public static final String VERSION = "2.0.0";
public static final String VERSION = "2.0.1";

private static BufferedWriter logWriter;
private static final List<String> KNOWN_RCD_FILE_HASHES = new ArrayList<>();
private static final Map<String, String> KNOWN_RCD_FILE_HASHES = new HashMap<>();
private static final String CHAR_TO_SHORT_CONVERSION = "!\"&'(),-./0123456789:?ABCDEFGHIJKLMNOPQRSTUVWXYZ ]^_abcdefghijklmnopqrstuvwxyz…♪、。々「」ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろわをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロワヲンヴ・ー一三上下不与世丘両中丸主乗乙乱乳予争事二人今介仕他付代以仮仲件会伝位低住体何作使供侵係保信俺倍倒値偉側偶備傷像僧元兄先光兜入全公具典内再冒冥出刀分切列初別利刻則前剣創力加助効勇勉動化匹十半協博印危去参双反取受叡口古召可台史右司合同名向否周呪味呼命品唯唱問喜営器噴四回囲図国土在地坂型域基堂報場塊塔墓増壁壇壊士声売壷変外多夜夢大天太央失奇契奥女好妊妖妻始姿娘婦子字存孤学宇守官宙定宝実客室宮家密寝対封専導小少尾屋屏属山岩崖崩嵐左巨己布帯帰常年幸幻幾広床底店度座庫廊廟弁引弟弱張強弾当形影役彼待後心必忍忘応念怒思急性怨恐息恵悔悟悪悲情惑想意愚愛感慈態憶我戦戻所扉手扱投抜押拝拡拳拾持指振探撃撮操支攻放敗教散数敵敷文料斧断新方旅族日早昇明昔星映時晩普晶智暗曲書最月有服望未末本杉村杖束来杯板析果架柱査格械棺検椿楼楽槍様槽模樹橋機欠次欲歓止正武歩歯歳歴死殊残段殺殿母毒毛気水氷永求汝池決治法波泥注洞洪流海消涙涯深済減湖満源溶滅滝火灯灼炎無然熱爆爪父版牛物特犬状狂独獄獅獣玄玉王珠現球理瓶生産用男画界略番発登白百的盤目直盾看真眼着知石研破碑示礼社祈祖神祠祭禁福私秘秤移種穴究空突窟立竜章竪端笛符第筒答箱範精系約納純紫細紹終経結続緑練罠罪罰義羽習翻翼老考者耐聖聞肉肩胸能脱腕自至船色若苦英荷華落葉蔵薇薔薬蛇血行術衛表裁装裏補製複要見覚親解言記訳証試話詳認誕誘語誠説読誰調論謁謎謝識議護谷貝財貧貯買貸資賢贄贖赤走起超足跡路踊蹴身車軽輝辞込辿近返迷追送逃通速造連進遊過道達違遠適選遺還郎部配重野量金針鉄銀銃銅録鍵鎖鏡長門閉開間関闇闘防限険陽階隠雄雑難雨霊青静面革靴音順領頭題顔願類風飛食館馬駄験骨高魂魔魚鳥鳴黄黒泉居転清成仏拠維視宿浮熟飾冷得集安割栄偽屍伸巻緒捨固届叩越激彫蘇狭浅Ⅱ[]:!?~/0123456789ABCDEFGHIJKLMNOPRSTUVWXYabdeghilmoprstux辺薄島異温復称狙豊穣虫絶QZcfjknqvwyz+-旧了設更橫幅似確置整>%香ü描園為渡象相聴比較掘酷艇原民雷絵南米平木秋田県湯環砂漠角運湿円背負構授輪圏隙草植快埋寺院妙該式判()警告収首腰芸酒美組各演点勝観編丈夫姫救’,.霧節幽技師柄期瞬電購任販Á;û+→↓←↑⓪①②③④⑤⑥⑦⑧⑨<”挑朝痛魅鍛戒飲憂照磨射互降沈醜触煮疲素競際易堅豪屈潔削除替Ü♡*$街極";

static {
Expand All @@ -34,11 +34,11 @@ public class FileUtils {
}
logWriter = temp;

KNOWN_RCD_FILE_HASHES.add("181C959BF2F2567279CC717C8AD03A20"); // 1.0.0.1
KNOWN_RCD_FILE_HASHES.add("89D8BF2DD6B8FA365A83DDBFD947CCFA"); // 1.1.1.1
KNOWN_RCD_FILE_HASHES.add("922C4FB1552843B73CF14ADCC923CF17"); // 1.2.2.1 and 1.3.3.1
KNOWN_RCD_FILE_HASHES.put("181C959BF2F2567279CC717C8AD03A20", "1.0"); // 1.0.0.1
KNOWN_RCD_FILE_HASHES.put("89D8BF2DD6B8FA365A83DDBFD947CCFA", "1.1"); // 1.1.1.1
KNOWN_RCD_FILE_HASHES.put("922C4FB1552843B73CF14ADCC923CF17", "1.3"); // 1.2.2.1 and 1.3.3.1
// 1.5.5.x is unknown
KNOWN_RCD_FILE_HASHES.add("21869050145662F6DAAC6A1B3D54F3B9"); // 1.6.6.x
KNOWN_RCD_FILE_HASHES.put("21869050145662F6DAAC6A1B3D54F3B9", "1.6"); // 1.6.6.x
}

public static BufferedWriter getFileWriter(String file) {
Expand Down Expand Up @@ -109,12 +109,14 @@ private static byte[] getBytes(InputStream inputStream, long fileSize) throws IO
return allBytes;
}

public static boolean hashRcdFile(File file) {
public static boolean hashRcdFileSetVersion(File file) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] fileBytes = getBytes(new FileInputStream(file), file.length());
String md5Hash = printHexBinary(md5.digest(fileBytes)).toUpperCase();
if(KNOWN_RCD_FILE_HASHES.contains(md5Hash)) {
String laMulanaVersion = KNOWN_RCD_FILE_HASHES.get(md5Hash);
if (laMulanaVersion != null) {
DataFromFile.setLaMulanaVersion(laMulanaVersion);
return true;
}
FileUtils.log("MD5 hash " + md5Hash + " for file " + file.getAbsolutePath() + " does not match any known versions of La-Mulana. Is this a modified file?");
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/lmr/randomizer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,18 @@ protected Void doInBackground() throws Exception {

private boolean backupRcd() {
File rcdFile = new File("script.rcd.bak");
if(!rcdFile.exists()) {
if(rcdFile.exists()) {
FileUtils.hashRcdFileSetVersion(rcdFile);
}
else {
File existingRcd = new File(Settings.getLaMulanaBaseDir(), "data/mapdata/script.rcd");
if(!existingRcd.exists()) {
JOptionPane.showMessageDialog(this,
"Unable to find file " + existingRcd.getAbsolutePath(),
"Randomizer error", JOptionPane.ERROR_MESSAGE);
return false;
}
else if (!FileUtils.hashRcdFile(existingRcd)) {
else if (!FileUtils.hashRcdFileSetVersion(existingRcd)) {
JOptionPane.showMessageDialog(this,
"The data/mapdata/script.rcd file in the game directory is not original! Please restore it from a backup / clean install!",
"Randomizer error", JOptionPane.ERROR_MESSAGE);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/lmr/randomizer/dat/DatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ private static ScannableBlock buildScannableBlock(int blockIndex, DataInputStrea
dataIndex += listEntry.getSize() / 2;
scannableBlock.getBlockContents().add(listEntry);

if(scannableBlock.getSlate() > 0) {
if(scannableBlock.getSlate() > 0
|| (blockIndex == BlockConstants.Tablet_Inferno_TuneOfThineOcarina && DataFromFile.isLaMulanaVersionBefore("1.3"))) {
dataInputStream.readShort(); // 0x000a
dataIndex += 2;
listEntry.setIncludeEndRecordIndicator(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ event.fools2022.medicineIntro=Welcome! We just got a new shipment of medicine.
event.fools2022.snapshotsRemoved=The text has worn away too much to make out what it says.
event.fools2022.snapshotsGraveyard1=REAL SPUD
event.fools2022.snapshotsGraveyard2={MANTRA=DEATH}The chant of truth, {COLOR=MANTRA}REAL SPUD{COLOR=DEFAULT}.
event.fools2022.snapshotsGraveyardFail1=R L S
event.fools2022.snapshotsGraveyardFail2=The chant of truth, {COLOR=MANTRA}R L S{COLOR=DEFAULT}.
event.fools2022.snapshotsGraveyardFail1=R L S
event.fools2022.snapshotsGraveyardFail2=The chant of truth, {COLOR=MANTRA}R L S{COLOR=DEFAULT} .
event.fools2022.toilsForNaught=To the one who toils for naught.\nThou art foolish.\nThou art foolish.\nThou art foolish.\nThou art foolish.
event.fools2022.holyBlessing={COLOR=BLUE}Urtharbrunnr{COLOR=DEFAULT} captures the dew of Yggdrasil. The Norns tend the sacred tree. It is nourished in turn by the water from the well, and through it, destiny is forged anew.
event.fools2022.htShortcut1=Press ↑ to go to {COLOR=BLUE}Room 8{COLOR=DEFAULT}.
Expand Down

0 comments on commit 0c8a8bc

Please sign in to comment.