1
0
Fork 0

(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
rubidium 2010-04-21 19:20:28 +00:00
parent 2dee7158d3
commit 706d321f52
7 changed files with 41 additions and 19 deletions

View File

@ -85,6 +85,7 @@ enum ClientStatus {
STATUS_DONE_MAP, ///< The client has downloaded the map
STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames
STATUS_ACTIVE, ///< The client is active within in the game
STATUS_END ///< Must ALWAYS be on the end of this list!! (period)
};
class NetworkClientSocket;

View File

@ -453,8 +453,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
if (MY_CLIENT->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
if (!Company::IsValidID(playas)) playas = COMPANY_SPECTATOR;
ci = NetworkFindClientInfoFromClientID(client_id);
if (ci != NULL) {
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,
* 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;
strecpy(ci->client_name, name, lastof(ci->client_name));

View File

@ -373,19 +373,38 @@ static bool GunzipFile(const ContentInfo *ci)
if (fin == NULL || fout == NULL) {
ret = false;
goto exit;
}
byte buff[8192];
while (!gzeof(fin)) {
int read = gzread(fin, buff, sizeof(buff));
if (read < 0 || (size_t)read != fwrite(buff, 1, read, fout)) {
ret = false;
break;
} else {
byte buff[8192];
while (1) {
int read = gzread(fin, buff, sizeof(buff));
if (read == 0) {
/* If gzread() returns 0, either the end-of-file has been
* reached or an underlying read error has occurred.
*
* 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) {
/* Closes ftmp too! */
gzclose(fin);

View File

@ -1703,7 +1703,8 @@ void NetworkServerShowStatusToConsole()
{
static const char * const stat_str[] = {
"inactive",
"authorizing",
"authorizing (server password)",
"authorizing (company password)",
"authorized",
"waiting",
"loading map",
@ -1711,6 +1712,7 @@ void NetworkServerShowStatusToConsole()
"ready",
"active"
};
assert_compile(lengthof(stat_str) == STATUS_END);
NetworkClientSocket *cs;
FOR_ALL_CLIENT_SOCKETS(cs) {

View File

@ -1208,8 +1208,6 @@ void StateGameLoop()
CallWindowTickEvent();
NewsLoop();
} else {
CheckCaches();
if (_debug_desync_level > 2 && _date_fract == 0 && (_date & 0x1F) == 0) {
/* Save the desync savegame if needed. */
char name[MAX_PATH];
@ -1217,6 +1215,8 @@ void StateGameLoop()
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
}
CheckCaches();
/* All these actions has to be done from OWNER_NONE
* for multiplayer compatibility */
CompanyID old_company = _current_company;

View File

@ -66,9 +66,11 @@ enum RoadBits {
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_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);
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 */

View File

@ -481,7 +481,7 @@ int Train::GetCurrentMaxSpeed() const
int st_max_speed = 120;
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);
}