Changeset 238 for binary-improvements/MapRendering
- Timestamp:
- Jul 3, 2015, 4:16:11 PM (9 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/MapRendering/MapRenderBlockBuffer.cs
r233 r238 53 53 } 54 54 55 public void SetPart (Vector2i offset, int partSize, Color [] pixels) {55 public void SetPart (Vector2i offset, int partSize, Color32[] pixels) { 56 56 if (offset.x + partSize > blockMap.width || offset.y + partSize > blockMap.height) { 57 57 Log.Error (string.Format ("MapBlockBuffer[{0}].SetPart ({1}, {2}, {3}) has blockMap.size ({4}/{5})", zoomLevel, offset, partSize, pixels.Length, blockMap.width, blockMap.height)); 58 58 return; 59 59 } 60 blockMap.SetPixels (offset.x, offset.y, partSize, partSize, pixels);60 blockMap.SetPixels32 (offset.x, offset.y, partSize, partSize, pixels); 61 61 } 62 62 63 public Color [] GetHalfScaled ()63 public Color32[] GetHalfScaled () 64 64 { 65 65 zoomBuffer.Resize (Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE); 66 zoomBuffer.SetPixels (blockMap.GetPixels());66 zoomBuffer.SetPixels32 (blockMap.GetPixels32 ()); 67 67 68 68 TextureScale.Point (zoomBuffer, Constants.MAP_BLOCK_SIZE / 2, Constants.MAP_BLOCK_SIZE / 2); 69 69 70 return zoomBuffer.GetPixels ();70 return zoomBuffer.GetPixels32 (); 71 71 } 72 72 -
binary-improvements/MapRendering/MapRendering/MapRendering.cs
r235 r238 24 24 private static object lockObject = new object (); 25 25 private MapRenderBlockBuffer[] zoomLevelBuffers; 26 private Dictionary<Vector2i, Color []> dirtyChunks = new Dictionary<Vector2i, Color[]> ();26 private Dictionary<Vector2i, Color32[]> dirtyChunks = new Dictionary<Vector2i, Color32[]> (); 27 27 private System.Timers.Timer chunkSaveTimer = new System.Timers.Timer (500); 28 28 private bool renderingFullMap = false; … … 37 37 private MapRendering () 38 38 { 39 Constants.MAP_DIRECTORY = StaticDirectories.GetSaveGameDir () + "/map";39 Constants.MAP_DIRECTORY = GameUtils.GetSaveGameDir () + "/map"; 40 40 41 41 lock (lockObject) { … … 69 69 ushort[] mapColors = c.GetMapColors (); 70 70 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]; 72 72 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]); 74 74 } 75 75 Instance.dirtyChunks [cPos2] = realColors; … … 91 91 MicroStopwatch microStopwatch = new MicroStopwatch (); 92 92 93 string regionSaveDir = StaticDirectories.GetSaveGameRegionDir ();93 string regionSaveDir = GameUtils.GetSaveGameRegionDir (); 94 94 RegionFileManager rfm = new RegionFileManager (regionSaveDir, regionSaveDir, 0, false); 95 95 Texture2D fullMapTexture = null; … … 119 119 renderingFullMap = true; 120 120 121 if (widthPix <= 8 000 && heightPix <= 8000)121 if (widthPix <= 8192 && heightPix <= 8192) 122 122 fullMapTexture = new Texture2D (widthPix, heightPix); 123 123 … … 135 135 ushort[] mapColors = c.GetMapColors (); 136 136 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]; 138 138 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]); 140 140 } 141 141 dirtyChunks [curChunkPos] = realColors; 142 142 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); 144 144 } 145 145 } … … 160 160 byte[] array = fullMapTexture.EncodeToPNG (); 161 161 File.WriteAllBytes (Constants.MAP_DIRECTORY + "/map.png", array); 162 Texture2D.Destroy (fullMapTexture);162 UnityEngine.Object.Destroy (fullMapTexture); 163 163 fullMapTexture = null; 164 164 } … … 337 337 } 338 338 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 } 339 347 } 340 348 } -
binary-improvements/MapRendering/ModInfo.xml
r236 r238 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value=" 3" />7 <Version value="4" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/API/GetLandClaims.cs
r230 r238 29 29 result.Add ("claimowners", claimOwners); 30 30 31 Dictionary<Vector3i, PersistentPlayerData> d = GameManager.Instance.GetPersistentPlayerList (). positionToLPBlockOwner;31 Dictionary<Vector3i, PersistentPlayerData> d = GameManager.Instance.GetPersistentPlayerList ().m_lpBlockMap; 32 32 if (d != null) { 33 33 World w = GameManager.Instance.World; … … 45 45 if (steamid.Length == 0 || kvp.Key.PlayerId.Equals (steamid)) { 46 46 string curID = kvp.Key.PlayerId; 47 bool isActive = w. LandClaimIsActive(kvp.Key);47 bool isActive = w.IsLandProtectionValidForPlayer (kvp.Key); 48 48 49 49 JSONObject owner = new JSONObject (); -
binary-improvements/MapRendering/Web/Web.cs
r230 r238 56 56 57 57 handlers.Add ( 58 "/itemicons/", 59 new ItemIconHandler ( 60 "/itemicons/", 61 true) 62 ); 63 64 handlers.Add ( 58 65 "/map/", 59 66 new StaticHandler ( 60 67 "/map/", 61 StaticDirectories.GetSaveGameDir () + "/map",68 GameUtils.GetSaveGameDir () + "/map", 62 69 MapRendering.MapRendering.GetTileCache (), 63 70 false) -
binary-improvements/MapRendering/WebAndMapRendering.csproj
r230 r238 59 59 <Compile Include="Web\API\GetLandClaims.cs" /> 60 60 <Compile Include="Commands\webstat.cs" /> 61 <Compile Include="Web\ItemIconHandler.cs" /> 61 62 </ItemGroup> 62 63 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Note:
See TracChangeset
for help on using the changeset viewer.