void do_parent(dbref player, dbref cause, int key, char *tname, char *pname) { dbref thing, parent, curr; int lev; /* get victim */ init_match(player, tname, NOTYPE); match_everything(0); thing = noisy_match_result(); if (thing == NOTHING) return; /* Make sure we can do it */ if ( NoMod(thing) && !WizMod(player) ) { notify_quiet(player, "Permission denied."); return; } if (!Controls(player, thing) && !could_doit(player,thing,A_LTWINK, 0, 0)) { notify_quiet(player, "Permission denied."); return; } if ( Backstage(player) && NoBackstage(thing) ) { notify_quiet(player, "Permission denied."); return; } /* Find out what the new parent is */ if (*pname) { init_match(player, pname, Typeof(thing)); match_everything(0); parent = noisy_match_result(); if (parent == NOTHING) return; /* Make sure we have rights to set parent */ if (!Parentable(player, parent)) { notify_quiet(player, "Permission denied."); return; } /* Verify no recursive reference */ ITER_PARENTS(parent, curr, lev) { if (curr == thing) { notify_quiet(player, "You can't have yourself as a parent!"); return; } } } else {
void do_unbless(int descr, dbref player, const char *what, const char *propname) { dbref victim; struct match_data md; char buf[BUFFER_LEN]; int cnt; if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only Wizard players may use this command."); return; } if (!propname || !*propname) { notify(player, "Usage is @unbless object=propname."); return; } /* get victim */ init_match(descr, player, what, NOTYPE, &md); match_everything(&md); if ((victim = noisy_match_result(&md)) == NOTHING) { return; } if (!Wizard(OWNER(player))) { notify(player, "Permission denied. (You're not a wizard)"); return; } cnt = blessprops_wildcard(player, victim, "", propname, 0); snprintf(buf, sizeof(buf), "%d propert%s unblessed.", cnt, (cnt == 1)? "y" : "ies"); notify(player, buf); }
static dbref parse_linkable_room(dbref player, char *room_name) { dbref room; init_match(player, room_name, NOTYPE); match_everything(MAT_NO_EXITS | MAT_NUMERIC | MAT_HOME); room = match_result(); /* HOME is always linkable */ if (room == HOME) return HOME; /* Make sure we can link to it */ if (!Good_obj(room)) { notify_quiet(player, "That's not a valid object."); return NOTHING; } else if (!Has_contents(room) || !Linkable(player, room)) { notify_quiet(player, "You can't link to that."); return NOTHING; } else { return room; } }
void do_bless(int descr, dbref player, const char *what, const char *propname) { dbref victim; struct match_data md; char buf[BUFFER_LEN]; int cnt; if (force_level) { notify(player, "Can't @force an @bless."); return; } if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only Wizard players may use this command."); return; } if (!propname || !*propname) { notify(player, "Usage is @bless object=propname."); return; } /* get victim */ init_match(descr, player, what, NOTYPE, &md); match_everything(&md); if ((victim = noisy_match_result(&md)) == NOTHING) { return; } #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(victim))) { notify(player, "Only God may touch God's stuff."); return; } #endif if (!Wizard(OWNER(player))) { notify(player, "Permission denied. (you're not a wizard)"); return; } cnt = blessprops_wildcard(player, victim, "", propname, 1); snprintf(buf, sizeof(buf), "%d propert%s blessed.", cnt, (cnt == 1)? "y" : "ies"); notify(player, buf); }
static dbref parse_linkable_dest(int descr, dbref player, dbref exit, const char *dest_name) { dbref dobj; /* destination room/player/thing/link */ char buf[BUFFER_LEN]; struct match_data md; init_match(descr, player, dest_name, NOTYPE, &md); match_absolute(&md); match_everything(&md); match_home(&md); match_null(&md); if ((dobj = match_result(&md)) == NOTHING || dobj == AMBIGUOUS) { sprintf(buf, CINFO "I couldn't find '%s'.", dest_name); anotify_nolisten2(player, buf); return NOTHING; } if (!tp_teleport_to_player && Typeof(dobj) == TYPE_PLAYER) { sprintf(buf, CFAIL "You can't link to players. Destination %s ignored.", unparse_object(player, dobj)); anotify_nolisten2(player, buf); return NOTHING; } if (!can_link(player, exit)) { anotify_nolisten2(player, CFAIL "You can't link that."); return NOTHING; } if (!can_link_to(player, Typeof(exit), dobj)) { sprintf(buf, CFAIL "You can't link to %s.", unparse_object(player, dobj)); anotify_nolisten2(player, buf); return NOTHING; } else return dobj; }
void do_zone(dbref player, dbref cause, int key, char *tname, char *pname) { dbref thing, zonemaster; switch( key ) { case ZONE_ADD: /* or default */ if( *tname && !*pname ) { init_match(player, tname, NOTYPE); match_everything(0); thing = noisy_match_result(); if( thing == NOTHING ) return; if( !Examinable(player, thing) ) { notify_quiet(player, "You can't do that."); return; } viewzonelist(player, thing); return; } if( !*tname || !*pname ) { notify_quiet(player, "This switch expects two arguments."); return; } init_match(player, tname, NOTYPE); match_everything(0); thing = noisy_match_result(); if( thing == NOTHING ) return; /* Make sure we can do it */ if ( (NoMod(thing) && !WizMod(player)) || (Backstage(player) && NoBackstage(thing)) ) { notify_quiet(player, "Permission denied."); return; } if (!Controls(player, thing)) { notify_quiet(player, "Permission denied."); return; } if( ZoneMaster(thing) ) { notify_quiet(player, "You can't zone a Zone Master."); return; } /* Find out what the new zone is */ init_match(player, pname, NOTYPE); match_everything(0); zonemaster = noisy_match_result(); if (zonemaster == NOTHING) return; if( !ZoneMaster(zonemaster) ) { notify_quiet(player, "That's not a Zone Master."); return; } if(!Controls(player, zonemaster) && !could_doit(player, zonemaster, A_LZONETO, 0, 0) && !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)) { notify_quiet(player, "Permission denied."); return; } if( zlist_inlist(thing, zonemaster) ) { notify_quiet(player, "Object is already in that zone."); return; } zlist_add(thing, zonemaster); zlist_add(zonemaster, thing); notify_quiet(player, "Zone Master added to object."); break; case ZONE_DELETE: if( !*tname || !*pname ) { notify_quiet(player, "This switch expects two arguments."); return; } /* Find out what the zone is */ init_match(player, pname, NOTYPE); match_everything(0); zonemaster = noisy_match_result(); if (zonemaster == NOTHING) return; init_match(player, tname, NOTYPE); match_everything(0); thing = noisy_match_result(); if( thing == NOTHING ) return; if(!zlist_inlist(thing, zonemaster)) { notify_quiet(player, "That is not one of this object's Zone Masters."); return; } /* only need to control zmo or be zonewiz to delete or control object */ if(!Controls(player, thing) && !Controls(player, zonemaster) && !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0) ) { notify_quiet(player, "Permission denied."); return; } if ( (NoMod(thing) && !WizMod(player)) || (Backstage(player) && NoBackstage(thing)) ) { notify_quiet(player, "Permission denied."); return; } zlist_del(thing, zonemaster); zlist_del(zonemaster, thing); notify_quiet(player, "Deleted."); break; case ZONE_PURGE: if( !*tname || *pname) { notify_quiet(player, "This switch expects one argument."); return; } /* Find out what the zone is */ init_match(player, tname, NOTYPE); match_everything(0); thing = noisy_match_result(); if (thing == NOTHING) return; if( ZoneMaster(thing) ) { if(!Controls(player, thing) && !could_doit(player, thing, A_LZONEWIZ, 0, 0)) { notify_quiet(player, "Permission denied."); return; } if ( (NoMod(thing) && !WizMod(player)) || (Backstage(player) && NoBackstage(thing)) ) { notify_quiet(player, "Permission denied."); return; } zlist_destroy(thing); notify_quiet(player, "All objects removed from zone."); } else { if(!Controls(player, thing)) { notify_quiet(player, "Permission denied."); return; } if ( (NoMod(thing) && !WizMod(player)) || (Backstage(player) && NoBackstage(thing)) ) { notify_quiet(player, "Permission denied."); return; } zlist_destroy(thing); notify_quiet(player, "Object removed from all zones."); } break; default: notify_quiet(player, "Unknown switch!"); break; } return; }
void do_link(dbref player, dbref cause, int key, char *what, char *where) { dbref thing, room; char *buff; int nomtest; if ( (key & SIDEEFFECT) && !SideFX(player) ) { notify(player, "#-1 FUNCTION DISABLED"); return; } /* Find the thing to link */ init_match(player, what, TYPE_EXIT); match_everything(0); thing = noisy_match_result(); if (thing == NOTHING) return; nomtest = ((NoMod(thing) && !WizMod(player)) || (DePriv(player,Owner(thing),DP_MODIFY,POWER7,NOTHING) && (Owner(thing) != Owner(player))) || (Backstage(player) && NoBackstage(thing) && !Immortal(player))); /* Allow unlink if where is not specified */ if (!where || !*where) { if (!nomtest) do_unlink(player, cause, key, what); else notify(player,"Permission denied."); return; } switch (Typeof(thing)) { case TYPE_EXIT: /* Set destination */ room = parse_linkable_room(player, where); if (room != NOTHING) { if (!nomtest) link_exit(player, thing, room, key); else notify(player,"Permission denied."); } break; case TYPE_PLAYER: case TYPE_THING: /* Set home */ if (!Controls(player, thing) || nomtest) { notify_quiet(player, "Permission denied."); break; } init_match(player, where, NOTYPE); match_everything(MAT_NO_EXITS); room = noisy_match_result(); if (!Good_obj(room)) break; if (!Has_contents(room)) { notify_quiet(player, "Can't link to an exit."); break; } if (!can_set_home(player, thing, room) || !could_doit(player, room, A_LLINK, 1, 0)) { notify_quiet(player, "Permission denied."); } else if (room == HOME) { notify_quiet(player, "Can't set home to home."); } else { s_Home(thing, room); if (!(Quiet(player) || (key & SIDEEFFECT)) ) notify_quiet(player, "Home set."); } break; case TYPE_ROOM: /* Set dropto */ if (!Controls(player, thing) || nomtest) { notify_quiet(player, "Permission denied."); break; } room = parse_linkable_room(player, where); if (!Good_obj(room) && (room != HOME)) { notify_quiet(player, "Permission denied."); break; } if ((room != HOME) && !isRoom(room)) { notify_quiet(player, "That is not a room!"); } else if ((room != HOME) && ((!controls(player, room) && !Link_ok(room)) || !could_doit(player, room, A_LLINK, 1, 0))) { notify_quiet(player, "Permission denied."); } else { s_Dropto(thing, room); if (!Quiet(player)) notify_quiet(player, "Dropto set."); } break; default: STARTLOG(LOG_BUGS, "BUG", "OTYPE") buff = alloc_mbuf("do_link.LOG.badtype"); sprintf(buff, "Strange object type: object #%d = %d", thing, Typeof(thing)); log_text(buff); free_mbuf(buff); ENDLOG } }
// --------------------------------------------------------------------------- // do_wait: Command interface to wait_que // void do_wait ( dbref executor, dbref caller, dbref enactor, int eval, int key, char *event, char *cmd, char *cargs[], int ncargs ) { CLinearTimeAbsolute ltaWhen; CLinearTimeDelta ltd; // If arg1 is all numeric, do simple (non-sem) timed wait. // if (is_rational(event)) { if (key & WAIT_UNTIL) { ltaWhen.SetSecondsString(event); } else { ltaWhen.GetUTC(); ltd.SetSecondsString(event); ltaWhen += ltd; } wait_que(executor, caller, enactor, eval, true, ltaWhen, NOTHING, 0, cmd, ncargs, cargs, mudstate.global_regs); return; } // Semaphore wait with optional timeout. // char *what = parse_to(&event, '/', 0); init_match(executor, what, NOTYPE); match_everything(0); dbref thing = noisy_match_result(); if (!Good_obj(thing)) { return; } else if (!Controls(executor, thing) && !Link_ok(thing)) { notify(executor, NOPERM_MESSAGE); } else { // Get timeout, default 0. // int atr = A_SEMAPHORE; bool bTimed = false; if (event && *event) { if (is_rational(event)) { if (key & WAIT_UNTIL) { ltaWhen.SetSecondsString(event); } else { ltaWhen.GetUTC(); ltd.SetSecondsString(event); ltaWhen += ltd; } bTimed = true; } else { ATTR *ap = atr_str(event); if (!ap) { atr = mkattr(executor, event); if (atr <= 0) { notify_quiet(executor, "Invalid attribute."); return; } ap = atr_num(atr); } else { atr = ap->number; } if (!bCanSetAttr(executor, thing, ap)) { notify_quiet(executor, NOPERM_MESSAGE); return; } } } int num = add_to(thing, 1, atr); if (num <= 0) { // Thing over-notified, run the command immediately. // thing = NOTHING; bTimed = false; } wait_que(executor, caller, enactor, eval, bTimed, ltaWhen, thing, atr, cmd, ncargs, cargs, mudstate.global_regs); } }
void do_notify ( dbref executor, dbref caller, dbref enactor, int key, int nargs, char *what, char *count ) { UNUSED_PARAMETER(caller); UNUSED_PARAMETER(enactor); UNUSED_PARAMETER(nargs); char *obj = parse_to(&what, '/', 0); init_match(executor, obj, NOTYPE); match_everything(0); dbref thing = noisy_match_result(); if (!Good_obj(thing)) { return; } if (!Controls(executor, thing) && !Link_ok(thing)) { notify(executor, NOPERM_MESSAGE); } else { int atr = A_SEMAPHORE; if ( what && what[0] != '\0') { int i = mkattr(executor, what); if (0 < i) { atr = i; if (atr != A_SEMAPHORE) { // Do they have permission to set this attribute? // ATTR *ap = (ATTR *)anum_get(atr); if (!bCanSetAttr(executor, thing, ap)) { notify_quiet(executor, NOPERM_MESSAGE); return; } } } } int loccount; if ( count && count[0] != '\0') { loccount = mux_atol(count); } else { loccount = 1; } if (loccount > 0) { nfy_que(thing, atr, key, loccount); if ( (!(Quiet(executor) || Quiet(thing))) && key != NFY_QUIET) { if (key == NFY_DRAIN) { notify_quiet(executor, "Drained."); } else { notify_quiet(executor, "Notified."); } } } } }
void do_dequeue(int descr, dbref player, const char *arg1) { char buf[BUFFER_LEN]; int count; dbref match; struct match_data md; timequeue tmp, ptr = tqhead; if (*arg1 == '\0') { notify_nolisten(player, "What event do you want to dequeue?", 1); } else { if (!string_compare(arg1, "all")) { if (!Wizard(OWNER(player))) { notify_nolisten(player, "Permission denied", 1); return; } while (ptr) { tmp = ptr; tqhead = ptr = ptr->next; free_timenode(tmp); process_count--; } tqhead = NULL; muf_event_dequeue(NOTHING, 0); notify_nolisten(player, "Time queue cleared.", 1); } else { if (!number(arg1)) { init_match(descr, player, arg1, NOTYPE, &md); match_absolute(&md); match_everything(&md); match = noisy_match_result(&md); if (match == NOTHING) { notify_nolisten(player, "I don't know what you want to dequeue!", 1); return; } if (!valid_objref(match)) { notify_nolisten(player, "I don't recognize that object.", 1); return; } if ((!Wizard(OWNER(player))) && (OWNER(match) != OWNER(player))) { notify_nolisten(player, "Permission denied.", 1); return; } count = dequeue_prog(match, 0); if (!count) { notify_nolisten(player, "That program wasn't in the time queue.", 1); return; } if (count > 1) { snprintf(buf, sizeof(buf), "%d processes dequeued.", count); } else { snprintf(buf, sizeof(buf), "Process dequeued."); } notify_nolisten(player, buf, 1); } else { if ((count = atoi(arg1))) { if (!(control_process(player, count))) { notify_nolisten(player, "Permission denied.", 1); return; } if (!(dequeue_process(count))) { notify_nolisten(player, "No such process!", 1); return; } process_count--; notify_nolisten(player, "Process dequeued.", 1); } else { notify_nolisten(player, "What process do you want to dequeue?", 1); } } } } return; }