aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-05 05:26:18 +0000
committerTeravus Ovares2008-02-05 05:26:18 +0000
commitca5aadfbff63e03b7ca081e753204d8da040c9bb (patch)
treee2d19e01678c27cff57bc26257cec7385c3df274
parentAdded copyright statements. (diff)
downloadopensim-SC_OLD-ca5aadfbff63e03b7ca081e753204d8da040c9bb.zip
opensim-SC_OLD-ca5aadfbff63e03b7ca081e753204d8da040c9bb.tar.gz
opensim-SC_OLD-ca5aadfbff63e03b7ca081e753204d8da040c9bb.tar.bz2
opensim-SC_OLD-ca5aadfbff63e03b7ca081e753204d8da040c9bb.tar.xz
* Refactored the sound calls to SceneObjectPart
* Fixed a few bugs * Wrote an example module to make certain event systems more mature.
-rw-r--r--OpenSim/Framework/IClientAPI.cs4
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs324
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs78
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs119
8 files changed, 449 insertions, 121 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 2ef05ae..d2d7365 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -403,6 +403,8 @@ namespace OpenSim.Framework
403 403
404 public delegate void MoneyTransferRequest(LLUUID sourceID, LLUUID destID, int amount, int transactionType, string description); 404 public delegate void MoneyTransferRequest(LLUUID sourceID, LLUUID destID, int amount, int transactionType, string description);
405 405
406 // We keep all this information for fraud purposes in the future.
407 public delegate void MoneyBalanceRequest(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID TransactionID);
406 408
407 public delegate void ObjectPermissions( 409 public delegate void ObjectPermissions(
408 IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, 410 IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID,
@@ -507,6 +509,8 @@ namespace OpenSim.Framework
507 // Financial packets 509 // Financial packets
508 event MoneyTransferRequest OnMoneyTransferRequest; 510 event MoneyTransferRequest OnMoneyTransferRequest;
509 511
512 event MoneyBalanceRequest OnMoneyBalanceRequest;
513
510 514
511 LLVector3 StartPos { get; set; } 515 LLVector3 StartPos { get; set; }
512 516
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index e89b722..5fdb9b3 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -581,6 +581,8 @@ namespace OpenSim.Region.ClientStack
581 581
582 public event MoneyTransferRequest OnMoneyTransferRequest; 582 public event MoneyTransferRequest OnMoneyTransferRequest;
583 583
584 public event MoneyBalanceRequest OnMoneyBalanceRequest;
585
584 586
585 #region Scene/Avatar to Client 587 #region Scene/Avatar to Client
586 588
@@ -2067,15 +2069,23 @@ namespace OpenSim.Region.ClientStack
2067 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) 2069 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
2068 { 2070 {
2069 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack; 2071 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
2072 // validate the agent owns the agentID and sessionID
2073 if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && money.AgentData.SessionID == sender.SessionId)
2074 {
2070 2075
2071 if (OnMoneyTransferRequest != null) 2076 if (OnMoneyTransferRequest != null)
2077 {
2078 OnMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
2079 money.MoneyData.Amount, money.MoneyData.TransactionType,
2080 Util.FieldToString(money.MoneyData.Description));
2081 }
2082
2083 return true;
2084 }
2085 else
2072 { 2086 {
2073 OnMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID, 2087 return false;
2074 money.MoneyData.Amount, money.MoneyData.TransactionType,
2075 Util.FieldToString(money.MoneyData.Description));
2076 } 2088 }
2077
2078 return true;
2079 } 2089 }
2080 2090
2081 private bool HandleViewerEffect(IClientAPI sender, Packet Pack) 2091 private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
@@ -3434,7 +3444,13 @@ namespace OpenSim.Region.ClientStack
3434 #endregion 3444 #endregion
3435 3445
3436 case PacketType.MoneyBalanceRequest: 3446 case PacketType.MoneyBalanceRequest:
3437 SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); 3447 MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
3448 if (OnMoneyBalanceRequest != null)
3449 {
3450 OnMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
3451 }
3452
3453
3438 break; 3454 break;
3439 case PacketType.UUIDNameRequest: 3455 case PacketType.UUIDNameRequest:
3440 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; 3456 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
diff --git a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
new file mode 100644
index 0000000..81478a1
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
@@ -0,0 +1,324 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using Nini.Config;
30using System;
31using System.Collections;
32using System.Collections.Generic;
33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes;
37using libsecondlife;
38using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs;
39
40namespace OpenSim.Region.Environment.Modules
41{
42 public class BetaGridLikeMoneyModule: IRegionModule
43 {
44
45 private LogBase m_log;
46
47 private Dictionary<ulong,Scene> m_scenel = new Dictionary<ulong,Scene>();
48
49 private IConfigSource m_gConfig;
50
51 private bool m_keepMoneyAcrossLogins = true;
52
53 private int m_minFundsBeforeRefresh = 100;
54
55 private int m_stipend = 1000;
56
57 private bool m_enabled = true;
58
59
60
61 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
62
63
64
65 private bool gridmode = false;
66
67 public void Initialise(Scene scene, IConfigSource config)
68 {
69 m_log = MainLog.Instance;
70
71 m_gConfig = config;
72 ReadConfigAndPopulate();
73
74 if (m_enabled)
75 {
76 lock (m_scenel)
77 {
78
79 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
80 {
81 m_scenel[scene.RegionInfo.RegionHandle] = scene;
82 }
83 else
84 {
85 m_scenel.Add(scene.RegionInfo.RegionHandle, scene);
86 }
87 }
88
89 scene.EventManager.OnNewClient += OnNewClient;
90 scene.EventManager.OnMoneyTransfer += MoneyTransferAction;
91 scene.EventManager.OnClientClosed += ClientClosed;
92 }
93 }
94 private void ReadConfigAndPopulate()
95 {
96 IConfig startupConfig = m_gConfig.Configs["Startup"];
97 gridmode = startupConfig.GetBoolean("gridmode", false);
98 m_enabled = (startupConfig.GetString("moneymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule");
99
100 }
101
102 private void OnNewClient(IClientAPI client)
103 {
104 // Here we check if we're in grid mode
105 // I imagine that the 'check balance'
106 // function for the client should be here or shortly after
107
108 if (gridmode)
109 {
110 CheckExistAndRefreshFunds(client.AgentId);
111 }
112 else
113 {
114 CheckExistAndRefreshFunds(client.AgentId);
115 }
116
117 // Subscribe to Money messages
118 client.OnMoneyBalanceRequest += SendMoneyBalance;
119 client.OnLogout += ClientClosed;
120
121 }
122
123 public void ClientClosed(LLUUID AgentID)
124 {
125 lock (m_KnownClientFunds)
126 {
127 if (!m_keepMoneyAcrossLogins)
128 m_KnownClientFunds.Remove(AgentID);
129 }
130
131 }
132
133 private void MoneyTransferAction (Object osender, MoneyTransferArgs e)
134 {
135 IClientAPI sender = null;
136 IClientAPI receiver = null;
137
138 sender = LocateClientObject(e.sender);
139 if (sender != null)
140 {
141
142
143 receiver = LocateClientObject(e.reciever);
144 bool transactionresult = doMoneyTranfer(e.sender, e.reciever, e.amount);
145
146 if (e.sender != e.reciever)
147 {
148 if (sender != null)
149 {
150 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
151 }
152 }
153
154 if (receiver != null)
155 {
156 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.reciever));
157 }
158
159
160 }
161 else
162 {
163 MainLog.Instance.Warn("MONEY", "Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Reciver: " + e.reciever.ToString() + " Amount: " + e.amount.ToString());
164 }
165
166
167
168 }
169
170 private bool doMoneyTranfer(LLUUID Sender, LLUUID Receiver, int amount)
171 {
172 bool result = false;
173 if (amount >= 0)
174 {
175 lock (m_KnownClientFunds)
176 {
177 // If we don't know about the sender, then the sender can't
178 // actually be here and therefore this is likely fraud or outdated.
179 if (m_KnownClientFunds.ContainsKey(Sender))
180 {
181 // Does the sender have enough funds to give?
182 if (m_KnownClientFunds[Sender] >= amount)
183 {
184 // Subtract the funds from the senders account
185 m_KnownClientFunds[Sender] -= amount;
186
187 // do we know about the receiver?
188 if (!m_KnownClientFunds.ContainsKey(Receiver))
189 {
190 // Make a record for them so they get the updated balance when they login
191 CheckExistAndRefreshFunds(Receiver);
192 }
193
194 //Add the amount to the Receiver's funds
195 m_KnownClientFunds[Receiver] += amount;
196 result = true;
197 }
198 else
199 {
200 // These below are redundant to make this clearer to read
201 result = false;
202 }
203 }
204 else
205 {
206 result = false;
207 }
208 }
209 }
210 return result;
211 }
212
213 private IClientAPI LocateClientObject(LLUUID AgentID)
214 {
215 ScenePresence tPresence = null;
216 IClientAPI rclient = null;
217
218 lock (m_scenel)
219 {
220 foreach (Scene _scene in m_scenel.Values)
221 {
222 tPresence = _scene.GetScenePresence(AgentID);
223 if (tPresence != null)
224 {
225 if (!tPresence.IsChildAgent)
226 {
227 rclient = tPresence.ControllingClient;
228 }
229 }
230 if (rclient != null)
231 {
232 return rclient;
233 }
234 }
235
236 }
237 return null;
238 }
239
240 public void ClientClosed(IClientAPI client)
241 {
242 ClientClosed(client.AgentId);
243 }
244
245 public void SendMoneyBalance(IClientAPI client, LLUUID agentID, LLUUID SessionID, LLUUID TransactionID)
246 {
247 if (client.AgentId == agentID && client.SessionId == SessionID)
248 {
249
250 int returnfunds = 0;
251
252 try
253 {
254 returnfunds = GetFundsForAgentID(agentID);
255 }
256 catch (System.Exception e)
257 {
258 client.SendAlertMessage(e.Message + " ");
259 }
260
261 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds);
262 }
263 else
264 {
265 client.SendAlertMessage("Unable to send your money balance to you!");
266 }
267 }
268
269 private void CheckExistAndRefreshFunds(LLUUID agentID)
270 {
271 lock (m_KnownClientFunds)
272 {
273 if (!m_KnownClientFunds.ContainsKey(agentID))
274 {
275 m_KnownClientFunds.Add(agentID, m_stipend);
276 }
277 else
278 {
279 if (m_KnownClientFunds[agentID] <= m_minFundsBeforeRefresh)
280 {
281 m_KnownClientFunds[agentID] = m_stipend;
282 }
283 }
284 }
285 }
286 private int GetFundsForAgentID(LLUUID AgentID)
287 {
288 int returnfunds = 0;
289 lock (m_KnownClientFunds)
290 {
291 if (m_KnownClientFunds.ContainsKey(AgentID))
292 {
293 returnfunds = m_KnownClientFunds[AgentID];
294 }
295 else
296 {
297 throw new Exception("Unable to get funds.");
298 }
299 }
300 return returnfunds;
301 }
302
303 public void PostInitialise()
304 {
305 }
306
307
308
309 public void Close()
310 {
311 }
312
313 public string Name
314 {
315 get { return "BetaGridLikeMoneyModule"; }
316 }
317
318 public bool IsSharedModule
319 {
320 get { return true; }
321 }
322 }
323
324}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 89fd5ea..a80426b 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1315,6 +1315,8 @@ namespace OpenSim.Region.Environment.Scenes
1315 avatar.AbsolutePosition.Z); 1315 avatar.AbsolutePosition.Z);
1316 m_sceneGridService.SendCloseChildAgentConnections(avatar); 1316 m_sceneGridService.SendCloseChildAgentConnections(avatar);
1317 } 1317 }
1318
1319 m_eventManager.TriggerClientClosed(agentID);
1318 } 1320 }
1319 catch (NullReferenceException) 1321 catch (NullReferenceException)
1320 { 1322 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 51d1b32..cada991 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -125,6 +125,10 @@ namespace OpenSim.Region.Environment.Scenes
125 125
126 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule; 126 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
127 127
128 public delegate void ClientClosed(LLUUID clientID);
129
130 public event ClientClosed OnClientClosed;
131
128 public delegate void ScriptChangedEvent(uint localID, uint change); 132 public delegate void ScriptChangedEvent(uint localID, uint change);
129 133
130 public event ScriptChangedEvent OnScriptChangedEvent; 134 public event ScriptChangedEvent OnScriptChangedEvent;
@@ -338,6 +342,14 @@ namespace OpenSim.Region.Environment.Scenes
338 342
339 } 343 }
340 } 344 }
345
346 public void TriggerClientClosed(LLUUID ClientID)
347 {
348 if (OnClientClosed != null)
349 {
350 OnClientClosed(ClientID);
351 }
352 }
341 353
342 } 354 }
343} \ No newline at end of file 355} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 159eaf1..0ba64f2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1457,6 +1457,84 @@ namespace OpenSim.Region.Environment.Scenes
1457 1457
1458 #endregion 1458 #endregion
1459 1459
1460 #region Sound
1461 public void PreloadSound(string sound)
1462 {
1463 LLUUID ownerID = OwnerID;
1464 LLUUID objectID = UUID;
1465 LLUUID soundID = LLUUID.Zero;
1466
1467 if (!LLUUID.TryParse(sound, out soundID))
1468 {
1469 //Trys to fetch sound id from prim's inventory.
1470 //Prim's inventory doesn't support non script items yet
1471 SceneObjectPart op = this;
1472 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
1473 {
1474 if (item.Value.Name == sound)
1475 {
1476 soundID = item.Value.ItemID;
1477 break;
1478 }
1479 }
1480 }
1481
1482 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
1483 foreach (ScenePresence p in avatarts)
1484 {
1485 // TODO: some filtering by distance of avatar
1486
1487 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
1488 }
1489 }
1490
1491 public void SendSound(string sound, double volume, bool triggered)
1492 {
1493 if (volume > 1)
1494 volume = 1;
1495 if (volume < 0)
1496 volume = 0;
1497
1498 LLUUID ownerID = OwnerID;
1499 LLUUID objectID = UUID;
1500 LLUUID parentID = GetRootPartUUID();
1501 LLUUID soundID = LLUUID.Zero;
1502 LLVector3 position = AbsolutePosition; // region local
1503 ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle;
1504
1505 byte flags = 0;
1506
1507 if (!LLUUID.TryParse(sound, out soundID))
1508 {
1509 // search sound file from inventory
1510 SceneObjectPart op = this;
1511 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
1512 {
1513 if (item.Value.Name == sound)
1514 {
1515 soundID = item.Value.ItemID;
1516 break;
1517 }
1518 }
1519 }
1520
1521 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
1522 foreach (ScenePresence p in avatarts)
1523 {
1524 // TODO: some filtering by distance of avatar
1525 if (triggered)
1526 {
1527 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
1528 }
1529 else
1530 {
1531 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
1532 }
1533 }
1534 }
1535
1536 #endregion
1537
1460 #region Resizing/Scale 1538 #region Resizing/Scale
1461 1539
1462 /// <summary> 1540 /// <summary>
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 19bd6cd..b15db31 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -145,6 +145,7 @@ namespace SimpleApp
145 public event FriendActionDelegate OnDenyFriendRequest; 145 public event FriendActionDelegate OnDenyFriendRequest;
146 public event FriendshipTermination OnTerminateFriendship; 146 public event FriendshipTermination OnTerminateFriendship;
147 public event PacketStats OnPacketStats; 147 public event PacketStats OnPacketStats;
148 public event MoneyBalanceRequest OnMoneyBalanceRequest;
148 149
149#pragma warning restore 67 150#pragma warning restore 67
150 151
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 367a5f7..80df86e 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -906,37 +906,8 @@ namespace OpenSim.Region.ScriptEngine.Common
906 906
907 public void llPlaySound(string sound, double volume) 907 public void llPlaySound(string sound, double volume)
908 { 908 {
909 if (volume > 1) 909
910 volume = 1; 910 m_host.SendSound(sound, volume, false);
911 if (volume < 0)
912 volume = 0;
913
914 LLUUID ownerID = m_host.OwnerID;
915 LLUUID objectID = m_host.UUID;
916 LLUUID soundID = LLUUID.Zero;
917 byte flags = 0;
918
919 if (!LLUUID.TryParse(sound, out soundID))
920 {
921 //Trys to fetch sound id from prim's inventory.
922 //Prim's inventory doesn't support non script items yet
923 SceneObjectPart op = World.GetSceneObjectPart(objectID);
924 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
925 {
926 if (item.Value.Name == sound)
927 {
928 soundID = item.Value.ItemID;
929 break;
930 }
931 }
932 }
933
934 List<ScenePresence> avatarts = World.GetAvatars();
935 foreach (ScenePresence p in avatarts)
936 {
937 // TODO: some filtering by distance of avatar
938 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
939 }
940 } 911 }
941 912
942 public void llLoopSound(string sound, double volume) 913 public void llLoopSound(string sound, double volume)
@@ -961,38 +932,7 @@ namespace OpenSim.Region.ScriptEngine.Common
961 932
962 public void llTriggerSound(string sound, double volume) 933 public void llTriggerSound(string sound, double volume)
963 { 934 {
964 if (volume > 1) 935 m_host.SendSound(sound, volume, true);
965 volume = 1;
966 if (volume < 0)
967 volume = 0;
968
969 LLUUID ownerID = m_host.OwnerID;
970 LLUUID objectID = m_host.UUID;
971 LLUUID parentID = this.m_host.GetRootPartUUID();
972 LLUUID soundID = LLUUID.Zero;
973 LLVector3 position = this.m_host.AbsolutePosition; // region local
974 ulong regionHandle = World.RegionInfo.RegionHandle;
975
976 if (!LLUUID.TryParse(sound, out soundID))
977 {
978 // search sound file from inventory
979 SceneObjectPart op = World.GetSceneObjectPart(objectID);
980 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
981 {
982 if (item.Value.Name == sound)
983 {
984 soundID = item.Value.ItemID;
985 break;
986 }
987 }
988 }
989
990 List<ScenePresence> avatarts = World.GetAvatars();
991 foreach (ScenePresence p in avatarts)
992 {
993 // TODO: some filtering by distance of avatar
994 p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
995 }
996 } 936 }
997 937
998 public void llStopSound() 938 public void llStopSound()
@@ -1002,31 +942,7 @@ namespace OpenSim.Region.ScriptEngine.Common
1002 942
1003 public void llPreloadSound(string sound) 943 public void llPreloadSound(string sound)
1004 { 944 {
1005 LLUUID ownerID = m_host.OwnerID; 945 m_host.PreloadSound(sound);
1006 LLUUID objectID = m_host.UUID;
1007 LLUUID soundID = LLUUID.Zero;
1008
1009 if (!LLUUID.TryParse(sound, out soundID))
1010 {
1011 //Trys to fetch sound id from prim's inventory.
1012 //Prim's inventory doesn't support non script items yet
1013 SceneObjectPart op = World.GetSceneObjectPart(objectID);
1014 foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
1015 {
1016 if (item.Value.Name == sound)
1017 {
1018 soundID = item.Value.ItemID;
1019 break;
1020 }
1021 }
1022 }
1023
1024 List<ScenePresence> avatarts = World.GetAvatars();
1025 foreach (ScenePresence p in avatarts)
1026 {
1027 // TODO: some filtering by distance of avatar
1028 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
1029 }
1030 } 946 }
1031 947
1032 public string llGetSubString(string src, int start, int end) 948 public string llGetSubString(string src, int start, int end)
@@ -2439,32 +2355,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2439 2355
2440 } 2356 }
2441 prules.CRC = 1; 2357 prules.CRC = 1;
2442 Console.WriteLine("----------ps----------\n"); 2358
2443 Console.WriteLine(" AngularVelocity:" + prules.AngularVelocity.ToString() + "\n" +
2444 " BurstPartCount:" + prules.BurstPartCount.ToString() + "\n" +
2445 " BurstRadius:" + prules.BurstRadius.ToString() + "\n" +
2446 " BurstRate:" + prules.BurstRate.ToString() + "\n" +
2447 " BurstSpeedMax:" + prules.BurstSpeedMax.ToString() + "\n" +
2448 " BurstSpeedMin:" + prules.BurstSpeedMin.ToString() + "\n" +
2449 " CRC:" + prules.CRC.ToString() + "\n" +
2450 " InnerAngle:" + prules.InnerAngle.ToString() + "\n" +
2451 " MaxAge:" + prules.MaxAge.ToString() + "\n" +
2452 " OuterAngle:" + prules.OuterAngle.ToString() + "\n" +
2453 " PartAcceleration:" + prules.PartAcceleration.ToString() + "\n" +
2454 " PartDataFlags:" + prules.PartDataFlags.ToString() + "\n" +
2455 " PartEndColor:" + prules.PartEndColor.ToString() + "\n" +
2456 " PartEndScaleX:" + prules.PartEndScaleX.ToString() + "\n" +
2457 " PartEndScaleY:" + prules.PartEndScaleY.ToString() + "\n" +
2458 " PartFlags:" + prules.PartFlags.ToString() + "\n" +
2459 " PartMaxAge:" + prules.PartMaxAge.ToString() + "\n" +
2460 " PartStartColor:" + prules.PartStartColor.ToString() + "\n" +
2461 " PartStartScaleX:" + prules.PartStartScaleX.ToString() + "\n" +
2462 " PartStartScaleY:" + prules.PartStartScaleY.ToString() + "\n" +
2463 " Pattern:" + prules.Pattern.ToString() + "\n" +
2464 " StartAge:" + prules.StartAge.ToString() + "\n" +
2465 " Target:" + prules.Target.ToString() + "\n" +
2466 " Texture:" + prules.Texture.ToString() + "");
2467 OpenSim.Framework.Console.MainLog.Instance.Verbose("PARTICLE", "PS: " + prules.ToString());
2468 m_host.AddNewParticleSystem(prules); 2359 m_host.AddNewParticleSystem(prules);
2469 m_host.SendFullUpdateToAllClients(); 2360 m_host.SendFullUpdateToAllClients();
2470 } 2361 }