Exemplo n.º 1
0
static enum parser_error parse_owner(struct parser *p) {
	struct store *s = parser_priv(p);
	unsigned int maxcost = parser_getuint(p, "purse");
	char *name = string_make(parser_getstr(p, "name"));
	struct owner *o;

	if (!s)
		return PARSE_ERROR_MISSING_RECORD_HEADER;

	o = mem_zalloc(sizeof *o);
	o->oidx = (s->owners ? s->owners->oidx + 1 : 0);
	o->next = s->owners;
	o->name = name;
	o->max_cost = maxcost;
	s->owners = o;
	return PARSE_ERROR_NONE;
}
Exemplo n.º 2
0
static enum parser_error parse_prefs_b(struct parser *p)
{
	int idx;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass)
		return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx > z_info->k_max)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	add_autoinscription(idx, parser_getstr(p, "text"));

	return PARSE_ERROR_NONE;
}
Exemplo n.º 3
0
static enum parser_error parse_vault_columns(struct parser *p) {
	struct vault *v = parser_priv(p);
	size_t i;

	if (!v)
		return PARSE_ERROR_MISSING_RECORD_HEADER;
	v->wid = parser_getuint(p, "width");

	/* Make sure vaults are no wider than the room profiles allow. */
	for (i = 0; i < N_ELEMENTS(room_builders); i++)
		if (streq(v->typ, room_builders[i].name))
			break;
	if (i == N_ELEMENTS(room_builders))
		return PARSE_ERROR_NO_ROOM_FOUND;
	if (v->wid > room_builders[i].max_width)
		return PARSE_ERROR_VAULT_TOO_BIG;
	return PARSE_ERROR_NONE;
}
Exemplo n.º 4
0
static enum parser_error parse_room_width(struct parser *p) {
	struct room_template *t = parser_priv(p);
	size_t i;

	if (!t)
		return PARSE_ERROR_MISSING_RECORD_HEADER;
	t->wid = parser_getuint(p, "width");

	/* Make sure rooms are no wider than the room profiles allow. */
	for (i = 0; i < N_ELEMENTS(room_builders); i++)
		if (streq("room template", room_builders[i].name))
			break;
	if (i == N_ELEMENTS(room_builders))
		return PARSE_ERROR_NO_ROOM_FOUND;
	if (t->wid > room_builders[i].max_width)
		return PARSE_ERROR_VAULT_TOO_BIG;
	return PARSE_ERROR_NONE;
}
Exemplo n.º 5
0
static enum parser_error parse_r_friends(struct parser *p) {
	struct monster_race *r = parser_priv(p);
	struct monster_friends *f;
	struct random number;
	
	if (!r)
		return PARSE_ERROR_MISSING_RECORD_HEADER;
	f = mem_zalloc(sizeof *f);
	number = parser_getrand(p, "number");
	f->number_dice = number.dice;
	f->number_side = number.sides;
	f->percent_chance = parser_getuint(p, "chance");
	f->name = string_make(parser_getstr(p, "name"));
	f->next = r->friends;
	r->friends = f;
	
	return PARSE_ERROR_NONE;
}			
Exemplo n.º 6
0
static enum parser_error parse_prefs_f(struct parser *p)
{
	int idx;
	feature_type *feature;

