mirror of https://github.com/OpenTTD/OpenTTD
(svn r9342) [0.5] -Backport from trunk (r8980, r9065, r9339):
- Fix: the industry list should also be (re)set when the number of industries is 0 (r8980) - Fix: possible dereference of NULL pointer (r9065) - Codechange: disable shares by default and increase the default maximum distance from edge for oil refineries (r9339)release/0.5
parent
98f77876e6
commit
11b1c6f2ee
|
@ -553,26 +553,30 @@ static int CDECL GeneralIndustrySorter(const void *a, const void *b)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a sorted industry list.
|
||||||
|
* When there are no industries, the list has to be made. This so when one
|
||||||
|
* starts a new game without industries after playing a game with industries
|
||||||
|
* the list is not populated with invalid industries from the previous game.
|
||||||
|
*/
|
||||||
static void MakeSortedIndustryList(void)
|
static void MakeSortedIndustryList(void)
|
||||||
{
|
{
|
||||||
const Industry* i;
|
const Industry* i;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
/* Don't attempt a sort if there are no industries */
|
|
||||||
if (GetNumIndustries() == 0) return;
|
|
||||||
|
|
||||||
/* Create array for sorting */
|
/* Create array for sorting */
|
||||||
_industry_sort = realloc((void *)_industry_sort, (GetMaxIndustryIndex() + 1) * sizeof(_industry_sort[0]));
|
_industry_sort = realloc((void *)_industry_sort, (GetMaxIndustryIndex() + 1) * sizeof(_industry_sort[0]));
|
||||||
if (_industry_sort == NULL)
|
if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list");
|
||||||
error("Could not allocate memory for the industry-sorting-list");
|
|
||||||
|
|
||||||
FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i;
|
/* Don't attempt a sort if there are no industries */
|
||||||
|
if (GetNumIndustries() != 0) {
|
||||||
|
FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i;
|
||||||
|
qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter);
|
||||||
|
}
|
||||||
|
|
||||||
_num_industry_sort = n;
|
_num_industry_sort = n;
|
||||||
_last_industry = NULL; // used for "cache"
|
_last_industry = NULL; // used for "cache"
|
||||||
|
|
||||||
qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter);
|
|
||||||
|
|
||||||
DEBUG(misc, 1) ("Resorting Industries list...");
|
DEBUG(misc, 1) ("Resorting Industries list...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
|
||||||
// you can remove all kind of roads with extra dynamite
|
// you can remove all kind of roads with extra dynamite
|
||||||
if (_patches.extra_dynamite) return true;
|
if (_patches.extra_dynamite) return true;
|
||||||
|
|
||||||
t = ClosestTownFromTile(tile, _patches.dist_local_authority);
|
t = ClosestTownFromTile(tile, (uint)-1);
|
||||||
|
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
|
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
|
||||||
|
|
|
@ -1350,7 +1350,7 @@ const SettingDesc _patch_settings[] = {
|
||||||
SDT_VAR(Patches, starting_year, SLE_INT32, 0,NC, 1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
|
SDT_VAR(Patches, starting_year, SLE_INT32, 0,NC, 1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
|
||||||
SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
|
SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
|
||||||
SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
|
SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
|
||||||
SDT_BOOL(Patches, allow_shares, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
|
SDT_BOOL(Patches, allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* AI section of the GUI-configure patches window */
|
/* AI section of the GUI-configure patches window */
|
||||||
|
@ -1465,7 +1465,7 @@ const SettingDesc _patch_settings[] = {
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* Terrain genation related patch options */
|
/* Terrain genation related patch options */
|
||||||
SDT_CONDVAR(Patches, land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
|
SDT_CONDVAR(Patches, land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
|
||||||
SDT_CONDVAR(Patches, oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 16, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
|
SDT_CONDVAR(Patches, oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
|
||||||
SDT_CONDVAR(Patches, tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
|
SDT_CONDVAR(Patches, tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
|
||||||
SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(uint32), 0, STR_NULL, NULL),
|
SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(uint32), 0, STR_NULL, NULL),
|
||||||
SDT_CONDVAR(Patches, tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
|
SDT_CONDVAR(Patches, tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
|
||||||
|
|
Loading…
Reference in New Issue