Ignore:
Timestamp:
Jul 3, 2015, 4:16:11 PM (10 years ago)
Author:
alloc
Message:

Server fixes for A12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/MapRendering/MapRendering/MapRendering.cs

    r235 r238  
    2424                private static object lockObject = new object ();
    2525                private MapRenderBlockBuffer[] zoomLevelBuffers;
    26                 private Dictionary<Vector2i, Color[]> dirtyChunks = new Dictionary<Vector2i, Color[]> ();
     26                private Dictionary<Vector2i, Color32[]> dirtyChunks = new Dictionary<Vector2i, Color32[]> ();
    2727                private System.Timers.Timer chunkSaveTimer = new System.Timers.Timer (500);
    2828                private bool renderingFullMap = false;
     
    3737                private MapRendering ()
    3838                {
    39                         Constants.MAP_DIRECTORY = StaticDirectories.GetSaveGameDir () + "/map";
     39                        Constants.MAP_DIRECTORY = GameUtils.GetSaveGameDir () + "/map";
    4040
    4141                        lock (lockObject) {
     
    6969                                                                ushort[] mapColors = c.GetMapColors ();
    7070                                                                if (mapColors != null) {
    71                                                                         Color[] realColors = new Color[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];
     71                                                                        Color32[] realColors = new Color32[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];
    7272                                                                        for (int i_colors = 0; i_colors < mapColors.Length; i_colors++) {
    73                                                                                 realColors [i_colors] = shortColorToColor (mapColors [i_colors]);
     73                                                                                realColors [i_colors] = shortColorToColor32 (mapColors [i_colors]);
    7474                                                                        }
    7575                                                                        Instance.dirtyChunks [cPos2] = realColors;
     
    9191                        MicroStopwatch microStopwatch = new MicroStopwatch ();
    9292
    93                         string regionSaveDir = StaticDirectories.GetSaveGameRegionDir ();
     93                        string regionSaveDir = GameUtils.GetSaveGameRegionDir ();
    9494                        RegionFileManager rfm = new RegionFileManager (regionSaveDir, regionSaveDir, 0, false);
    9595                        Texture2D fullMapTexture = null;
     
    119119                                renderingFullMap = true;
    120120
    121                                 if (widthPix <= 8000 && heightPix <= 8000)
     121                                if (widthPix <= 8192 && heightPix <= 8192)
    122122                                        fullMapTexture = new Texture2D (widthPix, heightPix);
    123123
     
    135135                                                                ushort[] mapColors = c.GetMapColors ();
    136136                                                                if (mapColors != null) {
    137                                                                         Color[] realColors = new Color[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];
     137                                                                        Color32[] realColors = new Color32[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];
    138138                                                                        for (int i_colors = 0; i_colors < mapColors.Length; i_colors++) {
    139                                                                                 realColors [i_colors] = shortColorToColor (mapColors [i_colors]);
     139                                                                                realColors [i_colors] = shortColorToColor32 (mapColors [i_colors]);
    140140                                                                        }
    141141                                                                        dirtyChunks [curChunkPos] = realColors;
    142142                                                                        if (fullMapTexture != null)
    143                                                                                 fullMapTexture.SetPixels (curFullMapPos.x, curFullMapPos.y, Constants.MAP_CHUNK_SIZE, Constants.MAP_CHUNK_SIZE, realColors);
     143                                                                                fullMapTexture.SetPixels32 (curFullMapPos.x, curFullMapPos.y, Constants.MAP_CHUNK_SIZE, Constants.MAP_CHUNK_SIZE, realColors);
    144144                                                                }
    145145                                                        }
     
    160160                                byte[] array = fullMapTexture.EncodeToPNG ();
    161161                                File.WriteAllBytes (Constants.MAP_DIRECTORY + "/map.png", array);
    162                                 Texture2D.Destroy (fullMapTexture);
     162                                UnityEngine.Object.Destroy (fullMapTexture);
    163163                                fullMapTexture = null;
    164164                        }
     
    337337                }
    338338
     339                private static Color32 shortColorToColor32 (ushort col)
     340                {
     341                        byte r = (byte)(256 * (col >> 10 & 31) / 32);
     342                        byte g = (byte)(256 * (col >> 5 & 31) / 32);
     343                        byte b = (byte)(256 * (col & 31) / 32);
     344                        byte a = 255;
     345                        return new Color32 (r, g, b, a);
     346                }
    339347        }
    340348}
Note: See TracChangeset for help on using the changeset viewer.