LinkedList<Face>* CSDFController::GetFaceList(LinkedList<Face>* triangles, Octree* root, Vector4 center, Vector4 ray) { if (root == NULL) return triangles; LinkedList<Octree>* octrees = oc_list; LinkedList<Face>* faces = fc_list; octrees->Clear(); faces->Clear(); //center = center - (ray * diagonal); // hack ray_octree_traversal(root, ray, center, octrees); // create triangle list LinkedList<Octree>::Cell<Octree>* tmp = octrees->start; while(tmp != NULL) { for(unsigned int i = 0; i < tmp->data->count; i++) { if(!faces->Contains(tmp->data->triangles[i])) faces->InsertToEnd(tmp->data->triangles[i]); } tmp = tmp->next; } //delete octrees; // bez prealokovania return faces; }
void testSize(ostream & os){ printSubheader("SIZE",os); stringstream sizeStr; LinkedList<string> ll; TESTM(ll.IsEmpty(),"Expected ll to be empty"); sizeStr << ll.GetSize(); TESTM(ll.GetSize() == 0,"Expected: 0\nActual: " << sizeStr << "\n"); ll.Insert("Buh!",NULL); sizeStr << ll.GetSize(); TESTM(ll.GetSize()==1,"Expected: 0\nActual: " << sizeStr << "\n"); TESTM(!ll.IsEmpty(),"Expected ll not to be empty"); ll.Insert("Buh!",NULL); sizeStr << ll.GetSize(); TESTM(ll.GetSize()==2,"Expected: 2\nActual: " << sizeStr << "\n"); ll.Insert("Muh!",NULL); ll.Insert("Buh!",NULL); ll.Insert("Juh!",NULL); ll.Clear(); sizeStr << ll.GetSize(); TESTM(ll.GetSize() == 0,"Expected: 0\nActual: " << sizeStr << "\n"); }
void KeyboardHandler (unsigned char cKey, int iX, int iY) // keyboard input handling function { switch (cKey) { case 'p' : case 'P' : bPause = !bPause ; break ; #ifdef _DEBUG case 'm' : // toggle filling case 'M' : ToggleFilling(!bFilling) ; break ; case 'n' : // toggle lighting case 'N' : ToggleLighting(!bLighting) ; break ; #endif case 'i' : case 'I' : InitCamera(10) ; break ; case 'a' : case 'A' : bAutofire = !bAutofire ; break ; case ' ' : if (!bExplode && !bPause) FireShot(&Player, pPlayerShots) ; break ; case 'w' : case 'W' : fCameraAngle[0] += 10 ; break ; case 'x' : case 'X' : fCameraAngle[0] -= 10 ; break ; case 's' : case 'S' : fCameraAngle[2] += 10 ; break ; case 'd' : case 'D' : fCameraAngle[2] -= 10 ; break ; case 'r' : case 'R' : iScore = 0 ; bExplode = !bExplode ; iCount = 0 ; break ; case 'c' : case 'C' : bRotate = !bRotate ; break ; case 'q' : // quit program case 'Q' : ClearEntitys(pPlayerShots) ; ClearEntitys(pEnemyShots) ; ClearEntitys(pStars) ; ClearEntitys(pPlanets) ; Particles.Clear(true) ; exit(0) ; break ; } }
void HoldemRules::DetermineWinners() { //-------------------------------------------- // Calculate best combinations for all players //Debug("DetermineWinners 1"); const LinkedList<Card*>& r_comm_cards = mrTable.GetCommunityCards(); //Debug("DetermineWinners 2"); LinkedList<Player*>& players = mrTable.GetPlayers(); //Debug("DetermineWinners 3"); for (LinkedList<Player*>::Iterator i = players.Begin(); !i.Done(); i++) { if ((*i)->IsFolded()) { Debug(String("Player [") + (*i)->Name() + "] is folded"); continue; } Debug(String("DetermineWinners 4: [") + (*i)->Name() + "]"); const LinkedList<Card*>& r_player_cards = (*i)->GetCards(); Debug("DetermineWinners 5"); Card* cards[r_player_cards.Size() + r_comm_cards.Size()]; Debug("DetermineWinners 6"); //cout << "--------------------------------------\n"; cout << '[' << (*i)->Name() << "] shows: "; int j; for (j = 0; j < r_player_cards.Size(); j++) { cards[j] = r_player_cards[j]; Debug(r_player_cards[j]->ToString() + " "); cout << r_player_cards[j]->ToString() << ' '; } cout << '\n'; Debug("--"); for (j = r_player_cards.Size(); j < r_player_cards.Size() + r_comm_cards.Size(); j++) { cards[j] = r_comm_cards[j - r_player_cards.Size()]; Debug(r_comm_cards[j - r_player_cards.Size()]->ToString() + " "); } Debug("\n"); Debug("DetermineWinners 8"); (*i)->SetHandStrength(GetHandStrength(cards, r_player_cards.Size() + r_comm_cards.Size())); Debug(String("Hand strength for [") + (*i)->Name() + "]: " + (long) (*i)->HandStrength()); Debug("DetermineWinners 9"); } //------------------------------- // Order players by hand strength LinkedList<LinkedList<Player*>* > winners; Debug("DetermineWinners 10"); int num_winners = 0; for (;;) { //while (num_winners < players.Size()) { Debug("DetermineWinners 11"); unsigned long max_strength = 0; for (LinkedList<Player*>::Iterator i = players.Begin(); !i.Done(); i++) { if ((*i)->IsFolded()) { continue; } if ((*i)->HandStrength() > max_strength) { max_strength = (*i)->HandStrength(); } } if (max_strength <= 0) { Debug(String("DetermineWinners: Thats all")); // No more winners break; } Debug(String("DetermineWinners: max_strength = ") + (long) max_strength); LinkedList<Player*>* p_w = new LinkedList<Player*>(); for (LinkedList<Player*>::Iterator i = players.Begin(); !i.Done(); i++) { if ((*i)->IsFolded()) { continue; } if ((*i)->HandStrength() == max_strength) { p_w->Add((*i)); (*i)->SetHandStrength(0); num_winners++; Debug(String("DetermineWinners: adding winner: [") + (*i)->Name() + "]"); } } Debug("DetermineWinners 111"); if (p_w->Size() > 0) { Debug("DetermineWinners 1111"); winners.Add(p_w); Debug("DetermineWinners 11111"); } } Debug("DetermineWinners 12"); //----------------------------------------------------- // Iterate ower winners and add wins to player balances for (LinkedList<LinkedList<Player*>* >::Iterator i = winners.Begin(); !i.Done(); i++) { mrTable.GetPotManager().Win(*(*i)); delete (*i); } winners.Clear(); }