//-------------------------------------------------------------------------- VeSizeT VeFileOStream::Write(const void* pvBuffer, VeSizeT stBytes) noexcept { if (pvBuffer && stBytes) { const VeSizeT stRes = stBytes; const VeChar8* pcBuffer = (const VeChar8*)pvBuffer; if (HasCacheUse()) { VeSizeT stCache = VE_MIN(CacheCanUse(), stBytes); VeCrazyCopy(Cache(), pcBuffer, stCache); pcBuffer += stCache; m_stFileSize += stCache; stBytes -= stCache; WriteBackCache(); } if (stBytes >= m_stCacheSize) { fwrite(pcBuffer, 1, stBytes, m_pkFile); m_stFileSize += stBytes; m_stCachePointer = m_stFileSize; } else { VeCrazyCopy(Cache(), pcBuffer, stBytes); m_stFileSize += stBytes; } return stRes; } else { return 0; } }
void wxHtmlTagsCache::QueryTag(const wxString::const_iterator& at, const wxString::const_iterator& inputEnd, wxString::const_iterator *end1, wxString::const_iterator *end2, bool *hasEnding) { if (Cache().empty()) { *end1 = *end2 = inputEnd; *hasEnding = true; return; } if (Cache()[m_CachePos].Key != at) { int delta = (at < Cache()[m_CachePos].Key) ? -1 : 1; do { m_CachePos += delta; if ( m_CachePos < 0 || m_CachePos >= (int)Cache().size() ) { if ( m_CachePos < 0 ) m_CachePos = 0; else m_CachePos = Cache().size() - 1; // something is very wrong with HTML, give up by returning an // impossibly large value which is going to be ignored by the // caller *end1 = *end2 = inputEnd; *hasEnding = true; return; } } while (Cache()[m_CachePos].Key != at); } switch ( Cache()[m_CachePos].type ) { case wxHtmlCacheItem::Type_Normal: *end1 = Cache()[m_CachePos].End1; *end2 = Cache()[m_CachePos].End2; *hasEnding = true; break; case wxHtmlCacheItem::Type_EndingTag: wxFAIL_MSG("QueryTag called for ending tag - can't be"); // but if it does happen, fall through, better than crashing case wxHtmlCacheItem::Type_NoMatchingEndingTag: // If input HTML is invalid and there's no closing tag for this // one, pretend that it runs all the way to the end of input *end1 = inputEnd; *end2 = inputEnd; *hasEnding = false; break; } }
void LoginForm::authenticationComplete() { if (m_Greeter.isAuthenticated()) { Cache().setLastUser(ui->userInput->text()); Cache().setLastSession(ui->userInput->text(), currentSession()); Cache().sync(); m_Greeter.startSessionSync(currentSession()); } else { ui->passwordInput->clear(); userChanged(); } }
/* ================== Sound::Sound ================== */ Sound::Sound(string file, PlaybackMethod method) { oggFile = NULL; oggStream = NULL; vorbisInfo = NULL; bytePos = 0; cacheBuffer = NULL; buffers[0] = 0; buffers[1] = 0; source = 0; audioData.format = 0; audioData.frequency = 0; pbMethod = PLAYBACK_UNDEFINED; requiresInitialFill = true; loop = false; deleteWhenDone = true; AudioManager::GetSingleton()->AddSound(this); PimAssert(method != PLAYBACK_UNDEFINED, "Error: Must provide valid playback method!"); if (method == PLAYBACK_CACHE) { Cache(file); } else if (method == PLAYBACK_STREAM) { Stream(file); } }
void LexicalReorderingTableTree::InitializeForInput(const InputType& input){ ClearCache(); if(ConfusionNet const* cn = dynamic_cast<ConfusionNet const*>(&input)){ Cache(*cn); } else if(Sentence const* s = dynamic_cast<Sentence const*>(&input)){ // Cache(*s); ... this just takes up too much memory, we cache elsewhere DisableCache(); } };
GuiImageAsync *BoxBrowser::Get( u32 idx ) { std::map<u32, GuiImageAsync *>::iterator it = coverImg.find( idx ); if( it != coverImg.end() ) { return (*it).second; } return Cache( idx ); }
void CSoundInterface::CacheAll() { for ( int i = 1; i < SOUND_MAX; i++ ) { std::stringstream filename; filename << "sound" << std::setfill('0') << std::setw(3) << i << ".wav"; if ( !Cache(static_cast<Sound>(i), filename.str()) ) GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str()); } }
ID3DX11EffectVariable* Shader::Regist(const String& name) { auto variable = Current()->effect->GetVariableByName(name.ToNarrow().c_str()); if (!variable->IsValid()) { throw std::exception("無効な変数です"); } Current()->variable[name] = variable; return Cache(name); }
CNamedIndexesBlock* CNamedIndexesBlocks::FindOrCreateAndCacheBlock(CNamedIndexesBlock* pcNotFullBlock) { BOOL bResult; if (pcNotFullBlock == NULL) { pcNotFullBlock = FindNotFullBlock(); } if (pcNotFullBlock == NULL) { pcNotFullBlock = macBlocks.Add(); pcNotFullBlock->Init(miBlockWidth, miBlockChunkSize); bResult = Cache(pcNotFullBlock); if (bResult) { return pcNotFullBlock; } else { return NULL; } } else if (pcNotFullBlock->IsNotCached()) { bResult = Cache(pcNotFullBlock); if (bResult) { return pcNotFullBlock; } else { return NULL; } } else { return pcNotFullBlock; } }
void init() override{ m_data->archive.open(L"resource.dat"); if (!(m_data->archive)){ MessageBox::Show(L"Load Error!", MessageBoxStyle::Ok); } font = Font(60, Typeface::Light); font1 = Font(30, Typeface::Light); font2 = Font(25, Typeface::Light); Image Cache(m_data->archive.load(L"Title.png")); Back = Texture(Cache); }
ID3DX11EffectVariable* Shader::Variable(const String& name) { if (IsCached(name)) { return Cache(name); } auto val = Regist(name); assert(val && (const wchar_t*)name); return val; }
void LexicalReorderingTableTree::InitializeForInput(const InputType& input){ ClearCache(); if(ConfusionNet const* cn = dynamic_cast<ConfusionNet const*>(&input)){ Cache(*cn); } else if(Sentence const* s = dynamic_cast<Sentence const*>(&input)){ // Cache(*s); ... this just takes up too much memory, we cache elsewhere DisableCache(); } if (!m_Table.get()) { //load thread specific table. m_Table.reset(new PrefixTreeMap()); m_Table->Read(m_FilePath+".binlexr"); } };
void LoginForm::userChanged() { setCurrentSession(Cache().getLastSession(ui->userInput->text())); if (m_Greeter.inAuthentication()) { m_Greeter.cancelAuthentication(); } if (! ui->userInput->text().isEmpty()) { m_Greeter.authenticate(ui->userInput->text()); ui->passwordInput->setFocus(); } else { ui->userInput->setFocus(); } }
BOOL CNamedIndexesBlocks::Add(OIndex oi, CChars* szName, BOOL bFailOnExisting) { int i; CNamedIndexesBlock* pcBlock; OIndex oiExisiting; CNamedIndexesBlock* pcNotFullBlock; CArrayNamedIndexesBlockPtr cArrayBlockPrts; cArrayBlockPrts.Init(16); GetPotentialContainingBlocks(szName, &cArrayBlockPrts); SortBlockPtrsCachedFirst(&cArrayBlockPrts); pcNotFullBlock = NULL; for (i = 0; i < cArrayBlockPrts.NumElements(); i++) { pcBlock = *cArrayBlockPrts.Get(i); if (pcBlock->IsNotCached()) { Cache(pcBlock); } oiExisiting = pcBlock->GetIndex(szName); if (oiExisiting != INVALID_O_INDEX) { //Already exists; cArrayBlockPrts.Kill(); return !bFailOnExisting; } if (pcNotFullBlock == NULL) { if (pcBlock->IsNotFull()) { pcNotFullBlock = pcBlock; } } } cArrayBlockPrts.Kill(); pcNotFullBlock = FindOrCreateAndCacheBlock(pcNotFullBlock); if (pcNotFullBlock) { return pcNotFullBlock->AddUnsafe(oi, szName); } return FALSE; }
BOOL CNamedIndexesBlocks::Remove(CChars* szName) { int i; CNamedIndexesBlock* pcBlock; BOOL bResult; CArrayNamedIndexesBlockPtr cArrayBlockPrts; int iIndex; cArrayBlockPrts.Init(16); GetPotentialContainingBlocks(szName, &cArrayBlockPrts); SortBlockPtrsCachedFirst(&cArrayBlockPrts); for (i = 0; i < cArrayBlockPrts.NumElements(); i++) { pcBlock = *cArrayBlockPrts.Get(i); if (!pcBlock->IsCached()) { bResult = Cache(pcBlock); if (!bResult) { cArrayBlockPrts.Kill(); return INVALID_O_INDEX; } } bResult = pcBlock->Remove(szName); if (bResult) { if (pcBlock->IsEmpty()) { pcBlock->Kill(); iIndex = macBlocks.GetIndex(pcBlock); macBlocks.RemoveAt(iIndex, FALSE); pcBlock = macBlocks.SafeGet(i); if (pcBlock) { pcBlock->Dirty(); } } cArrayBlockPrts.Kill(); return TRUE; } } cArrayBlockPrts.Kill(); return FALSE; }
RichPara::~RichPara() { if(cacheid && !part.IsPicked() && !incache) { Mutex::Lock __(sCacheMutex); Array<RichPara>& cache = Cache(); incache = true; cache.InsertPick(0, *this); int total = 0; for(int i = 1; i < cache.GetCount(); i++) { total += cache[i].GetLength(); if(total > 10000 || i > 64) { cache.SetCount(i); break; } i++; } } }
CWaypoints::CPoint::CPoint(double dLon, double dLat, int iAltitude, const wchar_t * wcName) : m_OSMPropList() { static int iNextId = 0; m_iId = iNextId++; m_dLongitude = dLon; m_dLatitude = dLat; Cache(); m_iAltitude = iAltitude; SetLabel(wcName); m_iRadius = 0; SYSTEMTIME st; FILETIME ft; GetSystemTime(&st); SystemTimeToFileTime(&st, &ft); m_dLastUsed = double(ft.dwHighDateTime) * double(1 << 16) * double(1 << 16) + double(ft.dwLowDateTime); m_fInProximity = false; }
bool Resource::Load() { m_iRefCount++; if ( m_bReady ) { return false; } if ( GetClassType() != Base::Mesh_Terrain ) { if ( m_szPathName == L"" ) { return false; } char szFile[256]; wcstombs( szFile, m_szPathName.c_str(), 256 ); FILE * pFile = fopen( szFile, "rb" ); if ( pFile == NULL ) { return false; } DWORD dwSize = _filelength( _fileno( pFile ) ); m_kFileBuffer.Create( dwSize ); fread( m_kFileBuffer.GetPointer(), sizeof(char), dwSize, pFile ); } if ( ! Create() ) { return false; } if ( ! Cache() ) { return false; } m_bReady = true; return true; }
void LoginForm::initialize() { QPixmap icon(":/resources/rqt-2.png"); // This project came from Razor-qt ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->hostnameLabel->setText(m_Greeter.hostname()); ui->sessionCombo->setModel(&sessionsModel); addLeaveEntry(power.canShutdown(), "system-shutdown", tr("Shutdown"), "shutdown"); addLeaveEntry(power.canRestart(), "system-reboot", tr("Restart"), "restart"); addLeaveEntry(power.canHibernate(), "system-suspend-hibernate", tr("Hibernate"), "hibernate"); addLeaveEntry(power.canSuspend(), "system-suspend", tr("Suspend"), "suspend"); ui->leaveComboBox->setDisabled(ui->leaveComboBox->count() <= 1); ui->sessionCombo->setCurrentIndex(0); setCurrentSession(m_Greeter.defaultSessionHint()); connect(ui->userInput, SIGNAL(editingFinished()), this, SLOT(userChanged())); connect(ui->leaveComboBox, SIGNAL(activated(int)), this, SLOT(leaveDropDownActivated(int))); connect(&m_Greeter, SIGNAL(showPrompt(QString, QLightDM::Greeter::PromptType)), this, SLOT(onPrompt(QString, QLightDM::Greeter::PromptType))); connect(&m_Greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationComplete())); ui->passwordInput->setEnabled(false); ui->passwordInput->clear(); if (! m_Greeter.hideUsersHint()) { QStringList knownUsers; QLightDM::UsersModel usersModel; for (int i = 0; i < usersModel.rowCount(QModelIndex()); i++) { knownUsers << usersModel.data(usersModel.index(i, 0), QLightDM::UsersModel::NameRole).toString(); } ui->userInput->setCompleter(new QCompleter(knownUsers)); ui->userInput->completer()->setCompletionMode(QCompleter::InlineCompletion); } QString user = Cache().getLastUser(); if (user.isEmpty()) { user = m_Greeter.selectUserHint(); } ui->userInput->setText(user); userChanged(); }
/// @brief Get frame /// @param n /// @return /// const AegiVideoFrame VideoProviderCache::GetFrame(int n) { // See if frame is cached CachedFrame cached; for (std::list<CachedFrame>::iterator cur=cache.begin();cur!=cache.end();cur++) { cached = *cur; if (cached.n == n) { cache.erase(cur); cache.push_back(cached); return cached.frame; } } // Not cached, retrieve it const AegiVideoFrame frame = master->GetFrame(n); const AegiVideoFrame *srcFrame = &frame; // Cache frame Cache(n,*srcFrame); return *srcFrame; }
uint32 Lock::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData) { switch(messageID) { case MID_PRECREATE: { if (fData == PRECREATE_WORLDFILE || fData == PRECREATE_STRINGPROP) { ReadProp((ObjectCreateStruct*)pData); } Cache(); } break; case MID_INITIALUPDATE : { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate(); } } break; case MID_SAVEOBJECT: { Save((HMESSAGEWRITE)pData); } break; case MID_LOADOBJECT: { Load((HMESSAGEREAD)pData); } break; default : break; } return Prop::EngineMessageFn(messageID, pData, fData); }
OIndex CNamedIndexesBlocks::GetIndex(CChars* szName) { int i; CNamedIndexesBlock* pcBlock; OIndex oiExisiting; BOOL bResult; CArrayNamedIndexesBlockPtr cArrayBlockPrts; cArrayBlockPrts.Init(16); GetPotentialContainingBlocks(szName, &cArrayBlockPrts); SortBlockPtrsCachedFirst(&cArrayBlockPrts); for (i = 0; i < cArrayBlockPrts.NumElements(); i++) { pcBlock = *cArrayBlockPrts.Get(i); if (!pcBlock->IsCached()) { bResult = Cache(pcBlock); if (!bResult) { cArrayBlockPrts.Kill(); return INVALID_O_INDEX; } } oiExisiting = pcBlock->GetIndex(szName); if (oiExisiting != INVALID_O_INDEX) { cArrayBlockPrts.Kill(); return oiExisiting; } } cArrayBlockPrts.Kill(); return INVALID_O_INDEX; }
wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source) { m_Cache = new wxHtmlTagsCacheData; m_CachePos = 0; wxChar tagBuffer[256]; const wxString::const_iterator end = source.end(); for ( wxString::const_iterator pos = source.begin(); pos < end; ++pos ) { if (*pos != wxT('<')) continue; // possible tag start found: // don't cache comment tags if ( wxHtmlParser::SkipCommentTag(pos, end) ) continue; // Remember the starting tag position. wxString::const_iterator stpos = pos++; // And look for the ending one. int i; for ( i = 0; pos < end && i < (int)WXSIZEOF(tagBuffer) - 1 && *pos != wxT('>') && !wxIsspace(*pos); ++i, ++pos ) { tagBuffer[i] = (wxChar)wxToupper(*pos); } tagBuffer[i] = wxT('\0'); while (pos < end && *pos != wxT('>')) ++pos; if ( pos == end ) { // We didn't find a closing bracket, this is not a valid tag after // all. Notice that we need to roll back pos to avoid creating an // invalid iterator when "++pos" is done in the loop statement. --pos; continue; } // We have a valid tag, add it to the cache. size_t tg = Cache().size(); Cache().push_back(wxHtmlCacheItem()); Cache()[tg].Key = stpos; Cache()[tg].Name = new wxChar[i+1]; memcpy(Cache()[tg].Name, tagBuffer, (i+1)*sizeof(wxChar)); if ((stpos+1) < end && *(stpos+1) == wxT('/')) // ending tag: { Cache()[tg].type = wxHtmlCacheItem::Type_EndingTag; // find matching begin tag: for (i = tg; i >= 0; i--) { if ((Cache()[i].type == wxHtmlCacheItem::Type_NoMatchingEndingTag) && (wxStrcmp(Cache()[i].Name, tagBuffer+1) == 0)) { Cache()[i].type = wxHtmlCacheItem::Type_Normal; Cache()[i].End1 = stpos; Cache()[i].End2 = pos + 1; break; } } } else { Cache()[tg].type = wxHtmlCacheItem::Type_NoMatchingEndingTag; if (wxIsCDATAElement(tagBuffer)) { // store the orig pos in case we are missing the closing // tag (see below) const wxString::const_iterator old_pos = pos; bool foundCloseTag = false; // find next matching tag int tag_len = wxStrlen(tagBuffer); while (pos < end) { // find the ending tag while (pos + 1 < end && (*pos != '<' || *(pos+1) != '/')) ++pos; if (*pos == '<') ++pos; // see if it matches int match_pos = 0; while (pos < end && match_pos < tag_len ) { wxChar c = *pos; if ( c == '>' || c == '<' ) break; // cast to wxChar needed to suppress warning in // Unicode build if ((wxChar)wxToupper(c) == tagBuffer[match_pos]) { ++match_pos; } else if (c == wxT(' ') || c == wxT('\n') || c == wxT('\r') || c == wxT('\t')) { // need to skip over these } else { match_pos = 0; } ++pos; } // found a match if (match_pos == tag_len) { pos = pos - tag_len - 3; foundCloseTag = true; break; } else // keep looking for the closing tag { ++pos; } } if (!foundCloseTag) { // we didn't find closing tag; this means the markup // is incorrect and the best thing we can do is to // ignore the unclosed tag and continue parsing as if // it didn't exist: pos = old_pos; } } } } // ok, we're done, now we'll free .Name members of cache - we don't need it anymore: for ( wxHtmlTagsCacheData::iterator i = Cache().begin(); i != Cache().end(); ++i ) { wxDELETEA(i->Name); } }
//************************************************************************ // CLCDGfx::EndDraw //************************************************************************ void CLCDGfx::EndDraw(void) { ASSERT(NULL != m_hPrevBitmap); if(NULL != m_hPrevBitmap) { GdiFlush(); m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hPrevBitmap); ASSERT(m_hPrevBitmap == m_hBitmap); m_hPrevBitmap = NULL; } if(m_nBPP != 1 || !m_bTransition) memcpy(m_pLcdBitmapBits, m_pBitmapBits, m_nWidth * m_nHeight * m_nBPP); else { if(m_dwTransitionStart == 0) { Cache(); } PBYTE pScreen1 = m_pSavedBitmapBits; PBYTE pScreen2 = m_pBitmapBits; DWORD dwTimeElapsed = GetTickCount() - m_dwTransitionStart; /* if(m_eTransition == TRANSITION_BT || m_eTransition == TRANSITION_TB) { int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; if(m_eTransition == TRANSITION_TB) { iCols = m_nHeight - iCols; pScreen1 = m_pBitmapBits; pScreen2 = m_pSavedBitmapBits; } if(iCols > m_nHeight) iCols = m_nHeight; if(iCols < 0) iCols = 0; memcpy(m_pLcdBitmapBits,pScreen1+(iCols*m_nWidth),((m_nHeight-iCols)*m_nWidth)); memcpy(m_pLcdBitmapBits+((m_nHeight-iCols)*m_nWidth),pScreen2,iCols *m_nWidth); } else if(m_eTransition == TRANSITION_LR || m_eTransition == TRANSITION_RL) { int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; if(m_eTransition == TRANSITION_LR) { iCols = m_nWidth - iCols; pScreen1 = m_pBitmapBits; pScreen2 = m_pSavedBitmapBits; } if(iCols > m_nWidth) iCols = m_nWidth; if(iCols < 0) iCols = 0; for(int i=0;i<m_nHeight;i++) { memcpy(m_pLcdBitmapBits+(i*m_nWidth),pScreen1+(i*m_nWidth)+iCols,m_nWidth-iCols); memcpy(m_pLcdBitmapBits+(i*m_nWidth)+(m_nWidth-iCols),pScreen2+(i*m_nWidth),iCols); } } else*/ if(m_eTransition == TRANSITION_HLINES) { int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; if(iCols%2 == 1) iCols--; if(iCols > m_nHeight) iCols = m_nHeight; if(iCols < 2) iCols = 2; memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth); for(int i=0;i<m_nHeight;i += m_nHeight/iCols) memcpy(m_pLcdBitmapBits+(i*m_nWidth),pScreen2+(i*m_nWidth),m_nWidth); } else if(m_eTransition == TRANSITION_VLINES) { int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; if(iCols%2 == 1) iCols--; if(iCols > m_nWidth) iCols = m_nWidth; if(iCols < 2) iCols = 2; memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth); for(int i=0;i<m_nHeight;i++) { for(int j=0;j<m_nWidth;j+=m_nWidth/iCols) memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1); } } else if(m_eTransition == TRANSITION_FADE) { int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; if(iCols%2 == 1) iCols--; if(iCols > m_nHeight) iCols = m_nHeight; if(iCols < 2) iCols = 2; int iCols2 = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; if(iCols2%2 == 1) iCols2--; if(iCols2 > m_nWidth) iCols2 = m_nWidth; if(iCols2 < 2) iCols2 = 2; memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth); for(int i=0;i<m_nHeight;i += m_nHeight/iCols) { for(int j=0;j<m_nWidth;j+=m_nWidth/iCols2) memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1); } } else if(m_eTransition == TRANSITION_MORPH) { double dPercent = ((float)dwTimeElapsed/(float)TRANSITION_DURATION); double dPixelPercent = dPercent; memset(m_pLcdBitmapBits,0x00,m_nHeight * m_nWidth); SLCDPixel *pPixel = NULL; vector<SLCDPixel*>::iterator iter = m_LMovingPixels.begin(); int iIndex = 0,iMoved = 0; while(iter != m_LMovingPixels.end()) { pPixel = *iter; if(pPixel->Position.x != pPixel->Destination.x ||pPixel->Position.y != pPixel->Destination.y) { iMoved++; dPixelPercent = dPercent * pPixel->dSpeed; if(dPixelPercent > 1.0f) dPixelPercent = 1.0f; if(pPixel->Start.x < pPixel->Destination.x) pPixel->Position.x = pPixel->Start.x + dPixelPercent*(pPixel->Destination.x-pPixel->Start.x); else if(pPixel->Start.x > pPixel->Destination.x) pPixel->Position.x = pPixel->Start.x - dPixelPercent*(pPixel->Start.x-pPixel->Destination.x); if(pPixel->Start.y < pPixel->Destination.y) pPixel->Position.y = pPixel->Start.y + dPixelPercent*(pPixel->Destination.y-pPixel->Start.y); else if(pPixel->Start.y > pPixel->Destination.y) pPixel->Position.y = pPixel->Start.y - dPixelPercent*(pPixel->Start.y-pPixel->Destination.y); } iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x; if(iIndex >= 0 && iIndex < m_nHeight * m_nWidth) m_pLcdBitmapBits[iIndex] = pPixel->cValue; iter++; } iter = m_LStaticPixels.begin(); while(iter != m_LStaticPixels.end()) { pPixel = *iter; iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x; m_pLcdBitmapBits[iIndex] = pPixel->cValue; iter++; } if(iMoved == 0) EndTransition(); } if(m_eTransition != TRANSITION_MORPH && dwTimeElapsed > TRANSITION_DURATION) { EndTransition(); } } m_dwLastDraw = GetTickCount(); }
VOID OnProcessEvent( PROCESSID ProcessId ) { WCHAR fileName[260]; VOID *processHandle = NULL; processHandle = Process_Open(ProcessId, PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME); if (!processHandle) return; Process_GetFileNameByHandle(processHandle, fileName); GetConfigFileFromProcessId(ProcessId, fileName); if (File_Exists(fileName)) { MOTIONINJOY_BUTTON_MAP map; PUSH_GAME game = { 0 }; //MiJ Memory_Clear(&map, sizeof(map)); PopulateButtonMap(&map, fileName); Memory_Copy(PushSharedMemory->ButtonMap, &map, sizeof(map)); SetButtonMapping(&map); PushSharedMemory->HasConfig = TRUE; DWORD bird = GetConfig(L"Spoof", fileName); if (bird) PushSharedMemory->SpoofControllerType = TRUE; Game_Initialize(fileName, &game); if (game.Settings.UseRamDisk) { PushSharedMemory->GameUsesRamDisk = TRUE; //suspend process to allow us time to cache files Process_Suspend(processHandle); Cache(&game); } PushSharedMemory->DisableRepeatKeys = game.Settings.DisableRepeatKeys; PushSharedMemory->SwapWASD = game.Settings.SwapWASD; PushSharedMemory->VsyncOverrideMode = game.Settings.VsyncOverrideMode; if (game.Settings.FrameLimit > 1) { PushSharedMemory->FrameLimit = game.Settings.FrameLimit; } // Check if user wants maximum gpu engine and memory clocks if (game.Settings.ForceMaxClocks) { Hardware_ForceMaxClocks(); } if (PushSharedMemory->GameUsesRamDisk) //resume process Process_Resume(processHandle); } else { PushSharedMemory->GameUsesRamDisk = FALSE; } Process_Close(processHandle); //terminate Xpadder unsigned int processId = Process_GetId(L"Xpadder.exe", 0); if (processId) { processHandle = Process_Open(processId, PROCESS_TERMINATE); Process_Terminate(processHandle); Process_Close(processHandle); } PushSharedMemory->OSDFlags |= OSD_FPS; //enable fps counter }
void RichPara::Unpack(const String& data, const Array<RichObject>& obj, const RichPara::Format& style) { part.Clear(); format = style; if(cacheid) { Mutex::Lock __(sCacheMutex); Array<RichPara>& cache = Cache(); for(int i = 0; i < cache.GetCount(); i++) if(cache[i].cacheid == cacheid) { *this = cache[i]; incache = false; cache.Remove(i); return; } } StringStream in(data); dword pattr = in.Get32(); if(pattr & 1) format.align = in.Get16(); if(pattr & 2) format.before = in.Get16(); if(pattr & 4) format.lm = in.Get16(); if(pattr & 8) format.indent = in.Get16(); if(pattr & 0x10) format.rm = in.Get16(); if(pattr & 0x20) format.after = in.Get16(); if(pattr & 0x40) format.bullet = in.Get16(); if(pattr & 0x80) format.keep = in.Get(); if(pattr & 0x100) format.newpage = in.Get(); if(pattr & 0x200) format.tabsize = in.Get16(); if(pattr & 0x400) in % format.label; if(pattr & 0x800) format.keepnext = in.Get(); if(pattr & 0x1000) format.orphan = in.Get(); if(pattr & 0x2000) { in % format.before_number; in % format.after_number; format.reset_number = in.Get(); in.Get(format.number, 8); } if(pattr & 0x4000) { format.linespacing = (int8)in.Get(); } if(pattr & 0x8000) { format.tab.Clear(); int n = in.Get16(); format.tab.Reserve(n); for(int i = 0; i < n; i++) { RichPara::Tab& w = format.tab.Add(); w.pos = in.Get32(); w.align = in.Get(); w.fillchar = in.Get(); } } if(pattr & 0x10000) format.ruler = in.Get16(); if(pattr & 0x20000) format.rulerink.Serialize(in); part.Clear(); int oi = 0; UnpackParts(in, style, part, obj, oi); }
Impl() : cache(Cache()) {}
Impl(CacheFile& cacheFile, std::unordered_map<Poco::URI, Poco::URI> uriMap) : cache(Cache(cacheFile, uriMap)) {}
void GeoResolver::CacheCities (QList<int> ids) { Cache (ids, Cities_, GeoIdType::Country); }
bool DizList::Flush(const string& Path,const string* DizName) { if (!Modified) return true; if (DizName) { strDizFileName = *DizName; } else if (strDizFileName.IsEmpty()) { if (!DizData || !Path) return false; strDizFileName = Path; AddEndSlash(strDizFileName); string strArgName; GetCommaWord(Opt.Diz.strListNames,strArgName); strDizFileName += strArgName; } DWORD FileAttr=apiGetFileAttributes(strDizFileName); if (FileAttr != INVALID_FILE_ATTRIBUTES) { if (FileAttr&FILE_ATTRIBUTE_READONLY) { if(Opt.Diz.ROUpdate) { if(apiSetFileAttributes(strDizFileName,FileAttr)) { FileAttr^=FILE_ATTRIBUTE_READONLY; } } } if(!(FileAttr&FILE_ATTRIBUTE_READONLY)) { #if 1 //Maximus5: На некоторых сетевых устройствах атрибуты вообще не устанавливаются // Поэтому возвращается ошибка, и производится попытка Elevation (что бессмысленно) DisableElevation DE; #endif apiSetFileAttributes(strDizFileName,FILE_ATTRIBUTE_ARCHIVE); } else { Message(MSG_WARNING,1,MSG(MError),MSG(MCannotUpdateDiz),MSG(MCannotUpdateRODiz),MSG(MOk)); return false; } } File DizFile; bool AnyError=false; bool EmptyDiz=true; // Don't use CreationDisposition=CREATE_ALWAYS here - it's kills alternate streams if(DizCount && DizFile.Open(strDizFileName, GENERIC_WRITE, FILE_SHARE_READ, nullptr, FileAttr==INVALID_FILE_ATTRIBUTES?CREATE_NEW:TRUNCATE_EXISTING)) { uintptr_t CodePage = Opt.Diz.SaveInUTF ? CP_UTF8 : (Opt.Diz.AnsiByDefault ? CP_ACP : CP_OEMCP); CachedWrite Cache(DizFile); if (CodePage == CP_UTF8) { DWORD dwSignature = SIGN_UTF8; if(!Cache.Write(&dwSignature, 3)) { AnyError=true; } } if(!AnyError) { for (size_t I=0; I<DizCount; I++) { if (!DizData[I]->Deleted) { DWORD Size=static_cast<DWORD>((DizData[I]->DizText.GetLength()+1)*(CodePage == CP_UTF8?3:1)); //UTF-8, up to 3 bytes per char support char* lpDizText = new char[Size]; if (lpDizText) { int BytesCount=WideCharToMultiByte(CodePage, 0, DizData[I]->DizText, static_cast<int>(DizData[I]->DizText.GetLength()+1), lpDizText, Size, nullptr, nullptr); if (BytesCount && BytesCount-1) { if(Cache.Write(lpDizText, BytesCount-1)) { EmptyDiz=false; } else { AnyError=true; break; } if(!Cache.Write("\r\n", 2)) { AnyError=true; break; } } delete[] lpDizText; } } } } if(!AnyError) { if(!Cache.Flush()) { AnyError=true; } } DizFile.Close(); } if (!EmptyDiz && !AnyError) { if (FileAttr==INVALID_FILE_ATTRIBUTES) { FileAttr=FILE_ATTRIBUTE_ARCHIVE|(Opt.Diz.SetHidden?FILE_ATTRIBUTE_HIDDEN:0); } apiSetFileAttributes(strDizFileName,FileAttr); } else { apiDeleteFile(strDizFileName); if(AnyError) { Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MError),MSG(MCannotUpdateDiz),MSG(MOk)); return false; } } Modified=false; return true; }