Merge branch 'master' into jgrpp

# Conflicts:
#	src/3rdparty/fmt/core.h
#	src/command_type.h
#	src/console_cmds.cpp
#	src/core/overflowsafe_type.hpp
#	src/landscape.cpp
#	src/network/network.cpp
#	src/newgrf_object.h
#	src/object_cmd.cpp
#	src/order_gui.cpp
#	src/saveload/vehicle_sl.cpp
#	src/script/api/script_industrytype.cpp
#	src/script/api/script_object.hpp
#	src/script/api/script_town.cpp
#	src/table/object_land.h
#	src/timetable_cmd.cpp
#	src/tree_cmd.cpp
#	src/vehicle_gui.cpp
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2023-01-15 19:28:37 +00:00
64 changed files with 442 additions and 310 deletions

View File

@@ -67,8 +67,10 @@ CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
break;
}
/* Overflow protection */
if (c->money + c->current_loan + loan < c->money) return CMD_ERROR;
/* In case adding the loan triggers the overflow protection of Money,
* we would essentially be losing money as taking and repaying the loan
* immediately would not get us back to the same bank balance anymore. */
if (c->money > Money::max() - loan) return CMD_ERROR;
if (flags & DC_EXEC) {
c->money += loan;