1
0
Fork 0

(svn r22701) [1.1] -Backport from trunk:

- Fix: [Network] Failed network address resolving could trigger temporary freezes [FS#4697] (r22696, r22695)
- Fix: [NewGRF] The override managers were not reset in some cases like creating a new scenario [FS#4691] (r22693)
- Fix: [NewGRF] Aircrafts defined with IDs above the default aircrafts always defaulted to passenger cargo (r22690)
release/1.1
rubidium 2011-07-30 17:45:37 +00:00
parent 4b800313f4
commit a51531e410
12 changed files with 37 additions and 26 deletions

View File

@ -560,12 +560,12 @@ Function CheckWindowsVersion
StrCmp $R0 "win9x" 0 WinNT
ClearErrors
StrCmp ${APPARCH} "win9x" Done 0
MessageBox MB_OKCANCEL|MB_ICONSTOP "You are trying to install the Windows 2000, XP and Vista version on Windows 95, 98 or ME. This is will not work. Please download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
MessageBox MB_OKCANCEL|MB_ICONSTOP "You are trying to install the Windows 2000, XP, Vista and 7 version on Windows 95, 98 or ME. This is will not work. Please download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
GoTo Done
WinNT:
ClearErrors
StrCmp ${APPARCH} "win9x" 0 Done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You are trying to install the Windows 95, 98 and ME version on Windows 2000, XP or Vista. This is not advised, but will work with reduced capabilities. We suggest that you download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You are trying to install the Windows 95, 98 and ME version on Windows 2000, XP, Vista or 7. This is not advised, but will work with reduced capabilities. We suggest that you download the correct version. Do you really want to continue?" IDOK Done IDCANCEL Abort
Abort:
Quit
Done:

View File

@ -91,6 +91,8 @@ Engine::Engine(VehicleType type, EngineID base)
this->info.base_life = 0xFF;
/* Set road vehicle tractive effort to the default value */
if (type == VEH_ROAD) this->u.road.tractive_effort = 0x4C;
/* Aircraft must have CT_INVALID as default, as there is no property */
if (type == VEH_AIRCRAFT) this->info.cargo_type = CT_INVALID;
/* Set visual effect to the default value */
switch (type) {
case VEH_TRAIN: this->u.rail.visual_effect = VE_DEFAULT; break;

View File

@ -14,6 +14,7 @@
#include "news_func.h"
#include "ai/ai.hpp"
#include "ai/ai_gui.hpp"
#include "newgrf.h"
#include "newgrf_house.h"
#include "group.h"
#include "economy_func.h"
@ -77,6 +78,8 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
InitializeOldNames();
}
ResetPersistentNewGRFData();
InitializeSound();
InitializeMusic();

View File

@ -132,6 +132,7 @@ const sockaddr_storage *NetworkAddress::GetAddress()
* that means "don't care whether it is SOCK_STREAM or SOCK_DGRAM".
*/
this->Resolve(this->address.ss_family, SOCK_STREAM, AI_ADDRCONFIG, NULL, ResolveLoopProc);
this->resolved = true;
}
return &this->address;
}

View File

@ -33,6 +33,7 @@ private:
char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname
int address_length; ///< The length of the resolved address
sockaddr_storage address; ///< The resolved address
bool resolved; ///< Whether the address has been (tried to be) resolved
/**
* Helper function to resolve something to a socket.
@ -49,7 +50,8 @@ public:
*/
NetworkAddress(struct sockaddr_storage &address, int address_length) :
address_length(address_length),
address(address)
address(address),
resolved(address_length != 0)
{
*this->hostname = '\0';
}
@ -59,7 +61,8 @@ public:
* @param address the IP address with port
*/
NetworkAddress(sockaddr *address, int address_length) :
address_length(address_length)
address_length(address_length),
resolved(address_length != 0)
{
*this->hostname = '\0';
memset(&this->address, 0, sizeof(this->address));
@ -73,7 +76,8 @@ public:
* @param family the address family
*/
NetworkAddress(const char *hostname = "", uint16 port = 0, int family = AF_UNSPEC) :
address_length(0)
address_length(0),
resolved(false)
{
/* Also handle IPv6 bracket enclosed hostnames */
if (StrEmpty(hostname)) hostname = "";
@ -121,7 +125,7 @@ public:
*/
bool IsResolved() const
{
return this->address_length != 0;
return this->resolved;
}
bool IsFamily(int family);

View File

@ -832,7 +832,6 @@ void NetworkUDPGameLoop()
} else {
_udp_client_socket->ReceivePackets();
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
NetworkGameListRequery();
}
}

