Beispiel #1
0
static void
merge_list_set_val(struct obj_list_data *d, GtkTreeIter *iter, int row)
{
  int cx;
  unsigned int i = 0;
  char *file, *bfile;

  for (i = 0; i < MERG_WIN_COL_NUM; i++) {
    switch (i) {
    case MERG_WIN_COL_FILE:
      getobj(d->obj, "file", row, 0, NULL, &file);
      bfile = getbasename(file);
      if (bfile) {
	list_store_set_string(GTK_WIDGET(d->text), iter, i, CHK_STR(bfile));
	g_free(bfile);
      } else {
	list_store_set_string(GTK_WIDGET(d->text), iter, i, "....................");
      }
      break;
    case MERG_WIN_COL_HIDDEN:
      getobj(d->obj, Mlist[i].name, row, 0, NULL, &cx);
      cx = ! cx;
      list_store_set_val(GTK_WIDGET(d->text), iter, i, Mlist[i].type, &cx);
      break;
    default:
      if (Mlist[i].type == G_TYPE_DOUBLE) {
	getobj(d->obj, Mlist[i].name, row, 0, NULL, &cx);
	list_store_set_double(GTK_WIDGET(d->text), iter, i, cx / 100.0);
      } else {
	getobj(d->obj, Mlist[i].name, row, 0, NULL, &cx);
	list_store_set_val(GTK_WIDGET(d->text), iter, i, Mlist[i].type, &cx);
      }
    }
  }
}
Beispiel #2
0
int do_naming(void)
{
	int n, selected[1];
	struct obj *obj;
	static const char allowall[] = {ALL_CLASSES, 0};
	struct menulist menu;

	init_menulist(&menu);

	add_menuitem(&menu, 1, "Name a monster", 'C', FALSE);
	add_menuitem(&menu, 2, "Name the current level", 'f', FALSE);
	add_menuitem(&menu, 3, "Name an individual item", 'y', FALSE);
	add_menuitem(&menu, 4, "Name all items of a certain type", 'n', FALSE);

	n = display_menu(menu.items, menu.icount, "What do you wish to name?",
			PICK_ONE, selected);
	free(menu.items);
	if (n)
	    n = selected[0] - 1;
	else
	    return 0;

	switch (n) {
	    default: break;
	    case 0:
		do_mname();
		break;
		
	    case 1:
		donamelevel();
		break;

		/* cases 2 & 3 duplicated from ddocall() */
	    case 2:
		obj = getobj(allowall, "name");
		if(obj)
		    do_oname(obj);
		break;
	    case 3:
		obj = getobj(callable, "call");
		if (obj) {
		    /* behave as if examining it in inventory;
		     * this might set dknown if it was picked up
		     * while blind and the hero can now see */
		    xname(obj);

		    if (!obj->dknown) {
			pline("You would never recognize another one.");
			return 0;
		    }
		    docall(obj);
		}
		break;
	}
	return 0;
}
Beispiel #3
0
/*
 * Update some rows in the specified table
 * _h: structure representing database connection
 * _k: key names
 * _o: operators
 * _v: values of the keys that must match
 * _uk: updated columns
 * _uv: updated values of the columns
 * _n: number of key=value pairs
 * _un: number of columns to update
 */
int perlvdb_db_update(db_con_t* h, db_key_t* k, db_op_t* o, db_val_t* v,
	      db_key_t* uk, db_val_t* uv, int n, int un) {

	AV *condarr;
	AV *updatearr;

	SV *condarrref;
	SV *updatearrref;

	SV *ret;

	condarr = conds2perlarray(k, o, v, n);
	updatearr = pairs2perlarray(uk, uv, un);

	condarrref = newRV_noinc((SV*)condarr);
	updatearrref = newRV_noinc((SV*)updatearr);

	ret = perlvdb_perlmethod(getobj(h), PERL_VDB_UPDATEMETHOD,
			condarrref, updatearrref, NULL, NULL);

	av_undef(condarr);
	av_undef(updatearr);

	return IV2int(ret);
}
Beispiel #4
0
struct IplImage *framescompare(struct IplImage *curr, struct IplImage *prev)
{
	int x, y, h, w;
	struct IplImage *res;
	unsigned char *pvdata, *cvdata;
	struct rct rectangle;

	h = curr->height;
	w = curr->width;
	
	cvdata = getvals(curr);

	pvdata = getvals(prev);
	
	res = ipl_cloneimg(prev);
	
