//--------------------------------------------------------------------------- void __fastcall TSettingsEditDlg::CopyButtonClick( TObject */*Sender*/ ) { getDetails(); // save what is set already int offset = SectionsList->ItemIndex; if ( offset > 0 && !currSectionOnly) { std::string Value = "new section"; if ( enquireDialog( this, "Please give a name for the new section", Value ) ) { getDetails(); // save old section if ( bundle->dupSection( Value ) ) { bundle->openSection( Value ); showSections(); showDetails(); } else { MinosParameters::getMinosParameters() ->mshowMessage( "Section already exists", this ); } } } }
// Entry point for a search. virtual shared_ptr<Cursor> newCursor(const BSONObj& query, const BSONObj& order, int numWanted) const { vector<QueryGeometry> regions; double maxDistance = DBL_MAX; bool isNear = false; bool isIntersect = false; // Go through the fields that we index, and for each geo one, make a QueryGeometry // object for the S2Cursor class to do intersection testing/cover generating with. for (size_t i = 0; i < _fields.size(); ++i) { const IndexedField &field = _fields[i]; if (IndexedField::GEO != field.type) { continue; } BSONElement e = query.getFieldDotted(field.name); if (e.eoo()) { continue; } if (!e.isABSONObj()) { continue; } BSONObj obj = e.Obj(); QueryGeometry geoQueryField(field.name); if (parseLegacy(obj, &geoQueryField, &isNear, &isIntersect, &maxDistance)) { regions.push_back(geoQueryField); } else if (parseQuery(obj, &geoQueryField, &isNear, &isIntersect, &maxDistance)) { regions.push_back(geoQueryField); } else { uasserted(16535, "can't parse query for *2d geo search: " + obj.toString()); } } if (isNear && isIntersect ) { uasserted(16474, "Can't do both near and intersect, query: " + query.toString()); } // I copied this from 2d.cpp. Guard against perversion. if (numWanted < 0) numWanted *= -1; if (0 == numWanted) numWanted = INT_MAX; BSONObjBuilder geoFieldsToNuke; for (size_t i = 0; i < _fields.size(); ++i) { const IndexedField &field = _fields[i]; if (IndexedField::GEO != field.type) { continue; } geoFieldsToNuke.append(field.name, ""); } // false means we want to filter OUT geoFieldsToNuke, not filter to include only that. BSONObj filteredQuery = query.filterFieldsUndotted(geoFieldsToNuke.obj(), false); if (isNear) { S2NearCursor *cursor = new S2NearCursor(keyPattern(), getDetails(), filteredQuery, regions, _params, numWanted, maxDistance); return shared_ptr<Cursor>(cursor); } else { // Default to intersect. S2Cursor *cursor = new S2Cursor(keyPattern(), getDetails(), filteredQuery, regions, _params, numWanted); return shared_ptr<Cursor>(cursor); } }
HRESULT CKhParser::fillHomonyms(BSTR response) { wchar_t* str(response); int i = 0; const wchar_t* foundStem = L"FOUND STEM:"; homonyms.clear(); hom homonym; wchar_t* tmp = wcsstr(str, foundStem); while (tmp != 0) { tmp = tmp + 12; // grammatics wchar_t* form = getDetails(tmp, L' '); // affixes wchar_t* affixes = getDetails(wcschr(tmp, L' '), 0xA); tmp = wcschr(tmp, 0xA); if (tmp == 0) continue; tmp = wcschr(tmp, L' '); if (tmp == 0) continue; // headword wchar_t* headword = getSubstr(tmp, L' '); tmp = wcschr(tmp, 0x201B); if (tmp == 0) continue; tmp = tmp + 1; // meaning wchar_t* meaning = getSubstr(tmp, 0x2019); tmp = wcschr(tmp, 0x2019) + 1; wchar_t* stem = getSubstr(tmp, 0xA); if (stem[0] != 0x0) { for (i = (int)wcslen(stem) - 1; i >= 0; i--) if (stem[i] == L' ') stem[i] = 0x0; } if (stem[0] != 0x0) homonym.khak = std::wstring(stem); else homonym.khak = std::wstring(headword); homonym.khak.append(affixes); homonym.rus = std::wstring(meaning).append(form); homonyms.push_back(homonym); tmp = tmp = wcsstr(tmp, foundStem); } return S_OK; }
void FightsManager::fightLoop() { LureEngine &engine = LureEngine::getReference(); Resources &res = Resources::getReference(); Game &game = Game::getReference(); Room &room = Room::getReference(); FighterRecord &playerFight = getDetails(PLAYER_ID); uint32 timerVal = g_system->getMillis(); // Loop for the duration of the battle while (!engine.shouldQuit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) { checkEvents(); if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) { timerVal = g_system->getMillis(); game.tick(); room.update(); res.delayList().tick(); } Screen::getReference().update(); game.debugger().onFrame(); g_system->delayMillis(10); } }
int InputFilterWithDelta::getDelta( filterspec_id_t id, InputDetails &delta ) const { InputDetails const &details = getDetails( id ); InputDetails const &oldDetails = getOldDetails( id ); if ( details.type == oldDetails.type ) { delta.type = details.type; delta.x = details.x - oldDetails.x; delta.y = details.y - oldDetails.y; } else if ( details.type != INPUT_TYPE_FAIL && oldDetails.type == INPUT_TYPE_FAIL ) { delta.type = details.type; delta.x = details.x; delta.y = details.y; return 1; } else if ( details.type == INPUT_TYPE_FAIL && oldDetails.type != INPUT_TYPE_FAIL ) { delta.type = oldDetails.type; delta.x = -oldDetails.x; delta.y = -oldDetails.y; return -1; } else if ( details.type == INPUT_TYPE_FAIL && oldDetails.type == INPUT_TYPE_FAIL ) { delta.type = INPUT_TYPE_FAIL; delta.x = delta.y = 0; } return 0; }
void FightsManager::enemyKilled() { Resources &res = Resources::getReference(); Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID); FighterRecord &playerRec = getDetails(PLAYER_ID); playerHotspot->setTickProc(PLAYER_TICK_PROC_ID); playerRec.fwhits = GENERAL_MAGIC_ID; playerHotspot->resource()->colorOffset = 128; playerHotspot->setSize(32, 48); playerHotspot->resource()->width = 32; playerHotspot->resource()->height = 48; playerHotspot->setAnimationIndex(PLAYER_ANIM_INDEX); playerHotspot->setPosition(playerHotspot->x(), playerHotspot->y() + 5); playerHotspot->setDirection(LEFT); if (playerHotspot->roomNumber() == 6) { Dialog::show(0xc9f); HotspotData *axeHotspot = res.getHotspot(0x2738); axeHotspot->roomNumber = PLAYER_ID; axeHotspot->flags |= HOTSPOTFLAG_FOUND; // Prevent the weapon animation being drawn axeHotspot = res.getHotspot(0x440); axeHotspot->layer = 0; } }
// Storable Interface Methods void FollowUpRecord::getAttributesAndValues(QMap<QString, QVariant> & attributesAndValues) const{ Record::getAttributesAndValues(attributesAndValues); attributesAndValues.insert(QString("Status"), QVariant(getStatusString())); attributesAndValues.insert(QString("DueDateAndTime"), QVariant(QDateTime(getDueDateTime()))); attributesAndValues.insert(QString("Details"), QVariant(QString(getDetails()))); attributesAndValues.insert(QString("ConsultationRecordID"), QVariant(getConsultationRecordId())); }
void __fastcall TContestEntryDetails::OKButtonClick( TObject * /*Sender*/ ) { // make sure we have the minimum required information if (ProtectedOption->Checked && ! contest->isProtected()) { if (!mShowYesNoMessage(this, "This contest will be marked as protected.\r\n" "This is a permanent change that may be temporarily overridden.\r\n" "Please confirm this change by pressing \"Ok\"." )) { return; } } TWinControl *nextD = getDetails( ); if ( nextD ) { nextD->SetFocus(); } else { if (saveContestOK) { bool temp = contest->isProtectedSuppressed(); contest->setProtectedSuppressed(true); contest->commonSave( false ); contest->setProtectedSuppressed(temp); } *inputcontest = *contest; ModalResult = mrOk; } }
void __fastcall TContestEntryDetails::FormShow( TObject * /*Sender*/ ) { // ScaleBy( TContestApp::getContestApp() ->sysfont->Size, Font->Size ); // Font->Assign( TContestApp::getContestApp() ->sysfont ); QTHBundleFrame->initialise( "QTH", &contest->QTHBundle, &contest->QTHBundleName ); StationBundleFrame->initialise( "Station", &contest->stationBundle, &contest->stationBundleName ); EntryBundleFrame->initialise( "Entry", &contest->entryBundle, &contest->entryBundleName ); ContestNameSelected->Text = contest->VHFContestName.getValue().c_str(); contest->initialiseINI(); for ( int i = 0; i < 24; i++ ) { std::string cbText = ( boost::format( "%02.2d:" ) % i ).str(); std::string hour = cbText + "00"; std::string halfhour = cbText + "30"; StartTimeCombo->Items->Add( hour.c_str() ); StartTimeCombo->Items->Add( halfhour.c_str() ); EndTimeCombo->Items->Add( hour.c_str() ); EndTimeCombo->Items->Add( halfhour.c_str() ); } TWinControl *nextD = getDetails( ); if ( nextD ) { nextD->SetFocus(); } }
void SearchQueryView::editLine() { QString textName; int lineNumber; QList<Focus> foci; getDetails( currentIndex(), textName , lineNumber, foci ); emit requestEditLine( textName, lineNumber, foci ); }
void SearchQueryView::playSound() { QString textName; int lineNumber; QList<Focus> foci; getDetails( currentIndex(), textName , lineNumber, foci ); emit requestPlaySound( textName, lineNumber ); }
void Food::description() const { cout << "商品名称: " << getName() << endl; cout << "原价: " << getUnitPrice() << endl; cout << "折扣价: " << getUnitPrice() * getDiscount() << endl; cout << "折扣系数: " << getDiscount() << endl; cout << "库存: " << getInventory() << endl; cout << "商品详情: " << endl << getDetails() << endl; }
void FightsManager::fighterAnimHandler(Hotspot &h) { FighterRecord &fighter = getDetails(h.hotspotId()); FighterRecord &opponent = getDetails(fighter.fwenemy_ad); FighterRecord &player = getDetails(PLAYER_ID); fetchFighterDistance(fighter, opponent); if (fighter.fwseq_ad) { fightHandler(h, fighter.fwseq_ad); return; } uint16 seqNum = 0; if (fighter.fwdist != FIGHT_DISTANCE) { seqNum = getFighterMove(fighter, fighter.fwnot_near); } else { uint16 offset = (fighter.fwhits * fighter.fwdef_len) + fighter.fwdefend_adds + 4; // Scan for the given sequence uint16 v = getWord(offset); while ((v != 0) && (v != player.fwseq_no)) { offset += 4; v = getWord(offset); } if (v == 0) { // No sequence match found seqNum = getFighterMove(fighter, fighter.fwattack_table); } else { v = getWord(offset + 2); seqNum = getFighterMove(fighter, fighter.fwdefend_table); if (seqNum == 0) seqNum = getFighterMove(fighter, fighter.fwattack_table); else if (seqNum == 0xff) seqNum = v; } } // Set the sequence and pass onto the fight handler fighter.fwseq_no = seqNum; fighter.fwseq_ad = getWord(FIGHT_TBL_1 + (seqNum << 1)); }
//--------------------------------------------------------------------------- void __fastcall TContestEntryDetails::EntDetailButtonClick( TObject * /*Sender*/ ) { getDetails( ); // override from the window std::auto_ptr <TEntryOptionsForm> EntryDlg( new TEntryOptionsForm( this, contest, false ) ); EntryDlg->EntryGroup->Visible = false; EntryDlg->Caption = "Entry Details"; if ( EntryDlg->ShowModal() == mrOk ) setDetails( ); }
//--------------------------------------------------------------------------- void __fastcall TContestEntryDetails::BundleOverrideButtonClick( TObject * /*Sender*/ ) { getDetails( ); // override from the window contest->setINIDetails(); setDetails( ); if ( bool( CalendarDlg ) ) { setDetails( CalendarDlg->ic ); } }
void __fastcall TSettingsEditDlg::NewSectionButtonClick( TObject */*Sender*/ ) { getDetails(); // save what is set already std::string Value = "new section"; if ( enquireDialog( this, "Please give a name for the new section", Value ) ) { bundle->newSection( Value ); bundle->openSection( Value ); showSections(); showDetails(); } }
void __fastcall TContestEntryDetails::BundleFrameBundleSectionChange( TObject *Sender) { TComboBox *cb = dynamic_cast<TComboBox *>(Sender); TSettingBundleFrame *bf = dynamic_cast<TSettingBundleFrame *>(cb->Parent); if (bf) { bf->BundleSectionChange(Sender); } getDetails( ); // override from the window contest->setINIDetails(); setDetails( ); }
void __fastcall TContestEntryDetails::StationBundleFrameBundleEditClick( TObject *Sender) { TButton *cb = dynamic_cast<TButton *>(Sender ); TSettingBundleFrame *bf = dynamic_cast<TSettingBundleFrame *>(cb->Parent); if (bf) { bf->BundleEditClick(Sender); } getDetails( ); // override from the window contest->setINIDetails(); setDetails( ); }
void FightsManager::setupSkorlFight() { Resources &res = Resources::getReference(); Hotspot *player = res.getActiveHotspot(PLAYER_ID); FighterRecord &rec = getDetails(PLAYER_ID); setupPigFight(); rec.fwenemy_ad = SKORL_FIGHTER_ID; rec.fwweapon = 0x445; rec.fwtrue_x = 282; rec.fwtrue_y = 136; player->setPosition(282, 136); player->resource()->colorOffset = 96; }
void __fastcall TContestEntryDetails::OKButtonClick( TObject * /*Sender*/ ) { // make sure we have the minimum required information if ( getDetails( ) ) { TWinControl * next = getNextFocus(); if ( next ) { next->SetFocus(); return ; } *inputcontest = *contest; ModalResult = mrOk; } }
std::vector<NVM_UINT16> Device::getLastShutdownStatus() { LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__); std::vector<NVM_UINT16> result; NVM_UINT8 lastShutdownState = getDetails().status.last_shutdown_status; if (lastShutdownState == SHUTDOWN_STATUS_UNKNOWN) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_UKNOWN); } else // can't be "Unknown" and "Known" { if (lastShutdownState & SHUTDOWN_STATUS_CLEAN) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_FW_FLUSH_COMPLETE); } if (lastShutdownState & SHUTDOWN_STATUS_PM_ADR) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_PM_ADR_COMMAND); } if (lastShutdownState & SHUTDOWN_STATUS_PM_S3) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_PM_S3); } if (lastShutdownState & SHUTDOWN_STATUS_PM_S5) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_PM_S5); } if (lastShutdownState & SHUTDOWN_STATUS_DDRT_POWER_FAIL) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_DDRT_POWER_FAIL); } if (lastShutdownState & SHUTDOWN_STATUS_PMIC_12V_POWER_FAIL) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_PMIC_12V_POWER_FAIL); } if (lastShutdownState & SHUTDOWN_STATUS_WARM_RESET) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_PM_WARM_RESET); } if (lastShutdownState & SHUTDOWN_STATUS_FORCED_THERMAL) { result.push_back(DEVICE_LAST_SHUTDOWN_STATUS_THERMAL_SHUTDOWN); } } return result; }
//============================================================================== bool ContextDefinitionManager::deserializeDefinitions(ISerializer& serializer) { // load generic definitions size_t count = 0; serializer.deserialize(count); for (size_t i = 0; i < count; i++) { std::string defName; serializer.deserialize(defName); std::string parentDefName; serializer.deserialize(parentDefName); auto pDef = getDefinition(defName.c_str()); IClassDefinitionModifier* modifier = nullptr; if (!pDef) { auto definition = registerDefinition(createGenericDefinition(defName.c_str())); modifier = definition->getDetails().getDefinitionModifier(); } size_t size = 0; serializer.deserialize(size); std::string propName; std::string typeName; uint32_t flags; for (size_t j = 0; j < size; j++) { propName.clear(); typeName.clear(); serializer.deserialize(propName); serializer.deserialize(typeName); serializer.deserialize(flags); IBasePropertyPtr property = nullptr; auto metaType = MetaType::find(typeName.c_str()); if (modifier) { bool isCollection = flags & ContextDefinitionManagerDetails::IS_COLLECTION; auto property = modifier->addProperty( propName.c_str(), metaType != nullptr ? metaType->typeId().getName() : typeName.c_str(), nullptr, isCollection); // TF_ASSERT( property ); } } } return true; }
void FightsManager::setupPigFight() { Resources &res = Resources::getReference(); Hotspot *player = res.getActiveHotspot(PLAYER_ID); player->setSkipFlag(false); player->resource()->colorOffset = 16; player->setTickProc(PLAYER_FIGHT_TICK_PROC_ID); player->setSize(48, 53); player->setAnimationIndex(PLAYER_FIGHT_ANIM_INDEX); player->resource()->width = 48; player->resource()->height = 53; player->setOccupied(false); player->setPosition(262, 94); FighterRecord &rec = getDetails(PLAYER_ID); rec.fwhits = 0; rec.fwtrue_x = 262; rec.fwtrue_y = 53; rec.fwseq_ad = FIGHT_PLAYER_INIT; rec.fwenemy_ad = PIG_ID; }
int CVICALLBACK OpenProjectConfirm (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: int i, checked; /* for (i = 0; i < projectlist.number; i++) { IsListItemChecked(panel_open,OPPANEL_TREE_ProjectList,i,&checked); if (checked) { MessagePopup("Number of Projects","checked"); operatingproject = projectlist.projects[i]; break; } }*/ GetTreeItem(panel_open,OPPANEL_TREE_ProjectList,VAL_ALL,0,0,VAL_NEXT_PLUS_SELF,VAL_SELECTED,&i); if (i == -1) { MessagePopup("打开时出错!","请选中某项后再点击打开按钮"); return -1; } if (state_open == 1) { operatingproject = projectlist.projects[i]; getDetails(&operatingproject); openproject(); } else { operatinggroupnum = i+1; openmeasuregroup(); } HidePanel (panel_open); state_open = 0; DisplayPanel (panel_main); break; } return 0; }
BSONObj ChangeLogType::toBSON() const { BSONObjBuilder builder; if (_changeId) builder.append(changeId.name(), getChangeId()); if (_server) builder.append(server.name(), getServer()); if (_shard) builder.append(shard.name(), getShard()); if (_clientAddr) builder.append(clientAddr.name(), getClientAddr()); if (_time) builder.append(time.name(), getTime()); if (_what) builder.append(what.name(), getWhat()); if (_ns) builder.append(ns.name(), getNS()); if (_details) builder.append(details.name(), getDetails()); return builder.obj(); }
void insert(int pos) { struct details *temp; temp = getDetails(); struct details *temp1=head; int agecount=0; while(temp1!=NULL){ // Checking if age slot is empty if(temp->age==temp1->age) agecount++; temp1 = temp1->next;} if(agecount>=5) { printf("Age group full\n"); return; } if(head==NULL) head = root = temp; else { if(pos==1) // Inserting Node at first Position { temp ->next = head; head = temp; } else if(pos==count()+1) //Inserting Node at last Position { root->next = temp; root = temp; } else//Inserting Anywhere else { struct details *ptr=head; for(int i=1;i<pos-1;i++) ptr = ptr->next; temp->next = ptr->next; ptr->next = temp; } } }
void __fastcall TContestEntryDetails::BundleFrameBundleEditClick( TObject *Sender) { TButton *cb = dynamic_cast<TButton *>(Sender ); TSettingBundleFrame *bf = dynamic_cast<TSettingBundleFrame *>(cb->Parent); if (bf) { bf->BundleEditClick(Sender); } getDetails( ); // override from the window contest->setINIDetails(); setDetails( ); TWinControl *next = getNextFocus(); if (next) { next->SetFocus(); } else { OKButton->SetFocus(); } }
void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) { Resources &res = Resources::getReference(); FighterRecord &fighter = getDetails(h.hotspotId()); FighterRecord &opponent = getDetails(fighter.fwenemy_ad); uint16 v1, v2; bool breakFlag = false; while (!breakFlag) { if (moveOffset == 0) { // Player is doing nothing, so check the move number moveOffset = getWord(FIGHT_PLAYER_MOVE_TABLE + (fighter.fwmove_number << 1)); debugC(ERROR_DETAILED, kLureDebugFights, "Hotspot %xh fight move=%d, new offset=%xh", h.hotspotId(), fighter.fwmove_number, moveOffset); if (moveOffset == 0) return; fighter.fwseq_no = fighter.fwmove_number; fighter.fwseq_ad = moveOffset; } uint16 moveValue = getWord(moveOffset); debugC(ERROR_DETAILED, kLureDebugFights, "Hotspot %xh script offset=%xh value=%xh", h.hotspotId(), moveOffset, moveValue); moveOffset += sizeof(uint16); if ((moveValue & 0x8000) == 0) { // Set frame to specified number h.setFrameNumber(moveValue); // Set the new fighter position int16 newX, newY; newX = h.x() + (int16)getWord(moveOffset); if (newX < 32) newX = 32; if (newX > 240) newX = 240; newY = h.y() + (int16)getWord(moveOffset + 2); h.setPosition(newX, newY); if (fighter.fwweapon != 0) { Hotspot *weaponHotspot = res.getActiveHotspot(fighter.fwweapon); assert(weaponHotspot); uint16 newFrameNumber = getWord(moveOffset + 4); int16 xChange = (int16)getWord(moveOffset + 6); int16 yChange = (int16)getWord(moveOffset + 8); weaponHotspot->setFrameNumber(newFrameNumber); weaponHotspot->setPosition(h.x() + xChange, h.y() + yChange); } moveOffset += 5 * sizeof(uint16); fighter.fwseq_ad = moveOffset; return; } switch (moveValue) { case 0xFFFA: // Walk left if ((fighter.fwmove_number == 5) || (fighter.fwmove_number == 10)) { if (h.x() < 32) { breakFlag = true; } else { h.setPosition(h.x() - 4, h.y()); fighter.fwtrue_x = h.x(); if (fetchFighterDistance(fighter, opponent) < FIGHT_DISTANCE) { h.setPosition(h.x() + 4, h.y()); fighter.fwtrue_x += 4; breakFlag = true; } else { removeWeapon(fighter.fwweapon); fighter.fwtrue_x = h.x(); fighter.fwtrue_y = h.y(); uint16 frameNum = (fighter.fwwalk_roll == 7) ? 0 : fighter.fwwalk_roll + 1; fighter.fwwalk_roll = frameNum; fighter.fwseq_ad = moveOffset; h.setFrameNumber(frameNum); return; } } } else { // Signal to start a new action moveOffset = 0; } break; case 0xFFF9: // Walk right if ((fighter.fwmove_number == 9) || (fighter.fwmove_number == 14)) { if (h.x() >= 240) { breakFlag = true; } else { removeWeapon(fighter.fwweapon); h.setPosition(h.x() + 4, h.y()); fighter.fwtrue_x = h.x(); fighter.fwtrue_y = h.y(); fighter.fwwalk_roll = (fighter.fwwalk_roll == 0) ? 7 : fighter.fwwalk_roll - 1; fighter.fwseq_ad = moveOffset; h.setFrameNumber(fighter.fwwalk_roll); return; } } else { // Signal to start a new action moveOffset = 0; } break; case 0xFFEB: // Enemy right removeWeapon(fighter.fwweapon); h.setPosition(h.x() + 4, h.y()); fighter.fwtrue_x = h.x(); if (fetchFighterDistance(fighter, opponent) < FIGHT_DISTANCE) { h.setPosition(h.x() - 4, h.y()); fighter.fwtrue_x -= 4; fighter.fwseq_ad = 0; h.setFrameNumber(8); } else { h.setFrameNumber(getWord(moveOffset)); moveOffset += sizeof(uint16); fighter.fwseq_ad = moveOffset; } return; case 0xFFFB: // End of sequence breakFlag = true; break; case 0xFFF8: // Set fight address moveOffset = getWord(moveOffset); break; case 0xFFFF: case 0xFFFE: if (moveValue == 0xffff) // Set the animation record h.setAnimation(getWord(moveOffset)); else // New set animation record h.setAnimation(getWord(fighter.fwheader_list + (getWord(moveOffset) << 1))); h.setFrameNumber(0); moveOffset += sizeof(uint16); break; case 0xFFF7: // On hold if (getWord(moveOffset) == fighter.fwmove_number) moveOffset = getWord(moveOffset + 2); else moveOffset += 2 * sizeof(uint16); break; case 0xFFF6: // Not hold if (getWord(moveOffset) == fighter.fwmove_number) moveOffset += 2 * sizeof(uint16); else moveOffset = getWord(moveOffset + 2); break; case 0xFFF4: // End sequence fighter.fwseq_no = 0; break; case 0xFFF2: // Set defend fighter.fwblocking = getWord(moveOffset); moveOffset += sizeof(uint16); break; case 0xFFF1: // If blocking v1 = getWord(moveOffset); v2 = getWord(moveOffset + 2); moveOffset += 2 * sizeof(uint16); if (v1 == opponent.fwblocking) { Sound.addSound(42); moveOffset = v2; } break; case 0xFFF0: // Check hit v1 = getWord(moveOffset); moveOffset += sizeof(uint16); if (fighter.fwdist <= FIGHT_DISTANCE) { if (h.hotspotId() == PLAYER_ID) { // Player hits opponent Sound.addSound(52); if (opponent.fwhits != 5) { opponent.fwseq_ad = v1; if (++opponent.fwhit_value != opponent.fwhit_rate) { opponent.fwhit_value = 0; if (++opponent.fwhits == 5) opponent.fwseq_ad = opponent.fwdie_seq; } } } else { // Opponent hit player Sound.addSound(37); opponent.fwseq_ad = v1; if (++opponent.fwhits == 10) { // Player has been killed fighter.fwhits = 10; opponent.fwseq_ad = FIGHT_PLAYER_DIES; Sound.addSound(36); } } } break; case 0xFFEF: // Save co-ordinates fighter.fwtrue_x = h.x(); fighter.fwtrue_y = h.y(); break; case 0xFFEE: // Restore co-ordinates h.setPosition(fighter.fwtrue_x, fighter.fwtrue_y); break; case 0xFFED: // End of game getDetails(PLAYER_ID).fwhits = GENERAL_MAGIC_ID; Game::getReference().setState(GS_RESTORE_RESTART); return; case 0xFFEC: // Enemy has been killed enemyKilled(); break; case 0xFFEA: // Fight sound Sound.addSound(getWord(moveOffset) & 0xff); moveOffset += sizeof(uint16); break; default: error("Unknown fight command %xh", moveValue); } } fighter.fwseq_no = 0; fighter.fwseq_ad = 0; if (h.hotspotId() == PLAYER_ID) _mouseFlags = 0; }
void searchCommand( NamespaceDetails* nsd , int idxNo , const BSONObj& n /*near*/ , double maxDistance , const BSONObj& search , BSONObjBuilder& result , unsigned limit ) { Timer t; log(1) << "SEARCH near:" << n << " maxDistance:" << maxDistance << " search: " << search << endl; int x,y; { BSONObjIterator i( n ); x = hash( i.next() ); y = hash( i.next() ); } int scale = (int)ceil( maxDistance / _bucketSize ); GeoHaystackSearchHopper hopper(n,maxDistance,limit,_geo); long long btreeMatches = 0; for ( int a=-scale; a<=scale; a++ ) { for ( int b=-scale; b<=scale; b++ ) { BSONObjBuilder bb; bb.append( "" , makeString( x + a , y + b ) ); for ( unsigned i=0; i<_other.size(); i++ ) { BSONElement e = search.getFieldDotted( _other[i] ); if ( e.eoo() ) bb.appendNull( "" ); else bb.appendAs( e , "" ); } BSONObj key = bb.obj(); GEOQUADDEBUG( "KEY: " << key ); set<DiskLoc> thisPass; scoped_ptr<BtreeCursor> cursor( BtreeCursor::make( nsd , idxNo , *getDetails() , key , key , true , 1 ) ); while ( cursor->ok() ) { pair<set<DiskLoc>::iterator, bool> p = thisPass.insert( cursor->currLoc() ); if ( p.second ) { hopper.got( cursor->currLoc() ); GEOQUADDEBUG( "\t" << cursor->current() ); btreeMatches++; } cursor->advance(); } } } BSONArrayBuilder arr( result.subarrayStart( "results" ) ); int num = hopper.append( arr ); arr.done(); { BSONObjBuilder b( result.subobjStart( "stats" ) ); b.append( "time" , t.millis() ); b.appendNumber( "btreeMatches" , btreeMatches ); b.append( "n" , num ); b.done(); } }
void main() { long thisThread; double TimeUsed; double totScore; double mwips; double totMwips; double total[4][10]; double timeTot[4]; int answers[4][10]; int g, i, j, t; int threads; int passThreads[4]; int count = 10; int duration = 5; char errorMsg[100]; n1 = 12*x100; n2 = 14*x100; n3 = 345*x100; n4 = 210*x100; n5 = 32*x100; n6 = 899*x100; n7 = 616*x100; n8 = 93*x100; passThreads[0] = 1; passThreads[1] = 2; passThreads[2] = 4; passThreads[3] = 8; FILE *outfile; outfile = fopen("MP-WHETS.txt","a+"); if (outfile == NULL) { printf ("Cannot open results file \n\n"); printf(" Press Enter\n"); g = getchar(); exit (0); } printf("\n"); getDetails(); local_time(); printf(" ##########################################\n"); fprintf (outfile, " #####################################################\n"); printf ("\nFrom File /proc/cpuinfo\n"); printf("%s\n", configdata[0]); printf ("\nFrom File /proc/version\n"); printf("%s\n", configdata[1]); printf("\n MP-Whetstone Benchmark %s %s\n", version, timeday); printf(" Using 1, 2, 4 and 8 Threads\n\n"); printf(" MFLOPS MFLOPS If Fixpt Cos MFLOPS Equal Exp MWIPS\n"); printf(" 1 2 MOPS MOPS MOPS 3 MOPS MOPS\n\n"); fprintf(outfile, "\n MP-Whetstone Benchmark %s %s\n", version, timeday); fprintf(outfile, " Using 1, 2, 4 and 8 Threads\n\n"); fprintf(outfile, " MWIPS MFLOPS MFLOPS MFLOPS Cos Exp Fixpt If Equal\n"); fprintf(outfile, " 1 2 3 MOPS MOPS MOPS MOPS MOPS\n\n"); do { TimeUsed=0; thisThread = 0; start_time(); for (test=1; test<9; test++) { pthread_create(&tid[thisThread], attrt, whetstones, (void *)thisThread); pthread_join(tid[thisThread], NULL); } TimeUsed = secs; count = count - 1; if (TimeUsed > 0.2) count = 0; else repeatPasses = repeatPasses * 5; } while (count > 0); if (TimeUsed > 0) repeatPasses = (int)((SPDP)(duration * repeatPasses) / TimeUsed); if (repeatPasses < 1) repeatPasses = 1; for(t=0; t<4; t++) { threads = passThreads[t]; printf("%2dT ", threads); fprintf(outfile, "%2dT ", threads); fflush(stdout); fflush(outfile); timeTot[t] = 0; TimeUsed = 0; for (test=1; test<9; test++) { totScore = 0; start_time(); for (thisThread=1; thisThread<threads+1; thisThread++) { pthread_create(&tid[thisThread], attrt, whetstones, (void *)thisThread); } for (thisThread=1; thisThread<threads+1; thisThread++) { pthread_join(tid[thisThread], NULL); } end_time(); TimeUsed = TimeUsed + secs; for (i=1; i<threads+1; i++) { totScore = totScore + score[i][test]; } printf("%7.1f", totScore); fflush(stdout); } timeTot[t] = TimeUsed; for (i=1; i<threads+1; i++) { score[i][9] = 0.0; } totMwips = 0; for (i=1; i<threads+1; i++) { mwips=(double)(repeatPasses) * (double)(x100) / (10 * timec[i][9]); score[i][9] = mwips; totMwips = totMwips + mwips; } printf("%7.1f\n", totMwips); fflush(stdout); results[t][9] = 0.0; for (j=1; j<10; j++) { total[t][j] = 0.0; for (i=1; i<threads+1; i++) { total[t][j] = total[t][j] + score[i][j]; } } sprintf(errorMsg, " All calculations produced consistent numeric results"); for (j=1; j<10; j++) { for (i=1; i<threads+1; i++) { if (results[i][j] != results[1][j]) { sprintf(errorMsg, " Numeric results incorrect"); } } } fprintf(outfile, "%7.1f%7.1f%7.1f%7.1f%6.1f%6.1f%7.1f%7.1f%7.1f\n", total[t][9], total[t][1], total[t][2], total[t][6], total[t][5], total[t][8], total[t][4], total[t][3], total[t][7]); fflush(stdout); fflush(outfile); } printf("\n Overall Seconds %6.2f 1T, %6.2f 2T, %6.2f 4T, %6.2f 8T\n\n%s\n\n", timeTot[0], timeTot[1], timeTot[2], timeTot[3], errorMsg); fprintf(outfile, "\n Overall Seconds %6.2f 1T, %6.2f 2T, %6.2f 4T, %6.2f 8T\n\n%s\n\n", timeTot[0], timeTot[1], timeTot[2], timeTot[3], errorMsg); fflush(stdout); fflush(outfile); fprintf (outfile, "\nSYSTEM INFORMATION\n\nFrom File /proc/cpuinfo\n"); fprintf (outfile, "%s \n", configdata[0]); fprintf (outfile, "\nFrom File /proc/version\n"); fprintf (outfile, "%s \n", configdata[1]); fprintf (outfile, "\n"); fflush(outfile); char moredata[1024]; printf("Type additional information to include in MP-MFLOPS.txt - Press Enter\n"); if (fgets (moredata, sizeof(moredata), stdin) != NULL) fprintf (outfile, "Additional information - %s\n", moredata); fflush(stdout); fflush(outfile); fclose(outfile); return; }