Skip to content

Commit 49b8326

Browse files
committed
fix: shift-jis based modelpack will cause crash
1 parent ba54f43 commit 49b8326

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

src/main/rtm-patches/jp/ngt/rtm/modelpack/ModelPackManager.java.patch

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,22 @@
3838

3939
TimeTableManager.INSTANCE.load();
4040
par1.loadFinished = true;
41-
@@ -143,29 +146,43 @@
41+
@@ -143,29 +146,32 @@
4242
public ResourceType getType(String name) {
4343
return this.typeMap.get(name);
4444
}
4545

4646
public String registerResourceSet(ResourceType type, File file) throws IOException {
47-
+ List<String> json = null;
48-
for(String s : ENCODING) {
49-
try {
47+
- for(String s : ENCODING) {
48+
- try {
5049
- String s1 = NGTText.readText(file, false, s);
5150
- ResourceConfig resourceconfig = (ResourceConfig)NGTJson.getObjectFromJson(s1, type.cfgClass);
5251
- return this.registerResourceSet(type, resourceconfig, s1);
53-
+ json = NGTText.readText(file, s);
54-
+ break;
55-
} catch (IOException ioexception) {
56-
ioexception.printStackTrace();
57-
}
58-
}
59-
+ if (json == null)
60-
+ throw new ModelPackException("Can't load json. please check encoding of json " +
61-
+ "file and file is exists.", file.getAbsolutePath());
52+
- } catch (IOException ioexception) {
53+
- ioexception.printStackTrace();
54+
- }
55+
- }
56+
+ List<String> json = NGTText.readText(file, null);;
6257

6358
- throw new ModelPackException("Can't load model", file.getAbsolutePath());
6459
+ ResourceConfig resourceconfig = (ResourceConfig)NGTJson.getObjectFromJson(com.anatawa12.fixRtm.UtilsKt.joinLinesForJsonReading(json), type.cfgClass);
@@ -87,7 +82,7 @@
8782
return cfg.getName();
8883
} else {
8984
throw new ModelPackException("Failed to create ResourceSet", cfg.getName());
90-
@@ -177,15 +194,16 @@
85+
@@ -177,15 +183,16 @@
9186

9287
for(Entry<ResourceType, Map<String, ResourceSet>> entry : this.allModelSetMap.entrySet()) {
9388
for(ResourceSet resourceset : entry.getValue().values()) {
@@ -105,7 +100,7 @@
105100
public void addModelSetName(int count, String typeName, String name) {
106101
assert NGTUtil.isSMP() && !NGTUtil.isServer();
107102

108-
@@ -227,16 +245,13 @@
103+
@@ -227,16 +234,13 @@
109104
resourcetype = type.parent;
110105
}
111106

0 commit comments

Comments
 (0)