	for(y = 0; y < h; y++) {
		for(x = 0; x < w; x++) {
			if(abs(cvdata[y * w + x] - pvdata[y * w + x]) > 20) {
				rectangle.x1 = x;
				rectangle.y1 = y;
				rectangle.x2 = x;
				rectangle.y2 = y;
				getobj(cvdata, pvdata, x, y, w, h, &rectangle);
			}
			if((rectangle.x2 - rectangle.x1) * (rectangle.y2 - rectangle.y1) > 50) {
			drawRectangle(res, rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2);
			}
		}
	}
	
	free(pvdata);
	free(cvdata);
	return res;
}
Beispiel #5
0
int
doweararm(void)
{
	struct obj *otmp;
	int delay;
	int err = 0;
	long mask = 0;

	otmp = getobj("[", "wear");
	if(!otmp) return(0);
	if(otmp->owornmask & W_ARMOR) {
		pline("You are already wearing that!");
		return(0);
	}
	if(otmp->otyp == HELMET){
		if(uarmh) {
			pline("You are already wearing a helmet.");
			err++;
		} else
			mask = W_ARMH;
	} else if(otmp->otyp == SHIELD){
		if(uarms) pline("You are already wearing a shield."), err++;
		if(uwep && uwep->otyp == TWO_HANDED_SWORD)
	pline("You cannot wear a shield and wield a two-handed sword."), err++;
		if(!err) mask = W_ARMS;
	} else if(otmp->otyp == PAIR_OF_GLOVES) {
		if(uarmg) {
			pline("You are already wearing gloves.");
			err++;
		} else
		if(uwep && uwep->cursed) {
			pline("You cannot wear gloves over your weapon.");
			err++;
		} else
			mask = W_ARMG;
	} else {
		if(uarm) {
			if(otmp->otyp != ELVEN_CLOAK || uarm2) {
				pline("You are already wearing some armor.");
				err++;
			}
		}
		if(!err) mask = W_ARM;
	}
	if(otmp == uwep && uwep->cursed) {
		if(!err++)
			pline("%s is welded to your hand.", Doname(uwep));
	}
	if(err) return(0);
	setworn(otmp, mask);
	if(otmp == uwep)
		setuwep((struct obj *) 0);
	delay = -objects[otmp->otyp].oc_delay;
	if(delay){
		nomul(delay);
		nomovemsg = "You finished your dressing manoeuvre.";
	}
	otmp->known = 1;
	return(1);
}
Beispiel #6
0
int dowield(void)
{
    struct obj *wep;
    int res = 0;

    multi = 0;
    if (!(wep = getobj("#-)", "wield")))	// nothing
	;
    else if (uwep == wep)
	pline("You are already wielding that!");
    else if (uwep && uwep->cursed)
	pline("The %s welded to your hand!", aobjnam(uwep, "are"));
    else if (wep == &zeroobj) {
	if (uwep == 0) {
	    pline("You are already empty handed.");
	} else {
	    setuwep((struct obj *) 0);
	    res++;
	    pline("You are empty handed.");
	}
    } else if (uarms && wep->otyp == TWO_HANDED_SWORD)
	pline("You cannot wield a two-handed sword and wear a shield.");
    else if (wep->owornmask & (W_ARMOR | W_RING))
	pline("You cannot wield that!");
    else {
	setuwep(wep);
	res++;
	if (uwep->cursed)
	    pline("The %s %s to your hand!", aobjnam(uwep, "weld"), (uwep->quan == 1) ? "itself" : "themselves");	// a3
	else
	    prinv(uwep);
    }
    return res;
}
Beispiel #7
0
int
doremarm(void)
{
	struct obj     *otmp;
	if (!uarm && !uarmh && !uarms && !uarmg) {
		pline("Not wearing any armor.");
		return (0);
	}
	otmp = (!uarmh && !uarms && !uarmg) ? uarm :
		(!uarms && !uarm && !uarmg) ? uarmh :
		(!uarmh && !uarm && !uarmg) ? uarms :
		(!uarmh && !uarm && !uarms) ? uarmg :
		getobj("[", "take off");
	if (!otmp)
		return (0);
	if (!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
		pline("You can't take that off.");
		return (0);
	}
	if (otmp == uarmg && uwep && uwep->cursed) {	/* myers@uwmacc */
		pline("You seem not able to take off the gloves while holding your weapon.");
		return (0);
	}
	(void) armoroff(otmp);
	return (1);
}
Beispiel #8
0
int
dothrow()
{
	register struct obj *obj;

	if(check_capacity(NULL)) return(0);
	obj = getobj(toss_objs, "throw");
	/* it is also possible to throw food */
	/* (or jewels, or iron balls... ) */

	if(!obj || !getdir(NULL)) {       /* ask "in what direction?" */
		if (obj && obj->oclass == GOLD_CLASS) {
		    u.ugold += obj->quan;
		    flags.botl = 1;
		    dealloc_obj(obj);
		}
		return(0);
	}

	if(obj->oclass == GOLD_CLASS) return(throw_gold(obj));

	if(!canletgo(obj,"throw"))
		return(0);
	if (obj->oartifact == ART_MJOLLNIR && obj != uwep) {
		You("must be wielding %s in order to throw it.", xname(obj));
		return(0);
	}
	if ((obj->oartifact == ART_MJOLLNIR && ACURR(A_STR) != 125)
	   || (obj->otyp == BOULDER
#ifdef POLYSELF
					&& !throws_rocks(uasmon)
#endif
								)) {
		pline("It's too heavy.");
		return(1);
	}
	if(!u.dx && !u.dy && !u.dz) {
		You("cannot throw an object at yourself.");
		return(0);
	}
	u_wipe_engr(2);

	if(obj == uwep) {
	    if(welded(obj)) {
		weldmsg(obj, FALSE);
		return(1);
	    }
	    if(obj->quan > 1L)
		setuwep(splitobj(obj, 1L));
	    else {
		setuwep((struct obj *)0);
		if (uwep) return(1); /* unwielded, died, rewielded */
	    }
	}
	else if(obj->quan > 1L)
		(void) splitobj(obj, 1L);
	freeinv(obj);
	return(throwit(obj));
}
Beispiel #9
0
static int l_gc(lua_State *L)
{
	Object *obj = getobj(L, 1);
	if (obj->ctx) {
		SSL_CTX_free(obj->ctx);
		obj->ctx = NULL;
	}
	return 0;
}
Beispiel #10
0
void
add_font_style_combo_item_to_cbox(GtkTreeStore *list, GtkTreeIter *iter, GtkTreeIter *parent, int column_id_bold, int column_id_italic, struct objlist *obj, const char *field, int id)
{
  int style;

  getobj(obj, field, id, 0, NULL, &style);

  add_text_combo_item_to_cbox(list, iter, parent, column_id_bold, -1, _("Bold"), TOGGLE_CHECK, style & GRA_FONT_STYLE_BOLD);
  add_text_combo_item_to_cbox(list, iter, parent, column_id_italic, -1, _("Italic"), TOGGLE_CHECK, style & GRA_FONT_STYLE_ITALIC);
}
Beispiel #11
0
void getobj(unsigned char *cvdata, unsigned char *pvdata, int x, int y, int w, int h, struct rct *rectangle)
{	
	cvdata[y * w + x] = 0;
	pvdata[y * w + x] = 0;
	rectangle->x1 = (x < rectangle->x1)? x : rectangle->x1;	
	rectangle->y1 = (y < rectangle->y1)? y : rectangle->y1;
	rectangle->x2 = (x > rectangle->x2)? x : rectangle->x2;	
	rectangle->y2 = (y > rectangle->y2)? y : rectangle->y2;
	
	if ((x + 1) < w && abs(cvdata[y * w + x + 1] - pvdata[y * w + x + 1]) > 20){ // right
		getobj(cvdata, pvdata, x + 1, y, w, h, rectangle);
	}if((x- 1) >= 0 && abs(cvdata[y * w + x - 1] - pvdata[y * w + x - 1]) > 20){ // left
		getobj(cvdata, pvdata, x - 1, y, w, h, rectangle);
	}if((y + 1) < h && abs(cvdata[(y + 1) * w + x] - pvdata[(y + 1) * w + x]) > 20){ // up
		getobj(cvdata, pvdata, x, y + 1, w, h, rectangle);
	}if((y - 1) >= 0 && abs(cvdata[(y - 1) * w + x] - pvdata[(y - 1) * w + x]) > 20){ // down
		getobj(cvdata, pvdata, x, y - 1, w, h, rectangle);
	}	
}
Beispiel #12
0
/*
 * -- rudimentary -- to do this correctly requires much more work
 * -- all sharp weapons get one or more qualities derived from the potions
 * -- texts on scrolls may be (partially) wiped out; do they become blank?
 * --   or does their effect change, like under Confusion?
 * -- all objects may be made invisible by POT_INVISIBILITY
 * -- If the flask is small, can one dip a large object? Does it magically
 * --   become a jug? Etc.
 */
