Changeset 144 for binary-improvements/7dtd-server-fixes/src/MapRendering
- Timestamp:
- Aug 30, 2014, 6:11:18 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/MapRendering
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/MapRendering/Constants.cs
r143 r144 3 3 namespace AllocsFixes.MapRendering 4 4 { 5 public class Constants5 public static class Constants 6 6 { 7 7 public const int MAP_BLOCK_SIZE = 128; -
binary-improvements/7dtd-server-fixes/src/MapRendering/MapRendering.cs
r143 r144 36 36 37 37 chunkSaveTimer.AutoReset = false; 38 chunkSaveTimer.Elapsed += new System.Timers.ElapsedEventHandler ( RenderDirtyChunks);38 chunkSaveTimer.Elapsed += new System.Timers.ElapsedEventHandler (TimedRendering); 39 39 } 40 40 … … 130 130 } 131 131 } 132 133 while (dirtyChunks.Count > 0) { 134 RenderDirtyChunks (); 135 } 136 132 137 Log.Out (String.Format ("RenderMap: {0}/{1} ({2}%)", curFullMapPos.x, widthPix, (int)((float)curFullMapPos.x / widthPix * 100))); 133 138 } 134 139 } finally { 135 140 Monitor.Exit (Instance.zoomLevelBuffers); 136 }137 int totalDirtyCount = dirtyChunks.Count;138 Log.Out (String.Format ("Rendering chunks: {0}/{1} ({2}%)", totalDirtyCount - dirtyChunks.Count, totalDirtyCount, (int)((float)(totalDirtyCount - dirtyChunks.Count) / totalDirtyCount * 100)));139 while (dirtyChunks.Count > 0) {140 RenderDirtyChunks (null, null);141 Log.Out (String.Format ("Rendering chunks: {0}/{1} ({2}%)", totalDirtyCount - dirtyChunks.Count, totalDirtyCount, (int)((float)(totalDirtyCount - dirtyChunks.Count) / totalDirtyCount * 100)));142 141 } 143 142 … … 162 161 } 163 162 164 private void RenderDirtyChunks(object source, System.Timers.ElapsedEventArgs e)163 private void TimedRendering (object source, System.Timers.ElapsedEventArgs e) 165 164 { 166 165 Monitor.Enter (zoomLevelBuffers); 167 166 try { 168 msw.ResetAndRestart (); 169 170 if (dirtyChunks.Count > 0) { 171 List<Vector2i> keys = new List<Vector2i> (dirtyChunks.Keys); 172 List<Vector2i> chunksDone = new List<Vector2i> (); 173 174 Vector2i chunkPos = keys [0]; 175 chunksDone.Add (chunkPos); 176 177 //Log.Out ("Start Dirty: " + chunkPos); 178 179 Vector2i block, blockOffset; 180 getBlockNumber (chunkPos, out block, out blockOffset, Constants.MAP_BLOCK_TO_CHUNK_DIV, Constants.MAP_CHUNK_SIZE); 181 182 zoomLevelBuffers [Constants.ZOOMLEVELS - 1].LoadBlock (block); 183 184 Vector2i v_block, v_blockOffset; 185 foreach (Vector2i v in keys) { 186 getBlockNumber (v, out v_block, out v_blockOffset, Constants.MAP_BLOCK_TO_CHUNK_DIV, Constants.MAP_CHUNK_SIZE); 187 if (v_block.Equals (block)) { 188 //Log.Out ("Dirty: " + v + " render: true"); 189 chunksDone.Add (v); 190 zoomLevelBuffers [Constants.ZOOMLEVELS - 1].SetPart (v_blockOffset, Constants.MAP_CHUNK_SIZE, dirtyChunks [v]); 191 } else { 192 //Log.Out ("Dirty: " + v + " render: false"); 193 } 194 } 195 196 foreach (Vector2i v in chunksDone) 197 dirtyChunks.Remove (v); 198 199 RenderZoomLevel (Constants.ZOOMLEVELS - 1, block); 200 201 SaveAllBlockMaps (null, null); 202 } 203 204 if (e != null) 167 RenderDirtyChunks (); 205 168 if (dirtyChunks.Count > 0) 206 169 Instance.chunkSaveTimer.Start (); 207 170 } finally { 208 171 Monitor.Exit (zoomLevelBuffers); 172 } 173 } 174 175 private void RenderDirtyChunks () 176 { 177 msw.ResetAndRestart (); 178 179 if (dirtyChunks.Count > 0) { 180 List<Vector2i> keys = new List<Vector2i> (dirtyChunks.Keys); 181 List<Vector2i> chunksDone = new List<Vector2i> (); 182 183 Vector2i chunkPos = keys [0]; 184 chunksDone.Add (chunkPos); 185 186 //Log.Out ("Start Dirty: " + chunkPos); 187 188 Vector2i block, blockOffset; 189 getBlockNumber (chunkPos, out block, out blockOffset, Constants.MAP_BLOCK_TO_CHUNK_DIV, Constants.MAP_CHUNK_SIZE); 190 191 zoomLevelBuffers [Constants.ZOOMLEVELS - 1].LoadBlock (block); 192 193 Vector2i v_block, v_blockOffset; 194 foreach (Vector2i v in keys) { 195 getBlockNumber (v, out v_block, out v_blockOffset, Constants.MAP_BLOCK_TO_CHUNK_DIV, Constants.MAP_CHUNK_SIZE); 196 if (v_block.Equals (block)) { 197 //Log.Out ("Dirty: " + v + " render: true"); 198 chunksDone.Add (v); 199 zoomLevelBuffers [Constants.ZOOMLEVELS - 1].SetPart (v_blockOffset, Constants.MAP_CHUNK_SIZE, dirtyChunks [v]); 200 } else { 201 //Log.Out ("Dirty: " + v + " render: false"); 202 } 203 } 204 205 foreach (Vector2i v in chunksDone) 206 dirtyChunks.Remove (v); 207 208 RenderZoomLevel (Constants.ZOOMLEVELS - 1, block); 209 210 SaveAllBlockMaps (null, null); 209 211 } 210 212 }
Note:
See TracChangeset
for help on using the changeset viewer.