Beispiel #1
0
static dbref
make_player(const char *name, const char *password, const char *host,
            const char *ip)
{
  dbref player;
  char temp[SBUF_LEN];
  char *flaglist, *flagname;
  char flagbuff[BUFFER_LEN];

  player = new_object();

  /* initialize everything */
  set_name(player, name);
  Location(player) = PLAYER_START;
  Home(player) = PLAYER_START;
  Owner(player) = player;
  Parent(player) = NOTHING;
  Type(player) = TYPE_PLAYER;
  Flags(player) = new_flag_bitmask("FLAG");
  strcpy(flagbuff, options.player_flags);
  flaglist = trim_space_sep(flagbuff, ' ');
  if (*flaglist != '\0') {
    while (flaglist) {
      flagname = split_token(&flaglist, ' ');
      twiddle_flag_internal("FLAG", player, flagname, 0);
    }
  }
  if (Suspect_Site(host, player) || Suspect_Site(ip, player))
    set_flag_internal(player, "SUSPECT");
  set_initial_warnings(player);
  /* Modtime tracks login failures */
  ModTime(player) = (time_t) 0;
  (void) atr_add(player, pword_attr, password_hash(password, NULL), GOD, 0);
  giveto(player, START_BONUS); /* starting bonus */
  (void) atr_add(player, "LAST", show_time(mudtime, 0), GOD, 0);
  (void) atr_add(player, "LASTSITE", host, GOD, 0);
  (void) atr_add(player, "LASTIP", ip, GOD, 0);
  (void) atr_add(player, "LASTFAILED", " ", GOD, 0);
  snprintf(temp, sizeof temp, "%d", START_QUOTA);
  (void) atr_add(player, "RQUOTA", temp, GOD, 0);
  (void) atr_add(player, "MAILCURF", "0", GOD,
                 AF_LOCKED | AF_NOPROG | AF_WIZARD);
  add_folder_name(player, 0, "inbox");
  /* link him to PLAYER_START */
  PUSH(player, Contents(PLAYER_START));

  add_player(player);
  add_lock(GOD, player, Basic_Lock, parse_boolexp(player, "=me", Basic_Lock),
           LF_DEFAULT);
  add_lock(GOD, player, Enter_Lock, parse_boolexp(player, "=me", Basic_Lock),
           LF_DEFAULT);
  add_lock(GOD, player, Use_Lock, parse_boolexp(player, "=me", Basic_Lock),
           LF_DEFAULT);

  current_state.players++;

  local_data_create(player);

  return player;
}
Beispiel #2
0
static void 
link_exit(dbref player, dbref exit, dbref dest, int key)
{
    int cost, quot;

    /* Make sure we can link there */

    if ((dest != HOME) &&
	((!controls(player, dest) && !Link_ok(dest)) ||
	 !could_doit(player, dest, A_LLINK, 1, 0))) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* Exit must be unlinked or controlled by you */

    if ((Location(exit) != NOTHING) && !controls(player, exit)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* If exit is unlinked and mudconf 'paranoid_exit_linking' is enabled
     * Do not allow the exit to be linked if you do not control it
     */
    if ( (mudconf.paranoid_exit_linking == 1) && !controls(player,exit) ) {
        notify_quiet(player, "Permission denied.");
	return;
    }

    /* handle costs */

    cost = mudconf.linkcost;
    quot = 0;
    if (Owner(exit) != Owner(player)) {
	cost += mudconf.opencost;
	quot += mudconf.exit_quota;
    }
    if (!canpayfees(player, player, cost, quot, TYPE_EXIT))
	return;

    /* Pay the owner for his loss */

    /* Ok, if paranoid_exit_linking is enabled the linker does NOT own exit */
    if (!(mudconf.paranoid_exit_linking)) {
       if (Owner(exit) != Owner(player)) {
	   giveto(Owner(exit), mudconf.opencost, NOTHING);
	   add_quota(Owner(exit), quot, TYPE_EXIT);
	   s_Owner(exit, Owner(player));
	   s_Flags(exit, (Flags(exit) & ~(INHERIT | WIZARD)) | HALT);
       }
    }
    /* link has been validated and paid for, do it and tell the player */

    s_Location(exit, dest);
    if (!(Quiet(player) || (key & SIDEEFFECT)) )
	notify_quiet(player, "Linked.");
}
Beispiel #3
0
// NFY_DRAIN or NFY_NFYALL
//
static int CallBack_NotifySemaphoreDrainOrAll(PTASK_RECORD p)
{
    if (p->fpTask == Task_SemaphoreTimeout)
    {
        // This represents a semaphore.
        //
        BQUE *point = (BQUE *)(p->arg_voidptr);
        if (  point->sem == Notify_Sem
           && (  point->attr == Notify_Attr
              || !Notify_Attr))
        {
            Notify_Num_Done++;
            if (Notify_Key == NFY_DRAIN)
            {
                // Discard the command
                //
                giveto(point->executor, mudconf.waitcost);
                a_Queue(Owner(point->executor), -1);

                for (int i = 0; i < MAX_GLOBAL_REGS; i++)
                {
                    if (point->scr[i])
                    {
                        RegRelease(point->scr[i]);
                        point->scr[i] = NULL;
                    }
                }

                MEMFREE(point->text);
                point->text = NULL;
                free_qentry(point);

                return IU_REMOVE_TASK;
            }
            else
            {
                // Allow the command to run. The priority may have been
                // PRIORITY_SUSPEND, so we need to change it.
                //
                if (isPlayer(point->enactor))
                {
                    p->iPriority = PRIORITY_PLAYER;
                }
                else
                {
                    p->iPriority = PRIORITY_OBJECT;
                }
                p->ltaWhen.GetUTC();
                p->fpTask = Task_RunQueueEntry;
                return IU_UPDATE_TASK;
            }
        }
    }
    return IU_NEXT_TASK;
}
Beispiel #4
0
static int CallBack_HaltQueue(PTASK_RECORD p)
{
    if (  p->fpTask == Task_RunQueueEntry
#ifdef QUERY_SLAVE
       || p->fpTask == Task_SQLTimeout
#endif // QUERY_SLAVE
       || p->fpTask == Task_SemaphoreTimeout)
    {
        // This is a @wait, timed Semaphore Task, or timed SQL Query.
        //
        BQUE *point = (BQUE *)(p->arg_voidptr);
        if (que_want(point, Halt_Player_Target, Halt_Object_Target))
        {
            // Accounting for pennies and queue quota.
            //
            dbref dbOwner = point->executor;
            if (!isPlayer(dbOwner))
            {
                dbOwner = Owner(dbOwner);
            }
            if (dbOwner != Halt_Player_Run)
            {
                if (Halt_Player_Run != NOTHING)
                {
                    giveto(Halt_Player_Run, mudconf.waitcost * Halt_Entries_Run);
                    a_Queue(Halt_Player_Run, -Halt_Entries_Run);
                }
                Halt_Player_Run = dbOwner;
                Halt_Entries_Run = 0;
            }
            Halt_Entries++;
            Halt_Entries_Run++;
            if (p->fpTask == Task_SemaphoreTimeout)
            {
                add_to(point->sem, -1, point->attr);
            }

            for (int i = 0; i < MAX_GLOBAL_REGS; i++)
            {
                if (point->scr[i])
                {
                    RegRelease(point->scr[i]);
                    point->scr[i] = NULL;
                }
            }

            MEMFREE(point->text);
            point->text = NULL;
            free_qentry(point);
            return IU_REMOVE_TASK;
        }
    }
    return IU_NEXT_TASK;
}
Beispiel #5
0
/** Processing related to players' last connections.
 * Here we check to see if a player gets a paycheck, tell them their
 * last connection site, and update all their LAST* attributes.
 * \param player dbref of player.
 * \param host hostname of player's current connection.
 * \param ip ip address of player's current connection.
 */
void
check_last(dbref player, const char *host, const char *ip)
{
  char *s;
  ATTR *a;
  ATTR *h;
  char last_time[MAX_COMMAND_LEN / 8];
  char last_place[MAX_COMMAND_LEN];

  /* compare to last connect see if player gets salary */
  s = show_time(mudtime, 0);
  a = atr_get_noparent(player, "LAST");
  if (a && (strncmp(atr_value(a), s, 10) != 0))
    giveto(player, Paycheck(player));
  /* tell the player where he last connected from */
  if (!Guest(player)) {
    h = atr_get_noparent(player, "LASTSITE");
    if (h && a) {
      strcpy(last_place, atr_value(h));
      strcpy(last_time, atr_value(a));
      notify_format(player, T("Last connect was from %s on %s."), last_place,
                    last_time);
    }
    /* How about last failed connection */
    h = atr_get_noparent(player, "LASTFAILED");
    if (h && a) {
      strcpy(last_place, atr_value(h));
      if (strlen(last_place) > 2)
        notify_format(player, T("Last FAILED connect was from %s."),
                      last_place);
    }
  }
  /* if there is no Lastsite, then the player is newly created.
   * the extra variables are a kludge to work around some weird
   * behavior involving uncompress.
   */

  /* set the new attributes */
  (void) atr_add(player, "LAST", s, GOD, 0);
  (void) atr_add(player, "LASTSITE", host, GOD, 0);
  (void) atr_add(player, "LASTIP", ip, GOD, 0);
  (void) atr_add(player, "LASTFAILED", " ", GOD, 0);
}
Beispiel #6
0
// ------------------------------------------------------------------
//
// halt_que: Remove all queued commands that match (executor, object).
//
// (NOTHING,  NOTHING)    matches all queue entries.
// (NOTHING,  <object>)   matches only queue entries run from <object>.
// (<executor>, NOTHING)  matches only queue entries owned by <executor>.
// (<executor>, <object>) matches only queue entries run from <objects>
//                        and owned by <executor>.
//
int halt_que(dbref executor, dbref object)
{
    Halt_Player_Target = executor;
    Halt_Object_Target = object;
    Halt_Entries       = 0;
    Halt_Player_Run    = NOTHING;
    Halt_Entries_Run   = 0;

    // Process @wait, timed semaphores, and untimed semaphores.
    //
    scheduler.TraverseUnordered(CallBack_HaltQueue);

    if (Halt_Player_Run != NOTHING)
    {
        giveto(Halt_Player_Run, mudconf.waitcost * Halt_Entries_Run);
        a_Queue(Halt_Player_Run, -Halt_Entries_Run);
        Halt_Player_Run = NOTHING;
    }
    return Halt_Entries;
}
Beispiel #7
0
void move_object(dbref thing, dbref dest)
{
	dbref src;

	/*
	 * Remove from the source location 
	 */

	src = Location(thing);
	if(src != NOTHING)
		s_Contents(src, remove_first(Contents(src), thing));

	/*
	 * Special check for HOME 
	 */

	if(dest == HOME)
		dest = Home(thing);

	/*
	 * Add to destination location 
	 */

	if(dest != NOTHING)
		s_Contents(dest, insert_first(Contents(dest), thing));
	else
		s_Next(thing, NOTHING);
	s_Location(thing, dest);

	/*
	 * Look around and do the penny check 
	 */

	look_in(thing, dest, (LK_SHOWEXIT | LK_OBEYTERSE));
	if(isPlayer(thing) && (mudconf.payfind > 0) &&
	   (Pennies(thing) < mudconf.paylimit) && (!Controls(thing, dest)) &&
	   ((random() % mudconf.payfind) == 0)) {
		giveto(thing, 1);
		notify_printf(thing, "You found a %s!", mudconf.one_coin);
	}
}
Beispiel #8
0
/** Link an exit, room, player, or thing.
 * \verbatim
 * This is the top-level function for @link, which is used to link an
 * exit to a destination, set a player or thing's home, or set a
 * drop-to on a room.
 *
 * Linking an exit usually seizes ownership of the exit and costs 1 penny.
 * 1 penny is also transferred to the former owner.
 * \endverbatim
 * \param player the enactor.
 * \param name the name of the object to link.
 * \param room_name the name of the link destination.
 * \param preserve if 1, preserve ownership and zone data on exit relink.
 */
void
do_link(dbref player, const char *name, const char *room_name, int preserve)
{
  /* Use this to link to a room that you own.
   * It usually seizes ownership of the exit and costs 1 penny,
   * plus a penny transferred to the exit owner if they aren't you.
   * You must own the linked-to room AND specify it by room number.
   */

  dbref thing;
  dbref room;

  if (!room_name || !*room_name) {
    do_unlink(player, name);
    return;
  }
  if (!IsRoom(player) && GoodObject(Location(player)) &&
      IsExit(Location(player))) {
    notify(player, T("You somehow wound up in a exit. No biscuit."));
    return;
  }
  if ((thing = noisy_match_result(player, name, TYPE_EXIT, MAT_EVERYTHING))
      != NOTHING) {
    switch (Typeof(thing)) {
    case TYPE_EXIT:
      if ((room = check_var_link(room_name)) == NOTHING)
        room = parse_linkable_room(player, room_name);
      if (room == NOTHING)
        return;
      if (GoodObject(room) && !can_link_to(player, room)) {
        notify(player, T("Permission denied."));
        break;
      }
      /* We may link an exit if it's unlinked and we pass the link-lock
       * or if we control it.
       */
      if (!(controls(player, thing)
            || ((Location(thing) == NOTHING)
                && eval_lock(player, thing, Link_Lock)))) {
        notify(player, T("Permission denied."));
        return;
      }
      if (preserve && !Wizard(player)) {
        notify(player, T("Permission denied."));
        return;
      }
      /* handle costs */
      if (Owner(thing) == Owner(player)) {
        if (!payfor(player, LINK_COST)) {
          notify_format(player, T("It costs %d %s to link this exit."),
                        LINK_COST, ((LINK_COST == 1) ? MONEY : MONIES));
          return;
        }
      } else {
        if (!payfor(player, LINK_COST + EXIT_COST)) {
          int a = LINK_COST + EXIT_COST;
          notify_format(player, T("It costs %d %s to link this exit."), a,
                        ((a == 1) ? MONEY : MONIES));
          return;
        } else if (!preserve) {
          /* pay the owner for his loss */
          giveto(Owner(thing), EXIT_COST);
          chown_object(player, thing, player, 0);
        }
      }

      /* link has been validated and paid for; do it */
      if (!preserve) {
        Owner(thing) = Owner(player);
        Zone(thing) = Zone(player);
      }
      Location(thing) = room;

      /* notify the player */
      notify_format(player, T("Linked exit #%d to %s"), thing,
                    unparse_object(player, room));
      break;
    case TYPE_PLAYER:
    case TYPE_THING:
      if ((room =
           noisy_match_result(player, room_name, NOTYPE,
                              MAT_EVERYTHING)) == NOTHING) {
        notify(player, T("No match."));
        return;
      }
      if (IsExit(room)) {
        notify(player, T("That is an exit."));
        return;
      }
      if (thing == room) {
        notify(player, T("You may not link something to itself."));
        return;
      }
      /* abode */
      if (!controls(player, room) && !Abode(room)) {
        notify(player, T("Permission denied."));
        break;
      }
      if (!controls(player, thing)) {
        notify(player, T("Permission denied."));
      } else if (room == HOME) {
        notify(player, T("Can't set home to home."));
      } else {
        /* do the link */
        Home(thing) = room;     /* home */
        if (!Quiet(player) && !(Quiet(thing) && (Owner(thing) == player)))
          notify(player, T("Home set."));
      }
      break;
    case TYPE_ROOM:
      if ((room = parse_linkable_room(player, room_name)) == NOTHING)
        return;
      if ((room != HOME) && (!IsRoom(room))) {
        notify(player, T("That is not a room!"));
        return;
      }
      if (!controls(player, thing)) {
        notify(player, T("Permission denied."));
      } else {
        /* do the link, in location */
        Location(thing) = room; /* dropto */
        notify(player, T("Dropto set."));
      }
      break;
    default:
      notify(player, T("Internal error: weird object type."));
      do_log(LT_ERR, NOTHING, NOTHING,
             "Weird object! Type of #%d is %d", thing, Typeof(thing));
      break;
    }
  }
}
Beispiel #9
0
static void give_money (dbref giver, dbref recipient, int key, int amount)
{
dbref	aowner;
int	cost, pcost, rcost, aflags, dpamount;
char	*str;

	/* do amount consistency check */

	if (amount < 0 && ((!Builder(giver) && !HasPriv(giver,recipient,POWER_STEAL,POWER3,NOTHING)) ||
				DePriv(giver,recipient,DP_STEAL,POWER6,NOTHING))) {
		notify(giver,
			unsafe_tprintf("You look through your pockets. Nope, no negative %s.",
				mudconf.many_coins));
		return;
	}

	if (!amount) {
		notify(giver,
			unsafe_tprintf("You must specify a positive number of %s.",
							mudconf.many_coins));
		return;
	}

	dpamount = 0;
	if (amount < 0) 
	  dpamount = DePriv(giver,NOTHING,DP_NOSTEAL,POWER7,POWER_LEVEL_NA);
	else
	  dpamount = DePriv(giver,NOTHING,DP_NOGOLD,POWER7,POWER_LEVEL_NA);
	if (dpamount) {
	  if (DPShift(giver))
	    dpamount--;
	  dpamount = mudconf.money_limit[dpamount];
	}
	else
	  dpamount = -1;
	if (!Admin(Owner(giver))) {
		if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount > mudconf.paylimit)) {
			notify(giver,
				unsafe_tprintf("That player doesn't need that many %s!",
					mudconf.many_coins));
			return;
		}
		if ((Typeof(recipient) != TYPE_PLAYER) && (!could_doit(giver, recipient, A_LUSE,1))) {
			notify(giver,
				unsafe_tprintf("%s won't take your money.",
					Name(recipient)));
			return;
		}
	}

	str = atr_get(Owner(giver), A_PAYLIM, &aowner, &aflags);
	pcost = atoi(str);
	free_lbuf(str);
	if (!Immortal(Owner(giver)) && pcost) {
		if ((Typeof(recipient) == TYPE_PLAYER) && (amount > 0) &&
			 (Pennies(recipient) + amount > pcost)) {
			notify(giver,
				unsafe_tprintf("That player doesn't need that many %s!",
					mudconf.many_coins));
			return;
		}
		else if (Pennies(recipient) + amount < (-pcost)) {
			notify(giver,"That player doesn't need that much debt!");
			return;
		}
	}
        str = atr_get(Owner(recipient), A_RECEIVELIM, &aowner, &aflags);
        rcost = atoi(str);
        free_lbuf(str);
	if (!Immortal(Owner(giver)) && rcost) {
		if ((Typeof(recipient) == TYPE_PLAYER) && (amount > 0) &&
			 (Pennies(recipient) + amount > rcost)) {
			notify(giver,
				unsafe_tprintf("That player doesn't need that many %s!",
					mudconf.many_coins));
			return;
		}
		else if (Pennies(recipient) + amount < (-rcost)) {
			notify(giver,"That player doesn't need that much debt!");
			return;
		}
	}

	if (!Immortal(Owner(giver))) {
	  if (dpamount >= 0) {
	    if (amount > 0) {
	      if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount > dpamount)) {
		notify(giver,
			unsafe_tprintf("That player doesn't need that many %s!",
				mudconf.many_coins));
		return;
	      }
	      else if (amount > dpamount) {
		notify(giver, "Permission denied.");
		return;
	      }
	    }
	    else {
	      if ((Typeof(recipient) == TYPE_PLAYER) && (Pennies(recipient) + amount < (-dpamount))) {
		notify(giver,
			unsafe_tprintf("That player doesn't need that many %s!",
				mudconf.many_coins));
		return;
	      }
	      else if (amount < (-dpamount)) {
		notify(giver, "Permission denied.");
		return;
	      }
	    }
	  }
	}

	/* try to do the give */

	if (!payfor_give(giver, amount)) {
		notify(giver,
			unsafe_tprintf("You don't have that many %s to give!",
				mudconf.many_coins));
		return;
	}

	/* Find out cost if an object */

	if (Typeof(recipient) == TYPE_THING) {
		str = atr_pget(recipient, A_COST, &aowner, &aflags);
		cost = atoi(str);
		free_lbuf(str);

		/* Can't afford it? */

		if (amount < cost) {
			notify(giver, "Feeling poor today?");
			giveto(giver, amount, NOTHING);
			return;
		}

		/* Negative cost */

		if (cost < 0) {
			return;
		}
	} else {
		cost = amount;
	}

	if (!(key & GIVE_QUIET)) {
		if (amount == 1) {
			notify(giver,
				unsafe_tprintf("You give a %s to %s.",
					mudconf.one_coin, Name(recipient)));
			notify_with_cause(recipient, giver,
				unsafe_tprintf("%s gives you a %s.", Name(giver),
					mudconf.one_coin));
		} else {
			notify(giver,
				unsafe_tprintf("You give %d %s to %s.", amount,
					mudconf.many_coins, Name(recipient)));
			notify_with_cause(recipient, giver,
				unsafe_tprintf("%s gives you %d %s.", Name(giver),
				amount, mudconf.many_coins));
		}
	}
	else {
		if (amount == 1) {
			notify(giver,
				unsafe_tprintf("You give a %s to %s. (quiet)",
					mudconf.one_coin, Name(recipient)));
		}
		else {
			notify(giver,
				unsafe_tprintf("You give %d %s to %s. (quiet)",
					amount, mudconf.many_coins,
					Name(recipient)));
		}
	}

	/* Report change given */

	if((amount - cost) == 1) {
        	notify(giver,
			unsafe_tprintf("You get 1 %s in change.", mudconf.one_coin));
		giveto(giver, 1, NOTHING);
	} else if (amount != cost) {
		notify(giver,
			unsafe_tprintf("You get %d %s in change.",
				(amount - cost), mudconf.many_coins));
		giveto(giver, (amount - cost), NOTHING);
	}
	if (pcost && (Pennies(Owner(recipient)) + cost > pcost)) {
	  pcost = pcost - Pennies(Owner(recipient));
	  if (pcost < 0)
	    pcost = 0;
	}
	else
	  pcost = cost;
	if (!giveto(recipient, pcost, giver))
		giveto(giver, cost, NOTHING);

	/* Transfer the money and run PAY attributes */
        /* Rooms should not kick off the PAY attribute */

        if ( !isRoom(giver) )
	   did_it(giver, recipient, A_PAY, NULL, A_OPAY, NULL, A_APAY,
	   	  (char **)NULL, 0);
	return;
}
Beispiel #10
0
void do_kill (dbref player, dbref cause, int key, char *what, char *costchar)
{
dbref	victim;
char	*buf1, *buf2;
int	cost;

	init_match(player, what, TYPE_PLAYER);
	match_neighbor();
	match_me();
	match_here();
	if (Wizard(player)) {
		match_player();
		match_absolute();
	}
	victim = match_result();

	switch (victim) {
	case NOTHING:
		notify(player, "I don't see that player here.");
		break;
	case AMBIGUOUS:
		notify(player, "I don't know who you mean!");
		break;
	default:
		if ((Typeof(victim) != TYPE_PLAYER) &&
		    (Typeof(victim) != TYPE_THING)) {
			notify(player,
				"Sorry, you can only kill players and things.");
			break;
		}
		if ((Haven(Location(victim)) && !Wizard(player)) ||
		    (controls(victim, Location(victim)) &&
		     !controls(player, Location(victim))) ||
		    Immortal(victim)) {
			notify(player, "Sorry.");
			break;
		}
		if (key == KILL_SLAY) {
		  if (Builder(player) && Builder(victim)) {
			notify(player, "Sorry.");
			break;
		  }
		}

		/* go for it */

		cost = atoi(costchar);
		if (key == KILL_KILL) {
			if (HasPriv(victim,player,POWER_NOKILL,POWER4,NOTHING)) {
			  notify(player, "Sorry.");
			  break;
			}
			if (cost < mudconf.killmin)
				cost = mudconf.killmin;
			if (cost > mudconf.killmax)
				cost = mudconf.killmax;

			/* see if it works */

			if (!payfor(player, cost)) {
				notify(player,
					unsafe_tprintf("You don't have enough %s.",
						mudconf.many_coins));
				return;
			}
		} else {
			cost = 0;
		}

		if (!(((random() % mudconf.killguarantee) < cost) ||
		      (key == KILL_SLAY)) ||
		    Wizard(victim)) {

			/* Failure: notify player and victim only */

			notify(player, "Your murder attempt failed.");
			buf1 = alloc_lbuf("do_kill.failed");
			sprintf(buf1, "%s tried to kill you!", Name(player));
			notify_with_cause(victim, player, buf1);
			if (Suspect(player)) {
				strcpy(buf1, Name(player));
				if (player == Owner(player)) {
					raw_broadcast(0, WIZARD,
						"[Suspect] %s tried to kill %s(#%d).",
						buf1, Name(victim), victim);
				} else {
					buf2 = alloc_lbuf("do_kill.SUSP.failed");
					strcpy(buf2, Name(Owner(player)));
					raw_broadcast(0, WIZARD,
						"[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).",
						buf2, buf1, player,
						Name(victim), victim);
					free_lbuf(buf2);
				}
			}
			free_lbuf(buf1);
			break;
		}

		/* Success!  You killed him */

		buf1 = alloc_lbuf("do_kill.succ.1");
		buf2 = alloc_lbuf("do_kill.succ.2");
		if (Suspect(player)) {
			strcpy(buf1, Name(player));
			if (player == Owner(player)) {
				raw_broadcast(0, WIZARD,
					"[Suspect] %s killed %s(#%d).",
					buf1, Name(victim), victim);
			} else {
				strcpy(buf2, Name(Owner(player)));
				raw_broadcast(0, WIZARD,
					"[Suspect] %s <via %s(#%d)> killed %s(#%d).",
					buf2, buf1, player, Name(victim),
					victim);
			}
		}
		sprintf(buf1, "You killed %s!", Name(victim));
		sprintf(buf2, "killed %s!", Name(victim));
		if (Typeof(victim) != TYPE_PLAYER)
			if (halt_que(NOTHING, victim) > 0)
				if (!Quiet(victim))
					notify(Owner(victim), "Halted.");
		did_it(player, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL,
			(char **)NULL, 0);

		/* notify victim */

		sprintf(buf1, "%s killed you!", Name(player));
		notify_with_cause(victim, player, buf1);

		/* Pay off the bonus */

		if (key == KILL_KILL) {
			cost /= 2; 	/* victim gets half */
			if (Pennies(Owner(victim)) < mudconf.paylimit) {
				sprintf(buf1,
					"Your insurance policy pays %d %s.",
					cost, mudconf.many_coins);
				notify(victim, buf1);
				giveto(Owner(victim), cost, NOTHING);
			} else {
				notify(victim,
					"Your insurance policy has been revoked.");
			}
		}
		free_lbuf(buf1);
		free_lbuf(buf2);

		/* send him home */

		move_via_generic(victim, HOME, NOTHING, 0);
		divest_object(victim);
		break;
	}
}
Beispiel #11
0
/** Change an object's owner.
 * \verbatim
 * This implements @chown.
 * \endverbatim
 * \param player the enactor.
 * \param name name of object to change owner of.
 * \param newobj name of new owner for object.
 * \param preserve if 1, preserve privileges and don't halt the object.
 * \param pe_info the pe_info for lock checks
 */