int
dodip()
{
	struct obj *potion, *obj;

	if(!(obj = getobj("#", "dip")))
		return(0);
	if(!(potion = getobj("!", "dip into")))
		return(0);
	pline("Interesting...");
	if(obj->otyp == ARROW || obj->otyp == DART ||
	   obj->otyp == CROSSBOW_BOLT) {
		if(potion->otyp == POT_SICKNESS) {
			useup(potion);
			if(obj->spe < 7) obj->spe++;	/* %% */
		}
	}
	return(1);
}
Beispiel #13
0
int doinvoke(struct obj *obj)
{
    if (obj && !validate_object(obj, invoke_types, "invoke, break, or rub"))
	return 0;
    else if (!obj)
	obj = getobj(invoke_types, "invoke, break, or rub");
    if (!obj) return 0;
    
    if (obj->oartifact && !touch_artifact(obj, &youmonst))
	return 1;
    return arti_invoke(obj);
}
Beispiel #14
0
int dowield(struct obj *wep)
{
	struct obj *oldwep;
	int result;

	/* May we attempt this? */
	multi = 0;
	if (cantwield(youmonst.data)) {
		pline("Don't be ridiculous!");
		return 0;
	}

	/* Prompt for a new weapon */
	if (wep && !validate_object(wep, wield_objs, "wield"))
		return 0;
	else if (!wep)
		wep = getobj(wield_objs, "wield");
	if (!wep)
		/* Cancelled */
		return 0;
	else if (wep == uwep) {
	    pline("You are already wielding that!");
	    if (is_weptool(wep)) unweapon = FALSE;	/* [see setuwep()] */
		return 0;
	} else if (welded(uwep)) {
		weldmsg(uwep);
		/* previously interrupted armor removal mustn't be resumed */
		reset_remarm();
		return 0;
	}

	/* Handle no object, or object in other slot */
	if (wep == &zeroobj)
		wep = NULL;
	else if (wep == uswapwep)
		return doswapweapon();
	else if (wep == uquiver)
		setuqwep(NULL);
	else if (wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL
			| W_SADDLE)) {
		pline("You cannot wield that!");
		return 0;
	}

	/* Set your new primary weapon */
	oldwep = uwep;
	result = ready_weapon(wep);
	if (flags.pushweapon && oldwep && uwep != oldwep)
		setuswapwep(oldwep);
	untwoweapon();

	return result;
}
Beispiel #15
0
/*
 * Query table for specified rows
 * h: structure representing database connection
 * k: key names
 * op: operators
 * v: values of the keys that must match
 * c: column names to return
 * n: number of key=values pairs to compare
 * nc: number of columns to return
 * o: order by the specified column
 */
