2025-01-04 05:01:06 -05:00
|
|
|
#include <stdlib.h>
|
2025-01-05 17:18:51 -05:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2025-01-04 05:01:06 -05:00
|
|
|
#include "room.h"
|
|
|
|
|
|
|
|
void free_room(Room r) {
|
|
|
|
free(r.name);
|
|
|
|
free(r.description);
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_rooms(Rooms r) {
|
|
|
|
for (int i = 0; i < r.count; i++) {
|
|
|
|
free_room(r.rooms[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-05 17:18:51 -05:00
|
|
|
Room *find_room(Rooms *r, const char *name) {
|
|
|
|
for (int i = 0; i < r->count; i++) {
|
|
|
|
if (strcmp(r->rooms[i].name, name) == 0) {
|
|
|
|
return &r->rooms[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Couldn't find room %s\n", name);
|
|
|
|
return NULL;
|
|
|
|
}
|