void tech_fix(dbref player, void *data, char *buffer) { MECH *mech = data; int n = atoi(buffer); int low, high; int isds; skipws(buffer); TECHCOMMANDC; if (unit_is_fixable(mech)) make_damage_table(mech); else make_scrap_table(mech); DOCHECK(!damage_last && MechType(mech) == CLASS_MECH, "The 'mech is in pristine condition!"); DOCHECK(!damage_last, "It's in pristine condition!"); if (sscanf(buffer, "%d-%d", &low, &high) == 2) { DOCHECK(low < 1 || low > damage_last, "Invalid low #!"); DOCHECK(high < 1 || high > damage_last, "Invalid high #!"); for (n = low; n <= high; n++) fix_entry(player, mech, n); return; } DOCHECK(n < 1 || n > damage_last, "Invalid #!"); fix_entry(player, mech, n); }
void mech_createbays(dbref player, void *data, char *buffer) { char *args[NUM_BAYS + 1]; int argc; dbref it; int i; MECH *ds = (MECH *) data; MAP *map; DOCHECK((argc = mech_parseattributes(buffer, args, NUM_BAYS + 1)) == (NUM_BAYS + 1), "Invalid number of arguments!"); for(i = 0; i < argc; i++) { it = match_thing(player, args[i]); DOCHECK(it == NOTHING, tprintf("Argument %d is invalid.", i + 1)); DOCHECK(!IsMap(it), tprintf("Argument %d is not a map.", i + 1)); map = FindObjectsData(it); AeroBay(ds, i) = it; map->onmap = ds->mynum; } for(i = argc; i < NUM_BAYS; i++) AeroBay(ds, i) = -1; notify_printf(player, "%d bay(s) set up!", argc); }
void mech_c3i_network(dbref player, MECH * mech, char *buffer) { cch(MECH_USUALO); DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!"); DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!"); DOCHECK(AnyECMDisturbed(mech), "Your C3i system is not currently operational!"); validateC3iNetwork(mech); DOCHECK(MechC3iNetworkSize(mech) <= 0, "There are no other units in your C3i network!"); showNetworkData(player, mech, 0); }
void debug_setwbv(dbref player, void *data, char *buffer) { char *args[3]; int bv; int id, brand; DOCHECK(mech_parseattributes(buffer, args, 3) != 2, "Invalid arguments!"); DOCHECK(Readnum(bv, args[1]), "Invalid value!"); DOCHECK(bv <0, "BV needs to be >=0"); DOCHECK(!find_matching_vlong_part(args[0], NULL, &id, &brand), "That is no weapon!"); DOCHECK(!IsWeapon(id), "That is no weapon!"); MechWeapons[Weapon2I(id)].battlevalue = bv; notify_printf(player, "BV for %s set to %d.", MechWeapons[Weapon2I(id)].name, bv); }
void mech_c3i_message(dbref player, MECH * mech, char *buffer) { cch(MECH_USUALO); DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!"); DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!"); DOCHECK(AnyECMDisturbed(mech), "Your C3i system is not currently operational!"); validateC3iNetwork(mech); DOCHECK(MechC3iNetworkSize(mech) <= 0, "There are no other units in your C3i network!"); skipws(buffer); DOCHECK(!*buffer, "What do you want to send on the C3i Network?"); sendNetworkMessage(player, mech, buffer, 0); }
void debug_setvrt(dbref player, void *data, char *buffer) { char *args[3]; int vrt; int id, brand; DOCHECK(mech_parseattributes(buffer, args, 3) != 2, "Invalid arguments!"); DOCHECK(Readnum(vrt, args[1]), "Invalid value!"); DOCHECK(vrt <= 0, "VRT needs to be >0"); DOCHECK(vrt > 127, "VRT can be at max 127"); DOCHECK(!find_matching_vlong_part(args[0], NULL, &id, &brand), "That is no weapon!"); DOCHECK(!IsWeapon(id), "That is no weapon!"); MechWeapons[Weapon2I(id)].vrt = vrt; notify_printf(player, "VRT for %s set to %d.", MechWeapons[Weapon2I(id)].name, vrt); log_error(LOG_WIZARD, "WIZ", "CHANGE", "VRT for %s set to %d by #%d", MechWeapons[Weapon2I(id)].name, vrt, player); }
void mech_enterbay(dbref player, void *data, char *buffer) { char *args[3]; int argc; dbref ref = -1, bayn = -1; MECH *mech = data, *ds; MAP *map; cch(MECH_USUAL); DOCHECK(MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0, "You lack fuel to maneuver in!"); DOCHECK(Jumping(mech), "While in mid-jump? No way."); DOCHECK(MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech)), "Crawl inside? I think not. Stand first."); DOCHECK(OODing(mech), "While in mid-flight? No way."); DOCHECK((argc = mech_parseattributes(buffer, args, 2)) == 2, "Hmm, invalid number of arguments?"); if(argc > 0) DOCHECK((ref = FindTargetDBREFFromMapNumber(mech, args[0])) <= 0, "Invalid target!"); if(ref < 0) { DOCHECK(!Find_Single_DS_In_MechHex(mech, &ref, &bayn), "No DS bay found in your hex!"); DOCHECK(ref < 0, "Multiple enterable things found ; use the id for specifying which you want."); DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); } else { DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); DOCHECK(!Find_DS_Bay_In_MechHex(mech, ds, &bayn), "You see no bays in your hex."); } DOCHECK(IsDS(mech) && !(MechSpecials2(mech) & CARRIER_TECH), "Your craft can't enter bays."); DOCHECK(!DS_Bay_Is_Open(mech, ds, AeroBay(ds, bayn)), "The door has been jammed!"); DOCHECK(IsDS(mech), "Your unit is a bit too large to fit in there."); DOCHECK((fabs((float) (MechSpeed(mech) - MechSpeed(ds)))) > MP1, "Speed difference's too large to enter!"); DOCHECK(MechZ(ds) != MechZ(mech), "Get to same elevation before thinking about entering!"); DOCHECK(abs(MechVerticalSpeed(mech) - MechVerticalSpeed(ds)) > 10, "Vertical speed difference is too great to enter safely!"); DOCHECK(MechType(mech) == CLASS_MECH && !MechIsQuad(mech) && (IsMechLegLess(mech)), "Without legs? Are you kidding?"); ref = AeroBay(ds, bayn); map = getMap(ref); DOCHECK(!map, "You sense wrongness in fabric of space."); DOCHECK(EnteringHangar(mech), "You are already entering the hangar!"); if(!can_pass_lock(mech->mynum, ref, A_LENTER)) { char *msg = silly_atr_get(ref, A_FAIL); if(!msg || !*msg) msg = "You are unable to enter the bay!"; notify(player, msg); return; } DOCHECK(!DS_Bay_Is_EnterOK(mech, ds, AeroBay(ds, bayn)), "Someone else is using the door at the moment."); DOCHECK(!(map = getMap(mech->mapindex)), "You sense a wrongness in fabric of space."); HexLOSBroadcast(map, MechX(mech), MechY(mech), "The bay doors at $h start to open.."); MECHEVENT(mech, EVENT_ENTER_HANGAR, mech_enterbay_event, 12, ref); }
REGISTER_TESTS_END // TestFixupFolderPath //------------------------------------------------------------------------------ void TestPathUtils::TestFixupFolderPath() const { #define DOCHECK( before, after ) \ { \ AStackString<> path( before ); \ PathUtils::FixupFolderPath( path ); \ TEST_ASSERT( path == after ); \ } #if defined( __WINDOWS__ ) // standard windows path DOCHECK( "c:\\folder", "c:\\folder\\" ) // redundant slashes DOCHECK( "c:\\folder\\\\thing", "c:\\folder\\thing\\" ) // UNC path double slash is preserved DOCHECK( "\\\\server\\folder", "\\\\server\\folder\\" ) #endif #undef DOCHECK } // TestPathBeginsWith //------------------------------------------------------------------------------ void TestPathUtils::TestPathBeginsWith() const {
void mech_c3i_join_leave(dbref player, void *data, char *buffer) { MECH *mech = (MECH *) data, *target; MAP *objMap; char *args[2]; dbref refTarget; int LOS = 1; float range = 0.0; cch(MECH_USUALO); DOCHECK(mech_parseattributes(buffer, args, 2) != 1, "Invalid number of arguments to function!"); DOCHECK(!HasC3i(mech), "This unit is not equipped with C3i!"); DOCHECK(C3iDestroyed(mech), "Your C3i system is destroyed!"); DOCHECK(AnyECMDisturbed(mech), "Your C3i system is not currently operational!"); validateC3iNetwork(mech); /* Clear our C3i Network */ if (!strcmp(args[0], "-")) { if (MechC3iNetworkSize(mech) <= 0) { mech_notify(mech, MECHALL, "You are not connected to a C3i network!"); return; } clearC3iNetwork(mech, 1); mech_notify(mech, MECHALL, "You disconnect from the C3i network."); return; } /* Well, if we're here then we wanna connect to a network */ /* Let's check to see if we're already in one... can't be in two at the same time */ DOCHECK(MechC3iNetworkSize(mech) > 0, "You are already in a C3i network!"); objMap = getMap(mech->mapindex); /* Find who we're trying to connect to */ refTarget = FindTargetDBREFFromMapNumber(mech, args[0]); target = getMech(refTarget); if (target) { LOS = InLineOfSight(mech, target, MechX(target), MechY(target), range); } else refTarget = 0; DOCHECK((refTarget < 1) || !LOS, "That is not a valid targetID. Try again."); DOCHECK(MechTeam(mech) != MechTeam(target), "You can't use the C3i network of unfriendly units!"); DOCHECK(mech == target, "You can't connect to yourself!"); DOCHECK(Destroyed(target), "That unit is destroyed!"); DOCHECK(!Started(target), "That unit is not started!"); DOCHECK(!HasC3i(target), "That unit does not appear to be equipped with C3i!"); /* validate the network of our target */ validateC3iNetwork(target); DOCHECK(MechC3iNetworkSize(target) >= C3I_NETWORK_SIZE, "That unit's C3i network is operating at maximum capacity!"); /* Connect us up */ mech_notify(mech, MECHALL, tprintf("You connect to %s's C3i network.", GetMechToMechID(mech, target))); addMechToC3iNetwork(target, mech); }
void show_mechs_damage(dbref player, void *data, char *buffer) { MECH *mech = data; coolmenu *c = NULL; int i, j, v1, v2; char buf[MBUF_SIZE]; char buf2[MBUF_SIZE]; int isds; TECHCOMMANDD; if (unit_is_fixable(mech)) make_damage_table(mech); else make_scrap_table(mech); DOCHECK(!damage_last && MechType(mech) == CLASS_MECH, "The 'mech is in pristine condition!"); DOCHECK(!damage_last, "It's in pristine condition!"); addline(); cent(tprintf("Damage for %s", GetMechID(mech))); addline(); for (i = 0; i < damage_last; i++) { v1 = damage_table[i][1]; v2 = damage_table[i][2]; switch (damage_table[i][0]) { case REATTACH: case DETACH: case RESEAL: case REPLACESUIT: strcpy(buf, repair_need_msgs[(int) damage_table[i][0]]); break; case REPAIRP: case REPAIRP_T: case REPAIRG: case ENHCRIT_MISC: case ENHCRIT_FOCUS: case ENHCRIT_CRYSTAL: case ENHCRIT_BARREL: case ENHCRIT_AMMOB: case ENHCRIT_RANGING: case ENHCRIT_AMMOM: case SCRAPP: case SCRAPG: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2)); break; case RELOAD: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2), FullAmmo(mech, v1, v2) - GetPartData(mech, v1, v2)); break; case UNLOAD: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2), GetPartData(mech, v1, v2)); break; case FIXARMOR: case FIXARMOR_R: case FIXINTERNAL: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], damage_table[i][2]); break; } j = is_under_repair(mech, i); sprintf(buf2, "%%ch%s%-2d:%s %%cn%s%s", j ? "%cg" : "%cy", i + 1, ShortArmorSectionString(MechType(mech), MechMove(mech), v1), buf, j ? " (*)" : ""); vsi(buf2); } addline(); vsi("(*) / %ch%cgGreen%cn = Job already done. %ch%cyYellow%cn = To be done."); addline(); ShowCoolMenu(player, c); KillCoolMenu(c); }
int procfs_dostatus(struct proc *curp, struct lwp *lp, struct pfsnode *pfs, struct uio *uio) { struct proc *p = lp->lwp_proc; struct session *sess; struct tty *tp; struct ucred *cr; char *ps; char *sep; int pid, ppid, pgid, sid; size_t xlen; int i; int error; char psbuf[256]; /* XXX - conservative */ if (uio->uio_rw != UIO_READ) return (EOPNOTSUPP); pid = p->p_pid; ppid = p->p_pptr ? p->p_pptr->p_pid : 0; pgid = p->p_pgrp->pg_id; sess = p->p_pgrp->pg_session; sid = sess->s_leader ? sess->s_leader->p_pid : 0; /* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg euid ruid rgid,egid,groups[1 .. NGROUPS] */ KASSERT(sizeof(psbuf) > MAXCOMLEN, ("Too short buffer for new MAXCOMLEN")); ps = psbuf; bcopy(p->p_comm, ps, MAXCOMLEN); ps[MAXCOMLEN] = '\0'; ps += strlen(ps); DOCHECK(); ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " %d %d %d %d ", pid, ppid, pgid, sid); DOCHECK(); if ((p->p_flags & P_CONTROLT) && (tp = sess->s_ttyp)) ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "%d,%d ", major(tp->t_dev), minor(tp->t_dev)); else ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "%d,%d ", -1, -1); DOCHECK(); sep = ""; if (sess->s_ttyvp) { ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "%sctty", sep); sep = ","; DOCHECK(); } if (SESS_LEADER(p)) { ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "%ssldr", sep); sep = ","; DOCHECK(); } if (*sep != ',') { ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "noflags"); DOCHECK(); } if (p->p_flags & P_SWAPPEDOUT) { ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " -1,-1 -1,-1 -1,-1"); } else { struct rusage ru; calcru_proc(p, &ru); ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " %ld,%ld %ld,%ld %ld,%ld", p->p_start.tv_sec, p->p_start.tv_usec, ru.ru_utime.tv_sec, ru.ru_utime.tv_usec, ru.ru_stime.tv_sec, ru.ru_stime.tv_usec); } DOCHECK(); ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " %s", (lp->lwp_wchan && lp->lwp_wmesg) ? lp->lwp_wmesg : "nochan"); DOCHECK(); cr = p->p_ucred; ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " %lu %lu %lu", (u_long)cr->cr_uid, (u_long)p->p_ucred->cr_ruid, (u_long)p->p_ucred->cr_rgid); DOCHECK(); /* egid (p->p_ucred->cr_svgid) is equal to cr_ngroups[0] see also getegid(2) in /sys/kern/kern_prot.c */ for (i = 0; i < cr->cr_ngroups; i++) { ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, ",%lu", (u_long)cr->cr_groups[i]); DOCHECK(); } if (p->p_ucred->cr_prison) ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " %s", p->p_ucred->cr_prison->pr_host); else ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, " -"); DOCHECK(); ps += ksnprintf(ps, psbuf + sizeof(psbuf) - ps, "\n"); DOCHECK(); xlen = ps - psbuf; error = uiomove_frombuf(psbuf, xlen, uio); bailout: return (error); }