mirror of https://github.com/OpenTTD/OpenTTD
(svn r19690) [1.0] -Backport from trunk:
- Fix: Desync when joining the game because of using the wrong variable (r19687) - Fix: Truncated archives were not detected when using zlib 1.2.3. This also fixes zlib 1.2.4 compatibility, zlib 1.2.5 is bugfree (r19686) - Fix: Towns with 3x3 and 2x2 road layouts could not expand (r19683) - Fix: When joining a MP game all clients with company ID > 0 would be shown as if they were a spectator [FS#3775] (r19680) - Fix: Client status was shown incorrect in the console (r19678)release/1.0
parent
2dee7158d3
commit
706d321f52
|
@ -85,6 +85,7 @@ enum ClientStatus {
|
||||||
STATUS_DONE_MAP, ///< The client has downloaded the map
|
STATUS_DONE_MAP, ///< The client has downloaded the map
|
||||||
STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames
|
STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames
|
||||||
STATUS_ACTIVE, ///< The client is active within in the game
|
STATUS_ACTIVE, ///< The client is active within in the game
|
||||||
|
STATUS_END ///< Must ALWAYS be on the end of this list!! (period)
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetworkClientSocket;
|
class NetworkClientSocket;
|
||||||
|
|
|
@ -453,8 +453,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
|
||||||
|
|
||||||
if (MY_CLIENT->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
|
if (MY_CLIENT->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
|
||||||
|
|
||||||
if (!Company::IsValidID(playas)) playas = COMPANY_SPECTATOR;
|
|
||||||
|
|
||||||
ci = NetworkFindClientInfoFromClientID(client_id);
|
ci = NetworkFindClientInfoFromClientID(client_id);
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
|
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
|
||||||
|
@ -467,7 +465,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
|
||||||
|
|
||||||
/* Make sure we're in the company the server tells us to be in,
|
/* Make sure we're in the company the server tells us to be in,
|
||||||
* for the rare case that we get moved while joining. */
|
* for the rare case that we get moved while joining. */
|
||||||
if (client_id == _network_own_client_id) SetLocalCompany(playas);
|
if (client_id == _network_own_client_id) SetLocalCompany(!Company::IsValidID(playas) ? COMPANY_SPECTATOR : playas);
|
||||||
|
|
||||||
ci->client_playas = playas;
|
ci->client_playas = playas;
|
||||||
strecpy(ci->client_name, name, lastof(ci->client_name));
|
strecpy(ci->client_name, name, lastof(ci->client_name));
|
||||||
|
|
|
@ -373,19 +373,38 @@ static bool GunzipFile(const ContentInfo *ci)
|
||||||
|
|
||||||
if (fin == NULL || fout == NULL) {
|
if (fin == NULL || fout == NULL) {
|
||||||
ret = false;
|
ret = false;
|
||||||
goto exit;
|
} else {
|
||||||
}
|
byte buff[8192];
|
||||||
|
while (1) {
|
||||||
byte buff[8192];
|
int read = gzread(fin, buff, sizeof(buff));
|
||||||
while (!gzeof(fin)) {
|
if (read == 0) {
|
||||||
int read = gzread(fin, buff, sizeof(buff));
|
/* If gzread() returns 0, either the end-of-file has been
|
||||||
if (read < 0 || (size_t)read != fwrite(buff, 1, read, fout)) {
|
* reached or an underlying read error has occurred.
|
||||||
ret = false;
|
*
|
||||||
break;
|
* gzeof() can't be used, because:
|
||||||
|
* 1.2.5 - it is safe, 1 means 'everything was OK'
|
||||||
|
* 1.2.3.5, 1.2.4 - 0 or 1 is returned 'randomly'
|
||||||
|
* 1.2.3.3 - 1 is returned for truncated archive
|
||||||
|
*
|
||||||
|
* So we use gzerror(). When proper end of archive
|
||||||
|
* has been reached, then:
|
||||||
|
* errnum == Z_STREAM_END in 1.2.3.3,
|
||||||
|
* errnum == 0 in 1.2.4 and 1.2.5 */
|
||||||
|
int errnum;
|
||||||
|
gzerror(fin, &errnum);
|
||||||
|
if (errnum != 0 && errnum != Z_STREAM_END) ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (read < 0 || (size_t)read != fwrite(buff, 1, read, fout)) {
|
||||||
|
/* If gzread() returns -1, there was an error in archive */
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* DO NOT DO THIS! It will fail to detect broken archive with 1.2.3.3!
|
||||||
|
* if (read < sizeof(buff)) break; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
|
||||||
if (fin != NULL) {
|
if (fin != NULL) {
|
||||||
/* Closes ftmp too! */
|
/* Closes ftmp too! */
|
||||||
gzclose(fin);
|
gzclose(fin);
|
||||||
|
|
|
@ -1703,7 +1703,8 @@ void NetworkServerShowStatusToConsole()
|
||||||
{
|
{
|
||||||
static const char * const stat_str[] = {
|
static const char * const stat_str[] = {
|
||||||
"inactive",
|
"inactive",
|
||||||
"authorizing",
|
"authorizing (server password)",
|
||||||
|
"authorizing (company password)",
|
||||||
"authorized",
|
"authorized",
|
||||||
"waiting",
|
"waiting",
|
||||||
"loading map",
|
"loading map",
|
||||||
|
@ -1711,6 +1712,7 @@ void NetworkServerShowStatusToConsole()
|
||||||
"ready",
|
"ready",
|
||||||
"active"
|
"active"
|
||||||
};
|
};
|
||||||
|
assert_compile(lengthof(stat_str) == STATUS_END);
|
||||||
|
|
||||||
NetworkClientSocket *cs;
|
NetworkClientSocket *cs;
|
||||||
FOR_ALL_CLIENT_SOCKETS(cs) {
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
||||||
|
|
|
@ -1208,8 +1208,6 @@ void StateGameLoop()
|
||||||
CallWindowTickEvent();
|
CallWindowTickEvent();
|
||||||
NewsLoop();
|
NewsLoop();
|
||||||
} else {
|
} else {
|
||||||
CheckCaches();
|
|
||||||
|
|
||||||
if (_debug_desync_level > 2 && _date_fract == 0 && (_date & 0x1F) == 0) {
|
if (_debug_desync_level > 2 && _date_fract == 0 && (_date & 0x1F) == 0) {
|
||||||
/* Save the desync savegame if needed. */
|
/* Save the desync savegame if needed. */
|
||||||
char name[MAX_PATH];
|
char name[MAX_PATH];
|
||||||
|
@ -1217,6 +1215,8 @@ void StateGameLoop()
|
||||||
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
|
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckCaches();
|
||||||
|
|
||||||
/* All these actions has to be done from OWNER_NONE
|
/* All these actions has to be done from OWNER_NONE
|
||||||
* for multiplayer compatibility */
|
* for multiplayer compatibility */
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
|
|
|
@ -66,9 +66,11 @@ enum RoadBits {
|
||||||
ROAD_S = ROAD_SE | ROAD_SW, ///< Road at the two southern edges
|
ROAD_S = ROAD_SE | ROAD_SW, ///< Road at the two southern edges
|
||||||
ROAD_W = ROAD_NW | ROAD_SW, ///< Road at the two western edges
|
ROAD_W = ROAD_NW | ROAD_SW, ///< Road at the two western edges
|
||||||
|
|
||||||
ROAD_ALL = ROAD_X | ROAD_Y ///< Full 4-way crossing
|
ROAD_ALL = ROAD_X | ROAD_Y, ///< Full 4-way crossing
|
||||||
|
|
||||||
|
ROAD_END = ROAD_ALL + 1 ///< Out-of-range roadbits, used for iterations
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(RoadBits);
|
DECLARE_ENUM_AS_BIT_SET(RoadBits);
|
||||||
template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_ALL, ROAD_NONE, 4> {};
|
template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_END, ROAD_NONE, 4> {};
|
||||||
|
|
||||||
#endif /* ROAD_TYPE_H */
|
#endif /* ROAD_TYPE_H */
|
||||||
|
|
|
@ -481,7 +481,7 @@ int Train::GetCurrentMaxSpeed() const
|
||||||
int st_max_speed = 120;
|
int st_max_speed = 120;
|
||||||
|
|
||||||
int delta_v = this->cur_speed / (distance_to_go + 1);
|
int delta_v = this->cur_speed / (distance_to_go + 1);
|
||||||
if (this->max_speed > (this->cur_speed - delta_v)) {
|
if (max_speed > (this->cur_speed - delta_v)) {
|
||||||
st_max_speed = this->cur_speed - (delta_v / 10);
|
st_max_speed = this->cur_speed - (delta_v / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue