edit: Report loading/unloading of planes & land units properly
Print a message, send bulletin to owner. Affects plane keys 's', 'y', and land unit keys 'S', 'Y'. The message is necessary to give the deity a chance to catch unexpected changes, e.g. a player loading a plane right before the deity edits it. Watching out for such changes is especially important with non-interactive edit. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
97b3aacaca
commit
cbe9897bfa
4 changed files with 86 additions and 4 deletions
|
@ -898,15 +898,31 @@ edit_land(struct lndstr *land, char *key, char *p)
|
|||
case 'S':
|
||||
if (arg < -1 || arg >= ef_nelem(EF_SHIP))
|
||||
return RET_SYN;
|
||||
if (arg >= 0 && arg != land->lnd_ship)
|
||||
if (arg == land->lnd_ship) {
|
||||
pr("Ship of %s unchanged\n", prland(land));
|
||||
break;
|
||||
}
|
||||
divine_unload((struct empobj *)land, EF_SHIP, land->lnd_ship);
|
||||
if (arg >= 0) {
|
||||
divine_unload((struct empobj *)land, EF_LAND, land->lnd_land);
|
||||
land->lnd_land = -1;
|
||||
}
|
||||
divine_load((struct empobj *)land, EF_SHIP, arg);
|
||||
land->lnd_ship = arg;
|
||||
break;
|
||||
case 'Y':
|
||||
if (arg < -1 || arg >= ef_nelem(EF_LAND))
|
||||
return RET_SYN;
|
||||
if (arg >= 0 && arg != land->lnd_land)
|
||||
if (arg == land->lnd_land) {
|
||||
pr("Land unit of %s unchanged\n", prland(land));
|
||||
break;
|
||||
}
|
||||
divine_unload((struct empobj *)land, EF_LAND, land->lnd_land);
|
||||
if (arg >= 0) {
|
||||
divine_unload((struct empobj *)land, EF_SHIP, land->lnd_ship);
|
||||
land->lnd_ship = -1;
|
||||
}
|
||||
divine_load((struct empobj *)land, EF_LAND, arg);
|
||||
land->lnd_land = arg;
|
||||
break;
|
||||
case 'Z':
|
||||
|
@ -975,15 +991,31 @@ edit_plane(struct plnstr *plane, char *key, char *p)
|
|||
case 's':
|
||||
if (arg < -1 || arg >= ef_nelem(EF_SHIP))
|
||||
return RET_SYN;
|
||||
if (arg >= 0 && arg != plane->pln_ship)
|
||||
if (arg == plane->pln_ship) {
|
||||
pr("Ship of %s unchanged\n", prplane(plane));
|
||||
break;
|
||||
}
|
||||
divine_unload((struct empobj *)plane, EF_SHIP, plane->pln_ship);
|
||||
if (arg >= 0) {
|
||||
divine_unload((struct empobj *)plane, EF_LAND, plane->pln_land);
|
||||
plane->pln_land = -1;
|
||||
}
|
||||
divine_load((struct empobj *)plane, EF_SHIP, arg);
|
||||
plane->pln_ship = arg;
|
||||
break;
|
||||
case 'y':
|
||||
if (arg < -1 || arg >= ef_nelem(EF_LAND))
|
||||
return RET_SYN;
|
||||
if (arg >= 0 && arg != plane->pln_land)
|
||||
if (arg == plane->pln_land) {
|
||||
pr("Land unit of %s unchanged\n", prplane(plane));
|
||||
break;
|
||||
}
|
||||
divine_unload((struct empobj *)plane, EF_LAND, plane->pln_land);
|
||||
if (arg >= 0) {
|
||||
divine_unload((struct empobj *)plane, EF_SHIP, plane->pln_ship);
|
||||
plane->pln_ship = -1;
|
||||
}
|
||||
divine_load((struct empobj *)plane, EF_LAND, arg);
|
||||
plane->pln_land = arg;
|
||||
break;
|
||||
case 'f':
|
||||
|
|
|
@ -138,6 +138,34 @@ divine_unit_change(struct empobj *unit, char *name,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
divine_load_unload(struct empobj *unit, int type, int uid, char *act)
|
||||
{
|
||||
if (uid < 0)
|
||||
return;
|
||||
|
||||
pr("%s %s %s #%d\n",
|
||||
unit_nameof(unit), act, ef_nameof(type), uid);
|
||||
if (unit->own && unit->own != player->cnum)
|
||||
wu(0, unit->own,
|
||||
"%s %s %s #%d by an act of %s!\n",
|
||||
unit_nameof(unit), act, ef_nameof(type), uid,
|
||||
cname(player->cnum));
|
||||
/* carrier owner could differ; can't be bothered to report to him */
|
||||
}
|
||||
|
||||
void
|
||||
divine_load(struct empobj *unit, int type, int uid)
|
||||
{
|
||||
divine_load_unload(unit, type, uid, "loaded onto");
|
||||
}
|
||||
|
||||
void
|
||||
divine_unload(struct empobj *unit, int type, int uid)
|
||||
{
|
||||
divine_load_unload(unit, type, uid, "unloaded from");
|
||||
}
|
||||
|
||||
/*
|
||||
* Report deity giving/taking commodities to/from WHOM.
|
||||
* Give AMT of IP in PLACE.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue