@@ -1243,7 +1243,6 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -D_SQ64"
fi
CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
CFLAGS="$CFLAGS -DNO_GARBAGE_COLLECTOR"
if [ -n "$png_config" ]; then
CFLAGS="$CFLAGS -DWITH_PNG"
@@ -60,7 +60,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";NO_GARBAGE_COLLECTOR;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -167,7 +167,7 @@
AdditionalOptions="/MP"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";NO_GARBAGE_COLLECTOR"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@@ -269,7 +269,7 @@
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";NO_GARBAGE_COLLECTOR;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";_SQ64;WITH_ASSERT"
@@ -377,7 +377,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";NO_GARBAGE_COLLECTOR;_SQ64"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";_SQ64"
@@ -61,7 +61,7 @@
@@ -166,7 +166,7 @@
@@ -267,7 +267,7 @@
@@ -374,7 +374,7 @@
@@ -3,6 +3,7 @@
/** @file ai_core.cpp Implementation of AI. */
#include "../stdafx.h"
#include "../core/bitmath_func.hpp"
#include "../company_base.h"
#include "../company_func.h"
#include "../debug.h"
@@ -68,6 +69,13 @@
}
/* Occasionally collect garbage; every 255 ticks do one company.
* Effectively collecting garbage once every two months per AI. */
if ((AI::frame_counter & 255) == 0) {
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
if (IsValidCompanyID(cid) && !IsHumanCompany(cid)) GetCompany(cid)->ai_instance->CollectGarbage();
_current_company = OWNER_NONE;
@@ -296,6 +296,11 @@ void AIInstance::GameLoop()
void AIInstance::CollectGarbage()
{
if (this->is_started && !this->is_dead) this->engine->CollectGarbage();
/* static */ void AIInstance::DoCommandReturn(AIInstance *instance)
instance->engine->InsertResult(AIObject::GetLastCommandRes());
@@ -45,6 +45,11 @@ public:
void GameLoop();
/**
* Let the VM collect any garbage.
*/
void CollectGarbage();
* Get the storage of this AI.
static class AIStorage *GetStorage();
@@ -175,6 +175,11 @@ bool Squirrel::Resume(int suspend)
return this->vm->_suspended != 0;
void Squirrel::CollectGarbage()
sq_collectgarbage(this->vm);
bool Squirrel::CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT *ret, int suspend)
/* Store the stack-location for the return value. We need to
@@ -101,6 +101,11 @@ public:
bool Resume(int suspend = -1);
* Tell the VM to do a garbage collection run.
void InsertResult(bool result);
void InsertResult(int result);
Status change: