diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 63ba7f54b6..6c3ec41998 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -162,6 +162,12 @@ bool AIFileInfo::CheckMethod(const char *name) const return 0; } +AIInfo::AIInfo() : + min_loadable_version(0), + use_as_random(false) +{ +} + AIInfo::~AIInfo() { /* Free all allocated strings */ diff --git a/src/ai/ai_info.hpp b/src/ai/ai_info.hpp index 48d6db33fe..090a5ab224 100644 --- a/src/ai/ai_info.hpp +++ b/src/ai/ai_info.hpp @@ -41,7 +41,7 @@ public: friend class AIInfo; friend class AILibrary; - AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL), url(NULL) {}; + AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL), version(0), url(NULL) {}; ~AIFileInfo(); /** @@ -123,6 +123,7 @@ class AIInfo : public AIFileInfo { public: static const char *GetClassName() { return "AIInfo"; } + AIInfo(); ~AIInfo(); /** diff --git a/src/ottdres.rc.in b/src/ottdres.rc.in index 4a2dead450..22927d78d2 100644 --- a/src/ottdres.rc.in +++ b/src/ottdres.rc.in @@ -57,6 +57,17 @@ BEGIN END +101 DIALOG DISCARDABLE 0, 0, 600, 400 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "OpenTTD command line help" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "&OK",12,274,378,50,14,BS_CENTER + EDITTEXT 11,7,6,583,365,ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL +END + + #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 8c7179fe6f..ac5fbd35d0 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -736,7 +736,7 @@ static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data) return NULL; } -static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, Direction dir) +static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, Direction dir, bool update_blocked_ctr = true) { RoadVehFindData rvf; Vehicle *front = v->First(); @@ -765,7 +765,7 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, Direction dir) return NULL; } - if (++front->u.road.blocked_ctr > 1480) return NULL; + if (update_blocked_ctr && ++front->u.road.blocked_ctr > 1480) return NULL; return rvf.best; } @@ -1227,7 +1227,7 @@ static bool RoadVehLeaveDepot(Vehicle *v, bool first) int y = TileY(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].y & 0xF); if (first) { - if (RoadVehFindCloseTo(v, x, y, v->direction) != NULL) return true; + if (RoadVehFindCloseTo(v, x, y, v->direction, false) != NULL) return true; VehicleServiceInDepot(v); diff --git a/src/sdl.cpp b/src/sdl.cpp index bcbba22b95..55e30179b8 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -61,6 +61,7 @@ static const char sdl_files[] = M("SDL_SetColorKey") M("SDL_WM_SetIcon") M("SDL_MapRGB") + M("SDL_VideoModeOK") M("") ; #undef M diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 2249715a25..5c5ba92a43 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -965,10 +965,6 @@ static void AddWagonToConsist(Vehicle *v, Vehicle *dest) */ static void NormaliseTrainConsist(Vehicle *v) { - if (IsFreeWagon(v)) return; - - assert(IsFrontEngine(v)); - for (; v != NULL; v = GetNextVehicle(v)) { if (!IsMultiheaded(v) || !IsTrainEngine(v)) continue; diff --git a/src/win32.cpp b/src/win32.cpp index 8e1b343461..0ad85d9c01 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -937,23 +937,72 @@ void CreateConsole() #endif } +/** Temporary pointer to get the help message to the window */ +static const char *_help_msg; + +/** Callback function to handle the window */ +static INT_PTR CALLBACK HelpDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_INITDIALOG: { + char help_msg[8192]; + const char *p = _help_msg; + char *q = help_msg; + while (q != lastof(help_msg) && *p != '\0') { + if (*p == '\n') { + *q++ = '\r'; + if (q == lastof(help_msg)) { + q[-1] = '\0'; + break; + } + } + *q++ = *p++; + } + *q = '\0'; +#if defined(UNICODE) + /* We need to put the text in a seperate buffer because the default + * buffer in MB_TO_WIDE might not be large enough (512 chars) */ + wchar_t help_msgW[8192]; +#endif + SetDlgItemText(wnd, 11, MB_TO_WIDE_BUFFER(help_msg, help_msgW, lengthof(help_msgW))); + SendDlgItemMessage(wnd, 11, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), FALSE); + } return TRUE; + + case WM_COMMAND: + if (wParam == 12) ExitProcess(0); + return TRUE; + case WM_CLOSE: + ExitProcess(0); + } + + return FALSE; +} + void ShowInfo(const char *str) { if (_has_console) { fprintf(stderr, "%s\n", str); } else { bool old; -#if defined(UNICODE) - /* We need to put the text in a seperate buffer because the default - * buffer in MB_TO_WIDE might not be large enough (512 chars) */ - wchar_t help_msgW[8192]; -#endif ReleaseCapture(); _left_button_clicked = _left_button_down = false; old = MyShowCursor(true); - if (MessageBox(GetActiveWindow(), MB_TO_WIDE_BUFFER(str, help_msgW, lengthof(help_msgW)), _T("OpenTTD"), MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) { - CreateConsole(); + if (strlen(str) > 2048) { + /* The minimum length of the help message is 2048. Other messages sent via + * ShowInfo are much shorter, or so long they need this way of displaying + * them anyway. */ + _help_msg = str; + DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(101), NULL, HelpDialogFunc); + } else { +#if defined(UNICODE) + /* We need to put the text in a seperate buffer because the default + * buffer in MB_TO_WIDE might not be large enough (512 chars) */ + wchar_t help_msgW[8192]; +#endif + if (MessageBox(GetActiveWindow(), MB_TO_WIDE_BUFFER(str, help_msgW, lengthof(help_msgW)), _T("OpenTTD"), MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) { + CreateConsole(); + } } MyShowCursor(old); }