void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me) { float sortbuf, glob, i; string fn; glob = search_begin(language_filename(get_model_datafilename(string_null, -1, "txt")), TRUE, TRUE); if (glob < 0) return; me.configureXonoticImage(me, string_null, -1); sortbuf = buf_create(); for(i = 0; i < search_getsize(glob); ++i) { // select model #i! fn = search_getfilename(glob, i); if(!get_model_parameters(fn, -1)) continue; bufstr_add(sortbuf, sprintf("%-128s%s", get_model_parameters_name, fn), 1); } search_end(glob); buf_sort(sortbuf, 128, 0); me.numModels = buf_getsize(sortbuf); me.bufModels = buf_create(); for(i = 0; i < me.numModels; ++i) { fn = substring(bufstr_get(sortbuf, i), 128, -1); if(!get_model_parameters(fn, -1)) error("But it JUST worked!"); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_TITLE, get_model_parameters_name); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_IMAGE, strcat("/", substring(get_model_datafilename(get_model_parameters_modelname, get_model_parameters_modelskin, "tga"), 0, -5))); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_MODEL, get_model_parameters_modelname); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN, ftos(get_model_parameters_modelskin)); get_model_parameters_desc = strcat(get_model_parameters_desc, "\n"); if(get_model_parameters_sex) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nSex: %s", get_model_parameters_sex)); if(get_model_parameters_weight) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nWeight: %g kg", get_model_parameters_weight)); if(get_model_parameters_age) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nAge: %g", get_model_parameters_age)); while(substring(get_model_parameters_desc, -1, 1) == "\n") get_model_parameters_desc = substring(get_model_parameters_desc, 0, -2); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_DESC, get_model_parameters_desc); } buf_del(sortbuf); get_model_parameters(string_null, 0); me.loadCvars(me); // this will select the initial model, depending on the current cvars me.go(me, 0); // this will set the vars for the selected model }
void iq_schedule (buffer_desc_t ** bufs, int n) { int inx; int is_reads = 0; buf_sort (bufs, n, (sort_key_func_t) bd_phys_page_key); for (inx = 0; inx < n; inx++) { if (bufs[inx]->bd_iq) GPF_T1 ("buffer added to iq already has a bd_iq"); bufs[inx]->bd_iq = db_io_queue (bufs[inx]->bd_storage, bufs[inx]->bd_physical_page); } DO_SET (io_queue_t *, iq, &mti_io_queues) { int n_added = 0; buffer_desc_t * ipoint; int was_empty; IN_IOQ (iq); inx = 0; ipoint = iq->iq_first; was_empty = (iq->iq_first == NULL); while (inx < n) { buffer_desc_t * buf = bufs[inx]; if (!buf || buf->bd_iq != iq) { inx++; continue; } is_reads = buf->bd_being_read; if (buf->bd_iq_next || buf->bd_iq_prev) GPF_T1 ("can't schedule same buffer twice"); bufs[inx] = NULL; next_ipoint: if (!ipoint) { L2_PUSH_LAST (iq->iq_first, iq->iq_last, buf, bd_iq_); n_added++; inx++; } else if (BUF_SORT_DP (ipoint) < BUF_SORT_DP (buf)) { ipoint = ipoint->bd_iq_next; goto next_ipoint; } else if (BUF_SORT_DP (ipoint) == BUF_SORT_DP (buf)) GPF_T1 ("the same buffer can't be scheduled twice for io"); else { L2_INSERT (iq->iq_first, iq->iq_last, ipoint, buf, bd_iq_); n_added++; inx++; } if (!buf->bd_being_read) { page_leave_outside_map (buf); } } LEAVE_IOQ (iq); if (n_added && !is_reads) { dbg_printf (("IQ %s %d %s added, %s.\n", IQ_NAME (iq), n_added, is_reads ? "reads" : "writes", was_empty ? "starting" : "running")); } if (n_added && was_empty) semaphore_leave (iq->iq_sem); } END_DO_SET (); if (n) { if (is_reads) mti_reads_queued += n; else mti_writes_queued += n; } }