diff options
author | Adam Frisby | 2007-10-25 15:17:42 +0000 |
---|---|---|
committer | Adam Frisby | 2007-10-25 15:17:42 +0000 |
commit | 6804f9affba63e8f39f207769f026e9fcda70d94 (patch) | |
tree | 0e6c94f9ed6b58ba0aff545a412de193497f4103 /OpenSim | |
parent | * Added XMLRPC Controller Module to OpenSimMain which allows XML-RPC queries ... (diff) | |
download | opensim-SC_OLD-6804f9affba63e8f39f207769f026e9fcda70d94.zip opensim-SC_OLD-6804f9affba63e8f39f207769f026e9fcda70d94.tar.gz opensim-SC_OLD-6804f9affba63e8f39f207769f026e9fcda70d94.tar.bz2 opensim-SC_OLD-6804f9affba63e8f39f207769f026e9fcda70d94.tar.xz |
* Added static mutex to terrain load-tile to prevent file IO locking issues.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index d010a03..c8c6e51 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -51,6 +51,8 @@ namespace OpenSim.Region.Terrain | |||
51 | 51 | ||
52 | public class TerrainEngine | 52 | public class TerrainEngine |
53 | { | 53 | { |
54 | public static System.Threading.Mutex fileIOLock = new System.Threading.Mutex(); | ||
55 | |||
54 | /// <summary> | 56 | /// <summary> |
55 | /// Plugin library for scripts | 57 | /// Plugin library for scripts |
56 | /// </summary> | 58 | /// </summary> |
@@ -731,36 +733,45 @@ namespace OpenSim.Region.Terrain | |||
731 | /// <param name="lowerboundY">Where do the region coords start for this terrain?</param> | 733 | /// <param name="lowerboundY">Where do the region coords start for this terrain?</param> |
732 | public void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY) | 734 | public void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY) |
733 | { | 735 | { |
734 | int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); | 736 | fileIOLock.WaitOne(); |
735 | int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); | 737 | try |
738 | { | ||
736 | 739 | ||
737 | double[,] tempMap = new double[dimensionX, dimensionY]; | 740 | int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); |
741 | int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); | ||
738 | 742 | ||
739 | FileInfo file = new FileInfo(filename); | 743 | double[,] tempMap = new double[dimensionX, dimensionY]; |
740 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
741 | BinaryReader bs = new BinaryReader(s); | ||
742 | 744 | ||
743 | int x, y; | 745 | FileInfo file = new FileInfo(filename); |
744 | for (x = 0; x < dimensionX; x++) | 746 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
745 | { | 747 | BinaryReader bs = new BinaryReader(s); |
746 | for (y = 0; y < dimensionY; y++) | 748 | |
749 | int x, y; | ||
750 | for (x = 0; x < dimensionX; x++) | ||
747 | { | 751 | { |
748 | tempMap[x,y] = (double)bs.ReadSingle(); | 752 | for (y = 0; y < dimensionY; y++) |
753 | { | ||
754 | tempMap[x, y] = (double)bs.ReadSingle(); | ||
755 | } | ||
749 | } | 756 | } |
750 | } | ||
751 | 757 | ||
752 | for (y = 0; y < h; y++) | 758 | for (y = 0; y < h; y++) |
753 | { | ||
754 | for (x = 0; x < w; x++) | ||
755 | { | 759 | { |
756 | heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]); | 760 | for (x = 0; x < w; x++) |
761 | { | ||
762 | heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]); | ||
763 | } | ||
757 | } | 764 | } |
758 | } | ||
759 | 765 | ||
760 | bs.Close(); | 766 | bs.Close(); |
761 | s.Close(); | 767 | s.Close(); |
762 | 768 | ||
763 | tainted++; | 769 | tainted++; |
770 | } | ||
771 | finally | ||
772 | { | ||
773 | fileIOLock.ReleaseMutex(); | ||
774 | } | ||
764 | } | 775 | } |
765 | 776 | ||
766 | /// <summary> | 777 | /// <summary> |