#include <stdio.h> #include <string.h> #include "db.h" #include "config.h" #include "powers.h" #include "externs.h" void do_openexit(OBJ *player, char *direction, char *linkto, OBJ *rexit) /* rexit is so @dig can make a return exit */ { OBJ *loc = (rexit)?rexit:player->location; OBJ *exit, *owner; if(!loc || Typeof(loc) != TYPE_ROOM) { notify(player, "Sorry you can't make an exit here."); return; } if(!*direction) { notify(player, "You need to specify an exit name."); return; } else { if(!ok_exit_name(strip_color(direction))) { notify(player, tprintf("%s is a strange name for an exit!", direction)); return; } } if(!controls(player, loc, POW_MODIFY)) { notify(player, perm_denied()); return; } owner = def_owner(player); if(owns_stuff(owner)+1 > atoi(atr_get(owner, "QUOTA")) && !power(owner, POW_NOQUOTA)) { notify(player, "You don't have enough quota."); return; } exit = new_object(TYPE_EXIT, 1); SET(exit->name, strip_color(direction)); atr_add(exit, "RAINBOW", direction); exit->creator = player; exit->owner = owner; exit->flags = TYPE_EXIT; exit->flags |= OPAQUE; /* Make it transparent cuz it's cool */ exit->flags |= (exit->owner->flags & INHERIT_POWERS); check_spoofobj(player, exit); exit->next_exit = loc->exits; loc->exits = exit; exit->location = loc; exit->link = NULL; notify(player, tprintf("%s opened.", direction)); if(*linkto) do_link(player, tprintf("#%d", exit->dbref), linkto); } void do_link(OBJ *player, char *name, char *room_name) { OBJ *thing; OBJ *room; thing = match_object(player, name, TYPE_MASK & ~TYPE_ROOM); if(!thing) { notify(player, no_match(name)); return; } if(!*room_name) room = NULL; else { if(!string_compare(room_name, "here")) room = player->location; else room = match_dbref(room_name, TYPE_ROOM); if(!room || Typeof(room) != TYPE_ROOM) { notify(player, no_match(room_name)); return; } } if(!controls(player, thing, POW_MODIFY) || (room && !controls(player, room, POW_MODIFY))) { notify(player, perm_denied()); return; } switch(Typeof(thing)) { case TYPE_PLAYER: case TYPE_THING: if(!room) { notify(player, tprintf("You can't remove %s home!", poss(thing))); return; } notify(player, tprintf("%s home set to %s.", poss(thing), unparse_object(player, room))); break; case TYPE_EXIT: if(!room) notify(player, "Unlinked."); else notify(player, tprintf("Linked to %s.", unparse_object(player, room))); break; default: notify(player, "Tell an admin if you see this message!"); return; } thing->link = room; } void do_dig(OBJ *player, char *name, char *arg2) { OBJ *room, *where, *owner; char buf[4096]; char *rexit; where = player->location; if(!*name) { notify(player, "Dig what?"); return; } if(!ok_room_name(strip_color(name))) { notify(player, "That's a silly name for a room!"); return; } owner = def_owner(player); if(owns_stuff(owner)+1 > atoi(atr_get(owner, "QUOTA")) && !power(owner, POW_NOQUOTA)) { notify(player, "You don't have enough quota."); return; } room = new_object(TYPE_ROOM, 1); SET(room->name, strip_color(name)); atr_add(room, "RAINBOW", name); room->creator = player; room->owner = owner; room->flags = TYPE_ROOM; room->location = room; room->flags |= (room->owner->flags & INHERIT_POWERS); check_spoofobj(player, room); notify(player, tprintf("%s created with room number %d.", name, room->dbref)); if(!*arg2) return; strcpy(buf, arg2); if((rexit = strchr(buf, ','))) *rexit++ = '\0'; do_openexit(player, buf, tprintf("#%d", room->dbref), NULL); if(rexit && *rexit) do_openexit(player, rexit, tprintf("#%d", where->dbref), room); } void check_spoofobj(OBJ *player, OBJ *thing) { OBJ *o; if(thing->flags & HAVEN) return; for(o = player_list;o;o = o->next) { if(!strcmp(o->name, thing->name) && !controls(player, o, POW_SPOOF)) { notify(player, tprintf("WARNING: %s can be used to spoof an existing player. It has been set HAVEN.", unparse_object(player, thing))); thing->flags |= HAVEN; } } } void do_create(OBJ *player, char *name) { OBJ *thing, *owner; if(!*name) { notify(player, "Create what?"); return; } if(!ok_thing_name(strip_color(name))) { notify(player, "That's a silly name for a thing!"); return; } owner = def_owner(player); if(owns_stuff(owner)+1 > atoi(atr_get(owner, "QUOTA")) && !power(owner, POW_NOQUOTA)) { notify(player, "You don't have enough quota."); return; } thing = new_object(TYPE_THING, 1); SET(thing->name, strip_color(name)); atr_add(thing, "RAINBOW", name); thing->location = player; thing->creator = player; thing->owner = owner; thing->flags = TYPE_THING; thing->flags |= (thing->owner->flags & INHERIT_POWERS); check_spoofobj(player, thing); if(controls(player, player->location, POW_MODIFY)) thing->link = player->location; else thing->link = player; thing->exits = NULL; thing->next_con = player->contents; player->contents = thing; notify(player, tprintf("%s created.", unparse_object(player, thing))); if(Typeof(player) == TYPE_PLAYER && Wizard(player)) { atr_add(thing, "LOCK", tprintf("#%d", player->dbref)); notify(player, tprintf("%s lock set to %s", poss(thing), unparse_object(player, player))); } }