(svn r15775) [0.7] -Backport from trunk:

- Fix: Do not show the message about reporting an AI crash for the dummy AI (r15774)
- Fix: Number of active clients was not always properly updated [FS#2475] (r15773)
- Fix: Settings from the [gameopt] section (from old 0.6 config files) were overwritten with default values (r15771)
- Fix: Infinite loop when skipping sprites when a GRF is invalid (or truncated) (r15767)
- Fix: Crash when opening the content list window twice; inconsistencies when clicking download twice [FS#2744] (r15766)
This commit is contained in:
rubidium 2009-03-19 23:50:54 +00:00
parent 61e97110c9
commit 30afba1d10
8 changed files with 23 additions and 31 deletions

View File

@ -255,7 +255,9 @@ void AIInstance::Died()
this->engine = NULL;
ShowAIDebugWindow(_current_company);
ShowErrorMessage(INVALID_STRING_ID, STR_AI_PLEASE_REPORT_CRASH, 0, 0);
if (strcmp(GetCompany(_current_company)->ai_info->GetMainScript(), "%_dummy") != 0) {
ShowErrorMessage(INVALID_STRING_ID, STR_AI_PLEASE_REPORT_CRASH, 0, 0);
}
}
void AIInstance::GameLoop()

View File

@ -346,7 +346,7 @@ static uint NetworkCountActiveClients()
static bool _min_active_clients_paused = false;
/* Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate */
void CheckMinActiveClients()
static void CheckMinActiveClients()
{
if (!_network_dedicated) return;
@ -466,8 +466,6 @@ void NetworkCloseClient(NetworkClientSocket *cs)
delete cs->GetInfo();
delete cs;
CheckMinActiveClients();
}
/* For the server, to accept new clients */
@ -820,7 +818,6 @@ bool NetworkServerStart()
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
_min_active_clients_paused = false;
CheckMinActiveClients();
/* Try to register us to the master server */
_network_last_advertise_frame = 0;
@ -1028,6 +1025,7 @@ void NetworkGameLoop()
cp->company = (CompanyID)company;
}
#endif /* DEBUG_DUMP_COMMANDS */
CheckMinActiveClients();
bool send_frame = false;

View File

@ -95,7 +95,7 @@ public:
/* Yes... these are the NewGRF windows */
InvalidateWindowClasses(WC_SAVELOAD);
InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
InvalidateWindowData(WC_NETWORK_WINDOW, 0, 2);
InvalidateWindowData(WC_NETWORK_WINDOW, 1, 2);
break;
case CONTENT_TYPE_SCENARIO:
@ -319,7 +319,7 @@ public:
* Create the content list window.
* @param desc the window description to pass to Window's constructor.
*/
NetworkContentListWindow(const WindowDesc *desc, bool select_all) : QueryStringBaseWindow(EDITBOX_MAX_SIZE, desc), selected(NULL), list_pos(0)
NetworkContentListWindow(const WindowDesc *desc, bool select_all) : QueryStringBaseWindow(EDITBOX_MAX_SIZE, desc, 1), selected(NULL), list_pos(0)
{
ttd_strlcpy(this->edit_str_buf, "", this->edit_str_size);
this->afilter = CS_ALPHANUMERAL;
@ -383,7 +383,7 @@ public:
}
}
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0);
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0 || FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL);
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
@ -594,7 +594,7 @@ public:
break;
case NCLWW_DOWNLOAD:
new NetworkContentDownloadStatusWindow();
if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, 0) == NULL) new NetworkContentDownloadStatusWindow();
break;
}
}
@ -782,6 +782,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
_network_content_client.RequestContentList(cv, true);
}
DeleteWindowById(WC_NETWORK_WINDOW, 1);
new NetworkContentListWindow(&_network_content_list_desc, cv != NULL);
#else
ShowErrorMessage(STR_CONTENT_NO_ZLIB_SUB, STR_CONTENT_NO_ZLIB, 0, 0);

View File

@ -24,7 +24,6 @@ extern char *_network_host_list[10];
extern char *_network_ban_list[25];
byte NetworkSpectatorCount();
void CheckMinActiveClients();
void NetworkUpdateClientName();
bool NetworkCompanyHasClients(CompanyID company);
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);

View File

@ -1018,8 +1018,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT);
}
CheckMinActiveClients();
/* Execute script for, e.g. MOTD */
IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
}
@ -1752,8 +1750,6 @@ void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
NetworkAction action = (company_id == COMPANY_SPECTATOR) ? NETWORK_ACTION_COMPANY_SPECTATOR : NETWORK_ACTION_COMPANY_JOIN;
NetworkServerSendChat(action, DESTTYPE_BROADCAST, 0, "", client_id, company_id + 1);
CheckMinActiveClients();
}
void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string)

View File

@ -1163,12 +1163,6 @@ static bool ChangeDynamicEngines(int32 p1)
#ifdef ENABLE_NETWORK
static bool UpdateMinActiveClients(int32 p1)
{
CheckMinActiveClients();
return true;
}
static bool UpdateClientName(int32 p1)
{
NetworkUpdateClientName();
@ -1279,7 +1273,7 @@ static const SettingDesc _gameopt_settings[] = {
* 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
* for savegames version 0 - though it is an array, it has to go through the byteswap process */
SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16, C, 0, _old_diff_custom, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, 0, 3),
SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, C, 0, _old_diff_custom, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, 4, 96),
SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, C, 0, _old_diff_custom, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, 4, SL_MAX_VERSION),
SDT_VAR(GameSettings, difficulty.diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
SDT_OMANY(GameSettings, locale.currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRL|EEK|custom", STR_NULL, NULL, NULL),
@ -1577,7 +1571,7 @@ const SettingDesc _settings[] = {
SDTC_VAR(network.max_clients, SLE_UINT8, S, NO, 16, 2, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_VAR(network.max_spectators, SLE_UINT8, S, NO, 8, 0, MAX_CLIENTS, 0, STR_NULL, UpdateClientConfigValues),
SDTC_VAR(network.restart_game_year, SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, MAX_CLIENTS, 0, STR_NULL, UpdateMinActiveClients),
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_OMANY(network.server_lang, SLE_UINT8, S, NO, 0, 35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
SDTC_BOOL(network.reload_cfg, S, NO, false, STR_NULL, NULL),
SDTC_STR(network.last_host, SLE_STRB, S, 0, "0.0.0.0", STR_NULL, NULL),
@ -1907,15 +1901,16 @@ void LoadFromConfig()
IniFile *ini = IniLoadConfig();
ResetCurrencies(false); // Initialize the array of curencies, without preserving the custom one
PrepareOldDiffCustom();
ini_load_settings(ini, _gameopt_settings, "gameopt", &_settings_newgame);
HandleOldDiffCustom(false);
HandleSettingDescs(ini, ini_load_settings, ini_load_setting_list);
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);
NewsDisplayLoadConfig(ini, "news_display");
AILoadConfig(ini, "ai_players");
PrepareOldDiffCustom();
ini_load_settings(ini, _gameopt_settings, "gameopt", &_settings_newgame);
HandleOldDiffCustom(false);
CheckDifficultyLevels();
delete ini;
}

View File

@ -58,6 +58,6 @@ struct DrawBuildingsTileStruct {
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
void SkipSpriteData(byte type, uint16 num);
bool SkipSpriteData(byte type, uint16 num);
#endif /* SPRITE_H */

View File

@ -80,8 +80,9 @@ static void CompactSpriteCache();
* Skip the given amount of sprite graphics data.
* @param type the type of sprite (compressed etc)
* @param num the amount of sprites to skip
* @return true if the data could be correctly skipped.
*/
void SkipSpriteData(byte type, uint16 num)
bool SkipSpriteData(byte type, uint16 num)
{
if (type & 2) {
FioSkipBytes(num);
@ -90,6 +91,7 @@ void SkipSpriteData(byte type, uint16 num)
int8 i = FioReadByte();
if (i >= 0) {
int size = (i == 0) ? 0x80 : i;
if (size > num) return false;
num -= size;
FioSkipBytes(size);
} else {
@ -99,6 +101,7 @@ void SkipSpriteData(byte type, uint16 num)
}
}
}
return true;
}
/**
@ -120,9 +123,7 @@ static SpriteType ReadSpriteHeaderSkipData()
}
FioSkipBytes(7);
SkipSpriteData(type, num - 8);
return ST_NORMAL;
return SkipSpriteData(type, num - 8) ? ST_NORMAL : ST_INVALID;
}
/* Check if the given Sprite ID exists */