let new regions know about grid services god

httptests
UbitUmarov 2017-05-11 17:30:57 +01:00
parent 7e8c996d1b
commit 5968c6372a
1 changed files with 74 additions and 26 deletions

View File

@ -59,21 +59,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
/// <summary>Special UUID for actions that apply to all agents</summary>
private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
private static readonly UUID UUID_GRID_GOD = new UUID("6571e388-6218-4574-87db-f9379718315e");
protected Scene m_scene;
protected IDialogModule m_dialogModule;
protected IDialogModule DialogModule
{
get
{
if (m_dialogModule == null)
m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
return m_dialogModule;
}
}
public void Initialise(IConfigSource source)
{
}
@ -97,6 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
public void RegionLoaded(Scene scene)
{
m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
}
public void Close() {}
@ -152,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
if (god == null || god.ControllingClient.SessionId != godSessionID)
return String.Empty;
KickUser(godID, agentID, kickFlags, Util.StringToBytes1024(reason));
KickUser(godID, agentID, kickFlags, reason);
}
else
{
@ -173,8 +164,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
sp.GrantGodlikePowers(token, godLike);
if (godLike && !sp.IsViewerUIGod && DialogModule != null)
DialogModule.SendAlertToUser(agentID, "Request for god powers denied");
if (godLike && !sp.IsViewerUIGod && m_dialogModule != null)
m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied");
}
public void KickUser(UUID godID, UUID agentID, uint kickflags, byte[] reason)
{
KickUser(godID, agentID, kickflags, Utils.BytesToString(reason));
}
/// <summary>
@ -184,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
/// <param name="agentID">the person that is being kicked</param>
/// <param name="kickflags">Tells what to do to the user</param>
/// <param name="reason">The message to send to the user after it's been turned into a field</param>
public void KickUser(UUID godID, UUID agentID, uint kickflags, byte[] reason)
public void KickUser(UUID godID, UUID agentID, uint kickflags, string reason)
{
// assuming automatic god rights on this for fast griefing reaction
// this is also needed for kick via message
@ -201,8 +197,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence p)
{
if (p.UUID != godID && godlevel > p.GodController.GodLevel)
if (p.UUID != godID)
{
if(godlevel > p.GodController.GodLevel)
doKickmodes(godID, p, kickflags, reason);
else if(m_dialogModule != null)
m_dialogModule.SendAlertToUser(p.UUID, "Kick from " + godID.ToString() + " ignored, kick reason: " + reason);
}
});
return;
}
@ -217,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID);
transferModule.SendInstantMessage(new GridInstantMessage(
m_scene, godID, "God", agentID, (byte)250, false,
Utils.BytesToString(reason), UUID.Zero, true,
reason, UUID.Zero, true,
new Vector3(), new byte[] {(byte)kickflags}, true),
delegate(bool success) {} );
}
@ -225,7 +226,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
}
if (godlevel <= sp.GodController.GodLevel) // no god wars
{
if(m_dialogModule != null)
m_dialogModule.SendAlertToUser(sp.UUID, "Kick from " + godID.ToString() + " ignored, kick reason: " + reason);
return;
}
if(sp.UUID == godID)
return;
@ -233,29 +238,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
doKickmodes(godID, sp, kickflags, reason);
}
private void doKickmodes(UUID godID, ScenePresence sp, uint kickflags, byte[] reason)
private void doKickmodes(UUID godID, ScenePresence sp, uint kickflags, string reason)
{
switch (kickflags)
{
case 0:
KickPresence(sp, Utils.BytesToString(reason));
KickPresence(sp, reason);
break;
case 1:
sp.AllowMovement = false;
m_dialogModule.SendAlertToUser(sp.UUID, Utils.BytesToString(reason));
if(m_dialogModule != null)
{
m_dialogModule.SendAlertToUser(sp.UUID, reason);
m_dialogModule.SendAlertToUser(godID, "User Frozen");
}
break;
case 2:
sp.AllowMovement = true;
m_dialogModule.SendAlertToUser(sp.UUID, Utils.BytesToString(reason));
if(m_dialogModule != null)
{
m_dialogModule.SendAlertToUser(sp.UUID, reason);
m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
}
break;
default:
break;
}
}
private void KickPresence(ScenePresence sp, string reason)
{
if(sp.IsDeleted || sp.IsChildAgent)
@ -264,6 +274,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
sp.Scene.CloseAgent(sp.UUID, true);
}
public void GridKickUser(UUID agentID, string reason)
{
int godlevel = 240; // grid god default
ScenePresence sp = m_scene.GetScenePresence(agentID);
if (sp == null || sp.IsChildAgent)
{
IMessageTransferModule transferModule =
m_scene.RequestModuleInterface<IMessageTransferModule>();
if (transferModule != null)
{
m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID);
transferModule.SendInstantMessage(new GridInstantMessage(
m_scene, UUID_GRID_GOD, "GRID", agentID, (byte)250, false,
reason, UUID.Zero, true,
new Vector3(), new byte[] {0}, true),
delegate(bool success) {} );
}
return;
}
if(sp.IsDeleted)
return;
if (godlevel <= sp.GodController.GodLevel) // no god wars
{
if(m_dialogModule != null)
m_dialogModule.SendAlertToUser(sp.UUID, "GRID kick detected and ignored, kick reason: " + reason);
return;
}
sp.ControllingClient.Kick(reason);
sp.Scene.CloseAgent(sp.UUID, true);
}
private void OnIncomingInstantMessage(GridInstantMessage msg)
{
if (msg.dialog == (uint)250) // Nonlocal kick
@ -273,7 +318,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
UUID godID = new UUID(msg.fromAgentID);
uint kickMode = (uint)msg.binaryBucket[0];
KickUser(godID, agentID, kickMode, Util.StringToBytes1024(reason));
if(godID == UUID_GRID_GOD)
GridKickUser(agentID, reason);
else
KickUser(godID, agentID, kickMode, reason);
}
}
}