// // Makes sure everything is in a usable state // Only does something the first time it is called // void assure_world(void) { static int first = 1; if (first) { world.tm.era = 3; world.tm.year = 329; world.tm.month = 4; world.tm.mday = 5; world.tm.wday = 4; world.tm.hour = 9; world.tm.min = 0; crtr_init(&world.plyr, '@' | A_BOLD); vector_init(&world.zones); world.gcrtrs = new_gclass(NULL); world.gitems = new_gclass(NULL); world.gmats = new_gclass(NULL); // allocate 16 actions to start world.acts = malloc(sizeof(action_node) * 16); world.acts_cnt = 0; world.acts_alloc = 16; // load name data world.eth = load_ethnicity("names/misriyyun"); first = 0; } }
gclass_t * get_gclass(const char * n, gclass_t * rt) { int i, len; const char * s; gclass_t * cl; while (n != NULL && *n) { while (*n == '/') n++; s = n; while (*n && *n != '/') n++; for (i = 0; i < rt->sub.cnt; i++) { cl = rt->sub.arr[i]; len = strlen(cl->name); len = len > n-s ? len : n-s; if (!strncmp(s, cl->name, len)) { rt = cl; break; } } if (i == rt->sub.cnt) { // create new gclass cl = new_gclass(rt); vector_append(&rt->sub, cl); cl->name = malloc(n - s + 1); memcpy(cl->name, s, n-s); cl->name[n-s] = 0; rt = cl; } } return rt; }