From 68d1b29e19ce8ceeee50618eb081ae78ed7c677f Mon Sep 17 00:00:00 2001 From: glx Date: Mon, 20 Aug 2007 15:17:24 +0000 Subject: [PATCH] (svn r10952) [0.5] -Backport from trunk (r10877, r10890, r10892, r10942, r10948): - Fix: Some isocodes were wrong (r10877) - Fix: Removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was [FS#1125] (r10890) - Fix: Trains would not get flooded when they are at the lower part of a tile that would become a coast tile after flooding [FS#1127] (r10892) - Fix: Make the AI not crash when it has ships as the AI does not support them [FS#1133] (r10942) - Add: [Windows] crash.dmp support for MSVC release builds (r10948) --- ai/default/default.c | 37 ++++++++------------------------- lang/italian.txt | 2 +- lang/unfinished/frisian.txt | 2 +- newgrf_text.c | 2 +- road_cmd.c | 17 ++++++++++++--- water_cmd.c | 4 ++++ win32.c | 41 +++++++++++++++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 35 deletions(-) diff --git a/ai/default/default.c b/ai/default/default.c index 28ddfde58a..4737fa1765 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -239,14 +239,6 @@ static int32 AiGetBasePrice(const Player* p) return base; } -#if 0 -static EngineID AiChooseShipToBuild(byte cargo, int32 money) -{ - // XXX: not done - return INVALID_ENGINE; -} -#endif - static EngineID AiChooseRoadVehToReplaceWith(const Player* p, const Vehicle* v) { int32 avail_money = p->player_money + v->value; @@ -277,9 +269,7 @@ static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v) static EngineID AiChooseShipToReplaceWith(const Player* p, const Vehicle* v) { - error("!AiChooseShipToReplaceWith"); - - /* maybe useless, but avoids compiler warning this way */ + /* Ships are not implemented in this (broken) AI */ return INVALID_ENGINE; } @@ -400,7 +390,7 @@ static void AiHandleReplaceAircraft(Player *p) static void AiHandleReplaceShip(Player *p) { - error("!AiHandleReplaceShip"); + /* Ships are not implemented in this (broken) AI */ } typedef EngineID CheckReplaceProc(const Player* p, const Vehicle* v); @@ -1478,12 +1468,6 @@ static void AiWantAircraftRoute(Player *p) } } -static void AiWantShipRoute(Player *p) -{ - // XXX -// error("AiWaitShipRoute"); -} - static void AiStateWantNewRoute(Player *p) @@ -1517,8 +1501,7 @@ static void AiStateWantNewRoute(Player *p) if (_patches.ai_disable_veh_aircraft) continue; AiWantAircraftRoute(p); } else { - if (_patches.ai_disable_veh_ship) continue; - AiWantShipRoute(p); + /* Ships are not implemented in this (broken) AI */ } // got a route? @@ -3510,20 +3493,17 @@ static void AiStateBuildAircraftVehicles(Player *p) static void AiStateCheckShipStuff(Player *p) { - // XXX - error("!AiStateCheckShipStuff"); + /* Ships are not implemented in this (broken) AI */ } static void AiStateBuildDefaultShipBlocks(Player *p) { - // XXX - error("!AiStateBuildDefaultShipBlocks"); + /* Ships are not implemented in this (broken) AI */ } static void AiStateDoShipStuff(Player *p) { - // XXX - error("!AiStateDoShipStuff"); + /* Ships are not implemented in this (broken) AI */ } static void AiStateSellVeh(Player *p) @@ -3558,9 +3538,8 @@ static void AiStateSellVeh(Player *p) } DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT); - } else if (v->type == VEH_Ship) { - // XXX: not implemented - error("!v->type == VEH_Ship"); + } else if (v->type == VEH_Ship) { + /* Ships are not implemented in this (broken) AI */ } } diff --git a/lang/italian.txt b/lang/italian.txt index f37759a3a1..fc4f582349 100644 --- a/lang/italian.txt +++ b/lang/italian.txt @@ -1,6 +1,6 @@ ##name Italian ##ownname Italiano -##isocode it +##isocode it_IT ##plural 0 ##case ms mp fs fp ##gender m f diff --git a/lang/unfinished/frisian.txt b/lang/unfinished/frisian.txt index d85c5d4a30..2ce1075cbe 100644 --- a/lang/unfinished/frisian.txt +++ b/lang/unfinished/frisian.txt @@ -1,6 +1,6 @@ ##name Frisian ##ownname Frysk -##isocode fy +##isocode fy_NL ##id 0x0000 STR_NULL : diff --git a/newgrf_text.c b/newgrf_text.c index caeed8116a..3a95af3587 100644 --- a/newgrf_text.c +++ b/newgrf_text.c @@ -95,7 +95,7 @@ const iso_grf iso_codes[] = { {"es_ES", GRFLX_SPANISH}, {"af_ZA", GRFLX_AFRIKAANS}, {"hr_HR", GRFLX_CROATIAN}, - {"cs_CS", GRFLX_CZECH}, + {"cs_CZ", GRFLX_CZECH}, {"ca_ES", GRFLX_CATALAN}, {"da_DA", GRFLX_DANISH}, {"nl_NL", GRFLX_DUTCH}, diff --git a/road_cmd.c b/road_cmd.c index 633b001ed2..084079db0d 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -520,7 +520,7 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) { TileIndex start_tile, tile; - int32 cost, ret; + int32 cost, ret, money; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -541,6 +541,7 @@ int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) } cost = 0; + money = GetAvailableMoneyForCommand(); tile = start_tile; // Start tile is the small number. for (;;) { @@ -551,8 +552,18 @@ int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) // try to remove the halves. if (bits != 0) { - ret = DoCommand(tile, bits, 0, flags, CMD_REMOVE_ROAD); - if (!CmdFailed(ret)) cost += ret; + ret = DoCommand(tile, bits, 0, flags& ~DC_EXEC, CMD_REMOVE_ROAD); + if (!CmdFailed(ret)) { + if (flags & DC_EXEC) { + money -= ret; + if (money < 0) { + _additional_cash_required = DoCommand(end_tile, start_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD); + return cost; + } + DoCommand(tile, bits, 0, flags, CMD_REMOVE_ROAD); + } + cost += ret; + } } if (tile == end_tile) break; diff --git a/water_cmd.c b/water_cmd.c index 4bea594e43..31bcc3dc09 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -550,6 +550,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) case MP_RAILWAY: { TrackBits tracks; Slope slope; + Vehicle *v; if (!IsPlainRailTile(target)) break; @@ -563,6 +564,9 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) )) { break; } + + v = FindFloodableVehicleOnTile(target); + if (v != NULL) FloodVehicle(v); } /* FALLTHROUGH */ diff --git a/win32.c b/win32.c index 30f01eb9e0..b90e8fcdc1 100644 --- a/win32.c +++ b/win32.c @@ -23,6 +23,10 @@ #include #include #include +#if defined(_MSC_VER) && !defined(WINCE) + #include +#endif + static bool _has_console; @@ -584,6 +588,43 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep) } } +#if !defined(_DEBUG) + { + HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll")); + if (dbghelp != NULL) { + typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE, + MINIDUMP_TYPE, + CONST PMINIDUMP_EXCEPTION_INFORMATION, + CONST PMINIDUMP_USER_STREAM_INFORMATION, + CONST PMINIDUMP_CALLBACK_INFORMATION); + MiniDumpWriteDump_t funcMiniDumpWriteDump = (MiniDumpWriteDump_t)GetProcAddress(dbghelp, "MiniDumpWriteDump"); + if (funcMiniDumpWriteDump != NULL) { + HANDLE file = CreateFile(_T("crash.dmp"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + HANDLE proc = GetCurrentProcess(); + DWORD procid = GetCurrentProcessId(); + MINIDUMP_EXCEPTION_INFORMATION mdei; + MINIDUMP_USER_STREAM userstream; + MINIDUMP_USER_STREAM_INFORMATION musi; + char msg[] = "****** Built on " __DATE__ " " __TIME__ ". ******"; + + userstream.Type = LastReservedStream + 1; + userstream.Buffer = msg; + userstream.BufferSize = sizeof(msg); + + musi.UserStreamCount = 1; + musi.UserStreamArray = &userstream; + + mdei.ThreadId = GetCurrentThreadId(); + mdei.ExceptionPointers = ep; + mdei.ClientPointers = false; + + funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, NULL); + } + FreeLibrary(dbghelp); + } + } +#endif + /* Close any possible log files */ CloseConsoleLogIfActive();