// returns true if progress was made by shortening the queue bool nsPACMan::ProcessPending() { if (mPendingQ.isEmpty()) return false; // queue during normal load, but if we are retrying a failed load then // fast fail the queries if (mInProgress || (IsLoading() && !mLoadFailureCount)) return false; RefPtr<PendingPACQuery> query(dont_AddRef(mPendingQ.popFirst())); if (mShutdown || IsLoading()) { query->Complete(NS_ERROR_NOT_AVAILABLE, EmptyCString()); return true; } nsAutoCString pacString; bool completed = false; mInProgress = true; nsAutoCString PACURI; // first we need to consider the system proxy changing the pac url if (mSystemProxySettings && NS_SUCCEEDED(mSystemProxySettings->GetPACURI(PACURI)) && !PACURI.IsEmpty() && !PACURI.Equals(mPACURISpec)) { query->UseAlternatePACFile(PACURI); LOG(("Use PAC from system settings: %s\n", PACURI.get())); completed = true; } // now try the system proxy settings for this particular url if // PAC was not specified if (!completed && mSystemProxySettings && PACURI.IsEmpty() && NS_SUCCEEDED(mSystemProxySettings-> GetProxyForURI(query->mSpec, query->mScheme, query->mHost, query->mPort, pacString))) { LOG(("Use proxy from system settings: %s\n", pacString.get())); query->Complete(NS_OK, pacString); completed = true; } // the systemproxysettings didn't complete the resolution. try via PAC if (!completed) { nsresult status = mPAC.GetProxyForURI(query->mSpec, query->mHost, pacString); LOG(("Use proxy from PAC: %s\n", pacString.get())); query->Complete(status, pacString); } mInProgress = false; return true; }
void FPacketCaptureArchive::SerializePacket(void* PacketData, uint32& PacketSize) { check(Header.PacketDataOffset.Get() != 0); check(Tell() >= Header.PacketDataOffset.Get()); uint32 PacketBufferSize = (IsLoading() ? PacketSize : 0); uint64 StartPos = Tell(); InnerArchive << PacketSize; if (IsLoading()) { if (Header.CaptureVersion >= CAPTURE_VER_PACKETCOUNT) { // Added PacketSize here, to deliberately overshoot, in case PacketDataLength is not updated in the file (possible) check(Tell() < Header.PacketDataOffset.Get() + Header.PacketDataLength.Get() + (uint32)sizeof(PacketSize) + PacketSize); } // Max 128MB packet - excessive, but this is not meant to be a perfect security check if (PacketBufferSize < PacketSize || !ensure(PacketSize <= 134217728)) { UE_LOG(OodleHandlerComponentLog, Warning, TEXT("Bad PacketSize value '%i' in loading packet capture file"), PacketSize); SetError(); return; } if (PacketSize > (InnerArchive.TotalSize() - InnerArchive.Tell())) { UE_LOG(OodleHandlerComponentLog, Warning, TEXT("PacketSize '%i' greater than remaining file data '%i'. Truncated file? ") TEXT("(run server with -forcelogflush to reduce chance of truncated capture files)"), PacketSize, (InnerArchive.TotalSize() - InnerArchive.Tell())); SetError(); return; } } InnerArchive.Serialize(PacketData, PacketSize); if (IsSaving()) { uint32 NewPacketCount = Header.PacketCount.Get() + 1; uint32 NewPacketDataLength = Header.PacketDataLength.Get() + (Tell() - StartPos); Header.PacketCount.Set(*this, NewPacketCount); Header.PacketDataLength.Set(*this, NewPacketDataLength); if (bImmediateFlush) { Flush(); } } }
void CGameServer::Delete(CBaseEntity* pEntity) { TAssert(GameNetwork()->IsHost() || IsLoading()); if (!(GameNetwork()->IsHost() || IsLoading())) TMsg("WARNING: CGameServer::Delete() when not host or not loading.\n"); if (GameNetwork()->IsHost()) GameNetwork()->CallFunction(NETWORK_TOCLIENTS, "DestroyEntity", pEntity->GetHandle()); CNetworkParameters p; p.i1 = (int)pEntity->GetHandle(); DestroyEntity(CONNECTION_GAME, &p); }
void UGameplayTagsManager::LoadGameplayTagTables(TArray<FString>& TagTableNames) { if (GameplayTagTables.Num() == 0 && TagTableNames.Num() > 0) { for (auto It(TagTableNames.CreateConstIterator()); It; ++It) { const FString& FileName = *It; UDataTable* TagTable = LoadObject<UDataTable>(NULL, *FileName, NULL, LOAD_None, NULL); // Handle case where the module is dynamically-loaded within a LoadPackage stack, which would otherwise // result in the tag table not having its RowStruct serialized in time. Without the RowStruct, the tags manager // will not be initialized correctly. if (TagTable && IsLoading()) { FLinkerLoad* TagLinker = TagTable->GetLinker(); if (TagLinker) { TagTable->GetLinker()->Preload(TagTable); } } GameplayTagTables.Add(TagTable); } } #if WITH_EDITOR // Hook into notifications for object re-imports so that the gameplay tag tree can be reconstructed if the table changes if (GIsEditor && GameplayTagTables.Num() > 0 && !RegisteredObjectReimport) { RegisteredObjectReimport = true; FEditorDelegates::OnAssetPostImport.AddUObject(this, &UGameplayTagsManager::OnObjectReimported); } #endif }
boost::shared_ptr<Image> Album::GetImage() { if (IsLoading()) { return boost::shared_ptr<Image>(); } const byte* album_id = sp_album_cover( m_pAlbum, SP_IMAGE_SIZE_NORMAL); if (album_id == NULL) { return boost::shared_ptr<Image>(); } boost::shared_ptr<Image> image = m_session->CreateImage(); if (image->Load( album_id )) { return image; } else { return boost::shared_ptr<Image>(); } }
void HttpStreamFArchive::Serialize( void* V, int64 Length ) { if ( IsLoading() ) { if ( Pos + Length > Buffer.Num() ) { ArIsError = true; return; } FMemory::Memcpy( V, Buffer.GetData() + Pos, Length ); Pos += Length; } else { check( Pos <= Buffer.Num() ); const int32 SpaceNeeded = Length - ( Buffer.Num() - Pos ); if ( SpaceNeeded > 0 ) { Buffer.AddZeroed( SpaceNeeded ); } FMemory::Memcpy( Buffer.GetData() + Pos, V, Length ); Pos += Length; } }
bool WrappedOpenGL::Serialise_glPushDebugGroup(SerialiserType &ser, GLenum source, GLuint id, GLsizei length, const GLchar *message) { std::string name = message ? std::string(message, message + (length > 0 ? length : strlen(message))) : ""; // unused, just for the user's benefit SERIALISE_ELEMENT(source); SERIALISE_ELEMENT(id); SERIALISE_ELEMENT(name); SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) { GLMarkerRegion::Begin(name, source, id); m_ReplayEventCount++; if(IsLoading(m_State)) { DrawcallDescription draw; draw.name = name; draw.flags |= DrawFlags::PushMarker; AddEvent(); AddDrawcall(draw, false); } } return true; }
bool WrappedOpenGL::Serialise_glInsertEventMarkerEXT(SerialiserType &ser, GLsizei length, const GLchar *marker_) { std::string marker = marker_ ? std::string(marker_, marker_ + (length > 0 ? length : strlen(marker_))) : ""; SERIALISE_ELEMENT(marker); SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) { GLMarkerRegion::Set(marker); if(IsLoading(m_State)) { DrawcallDescription draw; draw.name = marker; draw.flags |= DrawFlags::SetMarker; AddEvent(); AddDrawcall(draw, false); } } return true; }
bool WrappedOpenGL::Serialise_glDebugMessageInsert(SerialiserType &ser, GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf) { std::string name = buf ? std::string(buf, buf + (length > 0 ? length : strlen(buf))) : ""; // unused, just for the user's benefit SERIALISE_ELEMENT(source); SERIALISE_ELEMENT(type); SERIALISE_ELEMENT(id); SERIALISE_ELEMENT(severity); SERIALISE_ELEMENT(name); SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) { GLMarkerRegion::Set(name); if(IsLoading(m_State)) { DrawcallDescription draw; draw.name = name; draw.flags |= DrawFlags::SetMarker; AddEvent(); AddDrawcall(draw, false); } } return true; }
nsresult nsPACMan::AsyncGetProxyForURI(nsIURI *uri, nsPACManCallback *callback) { NS_ENSURE_STATE(!mShutdown); MaybeReloadPAC(); PendingPACQuery *query = new PendingPACQuery(this, uri, callback); if (!query) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(query); PR_APPEND_LINK(query, &mPendingQ); // If we're waiting for the PAC file to load, then delay starting the query. // See OnStreamComplete. However, if this is the PAC URI then query right // away since we know the result will be DIRECT. We could shortcut some code // in this case by issuing the callback directly from here, but that would // require extra code, so we just go through the usual async code path. int isPACURI = IsPACURI(uri); if (IsLoading() && !isPACURI) return NS_OK; nsresult rv = query->Start(isPACURI ? 0 : nsIDNSService::RESOLVE_SPECULATE); if (rv == NS_ERROR_DNS_LOOKUP_QUEUE_FULL && !isPACURI) { query->OnLookupComplete(NULL, NULL, NS_OK); rv = NS_OK; } else if (NS_FAILED(rv)) { NS_WARNING("failed to start PAC query"); PR_REMOVE_LINK(query); NS_RELEASE(query); } return rv; }
void CancelLoad() { if (xC_objectStore && IsLoading()) { xC_objectStore->GetFactory().CancelBuild(x4_objTag); x3_loading = false; } }
void GadgetHelpLoader::StopLoading() { if (IsLoading()) { m_url.StopLoading(g_main_message_handler); } g_main_message_handler->UnsetCallBacks(this); }
void SaveState::psxRcntFreeze() { Freeze(psxCounters); Freeze(psxNextCounter); Freeze(psxNextsCounter); if( IsLoading() ) psxRcntSetGates(); }
int32 FArchive::CustomVer(const FGuid& Key) const { auto* CustomVersion = GetCustomVersions().GetVersion(Key); // If this fails, you have forgotten to make an Ar.UsingCustomVersion call // before serializing your custom version-dependent object. check(IsLoading() || CustomVersion); return CustomVersion ? CustomVersion->Version : -1; }
/** Decrements 2nd ref-count, performing unload or async-load-cancel if 0 reached */ void Unlock() { --x2_lockCount; if (x2_lockCount) return; if (x10_object && xC_objectStore) Unload(); else if (IsLoading()) CancelLoad(); }
void Weapon::StopShooting() { if (max_strength.IsNotZero() && !IsLoading()) /* User has probably exceed the max_strength */ return; if (!ActiveCharacter().IsPreparingShoot()) { PrepareShoot(); } }
void CNodedMemoryBuffer::SkipField() { ASSERT(IsLoading()); if(m_iFieldType == ID_FIELD_IS_NODE) SkipNode(); else { Seek(m_dwFieldSize, SEEK_CURRENT); } }
const void *Image::GetData(std::size_t *out_data_size) { out_data_size = 0; if (!image_) return NULL; if (IsLoading()) { return NULL; } return sp_image_data(image_, out_data_size); }
void Weapon::Refresh() { if (IsLoading() && !ActiveCharacter().IsPreparingShoot()) { // Strength == max strength -> Fire !!! if (ReadStrength() >= max_strength) { PrepareShoot(); } else { // still pressing the Space key UpdateStrength(); } } }
// Start encrypting or decrypting data to/from the archive, using the specified cryptography object. void CCryptoArchive::SetCryptoOn(CCrypto* pCrypto) { // Get pointer to the CCryptoFile associated with the archive. // This is actually a CCryptoFile instead of a CFile because we overrode various routines and classes to do so. CCryptoFile* pFile = STATIC_DOWNCAST(CCryptoFile, GetFile()); ASSERT_VALID(pFile); BOOL bReading = IsLoading(); // Tell associated CCryptoFile object to turn encryption/decryption on pFile->SetCryptoOn(pCrypto, bReading, m_lpBufCur, m_lpBufMax); }
void CGameServer::DestroyAllEntities(const tvector<tstring>& asSpare, bool bRemakeGame) { if (!GameNetwork()->IsHost() && !IsLoading()) return; if (m_pWorkListener) m_pWorkListener->SetAction("Locating dead nodes", GameServer()->GetMaxEntities()); for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++) { CBaseEntity* pEntity = CBaseEntity::GetEntity(i); if (!pEntity) continue; bool bSpare = false; for (size_t j = 0; j < asSpare.size(); j++) { if (asSpare[j] == pEntity->GetClassName()) { bSpare = true; break; } } if (bSpare) continue; pEntity->Delete(); if (m_pWorkListener) m_pWorkListener->WorkProgress(i); } if (m_pWorkListener) m_pWorkListener->SetAction("Clearing buffers", GameServer()->m_ahDeletedEntities.size()); for (size_t i = 0; i < GameServer()->m_ahDeletedEntities.size(); i++) { delete GameServer()->m_ahDeletedEntities[i]; if (m_pWorkListener) m_pWorkListener->WorkProgress(i); } GameServer()->m_ahDeletedEntities.clear(); if (CBaseEntity::GetNumEntities() == 0) CBaseEntity::s_iNextEntityListIndex = 0; if (bRemakeGame && GameNetwork()->IsHost()) m_hGame = CreateGame(); }
/** Mechanism by which CToken decrements 1st ref-count, indicating CToken invalidation or reset. * Reaching 0 indicates the CToken should delete the CObjectReference */ u16 RemoveReference() { --x0_refCount; if (x0_refCount == 0) { if (x10_object) Unload(); if (IsLoading()) CancelLoad(); xC_objectStore->ObjectUnreferenced(x4_objTag); } return x0_refCount; }
FArchive& FObjectReader::operator<<(FStringAssetReference& Value) { FString Path = Value.ToString(); *this << Path; if (IsLoading()) { Value.SetPath(MoveTemp(Path)); } return *this; }
void BinarySerializerBase::serialize(std::string* var, const uint32_t bytes, String const&, bool PersistToDB) { if(IsLoading()) { char* data = new char[bytes]; serialize_impl(data, bytes, PersistToDB); *var = std::string(data, bytes); delete[] data; } else { serialize_impl(const_cast<char*>(var->c_str()), bytes, PersistToDB); } }
void FArchive::UsingCustomVersion(const FGuid& Key) { // If we're loading, we want to use the version that the archive was serialized with, not register a new one. if (IsLoading()) return; auto* RegisteredVersion = FCustomVersionContainer::GetRegistered().GetVersion(Key); // Ensure that the version has already been registered. // If this fails, you probably don't have an FCustomVersionRegistration variable defined for this GUID. check(RegisteredVersion); const_cast<FCustomVersionContainer&>(GetCustomVersions()).SetVersion(Key, RegisteredVersion->Version, RegisteredVersion->FriendlyName); }
virtual FArchive& operator<<(FStringAssetReference& Value) override { FArchive& Ar = *this; FString Path = Value.ToString(); Ar << Path; if (IsLoading()) { Value.SetPath(MoveTemp(Path)); } return Ar; }
/** * Serialize the given FName as an FString */ FArchive& FNameAsStringProxyArchive::operator<<( class FName& N ) { if (IsLoading()) { FString LoadedString; InnerArchive << LoadedString; N = FName(*LoadedString); } else { FString SavedString(N.ToString()); InnerArchive << SavedString; } return *this; }
void CMemoryBuffer::Seek(DWORD dwOff, UINT nFrom) { ASSERT(IsLoading()); switch(nFrom) { case SEEK_BEGIN: m_lpvCurrntPos = (void*) (((DWORD) m_lpvMemory) + dwOff); break; case SEEK_CURRENT: m_lpvCurrntPos = (void*) (((DWORD) m_lpvCurrntPos) + dwOff); break; default: ASSERT(FALSE); break; } }
void UChildActorComponent::DestroyChildActor(const bool bRequiresRename) { // If we own an Actor, kill it now if(ChildActor != nullptr && !GExitPurge) { // if still alive, destroy, otherwise just clear the pointer if (!ChildActor->IsPendingKillOrUnreachable()) { #if WITH_EDITOR if (CachedInstanceData) { delete CachedInstanceData; CachedInstanceData = nullptr; } #else check(!CachedInstanceData); #endif // If we're already tearing down we won't be needing this if (!HasAnyFlags(RF_BeginDestroyed)) { CachedInstanceData = new FChildActorComponentInstanceData(this); } UWorld* World = ChildActor->GetWorld(); // World may be nullptr during shutdown if(World != nullptr) { UClass* ChildClass = ChildActor->GetClass(); // We would like to make certain that our name is not going to accidentally get taken from us while we're destroyed // so we increment ClassUnique beyond our index to be certain of it. This is ... a bit hacky. ChildClass->ClassUnique = FMath::Max(ChildClass->ClassUnique, ChildActor->GetFName().GetNumber()); if (bRequiresRename) { const FString ObjectBaseName = FString::Printf(TEXT("DESTROYED_%s_CHILDACTOR"), *ChildClass->GetName()); const ERenameFlags RenameFlags = ((GetWorld()->IsGameWorld() || IsLoading()) ? REN_DoNotDirty | REN_ForceNoResetLoaders : REN_DoNotDirty); ChildActor->Rename(*MakeUniqueObjectName(ChildActor->GetOuter(), ChildClass, *ObjectBaseName).ToString(), nullptr, RenameFlags); } World->DestroyActor(ChildActor); } } ChildActor = nullptr; } }
void FCEFWebBrowserWindow::CheckTickActivity() { // Early out if we're currently hidden, not initialized or currently loading. if (bIsHidden || !IsValid() || IsLoading() || ViewportSize == FIntPoint::ZeroValue) { return; } // We clear the bTickedLastFrame flag here and set it on every Slate tick. // If it's still clear when we come back it means we're not getting ticks from slate. // Note: The BrowserSingleton object will not invoke this method if Slate itself is sleeping. // Therefore we can safely assume the widget is hidden in that case. if (!bTickedLastFrame) { SetIsHidden(true); } bTickedLastFrame = false; }