Add day length compatibility fixup for BeeRewards GS

This commit is contained in:
Jonathan G Rennison
2020-07-01 18:21:19 +01:00
parent 501f7458db
commit 8f964ee637
3 changed files with 18 additions and 1 deletions

9
bin/game/compat_brgs.nut Normal file
View File

@@ -0,0 +1,9 @@
if ("GetTimeBetweenDates" in CompanyGoal) {
CompanyGoal._GetTimeBetweenDates <- CompanyGoal.GetTimeBetweenDates;
CompanyGoal.GetTimeBetweenDates <- function(start, end)
{
return CompanyGoal._GetTimeBetweenDates(start, start + ((end - start) / GSDate.GetDayLengthFactor()));
}
GSLog.Info("Day length compatibility in effect.");
}

View File

@@ -59,7 +59,8 @@ ScriptInstance::ScriptInstance(const char *APIName) :
suspend(0),
is_paused(false),
in_shutdown(false),
callback(nullptr)
callback(nullptr),
APIName(APIName)
{
this->storage = new ScriptStorage();
this->engine = new Squirrel(APIName);
@@ -87,6 +88,12 @@ void ScriptInstance::Initialize(const char *main_script, const char *instance_na
return;
}
if (strcmp(this->APIName, "GS") == 0) {
if (strcmp(instance_name, "BeeRewardClass") == 0) {
this->LoadCompatibilityScripts("brgs", GAME_DIR);
}
}
/* Create the main-class */
this->instance = new SQObject();
if (!this->engine->CreateClassInstance(instance_name, this->controller, this->instance)) {

View File

@@ -256,6 +256,7 @@ private:
bool in_shutdown; ///< Is this instance currently being destructed?
Script_SuspendCallbackProc *callback; ///< Callback that should be called in the next tick the script runs.
size_t last_allocated_memory; ///< Last known allocated memory value (for display for crashed scripts)
const char *APIName; ///< Name of the API used for this squirrel.
/**
* Call the script Load function if it exists and data was loaded