/** * @brief Handles the list of constructable buildings. * @param[in] buildingList list of buildings to upate * @param[in] building Add this building to the construction list * @note Called everytime a building was constructed and thus maybe other buildings * get available. The content is updated everytime B_BuildingInit is called * (i.e everytime the buildings-list is displayed/updated) */ static void B_BuildingAddToList (linkedList_t **buildingList, building_t *building) { int count; assert(building); assert(building->name); count = LIST_Count(*buildingList); LIST_AddPointer(buildingList, _(building->name)); buildingConstructionList[count] = building->tpl; }
/** * @brief Callback every time the parent window is opened (pushed into the active window stack) */ static void UI_CvarListenerNodeBind (uiNode_t* node) { cvarChangeListener_t* l; l = Cvar_RegisterChangeListener(node->name, UI_CvarListenerNodeCallback); if (l == nullptr) { Com_Printf("Node %s is not binded: cvar %s not found\n", UI_GetPath(node), node->name); return; } if (LIST_GetPointer(static_cast<linkedList_t*>(l->data), node) == nullptr) { LIST_AddPointer(reinterpret_cast<linkedList_t**>(&l->data), node); } }
/** * @brief Return a list of hired employees in the given base of a given type * @param[in] base Which base the employee should be searched in. If NULL is given employees in all bases will be listed. * @param[in] type Which employee type to search for. * @param[out] hiredEmployees Linked list of hired employees in the base. * @return Number of hired employees in the base that are currently not on a transfer. Or @c -1 in case of an error. */ int E_GetHiredEmployees (const base_t* const base, employeeType_t type, linkedList_t **hiredEmployees) { employee_t *employee; if (type >= MAX_EMPL) { Com_Printf("E_GetHiredEmployees: Unknown EmployeeType: %i\n", type); *hiredEmployees = NULL; return -1; } LIST_Delete(hiredEmployees); E_Foreach(type, employee) { if (!E_IsHired(employee)) continue; if (!employee->transfer && (!base || E_IsInBase(employee, base))) { LIST_AddPointer(hiredEmployees, employee); } } if (hiredEmployees == NULL) return 0; return LIST_Count(*hiredEmployees); }
/** * @brief Copies the list structure data - but not the content from the original list. * We are only using pointers here. */ linkedList_t *LIST_CopyStructure (linkedList_t *src) { linkedList_t *dest = nullptr; LIST_Foreach(src, void, data) { LIST_AddPointer(&dest, data); }