int btree_find_test(const int argc, const char *const *const argv) { scoped_test_enabler ste(argc, argv); log4cxx::Logger::getRootLogger()->setLevel(coherent::log::log_TRACE); util::aio_context ctx(4); util::async_file f(ctx, "btree_btree_test.btree"); completion c1, c2, c3; test_create_callback tcc(c1); btree_creator bc; bc.submit_create_btree<int, int>(tcc, f, 1024*1024, 0, 64); c1.wait(); LOG(INFO, "B-tree created on disk."); sleep(1); test_init_callback tic(c2); btree<uint64_t, uint64_t> b(tic, f, 0); c2.wait(); LOG(INFO, "B-tree loaded."); LOG(INFO, "metadata: " << " page_size=" << b.impl->m.page_size ); sleep(1); test_find_callback tfc(c3); b.submit_find(tfc, 0); c3.wait(); LOG(INFO, "Find performed."); return 0; }
void iDlg_CreatInfo::DoCompose(const iRect& clRect) { iRect rc(clRect); // title gTextComposer.TextOut(dlgfc_hdr, gApp.Surface(),rc.point(),gTextMgr[m_cGroup.Type()*3+TRID_CREATURE_PEASANT_F2], iRect(rc.x,rc.y,rc.w,15),AlignCenter); rc.y+=15; // icon BlitIcon(gApp.Surface(),PDGG_MINIMON+m_cGroup.Type(),iRect(rc.x,rc.y,rc.w,45)); rc.y+=45; // Perks if (CREAT_DESC[m_cGroup.Type()].perks != CPERK_NONE) rc.y+=15; // props iRect trc(rc.x,rc.y,90,12); iTextComposer::FontConfig fc(iTextComposer::FS_SMALL, RGB16(192,192,255)); gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_ATTACK])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DEFENCE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SHOTS])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DAMAGE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_HEALTH])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SPEED])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_MORALE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_LUCK])+_T(" :"),trc,AlignTopRight); trc.y+=10; trc = iRect(rc.x+95,rc.y,rc.w-105,12); iTextComposer::FontConfig tfc(iTextComposer::FS_SMALL, RGB16(255,220,192)); iStringT tout; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].attack, CREAT_DESC[m_cGroup.Type()].attack+m_furtSkills.Value(FSK_ATTACK)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].defence, CREAT_DESC[m_cGroup.Type()].defence+m_furtSkills.Value(FSK_DEFENCE)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; if (CREAT_DESC[m_cGroup.Type()].shots) tout.Setf(_T("%d"),CREAT_DESC[m_cGroup.Type()].shots); else tout.Setf(_T("-")); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d - %d"),CREAT_DESC[m_cGroup.Type()].damage_min,CREAT_DESC[m_cGroup.Type()].damage_max); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].hits, CREAT_DESC[m_cGroup.Type()].hits+m_furtSkills.Value(FSK_HITS)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].speed, CREAT_DESC[m_cGroup.Type()].speed+m_furtSkills.Value(FSK_SPEED)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; sint32 morale = (CREAT_DESC[m_cGroup.Type()].perks&CPERK_UNDEAD)?0:(m_furtSkills.Value(FSK_MORALE)+m_moraleMod); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(morale,true),trc,AlignTopLeft); trc.y+=10; gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(m_furtSkills.Value(FSK_LUCK),true),trc,AlignTopLeft); trc.y+=10; }
bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card) { TargetChooserFactory tfc(observer); TargetChooser * hintTc = NULL; for(unsigned int i = 0; i < hints.size();i++) { if (hints[i]->mCombatAttackTip.size()) { hintTc = tfc.createTargetChooser(hints[i]->mCombatAttackTip,card); if(hintTc && hintTc->canTarget(card,true)) { SAFE_DELETE(hintTc); return true; } SAFE_DELETE(hintTc); } } return false; }
void CTTypes::RunTestCaseL(TInt aCurTestCase) { switch(aCurTestCase) { case 1: { __UHEAP_MARK; TestRgb tr1(0,0,0, this); TestRgb tr2(100,100,100, this); TestRgb tr3(10,20,30, this); TestRgb tr4(110,160,210, this); TestRgb tr5(255,255,255, this); INFO_PRINTF1(_L("TRgb")); tr1.Test(); tr2.Test(); tr3.Test(); tr4.Test(); tr5.Test(); ((CTTypesStep*)iStep)->CloseTMSGraphicsStep(); __UHEAP_MARKEND; } break; case 2: { INFO_PRINTF1(_L("TTypeface")); TestTypeface ttf1(_L(""), 0, this); TestTypeface ttf2(_L("Font name"), 1, this); TestTypeface ttf3(_L("Font name"), 2, this); TestTypeface ttf4(_L("Font name"), 3, this); TestTypeface ttf5(_L("Font name"), 4, this); TestTypeface ttf6(_L("Font name"), 5, this); TestTypeface ttf7(_L("Font name"), 6, this); TestTypeface ttf8(_L("Another font name"), 7, this); ttf1.Test(); ttf2.Test(); ttf3.Test(); ttf4.Test(); ttf5.Test(); ttf6.Test(); ttf7.Test(); ttf8.Test(); } break; case 3: { TestMargins tm1(0,0,0,0, this); TestMargins tm2(10,20,30,40, this); TestMargins tm3(-10,-20,-30,-40, this); INFO_PRINTF1(_L("TMargins")); tm1.Test(); tm2.Test(); tm3.Test(); } break; case 4: { TestPageSpec tps1(TPageSpec::EPortrait,TSize(0,0), this); TestPageSpec tps2(TPageSpec::ELandscape,TSize(0,0), this); TestPageSpec tps3(TPageSpec::EPortrait,TSize(10,-5), this); TestPageSpec tps4(TPageSpec::ELandscape,TSize(15,-20), this); TestPageSpec tps5(TPageSpec::EPortrait,TSize(1000,1500), this); TestPageSpec tps6(TPageSpec::ELandscape,TSize(2000,500), this); INFO_PRINTF1(_L("TPageSpec")); tps1.Test(); tps2.Test(); tps3.Test(); tps4.Test(); tps5.Test(); tps6.Test(); } break; case 5: { INFO_PRINTF1(_L("FontEffect")); ((CTTypesStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-0002")); TestFontEffect te(this); ((CTTypesStep*)iStep)->RecordTestResultL(); te.Test(); } break; case 6: { INFO_PRINTF1(_L("TFontSyle")); TestTFontStyle ts(this); ts.Test(); } break; case 7: { TTypeface typeface; typeface.iName=_L("Font name"); TFontStyle fontstyle; TestFontSpec tfspec(typeface,200,fontstyle, this); INFO_PRINTF1(_L("TFontSpec")); tfspec.Test(); } break; case 8: { /* TestLine tl1(TPoint(10,10),TPoint(90,90), this); TestLine tl2(TPoint(100,150),TPoint(50,-50), this); TestLine tl3(TPoint(-50,50),TPoint(60,-40), this); TestLine tl4(TPoint(-100,0),TPoint(0,200), this); TestLine tl5(TPoint(150,-50),TPoint(50,75), this); TestLine tl6(TPoint(0,-100),TPoint(-50,-150), this); TestLine tl7(TPoint(-1000,-1000),TPoint(1000,1000), this); TestLine tl8(TPoint(1000,-1000),TPoint(-1000,1000), this); TestLine tl9(TPoint(500,-1000),TPoint(-500,1000), this); TestLine tl10(TPoint(-500,-1000),TPoint(500,1000), this); TestLine tl11(TPoint(1000,-500),TPoint(-1000,500), this); TestLine tl12(TPoint(1000,500),TPoint(-1000,-500), this); INFO_PRINTF1(_L("TLinearDDA")); tl1.Test(); tl2.Test(); tl3.Test(); tl4.Test(); tl5.Test(); tl6.Test(); tl7.Test(); tl8.Test(); tl9.Test(); tl10.Test(); tl11.Test(); tl12.Test(); */ INFO_PRINTF1(_L("TLinearDDA is only for Graphics team. Removed.")); } break; case 9: { INFO_PRINTF1(_L("CTypefaceStore")); TestTFStore ttfs(this); ttfs.Test(); } break; case 10: { INFO_PRINTF1(_L("CFontCache")); TestFontCache tfc(this); tfc.Test(); } break; case 11: { /* INFO_PRINTF1(_L("CScaleCropPicture")); TestPicture tp(this); tp.Test(); */ INFO_PRINTF1(_L("CScaleCropPicture is only for Graphics team. Removed.")); } break; case 12: { /* INFO_PRINTF1(_L("CPalette")); TestPalette tpal(this); tpal.Test(); */ INFO_PRINTF1(_L("CPalette is only for Graphics team. Removed.")); } break; case 13: { INFO_PRINTF1(_L("TDisplayModeUtils")); TestDisplayModeUtils tdmu(this); tdmu.Test(); } break; case 14: ((CTTypesStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-GDI-0001")); ((CTTypesStep*)iStep)->RecordTestResultL(); ((CTTypesStep*)iStep)->CloseTMSGraphicsStep(); TestComplete(); break; } }
//if it's not part of a combo or there is more to gather, then return false bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerBaka * Ai) { TargetChooserFactory tfc(observer); TargetChooser * hintTc = NULL; bool gotCombo = false; int comboPartsHold = 0; int comboPartsUntil = 0; int comboPartsRestriction = 0; for(unsigned int i = 0; i < hints.size();i++) { comboPartsHold = 0; comboPartsUntil = 0; comboPartsRestriction = 0; if(gotCombo) return gotCombo;//because more then one might be possible at any time. if (hints[i]->hold.size()) { for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++) { hintTc = tfc.createTargetChooser(hints[i]->hold[hPart],card); int TcCheck = hintTc->countValidTargets(); if(hintTc && TcCheck >= hintTc->maxtargets) { comboPartsHold +=1; } SAFE_DELETE(hintTc); } } if (hints[i]->until.size()) { for(unsigned int hPart = 0; hPart < hints[i]->until.size(); hPart++) { hintTc = tfc.createTargetChooser(hints[i]->until[hPart],card); int TcCheck = hintTc->countValidTargets(); if(hintTc && TcCheck >= hintTc->maxtargets) { comboPartsUntil +=1; } SAFE_DELETE(hintTc); } } if (hints[i]->restrict.size()) { for(unsigned int hPart = 0; hPart < hints[i]->restrict.size(); hPart++) { AbilityFactory af(observer); int checkCond = af.parseCastRestrictions(card,card->controller(),hints[i]->restrict[hPart]); if(checkCond >= 1) { comboPartsRestriction +=1; } } } if( comboPartsUntil >= int(hints[i]->until.size()) && comboPartsHold >= int(hints[i]->hold.size()) && comboPartsRestriction >= int(hints[i]->restrict.size()) && hints[i]->combos.size() ) { ManaCost * needed = ManaCost::parseManaCost(hints[i]->manaNeeded, NULL, card); if(Ai->canPayManaCost(card,needed).size()||!needed->getConvertedCost()) { gotCombo = true; Ai->comboHint = hints[i];//set the combo we are doing. } SAFE_DELETE(needed); } } return gotCombo; }
bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card) { TargetChooserFactory tfc(observer); TargetChooser * hintTc = NULL; bool forCombo = false; for(unsigned int i = 0; i < hints.size();i++) { if (hints[i]->combos.size()) { //time to find the parts and condiations of the combo. string part = ""; if(!hints[i]->partOfCombo.size() && hints[i]->combos.size()) { for(unsigned int cPart = 0; cPart < hints[i]->combos.size(); cPart++) { //here we disect the different parts of a given combo part = hints[i]->combos[cPart]; hints[i]->partOfCombo = split(part,'^'); for(unsigned int dPart = 0; dPart < hints[i]->partOfCombo.size(); dPart++) { vector<string>asTc; asTc = parseBetween(hints[i]->partOfCombo[dPart],"hold(",")"); if(asTc.size()) { hints[i]->hold.push_back(asTc[1]); asTc.clear(); } asTc = parseBetween(hints[i]->partOfCombo[dPart],"until(",")"); if(asTc.size()) { hints[i]->until.push_back(asTc[1]); asTc.clear(); } asTc = parseBetween(hints[i]->partOfCombo[dPart],"restriction{","}"); if(asTc.size()) { hints[i]->restrict.push_back(asTc[1]); asTc.clear(); } asTc = parseBetween(hints[i]->partOfCombo[dPart],"cast(",")"); if(asTc.size()) { hints[i]->cardTargets[asTc[1]] = parseBetween(hints[i]->partOfCombo[dPart],"targeting(",")")[1]; } asTc = parseBetween(hints[i]->partOfCombo[dPart],"totalmananeeded(",")"); if(asTc.size()) { hints[i]->manaNeeded = asTc[1]; asTc.clear(); } } } }//we collect the peices of a combo on first run. for(unsigned int hPart = 0; hPart < hints[i]->hold.size(); hPart++) { hintTc = tfc.createTargetChooser(hints[i]->hold[hPart],card); if(hintTc && hintTc->canTarget(card,true) && hintTc->countValidTargets() <= hintTc->maxtargets) { forCombo = true; } SAFE_DELETE(hintTc); } } } return forCombo;//return forCombo that way all hints that are combos are predisected. }