(svn r2999) Do not pass if the HQ gets built for the first time or gets relocated as parameter - the command function has to check this anyway

This commit is contained in:
tron 2005-09-30 08:57:12 +00:00
parent fdebfbe8d5
commit 0181327f2d
2 changed files with 4 additions and 14 deletions

View File

@ -634,9 +634,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
break; break;
case WE_PLACE_OBJ: { case WE_PLACE_OBJ: {
/* You cannot destroy a HQ, only relocate it. So build_HQ is called, just with different flags */ if (DoCommandP(e->place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
TileIndex tile = GetPlayer(w->window_number)->location_of_house;
if (DoCommandP(e->place.tile, (tile == 0) ? 0 : 1 | w->window_number, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
ResetObjectToPlace(); ResetObjectToPlace();
break; break;
} }

View File

@ -60,7 +60,7 @@ int32 DestroyCompanyHQ(TileIndex tile, uint32 flags)
/** Build or relocate the HQ. This depends if the HQ is already built or not /** Build or relocate the HQ. This depends if the HQ is already built or not
* @param x,y the coordinates where the HQ will be built or relocated to * @param x,y the coordinates where the HQ will be built or relocated to
* @param p1 relocate HQ (set to some value, usually 1 or true) * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *); extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
@ -75,18 +75,10 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL); cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
if (CmdFailed(cost)) return CMD_ERROR; if (CmdFailed(cost)) return CMD_ERROR;
if (p1) { /* Moving HQ */ if (p->location_of_house != 0) { /* Moving HQ */
int32 ret; int32 ret = DestroyCompanyHQ(p->location_of_house, flags);
if (p->location_of_house == 0) return CMD_ERROR;
ret = DestroyCompanyHQ(p->location_of_house, flags);
if (CmdFailed(ret)) return CMD_ERROR; if (CmdFailed(ret)) return CMD_ERROR;
cost += ret; cost += ret;
} else { /* Building new HQ */
if (p->location_of_house != 0) return CMD_ERROR;
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {