mirror of https://github.com/OpenTTD/OpenTTD
(svn r22598) [1.1] -Backport from trunk:
- Fix: [NoAI] Doing rescan_ai in a game with running AIs caused a crash [FS#4631] (r22534) - Fix: Do not create an implicit order if the current order is the first order in the order list and we visit the station of the last entry of the order list (r22532) - Fix: MinGW 64 related compilation issues [FS#4623] (r22522, r22491, r22490, r22489) - Fix: The layout selectors of the airport build GUI did not latch properly (r22497, r22495)release/1.1
parent
863d0e08e3
commit
4ba397c285
|
@ -54,6 +54,10 @@ extern "C" {
|
|||
typedef __int64 SQInteger;
|
||||
typedef unsigned __int64 SQUnsignedInteger;
|
||||
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
|
||||
#elif defined(_WIN32)
|
||||
typedef long long SQInteger;
|
||||
typedef unsigned long long SQUnsignedInteger;
|
||||
typedef unsigned long long SQHash; /*should be the same size of a pointer*/
|
||||
#else
|
||||
typedef long SQInteger;
|
||||
typedef unsigned long SQUnsignedInteger;
|
||||
|
@ -77,6 +81,8 @@ typedef float SQFloat;
|
|||
#if defined(SQUSEDOUBLE) && !defined(_SQ64)
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 SQRawObjectVal; //must be 64bits
|
||||
#elif defined(_WIN32)
|
||||
typedef long long SQRawObjectVal; //must be 64bits
|
||||
#else
|
||||
typedef long SQRawObjectVal; //must be 64bits
|
||||
#endif
|
||||
|
|
|
@ -75,9 +75,9 @@ AIInfo *AIConfig::GetInfo() const
|
|||
return this->info;
|
||||
}
|
||||
|
||||
bool AIConfig::ResetInfo()
|
||||
bool AIConfig::ResetInfo(bool force_exact_match)
|
||||
{
|
||||
this->info = AI::FindInfo(this->name, -1, false);
|
||||
this->info = AI::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
|
||||
return this->info != NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,12 @@ public:
|
|||
/**
|
||||
* When ever the AI Scanner is reloaded, all infos become invalid. This
|
||||
* function tells AIConfig about this.
|
||||
* @param force_exact_match If true try to find the exact same version
|
||||
* as specified. If false any version is ok.
|
||||
* @return \c true if the reset was successful, \c false if the AI was no longer
|
||||
* found.
|
||||
*/
|
||||
bool ResetInfo();
|
||||
bool ResetInfo(bool force_exact_match);
|
||||
|
||||
/**
|
||||
* Get the AIInfo linked to this AIConfig.
|
||||
|
|
|
@ -170,13 +170,24 @@
|
|||
* a random new AI on reload). */
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
if (_settings_game.ai_config[c] != NULL && _settings_game.ai_config[c]->HasAI()) {
|
||||
if (!_settings_game.ai_config[c]->ResetInfo()) {
|
||||
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
||||
DEBUG(ai, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
||||
_settings_game.ai_config[c]->ChangeAI(NULL);
|
||||
if (Company::IsValidAiID(c)) {
|
||||
/* The code belonging to an already running AI was deleted. We can only do
|
||||
* one thing here to keep everything sane and that is kill the AI. After
|
||||
* killing the offending AI we start a random other one in it's place, just
|
||||
* like what would happen if the AI was missing during loading. */
|
||||
AI::Stop(c);
|
||||
AI::StartNew(c, false);
|
||||
}
|
||||
} else if (Company::IsValidAiID(c)) {
|
||||
/* Update the reference in the Company struct. */
|
||||
Company::Get(c)->ai_info = _settings_game.ai_config[c]->GetInfo();
|
||||
}
|
||||
}
|
||||
if (_settings_newgame.ai_config[c] != NULL && _settings_newgame.ai_config[c]->HasAI()) {
|
||||
if (!_settings_newgame.ai_config[c]->ResetInfo()) {
|
||||
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
||||
DEBUG(ai, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
||||
_settings_newgame.ai_config[c]->ChangeAI(NULL);
|
||||
}
|
||||
|
|
|
@ -575,7 +575,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = {
|
|||
static const WindowDesc _build_airport_desc(
|
||||
WDP_AUTO, 0, 0,
|
||||
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
WDF_CONSTRUCTION | WDF_UNCLICK_BUTTONS,
|
||||
_nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
|
||||
);
|
||||
|
||||
|
|
|
@ -243,11 +243,11 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
|
|||
buffer += seprintf(buffer, last, "Registers:\n");
|
||||
#ifdef _M_AMD64
|
||||
buffer += seprintf(buffer, last,
|
||||
" RAX: %.16llX RBX: %.16llX RCX: %.16llX RDX: %.16llX\n"
|
||||
" RSI: %.16llX RDI: %.16llX RBP: %.16llX RSP: %.16llX\n"
|
||||
" R8: %.16llX R9: %.16llX R10: %.16llX R11: %.16llX\n"
|
||||
" R12: %.16llX R13: %.16llX R14: %.16llX R15: %.16llX\n"
|
||||
" RIP: %.16llX EFLAGS: %.8X\n",
|
||||
" RAX: %.16I64X RBX: %.16I64X RCX: %.16I64X RDX: %.16I64X\n"
|
||||
" RSI: %.16I64X RDI: %.16I64X RBP: %.16I64X RSP: %.16I64X\n"
|
||||
" R8: %.16I64X R9: %.16I64X R10: %.16I64X R11: %.16I64X\n"
|
||||
" R12: %.16I64X R13: %.16I64X R14: %.16I64X R15: %.16I64X\n"
|
||||
" RIP: %.16I64X EFLAGS: %.8lX\n",
|
||||
ep->ContextRecord->Rax,
|
||||
ep->ContextRecord->Rbx,
|
||||
ep->ContextRecord->Rcx,
|
||||
|
@ -548,7 +548,6 @@ static void CDECL CustomAbort(int signal)
|
|||
|
||||
/* static */ void CrashLog::InitialiseCrashLog()
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef _M_AMD64
|
||||
CONTEXT ctx;
|
||||
RtlCaptureContext(&ctx);
|
||||
|
@ -559,12 +558,13 @@ static void CDECL CustomAbort(int signal)
|
|||
* alignment would be wrong in the called function. */
|
||||
_safe_esp = (void *)(ctx.Rsp - 8);
|
||||
#else
|
||||
#if defined(_MSC_VER)
|
||||
_asm {
|
||||
mov _safe_esp, esp
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
asm("movl %esp, __safe_esp");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* SIGABRT is not an unhandled exception, so we need to intercept it. */
|
||||
|
|
|
@ -97,10 +97,10 @@ static const char * const _list_group_names[] = {
|
|||
* @param onelen force calculation of the *one parameter
|
||||
* @return the integer index of the full-list, or -1 if not found
|
||||
*/
|
||||
static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
|
||||
static size_t LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
|
||||
{
|
||||
const char *s;
|
||||
int idx;
|
||||
size_t idx;
|
||||
|
||||
if (onelen == 0) onelen = strlen(one);
|
||||
|
||||
|
@ -113,7 +113,7 @@ static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
|
|||
s = many;
|
||||
while (*s != '|' && *s != 0) s++;
|
||||
if ((size_t)(s - many) == onelen && !memcmp(one, many, onelen)) return idx;
|
||||
if (*s == 0) return -1;
|
||||
if (*s == 0) return (size_t)-1;
|
||||
many = s + 1;
|
||||
idx++;
|
||||
}
|
||||
|
@ -126,11 +126,11 @@ static int LookupOneOfMany(const char *many, const char *one, size_t onelen = 0)
|
|||
* of seperated by a whitespace,tab or | character
|
||||
* @return the 'fully' set integer, or -1 if a set is not found
|
||||
*/
|
||||
static uint32 LookupManyOfMany(const char *many, const char *str)
|
||||
static size_t LookupManyOfMany(const char *many, const char *str)
|
||||
{
|
||||
const char *s;
|
||||
int r;
|
||||
uint32 res = 0;
|
||||
size_t r;
|
||||
size_t res = 0;
|
||||
|
||||
for (;;) {
|
||||
/* skip "whitespace" */
|
||||
|
@ -141,7 +141,7 @@ static uint32 LookupManyOfMany(const char *many, const char *str)
|
|||
while (*s != 0 && *s != ' ' && *s != '\t' && *s != '|') s++;
|
||||
|
||||
r = LookupOneOfMany(many, str, s - str);
|
||||
if (r == -1) return (uint32)-1;
|
||||
if (r == (size_t)-1) return r;
|
||||
|
||||
SetBit(res, r); // value found, set it
|
||||
if (*s == 0) break;
|
||||
|
@ -339,24 +339,24 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
|
|||
switch (desc->cmd) {
|
||||
case SDT_NUMX: {
|
||||
char *end;
|
||||
unsigned long val = strtoul(str, &end, 0);
|
||||
size_t val = strtoul(str, &end, 0);
|
||||
if (*end != '\0') ShowInfoF("ini: trailing characters at end of setting '%s'", desc->name);
|
||||
return (void*)val;
|
||||
}
|
||||
case SDT_ONEOFMANY: {
|
||||
long r = LookupOneOfMany(desc->many, str);
|
||||
size_t r = LookupOneOfMany(desc->many, str);
|
||||
/* if the first attempt of conversion from string to the appropriate value fails,
|
||||
* look if we have defined a converter from old value to new value. */
|
||||
if (r == -1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
|
||||
if (r != -1) return (void*)r; // and here goes converted value
|
||||
if (r == (size_t)-1 && desc->proc_cnvt != NULL) r = desc->proc_cnvt(str);
|
||||
if (r != (size_t)-1) return (void*)r; // and here goes converted value
|
||||
ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name); // sorry, we failed
|
||||
return 0;
|
||||
}
|
||||
case SDT_MANYOFMANY: {
|
||||
unsigned long r = LookupManyOfMany(desc->many, str);
|
||||
if (r != (unsigned long)-1) return (void*)r;
|
||||
size_t r = LookupManyOfMany(desc->many, str);
|
||||
if (r != (size_t)-1) return (void*)r;
|
||||
ShowInfoF("ini: invalid value '%s' for '%s'", str, desc->name);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
case SDT_BOOLX:
|
||||
if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) return (void*)true;
|
||||
|
@ -571,15 +571,15 @@ static void IniSaveSettings(IniFile *ini, const SettingDesc *sd, const char *grp
|
|||
break;
|
||||
case SLE_VAR_I8:
|
||||
case SLE_VAR_U8:
|
||||
if (*(byte*)ptr == (byte)(unsigned long)p) continue;
|
||||
if (*(byte*)ptr == (byte)(size_t)p) continue;
|
||||
break;
|
||||
case SLE_VAR_I16:
|
||||
case SLE_VAR_U16:
|
||||
if (*(uint16*)ptr == (uint16)(unsigned long)p) continue;
|
||||
if (*(uint16*)ptr == (uint16)(size_t)p) continue;
|
||||
break;
|
||||
case SLE_VAR_I32:
|
||||
case SLE_VAR_U32:
|
||||
if (*(uint32*)ptr == (uint32)(unsigned long)p) continue;
|
||||
if (*(uint32*)ptr == (uint32)(size_t)p) continue;
|
||||
break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ static bool CheckRoadSide(int p1)
|
|||
* @param value that was read from config file
|
||||
* @return the "hopefully" converted value
|
||||
*/
|
||||
static int32 ConvertLandscape(const char *value)
|
||||
static size_t ConvertLandscape(const char *value)
|
||||
{
|
||||
/* try with the old values */
|
||||
return LookupOneOfMany("normal|hilly|desert|candy", value);
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
|
|||
|
||||
|
||||
typedef bool OnChange(int32 var); ///< callback prototype on data modification
|
||||
typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error
|
||||
typedef size_t OnConvert(const char *value); ///< callback prototype for convertion error
|
||||
|
||||
/** Properties of config file settings. */
|
||||
struct SettingDescBase {
|
||||
|
|
|
@ -34,7 +34,7 @@ static bool DifficultyChange(int32);
|
|||
static bool DifficultyNoiseChange(int32 i);
|
||||
static bool MaxNoAIsChange(int32 i);
|
||||
static bool CheckRoadSide(int p1);
|
||||
static int32 ConvertLandscape(const char *value);
|
||||
static size_t ConvertLandscape(const char *value);
|
||||
static bool CheckFreeformEdges(int32 p1);
|
||||
static bool ChangeDynamicEngines(int32 p1);
|
||||
static bool StationCatchmentChanged(int32 p1);
|
||||
|
|
|
@ -1865,7 +1865,7 @@ void Vehicle::BeginLoading()
|
|||
in_list->GetDestination() != this->last_station_visited)) {
|
||||
bool suppress_implicit_orders = HasBit(this->GetGroundVehicleFlags(), GVF_SUPPRESS_IMPLICIT_ORDERS);
|
||||
/* Do not create consecutive duplicates of implicit orders */
|
||||
Order *prev_order = this->cur_implicit_order_index > 0 ? this->GetOrder(this->cur_implicit_order_index - 1) : NULL;
|
||||
Order *prev_order = this->cur_implicit_order_index > 0 ? this->GetOrder(this->cur_implicit_order_index - 1) : (this->GetNumOrders() > 1 ? this->GetLastOrder() : NULL);
|
||||
if (prev_order == NULL ||
|
||||
(!prev_order->IsType(OT_IMPLICIT) && !prev_order->IsType(OT_GOTO_STATION)) ||
|
||||
prev_order->GetDestination() != this->last_station_visited) {
|
||||
|
|
Loading…
Reference in New Issue