Merge branch 'more_cond_orders-sx' into jgrpp

# Conflicts:
#	config.lib
#	projects/openttd_vs100.vcxproj
#	projects/openttd_vs100.vcxproj.filters
#	projects/openttd_vs80.vcproj
#	projects/openttd_vs90.vcproj
#	src/order_gui.cpp
#	src/order_type.h
#	src/saveload/afterload.cpp
#	src/saveload/extended_ver_sl.cpp
This commit is contained in:
Jonathan G Rennison
2019-01-06 22:35:57 +00:00
36 changed files with 13882 additions and 58 deletions

View File

@@ -44,6 +44,7 @@ void SQAIOrder_Register(Squirrel *engine)
SQAIOrder.DefSQConst(engine, ScriptOrder::OF_INVALID, "OF_INVALID");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_RELIABILITY, "OC_RELIABILITY");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_MAX_RELIABILITY, "OC_MAX_RELIABILITY");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_MAX_SPEED, "OC_MAX_SPEED");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_AGE, "OC_AGE");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE");

View File

@@ -44,6 +44,7 @@ void SQGSOrder_Register(Squirrel *engine)
SQGSOrder.DefSQConst(engine, ScriptOrder::OF_INVALID, "OF_INVALID");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_RELIABILITY, "OC_RELIABILITY");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_MAX_RELIABILITY, "OC_MAX_RELIABILITY");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_MAX_SPEED, "OC_MAX_SPEED");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_AGE, "OC_AGE");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE");

View File

@@ -215,6 +215,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
switch (condition) {
case OC_LOAD_PERCENTAGE:
case OC_RELIABILITY:
case OC_MAX_RELIABILITY:
case OC_MAX_SPEED:
case OC_AGE:
case OC_REMAINING_LIFETIME:

View File

@@ -91,6 +91,7 @@ public:
/* Note: these values represent part of the in-game OrderConditionVariable enum */
OC_LOAD_PERCENTAGE = ::OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load, value is in tons.
OC_RELIABILITY = ::OCV_RELIABILITY, ///< Skip based on the reliability, value is percent (0..100).
OC_MAX_RELIABILITY = ::OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability. Value in percent
OC_MAX_SPEED = ::OCV_MAX_SPEED, ///< Skip based on the maximum speed, value is in OpenTTD's internal speed unit, see ScriptEngine::GetMaxSpeed.
OC_AGE = ::OCV_AGE, ///< Skip based on the age, value is in years.
OC_REQUIRES_SERVICE = ::OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service, no value.

View File

@@ -449,7 +449,8 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer
}
unsigned short bom = 0;
if (size >= 2) {
fread(&bom, 1, sizeof(bom), file); // Inside tar, no point checking return value of fread
size_t sr = fread(&bom, 1, sizeof(bom), file);
(void)sr; // Inside tar, no point checking return value of fread
}
SQLEXREADFUNC func;
@@ -487,8 +488,7 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer
return sq_throwerror(vm, "I/O error");
}
unsigned char uc;
fread(&uc, 1, sizeof(uc), file);
if (uc != 0xBF) {
if (fread(&uc, 1, sizeof(uc), file) != sizeof(uc) || uc != 0xBF) {
FioFCloseFile(file);
return sq_throwerror(vm, "Unrecognized encoding");
}