diff options
-rw-r--r-- | texad.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -72,17 +72,17 @@ struct world *genesis(void) struct room *r[3]; struct door *d[4]; + unsigned int i; + w = (struct world*) malloc(sizeof(struct world)); p = (struct player*) malloc(sizeof(struct player)); - r[0] = (struct room*) malloc(sizeof(struct room)); - r[1] = (struct room*) malloc(sizeof(struct room)); - r[2] = (struct room*) malloc(sizeof(struct room)); - - d[0] = (struct door*) malloc(sizeof(struct door)); - d[1] = (struct door*) malloc(sizeof(struct door)); - d[2] = (struct door*) malloc(sizeof(struct door)); - d[3] = (struct door*) malloc(sizeof(struct door)); + for (i = 0; i < sizeof(r) / sizeof(struct room*); i++) { + r[i] = (struct room*) malloc(sizeof(struct room)); + } + for (i = 0; i < sizeof(d) / sizeof(struct door*); i++) { + d[i] = (struct door*) malloc(sizeof(struct door)); + } r[0]->title = "The foo room"; r[0]->description = "You are in the foo room. Sunlight streams from the windows."; |