//---------------------------------------------------------------------- DWORD MC_TextureManager::update (void) { DWORD numTexturesFreed = 0; currentUsedTextures = 0; for (long i=0;i<MC_MAXTEXTURES;i++) { if ((masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) && (masterTextureNodes[i].gosTextureHandle != 0xffffffff)) { if (!masterTextureNodes[i].uniqueInstance && !(masterTextureNodes[i].neverFLUSH & 1)) //Only uncachable if BIT 1 is set, otherwise, cache 'em out! { if (masterTextureNodes[i].lastUsed <= (turn-60)) { //---------------------------------------------------------------- // Cache this badboy out. Textures don't change. Just Destroy! if (masterTextureNodes[i].gosTextureHandle) gos_DestroyTexture(masterTextureNodes[i].gosTextureHandle); masterTextureNodes[i].gosTextureHandle = CACHED_OUT_HANDLE; numTexturesFreed++; } } //Count ACTUAL number of textures being used. // ALSO can't count on turn being right. Logistics does not update unless simple Camera is up!! if (masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) currentUsedTextures++; } } return numTexturesFreed; }
//---------------------------------------------------------------------- void MC_TextureNode::destroy (void) { if ((gosTextureHandle != CACHED_OUT_HANDLE) && (gosTextureHandle != 0xffffffff) && (gosTextureHandle != 0x0)) { gos_DestroyTexture(gosTextureHandle); } mcTextureManager->textureStringHeap->Free(nodeName); mcTextureManager->textureCacheHeap->Free(textureData); init(); }
//---------------------------------------------------------------------- bool MC_TextureManager::flushCache (void) { bool cacheNotFull = false; totalCacheMisses++; currentUsedTextures = 0; //Count ACTUAL number of textures being used. // ALSO can't count on turn being right. Logistics does not update unless simple Camera is up!! for (long i=0;i<MC_MAXTEXTURES;i++) { if ((masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) && (masterTextureNodes[i].gosTextureHandle != 0xffffffff)) { currentUsedTextures++; } } //If we are now below the magic number, return that the cache is NOT full. if (currentUsedTextures < MAX_MC2_GOS_TEXTURES) return true; for (i=0;i<MC_MAXTEXTURES;i++) { if ((masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) && (masterTextureNodes[i].gosTextureHandle != 0xffffffff) && (!masterTextureNodes[i].uniqueInstance)) { if (masterTextureNodes[i].lastUsed <= (turn-cache_Threshold)) { //---------------------------------------------------------------- // Cache this badboy out. Textures don't change. Just Destroy! if (masterTextureNodes[i].gosTextureHandle) gos_DestroyTexture(masterTextureNodes[i].gosTextureHandle); masterTextureNodes[i].gosTextureHandle = CACHED_OUT_HANDLE; currentUsedTextures--; cacheNotFull = true; return cacheNotFull; } } } for (i=0;i<MC_MAXTEXTURES;i++) { if ((masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) && (masterTextureNodes[i].gosTextureHandle != 0xffffffff) && (masterTextureNodes[i].gosTextureHandle) && (!masterTextureNodes[i].uniqueInstance)) { if (masterTextureNodes[i].lastUsed <= (turn-30)) { //---------------------------------------------------------------- // Cache this badboy out. Textures don't change. Just Destroy! if (masterTextureNodes[i].gosTextureHandle) gos_DestroyTexture(masterTextureNodes[i].gosTextureHandle); masterTextureNodes[i].gosTextureHandle = CACHED_OUT_HANDLE; currentUsedTextures--; cacheNotFull = true; return cacheNotFull; } } } for (i=0;i<MC_MAXTEXTURES;i++) { if ((masterTextureNodes[i].gosTextureHandle != CACHED_OUT_HANDLE) && (masterTextureNodes[i].gosTextureHandle != 0xffffffff) && (!masterTextureNodes[i].uniqueInstance)) { if (masterTextureNodes[i].lastUsed <= (turn-1)) { //---------------------------------------------------------------- // Cache this badboy out. Textures don't change. Just Destroy! if (masterTextureNodes[i].gosTextureHandle) gos_DestroyTexture(masterTextureNodes[i].gosTextureHandle); masterTextureNodes[i].gosTextureHandle = CACHED_OUT_HANDLE; currentUsedTextures--; cacheNotFull = true; return cacheNotFull; } } } //gosASSERT(cacheNotFull); return cacheNotFull; }
bool ForceGroupBar::setPilotVideo( const char* pVideo, MechWarrior* pPilot ) { if ( !pVideo ) { if ( ForceGroupIcon::bMovie ) { delete ForceGroupIcon::bMovie; ForceGroupIcon::bMovie = NULL; } else if ( ForceGroupIcon::pilotVideoTexture ) gos_DestroyTexture( ForceGroupIcon::pilotVideoTexture ); ForceGroupIcon::pilotVideoTexture = 0; ForceGroupIcon::pilotVideoPilot = 0; } else if (ForceGroupIcon::bMovie || ControlGui::instance->isMoviePlaying() || ForceGroupIcon::pilotVideoTexture || !prefs.pilotVideos) { // one already playing... // OR we don't want them playing. return 0; } else { for ( int i = 0; i < iconCount; i++ ) { if ( icons[i] && icons[i]->unit->getPilot() == pPilot ) { ForceGroupIcon::pilotVideoPilot = pPilot; FullPathFileName aviPath; aviPath.init( moviePath, pVideo, ".bik" ); if ( (frameRate > 15.0) && fileExists(aviPath) && prefs.pilotVideos) // This is about correct. Slower then this and movie has hard time keeping up! { //Update the RECT every frame. What if we shift Icons around cause someone died!! RECT vRect; vRect.left = icons[i]->bmpLocation[icons[i]->locationIndex][1].x; vRect.right = icons[i]->pilotLocation[icons[i]->locationIndex][2]; vRect.top = icons[i]->bmpLocation[icons[i]->locationIndex][3].y; vRect.bottom = icons[i]->bmpLocation[icons[i]->locationIndex][1].y; ForceGroupIcon::bMovie = new MC2Movie; ForceGroupIcon::bMovie->init(aviPath,vRect,true); } else // make a still texture { char realPilotName[9]; //Set everything to zero so the strncpy below doesn't go off into LALA land!! memset(realPilotName,0,9); strncpy(realPilotName,pPilot->getName(),8); FullPathFileName path; path.init( moviePath, realPilotName, ".tga" ); if (fileExists(path)) ForceGroupIcon::pilotVideoTexture = gos_NewTextureFromFile( gos_Texture_Solid, path, 0 ); else { char realMovieName[256]; char realMoviePath[1024]; _splitpath(path,NULL,realMoviePath,realMovieName,NULL); //Not in main installed directory and not in fastfile. Look on CD. char actualPath[2048]; strcpy(actualPath,CDInstallPath); strcat(actualPath,realMoviePath); strcat(actualPath,realMovieName); strcat(actualPath,".tga"); bool fileThere = fileExists(actualPath); if (fileThere) ForceGroupIcon::pilotVideoTexture = gos_NewTextureFromFile( gos_Texture_Solid, actualPath, 0 ); bool openFailed = false; while (!fileThere) { openFailed = true; EnterWindowMode(); char data[2048]; char msg[1024]; char msg1[512]; char title[256]; cLoadString(IDS_MC2_movieMISSING,msg1,511); cLoadString(IDS_MC2_CDMISSING,msg,1023); cLoadString(IDS_MC2_MISSING_TITLE,title,255); sprintf(data,msg1,path,msg); DWORD result = MessageBox(NULL,data,title,MB_OKCANCEL | MB_ICONWARNING); if (result == IDCANCEL) { ExitGameOS(); return 1; } fileThere = fileExists(actualPath); if (fileThere) ForceGroupIcon::pilotVideoTexture = gos_NewTextureFromFile( gos_Texture_Solid, actualPath, 0 ); } if (openFailed && (Environment.fullScreen == 0) && prefs.fullScreen) EnterFullScreenMode(); } } break; } } } return 1; }