(svn r9849) [0.5] -Backport from trunk (r9693, r9694, r9697, r9718, r9719, r9725 and 9726):
- Fix: Crash when destroying bridge with train partially on it [FS#738] (r9726)
- Fix: Planes made a 270 degree turn instead of a 90 degree turn on the southern runway of the intercontinental airport [FS#743] (r9725)
- Fix: In-game private messages did not work for clients with high ClientIDs (r9719)
- Fix: Do not allow building of rail vehicles whose railtype is not available (r9718)
- Fix: [YAPF] The guessed path was ignored for ships [FS#736] (r9694)
--- a/airport_movement.h Fri Apr 20 19:45:38 2007 +0000
+++ b/airport_movement.h Tue May 15 21:24:18 2007 +0000
@@ -261,7 +261,7 @@
{ 136, 96, AMED_HELI_LOWER, 0 }, // 56 Land in front of hangar2
{ 126, 104, 0, 3 }, // 57 Outway 2
{ 136, 136, 0, 1 }, // 58 Airport OUTWAY 2
- { 136, 152, AMED_EXACTPOS, 5 }, // 59 Accelerate to end of runway2
+ { 136, 152, AMED_EXACTPOS, 1 }, // 59 Accelerate to end of runway2
{ 16, 152, AMED_NOSPDCLAMP, 0 }, // 60 Release control of runway2, for smoother movement
{ 20, 152, AMED_NOSPDCLAMP, 0 }, // 61 End of runway2
{ -56, 152, AMED_NOSPDCLAMP | AMED_TAKEOFF, 0 }, // 62 Take off2
--- a/engine.c Fri Apr 20 19:45:38 2007 +0000
+++ b/engine.c Tue May 15 21:24:18 2007 +0000
@@ -414,6 +414,12 @@
// check if it's available
if (!HASBIT(e->player_avail, player)) return false;
+ if (type == VEH_Train) {
+ /* Check if the rail type is available to this player */
+ const Player *p = GetPlayer(player);
+ if (!HASBIT(p->avail_railtypes, EngInfo(engine)->railtype)) return false;
+ }
+
return true;
}
--- a/network_client.c Fri Apr 20 19:45:38 2007 +0000
+++ b/network_client.c Tue May 15 21:24:18 2007 +0000
@@ -183,7 +183,7 @@
// Data:
// uint8: ActionID (see network_data.h, NetworkAction)
// uint8: Destination Type (see network_data.h, DestType);
- // uint8: Destination Player (1..MAX_PLAYERS)
+ // uint16: Destination Player
// String: Message (max MAX_TEXT_MSG_LEN)
//
@@ -191,7 +191,7 @@
NetworkSend_uint8(p, action);
NetworkSend_uint8(p, type);
- NetworkSend_uint8(p, dest);
+ NetworkSend_uint16(p, dest);
NetworkSend_string(p, msg);
NetworkSend_Packet(p, MY_CLIENT);
}
--- a/network_gui.c Fri Apr 20 19:45:38 2007 +0000
+++ b/network_gui.c Tue May 15 21:24:18 2007 +0000
@@ -1479,7 +1479,7 @@
AllocateWindowDesc(&_network_join_status_window_desc);
}
-static void SendChat(const char *buf, DestType type, byte dest)
+static void SendChat(const char *buf, DestType type, int dest)
{
if (buf[0] == '\0') return;
if (!_network_server) {
@@ -1543,7 +1543,7 @@
static void ChatTabCompletion(Window *w)
{
static char _chat_tab_completion_buf[lengthof(_edit_str_buf)];
- Textbuf *tb = &WP(w, querystr_d).text;
+ Textbuf *tb = &WP(w, chatquerystr_d).text;
uint len, tb_len;
uint item;
char *tb_buf, *pre_buf;
@@ -1601,7 +1601,7 @@
}
/* Update the textbuffer */
- UpdateTextBufferSize(&WP(w, querystr_d).text);
+ UpdateTextBufferSize(&WP(w, chatquerystr_d).text);
SetWindowDirty(w);
free(pre_buf);
@@ -1615,17 +1615,17 @@
_chat_tab_completion_active = false;
/* Update the textbuffer */
- UpdateTextBufferSize(&WP(w, querystr_d).text);
+ UpdateTextBufferSize(&WP(w, chatquerystr_d).text);
SetWindowDirty(w);
}
free(pre_buf);
}
-/* uses querystr_d WP macro
- * uses querystr_d->caption to store
- * - type of chat message (Private/Team/All) in bytes 0-7
- * - destination of chat message in the case of Team/Private in bytes 8-15 */
+/*
+ * uses chatquerystr_d WP macro
+ * uses chatquerystr_d->caption to store type of chat message (Private/Team/All)
+ */
static void ChatWindowWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -1644,25 +1644,25 @@
DrawWindowWidgets(w);
- assert(GB(WP(w, querystr_d).caption, 0, 8) < lengthof(chat_captions));
- msg = chat_captions[GB(WP(w, querystr_d).caption, 0, 8)];
+ assert(WP(w, chatquerystr_d).caption < lengthof(chat_captions));
+ msg = chat_captions[WP(w, chatquerystr_d).caption];
DrawStringRightAligned(w->widget[2].left - 2, w->widget[2].top + 1, msg, 16);
- DrawEditBox(w, &WP(w, querystr_d), 2);
+ DrawEditBox(w, &WP(w, chatquerystr_d), 2);
} break;
case WE_CLICK:
switch (e->we.click.widget) {
case 3: { /* Send */
- DestType type = GB(WP(w, querystr_d).caption, 0, 8);
- byte dest = GB(WP(w, querystr_d).caption, 8, 8);
- SendChat(WP(w, querystr_d).text.buf, type, dest);
+ DestType type = (DestType)WP(w, chatquerystr_d).caption;
+ int dest = WP(w, chatquerystr_d).dest;
+ SendChat(WP(w, chatquerystr_d).text.buf, type, dest);
} /* FALLTHROUGH */
case 0: /* Cancel */ DeleteWindow(w); break;
}
break;
case WE_MOUSELOOP:
- HandleEditBox(w, &WP(w, querystr_d), 2);
+ HandleEditBox(w, &WP(w, chatquerystr_d), 2);
break;
case WE_KEYPRESS:
@@ -1670,11 +1670,11 @@
ChatTabCompletion(w);
} else {
_chat_tab_completion_active = false;
- switch (HandleEditBoxKey(w, &WP(w, querystr_d), 2, e)) {
+ switch (HandleEditBoxKey(w, &WP(w, chatquerystr_d), 2, e)) {
case 1: { /* Return */
- DestType type = GB(WP(w, querystr_d).caption, 0, 8);
- byte dest = GB(WP(w, querystr_d).caption, 8, 8);
- SendChat(WP(w, querystr_d).text.buf, type, dest);
+ DestType type = (DestType)WP(w, chatquerystr_d).caption;
+ int dest = WP(w, chatquerystr_d).dest;
+ SendChat(WP(w, chatquerystr_d).text.buf, type, dest);
} /* FALLTHROUGH */
case 2: /* Escape */ DeleteWindow(w); break;
}
@@ -1704,7 +1704,7 @@
ChatWindowWndProc
};
-void ShowNetworkChatQueryWindow(DestType type, byte dest)
+void ShowNetworkChatQueryWindow(DestType type, int dest)
{
Window *w;
@@ -1716,11 +1716,12 @@
w = AllocateWindowDesc(&_chat_window_desc);
LowerWindowWidget(w, 2);
- WP(w,querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption
- WP(w,querystr_d).wnd_class = WC_MAIN_TOOLBAR;
- WP(w,querystr_d).wnd_num = 0;
- WP(w,querystr_d).afilter = CS_ALPHANUMERAL;
- InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0);
+ WP(w, chatquerystr_d).caption = type; // Misuse of caption
+ WP(w, chatquerystr_d).dest = dest;
+ WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL;
+ WP(w, chatquerystr_d).wnd_class = WC_MAIN_TOOLBAR;
+ WP(w, chatquerystr_d).wnd_num = 0;
+ InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0);
}
#endif /* ENABLE_NETWORK */
--- a/network_gui.h Fri Apr 20 19:45:38 2007 +0000
+++ b/network_gui.h Tue May 15 21:24:18 2007 +0000
@@ -9,7 +9,7 @@
void ShowNetworkNeedPassword(NetworkPasswordType npt);
void ShowNetworkGiveMoneyWindow(byte player); // PlayerID
-void ShowNetworkChatQueryWindow(DestType type, byte dest);
+void ShowNetworkChatQueryWindow(DestType type, int dest);
void ShowJoinStatusWindowAfterJoin(void);
void ShowNetworkGameWindow(void);
void ShowClientList(void);
@@ -17,7 +17,7 @@
#else /* ENABLE_NETWORK */
/* Network function stubs when networking is disabled */
-static inline void ShowNetworkChatQueryWindow(byte desttype, byte dest) {}
+static inline void ShowNetworkChatQueryWindow(byte desttype, int dest) {}
static inline void ShowClientList(void) {}
static inline void ShowJoinStatusWindowAfterJoin(void) {}
static inline void ShowNetworkGameWindow(void) {}
--- a/network_server.c Fri Apr 20 19:45:38 2007 +0000
+++ b/network_server.c Tue May 15 21:24:18 2007 +0000
@@ -1119,7 +1119,7 @@
{
NetworkAction action = NetworkRecv_uint8(cs, p);
DestType desttype = NetworkRecv_uint8(cs, p);
- int dest = NetworkRecv_uint8(cs, p);
+ int dest = NetworkRecv_uint16(cs, p);
char msg[MAX_TEXT_MSG_LEN];
NetworkRecv_string(cs, p, msg, MAX_TEXT_MSG_LEN);
--- a/tunnelbridge_cmd.c Fri Apr 20 19:45:38 2007 +0000
+++ b/tunnelbridge_cmd.c Tue May 15 21:24:18 2007 +0000
@@ -675,7 +675,7 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(endtile)) return CMD_ERROR;
+ if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) return CMD_ERROR;
direction = GetBridgeRampDirection(tile);
delta = TileOffsByDiagDir(direction);
@@ -828,8 +828,8 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicleOnGround(tile) ||
- !EnsureNoVehicleOnGround(endtile) ||
+ if (!EnsureNoVehicle(tile) ||
+ !EnsureNoVehicle(endtile) ||
FindVehicleBetween(tile, endtile, GetBridgeHeightRamp(tile), false) != NULL) {
return_cmd_error(STR_8803_TRAIN_IN_THE_WAY);
}
--- a/window.h Fri Apr 20 19:45:38 2007 +0000
+++ b/window.h Tue May 15 21:24:18 2007 +0000
@@ -348,6 +348,17 @@
} querystr_d;
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
+typedef struct chatquerystr_d {
+ StringID caption;
+ WindowClass wnd_class;
+ WindowNumber wnd_num;
+ Textbuf text;
+ const char *orig;
+ CharSetFilter afilter;
+ int dest;
+} chatquerystr_d;
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d));
+
typedef struct query_d {
StringID caption;
StringID message;
--- a/yapf/yapf_base.hpp Fri Apr 20 19:45:38 2007 +0000
+++ b/yapf/yapf_base.hpp Tue May 15 21:24:18 2007 +0000
@@ -117,7 +117,8 @@
while (true) {
m_num_steps++;
Node *n = m_nodes.GetBestOpenNode();
- if (n == NULL) break;
+ if (n == NULL)
+ break;
// if the best open node was worse than the best path found, we can finish
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
@@ -159,9 +160,9 @@
/** If path was found return the best node that has reached the destination. Otherwise
* return the best visited node (which was nearest to the destination).
*/
- FORCEINLINE Node& GetBestNode()
+ FORCEINLINE Node* GetBestNode()
{
- return (m_pBestDestNode != NULL) ? *m_pBestDestNode : *m_pBestIntermediateNode;
+ return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode;
}
/** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
--- a/yapf/yapf_rail.cpp Fri Apr 20 19:45:38 2007 +0000
+++ b/yapf/yapf_rail.cpp Tue May 15 21:24:18 2007 +0000
@@ -59,11 +59,11 @@
// some path found
// get found depot tile
- Node& n = Yapf().GetBestNode();
- *depot_tile = n.GetLastTile();
+ Node *n = Yapf().GetBestNode();
+ *depot_tile = n->GetLastTile();
// walk through the path back to the origin
- Node* pNode = &n;
+ Node *pNode = n;
while (pNode->m_parent != NULL) {
pNode = pNode->m_parent;
}
@@ -126,7 +126,7 @@
// if path not found - return INVALID_TRACKDIR
Trackdir next_trackdir = INVALID_TRACKDIR;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// walk through the path back to the origin
@@ -163,7 +163,7 @@
// path was found
// walk through the path back to the origin
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
while (pNode->m_parent != NULL) {
pNode = pNode->m_parent;
}
--- a/yapf/yapf_road.cpp Fri Apr 20 19:45:38 2007 +0000
+++ b/yapf/yapf_road.cpp Tue May 15 21:24:18 2007 +0000
@@ -278,7 +278,7 @@
// if path not found - return INVALID_TRACKDIR
Trackdir next_trackdir = INVALID_TRACKDIR;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// walk through the path back to its origin
@@ -320,7 +320,7 @@
// if path not found - return distance = UINT_MAX
uint dist = UINT_MAX;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// get the path cost estimate
@@ -362,8 +362,8 @@
// some path found
// get found depot tile
- Node& n = Yapf().GetBestNode();
- TileIndex depot_tile = n.m_segment_last_tile;
+ Node *n = Yapf().GetBestNode();
+ TileIndex depot_tile = n->m_segment_last_tile;
assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
Depot* ret = GetDepotByTile(depot_tile);
return ret;
--- a/yapf/yapf_ship.cpp Fri Apr 20 19:45:38 2007 +0000
+++ b/yapf/yapf_ship.cpp Tue May 15 21:24:18 2007 +0000
@@ -59,13 +59,13 @@
pf.SetOrigin(src_tile, trackdirs);
pf.SetDestination(v->dest_tile, dest_trackdirs);
// find best path
- bool bFound = pf.FindPath(v);
+ pf.FindPath(v);
Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
- if (bFound) {
- // path was found
+
+ Node* pNode = pf.GetBestNode();
+ if (pNode != NULL) {
// walk through the path back to the origin
- Node* pNode = &pf.GetBestNode();
Node* pPrevNode = NULL;
while (pNode->m_parent != NULL) {
pPrevNode = pNode;