1
0
Fork 0

(svn r20869) [1.0] -Backport from trunk:

- Fix: [NewGRF] Assert when an industry previously build on water was flooded because its NewGRF changed/is missing [FS#4112] (r20754)
- Fix: Do not use new game settings when creating many random towns/industries in the scenario editor [FS#4094] (r20712, r20711)
- Fix: Graphic glitch when switching to a different-sized font while the chat message box was visible (r20705)
- Fix: Vehicle lists of non-trains could not resize horizontally causing truncation of texts [FS#4123, FS#3955] (r20174)
release/1.0
rubidium 2010-10-02 14:31:07 +00:00
parent 9236112860
commit 672406654c
5 changed files with 26 additions and 11 deletions

View File

@ -799,6 +799,12 @@ static void TileLoop_Industry(TileIndex tile)
if (IsIndustryTileOnWater(tile)) TileLoop_Water(tile); if (IsIndustryTileOnWater(tile)) TileLoop_Water(tile);
/* Normally this doesn't happen, but if an industry NewGRF is removed
* an industry that was previously build on water can now be flooded.
* If this happens the tile is no longer an industry tile after
* returning from TileLoop_Water. */
if (!IsTileType(tile, MP_INDUSTRY)) return;
TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP); TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);
if (!IsIndustryCompleted(tile)) { if (!IsIndustryCompleted(tile)) {
@ -1814,7 +1820,8 @@ static uint32 GetScaledIndustryProbability(IndustryType it, bool *force_at_least
const IndustrySpec *ind_spc = GetIndustrySpec(it); const IndustrySpec *ind_spc = GetIndustrySpec(it);
uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape] * 16; // * 16 to increase precision uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape] * 16; // * 16 to increase precision
if (!ind_spc->enabled || chance == 0 || ind_spc->num_table == 0 || if (!ind_spc->enabled || chance == 0 || ind_spc->num_table == 0 ||
!CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION) || _settings_game.difficulty.number_industries == 0) { !CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION) ||
(_game_mode != GM_EDITOR && _settings_game.difficulty.number_industries == 0)) {
*force_at_least_one = false; *force_at_least_one = false;
return 0; return 0;
} else { } else {
@ -1822,7 +1829,7 @@ static uint32 GetScaledIndustryProbability(IndustryType it, bool *force_at_least
* For simplicity we scale in both cases, though scaling the probabilities of all industries has no effect. */ * For simplicity we scale in both cases, though scaling the probabilities of all industries has no effect. */
chance = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(chance) : ScaleByMapSize(chance); chance = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(chance) : ScaleByMapSize(chance);
*force_at_least_one = (chance > 0) && !(ind_spc->behaviour & INDUSTRYBEH_NOBUILT_MAPCREATION); *force_at_least_one = (chance > 0) && !(ind_spc->behaviour & INDUSTRYBEH_NOBUILT_MAPCREATION) && (_game_mode != GM_EDITOR);
return chance; return chance;
} }
} }
@ -1862,7 +1869,8 @@ static void PlaceInitialIndustry(IndustryType type, bool try_hard)
void GenerateIndustries() void GenerateIndustries()
{ {
assert(_settings_game.difficulty.number_industries < lengthof(_numof_industry_table)); assert(_settings_game.difficulty.number_industries < lengthof(_numof_industry_table));
uint total_amount = ScaleByMapSize(_numof_industry_table[_settings_game.difficulty.number_industries]); uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_industries : 1;
uint total_amount = ScaleByMapSize(_numof_industry_table[difficulty]);
/* Do not create any industries? */ /* Do not create any industries? */
if (total_amount == 0) return; if (total_amount == 0) return;

View File

@ -114,16 +114,22 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *
_chatmessage_dirty = true; _chatmessage_dirty = true;
} }
/** Initialize all font-dependent chat box sizes. */
void NetworkReInitChatBoxSize()
{
_chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL;
_chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING) + 2;
_chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactoryBase::GetCurrentBlitter()->GetBytesPerPixel());
}
void NetworkInitChatMessage() void NetworkInitChatMessage()
{ {
MAX_CHAT_MESSAGES = _settings_client.gui.network_chat_box_height; MAX_CHAT_MESSAGES = _settings_client.gui.network_chat_box_height;
_chatmsg_list = ReallocT(_chatmsg_list, _settings_client.gui.network_chat_box_height); _chatmsg_list = ReallocT(_chatmsg_list, _settings_client.gui.network_chat_box_height);
_chatmsg_box.x = 10; _chatmsg_box.x = 10;
_chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL;
_chatmsg_box.width = _settings_client.gui.network_chat_box_width; _chatmsg_box.width = _settings_client.gui.network_chat_box_width;
_chatmsg_box.height = _settings_client.gui.network_chat_box_height * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING) + 2; NetworkReInitChatBoxSize();
_chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactoryBase::GetCurrentBlitter()->GetBytesPerPixel());
_chatmessage_visible = false; _chatmessage_visible = false;
for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) { for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) {

View File

@ -1775,7 +1775,7 @@ static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, no
bool GenerateTowns(TownLayout layout) bool GenerateTowns(TownLayout layout)
{ {
uint num = 0; uint num = 0;
uint difficulty = _settings_game.difficulty.number_towns; uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_towns : 0;
uint n = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7)); uint n = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7));
uint32 townnameparts; uint32 townnameparts;

View File

@ -776,7 +776,7 @@ static const NWidgetPart _nested_vehicle_list[] = {
EndContainer(), EndContainer(),
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_GREY, VLW_WIDGET_LIST), SetMinimalSize(248, 0), SetFill(1, 0), NWidget(WWT_MATRIX, COLOUR_GREY, VLW_WIDGET_LIST), SetMinimalSize(248, 0), SetFill(1, 0), SetResize(1, 1),
NWidget(WWT_SCROLLBAR, COLOUR_GREY, VLW_WIDGET_SCROLLBAR), NWidget(WWT_SCROLLBAR, COLOUR_GREY, VLW_WIDGET_SCROLLBAR),
EndContainer(), EndContainer(),
@ -1001,13 +1001,10 @@ public:
{ {
if (widget != VLW_WIDGET_LIST) return; if (widget != VLW_WIDGET_LIST) return;
resize->width = 0;
resize->height = GetVehicleListHeight(this->vehicle_type, 1); resize->height = GetVehicleListHeight(this->vehicle_type, 1);
switch (this->vehicle_type) { switch (this->vehicle_type) {
case VEH_TRAIN: case VEH_TRAIN:
resize->width = 1;
/* Fallthrough */
case VEH_ROAD: case VEH_ROAD:
size->height = 6 * resize->height; size->height = 6 * resize->height;
break; break;

View File

@ -2488,6 +2488,10 @@ void ReInitAllWindows()
FOR_ALL_WINDOWS_FROM_BACK(w) { FOR_ALL_WINDOWS_FROM_BACK(w) {
w->ReInit(); w->ReInit();
} }
#ifdef ENABLE_NETWORK
void NetworkReInitChatBoxSize();
NetworkReInitChatBoxSize();
#endif
/* Make sure essential parts of all windows are visible */ /* Make sure essential parts of all windows are visible */
RelocateAllWindows(_cur_resolution.width, _cur_resolution.height); RelocateAllWindows(_cur_resolution.width, _cur_resolution.height);