mirror of https://github.com/OpenTTD/OpenTTD
Revert d7bd67cda3: [Scripts] "_typeof" metamethod negatively affects old scripts
parent
3d5083218d
commit
a577229e95
|
@ -12,8 +12,8 @@ AIBridge.GetBridgeID <- AIBridge.GetBridgeType;
|
|||
class AICompat14 {
|
||||
function Text(text)
|
||||
{
|
||||
if (typeof(text) != "string") return null;
|
||||
return text;
|
||||
if (type(text) == "string") return text;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ GSBridge.GetBridgeID <- GSBridge.GetBridgeType;
|
|||
class GSCompat14 {
|
||||
function Text(text)
|
||||
{
|
||||
type = typeof(text)
|
||||
if (type != "string" && type != "GSText") return null;
|
||||
return text;
|
||||
if (type(text) == "string") return text;
|
||||
if (type(text) == "instance" && text instanceof GSText) return text;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -484,8 +484,9 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
||||
endif()
|
||||
endforeach()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedStaticMethod(engine, &PushClassName<${CLS}, ScriptType::${APIUC}>, \"_typeof\");")
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif()
|
||||
|
||||
# Non-static methods
|
||||
set(MLEN 0)
|
||||
|
|
|
@ -35,7 +35,6 @@ template <> SQInteger PushClassName<AIInfo, ScriptType::AI>(HSQUIRRELVM vm) { sq
|
|||
DefSQClass<AIInfo, ScriptType::AI> SQAIInfo("AIInfo");
|
||||
SQAIInfo.PreRegister(engine);
|
||||
SQAIInfo.AddConstructor<void (AIInfo::*)(), 1>(engine, "x");
|
||||
SQAIInfo.DefSQAdvancedStaticMethod(engine, &PushClassName<AIInfo, ScriptType::AI>, "_typeof");
|
||||
SQAIInfo.DefSQAdvancedMethod(engine, &AIInfo::AddSetting, "AddSetting");
|
||||
SQAIInfo.DefSQAdvancedMethod(engine, &AIInfo::AddLabels, "AddLabels");
|
||||
SQAIInfo.DefSQConst(engine, SCRIPTCONFIG_NONE, "CONFIG_NONE");
|
||||
|
|
|
@ -33,7 +33,6 @@ template <> SQInteger PushClassName<GameInfo, ScriptType::GS>(HSQUIRRELVM vm) {
|
|||
DefSQClass<GameInfo, ScriptType::GS> SQGSInfo("GSInfo");
|
||||
SQGSInfo.PreRegister(engine);
|
||||
SQGSInfo.AddConstructor<void (GameInfo::*)(), 1>(engine, "x");
|
||||
SQGSInfo.DefSQAdvancedStaticMethod(engine, &PushClassName<GameInfo, ScriptType::GS>, "_typeof");
|
||||
SQGSInfo.DefSQAdvancedMethod(engine, &GameInfo::AddSetting, "AddSetting");
|
||||
SQGSInfo.DefSQAdvancedMethod(engine, &GameInfo::AddLabels, "AddLabels");
|
||||
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_NONE, "CONFIG_NONE");
|
||||
|
|
|
@ -14,8 +14,6 @@ void SQAIController_Register(Squirrel *engine)
|
|||
DefSQClass<ScriptController, ScriptType::AI> SQAIController("AIController");
|
||||
SQAIController.PreRegister(engine);
|
||||
|
||||
SQAIController.DefSQAdvancedStaticMethod(engine, &PushClassName<ScriptController, ScriptType::AI>, "_typeof");
|
||||
|
||||
SQAIController.DefSQStaticMethod(engine, &ScriptController::GetTick, "GetTick", 1, ".");
|
||||
SQAIController.DefSQStaticMethod(engine, &ScriptController::GetOpsTillSuspend, "GetOpsTillSuspend", 1, ".");
|
||||
SQAIController.DefSQStaticMethod(engine, &ScriptController::SetCommandDelay, "SetCommandDelay", 2, ".i");
|
||||
|
|
|
@ -14,8 +14,6 @@ void SQGSController_Register(Squirrel *engine)
|
|||
DefSQClass<ScriptController, ScriptType::GS> SQGSController("GSController");
|
||||
SQGSController.PreRegister(engine);
|
||||
|
||||
SQGSController.DefSQAdvancedStaticMethod(engine, &PushClassName<ScriptController, ScriptType::GS>, "_typeof");
|
||||
|
||||
SQGSController.DefSQStaticMethod(engine, &ScriptController::GetTick, "GetTick", 1, ".");
|
||||
SQGSController.DefSQStaticMethod(engine, &ScriptController::GetOpsTillSuspend, "GetOpsTillSuspend", 1, ".");
|
||||
SQGSController.DefSQStaticMethod(engine, &ScriptController::SetCommandDelay, "SetCommandDelay", 2, ".i");
|
||||
|
|
Loading…
Reference in New Issue