public void tileBackdropArrived(Tile tile) { // the backdrop may arrive when the tile has been phased out due to TileSet.ReTile() // the tile then hangs around as a means to pass backdrop to TileSet, which is supposed // to find appropriate location for the backdrop. bool found = false; #if DEBUG LibSys.StatusBar.Trace("TileSet::tileBackdropArrived() - " + tile.ToString()); #endif lock (tilesLock) { for (int vv = 0; vv < m_vCount; vv++) { for (int hh = 0; hh < m_hCount; hh++) { Tile tt = m_tiles[vv, hh]; //LibSys.StatusBar.Trace(" = " + tt.baseName + " UseSubstitute=" + tt.UseSubstitute + " SubstituteName=" + tt.SubstituteName); if (tt == tile) { // tile still in the array #if DEBUG LibSys.StatusBar.Trace(" - still in array : " + tt.baseName); #endif if (tt.UseSubstitute && tile.backdrop.HasImage && tt.SubstituteRectangle.IsEmpty) { tt.CalculateSubstituteRectangle(); } ArrangeBackdropRedraw(tt); found = true; } else if ((!tt.UseSubstitute && tt.baseName.Equals(tile.baseName)) || (tt.UseSubstitute && tile.UseSubstitute && tt.SubstituteName.Equals(tile.SubstituteName))) { // tile has been replaced by another tile with the same base name (due to ReTile()) #if DEBUG LibSys.StatusBar.Trace(" - " + tt.baseName + " - replaced by " + tile.baseName + " " + tile.backdrop); #endif tt.backdrop = tile.backdrop; if (!tt.baseName.Equals(tile.baseName)) { //tt.backdrop.MarkUsed(); tt.CalculateSubstituteRectangle(); } ArrangeBackdropRedraw(tt); found = true; } if (found && !tt.MayUseSubstitute) { goto endLoop; } } } endLoop: ; } // lock // tile not found - bitmap/backdrop stays in file system and cache for the future. }