void test_List_Remove(void **state) { struct list_node_t nodes[3]; struct list_t list = List_New(1); List_Append(&list, &nodes[0]); List_Append(&list, &nodes[1]); List_Append(&list, &nodes[2]); /* Try to remove a node not in the list. */ List_Remove(&list, &nodes[3]); assert_ptr_equal(list.root, &nodes[0]); assert_ptr_equal(nodes[0].next, &nodes[1]); assert_ptr_equal(nodes[1].next, &nodes[2]); List_Remove(&list, &nodes[1]); assert_ptr_equal(list.root, &nodes[0]); assert_ptr_equal(nodes[0].next, &nodes[2]); List_Remove(&list, &nodes[0]); assert_ptr_equal(list.root, &nodes[2]); List_Remove(&list, &nodes[2]); assert_null(list.root); }
void test_List_Append_NULL(void **state) { struct list_t list; struct list_node_t node; expect_assert_failure(List_Append(NULL, NULL)); expect_assert_failure(List_Append(&list, NULL)); expect_assert_failure(List_Append(NULL, &node)); }
void AsyncList_Append(AsyncList* self, void* data) { assert(self != NULL && data != NULL); SAL_Mutex_Acquire(self->Lock); List_Append(self->BaseList, data); SAL_Mutex_Release(self->Lock); }
void test_List_Append(void **state) { struct list_node_t nodes[3]; struct list_t list = List_New(1); List_Append(&list, &nodes[0]); assert_ptr_equal(list.root, &nodes[0]); List_Append(&list, &nodes[1]); assert_ptr_equal(list.root, &nodes[0]); assert_ptr_equal(nodes[0].next, &nodes[1]); List_Append(&list, &nodes[2]); assert_ptr_equal(list.root, &nodes[0]); assert_ptr_equal(nodes[0].next, &nodes[1]); assert_ptr_equal(nodes[1].next, &nodes[2]); }
void MeshVariable_SetMesh( void* meshVariable, void* _mesh ) { MeshVariable* self = (MeshVariable*)meshVariable; Mesh* mesh = (Mesh*)_mesh; assert( self ); self->mesh = mesh; if( mesh ) List_Append( mesh->vars, self ); }
val_t SVM_MakeObject(SimpleVM *vm, int type) { SVMObject *ob = MEM_calloc(sizeof(*ob)); LinkNode *node = MEM_malloc(sizeof(*node)); ob->type = TYPE_OBJECT; node->value = ob; List_Append(&vm->objects, node); return SVM_Obj2Val(ob); }
void ListSuite_TestClear( ListSuiteData* data ) { Index idx; for( idx = 0; idx < NUM_ITEMS; idx++ ) { List_Append( data->list, &data->arrayData[idx] ); } List_Clear( data->list ); pcu_check_true( data->list->nItems == 0 ); List_Clear( data->list ); pcu_check_true( data->list->nItems == 0 ); }
void ListSuite_TestAppend( ListSuiteData* data ) { Index idx; for( idx = 0; idx < NUM_ITEMS; idx++ ) { List_Append( data->list, &data->arrayData[idx] ); } pcu_check_true( data->list->nItems == NUM_ITEMS ); for( idx = 0; idx < NUM_ITEMS; idx++ ) { pcu_check_true( *(int*)List_GetItem( data->list, idx ) == idx ); } }
void *_MEM_malloc(size_t size, char *tag, char *file, int line) { MemHead *mem; MemTail *tail; pthread_mutex_lock(&mem_mutex); if (size & 7) { size = size + 8 - (size & 7); //round up to nearest multiple of eight } mem = (MemHead*) malloc(size+sizeof(MemHead)+sizeof(MemTail)); if (!mem) { pthread_mutex_unlock(&mem_mutex); return NULL; } tail = (MemTail*)(((unsigned char*)(mem+1)) + size); mem->code1 = H_MEMCODE1; mem->code2 = H_MEMCODE2; mem->size = size; mem->used = 0; mem->len = 0; mem->esize = 0; mem->esize = 0; mem->file = file; mem->tag = tag; mem->line = line; tail->code1 = T_MEMCODE1; tail->code2 = T_MEMCODE2; tail->size = size; tail->len = 0; tail->used = 0; tail->esize = 0; List_Append(&MemHeads, mem); List_Append(&MemTails, tail); pthread_mutex_unlock(&mem_mutex); return mem+1; }
CList List_Copy(CList &l, size_t from, size_t count) { from = clamp(from, 0ul, l.size); count = clamp(count, 0ul, l.size - from); CList copy = List_Create(count); for(size_t i = 0; i < count; ++i) { List_Append(copy, List_Get(l, from + i)); } return copy; }
void M_Menu_Demos(void) { ui_sortdemos = Cvar_Get("ui_sortdemos", "1", 0); ui_sortdemos->changed = ui_sortdemos_changed; ui_listalldemos = Cvar_Get("ui_listalldemos", "0", 0); m_demos.menu.name = "demos"; m_demos.menu.title = "Demo Browser"; strcpy(m_demos.browse, "/demos"); m_demos.menu.draw = Draw; m_demos.menu.expose = Expose; m_demos.menu.pop = Pop; m_demos.menu.size = Size; m_demos.menu.keydown = Keydown; m_demos.menu.free = Free; m_demos.menu.image = uis.backgroundHandle; m_demos.menu.color.u32 = uis.color.background.u32; m_demos.menu.transparent = uis.transparent; m_demos.list.generic.type = MTYPE_LIST; m_demos.list.generic.flags = QMF_HASFOCUS; m_demos.list.generic.activate = Activate; m_demos.list.generic.change = Change; m_demos.list.numcolumns = COL_MAX; m_demos.list.sortdir = 1; m_demos.list.sortcol = COL_NAME; m_demos.list.extrasize = DEMO_EXTRASIZE; m_demos.list.sort = Sort; m_demos.list.mlFlags = MLF_HEADER | MLF_SCROLLBAR; m_demos.list.columns[0].name = m_demos.browse; m_demos.list.columns[0].uiFlags = UI_LEFT; m_demos.list.columns[1].name = "Date"; m_demos.list.columns[1].uiFlags = UI_CENTER; m_demos.list.columns[2].name = "Size"; m_demos.list.columns[2].uiFlags = UI_RIGHT; m_demos.list.columns[3].name = "Map"; m_demos.list.columns[3].uiFlags = UI_CENTER; m_demos.list.columns[4].name = "POV"; m_demos.list.columns[4].uiFlags = UI_CENTER; ui_sortdemos_changed(ui_sortdemos); Menu_AddItem(&m_demos.menu, &m_demos.list); List_Append(&ui_menus, &m_demos.menu.entry); }
List* List_InsertAtIndex(List* list, int index, void* value) { if (index == 0) // If index is first element { return List_Prepend(list, value); } else if (index < list->count) // If index out of range, or index is last element. { return List_Append(list, value); } else { return List_UnsafeInsertAtIndex(list, index, value); } }
void ListSuite_TestExists( ListSuiteData* data ) { Index idx; int inArray=5; int notInArray=34352; for( idx = 0; idx < NUM_ITEMS; idx++ ) { List_Append( data->list, &data->arrayData[idx] ); } for( idx = 0; idx < NUM_ITEMS; idx++ ) { pcu_check_true( List_Exists( data->list, &data->arrayData[idx] ) == True ); } pcu_check_true( List_Exists( data->list, &inArray ) == True ); pcu_check_true( List_Exists( data->list, ¬InArray ) == False ); }
void test_List_GetLength(void **state) { const size_t nr_nodes = 4; struct list_node_t nodes[nr_nodes]; struct list_t list = List_New(1); for (size_t i = 0; i < nr_nodes; ++i) { assert_int_equal(List_GetLength(&list), i); List_Append(&list, &nodes[i]); } for (size_t i = 0; i < nr_nodes; ++i) { assert_int_equal(List_GetLength(&list), nr_nodes - i); List_Remove(&list, &nodes[i]); } }
/* Creates a class entry object */ _Use_decl_annotations_ IndicationClassEntry* IndicationClassList_AddEntry( IndicationClassList* list, const ProvRegEntry* regentry) { IndicationClassEntry *entry = (IndicationClassEntry*)Batch_GetClear( list->batch, sizeof(IndicationClassEntry)); if (NULL == entry) { LOGD_BATCH_OOM; return NULL; } entry->container = (void*)list; entry->regentry = regentry; entry->status = SUBSCRIBE_INITED; entry->subid = 0; List_Append((ListElem**)&list->head, (ListElem**)&list->tail, (ListElem*)entry); list->totalclass ++; return entry; }
void ListSuite_TestRemove( ListSuiteData* data ) { Index idx; Index listIndex=0; for( idx = 0; idx < NUM_ITEMS; idx++ ) { List_Append( data->list, &data->arrayData[idx] ); } for( idx = 0; idx < NUM_ITEMS; idx++ ) { if ( idx % 2 == 0 ) { List_Remove( data->list, &data->arrayData[idx] ); } } pcu_check_true( data->list->nItems == NUM_ITEMS/2 ); listIndex=0; for( idx = 0; idx < NUM_ITEMS; idx++ ) { if ( idx % 2 == 1 ) { pcu_check_true( *(int*)List_GetItem( data->list, listIndex ) == idx ); listIndex++; } } }
static void add_filter(ipaction_t action, unsigned mask, unsigned compare, unsigned duration, edict_t *ent) { ipfilter_t *ip; char *s; ip = G_Malloc(sizeof(*ip)); ip->action = action; ip->mask = mask; ip->compare = compare; ip->added = time(NULL); ip->duration = duration; if (ent) { strcpy(ip->adder, ent->client->pers.ip); s = strchr(ip->adder, ':'); if (s) { *s = 0; } } else { strcpy(ip->adder, "console"); } List_Append(&ipfilters, &ip->list); numipfilters++; }
/* =============== CL_QueueDownload Adds new download path into queue, incrementing pending count. Entry will stay in queue for entire lifetime of server connection, to make sure each path is tried exactly once. =============== */ qerror_t CL_QueueDownload( const char *path, dltype_t type ) { dlqueue_t *q; size_t len; FOR_EACH_DLQ( q ) { // avoid sending duplicate requests if( !FS_pathcmp( path, q->path ) ) { Com_DPrintf( "%s: %s [DUP]\n", __func__, path ); return Q_ERR_EXIST; } } len = strlen( path ); if( len >= MAX_QPATH ) { Com_Error( ERR_DROP, "%s: oversize quake path", __func__ ); } q = Z_Malloc( sizeof( *q ) + len ); memcpy( q->path, path, len + 1 ); q->type = type; q->state = DL_PENDING; #if USE_CURL // paks get bumped to the top and HTTP switches to single downloading. // this prevents someone on 28k dialup trying to do both the main .pak // and referenced configstrings data at once. if( type == DL_PAK ) List_Insert( &cls.download.queue, &q->entry ); else #endif List_Append( &cls.download.queue, &q->entry ); cls.download.pending++; Com_DPrintf( "%s: %s [%d]\n", __func__, path, cls.download.pending ); return Q_ERR_SUCCESS; }
// Generate the list of smileys / text to be drawn void Cache_ReplaceSmileys(struct ClcData *dat, struct ClcContact *contact, TCHAR *text, int text_size, SortedList **plText, int *max_smiley_height, BOOL replace_smileys) { SMADD_PARSET sp; int last_pos=0; *max_smiley_height = 0; if (!dat->text_replace_smileys || !replace_smileys || text == NULL || !ServiceExists(MS_SMILEYADD_PARSET)) { Cache_DestroySmileyList(*plText); *plText = NULL; return; } // Free old list if (*plText != NULL) { Cache_DestroySmileyList(*plText); *plText = NULL; } // Call service for the first time to see if needs to be used... sp.cbSize = sizeof(sp); if (dat->text_use_protocol_smileys) { sp.Protocolname = contact->proto; if (DBGetContactSettingByte(NULL,"CLC","Meta",0) != 1 && contact->proto != NULL && strcmp(contact->proto, "MetaContacts") == 0) { HANDLE hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (UINT)contact->hContact, 0); if (hContact != 0) { sp.Protocolname = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (UINT)hContact, 0); } } } else { sp.Protocolname = "clist"; } sp.str = text; sp.startChar = 0; sp.size = 0; CallService(MS_SMILEYADD_PARSET, 0, (LPARAM)&sp); if (sp.size == 0) { // Did not find a simley return; } // Lets add smileys *plText = List_Create( 10, 10 ); do { if (sp.SmileyIcon != NULL) // For deffective smileypacks { // Add text if (sp.startChar-last_pos > 0) { ClcContactTextPiece *piece = (ClcContactTextPiece *) mir_alloc(sizeof(ClcContactTextPiece)); piece->type = TEXT_PIECE_TYPE_TEXT; piece->start_pos = last_pos ;//sp.str - text; piece->len = sp.startChar-last_pos; List_Append(*plText, piece); } // Add smiley { BITMAP bm; ICONINFO icon; ClcContactTextPiece *piece = (ClcContactTextPiece *) mir_alloc(sizeof(ClcContactTextPiece)); piece->type = TEXT_PIECE_TYPE_SMILEY; piece->len = sp.size; piece->smiley = sp.SmileyIcon; if (GetIconInfo(piece->smiley, &icon) && GetObject(icon.hbmColor,sizeof(BITMAP),&bm)) { piece->smiley_width = bm.bmWidth; piece->smiley_height = bm.bmHeight; } else { piece->smiley_width = 16; piece->smiley_height = 16; } dat->text_smiley_height = max(piece->smiley_height, dat->text_smiley_height); *max_smiley_height = max(piece->smiley_height, *max_smiley_height); List_Append(*plText, piece); } } /* * Bokra SmileyAdd Fix: */ // Get next last_pos=sp.startChar+sp.size; CallService(MS_SMILEYADD_PARSET, 0, (LPARAM)&sp); } while (sp.size != 0); // // Get next // sp.str += sp.startChar + sp.size; // sp.startChar = 0; // sp.size = 0; // CallService(MS_SMILEYADD_PARSE, 0, (LPARAM)&sp); //} //while (sp.SmileyIcon != NULL && sp.size != 0); // Add rest of text if (last_pos < text_size) { ClcContactTextPiece *piece = (ClcContactTextPiece *) mir_alloc(sizeof(ClcContactTextPiece)); piece->type = TEXT_PIECE_TYPE_TEXT; piece->start_pos = last_pos; piece->len = text_size-last_pos; List_Append(*plText, piece); } }
unsigned GeneralSwarm_IntegrationPointMap( void* _self, void* _intSwarm, unsigned elementId, unsigned intPtCellId ){ GeneralSwarm* self = (GeneralSwarm*)_self; IntegrationPointsSwarm* intSwarm = (IntegrationPointsSwarm*)_intSwarm; Mesh* intMesh = (Mesh*)intSwarm->mesh; SwarmMap* map = NULL; // first, lets check if the int swarm is mirroring a general swarm if (intSwarm->mirroredSwarm == (Swarm*)self) { // ok, it is a mirrored swarm return Swarm_ParticleCellIDtoLocalID( self, CellLayout_MapElementIdToCellId( self->cellLayout, elementId ), intPtCellId ); } else if ( self->previousIntSwarmMap && self->previousIntSwarmMap->swarm==intSwarm ) { /* next check if previous swarmmap */ map = self->previousIntSwarmMap; } else { /* ok, previous is not our guy, check other existing: */ int ii; for (ii=0; ii<List_GetSize(self->intSwarmMapList); ii++) { map = *(SwarmMap**)List_GetItem(self->intSwarmMapList, ii); if ( map->swarm==intSwarm ){ self->previousIntSwarmMap = map; break; } } // if we've gotten to this point, there is no corresponding map.. let's create one */ map = SwarmMap_New( intSwarm ); // add to list List_Append( self->intSwarmMapList, (void*)&map ); self->previousIntSwarmMap = map; // also add to int swarm incase it moves List_Append( intSwarm->swarmsMappedTo, (void*)&map ); } unsigned matPointLocalIndex; if ( SwarmMap_Map(map,elementId,intPtCellId,&matPointLocalIndex) ) { /* ok, map found, return value */ return matPointLocalIndex; } else { /* not found... damn.. lets go ahead and find nearest neighbour */ /* lets check some things */ Journal_Firewall( Stg_Class_IsInstance( self->cellLayout, ElementCellLayout_Type ), NULL, "Error In func %s: %s expects a materialSwarm with cellLayout of type ElementCellLayout.", __func__, self->type ); Journal_Firewall( intSwarm->mesh==(FeMesh*)((ElementCellLayout*)self->cellLayout)->mesh, Journal_Register( Error_Type, (Name)self->type ), "Error - in %s(): Mapper requires both the MaterialSwarm and\n" "the IntegrationSwarm to live on the same mesh.\n" "Here the MaterialSwarm %s lives in the mesh %s\n" "and the IntegrationSwarm %s lives in the mesh %s.", self->name, ((ElementCellLayout*)self->cellLayout)->mesh->name, intSwarm->name, intSwarm->mesh->name ); Cell_Index cell_I = CellLayout_MapElementIdToCellId( intSwarm->cellLayout, elementId ); Cell_Index cell_M = CellLayout_MapElementIdToCellId( self->cellLayout, elementId ); IntegrationPoint* integrationPoint = (IntegrationPoint*)Swarm_ParticleInCellAt( intSwarm, cell_I, intPtCellId ); /* Convert integration point local to global coordinates */ Coord global; FeMesh_CoordLocalToGlobal( intMesh, elementId, integrationPoint->xi, (double*) &global ); /* now lets sweep material points to find our closest friend */ double distance2_min = DBL_MAX; double distance2; Particle_Index particle_M; unsigned cellPartCount = self->cellParticleCountTbl[ cell_M ]; Journal_Firewall( cellPartCount, Journal_Register( Error_Type, (Name)self->type ), "Error - in %s(): There doesn't appear to be any particles\n" "within the current cell (%u).\n", self->name, cell_M ); for ( particle_M = 0; particle_M < cellPartCount; particle_M++ ) { GlobalParticle* materialPoint = (GlobalParticle*)Swarm_ParticleInCellAt( self, cell_M, particle_M ); distance2 = pow( global[0] - materialPoint->coord[0], 2 ) + pow( global[1] - materialPoint->coord[1], 2 ); if( self->dim == 3 ) distance2 += pow( global[2] - materialPoint->coord[2], 2 ); if ( distance2 < distance2_min ){ distance2_min = distance2; matPointLocalIndex = Swarm_ParticleCellIDtoLocalID( self, cell_M, particle_M ); } } /* ok, we've found our nearest friend. record to mapping */ SwarmMap_Insert(map,elementId,intPtCellId,matPointLocalIndex); } return matPointLocalIndex; }
void StringList_Append(StringList *sl, char *s){ List_Append((List *)sl,(void *)s); }
static qboolean Parse_File(const char *path, int depth) { char *raw, *data, *p, *cmd; int argc; menuFrameWork_t *menu = NULL; qerror_t ret; ret = FS_LoadFile(path, (void **)&raw); if (!raw) { if (ret != Q_ERR_NOENT || depth) { Com_WPrintf("Couldn't %s %s: %s\n", depth ? "include" : "load", path, Q_ErrorString(ret)); } return qfalse; } data = raw; COM_Compress(data); while (*data) { p = strchr(data, '\n'); if (p) { *p = 0; } Cmd_TokenizeString(data, qtrue); argc = Cmd_Argc(); if (argc) { cmd = Cmd_Argv(0); if (menu) { if (!strcmp(cmd, "end")) { if (menu->nitems) { List_Append(&ui_menus, &menu->entry); } else { Com_WPrintf("Menu entry without items\n"); menu->free(menu); } menu = NULL; } else if (!strcmp(cmd, "title")) { if (menu->title) { Z_Free(menu->title); } menu->title = UI_CopyString(Cmd_Argv(1)); } else if (!strcmp(cmd, "plaque")) { Parse_Plaque(menu); } else if (!strcmp(cmd, "banner")) { Parse_Banner(menu); } else if (!strcmp(cmd, "background")) { Parse_Background(menu); } else if (!strcmp(cmd, "style")) { Parse_Style(menu); } else if (!strcmp(cmd, "values")) { Parse_Spin(menu, MTYPE_SPINCONTROL); } else if (!strcmp(cmd, "strings")) { Parse_Spin(menu, MTYPE_STRINGS); } else if (!strcmp(cmd, "pairs")) { Parse_Pairs(menu); } else if (!strcmp(cmd, "range")) { Parse_Range(menu); } else if (!strcmp(cmd, "action")) { Parse_Action(menu); } else if (!strcmp(cmd, "bitmap")) { Parse_Bitmap(menu); } else if (!strcmp(cmd, "bind")) { Parse_Bind(menu); } else if (!strcmp(cmd, "savegame")) { Parse_Savegame(menu, MTYPE_SAVEGAME); } else if (!strcmp(cmd, "loadgame")) { Parse_Savegame(menu, MTYPE_LOADGAME); } else if (!strcmp(cmd, "toggle")) { Parse_Toggle(menu); } else if (!strcmp(cmd, "field")) { Parse_Field(menu); } else if (!strcmp(cmd, "blank")) { Parse_Blank(menu); } else { Com_WPrintf("Unknown keyword '%s'\n", cmd); } } else { if (!strcmp(cmd, "begin")) { char *s = Cmd_Argv(1); if (!*s) { Com_WPrintf("Expected menu name after '%s'\n", cmd); break; } menu = UI_FindMenu(s); if (menu) { if (menu->free) { menu->free(menu); } List_Remove(&menu->entry); } menu = UI_Mallocz(sizeof(*menu)); menu->name = UI_CopyString(s); menu->push = Menu_Push; menu->pop = Menu_Pop; menu->free = Menu_Free; menu->image = uis.backgroundHandle; menu->color.u32 = uis.color.background.u32; menu->transparent = uis.transparent; } else if (!strcmp(cmd, "include")) { char *s = Cmd_Argv(1); if (!*s) { Com_WPrintf("Expected file name after '%s'\n", cmd); break; } if (depth == 16) { Com_WPrintf("Includes too deeply nested\n"); } else { Parse_File(s, depth + 1); } } else if (!strcmp(cmd, "color")) { Parse_Color(); } else if (!strcmp(cmd, "background")) { char *s = Cmd_Argv(1); if (SCR_ParseColor(s, &uis.color.background)) { uis.backgroundHandle = 0; uis.transparent = uis.color.background.u8[3] != 255; } else { uis.backgroundHandle = R_RegisterPic(s); uis.transparent = R_GetPicSize(NULL, NULL, uis.backgroundHandle); } } else if (!strcmp(cmd, "font")) { uis.fontHandle = R_RegisterFont(Cmd_Argv(1)); } else if (!strcmp(cmd, "cursor")) { uis.cursorHandle = R_RegisterPic(Cmd_Argv(1)); R_GetPicSize(&uis.cursorWidth, &uis.cursorHeight, uis.cursorHandle); } else if (!strcmp(cmd, "weapon")) { Cmd_ArgvBuffer(1, uis.weaponModel, sizeof(uis.weaponModel)); } else { Com_WPrintf("Unknown keyword '%s'\n", cmd); break; } } } if (!p) { break; } data = p + 1; } FS_FreeFile(raw); if (menu) { Com_WPrintf("Menu entry without 'end' terminator\n"); menu->free(menu); } return qtrue; }
void PF_LinkEdict(edict_t *ent) { areanode_t *node; server_entity_t *sent; int entnum; #if USE_FPS int i; #endif if (ent->area.prev) PF_UnlinkEdict(ent); // unlink from old position if (ent == ge->edicts) return; // don't add the world if (!ent->inuse) { Com_DPrintf("%s: entity %d is not in use\n", __func__, NUM_FOR_EDICT(ent)); return; } if (!sv.cm.cache) { return; } entnum = NUM_FOR_EDICT(ent); sent = &sv.entities[entnum]; // encode the size into the entity_state for client prediction switch (ent->solid) { case SOLID_BBOX: if ((ent->svflags & SVF_DEADMONSTER) || VectorCompare(ent->mins, ent->maxs)) { ent->s.solid = 0; sent->solid32 = 0; } else { ent->s.solid = MSG_PackSolid16(ent->mins, ent->maxs); sent->solid32 = MSG_PackSolid32(ent->mins, ent->maxs); } break; case SOLID_BSP: ent->s.solid = PACKED_BSP; // a SOLID_BBOX will never create this value sent->solid32 = PACKED_BSP; // FIXME: use 255? break; default: ent->s.solid = 0; sent->solid32 = 0; break; } SV_LinkEdict(&sv.cm, ent); // if first time, make sure old_origin is valid if (!ent->linkcount) { VectorCopy(ent->s.origin, ent->s.old_origin); #if USE_FPS VectorCopy(ent->s.origin, sent->create_origin); sent->create_framenum = sv.framenum; #endif } ent->linkcount++; #if USE_FPS // save origin for later recovery i = sv.framenum & ENT_HISTORY_MASK; VectorCopy(ent->s.origin, sent->history[i].origin); sent->history[i].framenum = sv.framenum; #endif if (ent->solid == SOLID_NOT) return; // find the first node that the ent's box crosses node = sv_areanodes; while (1) { if (node->axis == -1) break; if (ent->absmin[node->axis] > node->dist) node = node->children[0]; else if (ent->absmax[node->axis] < node->dist) node = node->children[1]; else break; // crosses the node } // link it in if (ent->solid == SOLID_TRIGGER) List_Append(&node->trigger_edicts, &ent->area); else List_Append(&node->solid_edicts, &ent->area); }
void M_Menu_Servers(void) { ui_sortservers = Cvar_Get("ui_sortservers", "0", 0); ui_sortservers->changed = ui_sortservers_changed; ui_colorservers = Cvar_Get("ui_colorservers", "0", 0); ui_colorservers->changed = ui_colorservers_changed; ui_pingrate = Cvar_Get("ui_pingrate", "0", 0); m_servers.menu.name = "servers"; m_servers.menu.title = "Server Browser"; m_servers.menu.draw = Draw; m_servers.menu.expose = Expose; m_servers.menu.push = Push; m_servers.menu.pop = Pop; m_servers.menu.size = Size; m_servers.menu.keydown = Keydown; m_servers.menu.free = Free; m_servers.menu.image = uis.backgroundHandle; m_servers.menu.color.u32 = uis.color.background.u32; m_servers.menu.transparent = uis.transparent; // // server list // m_servers.list.generic.type = MTYPE_LIST; m_servers.list.generic.flags = QMF_LEFT_JUSTIFY | QMF_HASFOCUS; m_servers.list.generic.activate = Connect; m_servers.list.generic.change = Change; m_servers.list.items = m_servers.names; m_servers.list.numcolumns = COL_MAX; m_servers.list.sortdir = 1; m_servers.list.sortcol = -1; m_servers.list.sort = Sort; m_servers.list.extrasize = SLOT_EXTRASIZE; m_servers.list.mlFlags = MLF_HEADER | MLF_SCROLLBAR; m_servers.list.columns[0].uiFlags = UI_LEFT; m_servers.list.columns[0].name = "Hostname"; m_servers.list.columns[1].uiFlags = UI_CENTER; m_servers.list.columns[1].name = "Mod"; m_servers.list.columns[2].uiFlags = UI_CENTER; m_servers.list.columns[2].name = "Map"; m_servers.list.columns[3].uiFlags = UI_CENTER; m_servers.list.columns[3].name = "Players"; m_servers.list.columns[4].uiFlags = UI_RIGHT; m_servers.list.columns[4].name = "RTT"; ui_colorservers_changed(ui_colorservers); // // server info // m_servers.info.generic.type = MTYPE_LIST; m_servers.info.generic.flags = QMF_LEFT_JUSTIFY | QMF_HIDDEN; m_servers.info.generic.activate = Connect; m_servers.info.numcolumns = 2; m_servers.info.mlFlags = MLF_HEADER | MLF_SCROLLBAR; m_servers.info.columns[0].uiFlags = UI_LEFT; m_servers.info.columns[0].name = "Key"; m_servers.info.columns[1].uiFlags = UI_LEFT; m_servers.info.columns[1].name = "Value"; // // player list // m_servers.players.generic.type = MTYPE_LIST; m_servers.players.generic.flags = QMF_LEFT_JUSTIFY | QMF_HIDDEN; m_servers.players.generic.activate = Connect; m_servers.players.numcolumns = 3; m_servers.players.mlFlags = MLF_HEADER; m_servers.players.columns[0].uiFlags = UI_RIGHT; m_servers.players.columns[0].name = "Frg"; m_servers.players.columns[1].uiFlags = UI_RIGHT; m_servers.players.columns[1].name = "RTT"; m_servers.players.columns[2].uiFlags = UI_LEFT; m_servers.players.columns[2].name = "Name"; Menu_AddItem(&m_servers.menu, &m_servers.list); Menu_AddItem(&m_servers.menu, &m_servers.info); Menu_AddItem(&m_servers.menu, &m_servers.players); List_Append(&ui_menus, &m_servers.menu.entry); }