Exemple #1
0
static void 
open_exit(dbref player, dbref loc, char *direction, char *linkto, int key)
{
    dbref exit;
    char *tpr_buff, *tprp_buff;

    if (!Good_obj(loc))
	return;

    if (!direction || !*direction) {
	notify_quiet(player, "Open where?");
	return;
    } else if (!controls(player, loc) && !could_doit(player, loc, A_LOPEN, 0, 0)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    exit = create_obj(player, TYPE_EXIT, direction, 0);
    if (exit == NOTHING)
	return;

    /* Initialize everything and link it in. */

    s_Exits(exit, loc);
    s_Next(exit, Exits(loc));
    s_Exits(loc, exit);

    /* and we're done */

    if ( !(key & SIDEEFFECT ) )
       notify_quiet(player, "Opened.");

    /* See if we should do a link */

    if (!linkto || !*linkto)
	return;

    loc = parse_linkable_room(player, linkto);
    if (loc != NOTHING) {

	/* Make sure the player passes the link lock */

	if ((loc != HOME) && !could_doit(player, loc, A_LLINK, 1, 0)) {
	    notify_quiet(player, "You can't link to there.");
	    return;
	}
	/* Link it if the player can pay for it */

	if (!payfor(player, mudconf.linkcost)) {
            tprp_buff = tpr_buff = alloc_lbuf("open_exit");
	    notify_quiet(player,
			 safe_tprintf(tpr_buff, &tprp_buff, "You don't have enough %s to link.",
				 mudconf.many_coins));
            free_lbuf(tpr_buff);
	} else {
	    s_Location(exit, loc);
	    if ( !(key & SIDEEFFECT ) )
	       notify_quiet(player, "Linked.");
	}
    }
}
Exemple #2
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);
	}
}
Exemple #3
0
dbref db_read(FILE * f, int *db_format, int *db_version, int *db_flags)
{
	dbref i, anum;
	char ch;
	const char *tstr;
	int header_gotten, size_gotten, nextattr_gotten;
	int read_attribs, read_name, read_zone, read_link, read_key, read_parent;
	int read_extflags, read_3flags, read_money, read_timestamps,
		read_new_strings;
	int read_powers, read_powers_player, read_powers_any;
	int deduce_version, deduce_name, deduce_zone, deduce_timestamps;
	int aflags, f1, f2, f3;
	BOOLEXP *tempbool;

	header_gotten = 0;
	size_gotten = 0;
	nextattr_gotten = 0;
	g_format = F_UNKNOWN;
	g_version = 0;
	g_flags = 0;
	read_attribs = 1;
	read_name = 1;
	read_zone = 0;
	read_link = 0;
	read_key = 1;
	read_parent = 0;
	read_money = 1;
	read_extflags = 0;
	read_3flags = 0;
	read_timestamps = 0;
	read_new_strings = 0;
	read_powers = 0;
	read_powers_player = 0;
	read_powers_any = 0;
	deduce_version = 1;
	deduce_zone = 1;
	deduce_name = 1;
	deduce_timestamps = 1;
	db_free();
	for(i = 0;; i++) {

		switch (ch = getc(f)) {
		case '-':				/* Misc tag */
			switch (ch = getc(f)) {
			case 'R':			/* Record number of players */
				mudstate.record_players = getref(f);
				break;
			default:
				(void) getstring_noalloc(f, 0);
			}
			break;
		case '+':				/*
								 * MUX and MUSH header 
								 */
			switch (ch = getc(f)) {	/*
									 * 2nd char selects 
									 * type 
									 */
			case 'X':			/*
								 * MUX VERSION 
								 */
				if(header_gotten) {
					fprintf(stderr,
							"\nDuplicate MUX version header entry at object %d, ignored.\n",
							i);
					tstr = getstring_noalloc(f, 0);
					break;
				}
				header_gotten = 1;
				deduce_version = 0;
				g_format = F_MUX;
				g_version = getref(f);

				/*
				 * Otherwise extract feature flags 
				 */

				if(g_version & V_GDBM) {
					read_attribs = 0;
					read_name = !(g_version & V_ATRNAME);
				}
				read_zone = (g_version & V_ZONE);
				read_link = (g_version & V_LINK);
				read_key = !(g_version & V_ATRKEY);
				read_parent = (g_version & V_PARENT);
				read_money = !(g_version & V_ATRMONEY);
				read_extflags = (g_version & V_XFLAGS);
				read_3flags = (g_version & V_3FLAGS);
				read_powers = (g_version & V_POWERS);
				read_new_strings = (g_version & V_QUOTED);
				g_flags = g_version & ~V_MASK;

				g_version &= V_MASK;
				deduce_name = 0;
				deduce_version = 0;
				deduce_zone = 0;
				break;
			case 'S':			/*
								 * SIZE 
								 */
				if(size_gotten) {
					fprintf(stderr,
							"\nDuplicate size entry at object %d, ignored.\n",
							i);
					tstr = getstring_noalloc(f, 0);
				} else {
					mudstate.min_size = getref(f);
				}
				size_gotten = 1;
				break;
			case 'A':			/*
								 * USER-NAMED ATTRIBUTE 
								 */
				anum = getref(f);
				tstr = getstring_noalloc(f, read_new_strings);
				if(isdigit(*tstr)) {
					aflags = 0;
					while (isdigit(*tstr))
						aflags = (aflags * 10) + (*tstr++ - '0');
					tstr++;		/*
								 * skip ':' 
								 */
				} else {
					aflags = mudconf.vattr_flags;
				}
				vattr_define((char *) tstr, anum, aflags);
				break;
			case 'F':			/*
								 * OPEN USER ATTRIBUTE SLOT 
								 */
				anum = getref(f);
				break;
			case 'N':			/*
								 * NEXT ATTR TO ALLOC WHEN NO
								 * FREELIST 
								 */
				if(nextattr_gotten) {
					fprintf(stderr,
							"\nDuplicate next free vattr entry at object %d, ignored.\n",
							i);
					tstr = getstring_noalloc(f, 0);
				} else {
					mudstate.attr_next = getref(f);
					nextattr_gotten = 1;
				}
				break;
			default:
				fprintf(stderr,
						"\nUnexpected character '%c' in MUX header near object #%d, ignored.\n",
						ch, i);
				tstr = getstring_noalloc(f, 0);
			}
			break;
		case '!':				/*
								 * MUX entry/MUSH entry/MUSE non-zoned entry 
								 */
			if(deduce_version) {
				g_format = F_MUX;
				g_version = 1;
				deduce_name = 0;
				deduce_zone = 0;
				deduce_version = 0;
			} else if(deduce_zone) {
				deduce_zone = 0;
				read_zone = 0;
			}
			i = getref(f);
			db_grow(i + 1);

			if(read_name) {
				tstr = getstring_noalloc(f, read_new_strings);
				if(deduce_name) {
					if(isdigit(*tstr)) {
						read_name = 0;
						s_Location(i, atoi(tstr));
					} else {
						s_Name(i, (char *) tstr);
						s_Location(i, getref(f));
					}
					deduce_name = 0;
				} else {
					s_Name(i, (char *) tstr);
					s_Location(i, getref(f));
				}
			} else {
				s_Location(i, getref(f));
			}

			/*
			 * ZONE on MUSE databases and some others 
			 */

			if(read_zone)
				s_Zone(i, getref(f));

			/*
			 * else
			 * * s_Zone(i, NOTHING); 
			 */

			/*
			 * CONTENTS and EXITS 
			 */

			s_Contents(i, getref(f));
			s_Exits(i, getref(f));

			/*
			 * LINK 
			 */

			if(read_link)
				s_Link(i, getref(f));
			else
				s_Link(i, NOTHING);

			/*
			 * NEXT 
			 */

			s_Next(i, getref(f));

			/*
			 * LOCK
			 */

			if(read_key) {
				tempbool = getboolexp(f);
				atr_add_raw(i, A_LOCK, unparse_boolexp_quiet(1, tempbool));
				free_boolexp(tempbool);
			}
			/*
			 * OWNER 
			 */

			s_Owner(i, getref(f));

			/*
			 * PARENT: PennMUSH uses this field for ZONE
			 * (which we  use as PARENT if we
			 * didn't already read in a  
			 * non-NOTHING parent. 
			 */

			if(read_parent) {
				s_Parent(i, getref(f));
			} else {
				s_Parent(i, NOTHING);
			}

			/*
			 * PENNIES 
			 */

			if(read_money)		/*
								 *  if not fix in
								 * unscraw_foreign  
								 */
				s_Pennies(i, getref(f));

			/*
			 * FLAGS 
			 */

			f1 = getref(f);
			if(read_extflags)
				f2 = getref(f);
			else
				f2 = 0;

			if(read_3flags)
				f3 = getref(f);
			else
				f3 = 0;

			s_Flags(i, f1);
			s_Flags2(i, f2);
			s_Flags3(i, f3);

			if(read_powers) {
				f1 = getref(f);
				f2 = getref(f);
				s_Powers(i, f1);
				s_Powers2(i, f2);
			}

			/*
			 * ATTRIBUTES 
			 */

			if(read_attribs) {
				if(!get_list(f, i, read_new_strings)) {
					fprintf(stderr,
							"\nError reading attrs for object #%d\n", i);
					return -1;
				}
			}
			/*
			 * check to see if it's a player 
			 */

			if(Typeof(i) == TYPE_PLAYER) {
				c_Connected(i);
			}
			break;
		case '*':				/*
								 * EOF marker 
								 */
			tstr = getstring_noalloc(f, 0);
			if(strcmp(tstr, "**END OF DUMP***")) {
				fprintf(stderr, "\nBad EOF marker at object #%d\n", i);
				return -1;
			} else {
				/*
				 * Fix up bizarro foreign DBs 
				 */

				*db_version = g_version;
				*db_format = g_format;
				*db_flags = g_flags;
				load_player_names();
				return mudstate.db_top;
			}
		default:
			fprintf(stderr, "\nIllegal character '%c' near object #%d\n",
					ch, i);
			return -1;
		}

	}

}