	const char *lighting;
	int light_idx;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass)
		return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx >= z_info->f_max)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	lighting = parser_getsym(p, "lighting");
	if (streq(lighting, "bright"))
		light_idx = FEAT_LIGHTING_BRIGHT;
	else if (streq(lighting, "lit"))
		light_idx = FEAT_LIGHTING_LIT;
	else if (streq(lighting, "dark"))
		light_idx = FEAT_LIGHTING_DARK;
	else if (streq(lighting, "all"))
		light_idx = FEAT_LIGHTING_MAX;
	else
		return PARSE_ERROR_GENERIC;	/* xxx fixme */

	if (light_idx < FEAT_LIGHTING_MAX) {
		feature = &f_info[idx];
		feature->x_attr[light_idx] = (byte) parser_getint(p, "attr");
		feature->x_char[light_idx] = (wchar_t) parser_getint(p, "char");
	} else {
		for (light_idx = 0; light_idx < FEAT_LIGHTING_MAX; light_idx++) {
			feature = &f_info[idx];
			feature->x_attr[light_idx] = (byte) parser_getint(p, "attr");
			feature->x_char[light_idx] =
				(wchar_t) parser_getint(p, "char");
		}
	}

	return PARSE_ERROR_NONE;
}
Exemplo n.º 7
0
static enum parser_error parse_prefs_v(struct parser *p)
{
	int idx;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass) return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx > MAX_COLORS)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	angband_color_table[idx][0] = parser_getint(p, "k");
	angband_color_table[idx][1] = parser_getint(p, "r");
	angband_color_table[idx][2] = parser_getint(p, "g");
	angband_color_table[idx][3] = parser_getint(p, "b");

	return PARSE_ERROR_NONE;
}
Exemplo n.º 8
0
static enum parser_error parse_prefs_r(struct parser *p)
{
	int idx;
	monster_race *monster;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass) return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx >= z_info->r_max)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	monster = &r_info[idx];
	monster->x_attr = (byte)parser_getint(p, "attr");
	monster->x_char = (char)parser_getint(p, "char");

	return PARSE_ERROR_NONE;
}
Exemplo n.º 9
0
static enum parser_error parse_graf_n(struct parser *p) {
	graphics_mode *list = parser_priv(p);
	graphics_mode *mode = mem_zalloc(sizeof(graphics_mode));
	if (!mode) {
		return PARSE_ERROR_OUT_OF_MEMORY;
	}
	mode->pNext = list;
	mode->grafID = parser_getuint(p, "index");
	strncpy(mode->menuname, parser_getstr(p, "menuname"), 32);

	mode->alphablend = 0;
	mode->overdrawRow = 0;
	mode->overdrawMax = 0;
	strncpy(mode->file, "", 32);
	strncpy(mode->pref, "none", 32);
	
	parser_setpriv(p, mode);
	return PARSE_ERROR_NONE;
}
Exemplo n.º 10
0
static enum parser_error parse_prefs_l(struct parser *p)
{
	unsigned int idx;
	flavor_type *flavor;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass)
		return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx >= z_info->flavor_max)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	flavor = &flavor_info[idx];
	flavor->x_attr = (byte) parser_getint(p, "attr");
	flavor->x_char = (wchar_t) parser_getint(p, "char");

	return PARSE_ERROR_NONE;
}
Exemplo n.º 11
0
static enum parser_error parse_prefs_n(struct parser *p)
{
	int idx;
	trap_kind *trap;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass)
		return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	if (idx >= z_info->trap_max)
		return PARSE_ERROR_OUT_OF_BOUNDS;

	trap = &trap_info[idx];
	trap->x_attr = (byte) parser_getint(p, "attr");
	trap->x_char = (wchar_t) parser_getint(p, "char");

	return PARSE_ERROR_NONE;
}
Exemplo n.º 12
0
static enum parser_error parse_r_friends_base(struct parser *p) {
	struct monster_race *r = parser_priv(p);
	struct monster_friends_base *f;
	struct random number;
	
	if (!r)
		return PARSE_ERROR_MISSING_RECORD_HEADER;
	f = mem_zalloc(sizeof *f);
	number = parser_getrand(p, "number");
	f->number_dice = number.dice;
	f->number_side = number.sides;
	f->percent_chance = parser_getuint(p, "chance");
	f->base = lookup_monster_base(parser_getstr(p, "name"));
	if (!f->base) return PARSE_ERROR_UNRECOGNISED_TVAL;

	f->next = r->friends_base;
	r->friends_base = f;
	
	return PARSE_ERROR_NONE;
}		
Exemplo n.º 13
0
static enum parser_error parse_prefs_l(struct parser *p)
{
	unsigned int idx;
	struct flavor *flavor;

	struct prefs_data *d = parser_priv(p);
	assert(d != NULL);
	if (d->bypass) return PARSE_ERROR_NONE;

	idx = parser_getuint(p, "idx");
	for (flavor = flavors; flavor; flavor = flavor->next)
		if (flavor->fidx == idx)
			break;

	if (flavor) {
		flavor->x_attr = (byte)parser_getint(p, "attr");
		flavor->x_char = (char)parser_getint(p, "char");
	}

	return PARSE_ERROR_NONE;
}
Exemplo n.º 14
0
static enum parser_error parse_turnover(struct parser *p) {
	struct store *s = parser_priv(p);
	s->turnover = parser_getuint(p, "turnover");
	return PARSE_ERROR_NONE;
}
Exemplo n.º 15
0
static enum parser_error parse_slots(struct parser *p) {
	struct store *s = parser_priv(p);
	s->normal_stock_min = parser_getuint(p, "min");
	s->normal_stock_max = parser_getuint(p, "max");
	return PARSE_ERROR_NONE;
}