ID_HANDLER *init_id_handler( int type ) { ID_HANDLER *handler; CREATE( handler, ID_HANDLER, 1 ); handler->free_ids = AllocList(); handler->type = type; handler->top_id = 0; return handler; }
/* function :: init_event_queue() * arguments :: what section to initialize. * ====================================================== * This function is used to initialize the event queue, * and the first section should be initialized at boot, * the second section should be called after all areas, * players, monsters, etc has been loaded into memory, * and it should contain all maintanence events. */ void init_event_queue(int section) { EVENT_DATA *event; int i; if (section == 1) { for (i = 0; i < MAX_EVENT_HASH; i++) { eventqueue[i] = AllocList(); } event_free = AllocStack(); global_events = AllocList(); } else if (section == 2) { event = alloc_event(); event->fun = &event_game_tick; event->type = EVENT_GAME_TICK; add_event_game(event, 10 * 60 * PULSES_PER_SECOND); } }
static void link_exits() { D_ROOM *r, *d; //room and destination room D_EXIT *e; //the exit we're linking in the room ITERATOR iterRoom, iterExit; //iterators for rooms and exits if( room_list == NULL ) { bug( "ERROR: Global room list does not exist. Aborting game!!" ); exit(1); } AttachIterator( &iterRoom, room_list );//iterate through all the rooms in the game while( ( r = (D_ROOM*)NextInList( &iterRoom ) ) != NULL ) { if( r->exits ) { AttachIterator( &iterExit, r->exits ); //iterate through each room's exits while( ( e = (D_EXIT*)NextInList(&iterExit ) ) != NULL ) { if( e->dest ) continue;//If it's already linked, skip it if( ( d = frbv( e->destVnum ) ) == NULL ) { bug( "Error: Attempting to link exit to room that does not exist( Room: %i Exit: %s to room %i.)", r->vnum, e->name, e->destVnum ); continue; } e->dest = d; } DetachIterator( &iterExit ); } else { bug( "Error: Room created with unallocated exit list. Correcting now..." ); r->exits = AllocList(); } } DetachIterator( &iterRoom ); return; }
static byte ParseArgs(int argc, char *argv[]) { int eaten; if (++argv, !--argc) { Usage(); return FALSE; } while (argc) { eaten = 1; if (!strcmp(*argv, "--separate-output")) separate_output = TRUE; else if (argc >= 2 && !strcmp(*argv, "--title")) title = argv[1], eaten = 2; else if (argc >= 2 && !strcmp(*argv, "--backtitle")) backtitle = argv[1], eaten = 2; else if (argc == 4 && !strcmp(*argv, "--yesno")) { eaten = argc; mode = InitYesNoBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); } else if (argc == 4 && !strcmp(*argv, "--msgbox")) { eaten = argc; mode = InitMsgBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); } else if (argc == 4 && !strcmp(*argv, "--infobox")) { eaten = argc; mode = InitInfoBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); } else if ((argc == 4 || argc == 5) && !strcmp(*argv, "--inputbox")) { eaten = argc; mode = InitInputBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); if (argc == 5) input = argv[4]; } else if (argc == 4 && !strcmp(*argv, "--textbox")) { eaten = argc; mode = InitTextBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); } else if (argc >= 7 && (argc % 2) == 1 && !strcmp(*argv, "--menu") && (listN = atoi(argv[4]))*2 + 5 == argc) { mode = InitMenuBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); AllocList(); for (eaten = 0; eaten < listN; eaten++) { list[eaten].tag = argv[5 + eaten*2]; list[eaten].item = argv[6 + eaten*2]; } eaten = argc; } else if (argc >= 8 && (argc % 3) == 2 && !strcmp(*argv, "--checklist") && (listN = atoi(argv[4]))*3 + 5 == argc) { mode = InitCheckBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); AllocList(); for (eaten = 0; eaten < listN; eaten++) { list[eaten].tag = argv[5 + eaten*3]; list[eaten].item = argv[6 + eaten*3]; list[eaten].status = OnOff(argv[7 + eaten*3]); } eaten = argc; } else if (argc >= 8 && (argc % 3) == 2 && !strcmp(*argv, "--radiolist") && (listN = atoi(argv[4]))*3 + 5 == argc) { mode = InitRadioBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); AllocList(); for (eaten = 0; eaten < listN; eaten++) { list[eaten].tag = argv[5 + eaten*3]; list[eaten].item = argv[6 + eaten*3]; list[eaten].status = OnOff(argv[7 + eaten*3]); } eaten = argc; } else if (argc == 5 && !strcmp(*argv, "--gauge")) { eaten = argc; mode = InitGaugeBox; text = argv[1]; height = atoi(argv[2]); width = atoi(argv[3]); percent = atoi(argv[4]); } else { Usage(); return FALSE; } argc -= eaten; argv += eaten; } width -= 2; height -= 2; return TRUE; }