Merge pull request #81 from CTD1/BEZAHLE_NICHT_ID

BEZAHLE NICHT ID
This commit is contained in:
Enno Rehling 2014-12-17 20:18:08 +01:00
commit d7899a392a
1 changed files with 34 additions and 1 deletions

View File

@ -3833,16 +3833,49 @@ int pay_cmd(unit * u, struct order *ord)
} }
else { else {
param_t p; param_t p;
int id;
init_order(ord); init_order(ord);
p = getparam(u->faction->locale); p = getparam(u->faction->locale);
id = getid();
building *b = NULL;
if (p == P_NOT) { if (p == P_NOT) {
unit *owner = building_owner(u->building); unit *owner = building_owner(u->building);
/* If the unit is not the owner of the building: error */
if (owner->no != u->no) { if (owner->no != u->no) {
/* The building is not ours error */
cmistake(u, ord, 1222, MSG_EVENT); cmistake(u, ord, 1222, MSG_EVENT);
} }
else { else {
/* If no building id is given or it is the id of our building, just set the do-not-pay flag */
if (id == 0 || id == u->building->no)
{
u->building->flags |= BLD_DONTPAY; u->building->flags |= BLD_DONTPAY;
} }
else {
/* Find the building that matches to the given id*/
b = findbuilding(id);
/* If there is a building and it is in the same region as the unit continue, else: error */
if (b && b->region == u->region)
{
/* If the unit is also the building owner (this is true if rules.region_owner_pay_building */
/* is set and no one is in the building) set the do-not-pay flag for this building, else: error */
if (building_owner(b) == u) {
b->flags |= BLD_DONTPAY;
}
else
{
/* The building is not ours error */
cmistake(u, ord, 1222, MSG_EVENT);
}
}
else
{
/* Building not found error */
cmistake(u, ord, 6, MSG_PRODUCE);
}
}
}
} }
} }
return 0; return 0;