bool DropPoolConfig::Generate(uint id, List<DropPoolItem>& outItems, void* userData/*=nullptr*/) const { const DropPool* dropPool = Find(id); Log::AssertNotNullFormat(dropPool, "Cannot find drop pool id:{}", id); RETURN_FALSE_IF_NULL(dropPool); return dropPool->Generate(*this, outItems, userData); }
bool IBrainBody::Behave(void* sender, float dt) { RETURN_FALSE_IF_NULL(mBrain); if (mCurrentBehavior != nullptr) { RETURN_TRUE_IF_TRUE(mCurrentBehavior->Update(*this, sender, dt)); mCurrentBehavior->Exit(*this, sender); mCurrentBehavior = nullptr; } const IBehavior* newBehavior = mBrain->Behave(*this, sender); if (mCurrentBehavior != newBehavior) { mCurrentBehavior = newBehavior; if (mCurrentBehavior != nullptr) { RETURN_TRUE_IF_TRUE(mCurrentBehavior->Update(*this, sender, dt)); mCurrentBehavior->Exit(*this, sender); mCurrentBehavior = nullptr; } } return true; }
bool TiledImage::LoadTiledTexture(Size2I tileSize) { auto textureAtlas=TextureAtlasFactory::Instance().CreateTiledAtlas(mSource, mSize, tileSize); RETURN_FALSE_IF_NULL(textureAtlas); mTexturePage = textureAtlas->FindPage(0); mTextureAtlas = textureAtlas; return true; }
bool FileStorage::RemoveFile(FileEntry* file) { RETURN_FALSE_IF_NULL(file); RETURN_FALSE_IF_NULL(file->Parent()); #ifdef MEDUSA_SAFE_CHECK if (file->Storage() != this) { Log::AssertFailed("Invalid operate file on different storage."); return false; } #endif RETURN_FALSE_IF_FALSE(OnRemoveFile(*file)); auto* parent = file->Parent(); return parent->RemoveFile(file); }
bool FileStorage::SaveFile(FileEntry& fileEntry, const IStream& sourceStream) { IStream* stream = WriteFileHelper(fileEntry, FileOpenMode::DestoryWriteOrCreate, FileDataType::Binary); RETURN_FALSE_IF_NULL(stream); sourceStream.CopyTo(*stream); SAFE_RELEASE(stream); return true; }
static bool SetSharedMemoryPool(SharedMemoryPool* pool) { RETURN_FALSE_IF_NULL(pool); if (NULL != m_raw) { return false; } m_raw = pool; return true; }
bool str_todouble(const char* str, double& value) { RETURN_FALSE_IF_NULL(str); char *endptr = NULL; double val = strtod(str, &endptr); if (NULL == endptr || 0 != *endptr) { return false; } value = val; return true; }
bool str_tofloat(const char* str, float& value) { RETURN_FALSE_IF_NULL(str); char *endptr = NULL; float val = strtof(str, &endptr); if (NULL == endptr || 0 != *endptr) { return false; } value = val; return true; }
bool str_toint64(const char* str, int64& value) { RETURN_FALSE_IF_NULL(str); char *endptr = NULL; long long int val = strtoll(str, &endptr, 10); if (NULL == endptr || 0 != *endptr) { return false; } value = val; return true; }
bool ShaderConstantInitializer::UpdateWorldMatrix( ShaderConstant& uniform ) { BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass(); RETURN_FALSE_IF_NULL(effect); IRenderBatch* batch=RenderingContext::Instance().Batch(); const Matrix& modelMatrix=batch->GetModelMatrix(); uniform.Invalidate(); uniform.SetMatrix(modelMatrix); return true; }
bool ShaderConstantInitializer::Update(RenderingStep step, ShaderConstant& uniform) { InitializerType* tempInitializer= mInitializerDict.TryGetValueWithFailed(step,nullptr); RETURN_FALSE_IF_NULL(tempInitializer); FuncType* func=(tempInitializer)->TryGetValue(uniform.Name()); if (func==nullptr) { return false; } return (*func)(uniform); }
bool ScriptModule::NewObjects(StringRef className, size_t count, List<ScriptObject*>& outObjects) { outObjects.Clear(); asIObjectType* scriptObjectType = mScriptModule->GetObjectTypeByName(className.c_str()); RETURN_FALSE_IF_NULL(scriptObjectType); HeapString factoryName = className; factoryName += "@ "; factoryName += className; factoryName += "()"; asIScriptFunction* factory = scriptObjectType->GetFactoryByDecl(factoryName.c_str()); RETURN_FALSE_IF_NULL(factory); asIScriptContext* context = ScriptEngine::Instance().GetScriptContext(); List<ScriptObject*> result; FOR_EACH_SIZE(i, count) { context->Prepare(factory); context->Execute(); asIScriptObject* scriptObject = *(asIScriptObject**)context->GetAddressOfReturnValue(); ScriptObject* temp = new ScriptObject(scriptObject); outObjects.Add(temp); }
bool PODLighTimeline::Start() { RETURN_FALSE_IF_FALSE((ITimeline::Start())); auto ani = mModel.CastPtr<PODLightTimelineModel>(); StringRef lightName=ani->LightName(); StringRef targetName=ani->TargetNodeName(); mLight=LightFactory::Instance().Find(lightName); RETURN_FALSE_IF_NULL(mLight); return true; }
bool IBrainBody::ReceiveEvent(void* sender, IEventArg& e) { RETURN_FALSE_IF_NULL(mBrain); const IBehavior* newBehavior = mBrain->ReceiveEvent(*this, sender, e); if (newBehavior != nullptr) { if (mCurrentBehavior != nullptr) { mCurrentBehavior->Exit(*this, sender); } mCurrentBehavior = newBehavior; } return true; }
bool JPSPlusPathFinder::AddNeighbors(const Cell* currentCell, const Cell* nextCell, const Cell* goalCell, Direction direction) { RETURN_FALSE_IF_NULL(nextCell); bool outIsCompleted = false; Direction outMarkedDirection; const Cell* nextNextCell = Jump(nextCell, goalCell, direction, outIsCompleted, outMarkedDirection); if (outIsCompleted) { LinkCell(currentCell, nextNextCell, (direction)); LinkCell(nextNextCell, goalCell, outMarkedDirection); return true; } if (nextNextCell) { AddToOpenList(currentCell, nextNextCell, goalCell, direction); } return false; }
bool ShaderConstantInitializer::UpdateViewProjectMatrix( ShaderConstant& uniform) { BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass(); RETURN_FALSE_IF_NULL(effect); //IRenderBatch* batch=RenderingContext::Instance().GetBatch(); Camera* camera= RenderingContext::Instance().GetCamera(); if (camera!=nullptr) { const Matrix& projectionMatrix= camera->ViewProjectionMatrix(); uniform.SetMatrix(projectionMatrix); } else { Log::Error("No camera for ViewProjectMatrix"); } return true; }
bool ChannelPipeline::SendUpstream(ChannelHandlerContext* ctx, MessageEvent<T>& e) { RETURN_FALSE_IF_NULL(ctx); ChannelHandler* base = ctx->GetHandler(); ChannelUpstreamHandler<T> * handler = dynamic_cast<ChannelUpstreamHandler<T>*>(base); //ChannelUpstreamHandler<T> * handler = NULL; //if (ChannelHandlerHelper<T>::CanHandleUpMessageEvent(base)) //{ // handler = static_cast<ChannelUpstreamHandler<T>*>(base); //} if (NULL == handler) { return ctx->SendUpstream(e); } else { return handler->HandleStreamEvent(*ctx, e); } }
bool INode::RemoveChild(INode* node) { RETURN_FALSE_IF_NULL(node); if (mNodes.RemoveFirst(node)) { node->SetParent(nullptr); mNodeDict.RemoveKey(node->Name()); if (node->IsManaged()) { mManagedNodes.RemoveFirst(node); } OnLayoutChanged(*node, NodeLayoutChangedFlags::ChildRemoved); OnRenderQueueChanged(); OnVisitQueueChanged(); return true; } return false; }
bool ShaderConstantInitializer::UpdateWorldViewProjectMatrix( ShaderConstant& uniform) { BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass(); RETURN_FALSE_IF_NULL(effect); IRenderBatch* batch=RenderingContext::Instance().Batch(); const Matrix& modelMatrix=batch->GetModelMatrix(); Camera* camera= RenderingContext::Instance().GetCamera(); if (camera!=nullptr) { const Matrix& projectionMatrix= camera->ViewProjectionMatrix(); Matrix pmvMatrix=modelMatrix*projectionMatrix; uniform.Invalidate(); uniform.SetMatrix(pmvMatrix); } else { uniform.Invalidate(); uniform.SetMatrix(modelMatrix); } return true; }
bool FileStorage::SearchFilesToExtract(const StringRef& searchPath, bool isRecursively /*= true*/, const StringRef& outDir /*= StringRef::Empty*/) { if (Path::IsDirectory(searchPath)) { return ExtractDirectory(searchPath, nullptr, isRecursively, outDir); } else { if (Path::HasSearchPattern(searchPath)) { List<HeapString> outFiles; FileInfo fileInfo(searchPath); auto dir = fileInfo.Directory(); auto* dirEntry = FindDirectory(dir); RETURN_FALSE_IF_NULL(dirEntry); return dirEntry->SearchFilesToExtract(fileInfo.FullName(), isRecursively, outDir); } else { return ExtractFile(searchPath, nullptr, outDir); } } }
bool FileStorage::SearchFilesToRemove(const StringRef& searchPath, bool isRecursively /*= true*/) { if (Path::IsDirectory(searchPath)) { return RemoveDirectory(searchPath); } else { if (Path::HasSearchPattern(searchPath)) { List<HeapString> outFiles; FileInfo fileInfo(searchPath); auto dir = fileInfo.Directory(); auto* dirEntry = FindDirectory(dir); RETURN_FALSE_IF_NULL(dirEntry); return dirEntry->SearchFilesToRemove(fileInfo.FullName(), isRecursively); } else { return RemoveFile(searchPath); } } }
bool FileStorage::RemoveDirectory(DirectoryEntry* dir) { RETURN_FALSE_IF_NULL(dir); #ifdef MEDUSA_SAFE_CHECK if (dir->Storage() != this) { Log::AssertFailed("Invalid operate dir on different storage."); return false; } if (dir == &mRootDir) { Log::AssertFailed("Cannot remove root dir."); return false; } #endif RETURN_FALSE_IF_FALSE(RemoveAllFiles(*dir)); RETURN_FALSE_IF_FALSE(RemoveAllDirectories(*dir)); RETURN_FALSE_IF_FALSE(OnRemoveDirectory(*dir)); auto* parent = dir->Parent(); parent->RemoveDirectory(dir); return true; }
bool StringTable::Contains(const FileIdRef& fileId) const { const StringNameItem* nameItem = mItems.TryGetValue(fileId.Name); RETURN_FALSE_IF_NULL(nameItem); return nameItem->Contains((uint)fileId.Order); }
bool INode::RemoveChild(const StringRef& name) { INode* node = FindChild(name); RETURN_FALSE_IF_NULL(node); return RemoveChild(node); }
bool ChannelPipeline::SendUpstream(T& event) { ChannelHandlerContext* ctx = GetActualUpstreamContext(m_head); RETURN_FALSE_IF_NULL(ctx); return SendUpstream(ctx, event); }
bool ChannelPipeline::SendDownstream(ChannelHandlerContext* ctx, T& e) { RETURN_FALSE_IF_NULL(ctx); ChannelHandler* handler = ctx->GetHandler(); return handler->HandleStreamEvent(*ctx, e); }
bool FileStorage::RemoveAllFiles(const StringRef& path) { auto* parent = FindDirectory(path); RETURN_FALSE_IF_NULL(parent); return RemoveAllFiles(*parent); }
bool FileMapTagItem::ContainsOrderItem(const FileIdRef& fileId) const { const FileMapNameItem* nameItem = mItems.GetOptional(fileId.Name, nullptr); RETURN_FALSE_IF_NULL(nameItem); return nameItem->Contains((uint)fileId.Order); }
bool FileStorage::ExtractFile(const StringRef& path, DirectoryEntry* parent /*= nullptr*/, const StringRef& outDir /*= StringRef::Empty*/) const { auto* fileEntry = FindFile(path, parent); RETURN_FALSE_IF_NULL(fileEntry); return fileEntry->Extract(outDir); }
bool FileStorage::RemoveAll(const StringRef& path, DirectoryEntry* parent /*= nullptr*/) { parent = FindDirectory(path, parent); RETURN_FALSE_IF_NULL(parent); return RemoveAll(*parent); }