mirror of https://github.com/OpenTTD/OpenTTD
(svn r13735) [0.6] -Backport from trunk:
- Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction (r13734) - Fix: Assumption that non-north tiles of a house do not have the 1x1 building bit set was flawed with some NewGRFs. This caused the amount of houses to differ, which causes the town radii to differ, which causes desyncs when towns are expanded (r13729) - Fix: Possible desync on the autorenew settings 20+ game years (i.e. 4.5+ hours) after a company was started (r13718) - Fix: Any player could construct new companies [FS#2144] (r13716) - Fix: Possible crash on creating a network packet (r13713) - Fix: Enforce the length restrictions of company and president name in the commands too (r13712)release/0.6
parent
bafea078f2
commit
6097389437
|
@ -1,3 +1,13 @@
|
|||
0.6.2 ?? (2008-??-??)
|
||||
------------------------------------------------------------------------
|
||||
- Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction (r13734)
|
||||
- Fix: Assumption that non-north tiles of a house do not have the 1x1 building bit set was flawed with some NewGRFs. This caused the amount of houses to differ, which causes the town radii to differ, which causes desyncs when towns are expanded (r13729)
|
||||
- Fix: Possible desync on the autorenew settings 20+ game years (i.e. 4.5+ hours) after a company was started (r13718)
|
||||
- Fix: Any player could construct new companies [FS#2144] (r13716)
|
||||
- Fix: Possible crash on creating a network packet (r13713)
|
||||
- Fix: Enforce the length restrictions of company and president name in the commands too (r13712)
|
||||
|
||||
|
||||
0.6.2-RC1 (2008-07-16)
|
||||
------------------------------------------------------------------------
|
||||
- Fix: Possible buffer overflow in string truncation code (r13700)
|
||||
|
|
|
@ -225,14 +225,12 @@ static bool IsUniqueCompanyName(const char *name)
|
|||
*/
|
||||
CommandCost CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Player *p;
|
||||
|
||||
if (StrEmpty(_cmd_text)) return CMD_ERROR;
|
||||
if (StrEmpty(_cmd_text) || strlen(_cmd_text) > MAX_LENGTH_COMPANY_NAME) return CMD_ERROR;
|
||||
|
||||
if (!IsUniqueCompanyName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
p = GetPlayer(_current_player);
|
||||
Player *p = GetPlayer(_current_player);
|
||||
free(p->name);
|
||||
p->name = strdup(_cmd_text);
|
||||
MarkWholeScreenDirty();
|
||||
|
@ -264,14 +262,12 @@ static bool IsUniquePresidentName(const char *name)
|
|||
*/
|
||||
CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Player *p;
|
||||
|
||||
if (StrEmpty(_cmd_text)) return CMD_ERROR;
|
||||
if (StrEmpty(_cmd_text) || strlen(_cmd_text) > MAX_LENGTH_PRESIDENT_NAME) return CMD_ERROR;
|
||||
|
||||
if (!IsUniquePresidentName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
p = GetPlayer(_current_player);
|
||||
Player *p = GetPlayer(_current_player);
|
||||
free(p->president_name);
|
||||
p->president_name = strdup(_cmd_text);
|
||||
|
||||
|
|
|
@ -22,10 +22,11 @@ enum {
|
|||
SEND_MTU = 1460, ///< Number of bytes we can pack in a single packet
|
||||
|
||||
NETWORK_GAME_INFO_VERSION = 4, ///< What version of game-info do we use?
|
||||
NETWORK_COMPANY_INFO_VERSION = 4, ///< What version of company info is this?
|
||||
NETWORK_COMPANY_INFO_VERSION = 5, ///< What version of company info is this?
|
||||
NETWORK_MASTER_SERVER_VERSION = 1, ///< What version of master-server-protocol do we use?
|
||||
|
||||
NETWORK_NAME_LENGTH = 80, ///< The maximum length of the server name and map name, in bytes including '\0'
|
||||
NETWORK_COMPANY_NAME_LENGTH = 32, ///< The maximum length of the company name, in bytes including '\0'
|
||||
NETWORK_HOSTNAME_LENGTH = 80, ///< The maximum length of the host name, in bytes including '\0'
|
||||
NETWORK_UNIQUE_ID_LENGTH = 33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
|
||||
NETWORK_REVISION_LENGTH = 15, ///< The maximum length of the revision, in bytes including '\0'
|
||||
|
|
|
@ -45,6 +45,7 @@ bool _network_advertise; ///< is the server advertising to the master server?
|
|||
|
||||
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
|
||||
assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
|
||||
assert_compile((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME + 1);
|
||||
|
||||
// global variables (declared in network_data.h)
|
||||
CommandPacket *_local_command_queue;
|
||||
|
|
|
@ -901,7 +901,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
|
|||
* to match the player in the packet. If it doesn't, the client has done
|
||||
* something pretty naughty (or a bug), and will be kicked
|
||||
*/
|
||||
if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0) && ci->client_playas != cp->player) {
|
||||
if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0 && ci->client_playas == PLAYER_NEW_COMPANY) && ci->client_playas != cp->player) {
|
||||
IConsolePrintF(_icolour_err, "WARNING: player %d (IP: %s) tried to execute a command as player %d, kicking...",
|
||||
ci->client_playas + 1, GetPlayerIP(ci), cp->player + 1);
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
|
||||
|
|
|
@ -92,12 +92,6 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
|
|||
|
||||
DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
|
||||
{
|
||||
NetworkTCPSocketHandler *cs;
|
||||
NetworkClientInfo *ci;
|
||||
Player *player;
|
||||
byte current = 0;
|
||||
int i;
|
||||
|
||||
// Just a fail-safe.. should never happen
|
||||
if (!_network_udp_server) return;
|
||||
|
||||
|
@ -110,6 +104,8 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
/* Fetch the latest version of everything */
|
||||
NetworkPopulateCompanyInfo();
|
||||
|
||||
Player *player;
|
||||
byte current = 0;
|
||||
/* Go through all the players */
|
||||
FOR_ALL_PLAYERS(player) {
|
||||
/* Skip non-active players */
|
||||
|
@ -130,58 +126,15 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
/* Send 1 if there is a passord for the company else send 0 */
|
||||
packet.Send_bool (!StrEmpty(_network_player_info[player->index].password));
|
||||
|
||||
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
|
||||
for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
|
||||
packet.Send_uint16(_network_player_info[player->index].num_vehicle[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NETWORK_STATION_TYPES; i++)
|
||||
for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
|
||||
packet.Send_uint16(_network_player_info[player->index].num_station[i]);
|
||||
|
||||
/* Find the clients that are connected to this player */
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
ci = DEREF_CLIENT_INFO(cs);
|
||||
if (ci->client_playas == player->index) {
|
||||
packet.Send_bool (true);
|
||||
packet.Send_string(ci->client_name);
|
||||
packet.Send_string(ci->unique_id);
|
||||
packet.Send_uint32(ci->join_date);
|
||||
}
|
||||
}
|
||||
/* Also check for the server itself */
|
||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
||||
if (ci->client_playas == player->index) {
|
||||
packet.Send_bool (true);
|
||||
packet.Send_string(ci->client_name);
|
||||
packet.Send_string(ci->unique_id);
|
||||
packet.Send_uint32(ci->join_date);
|
||||
}
|
||||
|
||||
/* Indicates end of client list */
|
||||
packet.Send_bool(false);
|
||||
}
|
||||
|
||||
/* And check if we have any spectators */
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
ci = DEREF_CLIENT_INFO(cs);
|
||||
if (!IsValidPlayer(ci->client_playas)) {
|
||||
packet.Send_bool (true);
|
||||
packet.Send_string(ci->client_name);
|
||||
packet.Send_string(ci->unique_id);
|
||||
packet.Send_uint32(ci->join_date);
|
||||
}
|
||||
}
|
||||
|
||||
/* Also check for the server itself */
|
||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
||||
if (!IsValidPlayer(ci->client_playas)) {
|
||||
packet.Send_bool (true);
|
||||
packet.Send_string(ci->client_name);
|
||||
packet.Send_string(ci->unique_id);
|
||||
packet.Send_uint32(ci->join_date);
|
||||
}
|
||||
|
||||
/* Indicates end of client list */
|
||||
packet.Send_bool(false);
|
||||
|
||||
this->SendPacket(&packet, client_addr);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ static BuildingCounts _building_counts;
|
|||
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
|
||||
|
||||
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID);
|
||||
extern TileIndex GetHouseNorthPart(HouseID &house);
|
||||
|
||||
/**
|
||||
* Check and update town and house values.
|
||||
|
@ -67,12 +68,8 @@ void UpdateHousesAndTowns()
|
|||
IncreaseBuildingCount(town, house_id);
|
||||
if (IsHouseCompleted(t)) town->population += GetHouseSpecs(house_id)->population;
|
||||
|
||||
/* Increase the number of houses for every house tile which
|
||||
* has a size bit set. Multi tile buildings have got only
|
||||
* one tile with such a bit set, so there is no problem. */
|
||||
if (GetHouseSpecs(GetHouseType(t))->building_flags & BUILDING_HAS_1_TILE) {
|
||||
town->num_houses++;
|
||||
}
|
||||
/* Increase the number of houses for every house, but only once. */
|
||||
if (GetHouseNorthPart(house_id) == 0) town->num_houses++;
|
||||
}
|
||||
|
||||
/* Update the population and num_house dependant values */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "gfx_func.h"
|
||||
#include "date_func.h"
|
||||
#include "player_func.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
@ -291,11 +292,18 @@ static uint32 GetRailContinuationInfo(TileIndex tile)
|
|||
uint i;
|
||||
|
||||
for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
|
||||
TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0));
|
||||
TileIndex neighbour_tile = tile + TileOffsByDir(*dir);
|
||||
TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(neighbour_tile, TRANSPORT_RAIL, 0));
|
||||
if (trackbits != TRACK_BIT_NONE) {
|
||||
/* If there is any track on the tile, set the bit in the second byte */
|
||||
SetBit(res, i + 8);
|
||||
|
||||
/* With tunnels and bridges the tile has tracks, but they are not necessarily connected
|
||||
* with the next tile because the ramp is not going in the right direction. */
|
||||
if (IsTileType(neighbour_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(neighbour_tile) != *diagdir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If any track reaches our exit direction, set the bit in the lower byte */
|
||||
if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
|
||||
}
|
||||
|
|
|
@ -1181,7 +1181,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||
const Player *p = GetPlayer((PlayerID)w->window_number);
|
||||
WP(w, def_d).byte_1 = 0;
|
||||
SetDParam(0, p->index);
|
||||
ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL);
|
||||
ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME, 94, w, CS_ALPHANUMERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||
Player *p = GetPlayer((PlayerID)w->window_number);
|
||||
WP(w, def_d).byte_1 = 1;
|
||||
SetDParam(0, p->index);
|
||||
ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
|
||||
ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_PRESIDENT_NAME, 150, w, CS_ALPHANUMERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ enum Owner {
|
|||
};
|
||||
DECLARE_POSTFIX_INCREMENT(Owner);
|
||||
|
||||
enum {
|
||||
MAX_LENGTH_PRESIDENT_NAME = 31, ///< The maximum length for a president's name
|
||||
MAX_LENGTH_COMPANY_NAME = 31, ///< The maximum length for a company's name
|
||||
};
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
||||
typedef TinyEnumT<Owner> OwnerByte;
|
||||
|
|
|
@ -841,18 +841,21 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
NetworkChangeCompanyPassword(1, &password);
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
_current_player = _local_player;
|
||||
|
||||
/* Now that we have a new player, broadcast our autorenew settings to
|
||||
* all clients so everything is in sync */
|
||||
NetworkSend_Command(0,
|
||||
(_patches_newgame.autorenew << 15 ) | (_patches_newgame.autorenew_months << 16) | 4,
|
||||
_patches_newgame.autorenew_money,
|
||||
CMD_SET_AUTOREPLACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
/* Now that we have a new player, broadcast its autorenew settings to
|
||||
* all clients so everything is in sync */
|
||||
DoCommand(0,
|
||||
(_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4,
|
||||
_patches.autorenew_money,
|
||||
DC_EXEC,
|
||||
CMD_SET_AUTOREPLACE
|
||||
);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) {
|
||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
||||
|
|
|
@ -1983,7 +1983,7 @@ static void DoClearTownHouseHelper(TileIndex tile, Town *t, HouseID house)
|
|||
* @param house Is changed to the HouseID of the north tile of the same house
|
||||
* @return TileDiff from the tile of the given HouseID to the north tile
|
||||
*/
|
||||
static TileIndex GetHouseNorthPart(HouseID &house)
|
||||
TileIndex GetHouseNorthPart(HouseID &house)
|
||||
{
|
||||
if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
|
||||
if (GetHouseSpecs(house - 1)->building_flags & TILE_SIZE_2x1) {
|
||||
|
|
Loading…
Reference in New Issue