Esempio n. 1
0
/*
 * Destructor: clean any state inside the Command object
 */
static void
Command_dealloc(twopence_Command *self)
{
	twopence_env_destroy(&self->environ);
	drop_string(&self->command);
	drop_string(&self->user);
	drop_string(&self->stdinPath);
	drop_object(&self->stdout);
	drop_object(&self->stderr);
	drop_object(&self->stdin);
}
Esempio n. 2
0
/*
	function to drop an object
 */
static void
dropobj(void)
{
	int    i;
	unsigned char  *p;
	long            amt;
	p = &item[playerx][playery];
	while (1) {
		if ((i = whatitem("drop")) == '\33')
			return;
		if (i == '*')
			showstr();
		else {
			if (i == '.') {	/* drop some gold */
				if (*p) {
					lprcat("\nThere's something here already!");
					return;
				}
				lprcat("\n\n");
				cl_dn(1, 23);
				lprcat("How much gold do you drop? ");
				if ((amt = readnum((long) c[GOLD])) == 0)
					return;
				if (amt > c[GOLD]) {
					lprcat("\nYou don't have that much!");
					return;
				}
				if (amt <= 32767) {
					*p = OGOLDPILE;
					i = amt;
				} else if (amt <= 327670L) {
					*p = ODGOLD;
					i = amt / 10;
					amt = 10 * i;
				} else if (amt <= 3276700L) {
					*p = OMAXGOLD;
					i = amt / 100;
					amt = 100 * i;
				} else if (amt <= 32767000L) {
					*p = OKGOLD;
					i = amt / 1000;
					amt = 1000 * i;
				} else {
					*p = OKGOLD;
					i = 32767;
					amt = 32767000L;
				}
				c[GOLD] -= amt;
				lprintf("You drop %ld gold pieces", (long)amt);
				iarg[playerx][playery] = i;
				bottomgold();
				know[playerx][playery] = 0;
				dropflag = 1;
				return;
			}
			drop_object(i - 'a');
			return;
		}
	}
}
Esempio n. 3
0
File: aoi.c Progetto: ChowZenki/aoi
void
aoi_update(struct aoi_space * space , uint32_t id, const char * modestring , float pos[3]) {
	struct object * obj = map_query(space, space->object,id);
	int i;
	bool set_watcher = false;
	bool set_marker = false;

	for (i=0;modestring[i];++i) {
		char m = modestring[i];
		switch(m) {
		case 'w':
			set_watcher = true;
			break;
		case 'm':
			set_marker = true;
			break;
		case 'd':
			obj->mode = MODE_DROP;
			drop_object(space, obj);
			return;
		}
	}
	obj->mode &= ~MODE_DROP;

	bool changed = change_mode(obj, set_watcher, set_marker);

	copy_position(obj->position, pos);
	if (changed || !is_near(pos, obj->last)) {
		// new object or change object mode
		// or position changed
		copy_position(obj->last , pos);
		obj->mode |= MODE_MOVE;
		++obj->version;
	} 
}
Esempio n. 4
0
static void
mdelete(struct map *m, uint32_t id) {
	struct object * obj = map_drop(m , id);
//	printf("delete %u\n",id);
	assert(obj != NULL);
	assert(obj->id == id);
	assert(obj->ref == 1);
	drop_object(SPACE, obj);
}
Esempio n. 5
0
/*
 * Destructor: clean any state inside the Transfer object
 */
static void
Transfer_dealloc(twopence_Transfer *self)
{
	twopence_buf_destroy(&self->databuf);
	drop_string(&self->remote_filename);
	drop_string(&self->local_filename);
	drop_string(&self->user);
	drop_object(&self->buffer);
}
Esempio n. 6
0
File: object.c Progetto: atrinik/dwc
/**
 * Drop an item, either on the floor or in a container.
 * @param op Who is dropping an item.
 * @param tmp What object to drop. */
void drop(object *op, object *tmp)
{
	if (tmp == NULL)
	{
		new_draw_info(NDI_UNIQUE, op, "You don't have anything to drop.");
		return;
	}

	if (QUERY_FLAG(tmp, FLAG_INV_LOCKED))
	{
		new_draw_info(NDI_UNIQUE, op, "This item is locked.");
		return;
	}

	if (QUERY_FLAG(tmp, FLAG_NO_DROP))
	{
		return;
	}

	if (op->type == PLAYER)
	{
		if (CONTR(op)->container)
		{
			put_object_in_sack(op, CONTR(op)->container, tmp, CONTR(op)->count);
		}
		else
		{
			drop_object(op, tmp, CONTR(op)->count);
		}

		CONTR(op)->count = 0;
	}
	else
	{
		drop_object(op, tmp, 0);
	}
}
Esempio n. 7
0
/*
	function to drop an object
 */
void dropobj (void)
{
	int i, pitflag=0;
	char *p;
	long amt;

	p = &item[playerx][playery];
	while (1) {
		if ((i = whatitem("drop"))==ESC)  
			return;
		if (i=='*') 
			showstr(); 
		else {
			/* drop some gold */
			if (i=='.')	{
				if (*p == OPIT) pitflag=1;
				if (*p && !pitflag) { 
				lprcat("\nThere's something here already!"); 
						return; 
				}
				lprcat("\n\n");
				cl_dn(1,23);
				lprcat("How much gold do you drop? ");
				if ((amt=readnum((long)c[GOLD])) <= 0) return;
				if (amt>c[GOLD]) { 
					lprcat("\nYou don't have that much!"); 
					return; 
				}
				if (amt<=32767) { 
					*p=OGOLDPILE; 
					i=(int)amt; 
				}
				else if (amt<=327670L) { 
					*p=ODGOLD; 
					i=(int)amt/10; 
					amt = 10L*i; 
				}
				else if (amt<=3276700L) { 
					*p=OMAXGOLD; 
					i=(int)amt/100; 
					amt = 100L*i; 
				}
				else if (amt<=32767000L) { 
					*p=OKGOLD; 
					i=(int)amt/1000; 
					amt = 1000L*i; 
				}
				else { 
					*p=OKGOLD; 
					i=(int)32767; 
					amt = 32767000L; 
				}
				c[GOLD] -= amt; 
				lprintf("You drop %d gold piece%s.",(long)amt,(amt==1)?"":"s");
				if (pitflag) {
					*p = OPIT;
					lprcat("\nThe gold disappears down the pit.");
				} else
					iarg[playerx][playery]=i; 
				bottomgold();
				know[playerx][playery]=0; 
				dropflag=1;  
				return;
			}
			drop_object(i-'a');
			return;
		}
	}
}
Esempio n. 8
0
/*
	*******
	REGEN()
	*******
	regen()

	subroutine to regenerate player hp and spells
 */
