double sdb2range (int n1, int n2) { return xyz2range(sdb[n1].coords.x, sdb[n1].coords.y, sdb[n1].coords.z, sdb[n2].coords.x, sdb[n2].coords.y, sdb[n2].coords.z); }
int do_nebula_report (dbref enactor) { static char buffer[BUFFER_LEN], nbuff[20]; double px = sdb[n].coords.x / PARSEC; double py = sdb[n].coords.y / PARSEC; double pz = sdb[n].coords.z / PARSEC; double cx[2], cy[2], cz[2]; double dx, dy, dz; register int x, y, z; register int i = 0; aspace_borders *nebula; double range; cx[0] = ceil(px / 100.0) * 100.0; cx[1] = floor(px / 100.0) * 100.0; cy[0] = ceil(py / 100.0) * 100.0; cy[1] = floor(py / 100.0) * 100.0; cz[0] = ceil(pz / 100.0) * 100.0; cz[1] = floor(pz / 100.0) * 100.0; if (error_on_console(enactor)) { return 0; } else if (!sdb[n].sensor.lrs_exist) { notify(enactor, ansi_red(tprintf("%s has no long-range sensors.", Name(sdb[n].object)))); } else if (!sdb[n].sensor.lrs_active) { notify(enactor, ansi_red("Long-range sensors are inactive.")); } else { snprintf(buffer, sizeof(buffer), "%s%s--[%sNebula Report%s]--------------------------------------------------------------%s\n%sNebulae Bearing Range Core Vis Core Coordinates%s\n%s-------------------- ------- ------- -------- ---------------------------------%s\n", ANSI_HILITE, ANSI_BLUE, ANSI_YELLOW, ANSI_BLUE, ANSI_NORMAL, ANSI_CYAN, ANSI_WHITE, ANSI_BLUE, ANSI_WHITE); if (aspace_config.nebula >= 1 && im_count(nebula_map) > 0) { for (i = 1; i <= im_count(nebula_map); i++) { nebula = im_find(nebula_map, i); if (!nebula) continue; range = xyz2range(sdb[n].coords.x, sdb[n].coords.y, sdb[n].coords.z, nebula->x, nebula->y, nebula->z) / PARSEC; if (fabs(range - nebula->radius) >= 150.0) continue; strncat(buffer, tprintf("%-20.20s %3d %-3d %-7.7s %7.3f%% %10.3f %10.3f %10.3f\n", nebula->name, (int) round2(xy2bearing((nebula->x - sdb[n].coords.x), (nebula->y - sdb[n].coords.y))), (int) round2(xyz2elevation((nebula->x - sdb[n].coords.x), (nebula->y - sdb[n].coords.y), (nebula->z - sdb[n].coords.z))), unparse_range(xyz2range(sdb[n].coords.x, sdb[n].coords.y, sdb[n].coords.z, nebula->x, nebula->y, nebula->z)), xyz2vis(nebula->x, nebula->y, nebula->z) * 100.0, nebula->x / PARSEC, nebula->y / PARSEC, nebula->z / PARSEC), sizeof(buffer) - 1); } } if (aspace_config.nebula <= 1) { for (z = 0; z < 2; ++z) { for (y = 0; y < 2; ++y) { for (x = 0; x < 2; ++x) { snprintf(nbuff, sizeof(nbuff), "Nebula %d-%d-%d", round2(fabs(cx[x] / 100.0)), round2(fabs(cy[y] / 100.0)), round2(fabs(cz[z] / 100.0))); dx = cx[x] * PARSEC; dy = cy[y] * PARSEC; dz = cz[z] * PARSEC; strncat(buffer, tprintf("%-20.20s %3d %-3d %-7.7s %7.3f%% %10.3f %10.3f %10.3f\n", nbuff, (int) round2(xy2bearing((dx - sdb[n].coords.x), (dy - sdb[n].coords.y))), (int) round2(xyz2elevation((dx - sdb[n].coords.x), (dy - sdb[n].coords.y), (dz - sdb[n].coords.z))), unparse_range(xyz2range(sdb[n].coords.x, sdb[n].coords.y, sdb[n].coords.z, dx, dy, dz)), xyz2vis(dx, dy, dz) * 100.0, cx[x] - sdb[n].coords.xo / PARSEC, cy[y] - sdb[n].coords.yo / PARSEC, cz[z] - sdb[n].coords.zo / PARSEC), sizeof(buffer) - 1); } } } } strncat(buffer, format_l_line(), sizeof(buffer) - 1); strncat(buffer, format_Course(n), sizeof(buffer) - 1); strncat(buffer, format_Speed(n), sizeof(buffer) - 1); strncat(buffer, "\n", sizeof(buffer) - 1); strncat(buffer, format_Location(n), sizeof(buffer) - 1); strncat(buffer, format_Velocity(n), sizeof(buffer) - 1); strncat(buffer, "\n", sizeof(buffer) - 1); strncat(buffer, format_l_end(), sizeof(buffer) - 1); notify(enactor, buffer); return 1; } return 0; }
/* * Border report for a space-object */ int do_border_report (dbref enactor) { static char buffer[BUFFER_LEN]; int index = 0; aspace_borders *sbi; double range; if (error_on_console(enactor)) { return 0; } else if (!sdb[n].sensor.lrs_exist) { notify(enactor, ansi_red(tprintf("%s has no long-range sensors.", Name(sdb[n].object)))); } else if (!sdb[n].sensor.lrs_active) { notify(enactor, ansi_red("Long-range sensors are inactive.")); } else { snprintf(buffer, sizeof(buffer), "%s%s--[%sBorder Report%s]--------------------------------------------------------------%s\n%sEmpire Bearing Range Status Center Coordinates%s\n%s-------------------- ------- ------- -------- ---------------------------------%s\n", ANSI_HILITE, ANSI_BLUE, ANSI_YELLOW, ANSI_BLUE, ANSI_NORMAL, ANSI_CYAN, ANSI_WHITE, ANSI_BLUE, ANSI_WHITE); for (index = 1; index <= im_count(border_map); index++) { sbi = im_find(border_map, index); if (sbi != NULL) { range = xyz2range(sdb[n].coords.x, sdb[n].coords.y, sdb[n].coords.z, sbi->x, sbi->y, sbi->z) / PARSEC; if (fabs(range - sbi->radius) >= 100.0) continue; strncat(buffer, tprintf("%-20.20s ", sbi->name), sizeof(buffer) - 1); if (range > sbi->radius) { strncat(buffer, tprintf("%3d %-3d %-7.7s Outside ", (int) xy2bearing((sbi->x - sdb[n].coords.x), (sbi->y - sdb[n].coords.y)), (int) xyz2elevation((sbi->x - sdb[n].coords.x), (sbi->y - sdb[n].coords.y), (sbi->z - sdb[n].coords.z)), unparse_range((range - sbi->radius) * PARSEC)), sizeof(buffer) - 1); } else { strncat(buffer, tprintf("%3d %-3d %-7.7s Inside ", (int) xy2bearing((sdb[n].coords.x - sbi->x), (sdb[n].coords.y - sbi->y)), (int) xyz2elevation((sdb[n].coords.x - sbi->x), (sdb[n].coords.y - sbi->y), (sdb[n].coords.z - sbi->z)), unparse_range((sbi->radius - range) * PARSEC)), sizeof(buffer) - 1); } strncat(buffer, tprintf("%10.3f %10.3f %10.3f\n", (sbi->x - sdb[n].coords.xo) / PARSEC, (sbi->y - sdb[n].coords.yo) / PARSEC, (sbi->z - sdb[n].coords.zo) / PARSEC), sizeof(buffer) - 1); } } strncat(buffer, format_l_line(), sizeof(buffer) - 1); strncat(buffer, format_Course(n), sizeof(buffer) - 1); strncat(buffer, format_Speed(n), sizeof(buffer) - 1); strncat(buffer, "\n", sizeof(buffer) - 1); strncat(buffer, format_Location(n), sizeof(buffer) - 1); strncat(buffer, format_Velocity(n), sizeof(buffer) - 1); strncat(buffer, "\n", sizeof(buffer) - 1); strncat(buffer, format_l_end(), sizeof(buffer) - 1); notify(enactor, buffer); return 1; } return 0; }