diff options
author | UbitUmarov | 2015-08-23 18:10:51 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-23 18:10:51 +0100 |
commit | f4719cfe1b7b7938f5319fb37d219c93bb857984 (patch) | |
tree | a564d64eb844c1f0f16cdd2a293fc3a866590687 | |
parent | add missing culture format on lslvector toString (diff) | |
download | opensim-SC_OLD-f4719cfe1b7b7938f5319fb37d219c93bb857984.zip opensim-SC_OLD-f4719cfe1b7b7938f5319fb37d219c93bb857984.tar.gz opensim-SC_OLD-f4719cfe1b7b7938f5319fb37d219c93bb857984.tar.bz2 opensim-SC_OLD-f4719cfe1b7b7938f5319fb37d219c93bb857984.tar.xz |
fix db region search by a position, for varregions ( ignoring other that
mysql for now )
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 2ad7590..fab0318 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL | |||
82 | 82 | ||
83 | public RegionData Get(int posX, int posY, UUID scopeID) | 83 | public RegionData Get(int posX, int posY, UUID scopeID) |
84 | { | 84 | { |
85 | /* fixed size regions | ||
85 | string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; | 86 | string command = "select * from `"+m_Realm+"` where locX = ?posX and locY = ?posY"; |
86 | if (scopeID != UUID.Zero) | 87 | if (scopeID != UUID.Zero) |
87 | command += " and ScopeID = ?scopeID"; | 88 | command += " and ScopeID = ?scopeID"; |
@@ -98,6 +99,45 @@ namespace OpenSim.Data.MySQL | |||
98 | 99 | ||
99 | return ret[0]; | 100 | return ret[0]; |
100 | } | 101 | } |
102 | */ | ||
103 | // extend database search for maximum region size area | ||
104 | string command = "select * from `" + m_Realm + "` where locX between ?startX and ?endX and locY between ?startY and ?endY"; | ||
105 | if (scopeID != UUID.Zero) | ||
106 | command += " and ScopeID = ?scopeID"; | ||
107 | |||
108 | int startX = posX - (int)Constants.MaximumRegionSize; | ||
109 | int startY = posY - (int)Constants.MaximumRegionSize; | ||
110 | int endX = posX; | ||
111 | int endY = posY; | ||
112 | |||
113 | List<RegionData> ret; | ||
114 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
115 | { | ||
116 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); | ||
117 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); | ||
118 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
119 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
120 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
121 | |||
122 | ret = RunCommand(cmd); | ||
123 | } | ||
124 | |||
125 | if (ret.Count == 0) | ||
126 | return null; | ||
127 | |||
128 | // find the first that contains pos | ||
129 | RegionData rg = null; | ||
130 | foreach (RegionData r in ret) | ||
131 | { | ||
132 | if (posX >= r.posX && posX < r.posX + r.sizeX | ||
133 | && posY >= r.posY && posY < r.posY + r.sizeY) | ||
134 | { | ||
135 | rg = r; | ||
136 | break; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | return rg; | ||
101 | } | 141 | } |
102 | 142 | ||
103 | public RegionData Get(UUID regionID, UUID scopeID) | 143 | public RegionData Get(UUID regionID, UUID scopeID) |