Mercurial > hg > openttd
comparison src/station_cmd.cpp @ 5833:bcd4b73b9fd2 draft
(svn r8399) -Fix (r8185): a new road stop was always created in CmdBuildRoadStop(), but it was not deleted if DC_EXEC flag was not set or if the station creation failed
author | glx <glx@openttd.org> |
---|---|
date | Thu, 25 Jan 2007 01:29:24 +0000 |
parents | 06a31b083e84 |
children | f9e0c80cf037 |
comparison
equal
deleted
inserted
replaced
5832:d4f51c2fea04 | 5833:bcd4b73b9fd2 |
---|---|
1357 if (st == NULL) { | 1357 if (st == NULL) { |
1358 st = GetClosestStationFromTile(tile, 8, _current_player); | 1358 st = GetClosestStationFromTile(tile, 8, _current_player); |
1359 if (st != NULL && st->facilities != 0) st = NULL; | 1359 if (st != NULL && st->facilities != 0) st = NULL; |
1360 } | 1360 } |
1361 | 1361 |
1362 /* If DC_EXEC is NOT set we still need to create the road stop to test if everything is OK. | |
1363 * In this case we need to delete it before return. */ | |
1364 std::auto_ptr<RoadStop> rs_auto_delete; | |
1365 | |
1362 //give us a road stop in the list, and check if something went wrong | 1366 //give us a road stop in the list, and check if something went wrong |
1363 road_stop = new RoadStop(tile); | 1367 road_stop = new RoadStop(tile); |
1364 if (road_stop == NULL) { | 1368 if (road_stop == NULL) { |
1365 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); | 1369 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); |
1366 } | 1370 } |
1371 | |
1372 /* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */ | |
1373 rs_auto_delete = std::auto_ptr<RoadStop>(road_stop); | |
1367 | 1374 |
1368 if (st != NULL && | 1375 if (st != NULL && |
1369 GetNumRoadStopsInStation(st, RS_BUS) + GetNumRoadStopsInStation(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { | 1376 GetNumRoadStopsInStation(st, RS_BUS) + GetNumRoadStopsInStation(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { |
1370 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); | 1377 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); |
1371 } | 1378 } |
1419 | 1426 |
1420 UpdateStationVirtCoordDirty(st); | 1427 UpdateStationVirtCoordDirty(st); |
1421 UpdateStationAcceptance(st, false); | 1428 UpdateStationAcceptance(st, false); |
1422 RebuildStationLists(); | 1429 RebuildStationLists(); |
1423 InvalidateWindow(WC_STATION_LIST, st->owner); | 1430 InvalidateWindow(WC_STATION_LIST, st->owner); |
1424 /* success, so don't delete the new station */ | 1431 /* success, so don't delete the new station and the new road stop */ |
1425 st_auto_delete.release(); | 1432 st_auto_delete.release(); |
1433 rs_auto_delete.release(); | |
1426 } | 1434 } |
1427 return cost; | 1435 return cost; |
1428 } | 1436 } |
1429 | 1437 |
1430 // Remove a bus station | 1438 // Remove a bus station |