#include "item.h"
#include "nat.h"
+#include "types.h"
extern void report_god_takes(char *, char *, natid);
extern void report_god_gives(char *, char *, natid);
ATTRIBUTE((format (printf, 5, 6)));
#define divine_unit_change_quiet(unit, name, change, ...) \
divine_unit_change((unit), (name), -(change), 0, __VA_ARGS__)
+extern void divine_flag_change(struct empobj *, char *, int, int,
+ struct symbol *);
extern void report_divine_gift(natid, struct ichrstr *, int, char *);
#endif
* types.h: Empire types
*
* Known contributors to this file:
- * Markus Armbruster, 2006-2011
+ * Markus Armbruster, 2006-2013
*/
#ifndef TYPES_H
struct sctstr;
struct shiplist;
struct shpstr;
+struct symbol;
struct trdstr;
struct trtstr;
struct comstr;
strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
break;
case 'W':
+ divine_flag_change((struct empobj *)ship, "Retreat conditions",
+ ship->shp_rflags, arg, retreat_flags);
ship->shp_rflags = arg;
break;
case 'c':
strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
break;
case 'W':
+ divine_flag_change((struct empobj *)land, "Retreat condition",
+ land->lnd_rflags, arg, retreat_flags);
land->lnd_rflags = arg;
break;
case 'c':
plane->pln_land = arg;
break;
case 'f':
+ divine_flag_change((struct empobj *)plane, "Flags",
+ plane->pln_flags, arg, plane_flags);
plane->pln_flags = arg;
break;
default:
divine_load_unload(unit, type, uid, "unloaded from");
}
+static int
+fmtflags (char *buf, size_t sz, int flags, struct symbol symtab[], int all)
+{
+ char *sep = "";
+ int n, i;
+ char *p;
+
+ if (sz)
+ buf[0] = 0;
+ n = 0;
+ for (i = 0; i < 32; i++) {
+ if (!(flags & bit(i)))
+ continue;
+ p = symbol_by_value(bit(i), symtab);
+ if (p)
+ n += snprintf(buf + n, sz - n, "%s%s", sep, p);
+ else if (all)
+ n += snprintf(buf + n, sz - n, "%s#%d", sep, i);
+ if (CANT_HAPPEN((size_t)n >= sz)) {
+ buf = NULL;
+ sz = n;
+ }
+ sep = ", ";
+ }
+ return n;
+}
+
+void
+divine_flag_change(struct empobj *unit, char *name,
+ int old, int new, struct symbol sym[])
+{
+ char set[1024], clr[1024];
+
+ if (new == old) {
+ pr("%s of %s unchanged\n", name, unit_nameof(unit));
+ return;
+ }
+
+ fmtflags(set, sizeof(set), new & ~old, sym, 1);
+ fmtflags(clr, sizeof(clr), old & ~new, sym, 1);
+ pr("%s of %s changed: %s%s%s%s%s\n",
+ name, unit_nameof(unit),
+ set, set[0] ? " set" : "",
+ set[0] && clr[0] ? ", and " : "",
+ clr, clr[0] ? " cleared" : "");
+
+ if (fmtflags(set, sizeof(set), new & ~old, sym, 0)
+ + fmtflags(clr, sizeof(clr), old & ~new, sym, 0))
+ wu(0, unit->own, "%s of %s changed by an act of %s: %s%s%s%s%s\n",
+ name, unit_nameof(unit), cname(player->cnum),
+ set, set[0] ? " set" : "",
+ set[0] && clr[0] ? " and " : "",
+ clr, clr[0] ? " cleared" : "");
+}
+
/*
* Report deity giving/taking commodities to/from WHOM.
* Give AMT of IP in PLACE.
Play#0 output Play#0 6 0 640
Play#0 input edit s 2 W 0 W 1
Play#0 command edit
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#2) unchanged
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#2) changed: group set
Play#0 output Play#0 6 0 640
Play#0 input edit s 3 W 513 W 1030 W 2
Play#0 command edit
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed: group, #9 set
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed: injured, torped, #10 set, and group, #9 cleared
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed: torped, #10 cleared
Play#0 output Play#0 6 0 640
Play#0 input edit u 2 R ""
Play#0 command edit
Play#0 output Play#0 6 0 640
Play#0 input edit u 2 W 0 W 1
Play#0 command edit
+ Play#0 output Play#0 1 Retreat condition of sup supply #2 unchanged
+ Play#0 output Play#0 1 Retreat condition of sup supply #2 changed: group set
Play#0 output Play#0 6 0 640
Play#0 input edit u 3 W 513 W 1030 W 2
Play#0 command edit
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed: group, #9 set
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed: injured, torped, #10 set, and group, #9 cleared
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed: torped, #10 cleared
Play#0 output Play#0 6 0 640
Play#0 input edit p 2 f 4
Play#0 command edit
+ Play#0 output Play#0 1 Flags of f1 Sopwith Camel #2 changed: airburst set
Play#0 output Play#0 6 0 640
Play#0 input edit p 2 s -1 s 9999
Play#0 command edit
Play#0 output Play#0 1 cs cargo ship (#2) given to you by an act of POGO!
Play#0 output Play#0 1 f1 Sopwith Camel #2 given to you by an act of POGO!
Play#0 output Play#0 1 sup supply #2 given to you by an act of POGO!
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#2) changed by an act of POGO: group set
+ Play#0 output Play#0 1 Retreat condition of sup supply #2 changed by an act of POGO: group set
+ Play#0 output Play#0 1 Flags of f1 Sopwith Camel #2 changed by an act of POGO: airburst set
Play#0 output Play#0 6 0 640
Play#0 input read 3
Play#0 command read
Play#0 output Play#0 1 POGO gave you 50 military in cs cargo ship (#5)
Play#0 output Play#0 1 POGO gave you 25 military in sup supply #4
Play#0 output Play#0 1 POGO gave you 25 military in sup supply #5
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed by an act of POGO: group set
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed by an act of POGO: injured, torped set and group cleared
+ Play#0 output Play#0 1 Retreat conditions of cs cargo ship (#3) changed by an act of POGO: torped cleared
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed by an act of POGO: group set
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed by an act of POGO: injured, torped set and group cleared
+ Play#0 output Play#0 1 Retreat condition of sup supply #3 changed by an act of POGO: torped cleared
Play#0 output Play#0 1 f1 Sopwith Camel #3 loaded onto ship #3 by an act of POGO!
Play#0 output Play#0 1 f1 Sopwith Camel #4 loaded onto ship #4 by an act of POGO!
Play#0 output Play#0 1 f1 Sopwith Camel #4 unloaded from ship #4 by an act of POGO!