View File

@ -890,6 +890,11 @@ public:
this->vscroll->SetCapacityFromWidget(this, NGWW_MATRIX);
this->GetWidget<NWidgetCore>(NGWW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
virtual void OnTick()
{
NetworkGameListRequery();
}
};
Listing NetworkGameWindow::last_sorting = {false, 5};

View File

@ -473,9 +473,9 @@ static void NetworkUDPQueryServerThread(void *pntr)
/* Clear item in gamelist */
NetworkGameList *item = CallocT<NetworkGameList>(1);
item->address = *info;
info->GetAddressAsString(item->info.server_name, lastof(item->info.server_name));
strecpy(item->info.hostname, info->GetHostname(), lastof(item->info.hostname));
item->address = *info;
item->manually = info->manually;
NetworkGameListAddItemDelayed(item);

View File

@ -7326,6 +7326,20 @@ void ResetNewGRFData()
_spritegroup_pool.CleanPool();
}
/**
* Reset NewGRF data which is stored persistently in savegames.
*/
void ResetPersistentNewGRFData()
{
/* Reset override managers */
_engine_mngr.ResetToDefaultMapping();
_house_mngr.ResetMapping();
_industry_mngr.ResetMapping();
_industile_mngr.ResetMapping();
_airport_mngr.ResetMapping();
_airporttile_mngr.ResetMapping();
}
static void BuildCargoTranslationMap()
{
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map));

View File

@ -163,6 +163,7 @@ void LoadNewGRFFile(struct GRFConfig *config, uint file_index, GrfLoadingStage s
void LoadNewGRF(uint load_index, uint file_index);
void ReloadNewGRFData(); // in saveload/afterload.cpp
void ResetNewGRFData();
void ResetPersistentNewGRFData();
void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);

View File

@ -300,17 +300,6 @@ static void ParseResolution(Dimension *res, const char *s)
res->height = max(strtoul(t + 1, NULL, 0), 64UL);
}
static void InitializeDynamicVariables()
{
/* Dynamic stuff needs to be initialized somewhere... */
_engine_mngr.ResetToDefaultMapping();
_house_mngr.ResetMapping();
_industry_mngr.ResetMapping();
_industile_mngr.ResetMapping();
_airport_mngr.ResetMapping();
_airporttile_mngr.ResetMapping();
}
/**
* Unitializes drivers, frees allocated memory, cleans pools, ...
@ -610,9 +599,6 @@ int ttd_main(int argc, char *argv[])
/* initialize screenshot formats */
InitializeScreenshotFormats();
/* initialize all variables that are allocated dynamically */
InitializeDynamicVariables();
/* Initialize FreeType */
InitFreeType();
@ -837,7 +823,6 @@ static void MakeNewGame(bool from_heightmap, bool reset_settings)
_game_mode = GM_NORMAL;
ResetGRFConfig(true);
InitializeDynamicVariables();
GenerateWorldSetCallback(&MakeNewGameDone);
GenerateWorld(from_heightmap ? GWM_HEIGHTMAP : GWM_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y, reset_settings);

View File

@ -2548,8 +2548,6 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
_next_offs = 0;
if (!load_check) {
_engine_mngr.ResetToDefaultMapping();
/* Old maps were hardcoded to 256x256 and thus did not contain
* any mapsize information. Pre-initialize to 256x256 to not to
* confuse old games */
@ -2653,7 +2651,6 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo
/* Load a TTDLX or TTDPatch game */
if (mode == SL_OLD_LOAD) {
_engine_mngr.ResetToDefaultMapping();
InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
/* TTD/TTO savegames have no NewGRFs, TTDP savegame have them