Skip to content

Commit

Permalink
Merge branch 'CorsixTH:master' into switch_staff_using_name_label
Browse files Browse the repository at this point in the history
  • Loading branch information
Matroftt authored Nov 28, 2024
2 parents 9c226e1 + c79bb6b commit 8117791
Show file tree
Hide file tree
Showing 67 changed files with 4,271 additions and 1,487 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ body:
Information about the configuration file can be found [here](https://github.com/CorsixTH/CorsixTH/wiki/Configuration-File).
You can find gamelog.txt at the same location as the config file."
placeholder: Paste gamelog.txt output here
render: bash
render: yaml
# Extra Info
- type: textarea
id: extra
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ jobs:
- name: Run simple code tests
if: matrix.static_analysis
run: |
# Check if there are trailing whitespaces.
python3 scripts/check_trailing_whitespaces.py
# Check if there bad whitespace.
python3 scripts/check_whitespace.py -e scanner.cpp -e parser.cpp
# Check for incorrectly encoded files.
python3 scripts/check_language_files_not_BOM.py
# Check if there are lua classes with invalid/improper declarations.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 'a1212c93cabaa9c5c36c1ffdb4bddd59fdf31e43'
vcpkgGitCommitId: '5f4628b89f3f98cd9a0b43c27ded2aa53da1f790'

- name: Run CMake dev configure
if: inputs.PRESET == 'win-dev'
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Release/
MinSizeRel/
RelWithDebInfo/

# For KDevelop
.kdev4/
*.kdev4

# Ignore the folder where libraries are pre-compiled
vcpkg/

Expand Down Expand Up @@ -79,6 +83,7 @@ CMakeScripts/

# Clang tools
compile_commands.json
.cache/

# This is for the CMake-generated Visual Studio project
*.vcxproj
Expand Down
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ end
-- W314: value assigned to field XYZ is unused
for _, lng in ipairs({"brazilian_portuguese", "czech", "danish", "developer",
"dutch", "english", "finnish", "french", "german", "greek", "hungarian",
"iberic_portuguese", "italian", "korean", "norwegian", "original_strings",
"iberic_portuguese", "italian", "japanese", "korean", "norwegian", "original_strings",
"polish", "russian", "simplified_chinese", "spanish", "swedish", "ukrainian",
"traditional_chinese"}) do
local filename = "CorsixTH/Lua/languages/" .. lng .. ".lua"
Expand Down
Binary file modified CorsixTH/Campaigns/Upper Pukington.map
Binary file not shown.
4 changes: 2 additions & 2 deletions CorsixTH/Campaigns/dethsdaw.level
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
%Name = "Dethsdaw"
%MapFile = "Dethsdaw.map"

%LevelBriefing = "The end is almost in sight, but first, some of the residents of Dethsdaw are coming down with a wobbly kind of illness. As always, the pinnacle of medical technologies are available to you as top scientists have created a new invention called the Atom Analyser. To move on to the final level, we want 900 cures, 90% treated, $450,000 in the bank, $750,000 worth of hospital and a reputation of 900. The Ministry expects total perfection!"
%LevelBriefing = "The end is almost in sight, but first, some of the residents of Dethsdaw are coming down with a wobbly kind of illness. As always, the pinnacle of medical technologies are available to you as top scientists have created a new invention called the Atom Analyser. To move on to the final level, we want 900 cures, 90% treated, $450,000 in the bank, $600,000 worth of hospital and a reputation of 900. The Ministry expects total perfection!"

%LevelDebriefing = "Exemplary! On the eve of your final mission, you've received a note from the Ministry of Health saying that they're putting you in charge of the largest and most complex hospital of them all!

Expand Down Expand Up @@ -292,7 +292,7 @@ Each entry states how many staff members of each category are available a given
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 450000 1 0
#win_criteria[2].Criteria.MaxMin.Value.Group.Bound 3 1 90 1 0
#win_criteria[3].Criteria.MaxMin.Value.Group.Bound 4 1 900 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 750000 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 600000 1 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 450 1 500
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 0 -40000 2 -20000
Expand Down
8 changes: 4 additions & 4 deletions CorsixTH/Campaigns/fourcorners.level
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SOFTWARE.
%Name = "Four Corners"
%MapFile = "Four Corners.map"

%LevelBriefing = "New advances in technology has allowed for improved research - you now have access to the Computer. Also, there is a tragic new condition involving gleaming foreheads and a new piece of diagnosis equipment to research. Your hospital, too, is strange since it is made up of nine cubes, so you will have to deal with it as best you can. Cure 600 people, treat 75% of them, have $200,000 in the bank, have a hospital worth $300,000 and a reputation of 750 to win."
%LevelBriefing = "New advances in technology has allowed for improved research - you now have access to the Computer. Also, there is a tragic new condition involving gleaming foreheads and a new piece of diagnosis equipment to research. Your hospital, too, is strange since it is made up of nine cubes, so you will have to deal with it as best you can. Cure 600 people, treat 75% of them, have $300,000 in the bank, have a hospital worth $200,000 and a reputation of 750 to win."

%LevelDebriefing = "Spectacular! The Ministry of Health is in good standing with the public thanks to you, but they feel as though one hospital is not moving forward enough.

Expand Down Expand Up @@ -204,14 +204,14 @@ Divides research input to get the amount of research points. must be > 0
6 Hospital value

#win_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 1 750 1 0
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 200000 1 0
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 300000 1 0
#win_criteria[2].Criteria.MaxMin.Value.Group.Bound 3 1 75 1 0
#win_criteria[3].Criteria.MaxMin.Value.Group.Bound 4 1 600 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 300000 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 200000 1 0
#win_criteria[5].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 400 1 450
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 25 2 0
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 25 2 10
#lose_criteria[2].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[3].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[4].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
Expand Down
4 changes: 2 additions & 2 deletions CorsixTH/Campaigns/hoppalong.level
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
%Name = "Hoppalong"
%MapFile = "Hoppalong.map"

%LevelBriefing = "A strange disease which makes people hairy is running rampant around the city of Wishinwell. According to our top scientists, it can only be removed by electroconvulsive therapy. Aside from that, you may find yourself out of room and out of cash, so plan ahead carefully. To win the level, cure 700 patients, treat 80% of visitors, amass $250,000 in the kitty, have a hospital worth $400,000 and gain a reputation of 800."
%LevelBriefing = "A strange disease which makes people hairy is running rampant around the city of Wishinwell. According to our top scientists, it can only be removed by electroconvulsive therapy. Aside from that, you may find yourself out of room and out of cash, so plan ahead carefully. To win the level, cure 700 patients, treat 80% of visitors, amass $250,000 in the kitty, have a hospital worth $350,000 and gain a reputation of 800."

%LevelDebriefing = "Perfect! Though you've done well here, a recent emergency has led to the creation of a makeshift hospital and your new boss, Mr B. Hind, is desperate for someone to run it. Don't let the public down!

Expand Down Expand Up @@ -292,7 +292,7 @@ Each entry states how many staff members of each category are available a given
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 250000 1 0
#win_criteria[2].Criteria.MaxMin.Value.Group.Bound 3 1 80 1 0
#win_criteria[3].Criteria.MaxMin.Value.Group.Bound 4 1 700 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 400000 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 350000 1 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 400 1 450
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 0 -50000 2 -30000
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Campaigns/snuffitsands.level
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Divides research input to get the amount of research points. must be > 0
#win_criteria[5].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 400 1 450
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 30 2 0
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 30 2 10
#lose_criteria[2].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[3].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[4].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
Expand Down
8 changes: 4 additions & 4 deletions CorsixTH/Campaigns/upperpukington.level
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SOFTWARE.
%Name = "Upper Pukington"
%MapFile = "Upper Pukington.map"

%LevelBriefing = "The Ministry of Health has recently acquired this old hospital in Upper Pukington, but has found it to be unsatisfactory in standards. There is a new tongue swelling disorder going around too, so watch out! Whilst you will not be dealing with emergencies, the layout is somewhat archaic, but we are sure you can reach the targets of 400 cures, 70% patient treatment, $150,000 in the kitty, $200,000 hospital value and a reputation of 650. Good luck!"
%LevelBriefing = "The Ministry of Health has recently acquired this old hospital in Upper Pukington, but has found it to be unsatisfactory in standards. There is a new tongue swelling disorder going around too, so watch out! Whilst you will not be dealing with emergencies, the layout is somewhat archaic, but we are sure you can reach the targets of 400 cures, 70% patient treatment, $200,000 in the kitty, $150,000 hospital value and a reputation of 650. Good luck!"

%LevelDebriefing = "Excellent! The Ministry sees that your climbing the ranks in this career, but watch you don't fall and break a leg! You wouldn't want to ruin your new Italian shoes now...

Expand Down Expand Up @@ -204,14 +204,14 @@ Divides research input to get the amount of research points. must be > 0
6 Hospital value

#win_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 1 650 1 0
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 150000 1 0
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 200000 1 0
#win_criteria[2].Criteria.MaxMin.Value.Group.Bound 3 1 70 1 0
#win_criteria[3].Criteria.MaxMin.Value.Group.Bound 4 1 400 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 200000 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 150000 1 0
#win_criteria[5].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 400 1 450
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 30 2 0
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 30 2 10
#lose_criteria[2].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[3].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[4].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
Expand Down
6 changes: 3 additions & 3 deletions CorsixTH/Campaigns/wishinwell.level
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SOFTWARE.
%Name = "Wishinwell"
%MapFile = "Wishinwell.map"

%LevelBriefing = "There are a couple of new conditions in the town of Wishinwell which require your attention, and youll be dealing with broken bones, so do not forget to prioritise research to cure rooms. You will also be dealing with a fair share of emergencies too. To win, gain a reputation of 700, treat 500 patients, cure 75% of your visitors, amass $175,000 in the bank and have a hospital worth $250,000. We at the Ministry wish you the best of luck!"
%LevelBriefing = "There are a couple of new conditions in the town of Wishinwell which require your attention, and you'll be dealing with broken bones, so do not forget to prioritise research to cure rooms. You will also be dealing with a fair share of emergencies too. To win, gain a reputation of 700, treat 500 patients, cure 75% of your visitors, amass $175,000 in the bank and have a hospital worth $200,000. We at the Ministry wish you the best of luck!"

%LevelDebriefing = "Outstanding! Now that you're on first name terms with your new boss, Mr I. Leggitt, you've been given a new project. He has noticed that you constantly stare at all four walls of your office,

Expand Down Expand Up @@ -207,11 +207,11 @@ Divides research input to get the amount of research points. must be > 0
#win_criteria[1].Criteria.MaxMin.Value.Group.Bound 2 1 175000 1 0
#win_criteria[2].Criteria.MaxMin.Value.Group.Bound 3 1 75 1 0
#win_criteria[3].Criteria.MaxMin.Value.Group.Bound 4 1 500 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 250000 1 0
#win_criteria[4].Criteria.MaxMin.Value.Group.Bound 6 1 200000 1 0
#win_criteria[5].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0

#lose_criteria[0].Criteria.MaxMin.Value.Group.Bound 1 0 400 1 450
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 25 2 0
#lose_criteria[1].Criteria.MaxMin.Value.Group.Bound 5 1 25 2 10
#lose_criteria[2].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[3].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
#lose_criteria[4].Criteria.MaxMin.Value.Group.Bound 0 0 0 0 0
Expand Down
8 changes: 0 additions & 8 deletions CorsixTH/CorsixTH.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ end
-- Load standard library extensions
corsixth.require("utility")

-- A DBGp debugger can debug this file if you start a CorsixTH DBGp client & connect
-- it to a running server, using this CorsixTH startup arg: -debugger
for _, arg in ipairs({...}) do
if arg:match("^%-%-connect%-lua%-dbgp") then
dofile("run_debugger")()
end
end

-- Check Lua version
local support = list_to_set({"Lua 5.1", "Lua 5.2", "Lua 5.3", "Lua 5.4"})
if not support[_VERSION] then
Expand Down
3 changes: 3 additions & 0 deletions CorsixTH/Levels/example.level
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ InterestRate is defined as centiprocent to allow for two decimals precision, i.e
300 means 3 %
#town.StartCash.InterestRate 100000 300

Soda price at drinks machines
#gbv.SodaPrice 20

-------------------- Disease Configuration -------------------------

When a drug is researched, what effectiveness does it have
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/api_version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Note: This file compiles as both Lua and C++. */

#endif /*]] --*/

return 2687;
return 2688;
64 changes: 31 additions & 33 deletions CorsixTH/Lua/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ local rnc = require("rnc")
local lfs = require("lfs")
local TH = require("TH")
local SDL = require("sdl")
local runDebugger = corsixth.require("run_debugger")

-- Increment each time a savegame break would occur
-- and add compatibility code in afterLoad functions
-- Recommended: Also replace/Update the summary comment

local SAVEGAME_VERSION = 191 -- CorsixTH 0.68.0~beta1
local SAVEGAME_VERSION = 209 -- Add soda price to level config

class "App"

Expand Down Expand Up @@ -70,12 +69,6 @@ function App:App()
self.window_active_status = false -- whether window is in focus, set after App:init
end

--! Starts a Lua DBGp client & connects it to a DBGp server.
--!return error_message (String) Returns an error message or nil.
function App:connectDebugger()
return runDebugger()
end

function App:setCommandLine(...)
self.command_line = { ... }
for _, arg in ipairs(self.command_line) do
Expand Down Expand Up @@ -176,10 +169,9 @@ function App:init()
self.video:setBlueFilterActive(false)
SDL.wm.setIconWin32()

self:setCaptureMouse()
self.caption = "CorsixTH"

-- Create gamelog file if missing
-- Create gamelog file.
self:initGamelogFile()

-- Prereq 2: Load and initialise the graphics subsystem
Expand All @@ -189,6 +181,7 @@ function App:init()

-- Put up the loading screen
if good_install_folder then
self:setCaptureMouse()
self.video:startFrame()
self.gfx:loadRaw("Load01V", 640, 480):draw(self.video,
math.floor((self.config.width - 640) / 2), math.floor((self.config.height - 480) / 2))
Expand Down Expand Up @@ -389,24 +382,28 @@ function App:init()
return true
end

--! Works out the intended location of the gamelog file.
--!return full path gamelog should exist at
function App:getGamelogPath()
local config_path = self.command_line["config-file"] or ""
config_path = config_path:match("^(.-)[^" .. pathsep .. "]*$")
return config_path .. "gamelog.txt"
end

--! Checks and creates the gamelog file if it does not exist.
--! Create the gamelog, using the launch time in the filename, and write the system information.
function App:initGamelogFile()
local gamelog_path = self:getGamelogPath()
local gamelog = io.open(gamelog_path, "r")
if gamelog then gamelog:close() return end

local fi = self:writeToFileOrTmp(gamelog_path)
self.gamelog_path = self.user_log_dir .. os.date("%y-%m-%d--%H-%M-%S--gamelog.txt", os.time(os.date("!*t")))
local fi, success = self:writeToFileOrTmp(self.gamelog_path)
local sysinfo = self:gamelogHeader()
fi:write(sysinfo)
fi:close()
if success then self:trimLogs() end -- Only trim logs if logs folder is writable
end

--! Trims the logs folder of old game logs down to ten files.
function App:trimLogs()
local log_retention, log_table = 11, {}
for node in lfs.dir(self.user_log_dir) do
local file = self.user_log_dir .. pathsep .. node
if node:sub(-12) == "-gamelog.txt" then
table.insert(log_table, file)
end
end
table.sort(log_table,
function(a, b) return lfs.attributes(a, "modification") > lfs.attributes(b, "modification") end)
for i=log_retention, #log_table do os.remove(log_table[i]) end
end

--! Tries to initialize the user level and campaign directories
Expand Down Expand Up @@ -435,6 +432,9 @@ function App:initUserDirectories()
self.user_campaign_dir = self.config.campaigns or
conf_path:match("^(.-)[^" .. pathsep .. "]*$") .. "Campaigns"
self.user_campaign_dir = setUserDir(self.user_campaign_dir, "User Campaigns")
self.user_log_dir = self.config.logs or
conf_path:match("^(.-)[^" .. pathsep .. "]*$") .. "Logs"
self.user_log_dir = setUserDir(self.user_log_dir, "Gamelogs")
end

--! Tries to initialize the savegame directory, returns true on success and
Expand Down Expand Up @@ -1019,7 +1019,7 @@ function App:saveConfig()
end

--! Tries to open the given file or a file in OS's temp dir.
-- Returns the file handler
-- Returns the file handler, and true if it was written to the intended file.
--!param file The full path of the intended file
--!param mode The mode in which the file is opened, defaults to write
function App:writeToFileOrTmp(file, mode)
Expand All @@ -1034,7 +1034,7 @@ function App:writeToFileOrTmp(file, mode)
end
end
assert(f, "Error: cannot write to filesystem")
return f
return f, not err
end

function App:fixHotkeys()
Expand Down Expand Up @@ -1253,8 +1253,8 @@ function App:idle()
self:resetIdle()
return
end
-- Have we been idle enough (~30s)
if self.idle_tick > 1000 then
-- Have we been idle enough (~30s, based on SDL tick rate of 18ms)
if self.idle_tick > 1680 then
-- User is idle, play the demo gameplay movie
self.moviePlayer:playDemoMovie()
self:resetIdle()
Expand Down Expand Up @@ -1641,10 +1641,10 @@ function App:getVersion(version)
-- Versioning format is major.minor.revision (required) Patch (optional)
-- Old versions (<= 0.67) retain existing format
-- All patch versions should be retained in this table (due to be replaced, see PR2518)
if ver > 191 then
if ver > 194 then
return "Trunk"
elseif ver > 180 then
return "v0.68.0 Beta 1"
return "v0.68.0"
elseif ver > 170 then
return "v0.67"
elseif ver > 156 then
Expand Down Expand Up @@ -1955,8 +1955,6 @@ end
--! Generate information about user's system and the program
--!return System and program info as a string
function App:gamelogHeader()
local gen_date = os.date("%Y-%m-%d %H:%M:%S")
gen_date = string.format("Gamelog generated on %s\n", gen_date)
local compile_opts = TH.GetCompileOptions()
local comp_details = {}
for key, value in pairs(compile_opts) do
Expand All @@ -1968,7 +1966,7 @@ function App:gamelogHeader()
local running = string.format("%s run with api version: %s, game version: %s, savegame version: %s\n",
compile_opts.jit or _VERSION, tostring(corsixth.require("api_version")),
self:getVersion(), tostring(SAVEGAME_VERSION))
return (gen_date .. compiled .. running)
return (compiled .. running)
end

-- Do not remove, for savegame compatibility < r1891
Expand Down
2 changes: 2 additions & 0 deletions CorsixTH/Lua/base_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ local configuration = {
VeryTired = 700,
-- Per mille point of attribute fatigue to be crack up (extremely) tired
CrackUpTired = 800,
-- How much soda costs at a drinks machine
SodaPrice = 20,
},

towns = {
Expand Down
Loading

0 comments on commit 8117791

Please sign in to comment.