Skip to content

Commit 29fca16

Browse files
authored
Merge pull request #600 from fixrtm/fix-encodig-error-on-model-load
fix: shift-jis based modelpack will cause crash
2 parents 5cdc0a7 + fb18de6 commit 29fca16

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

CHANGELOG-SNAPSHOTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The changelog for 2.0.23 and earlier is generated by [anatawa12's fork of `auto-
2020
### Fixed
2121
- Formation is broken when we disconnected long formation `#596`
2222
- Signal Converter Setting is not loaded correctly `#597`
23+
- shift-jis based modelpack will cause crash `#600`
2324

2425
### Security
2526

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Thanks to prepare-changelog.sh, we have some macros.
2727
### Fixed
2828
- Formation is broken when we disconnected long formation `#596`
2929
- Signal Converter Setting is not loaded correctly `#597`
30+
- shift-jis based modelpack will cause crash `#600`
3031

3132
### Security
3233

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)