int perlvdb_db_query(db_con_t* h, db_key_t* k, db_op_t* op, db_val_t* v,
			db_key_t* c, int n, int nc,
			db_key_t o, db_res_t** r) {


	AV *condarr;
	AV *retkeysarr;
	SV *order;

	SV *condarrref;
	SV *retkeysref;

	SV *resultset;

	int retval = 0;
        int i;
	/* Create parameter set */
	condarr = conds2perlarray(k, op, v, n);

	retkeysarr = keys2perlarray(c, nc);

	if (o) order = newSVpv(o->s, o->len);
	else order = &PL_sv_undef;

	condarrref = newRV_noinc((SV*)condarr);
	retkeysref = newRV_noinc((SV*)retkeysarr);

	/* Call perl method */
	resultset = perlvdb_perlmethod(getobj(h), PERL_VDB_QUERYMETHOD,
			condarrref, retkeysref, order, NULL);

	SvREFCNT_dec(condarrref);
	SvREFCNT_dec(retkeysref);
	if(SvOK(order))
		SvREFCNT_dec(order);

	/* Transform perl result set to OpenSIPS result set */
	if (!resultset) {
		/* No results. */
		retval = -1;
	} else {
		if (sv_isa(resultset, "OpenSIPS::VDB::Result")) {
			retval = perlresult2dbres(resultset, r);
		/* Nested refs are decreased/deleted inside the routine */
			SvREFCNT_dec(resultset);
		} else {
			LM_ERR("invalid result set retrieved from perl call.\n");
			retval = -1;
		}
	}
	return retval;
}
Beispiel #16
0
static char *set_field_by_id(const char *arg1, const char *arg2,
                             const char *arg3, int *retval)
{
	MCField *fptr = (MCField *)getobj(CT_FIELD, CT_ID, arg1, arg2);
	if (fptr == NULL)
		*retval = xresFail;
	else
	{
		fptr->settext(fptr->getcard()->getid(), arg3, False);
		*retval = xresSucc;
	}
	return NULL;
}
Beispiel #17
0
/*
 * Store name of table that will be used by
 * subsequent database functions
 */