void
regen(void)
{
	int    i, flag;
	long  *d;
	d = c;
#ifdef EXTRA
	d[MOVESMADE]++;
#endif
	if (d[TIMESTOP]) {
		if (--d[TIMESTOP] <= 0)
			bottomline();
		return;
	}			/* for stop time spell */
	flag = 0;

	if (d[STRENGTH] < 3) {
		d[STRENGTH] = 3;
		flag = 1;
	}
	if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0))
		gltime++;

	if (d[HP] != d[HPMAX])
		if (d[REGENCOUNTER]-- <= 0) {	/* regenerate hit points	 */
			d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL];
			if ((d[HP] += d[REGEN]) > d[HPMAX])
				d[HP] = d[HPMAX];
			bottomhp();
		}
	if (d[SPELLS] < d[SPELLMAX])	/* regenerate spells	 */
		if (d[ECOUNTER]-- <= 0) {
			d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]);
			d[SPELLS]++;
			bottomspell();
		}
	if (d[HERO])
		if (--d[HERO] <= 0) {
			for (i = 0; i < 6; i++)
				d[i] -= 10;
			flag = 1;
		}
	if (d[ALTPRO])
		if (--d[ALTPRO] <= 0) {
			d[MOREDEFENSES] -= 3;
			flag = 1;
		}
	if (d[PROTECTIONTIME])
		if (--d[PROTECTIONTIME] <= 0) {
			d[MOREDEFENSES] -= 2;
			flag = 1;
		}
	if (d[DEXCOUNT])
		if (--d[DEXCOUNT] <= 0) {
			d[DEXTERITY] -= 3;
			flag = 1;
		}
	if (d[STRCOUNT])
		if (--d[STRCOUNT] <= 0) {
			d[STREXTRA] -= 3;
			flag = 1;
		}
	if (d[BLINDCOUNT])
		if (--d[BLINDCOUNT] <= 0) {
			cursors();
			lprcat("\nThe blindness lifts  ");
			beep();
		}
	if (d[CONFUSE])
		if (--d[CONFUSE] <= 0) {
			cursors();
			lprcat("\nYou regain your senses");
			beep();
		}
	if (d[GIANTSTR])
		if (--d[GIANTSTR] <= 0) {
			d[STREXTRA] -= 20;
			flag = 1;
		}
	if (d[CHARMCOUNT])
		if ((--d[CHARMCOUNT]) <= 0)
			flag = 1;
	if (d[INVISIBILITY])
		if ((--d[INVISIBILITY]) <= 0)
			flag = 1;
	if (d[CANCELLATION])
		if ((--d[CANCELLATION]) <= 0)
			flag = 1;
	if (d[WTW])
		if ((--d[WTW]) <= 0)
			flag = 1;
	if (d[HASTESELF])
		if ((--d[HASTESELF]) <= 0)
			flag = 1;
	if (d[AGGRAVATE])
		--d[AGGRAVATE];
	if (d[SCAREMONST])
		if ((--d[SCAREMONST]) <= 0)
			flag = 1;
	if (d[STEALTH])
		if ((--d[STEALTH]) <= 0)
			flag = 1;
	if (d[AWARENESS])
		--d[AWARENESS];
	if (d[HOLDMONST])
		if ((--d[HOLDMONST]) <= 0)
			flag = 1;
	if (d[HASTEMONST])
		--d[HASTEMONST];
	if (d[FIRERESISTANCE])
		if ((--d[FIRERESISTANCE]) <= 0)
			flag = 1;
	if (d[GLOBE])
		if (--d[GLOBE] <= 0) {
			d[MOREDEFENSES] -= 10;
			flag = 1;
		}
	if (d[SPIRITPRO])
		if (--d[SPIRITPRO] <= 0)
			flag = 1;
	if (d[UNDEADPRO])
		if (--d[UNDEADPRO] <= 0)
			flag = 1;
	if (d[HALFDAM])
		if (--d[HALFDAM] <= 0) {
			cursors();
			lprcat("\nYou now feel better ");
			beep();
		}
	if (d[SEEINVISIBLE])
		if (--d[SEEINVISIBLE] <= 0) {
			monstnamelist[INVISIBLESTALKER] = ' ';
			cursors();
			lprcat("\nYou feel your vision return to normal");
			beep();
		}
	if (d[ITCHING]) {
		if (d[ITCHING] > 1)
			if ((d[WEAR] != -1) || (d[SHIELD] != -1))
				if (rnd(100) < 50) {
					d[WEAR] = d[SHIELD] = -1;
					cursors();
					lprcat("\nThe hysteria of itching forces you to remove your armor!");
					beep();
					recalc();
					bottomline();
				}
		if (--d[ITCHING] <= 0) {
			cursors();
			lprcat("\nYou now feel the irritation subside!");
			beep();
		}
	}
	if (d[CLUMSINESS]) {
		if (d[WIELD] != -1)
			if (d[CLUMSINESS] > 1)
				if (item[playerx][playery] == 0)	/* only if nothing there */
					if (rnd(100) < 33)	/* drop your weapon due
								 * to clumsiness */
						drop_object((int) d[WIELD]);
		if (--d[CLUMSINESS] <= 0) {
			cursors();
			lprcat("\nYou now feel less awkward!");
			beep();
		}
	}
	if (flag)
		bottomline();
}
Esempio n. 9
0
File: aoi.c Progetto: ChowZenki/aoi
static void
drop_pair(struct aoi_space * space, struct pair_list *p) {
	drop_object(space, p->watcher);
	drop_object(space, p->marker);
	space->alloc(space->alloc_ud, p, sizeof(*p));
}