move currency-base-uri simulator feature to global settings, based on [Economy] economy setting on opensim.ini. make sampleMoney honour it

master
UbitUmarov 2020-05-10 21:27:23 +01:00
parent aafc6579a1
commit c15869438c
4 changed files with 40 additions and 13 deletions

View File

@ -84,6 +84,8 @@ namespace OpenSim.Region.ClientStack.Linden
static private UUID m_scriptSyntaxID = UUID.Zero; static private UUID m_scriptSyntaxID = UUID.Zero;
static private byte[] m_scriptSyntaxXML = null; static private byte[] m_scriptSyntaxXML = null;
static private string m_economyURL = null;
#region ISharedRegionModule Members #region ISharedRegionModule Members
public void Initialise(IConfigSource source) public void Initialise(IConfigSource source)
@ -115,6 +117,8 @@ namespace OpenSim.Region.ClientStack.Linden
m_doScriptSyntax = config.GetBoolean("ScriptSyntax", m_doScriptSyntax); m_doScriptSyntax = config.GetBoolean("ScriptSyntax", m_doScriptSyntax);
} }
m_economyURL = Util.GetConfigVarFromSections<string>(source, "economy", new string[] { "Economy", "GridInfo" });
ReadScriptSyntax(); ReadScriptSyntax();
AddDefaultFeatures(); AddDefaultFeatures();
} }
@ -197,17 +201,18 @@ namespace OpenSim.Region.ClientStack.Linden
extrasMap["AnimationSet"] = true; extrasMap["AnimationSet"] = true;
// TODO: Take these out of here into their respective modules, like map-server-url // TODO: Take these out of here into their respective modules, like map-server-url
if (m_SearchURL != string.Empty) if (!string.IsNullOrWhiteSpace(m_SearchURL))
extrasMap["search-server-url"] = m_SearchURL; extrasMap["search-server-url"] = m_SearchURL;
if (!string.IsNullOrEmpty(m_DestinationGuideURL)) if (!string.IsNullOrEmpty(m_DestinationGuideURL))
extrasMap["destination-guide-url"] = m_DestinationGuideURL; extrasMap["destination-guide-url"] = m_DestinationGuideURL;
if (m_ExportSupported) if (m_ExportSupported)
extrasMap["ExportSupported"] = true; extrasMap["ExportSupported"] = true;
if (m_GridURL != string.Empty) if (!string.IsNullOrWhiteSpace(m_GridURL))
extrasMap["GridURL"] = m_GridURL; extrasMap["GridURL"] = m_GridURL;
if (m_GridName != string.Empty) if (!string.IsNullOrWhiteSpace(m_GridName))
extrasMap["GridName"] = m_GridName; extrasMap["GridName"] = m_GridName;
if(!string.IsNullOrWhiteSpace(m_economyURL))
extrasMap["currency-base-uri"] = Util.AppendEndSlash(m_economyURL);
if (extrasMap.Count > 0) if (extrasMap.Count > 0)
m_features["OpenSimExtras"] = extrasMap; m_features["OpenSimExtras"] = extrasMap;
} }
@ -263,6 +268,19 @@ namespace OpenSim.Region.ClientStack.Linden
return m_features.TryGetValue(name, out value); return m_features.TryGetValue(name, out value);
} }
public bool TryGetOpenSimExtraFeature(string name, out OSD value)
{
value = null;
lock (m_features)
{
if (!m_features.TryGetValue("OpenSimExtras", out OSD extra))
return false;
if(!(extra is OSDMap))
return false;
return (extra as OSDMap).TryGetValue(name, out value);
}
}
public OSDMap GetFeatures() public OSDMap GetFeatures()
{ {
lock (m_features) lock (m_features)

View File

@ -43,6 +43,7 @@ namespace OpenSim.Region.Framework.Interfaces
void AddOpenSimExtraFeature(string name, OSD value); void AddOpenSimExtraFeature(string name, OSD value);
bool RemoveFeature(string name); bool RemoveFeature(string name);
bool TryGetFeature(string name, out OSD value); bool TryGetFeature(string name, out OSD value);
bool TryGetOpenSimExtraFeature(string name, out OSD value);
OSDMap GetFeatures(); OSDMap GetFeatures();
} }
} }

