void ImageRenderer::render(QPainter *p, bool renderInternal) const { getImage()->render(p, getObjectState(), getState(), getMovmentState()); if (renderInternal) { this->renderInternal(p); } }
// Process one level of the word data. // N.B. The length words are updated without any locking. This is safe // because all length words are initially chain entries and a chain entry // can be replaced by another chain entry, a forwarding pointer or a normal // length word. Forwarding pointers and normal length words are only ever // set once. There is a small chance that we could lose some sharing as a // result of a race condition if a thread defers an object because it // contains a pointer with a chain entry and later sees an otherwise // equal object where another thread has replaced the chain with a // normal address, adds it to the list for immediate processing and // so never compares the two. void SortVector::wordDataTask(GCTaskId*, void *a, void *) { SortVector *s = (SortVector*)a; // Partition the objects between those that have pointers to objects that are // still to be processed and those that have been processed. if (s->baseObject.objList == ENDOFLIST) return; PolyObject *h = s->baseObject.objList; s->baseObject.objList = ENDOFLIST; s->baseObject.objCount = 0; POLYUNSIGNED words = OBJ_OBJECT_LENGTH(s->lengthWord); s->carryOver = 0; for (unsigned i = 0; i < 256; i++) { // Clear the entries in the hash table but not the sharing count. s->processObjects[i].objList = ENDOFLIST; s->processObjects[i].objCount = 0; } while (h != ENDOFLIST) { PolyObject *next = h->GetForwardingPtr(); bool deferred = false; for (POLYUNSIGNED i = 0; i < words; i++) { PolyWord w = h->Get(i); if (w.IsDataPtr()) { PolyObject *p = w.AsObjPtr(); objectState state = getObjectState(p); if (state == FORWARDED) { // Update the addresses of objects that have been merged h->Set(i, p->GetForwardingPtr()); s->carryOver++; break; } else if (state == CHAINED) { // If it is still to be shared leave it deferred = true; break; // from the loop } } } if (deferred) { // We can't do it yet: add it back to the list h->SetForwardingPtr(s->baseObject.objList); s->baseObject.objList = h; s->baseObject.objCount++; } else { // Add it to the hash table. unsigned char hash = 0; for (POLYUNSIGNED i = 0; i < words*sizeof(PolyWord); i++) hash += h->AsBytePtr()[i]; h->SetForwardingPtr(s->processObjects[hash].objList); s->processObjects[hash].objList = h; s->processObjects[hash].objCount++; } h = next; } s->SortData(); }
void TransfersSyncronizer::load(std::istream& is) { m_sync.load(is); StdInputStream inputStream(is); CryptoNote::BinaryInputStreamSerializer s(inputStream); uint32_t version = 0; s(version, "version"); if (version > TRANSFERS_STORAGE_ARCHIVE_VERSION) { throw std::runtime_error("TransfersSyncronizer version mismatch"); } struct ConsumerState { PublicKey viewKey; std::string state; std::vector<std::pair<AccountPublicAddress, std::string>> subscriptionStates; }; std::vector<ConsumerState> updatedStates; try { size_t subscriptionCount = 0; s.beginArray(subscriptionCount, "consumers"); while (subscriptionCount--) { s.beginObject(""); PublicKey viewKey; s(viewKey, "view_key"); std::string blob; s(blob, "state"); auto subIter = m_consumers.find(viewKey); if (subIter != m_consumers.end()) { auto consumerState = m_sync.getConsumerState(subIter->second.get()); assert(consumerState); { // store previous state auto prevConsumerState = getObjectState(*consumerState); // load consumer state setObjectState(*consumerState, blob); updatedStates.push_back(ConsumerState{ viewKey, std::move(prevConsumerState) }); } // load subscriptions size_t subCount = 0; s.beginArray(subCount, "subscriptions"); while (subCount--) { s.beginObject(""); AccountPublicAddress acc; std::string state; s(acc, "address"); s(state, "state"); auto sub = subIter->second->getSubscription(acc); if (sub != nullptr) { auto prevState = getObjectState(sub->getContainer()); setObjectState(sub->getContainer(), state); updatedStates.back().subscriptionStates.push_back(std::make_pair(acc, prevState)); } else { m_logger(Logging::DEBUGGING) << "Subscription not found: " << m_currency.accountAddressAsString(acc); } s.endObject(); } s.endArray(); } else { m_logger(Logging::DEBUGGING) << "Consumer not found: " << viewKey; } s.endObject(); } s.endArray(); } catch (...) { // rollback state for (const auto& consumerState : updatedStates) { auto consumer = m_consumers.find(consumerState.viewKey)->second.get(); setObjectState(*m_sync.getConsumerState(consumer), consumerState.state); for (const auto& sub : consumerState.subscriptionStates) { setObjectState(consumer->getSubscription(sub.first)->getContainer(), sub.second); } } throw; } }
void FullpipeEngine::updateMap(PreloadItem *pre) { switch (pre->sceneId) { case SC_1: updateMapPiece(PIC_MAP_S01, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_P01, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_A13, 1); break; case SC_2: updateMapPiece(PIC_MAP_S02, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_P01, 1); break; case SC_3: updateMapPiece(PIC_MAP_S03, 1); break; case SC_4: updateMapPiece(PIC_MAP_S04, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_P04, 1); break; case SC_5: updateMapPiece(PIC_MAP_S05, 1); if (pre->param == TrubaLeft) { updateMapPiece(PIC_MAP_P04, 1); } if (pre->param == TrubaUp) { updateMapPiece(PIC_MAP_P05, 1); updateMapPiece(PIC_MAP_A11, 1); } break; case SC_6: updateMapPiece(PIC_MAP_S06, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_A12, 1); break; case SC_7: updateMapPiece(PIC_MAP_S07, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_P18, 1); break; case SC_8: updateMapPiece(PIC_MAP_S08, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_P11, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_P18, 1); return; case SC_9: updateMapPiece(PIC_MAP_S09, 1); if (pre->param == TrubaDown) updateMapPiece(PIC_MAP_P11, 1); return; case SC_10: updateMapPiece(PIC_MAP_S10, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_P02, 1); break; case SC_11: updateMapPiece(PIC_MAP_S11, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_P02, 1); break; case SC_12: updateMapPiece(PIC_MAP_S12, 1); break; case SC_13: updateMapPiece(PIC_MAP_S13, 1); if (pre->param == TrubaUp) { updateMapPiece(PIC_MAP_P06, 1); updateMapPiece(PIC_MAP_A10, 1); } break; case SC_14: updateMapPiece(PIC_MAP_S14, 1); break; case SC_15: updateMapPiece(PIC_MAP_S15, 1); if (pre->param == TrubaUp) { updateMapPiece(PIC_MAP_P08, 1); updateMapPiece(PIC_MAP_A14, 1); } break; case SC_16: updateMapPiece(PIC_MAP_S16, 1); break; case SC_17: updateMapPiece(PIC_MAP_S17, 1); break; case SC_18: updateMapPiece(PIC_MAP_S1819, 1); if (pre->param == PIC_SC18_RTRUBA) updateMapPiece(PIC_MAP_P14, 1); break; case SC_19: updateMapPiece(PIC_MAP_S1819, 1); if (pre->param == PIC_SC19_RTRUBA3) { updateMapPiece(PIC_MAP_P15, 1); updateMapPiece(PIC_MAP_A09, 1); } break; case SC_20: updateMapPiece(PIC_MAP_S20, 1); break; case SC_21: updateMapPiece(PIC_MAP_S21, 1); if (pre->param == TrubaLeft) { updateMapPiece(PIC_MAP_P15, 1); updateMapPiece(PIC_MAP_A09, 1); } if (pre->param == TrubaDown) updateMapPiece(PIC_MAP_A08, 1); break; case SC_22: updateMapPiece(PIC_MAP_S22, 1); break; case SC_23: if (getObjectState(sO_UpperHatch_23) == getObjectEnumState(sO_UpperHatch_23, sO_Opened)) { updateMapPiece(PIC_MAP_S23_1, 0); updateMapPiece(PIC_MAP_S23_2, 1); updateMapPiece(PIC_MAP_P07, 1); } else { updateMapPiece(PIC_MAP_S23_1, 1); updateMapPiece(PIC_MAP_S23_2, 0); } break; case SC_24: updateMapPiece(PIC_MAP_S24, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_A08, 1); if (pre->param == TrubaDown) { updateMapPiece(PIC_MAP_P13, 1); updateMapPiece(PIC_MAP_A07, 1); } break; case SC_25: updateMapPiece(PIC_MAP_S25, 1); break; case SC_26: updateMapPiece(PIC_MAP_S26, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_A06, 1); if (pre->param == TrubaUp) { updateMapPiece(PIC_MAP_P13, 1); updateMapPiece(PIC_MAP_A07, 1); } break; case SC_27: updateMapPiece(PIC_MAP_S27, 1); break; case SC_28: updateMapPiece(PIC_MAP_S28, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_A06, 1); break; case SC_29: updateMapPiece(PIC_MAP_S29, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_A05, 1); break; case SC_30: updateMapPiece(PIC_MAP_S30, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_P09, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_A04, 1); break; case SC_31: updateMapPiece(PIC_MAP_S31_2, 1); if (getObjectState(sO_Cactus) == getObjectEnumState(sO_Cactus, sO_HasGrown)) updateMapPiece(PIC_MAP_S31_1, 1); if (pre->param == TrubaRight) updateMapPiece(PIC_MAP_P09, 1); break; case SC_32: updateMapPiece(PIC_MAP_S32_2, 1); if (getObjectState(sO_Cactus) == getObjectEnumState(sO_Cactus, sO_HasGrown)) updateMapPiece(PIC_MAP_S32_1, 1); break; case SC_33: updateMapPiece(PIC_MAP_S33, 1); break; case SC_34: updateMapPiece(PIC_MAP_S34, 1); if (pre->param == TrubaUp) updateMapPiece(PIC_MAP_A03, 1); break; case SC_35: updateMapPiece(PIC_MAP_S35, 1); if (pre->param == TrubaLeft) updateMapPiece(PIC_MAP_A02, 1); if (pre->param == TrubaDown) updateMapPiece(PIC_MAP_A03, 1); break; case SC_36: updateMapPiece(PIC_MAP_S36, 1); break; case SC_37: updateMapPiece(PIC_MAP_S37, 1); updateMapPiece(PIC_MAP_A01, 1); break; case SC_38: updateMapPiece(PIC_MAP_S38, 1); switch (pre->preloadId1) { case SC_15: updateMapPiece(PIC_MAP_P16, 1); break; case SC_1: updateMapPiece(PIC_MAP_P10, 1); break; case SC_10: updateMapPiece(PIC_MAP_P17, 1); break; case SC_19: updateMapPiece(PIC_MAP_P12, 1); break; } break; } }