void
do_chown(dbref player, const char *name, const char *newobj, int preserve,
         NEW_PE_INFO *pe_info)
{
  dbref thing;
  dbref newowner = NOTHING;
  long match_flags = MAT_POSSESSION | MAT_HERE | MAT_EXIT | MAT_ABSOLUTE;


  /* check for '@chown <object>/<atr>=<player>'  */
  if (strchr(name, '/')) {
    do_atrchown(player, name, newobj);
    return;
  }
  if (Wizard(player))
    match_flags |= MAT_PLAYER;

  if ((thing = noisy_match_result(player, name, TYPE_THING, match_flags))
      == NOTHING)
    return;

  if (!*newobj || !strcasecmp(newobj, "me")) {
    newowner = player;
  } else {
    if ((newowner = lookup_player(newobj)) == NOTHING) {
      notify(player, T("I couldn't find that player."));
      return;
    }
  }

  if (IsPlayer(thing) && !God(player)) {
    notify(player, T("Players always own themselves."));
    return;
  }
  /* Permissions checking */
  if (!chown_ok(player, thing, newowner, pe_info)) {
    notify(player, T("Permission denied."));
    return;
  }
  if (IsThing(thing) && !Hasprivs(player) &&
      !(GoodObject(Location(thing)) && (Location(thing) == player))) {
    notify(player, T("You must carry the object to @chown it."));
    return;
  }
  if (preserve && !Wizard(player)) {
    notify(player, T("You cannot @CHOWN/PRESERVE. Use normal @CHOWN."));
    return;
  }
  /* chowns to the zone master don't count towards fees */
  if (!ZMaster(newowner)) {
    /* Debit the owner-to-be */
    if (!can_pay_fees(newowner, Pennies(thing))) {
      /* not enough money or quota */
      if (newowner != player)
        notify(player,
               T
               ("That player doesn't have enough money or quota to receive that object."));
      return;
    }
    /* Credit the current owner */
    giveto(Owner(thing), Pennies(thing));
    change_quota(Owner(thing), QUOTA_COST);
  }
  chown_object(player, thing, newowner, preserve);
  notify(player, T("Owner changed."));
}
Beispiel #12
0
// This Task assumes that pEntry is already unlinked from any lists it may
// have been related to.
//
static void Task_RunQueueEntry(void *pEntry, int iUnused)
{
    UNUSED_PARAMETER(iUnused);

    BQUE *point = (BQUE *)pEntry;
    dbref executor = point->executor;

    if (  Good_obj(executor)
       && !Going(executor))
    {
        giveto(executor, mudconf.waitcost);
        mudstate.curr_enactor = point->enactor;
        mudstate.curr_executor = executor;
        a_Queue(Owner(executor), -1);
        point->executor = NOTHING;
        if (!Halted(executor))
        {
            // Load scratch args.
            //
            for (int i = 0; i < MAX_GLOBAL_REGS; i++)
            {
                if (mudstate.global_regs[i])
                {
                    RegRelease(mudstate.global_regs[i]);
                    mudstate.global_regs[i] = NULL;
                }
                mudstate.global_regs[i] = point->scr[i];
                point->scr[i] = NULL;
            }

            char *command = point->comm;

            mux_assert(!mudstate.inpipe);
            mux_assert(mudstate.pipe_nest_lev == 0);
            mux_assert(mudstate.poutobj == NOTHING);
            mux_assert(!mudstate.pout);

            break_called = false;
            while (  command
                  && !break_called)
            {
                mux_assert(!mudstate.poutnew);
                mux_assert(!mudstate.poutbufc);

                char *cp = parse_to(&command, ';', 0);

                if (  cp
                   && *cp)
                {
                    // Will command be piped?
                    //
                    if (  command
                       && *command == '|'
                       && mudstate.pipe_nest_lev < mudconf.ntfy_nest_lim)
                    {
                        command++;
                        mudstate.pipe_nest_lev++;
                        mudstate.inpipe = true;

                        mudstate.poutnew  = alloc_lbuf("process_command.pipe");
                        mudstate.poutbufc = mudstate.poutnew;
                        mudstate.poutobj  = executor;
                    }
                    else
                    {
                        mudstate.inpipe = false;
                        mudstate.poutobj = NOTHING;
                    }

                    CLinearTimeAbsolute ltaBegin;
                    ltaBegin.GetUTC();
                    MuxAlarm.Set(mudconf.max_cmdsecs);
                    CLinearTimeDelta ltdUsageBegin = GetProcessorUsage();

                    char *log_cmdbuf = process_command(executor, point->caller,
                        point->enactor, point->eval, false, cp, point->env,
                        point->nargs);

                    CLinearTimeAbsolute ltaEnd;
                    ltaEnd.GetUTC();
                    if (MuxAlarm.bAlarmed)
                    {
                        notify(executor, "GAME: Expensive activity abbreviated.");
                        s_Flags(point->enactor, FLAG_WORD1, Flags(point->enactor) | HALT);
                        s_Flags(point->executor, FLAG_WORD1, Flags(point->executor) | HALT);
                        halt_que(point->enactor, NOTHING);
                        halt_que(executor, NOTHING);
                    }
                    MuxAlarm.Clear();

                    CLinearTimeDelta ltdUsageEnd = GetProcessorUsage();
                    CLinearTimeDelta ltd = ltdUsageEnd - ltdUsageBegin;
                    db[executor].cpu_time_used += ltd;

                    ltd = ltaEnd - ltaBegin;
                    if (ltd > mudconf.rpt_cmdsecs)
                    {
                        STARTLOG(LOG_PROBLEMS, "CMD", "CPU");
                        log_name_and_loc(executor);
                        char *logbuf = alloc_lbuf("do_top.LOG.cpu");
                        mux_sprintf(logbuf, LBUF_SIZE, " queued command taking %s secs (enactor #%d): ",
                            ltd.ReturnSecondsString(4), point->enactor);
                        log_text(logbuf);
                        free_lbuf(logbuf);
                        log_text(log_cmdbuf);
                        ENDLOG;
                    }
                }

                // Transition %| value.
                //
                if (mudstate.pout)
                {
                    free_lbuf(mudstate.pout);
                    mudstate.pout = NULL;
                }
                if (mudstate.poutnew)
                {
                    *mudstate.poutbufc = '\0';
                    mudstate.pout = mudstate.poutnew;
                    mudstate.poutnew  = NULL;
                    mudstate.poutbufc = NULL;
                }
            }

            // Clean up %| value.
            //
            if (mudstate.pout)
            {
                free_lbuf(mudstate.pout);
                mudstate.pout = NULL;
            }
            mudstate.pipe_nest_lev = 0;
            mudstate.inpipe = false;
            mudstate.poutobj = NOTHING;
        }
    }

    for (int i = 0; i < MAX_GLOBAL_REGS; i++)
    {
        if (point->scr[i])
        {
            RegRelease(point->scr[i]);
            point->scr[i] = NULL;
        }

        if (mudstate.global_regs[i])
        {
            RegRelease(mudstate.global_regs[i]);
            mudstate.global_regs[i] = NULL;
        }
    }

    MEMFREE(point->text);
    point->text = NULL;
    free_qentry(point);
}