From 06967e230f50fbeee24176f3df8cda8a067544e4 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 10 Apr 2008 09:36:55 +0000 Subject: * Updates BetaGridLikeMoneyModule * Several people have asked for a way to limit uploads, so I've decided to show people how to do this in the BetaGridLikeMoneyModule. * Configure it in OpenSim.ini using the [Economy] header. See the bottom of the OpenSim.ini.example for more information. * This also fleshes out the Economy API a bit more. --- .../Environment/Modules/BetaGridLikeMoneyModule.cs | 101 ++++++++++++++++++++- .../Region/Environment/Scenes/Scene.Inventory.cs | 11 +++ OpenSim/Region/Environment/Scenes/Scene.cs | 14 +++ OpenSim/Region/Environment/Scenes/SceneEvents.cs | 14 +++ .../Region/Environment/Scenes/SimStatsReporter.cs | 9 +- 5 files changed, 143 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs index 6e16eb3..74ae0dc 100644 --- a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs @@ -56,10 +56,39 @@ namespace OpenSim.Region.Environment.Modules private bool gridmode = false; + private float EnergyEfficiency = 0f; + private int ObjectCapacity = 45000; + private int ObjectCount = 0; + private int PriceEnergyUnit = 0; + private int PriceGroupCreate = 0; + private int PriceObjectClaim = 0; + private float PriceObjectRent = 0f; + private float PriceObjectScaleFactor = 0f; + private int PriceParcelClaim = 0; + private float PriceParcelClaimFactor = 0f; + private int PriceParcelRent = 0; + private int PricePublicObjectDecay = 0; + private int PricePublicObjectDelete = 0; + private int PriceRentLight = 0; + private int PriceUpload = 0; + private int TeleportMinPrice = 0; + private int UserLevelPaysFees = 2; + + float TeleportPriceExponent = 0f; + + LLUUID EconomyBaseAccount = LLUUID.Zero; + public void Initialise(Scene scene, IConfigSource config) { m_gConfig = config; - ReadConfigAndPopulate(); + + IConfig startupConfig = m_gConfig.Configs["Startup"]; + IConfig economyConfig = m_gConfig.Configs["Economy"]; + + + + ReadConfigAndPopulate(scene, startupConfig, "Startup"); + ReadConfigAndPopulate(scene, economyConfig, "Economy"); if (m_enabled) { @@ -79,14 +108,47 @@ namespace OpenSim.Region.Environment.Modules scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnMoneyTransfer += MoneyTransferAction; scene.EventManager.OnClientClosed += ClientClosed; + scene.EventManager.OnNewInventoryItemUploadComplete += NewInventoryItemEconomyHandler; + } } - private void ReadConfigAndPopulate() + private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string config) { - IConfig startupConfig = m_gConfig.Configs["Startup"]; - gridmode = startupConfig.GetBoolean("gridmode", false); - m_enabled = (startupConfig.GetString("moneymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); + if (config == "Startup") + { + gridmode = startupConfig.GetBoolean("gridmode", false); + m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); + } + + if (config == "Economy") + { + ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000); + PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); + PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); + PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4); + PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4); + PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1); + PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f); + PriceUpload = startupConfig.GetInt("PriceUpload", 0); + PriceRentLight = startupConfig.GetInt("PriceRentLight", 5); + TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2); + TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f); + EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1); + PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1); + PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10); + PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1); + PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1); + string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString()); + Helpers.TryParse(EBA,out EconomyBaseAccount); + UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1); + m_stipend = startupConfig.GetInt("UserStipend", 500); + m_minFundsBeforeRefresh = startupConfig.GetInt("IssueStipendWhenClientIsBelowAmount", 10); + m_keepMoneyAcrossLogins = startupConfig.GetBoolean("KeepMoneyAcrossLogins", true); + } + + // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter. + scene.SetObjectCapacity(ObjectCapacity); } private void OnNewClient(IClientAPI client) @@ -105,8 +167,11 @@ namespace OpenSim.Region.Environment.Modules } // Subscribe to Money messages + client.OnEconomyDataRequest += EconomyDataRequestHandler; client.OnMoneyBalanceRequest += SendMoneyBalance; client.OnLogout += ClientClosed; + + } public void ClientClosed(LLUUID AgentID) @@ -118,6 +183,16 @@ namespace OpenSim.Region.Environment.Modules } } + public void EconomyDataRequestHandler(LLUUID agentId) + { + IClientAPI user = LocateClientObject(agentId); + + user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, + PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, + PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload, + TeleportMinPrice, TeleportPriceExponent); + } + private void MoneyTransferAction (Object osender, MoneyTransferArgs e) { IClientAPI sender = null; @@ -150,6 +225,22 @@ namespace OpenSim.Region.Environment.Modules } } + private void NewInventoryItemEconomyHandler(LLUUID Uploader, LLUUID AssetID, String AssetName, int userlevel) + { + // Presumably a normal grid would actually send this information to a server somewhere. + // We're going to apply the UploadCost here. + if (m_enabled) + { + // Only make users that are below the UserLevelPaysFees value pay. + // Use this to exclude Region Owners (2), Estate Managers(1), Users (0), Disabled(-1) + if (PriceUpload > 0 && userlevel <= UserLevelPaysFees) + { + doMoneyTranfer(Uploader, EconomyBaseAccount, PriceUpload); + } + } + + } + private bool doMoneyTranfer(LLUUID Sender, LLUUID Receiver, int amount) { bool result = false; diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index bc8fb59..97d09aa 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -73,6 +73,17 @@ namespace OpenSim.Region.Environment.Scenes { userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); + + int userlevel = 0; + if (PermissionsMngr.IsEstateManager(remoteClient.AgentId)) + { + userlevel = 1; + } + if (m_regInfo.MasterAvatarAssignedUUID == remoteClient.AgentId) + { + userlevel = 2; + } + EventManager.TriggerOnNewInventoryItemUploadComplete(remoteClient.AgentId, item.AssetID, item.Name, userlevel); } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8f4c332..4a57c5d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -219,6 +219,8 @@ namespace OpenSim.Region.Environment.Scenes set { m_innerScene.RestorePresences = value; } } + public int objectCapacity = 45000; + #endregion #region Constructors @@ -299,6 +301,9 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter = new SimStatsReporter(regInfo); m_statsReporter.OnSendStatsResult += SendSimStatsPackets; + + m_statsReporter.SetObjectCapacity(objectCapacity); + string OSString = ""; if (System.Environment.OSVersion.Platform != PlatformID.Unix) @@ -2016,6 +2021,15 @@ namespace OpenSim.Region.Environment.Scenes } } + public void SetObjectCapacity(int objects) + { + if (m_statsReporter != null) + { + m_statsReporter.SetObjectCapacity(objects); + } + objectCapacity = objects; + } + #endregion #region Other Methods diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index c916009..02c9f3f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -137,6 +137,10 @@ namespace OpenSim.Region.Environment.Scenes public event OnNewPresenceDelegate OnMakeChildAgent; + public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel); + + public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; + /// /// RegisterCapsEvent is called by Scene after the Caps object /// has been instantiated and before it is return to the @@ -207,6 +211,7 @@ namespace OpenSim.Region.Environment.Scenes private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; + private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; public void TriggerOnScriptChangedEvent(uint localID, uint change) { @@ -462,5 +467,14 @@ namespace OpenSim.Region.Environment.Scenes handlerDeregisterCaps(agentID, caps); } } + + public void TriggerOnNewInventoryItemUploadComplete(LLUUID agentID, LLUUID AssetID, String AssetName, int userlevel) + { + handlerNewInventoryItemUpdateComplete = OnNewInventoryItemUploadComplete; + if (handlerNewInventoryItemUpdateComplete != null) + { + handlerNewInventoryItemUpdateComplete(agentID, AssetID, AssetName, userlevel); + } + } } } diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index ef741d4..d72bee0 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -100,6 +100,8 @@ namespace OpenSim.Region.Environment.Scenes private int m_pendingUploads = 0; private int m_activeScripts = 0; private int m_scriptLinesPerSecond = 0; + + private int objectCapacity = 45000; SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; @@ -152,7 +154,7 @@ namespace OpenSim.Region.Environment.Scenes { statpack.Region.RegionFlags = (uint) 0; } - statpack.Region.ObjectCapacity = (uint) 45000; + statpack.Region.ObjectCapacity = (uint) objectCapacity; #region various statistic googly moogly @@ -389,6 +391,11 @@ namespace OpenSim.Region.Environment.Scenes m_activeScripts = count; } + public void SetObjectCapacity(int objects) + { + objectCapacity = objects; + } + #endregion } } -- cgit v1.1