View File

@ -67,7 +67,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
// private UUID EconomyBaseAccount = UUID.Zero; // private UUID EconomyBaseAccount = UUID.Zero;
private Dictionary<string, XmlRpcMethod> m_rpcHandlers; private Dictionary<string, XmlRpcMethod> m_rpcHandlers;
private string m_economyURL; private string m_localEconomyURL;
private float EnergyEfficiency = 1f; private float EnergyEfficiency = 1f;
// private ObjectPaid handerOnObjectPaid; // private ObjectPaid handerOnObjectPaid;
@ -142,10 +142,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
{ {
if (m_scenel.Count == 0) if (m_scenel.Count == 0)
{ {
m_economyURL = scene.RegionInfo.ServerURI; m_localEconomyURL = scene.RegionInfo.ServerURI;
if(!string.IsNullOrWhiteSpace(m_economyURL) && m_economyURL[m_economyURL.Length - 1] == '/')
m_economyURL = m_economyURL.Substring(0, m_economyURL.Length - 1);
m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
m_rpcHandlers.Add("getCurrencyQuote", quote_func); m_rpcHandlers.Add("getCurrencyQuote", quote_func);
m_rpcHandlers.Add("buyCurrency", buy_func); m_rpcHandlers.Add("buyCurrency", buy_func);
@ -186,10 +183,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
if (!m_enabled) if (!m_enabled)
return; return;
if (!string.IsNullOrWhiteSpace(m_economyURL)) ISimulatorFeaturesModule fm = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
if (fm != null && !string.IsNullOrWhiteSpace(m_localEconomyURL))
{ {
ISimulatorFeaturesModule fm = scene.RequestModuleInterface<ISimulatorFeaturesModule>(); if(fm.TryGetOpenSimExtraFeature("currency-base-uri", out OSD tmp))
fm?.AddOpenSimExtraFeature("currency-base-uri", m_economyURL); return;
fm.AddOpenSimExtraFeature("currency-base-uri", Util.AppendEndSlash(m_localEconomyURL));
} }
} }
@ -278,7 +277,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
m_enabled = false; m_enabled = false;
return; return;
} }
if(economyConfig == null) if(economyConfig == null)
return; return;
@ -495,6 +494,8 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
Hashtable currencyResponse = new Hashtable(); Hashtable currencyResponse = new Hashtable();
currencyResponse.Add("estimatedCost", 0); currencyResponse.Add("estimatedCost", 0);
currencyResponse.Add("estimatedLocalCost", " 0 Euros");
currencyResponse.Add("currencyBuy", amount); currencyResponse.Add("currencyBuy", amount);
Hashtable quoteResponse = new Hashtable(); Hashtable quoteResponse = new Hashtable();
@ -502,6 +503,9 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
quoteResponse.Add("currency", currencyResponse); quoteResponse.Add("currency", currencyResponse);
quoteResponse.Add("confirm", "asdfad9fj39ma9fj"); quoteResponse.Add("confirm", "asdfad9fj39ma9fj");
//quoteResponse.Add("success", false);
//quoteResponse.Add("errorMessage", "There is currency");
//quoteResponse.Add("errorURI", "http://opensimulator.org");
XmlRpcResponse returnval = new XmlRpcResponse(); XmlRpcResponse returnval = new XmlRpcResponse();
returnval.Value = quoteResponse; returnval.Value = quoteResponse;
return returnval; return returnval;

View File

@ -916,6 +916,10 @@
; To use other modules you need to override this setting ; To use other modules you need to override this setting
; economymodule = BetaGridLikeMoneyModule ; economymodule = BetaGridLikeMoneyModule
; the url of the economy service.
; this must match the grid economy setting (also known as helperURI or CurrencyServer, etc)
; economy = https://the.currency.machine.fdqn:port/folder/folder...
;# {SellEnabled} {} {Enable selling for 0?} {true false} true ;# {SellEnabled} {} {Enable selling for 0?} {true false} true
; The default economy module only implements just enough to allow free actions (transfer of objects, etc). ; The default economy module only implements just enough to allow free actions (transfer of objects, etc).
; There is no intention to implement anything further in core OpenSimulator. ; There is no intention to implement anything further in core OpenSimulator.