aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie Thielker2009-04-18 19:08:35 +0000
committerMelanie Thielker2009-04-18 19:08:35 +0000
commitd285ccb5cfdfca3128e2eef4f5185714a54a7a66 (patch)
treec5432695c51870dc893ce6fde9a96a83966d93da
parentThank you kindly, RemedyTomm for a patch that: (diff)
downloadopensim-SC_OLD-d285ccb5cfdfca3128e2eef4f5185714a54a7a66.zip
opensim-SC_OLD-d285ccb5cfdfca3128e2eef4f5185714a54a7a66.tar.gz
opensim-SC_OLD-d285ccb5cfdfca3128e2eef4f5185714a54a7a66.tar.bz2
opensim-SC_OLD-d285ccb5cfdfca3128e2eef4f5185714a54a7a66.tar.xz
Allow reading of notecards by asset ID.
Fixes Manthis #3420
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs160
1 files changed, 108 insertions, 52 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6a5777c..56d7d50 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -9167,41 +9167,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9167 } 9167 }
9168 9168
9169 public LSL_String llGetNumberOfNotecardLines(string name) 9169 public LSL_String llGetNumberOfNotecardLines(string name)
9170 { 9170 {
9171 m_host.AddScriptLPS(1); 9171 m_host.AddScriptLPS(1);
9172 9172
9173 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9173 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9174 9174
9175 foreach (TaskInventoryItem item in itemsDictionary.Values) 9175 UUID assetID = UUID.Zero;
9176
9177 if (!UUID.TryParse(name, out assetID))
9176 { 9178 {
9177 if (item.Type == 7 && item.Name == name) 9179 foreach (TaskInventoryItem item in itemsDictionary.Values)
9178 { 9180 {
9179 UUID tid = AsyncCommands. 9181 if (item.Type == 7 && item.Name == name)
9180 DataserverPlugin.RegisterRequest(m_localID,
9181 m_itemID, item.AssetID.ToString());
9182 if (NotecardCache.IsCached(item.AssetID))
9183 { 9182 {
9184 AsyncCommands. 9183 assetID = item.AssetID;
9185 DataserverPlugin.DataserverReply(item.AssetID.ToString(), 9184 break;
9186 NotecardCache.GetLines(item.AssetID).ToString());
9187 // ScriptSleep(100);
9188 return tid.ToString();
9189 } 9185 }
9190 WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
9191 {
9192 System.Text.ASCIIEncoding enc =
9193 new System.Text.ASCIIEncoding();
9194 string data = enc.GetString(a.Data);
9195 //m_log.Debug(data);
9196 NotecardCache.Cache(id, data);
9197 AsyncCommands.
9198 DataserverPlugin.DataserverReply(id.ToString(),
9199 NotecardCache.GetLines(id).ToString());
9200 });
9201 // ScriptSleep(100);
9202 return tid.ToString();
9203 } 9186 }
9204 } 9187 }
9188
9189 if (assetID == UUID.Zero)
9190 {
9191 // => complain loudly, as specified by the LSL docs
9192 ShoutError("Notecard '" + name + "' could not be found.");
9193 }
9194
9195 UUID tid = UUID.Zero;
9196
9197 if (NotecardCache.IsCached(assetID))
9198 {
9199 tid = AsyncCommands.
9200 DataserverPlugin.RegisterRequest(m_localID,
9201 m_itemID, assetID.ToString());
9202
9203 AsyncCommands.
9204 DataserverPlugin.DataserverReply(assetID.ToString(),
9205 NotecardCache.GetLines(assetID).ToString());
9206 // ScriptSleep(100);
9207 return tid.ToString();
9208 }
9209
9210 WithNotecard(assetID, delegate (UUID id, AssetBase a)
9211 {
9212 if (a.Type != 7)
9213 return;
9214
9215 tid = AsyncCommands.
9216 DataserverPlugin.RegisterRequest(m_localID,
9217 m_itemID, assetID.ToString());
9218
9219 System.Text.ASCIIEncoding enc =
9220 new System.Text.ASCIIEncoding();
9221 string data = enc.GetString(a.Data);
9222 //m_log.Debug(data);
9223 NotecardCache.Cache(id, data);
9224 AsyncCommands.
9225 DataserverPlugin.DataserverReply(id.ToString(),
9226 NotecardCache.GetLines(id).ToString());
9227 });
9228
9229 if (tid != UUID.Zero)
9230 {
9231 // ScriptSleep(100);
9232 return tid.ToString();
9233 }
9234
9205 // if we got to here, we didn't find the notecard the script was asking for 9235 // if we got to here, we didn't find the notecard the script was asking for
9206 // => complain loudly, as specified by the LSL docs 9236 // => complain loudly, as specified by the LSL docs
9207 ShoutError("Notecard '" + name + "' could not be found."); 9237 ShoutError("Notecard '" + name + "' could not be found.");
@@ -9216,40 +9246,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9216 9246
9217 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9247 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9218 9248
9219 foreach (TaskInventoryItem item in itemsDictionary.Values) 9249 UUID assetID = UUID.Zero;
9250
9251 if (!UUID.TryParse(name, out assetID))
9220 { 9252 {
9221 if (item.Type == 7 && item.Name == name) 9253 foreach (TaskInventoryItem item in itemsDictionary.Values)
9222 { 9254 {
9223 UUID tid = AsyncCommands. 9255 if (item.Type == 7 && item.Name == name)
9224 DataserverPlugin.RegisterRequest(m_localID,
9225 m_itemID, item.AssetID.ToString());
9226
9227 if (NotecardCache.IsCached(item.AssetID))
9228 { 9256 {
9229 AsyncCommands. 9257 assetID = item.AssetID;
9230 DataserverPlugin.DataserverReply(item.AssetID.ToString(), 9258 break;
9231 NotecardCache.GetLine(item.AssetID, line, m_notecardLineReadCharsMax));
9232 // ScriptSleep(100);
9233 return tid.ToString();
9234 } 9259 }
9235
9236 WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
9237 {
9238 System.Text.ASCIIEncoding enc =
9239 new System.Text.ASCIIEncoding();
9240 string data = enc.GetString(a.Data);
9241 //m_log.Debug(data);
9242 NotecardCache.Cache(id, data);
9243 AsyncCommands.
9244 DataserverPlugin.DataserverReply(id.ToString(),
9245 NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax));
9246 });
9247
9248 // ScriptSleep(100);
9249 return tid.ToString();
9250 } 9260 }
9251 } 9261 }
9252 9262
9263 if (assetID == UUID.Zero)
9264 {
9265 // => complain loudly, as specified by the LSL docs
9266 ShoutError("Notecard '" + name + "' could not be found.");
9267 }
9268
9269 UUID tid = UUID.Zero;
9270
9271 if (NotecardCache.IsCached(assetID))
9272 {
9273 tid = AsyncCommands.
9274 DataserverPlugin.RegisterRequest(m_localID,
9275 m_itemID, assetID.ToString());
9276
9277 AsyncCommands.
9278 DataserverPlugin.DataserverReply(assetID.ToString(),
9279 NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax));
9280 // ScriptSleep(100);
9281 return tid.ToString();
9282 }
9283
9284 WithNotecard(assetID, delegate (UUID id, AssetBase a)
9285 {
9286 if (a.Type != 7)
9287 return;
9288
9289 tid = AsyncCommands.
9290 DataserverPlugin.RegisterRequest(m_localID,
9291 m_itemID, assetID.ToString());
9292
9293 System.Text.ASCIIEncoding enc =
9294 new System.Text.ASCIIEncoding();
9295 string data = enc.GetString(a.Data);
9296 //m_log.Debug(data);
9297 NotecardCache.Cache(id, data);
9298 AsyncCommands.
9299 DataserverPlugin.DataserverReply(id.ToString(),
9300 NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax));
9301 });
9302
9303 if (tid != UUID.Zero)
9304 {
9305 // ScriptSleep(100);
9306 return tid.ToString();
9307 }
9308
9253 // if we got to here, we didn't find the notecard the script was asking for 9309 // if we got to here, we didn't find the notecard the script was asking for
9254 // => complain loudly, as specified by the LSL docs 9310 // => complain loudly, as specified by the LSL docs
9255 ShoutError("Notecard '" + name + "' could not be found."); 9311 ShoutError("Notecard '" + name + "' could not be found.");