Changeset - r14886:aced247f8320
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-03-20 17:19:16
alberth@openttd.org
(svn r19492) -Codechange: Keep track of last error in CmdClearArea().
1 file changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/landscape.cpp
Show inline comments
 
@@ -624,14 +624,18 @@ CommandCost CmdClearArea(TileIndex tile,
 

	
 
	Money money = GetAvailableMoneyForCommand();
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	bool success = false;
 
	CommandCost last_error = CMD_ERROR;
 
	bool had_success = false;
 

	
 
	for (int x = sx; x <= ex; ++x) {
 
		for (int y = sy; y <= ey; ++y) {
 
			CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
			if (ret.Failed()) continue;
 
			success = true;
 
			if (ret.Failed()) {
 
				last_error = ret;
 
				continue;
 
			}
 

	
 
			had_success = true;
 
			if (flags & DC_EXEC) {
 
				money -= ret.GetCost();
 
				if (ret.GetCost() > 0 && money < 0) {
 
@@ -652,7 +656,7 @@ CommandCost CmdClearArea(TileIndex tile,
 
		}
 
	}
 

	
 
	return (success) ? cost : CMD_ERROR;
 
	return had_success ? cost : last_error;
 
}
 

	
 

	
0 comments (0 inline, 0 general)