diff --git a/CHANGELOG.md b/CHANGELOG.md index 27e0870fc..a21539878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel - Updated Simplified Chinese and Traditional Chinese localization files (by @sbzlzh): - Add the missing `L.c4_disarm_t` translation in C4 +- Updated file code to read from `data_static` as fallback in new location allowed in .gma (by @EntranceJew) ## [v0.11.7b](https://github.com/TTT-2/TTT2/tree/v0.11.7b) (2022-08-27) diff --git a/gamemodes/terrortown/entities/entities/ttt_traitor_button/init.lua b/gamemodes/terrortown/entities/entities/ttt_traitor_button/init.lua index c2650632b..096ab8e01 100644 --- a/gamemodes/terrortown/entities/entities/ttt_traitor_button/init.lua +++ b/gamemodes/terrortown/entities/entities/ttt_traitor_button/init.lua @@ -16,14 +16,15 @@ local path = dir .. "/" .. game.GetMap() .. ".json" local function ReadMapConfig() file.CreateDir(dir) - local modTime = (not file.Exists(path, "DATA") and (lastRead + 1)) or file.Time(path, "DATA") + local modTime = (not file.Exists("data_static/" .. path, "GAME") and (lastRead + 1)) or file.Time("data_static/" .. path, "GAME") + modTime = modTime <= lastRead and (not file.Exists(path, "DATA") and (lastRead + 1)) or file.Time(path, "DATA") if modTime <= lastRead then return TButtonMapConfig end lastRead = modTime - local content = file.Read(path, "DATA") + local content = (file.Exists(path, "DATA") and file.Read(path, "DATA")) or file.Read("data_static/" .. path, "GAME") if not content then return TButtonMapConfig diff --git a/lua/ttt2/libraries/entspawnscript.lua b/lua/ttt2/libraries/entspawnscript.lua index f300b62e3..df019969a 100644 --- a/lua/ttt2/libraries/entspawnscript.lua +++ b/lua/ttt2/libraries/entspawnscript.lua @@ -328,7 +328,8 @@ if SERVER then -- @return boolean Returns true if the spawnn script already exists -- @realm server function entspawnscript.Exists(dir) - return fileExists(dir .. gameGetMap() .. ".json", "DATA") + local fullDir = dir .. gameGetMap() .. ".json" + return fileExists(fullDir, "DATA") or fileExists("data_static/" .. fullDir, "GAME") end @@ -353,7 +354,12 @@ if SERVER then -- @internal -- @realm server function entspawnscript.ReadFile(dir) - return utilJSONToTable(fileRead(dir .. gameGetMap() .. ".json", "DATA")) + local fullDir = dir .. gameGetMap() .. ".json" + if fileExists(fullDir, "DATA") then + return utilJSONToTable( fileRead(fullDir, "DATA") ) + else + return utilJSONToTable( fileRead("data_static/" .. fullDir, "GAME") ) + end end ---