~jb55/protoverse

1b9a46ce622a18e8b294884b3b0c64066653b647 — William Casarin 2 months ago 490949c
parse and describe spaces
3 files changed, 16 insertions(+), 12 deletions(-)

M satoshis-citadel.space
M src/describe.c
M src/parse.c
M satoshis-citadel.space => satoshis-citadel.space +1 -1
@@ 1,4 1,4 @@
(room (shape rectangle)
(space (shape rectangle)
      (condition "clean")
      (condition "shiny")
      (material "solid gold")

M src/describe.c => src/describe.c +5 -11
@@ 184,7 184,7 @@ static int push_shape(struct describe *desc)
	return 1;
}

static int describe_room(struct describe *desc)
static int describe_area(struct describe *desc, const char *name)
{
	int ok;



@@ 198,7 198,7 @@ static int describe_room(struct describe *desc)
	ok = push_shape(desc);
	if (!ok) return 0;

	ok = push_word(desc->strs, "room");
	ok = push_word(desc->strs, name);
	if (!ok) return 0;

	ok = push_made_of(desc);


@@ 308,12 308,6 @@ static int describe_object(struct describe *desc)
	return 0;
}

static int describe_space(struct describe *desc)
{
	(void)desc;
	return 0;
}

int describe_cell(struct cell *cell, struct parser *parsed, struct cursor *strbuf)
{
	struct describe desc;


@@ 324,13 318,13 @@ int describe_cell(struct cell *cell, struct parser *parsed, struct cursor *strbu

	switch (cell->type) {
	case C_ROOM:
		return describe_room(&desc);
		return describe_area(&desc, "room");
	case C_SPACE:
		return describe_area(&desc, "space");
	case C_GROUP:
		return describe_group(&desc);
	case C_OBJECT:
		return describe_object(&desc);
	case C_SPACE:
		return describe_space(&desc);
	}

	return 1;

M src/parse.c => src/parse.c +10 -0
@@ 1162,6 1162,10 @@ static int parse_cell_by_name(struct parser *parser,
	return 1;
}

static int parse_space(struct parser *parser, u16 *index)
{
	return parse_cell_by_name(parser, index, "space", C_SPACE);
}

static int parse_room(struct parser *parser, u16 *index)
{


@@ 1295,6 1299,12 @@ int parse_cell(struct parser *parser, u16 *index)
		goto close;
	}

	ok = parse_space(&backtracked, index);
	if (ok) {
		tokdebug("got parse_space\n");
		goto close;
	}

	ok = parse_object(&backtracked, index);
	if (ok) goto close;