/* send a standard radio communication */ void send_com(dbref from, char *arg_left, char *arg_right) { dbref com, obj; hship *ship; hcelestial *cel; huniverse *uid; double xmit, rcv; char contact[32]; char *r, *s; char buff[128]; ATTR *a; double sx, sy, sz, tx, ty, tz, dist; char pre[128]; char *mesg; int sent_to_from, send_to_com; if (!IsComm(from)) { notify(from, "You do not have the HS_COMM flag."); return; } uid = NULL; obj = atr_parse_dbref(from, "HSPACE"); if (!RealGoodObject(obj)) { notify(from, "You do not have a valid space id. Board, disembark, eject, or man a console."); return; } if (IsShip(obj)) { ship = find_ship_by_nav(obj); if (!ship) { notify(from, "Your space id is not a valid ship."); return; } if (ship->uid) { sx = ship->x; sy = ship->y; sz = ship->z; uid = ship->uid; } else if (ship->landed) { sx = ship->landed->x; sy = ship->landed->y; sz = ship->landed->z; uid = ship->landed->uid; } else if (ship->docked) { sx = ship->docked->x; sy = ship->docked->y; sz = ship->docked->z; uid = ship->docked->uid; } strncpy(contact, ship_name(ship), 10); } else if (IsCelestial(obj)) { cel = find_celestial(obj); if (!cel) { notify(from, "Your space id is not a valid celestial."); return; } sx = cel->x; sy = cel->y; sz = cel->z; uid = cel->uid; strncpy(contact, celestial_name(cel), 10); } contact[10] = '\0'; if (!uid) { notify(from, "Your space id does not have a valid uid."); return; } if (arg_left && arg_right && *arg_right) { xmit = strtod(arg_left, &s); if (s && *s) { return; } mesg = arg_right; } else { xmit = atr_parse_double(from, "TRANSMIT", 0.0); mesg = arg_left; } if (xmit < 100.0 || xmit > 999.9) { notify(from, "Transmission frequency must be between 100 and 999 MHz."); return; } a = atr_get(from, "CALLSIGN"); if (!a) { snprintf(pre, 127, "%s%s[%s%5.1f MHz%s%s]-[%s%-10s%s]-[%s ", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL, xmit, ANSI_HILITE, ANSI_BLUE, ANSI_GREEN, contact, ANSI_BLUE, ANSI_NORMAL); } else { snprintf(pre, 127, "%s%s[%s%5.1f MHz%s%s]-[%s%-10s%s]-[%s %s<%s%s%s>%s ", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL, xmit, ANSI_HILITE, ANSI_BLUE, ANSI_GREEN, contact, ANSI_BLUE, ANSI_NORMAL, ANSI_CYAN, ANSI_NORMAL, atr_value(a), ANSI_CYAN, ANSI_NORMAL); } /* go through the comm list and check each one */ sent_to_from = 0; for (com = 0; com < db_top; com++) { if (!IsComm(com)) continue; /* check if the user is in the same uid */ obj = atr_parse_dbref(com, "HSPACE"); if (IsShip(obj)) { ship = find_ship_by_nav(obj); if (!ship) continue; if (ship->uid && ship->uid != uid) continue; else if (ship->landed && ship->landed->uid != uid) continue; else if (ship->docked && ship->docked->uid != uid) continue; if (ship->uid) { tx = ship->x; ty = ship->y; tz = ship->z; } else if (ship->landed) { tx = ship->landed->x; ty = ship->landed->y; tz = ship->landed->z; } else if (ship->docked) { tx = ship->docked->x; ty = ship->docked->y; tz = ship->docked->z; } } else if (IsCelestial(obj)) { cel = find_celestial(obj); if (!cel) continue; if (cel->uid != uid) continue; tx = cel->x; ty = cel->y; tz = cel->z; } else { continue; } dist = dist3d(sx, sy, sz, tx, ty, tz) / hs_options.max_comm_dist; if (dist > 1.0) continue; a = atr_get(com, "FREQUENCY"); if (!a) continue; /* check all frequencies to see if we need to send to this com */ send_to_com = 0; snprintf(buff, 127, atr_value(a)); s = buff; while (s) { r = split_token(&s, ' '); rcv = parse_number(r); /* check to see if we're on the right frequency */ if (fabs(rcv - xmit) < 0.1) { send_to_com = 1; break; } } if (send_to_com) { if (com == from) sent_to_from = 1; notify_format(com, "%s%s%s%s]%s", pre, decay_msg(mesg, dist), ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); } } if (!sent_to_from) { notify_format(from, "You send \"%s\" on frequency %5.1f.", mesg, xmit); } }
/* list various hspace objects */ void hs_list(dbref executor, char *arg_left, char *arg_right) { huniverse *uid; hcelestial *cel; hship *ship; int i; dbref obj = NOTHING; /* list various informations */ if (!arg_left || !*arg_left) { notify(executor, "HSPACE: You must specify one of: configuration, universes, celestials, ships"); /* list configuration info */ } else if (!strncasecmp("CONFIGURATION", arg_left, strlen(arg_left))) { hs_print_config(executor, arg_right); /* list universe details */ } else if (!strncasecmp("UNIVERSES", arg_left, strlen(arg_left))) { notify(executor, "HSPACE: Listing universes..."); for (i = 0; i < hs_num_universes; i++) { uid = &hs_universes[i]; notify_format(executor, "%-3d: %s(#%d) %d celestials, %d ships, %d drones", i, Name(uid->objnum), uid->objnum, uid->num_celestials, uid->num_ships, uid->num_drones); } /* list celestial details */ } else if (!strncasecmp("CELESTIALS", arg_left, strlen(arg_left))) { notify(executor, "HSPACE: Listing celestials..."); for (i = 0; i < hs_num_celestials; i++) { cel = &hs_celestials[i]; if (cel->uid) { notify_format(executor, "%-3d: %s(#%d) %d flags, [%s(#%d)] %.0f,%.0f,%.0f", i, Name(cel->objnum), cel->objnum, cel->type, Name(cel->uid->objnum), cel->uid->objnum, cel->x, cel->y, cel->z); } else notify(executor, "HSPACE: Error! Invalid universe."); } /* list ship details */ } else if (!strncasecmp("SHIPS", arg_left, strlen(arg_left))) { notify(executor, "HSPACE: Listing ships..."); for (i = 0; i < hs_num_ships; i++) { ship = &hs_ships[i]; if (ship->uid) obj = ship->uid->objnum; else if (ship->landed) obj = ship->landed->objnum; else if (ship->docked) obj = atr_parse_dbref(ship->docked->objnum, "SHIPOBJ"); notify_format(executor, "%-3d: %s(#%d) [%s(#%d)] (%9.0f %9.0f %9.0f) %.0fm%.0f (%.0fm%.0f) @ %.0f (%.0f) Mm/s", i, ship_name(ship), ship->objnum, RealGoodObject(obj) ? Name(obj) : "*Unknown*", obj, ship->x, ship->y, ship->z, ship->xyhead, ship->zhead, ship->desired_xyhead, ship->desired_zhead, ship->speed, ship->desired_speed); } } return; }
void get_ship_attribute(hship *ship, char *which, char *buff, char **bp) { int len, i; if (!ship) { safe_str("#-1 INVALID OBJECT", buff, bp); return; } if (!which) { safe_str("#-1 INVALID ATTRIBUTE", buff, bp); return; } len = strlen(which); if (len < 1) { safe_str("#-1 INVALID ATTRIBUTE", buff, bp); return; } if (!strncasecmp("OBJNUM", which, len)) { safe_dbref(ship->objnum, buff, bp); } else if (!strncasecmp("NAME", which, len)) { safe_str(ship_name(ship), buff, bp); } else if (!strncasecmp("TYPE", which, len)) { if (HasFlag(ship->type, HS_DRONE)) safe_str("DRONE", buff, bp); else safe_str("SHIP", buff, bp); } else if (!strncasecmp("UNIVERSE", which, len)) { if (ship->uid) safe_dbref(ship->uid->objnum, buff, bp); else safe_dbref(NOTHING, buff, bp); } else if (!strncasecmp("X", which, len)) { safe_integer(ship->x, buff, bp); } else if (!strncasecmp("Y", which, len)) { safe_integer(ship->y, buff, bp); } else if (!strncasecmp("Z", which, len)) { safe_integer(ship->z, buff, bp); } else if (!strncasecmp("SPEED", which, len)) { safe_number(ship->speed, buff, bp); } else if (!strncasecmp("XYHEAD", which, len)) { safe_integer(rint(ship->xyhead), buff, bp); } else if (!strncasecmp("ZHEAD", which, len)) { safe_integer(rint(ship->zhead), buff, bp); } else if (!strncasecmp("LOCK", which, len)) { if (ship->lock) safe_integer(ship->lock->cnum, buff, bp); else safe_str("#-1", buff, bp); } else if (!strncasecmp("WAYPOINT", which, len)) { if (ship->wp_contact && ship->wp_contact->contact) { if (HasFlag(ship->wp_contact->type, HS_ANY_CELESTIAL)) { safe_format(buff, bp, "#%d %.0f %.0f %.0f", ContactObj(ship->wp_contact), ContactCelestial(ship->wp_contact)->x, ContactCelestial(ship->wp_contact)->y, ContactCelestial(ship->wp_contact)->z); } else if (HasFlag(ship->wp_contact->type, HS_ANY_SHIP)) { safe_format(buff, bp, "#%d %.0f %.0f %.0f", ContactObj(ship->wp_contact), ContactShip(ship->wp_contact)->x, ContactShip(ship->wp_contact)->y, ContactShip(ship->wp_contact)->z); } } } else if (!strncasecmp("CONSOLES", which, len)) { for (i = 0; i < ship->nconsoles; i++) { if (i > 0) safe_str(" ", buff, bp); safe_dbref(ship->console[i].objnum, buff, bp); } } else if (!strncasecmp("LANDED", which, len)) { if (ship->landed) safe_dbref(ship->landed->objnum, buff, bp); else safe_dbref(NOTHING, buff, bp); } else if (!strncasecmp("DOCKED", which, len)) { if (ship->docked) safe_dbref(ship->docked->objnum, buff, bp); else safe_dbref(NOTHING, buff, bp); } else if (!strncasecmp("LINKED", which, len)) { if (ship->linked) safe_dbref(ship->linked->objnum, buff, bp); else safe_dbref(NOTHING, buff, bp); } else if (!strncasecmp("ZHEAD", which, len)) { safe_integer(rint(ship->zhead), buff, bp); } else if (!strncasecmp("NAVMODE", which, len)) { safe_str(STR(hs_nav_modes, HasFlag(ship->type, HS_ANY_MODE)), buff, bp); } else if (!strncasecmp("AFTERBURNING", which, len)) { if (HasFlag(ship->type, HS_AFTERBURNING)) safe_integer(1, buff, bp); else safe_integer(0, buff, bp); } else if (!strncasecmp("SHIELD", which, len)) { safe_integer(rint(ship->shield.energy / get_stat(ship, SYS_MAX_CAPACITY) * 100.0), buff, bp); } else if (!strncasecmp("HULL", which, len)) { safe_integer(rint(ship->hull.energy / get_stat(ship, SYS_MAX_ARMOR) * 100.0), buff, bp); } else if (!strncasecmp("ENGINE", which, len)) { safe_integer(rint(ship->engine.energy / get_stat(ship, SYS_MAX_HEAT) * 100.0), buff, bp); } else if (!strncasecmp("REACTOR", which, len)) { safe_integer(rint(ship->reactor.energy / get_stat(ship, SYS_MAX_ENERGY) * 100.0), buff, bp); } else if (!strncasecmp("COMPUTER", which, len)) { safe_integer(rint(ship->computer.energy / get_stat(ship, SYS_MAX_MEMORY) * 100.0), buff, bp); } else if (!strncasecmp("SENSOR", which, len)) { safe_integer(rint(ship->sensor.energy / get_stat(ship, SYS_MAX_FOCUS) * 100.0), buff, bp); } else { safe_str("#-1 INVALID ATTRIBUTE", buff, bp); } return; }
do_LAND_command () { int i, n, found, siege_effectiveness, landing_detected, landed, alien_number, alien_index, alien_pn, array_index, bit_number, requested_alien_landing, alien_here, already_logged; long bit_mask; char *original_line_pointer; struct species_data *alien; struct nampla_data *alien_nampla; /* Get the ship. */ original_line_pointer = input_line_pointer; found = get_ship (); if (! found) { /* Check for missing comma or tab after ship name. */ input_line_pointer = original_line_pointer; fix_separator (); found = get_ship (); if (! found) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid ship name in LAND command.\n"); return; } } /* Make sure the ship is not a starbase. */ if (ship->type == STARBASE) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! A starbase cannot land on a planet!\n"); return; } if (ship->status == UNDER_CONSTRUCTION) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship is still under construction.\n"); return; } if (ship->status == FORCED_JUMP || ship->status == JUMPED_IN_COMBAT) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship jumped during combat and is still in transit.\n"); return; } /* Get the planet number, if specified. */ found = get_value (); get_planet: alien_pn = 0; alien_here = FALSE; requested_alien_landing = FALSE; landed = FALSE; if (! found) { found = get_location (); if (! found || nampla == NULL) found = FALSE; } else { /* Check if we or another species that has declared us ALLY has a colony on this planet. */ found = FALSE; alien_pn = value; requested_alien_landing = TRUE; array_index = (species_number - 1) / 32; bit_number = (species_number - 1) % 32; bit_mask = 1 << bit_number; for (alien_index = 0; alien_index < galaxy.num_species; alien_index++) { if (! data_in_memory[alien_index]) continue; alien = &spec_data[alien_index]; alien_nampla = namp_data[alien_index] - 1; for (i = 0; i < alien->num_namplas; i++) { ++alien_nampla; if (ship->x != alien_nampla->x) continue; if (ship->y != alien_nampla->y) continue; if (ship->z != alien_nampla->z) continue; if (alien_pn != alien_nampla->pn) continue; if ((alien_nampla->status & POPULATED) == 0) continue; if (alien_index == species_number - 1) { /* We have a colony here. No permission needed. */ nampla = alien_nampla; found = TRUE; alien_here = FALSE; requested_alien_landing = FALSE; goto finish_up; } alien_here = TRUE; if ((alien->ally[array_index] & bit_mask) == 0) continue; found = TRUE; break; } if (found) break; } } finish_up: already_logged = FALSE; if (requested_alien_landing && alien_here) { /* Notify the other alien(s). */ landed = found; for (alien_index = 0; alien_index < galaxy.num_species; alien_index++) { if (! data_in_memory[alien_index]) continue; if (alien_index == species_number - 1) continue; alien = &spec_data[alien_index]; alien_nampla = namp_data[alien_index] - 1; for (i = 0; i < alien->num_namplas; i++) { ++alien_nampla; if (ship->x != alien_nampla->x) continue; if (ship->y != alien_nampla->y) continue; if (ship->z != alien_nampla->z) continue; if (alien_pn != alien_nampla->pn) continue; if ((alien_nampla->status & POPULATED) == 0) continue; if ((alien->ally[array_index] & bit_mask) != 0) found = TRUE; else found = FALSE; if (landed && ! found) continue; if (landed) log_string (" "); else log_string ("!!! "); log_string (ship_name (ship)); if (landed) log_string (" was granted"); else log_string (" was denied"); log_string (" permission to land on PL "); log_string (alien_nampla->name); log_string (" by SP "); log_string (alien->name); log_string (".\n"); already_logged = TRUE; nampla = alien_nampla; if (first_pass) break; /* Define a 'landing request' transaction. */ if (num_transactions == MAX_TRANSACTIONS) { fprintf (stderr, "\n\n\tERROR! num_transactions > MAX_TRANSACTIONS!\n\n"); exit (-1); } n = num_transactions++; transaction[n].type = LANDING_REQUEST; transaction[n].value = landed; transaction[n].number1 = alien_index + 1; strcpy (transaction[n].name1, alien_nampla->name); strcpy (transaction[n].name2, ship_name(ship)); strcpy (transaction[n].name3, species->name); break; } } found = TRUE; } if (alien_here && ! landed) return; if (! found) { if ((ship->status == IN_ORBIT || ship->status == ON_SURFACE) && ! requested_alien_landing) { /* Player forgot to specify planet. Use the one it's already at. */ value = ship->pn; found = TRUE; goto get_planet; } fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid or missing planet in LAND command.\n"); return; } /* Make sure the ship and the planet are in the same star system. */ if (ship->x != nampla->x || ship->y != nampla->y || ship->z != nampla->z) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship and planet are not in the same sector.\n"); return; } /* Make sure planet is populated. */ if ((nampla->status & POPULATED) == 0) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Planet in LAND command is not populated.\n"); return; } /* Move the ship. */ ship->pn = nampla->pn; ship->status = ON_SURFACE; if (already_logged) return; /* If the planet is under siege, the landing may be detected by the besiegers. */ log_string (" "); log_string (ship_name (ship)); if (nampla->siege_eff != 0) { if (first_pass) { log_string (" will attempt to land on PL "); log_string (nampla->name); log_string (" in spite of the siege"); } else { if (nampla->siege_eff < 0) siege_effectiveness = -nampla->siege_eff; else siege_effectiveness = nampla->siege_eff; landing_detected = FALSE; if (rnd(100) <= siege_effectiveness) { landing_detected = TRUE; for (i = 0; i < num_transactions; i++) { /* Find out who is besieging this planet. */ if (transaction[i].type != BESIEGE_PLANET) continue; if (transaction[i].x != nampla->x) continue; if (transaction[i].y != nampla->y) continue; if (transaction[i].z != nampla->z) continue; if (transaction[i].pn != nampla->pn) continue; if (transaction[i].number2 != species_number) continue; alien_number = transaction[i].number1; /* Define a 'detection' transaction. */ if (num_transactions == MAX_TRANSACTIONS) { fprintf (stderr, "\n\n\tERROR! num_transactions > MAX_TRANSACTIONS!\n\n"); exit (-1); } n = num_transactions++; transaction[n].type = DETECTION_DURING_SIEGE; transaction[n].value = 1; /* Landing. */ strcpy (transaction[n].name1, nampla->name); strcpy (transaction[n].name2, ship_name(ship)); strcpy (transaction[n].name3, species->name); transaction[n].number3 = alien_number; } } if (rnd(100) <= siege_effectiveness) { /* Ship doesn't know if it was detected. */ log_string (" may have been detected by the besiegers when it landed on PL "); log_string (nampla->name); } else { /* Ship knows whether or not it was detected. */ if (landing_detected) { log_string (" was detected by the besiegers when it landed on PL "); log_string (nampla->name); } else { log_string (" landed on PL "); log_string (nampla->name); log_string (" without being detected by the besiegers"); } } } } else { if (first_pass) log_string (" will land on PL "); else log_string (" landed on PL "); log_string (nampla->name); } log_string (".\n"); }
do_ORBIT_command () { int i, found, specified_planet_number; char *original_line_pointer; /* Get the ship. */ original_line_pointer = input_line_pointer; found = get_ship (); if (! found) { /* Check for missing comma or tab after ship name. */ input_line_pointer = original_line_pointer; fix_separator (); found = get_ship (); if (! found) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid ship name in ORBIT command.\n"); return; } } if (ship->status == UNDER_CONSTRUCTION) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship is still under construction.\n"); return; } if (ship->status == FORCED_JUMP || ship->status == JUMPED_IN_COMBAT) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship jumped during combat and is still in transit.\n"); return; } /* Make sure this ship didn't just arrive via a MOVE command. */ if (ship->just_jumped == 50) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! ORBIT not allowed immediately after a MOVE!\n"); return; } /* Make sure ship is not salvage of a disbanded colony. */ if (disbanded_ship (ship)) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! This ship is salvage of a disbanded colony!\n"); return; } /* Get the planet. */ specified_planet_number = get_value (); get_planet: if (specified_planet_number) { found = FALSE; specified_planet_number = value; for (i = 0; i < num_stars; i++) { star = star_base + i; if (star->x != ship->x) continue; if (star->y != ship->y) continue; if (star->z != ship->z) continue; if (specified_planet_number >= 1 && specified_planet_number <= star->num_planets) found = TRUE; break; } if (! found) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid planet in ORBIT command.\n"); return; } ship->pn = specified_planet_number; goto finish_up; } found = get_location (); if (! found || nampla == NULL) { if (ship->status == IN_ORBIT || ship->status == ON_SURFACE) { /* Player forgot to specify planet. Use the one it's already at. */ specified_planet_number = ship->pn; value = specified_planet_number; goto get_planet; } fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid or missing planet in ORBIT command.\n"); return; } /* Make sure the ship and the planet are in the same star system. */ if (ship->x != nampla->x || ship->y != nampla->y || ship->z != nampla->z) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship and planet are not in the same sector.\n"); return; } /* Move the ship. */ ship->pn = nampla->pn; finish_up: ship->status = IN_ORBIT; /* If a planet number is being used, see if it has a name. If so, use the name. */ if (specified_planet_number) { for (i = 0; i < species->num_namplas; i++) { nampla = nampla_base + i; if (nampla->x != ship->x) continue; if (nampla->y != ship->y) continue; if (nampla->z != ship->z) continue; if (nampla->pn != specified_planet_number) continue; specified_planet_number = 0; break; } } /* Log result. */ log_string (" "); log_string (ship_name (ship)); if (first_pass) log_string (" will enter orbit around "); else log_string (" entered orbit around "); if (specified_planet_number) { log_string ("planet number "); log_int (specified_planet_number); } else { log_string ("PL "); log_string (nampla->name); } log_string (".\n"); }
do_DEEP_command () { int i, found; char *original_line_pointer; /* Get the ship. */ original_line_pointer = input_line_pointer; found = get_ship (); if (! found) { /* Check for missing comma or tab after ship name. */ input_line_pointer = original_line_pointer; fix_separator (); found = get_ship (); if (! found) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Invalid ship name in ORBIT command.\n"); return; } } if (ship->type == STARBASE) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! DEEP order may not be given for a starbase.\n"); return; } if (ship->status == UNDER_CONSTRUCTION) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship is still under construction.\n"); return; } if (ship->status == FORCED_JUMP || ship->status == JUMPED_IN_COMBAT) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! Ship jumped during combat and is still in transit.\n"); return; } /* Make sure ship is not salvage of a disbanded colony. */ if (disbanded_ship (ship)) { fprintf (log_file, "!!! Order ignored:\n"); fprintf (log_file, "!!! %s", original_line); fprintf (log_file, "!!! This ship is salvage of a disbanded colony!\n"); return; } /* Move the ship. */ ship->pn = 0; ship->status = IN_DEEP_SPACE; /* Log result. */ log_string (" "); log_string (ship_name (ship)); log_string (" moved into deep space.\n"); }
int main(int argc, char *argv[]) { int i, c, rc; char buffer[1000]; struct mtwist_state *mt; enum planet_type pt; int count = 1; int npc_mode = 0; int planet_mode = 0; int robot_mode = 0; int ship_mode = 0; int taunt_mode = 0; int warning_mode = 0; set_random_seed(&mt); while (1) { int option_index; c = getopt_long(argc, argv, "c:nprstw", long_options, &option_index); if (c < 0) { break; } switch (c) { case 'c': rc = sscanf(optarg, "%d", &count); if (rc != 1) count = 0; break; case 'n': npc_mode = 1; break; case 'p': planet_mode = 1; break; case 'r': robot_mode = 1; break; case 's': ship_mode = 1; break; case 't': taunt_mode = 1; break; case 'w': warning_mode = 1; break; default: fprintf(stderr, "%s: Unknown option.\n", argv[0]); usage(argv[0]); } } if (taunt_mode + planet_mode + warning_mode + npc_mode + robot_mode + ship_mode == 0) usage(argv[0]); for (i = 0; i < count; i++) { if (taunt_mode) { infinite_taunt(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (planet_mode) { pt = PlanetType(mt); planet_description(mt, buffer, sizeof(buffer) - 1, 60, pt); printf("%s\n", buffer); } if (warning_mode) { cop_attack_warning(mt, buffer, sizeof(buffer) - 1, 50); printf("%s\n", buffer); } if (npc_mode) { character_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (robot_mode) { robot_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } if (ship_mode) { ship_name(mt, buffer, sizeof(buffer) - 1); printf("%s\n", buffer); } } free(mt); return 0; }