mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-18 02:16:23 -05:00
hacky bugfix to keep game from crashing tf out with other languages (#383)
This commit is contained in:
parent
3fe57700a5
commit
145aa92d20
@ -99,19 +99,19 @@ const (
|
||||
|
||||
// --- Fonts ---
|
||||
|
||||
Font6 = "/data/local/font/{LANG_FONT}/font6"
|
||||
Font8 = "/data/local/font/{LANG_FONT}/font8"
|
||||
Font16 = "/data/local/font/{LANG_FONT}/font16"
|
||||
Font24 = "/data/local/font/{LANG_FONT}/font24"
|
||||
Font30 = "/data/local/font/{LANG_FONT}/font30"
|
||||
Font42 = "/data/local/font/{LANG_FONT}/font42"
|
||||
FontFormal12 = "/data/local/font/{LANG_FONT}/fontformal12"
|
||||
FontFormal11 = "/data/local/font/{LANG_FONT}/fontformal11"
|
||||
FontFormal10 = "/data/local/font/{LANG_FONT}/fontformal10"
|
||||
FontExocet10 = "/data/local/font/{LANG_FONT}/fontexocet10"
|
||||
FontExocet8 = "/data/local/font/{LANG_FONT}/fontexocet8"
|
||||
FontSucker = "/data/local/font/{LANG_FONT}/ReallyTheLastSucker"
|
||||
FontRediculous = "/data/local/font/{LANG_FONT}/fontridiculous"
|
||||
Font6 = "/data/local/FONT/{LANG_FONT}/font6"
|
||||
Font8 = "/data/local/FONT/{LANG_FONT}/font8"
|
||||
Font16 = "/data/local/FONT/{LANG_FONT}/font16"
|
||||
Font24 = "/data/local/FONT/{LANG_FONT}/font24"
|
||||
Font30 = "/data/local/FONT/{LANG_FONT}/font30"
|
||||
Font42 = "/data/local/FONT/{LANG_FONT}/font42"
|
||||
FontFormal12 = "/data/local/FONT/{LANG_FONT}/fontformal12"
|
||||
FontFormal11 = "/data/local/FONT/{LANG_FONT}/fontformal11"
|
||||
FontFormal10 = "/data/local/FONT/{LANG_FONT}/fontformal10"
|
||||
FontExocet10 = "/data/local/FONT/{LANG_FONT}/fontexocet10"
|
||||
FontExocet8 = "/data/local/FONT/{LANG_FONT}/fontexocet8"
|
||||
FontSucker = "/data/local/FONT/{LANG_FONT}/ReallyTheLastSucker"
|
||||
FontRediculous = "/data/local/FONT/{LANG_FONT}/fontridiculous"
|
||||
|
||||
// --- UI ---
|
||||
|
||||
@ -165,9 +165,9 @@ const (
|
||||
|
||||
// --- Data ---
|
||||
|
||||
ExpansionStringTable = "/data/local/lng/{LANG}/expansionstring.tbl"
|
||||
StringTable = "/data/local/lng/{LANG}/string.tbl"
|
||||
PatchStringTable = "/data/local/lng/{LANG}/patchstring.tbl"
|
||||
ExpansionStringTable = "/data/local/LNG/{LANG}/expansionstring.tbl"
|
||||
StringTable = "/data/local/LNG/{LANG}/string.tbl"
|
||||
PatchStringTable = "/data/local/LNG/{LANG}/patchstring.tbl"
|
||||
LevelPreset = "/data/global/excel/LvlPrest.txt"
|
||||
LevelType = "/data/global/excel/LvlTypes.txt"
|
||||
ObjectType = "/data/global/excel/objtype.bin"
|
||||
@ -176,12 +176,12 @@ const (
|
||||
LevelMaze = "/data/global/excel/LvlMaze.txt"
|
||||
LevelSubstitutions = "/data/global/excel/LvlSub.txt"
|
||||
|
||||
ObjectDetails = "/data/global/excel/Objects.txt"
|
||||
SoundSettings = "/data/global/excel/Sounds.txt"
|
||||
ItemStatCost = "/data/global/excel/ItemStatCost.txt"
|
||||
Hireling = "/data/global/excel/hireling.txt"
|
||||
DifficultyLevels = "/data/global/excel/difficultylevels.txt"
|
||||
AutoMap = "/data/global/excel/AutoMap.txt"
|
||||
ObjectDetails = "/data/global/excel/Objects.txt"
|
||||
SoundSettings = "/data/global/excel/Sounds.txt"
|
||||
ItemStatCost = "/data/global/excel/ItemStatCost.txt"
|
||||
Hireling = "/data/global/excel/hireling.txt"
|
||||
DifficultyLevels = "/data/global/excel/difficultylevels.txt"
|
||||
AutoMap = "/data/global/excel/AutoMap.txt"
|
||||
|
||||
// --- Animations ---
|
||||
|
||||
|
@ -85,7 +85,8 @@ func LoadFile(filePath string) ([]byte, error) {
|
||||
|
||||
data, err := singleton.fileManager.loadFile(filePath)
|
||||
if err != nil {
|
||||
log.Printf("error loading file %s (%v)", filePath, err.Error())
|
||||
attemptedPath := singleton.fileManager.fixupFilePath(filePath)
|
||||
log.Printf("error loading file %s (%v)", attemptedPath, err.Error())
|
||||
}
|
||||
|
||||
return data, err
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2config"
|
||||
)
|
||||
|
||||
@ -53,11 +51,32 @@ func (fm *fileManager) fileExists(filePath string) (bool, error) {
|
||||
|
||||
func (fm *fileManager) fixupFilePath(filePath string) string {
|
||||
filePath = strings.ReplaceAll(filePath, "{LANG}", fm.config.Language)
|
||||
if strings.ToUpper(d2resource.LanguageCode) == "CHI" {
|
||||
filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", fm.config.Language)
|
||||
} else {
|
||||
filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", "latin")
|
||||
if fm.config.Language != "ENG" {
|
||||
filePath = strings.ReplaceAll(filePath, "expansionstring", "string")
|
||||
}
|
||||
// hack, no string table entries present in d2exp, set to english instead
|
||||
if fm.config.Language == "RUS" {
|
||||
filePath = strings.ReplaceAll(filePath, "RUS", "ENG")
|
||||
}
|
||||
// hack, POR doesn't have string.tbl
|
||||
if fm.config.Language == "POR" {
|
||||
toReplace := "POR/string.tbl"
|
||||
fallback := "ENG/string.tbl"
|
||||
filePath = strings.ReplaceAll(filePath, toReplace, fallback)
|
||||
}
|
||||
// hack, POL doesn't have string.tbl
|
||||
if fm.config.Language == "POL" {
|
||||
toReplace := "POL/string.tbl"
|
||||
fallback := "ENG/string.tbl"
|
||||
filePath = strings.ReplaceAll(filePath, toReplace, fallback)
|
||||
}
|
||||
|
||||
// hack, CHI doesn't have the fonts in the mpq
|
||||
// if strings.ToUpper(d2resource.LanguageCode) == "CHI" {
|
||||
// filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", fm.config.Language)
|
||||
// } else {
|
||||
filePath = strings.ReplaceAll(filePath, "{LANG_FONT}", "latin")
|
||||
// }
|
||||
|
||||
filePath = strings.ToLower(filePath)
|
||||
filePath = strings.ReplaceAll(filePath, `/`, "\\")
|
||||
|
Loading…
Reference in New Issue
Block a user