int perlvdb_use_table(db_con_t* h, const char* t) {
	SV *ret;
	
	if (!h || !t) {
		LM_ERR("invalid parameter value\n");
		return -1;
	}

	ret = perlvdb_perlmethod(getobj(h), PERL_VDB_USETABLEMETHOD,
			sv_2mortal(newSVpv(t, 0)), NULL, NULL, NULL);

	return IV2int(ret);
}
/* Create a string in the heap. */
long newstring(avm* vm, char* s)
{
	objheader* obj;
	heap* hp = &vm->hp;
	long size = strlen(s)+1;
	long offset = allocblock(vm, size);
	obj = (objheader*)getobj(hp->heap, offset);
	obj->type = TSTRING;
	obj->size = size;
	obj->offset = (long)sizeof(mblock)+offset;
	strcpy(getdata(hp->heap, offset), (const char*)s);
	return offset;
}
Beispiel #19
0
void
add_bool_combo_item_to_cbox(GtkTreeStore *list, GtkTreeIter *iter, GtkTreeIter *parent, int column_id, struct objlist *obj, const char *field, int id, const char *title)
{
  GtkTreeIter locl_iter;
  int state;

  if (iter == NULL) {
    iter = &locl_iter;
  }

  getobj(obj, field, id, 0, NULL, &state);

  add_text_combo_item_to_cbox(list, iter, parent, column_id, -1, title, TOGGLE_CHECK, state);
}
Beispiel #20
0
char *
ngraph_get_init_file(const char *init_file)
{
  char *homedir, *confdir, *inifile;;
  struct objlist *sys;

  if (init_file == NULL) {
    return NULL;
  }

  sys = chkobject("system");
  getobj(sys, "home_dir", 0, 0, NULL, &homedir);
  getobj(sys, "conf_dir", 0, 0, NULL, &confdir);

  inifile = NULL;
  if (findfilename(homedir, CONFTOP, init_file)) {
    inifile = getfilename(homedir, CONFTOP, init_file);
  } else if (findfilename(confdir, CONFTOP, init_file)) {
    inifile = getfilename(confdir, CONFTOP, init_file);
  }

  return inifile;
}
Beispiel #21
0
static char *show_image_by_num(const char *arg1, const char *arg2,
                               const char *arg3, int *retval)
{
	MCImage *iptr = (MCImage *)getobj(CT_IMAGE, CT_EXPRESSION, arg1, arg2);
	if (iptr == NULL)
		*retval = xresFail;
	else
	{
		// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
		iptr->layer_redrawall();
		*retval = xresSucc;
	}
	return NULL;
}
// QC:?
VFS::File* ScriptVariable::getfile(VFS::File* pathRoot) const {
	if(isPointer()) {
		return getPointee()->getfile();
	}

	if(type == VAR_OBJ) {
		return getobj()->source();
	}

	static VFS::File* f = NULL;
	if(f)
		delete f;
	f = VFS::openFile(getstr(), pathRoot);
	return f;
}
Beispiel #23
0
/*
 * Store name of table that will be used by
 * subsequent database functions
 */
int perlvdb_use_table(db_con_t* h, const str* t) {
	SV *ret;
	SV *table;
	int res = -1;
	if (!h || !t || !t->s) {
		LM_ERR("invalid parameter value\n");
		return -1;
	}
	table = newSVpv(t->s, t->len);
	ret = perlvdb_perlmethod(getobj(h), PERL_VDB_USETABLEMETHOD,
			table, NULL, NULL, NULL);
	SvREFCNT_dec(table);
	res = IV2int(ret);
	return res;
}
Beispiel #24
0
/*
 * Insert a row into specified table
 * h: structure representing database connection
 * k: key names
 * v: values of the keys
 * n: number of key=value pairs
 */
int perlvdb_db_insertreplace(db_con_t* h, db_key_t* k, db_val_t* v,
		int n, char *insertreplace) {
	AV *arr;
	SV *arrref;
	SV *ret;

	arr = pairs2perlarray(k, v, n);
	arrref = newRV_noinc((SV*)arr);
	ret = perlvdb_perlmethod(getobj(h), insertreplace,
			arrref, NULL, NULL, NULL);

	av_undef(arr);

	return IV2int(ret);
}
Beispiel #25
0
/*
 * Delete a row from the specified table
 * h: structure representing database connection
 * k: key names
 * o: operators
 * v: values of the keys that must match
 * n: number of key=value pairs
 */
