drop.c

umud/CMD/drop.c · 1.4 KB

From the archive umud2.0.tar.gz

Download the archive   « Back to the archive contents

/*
	Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/

#ifndef	lint
static	char	RCSid[] = "$Header: /home/mjr/hacks/umud/CMD/RCS/drop.c,v 1.1 92/02/09 22:59:28 mjr Exp $";
#endif

/* configure all options BEFORE including system stuff. */
#include	"config.h"


#include	"mud.h"
#include	"match.h"
#include	"vars.h"


/* ARGSUSED */
cmd_drop(argc,argv,who,aswho)
int	argc;
char	*argv[];
char	*who;
char	*aswho;
{
	int	x;
	char	*loc;
	char	*dest;
	char	ob[MAXOID];
	char	*used;
	char	work[MAXOID]; /* Work buffer demanded by ut_dropto() */

	loc = ut_loc(who);

	for(x = 1; x < argc; x++) {
		if(matchinv(who,argv[x],1,MTCH_UNIQ|MTCH_QUIET,ob) &&
				matchinv(who,argv[x],1,MTCH_FRST,ob))
			continue;

		dest = ut_dropto(ob,loc,work);
		used = ut_getatt(who,0,typ_obj,var_using,(char *)0);

		if(used == (char *)0 || strcmp(used,ob)) {
			if(ut_listdel(who,who,var_cont,ob))
				return(UERR_FATAL);
		} else {
			if(ut_unset(who,who,var_using))
				return(UERR_FATAL);
		}
		if(ut_set(who,ob,typ_obj,var_loc,dest))
			return(UERR_FATAL);
		if(ut_listadd(who,dest,var_cont,ob))
			return(UERR_FATAL);

		if(!activate(ACTIV_PONLY,who,ob,loc,var_drop,argc,argv))
			say(who,"dropped ",ut_name(ob),".\n",(char *)0);

		if(!activate(ACTIV_ECAST,who,ob,loc,var_odrop,argc,argv))
			ut_roombcast(loc,who,ut_name(who)," dropped ",ut_name(ob),".\n",(char *)0);;
	}
	return(UERR_NONE);
}

Site Stats

Snippets: 1791
Codebases: 571