diff options
author | Justin Clarke Casey | 2008-08-09 22:04:42 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-08-09 22:04:42 +0000 |
commit | 03f9a3e1d6de6fa4d8fe0d1b71845b57b15f9d50 (patch) | |
tree | b721c2f2f63322544ef3fa46c28077196625b3fc /OpenSim/Region | |
parent | * Remove warnings (diff) | |
download | opensim-SC-03f9a3e1d6de6fa4d8fe0d1b71845b57b15f9d50.zip opensim-SC-03f9a3e1d6de6fa4d8fe0d1b71845b57b15f9d50.tar.gz opensim-SC-03f9a3e1d6de6fa4d8fe0d1b71845b57b15f9d50.tar.bz2 opensim-SC-03f9a3e1d6de6fa4d8fe0d1b71845b57b15f9d50.tar.xz |
* if the user uuid is present, preserve ownership information when loading an archive
* if the uuid isn't present, ownership is given to the region's master avatar
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index b0e5f96..2b1a4ed 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -48,10 +48,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | 51 | private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); |
52 | 52 | ||
53 | protected Scene m_scene; | 53 | private Scene m_scene; |
54 | protected string m_loadPath; | 54 | private string m_loadPath; |
55 | |||
56 | /// <summary> | ||
57 | /// Used to cache lookups for valid uuids. | ||
58 | /// </summary> | ||
59 | private IDictionary<LLUUID, bool> m_validUserUuids = new Dictionary<LLUUID, bool>(); | ||
55 | 60 | ||
56 | public ArchiveReadRequest(Scene scene, string loadPath) | 61 | public ArchiveReadRequest(Scene scene, string loadPath) |
57 | { | 62 | { |
@@ -61,7 +66,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
61 | DearchiveRegion(); | 66 | DearchiveRegion(); |
62 | } | 67 | } |
63 | 68 | ||
64 | protected void DearchiveRegion() | 69 | private void DearchiveRegion() |
65 | { | 70 | { |
66 | TarArchiveReader archive | 71 | TarArchiveReader archive |
67 | = new TarArchiveReader( | 72 | = new TarArchiveReader( |
@@ -129,13 +134,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
129 | // to the same scene (when this is possible). | 134 | // to the same scene (when this is possible). |
130 | sceneObject.ResetIDs(); | 135 | sceneObject.ResetIDs(); |
131 | 136 | ||
132 | // Make the master the owner/creator of everything imported for now | 137 | // Try to retain the original creator/owner/lastowner if their uuid is present on this grid |
138 | // otherwise, use the master avatar uuid instead | ||
133 | LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; | 139 | LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
134 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 140 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
135 | { | 141 | { |
136 | part.CreatorID = masterAvatarId; | 142 | if (!resolveUserUuid(part.CreatorID)) |
137 | part.OwnerID = masterAvatarId; | 143 | part.CreatorID = masterAvatarId; |
138 | part.LastOwnerID = masterAvatarId; | 144 | |
145 | if (!resolveUserUuid(part.OwnerID)) | ||
146 | part.OwnerID = masterAvatarId; | ||
147 | |||
148 | if (!resolveUserUuid(part.LastOwnerID)) | ||
149 | part.LastOwnerID = masterAvatarId; | ||
150 | |||
139 | // And zap any troublesome sit target information | 151 | // And zap any troublesome sit target information |
140 | part.SitTargetOrientation = new Quaternion(0,0,0,1); | 152 | part.SitTargetOrientation = new Quaternion(0,0,0,1); |
141 | part.SitTargetPosition = new Vector3(0,0,0); | 153 | part.SitTargetPosition = new Vector3(0,0,0); |
@@ -163,6 +175,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
163 | sceneObject.CreateScriptInstances(0, true); | 175 | sceneObject.CreateScriptInstances(0, true); |
164 | } | 176 | } |
165 | } | 177 | } |
178 | |||
179 | /// <summary> | ||
180 | /// Look up the given user id to check whether it's one that is valid for this grid. | ||
181 | /// </summary> | ||
182 | /// <param name="uuid"></param> | ||
183 | /// <returns></returns> | ||
184 | private bool resolveUserUuid(LLUUID uuid) | ||
185 | { | ||
186 | if (!m_validUserUuids.ContainsKey(uuid)) | ||
187 | { | ||
188 | if (m_scene.CommsManager.UserService.GetUserProfile(uuid) != null) | ||
189 | m_validUserUuids.Add(uuid, true); | ||
190 | else | ||
191 | m_validUserUuids.Add(uuid, false); | ||
192 | } | ||
193 | |||
194 | if (m_validUserUuids[uuid]) | ||
195 | return true; | ||
196 | else | ||
197 | return false; | ||
198 | } | ||
166 | 199 | ||
167 | /// <summary> | 200 | /// <summary> |
168 | /// Load an asset | 201 | /// Load an asset |
@@ -170,7 +203,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
170 | /// <param name="assetFilename"></param> | 203 | /// <param name="assetFilename"></param> |
171 | /// <param name="data"></param> | 204 | /// <param name="data"></param> |
172 | /// <returns>true if asset was successfully loaded, false otherwise</returns> | 205 | /// <returns>true if asset was successfully loaded, false otherwise</returns> |
173 | protected bool LoadAsset(string assetPath, byte[] data) | 206 | private bool LoadAsset(string assetPath, byte[] data) |
174 | { | 207 | { |
175 | // Right now we're nastily obtaining the lluuid from the filename | 208 | // Right now we're nastily obtaining the lluuid from the filename |
176 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); | 209 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); |
@@ -209,7 +242,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
209 | /// <returns> | 242 | /// <returns> |
210 | /// true if terrain was resolved successfully, false otherwise. | 243 | /// true if terrain was resolved successfully, false otherwise. |
211 | /// </returns> | 244 | /// </returns> |
212 | protected bool LoadTerrain(string terrainPath, byte[] data) | 245 | private bool LoadTerrain(string terrainPath, byte[] data) |
213 | { | 246 | { |
214 | ITerrainModule terrainModule = m_scene.RequestModuleInterface<ITerrainModule>(); | 247 | ITerrainModule terrainModule = m_scene.RequestModuleInterface<ITerrainModule>(); |
215 | 248 | ||