void Timers::Execute() { timeval curTime; gettimeofday(&curTime, 0); for (Timer* s = m_firstTimer; s != 0; s = m_firstTimer) { if (CompareTimevals(s->GetNextExecution(), curTime)) break; TimerCbk_t cbk = s->GetCallback(); void* userdata = s->GetUserdata(); s->Update(); int remainingReps = s->GetRemainingRepetitions(); cbk(userdata); if (FindTimer(s)) { DeleteFromList(s); if (remainingReps == 0) delete s; else InsertTimer(s); } } }
int Nalichnosti(struct Firm **head, struct Firm **Ehead) { struct Firm *ptr = *head; struct Firm *prev = NULL; char stoka[61]; int c = 0, kolichestvo = 0, result = 1, x = 0; printf("1: Dobavqne na kolichestva\n"); printf("2: Izvajdane na kolichestva\n"); c = getch(); x = Naimenovanie(stoka); if(x == ESCAPE) { return ESCAPE; } while(ptr != NULL) { result = strcmp(stoka, ptr->stoka); if(result == 0) { kolichestvo = Kolichestvo(); if(kolichestvo == ESCAPE) { return ESCAPE; } switch(c) { case '1': { ptr->kolichestvo += kolichestvo; return SUCC; } case '2': { if(kolichestvo > ptr->kolichestvo) { return ERROR; } else { ptr->kolichestvo -= kolichestvo; if(ptr->kolichestvo == 0) { DeleteFromList(head, Ehead, ptr, prev); } return SUCC; } } } } else { prev = ptr; ptr = ptr->next; } } }
void Timers::Destroy(Timer* timer) { if (FindTimer(timer)) { DeleteFromList(timer); delete timer; } }
void AGE_Frame::OnSoundItemsDelete(wxCommandEvent &Event) { auto selections = Sounds_Items_List->GetSelections(Items); if(selections < 1) return; wxBusyCursor WaitCursor; DeleteFromList(GenieFile->Sounds[SoundIDs[0]].Items, SoundItemIDs); ListSoundItems(); }
void CLightManager::DeleteLightnings (void) { CDynLight* pl = &m_data.lights [0]; for (short i = 0; i < m_data.nLights [0]; ) if ((pl->info.nSegment >= 0) && (pl->info.nSide < 0)) { DeleteFromList (pl, i); } else { i++; pl++; } }
void CLightManager::Delete (short nLight) { if ((nLight >= 0) && (nLight < m_data.nLights [0])) { CDynLight* pl = m_data.lights + nLight; #if DBG if ((nDbgSeg >= 0) && (nDbgSeg == pl->info.nSegment) && ((nDbgSide < 0) || (nDbgSide == pl->info.nSide))) nDbgSeg = nDbgSeg; #endif if (!pl->info.nType) { // do not remove static lights, or the nearest lights to segment info will get messed up! pl->info.bState = pl->info.bOn = 0; return; } DeleteFromList (pl, nLight); } }
int main() { Node *head = NULL; Node *current = NULL; Node *temp = NULL; AddtoList(&head, 1); AddtoList(&head, 2); AddtoList(&head, 3); AddtoList(&head, 1); AddtoList(&head, 3); current = head; //DeletFromList(&(head),1); PrintList(&head); while(current!= NULL) { temp = current; while(temp->next!=NULL) { DeleteFromList(&(temp->next), current->data); temp = temp->next; } current = current->next; } return 0; }
/*! * Ensures that the list is populated with all the cities in the save game * slots. */ Boolean hFiles(EventPtr event) { Boolean handled = false; char *currentcity; FormPtr form; #if defined(HRSUPPORT) Int16 hOff = 0, vOff = 0; #endif switch (event->eType) { case frmOpenEvent: form = FrmGetActiveForm(); SetSilkResizable(form, true); collapseMove(form, CM_DEFAULT, &hOff, &vOff); resizeSavegameForm(form, hOff, vOff); filesSetup(form); FrmDrawForm(form); handled = true; break; case frmCloseEvent: CleanSaveGameList(); SetSilkResizable(NULL, false); break; case ctlSelectEvent: switch (event->data.ctlSelect.controlID) { case buttonID_FilesNew: /* create new game and add it to the list */ FrmPopupForm(formID_filesNew); handled = true; break; case buttonID_FilesLoad: /* create new game */ if (LoadFromList() != -1) FrmGotoForm(formID_pocketCity); handled = true; break; case buttonID_FilesDelete: currentcity = GetCurrentCityOnList(); if ((currentcity != NULL) && (FrmCustomAlert(alertID_deleteCityConfirm, currentcity, NULL, NULL) == 0)) { DeleteFromList(); CleanSaveGameList(); UpdateSaveGameList(); } handled = true; break; } break; #if defined(HRSUPPORT) case winDisplayChangedEvent: #if defined(SONY_CLIE) case vchrSilkResize: #endif form = FrmGetActiveForm(); if (collapseMove(form, CM_DEFAULT, &hOff, &vOff)) { resizeSavegameForm(form, hOff, vOff); FrmDrawForm(form); } handled = true; break; #endif default: break; } return (handled); }