int real(void) { struct realmstr realm; struct natstr *natp; int curr; int lastr; struct range abs; char *realmp = player->argp[1]; natp = getnatp(player->cnum); if (!realmp) { curr = 0; lastr = MAXNOR - 1; } else { if (*realmp == '#') ++realmp; if (*realmp && !isdigit(*realmp)) return RET_SYN; curr = lastr = atoi(realmp); if (curr < 0 || curr >= MAXNOR) { pr("Realm number must be in the range 0:%d\n", MAXNOR - 1); return RET_SYN; } } if (!player->argp[2]) { while (curr <= lastr) { list_realm(curr, natp); curr++; } } else { if (sarg_type(player->argp[2]) != NS_AREA) return RET_SYN; abs.width = 0; abs.height = 0; if (!sarg_area(player->argp[2], &abs)) return RET_SYN; getrealm(curr, natp->nat_cnum, &realm); realm.r_xl = abs.lx; realm.r_xh = abs.hx; realm.r_yl = abs.ly; realm.r_yh = abs.hy; putrealm(&realm); list_realm(curr, natp); } return RET_OK; }
/* * setup the nstr_sect structure for sector selection. * can select on either NS_ALL, NS_AREA, or NS_DIST * iterate thru the "condarg" string looking * for arguments to compile into the nstr. * Using this function for anything but command arguments is usually * incorrect, because it respects conditionals. Use the snxtsct_FOO() * instead. */ int snxtsct(struct nstr_sect *np, char *str) { struct range range; struct natstr *natp; coord cx, cy; int dist; char buf[1024]; if (!str || !*str) { if (!(str = getstring("(sects)? ", buf))) return 0; } else make_stale_if_command_arg(str); switch (sarg_type(str)) { case NS_AREA: if (!sarg_area(str, &range)) return 0; snxtsct_area(np, &range); break; case NS_DIST: if (!sarg_range(str, &cx, &cy, &dist)) return 0; snxtsct_dist(np, cx, cy, dist); break; case NS_ALL: /* * Can't use snxtsct_all(), as it would disclose the real * origin. Use a world-sized area instead. */ natp = getnatp(player->cnum); range.lx = xabs(natp, -WORLD_X / 2); range.ly = yabs(natp, -WORLD_Y / 2); range.hx = xnorm(range.lx + WORLD_X - 1); range.hy = ynorm(range.ly + WORLD_Y - 1); xysize_range(&range); snxtsct_area(np, &range); break; default: return 0; } return snxtsct_use_condarg(np); }