int perlvdb_db_delete(db_con_t* h, db_key_t* k, db_op_t* o, db_val_t* v,
		int n) {
	AV *arr;
	SV *arrref;
	SV *ret;

	arr = conds2perlarray(k, o, v, n);
	arrref = newRV_noinc((SV*)arr);
	ret = perlvdb_perlmethod(getobj(h), PERL_VDB_DELETEMETHOD,
			arrref, NULL, NULL, NULL);

	av_undef(arr);

	return IV2int(ret);
}
Beispiel #26
0
int
doapply()
{
	struct obj *obj;
	int res = 1;

	obj = getobj("(", "use or apply");
	if(!obj) return(0);

	switch(obj->otyp){
	case EXPENSIVE_CAMERA:
		use_camera(obj); break;
	case ICE_BOX:
		use_ice_box(obj); break;
	case PICK_AXE:
		res = use_pick_axe(obj);
		break;

	case MAGIC_WHISTLE:
		if(pl_character[0] == 'W' || u.ulevel > 9) {
			use_magic_whistle(obj);
			break;
		}
		/* fall into next case */
	case WHISTLE:
		use_whistle(obj);
		break;

	case CAN_OPENER:
		if(!carrying(TIN)) {
			pline("You have no can to open.");
			goto xit;
		}
		pline("You cannot open a tin without eating its contents.");
		pline("In order to eat, use the 'e' command.");
		if(obj != uwep)
    pline("Opening the tin will be much easier if you wield the can-opener.");
		goto xit;

	default:
		pline("Sorry, I don't know how to use that.");
	xit:
		nomul(0);
		return(0);
	}
	nomul(0);
	return(res);
}
Beispiel #27
0
void
add_font_combo_item_to_cbox(GtkTreeStore *list, GtkTreeIter *iter, GtkTreeIter *parent, int column_id, struct objlist *obj, const char *field, int id)
{
  struct fontmap *fcur;
  char *font;
  int match;

  getobj(obj, field, id, 0, NULL, &font);

  fcur = Gra2cairoConf->fontmap_list_root;
  while (fcur) {
    match = ! g_strcmp0(font, fcur->fontalias);
    add_text_combo_item_to_cbox(list, iter, parent, column_id, -1, fcur->fontalias, TOGGLE_RADIO, match);
    fcur = fcur->next;
  }
}
Beispiel #28
0
void
add_enum_combo_item_to_cbox(GtkTreeStore *list, GtkTreeIter *iter, GtkTreeIter *parent, int column_id, struct objlist *obj, const char *field, int id)
{
  char **enum_array;
  int state, i;

  getobj(obj, field, id, 0, NULL, &state);
  enum_array = (char **) chkobjarglist(obj, field);
  if (enum_array == NULL) {
    return;
  }

  for (i = 0; enum_array[i] && enum_array[i][0]; i++) {
    add_text_combo_item_to_cbox(list, iter, parent, column_id, i, _(enum_array[i]), TOGGLE_RADIO, i == state);
  }
}
Beispiel #29
0
/* 'd' command: drop one inventory item */
int
dodrop()
{
#ifndef GOLDOBJ
	int result, i = (invent || u.ugold) ? 0 : (SIZE(drop_types) - 1);
#else
	int result, i = (invent) ? 0 : (SIZE(drop_types) - 1);
#endif

	if (*u.ushops) sellobj_state(SELL_DELIBERATE);
	result = drop(getobj(&drop_types[i], "drop"));
	if (*u.ushops) sellobj_state(SELL_NORMAL);
	reset_occupations();

	return result;
}
Beispiel #30
0
int
doremarm(void)
{
	struct obj *otmp;
	if(!uarm && !uarmh && !uarms && !uarmg) {
		pline("Not wearing any armor.");
		return(0);
	}
	otmp = (!uarmh && !uarms && !uarmg) ? uarm :
		(!uarms && !uarm && !uarmg) ? uarmh :
		(!uarmh && !uarm && !uarmg) ? uarms :
		(!uarmh && !uarm && !uarms) ? uarmg :
		getobj("[", "take off");
	if(!otmp) return(0);
	if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
		pline("You can't take that off.");
		return(0);
	}
	armoroff(otmp);
	return(1);
}