Revert previous change to temporary prims as it means birds have to repopulate every

3 minutes. Instead hook the OnPrimsLoaded event (after scene object restore) and delete
any persisted OpenSimBirdsN prims left over from last shutdown.
pull/1/merge
Jak Daniels 2015-01-03 16:09:25 +00:00
parent 173e046aba
commit f387b5e0c3
2 changed files with 33 additions and 7 deletions

View File

@ -92,7 +92,7 @@ namespace Flocking
public void AddRegion (Scene scene)
{
m_log.InfoFormat("[{0}]: Adding region '{1}' to this module", m_name, scene.RegionInfo.RegionName);
m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName);
IConfig cnf = m_config.Configs[scene.RegionInfo.RegionName];
if (cnf == null)
@ -130,7 +130,8 @@ namespace Flocking
//register handlers
m_scene.EventManager.OnFrame += FlockUpdate;
m_scene.EventManager.OnChatFromClient += SimChatSent; //listen for commands sent from the client
m_scene.EventManager.OnChatFromWorld += SimChatSent;
m_scene.EventManager.OnChatFromWorld += SimChatSent;
m_scene.EventManager.OnPrimsLoaded += PrimsLoaded;
// init module
m_model = new FlockingModel(m_name, m_maxSpeed, m_maxForce, m_neighbourDistance, m_desiredSeparation, m_tolerance, m_borderSize);
@ -150,11 +151,17 @@ namespace Flocking
// Mark Module Ready for duty
m_ready = true;
}
}
}
public void PrimsLoaded(Scene scene)
{
m_scene = scene;
ClearPersisted();
}
public void RemoveRegion (Scene scene)
{
m_log.InfoFormat("[{0}]: Removing region '{1}' from this module", m_name, scene.RegionInfo.RegionName);
m_log.InfoFormat("[{0}]: Removing region {1} from this module", m_name, scene.RegionInfo.RegionName);
if (m_enabled) {
m_view.Clear();
m_ready = false;
@ -193,6 +200,25 @@ namespace Flocking
m_view.PostInitialize(m_owner);
}
public void ClearPersisted()
{
//really trash all possible birds that may have been persisted at last shutdown
int i;
for (i = m_flockSize; i < m_maxFlockSize; i++)
{
foreach (EntityBase e in m_scene.GetEntities())
{
if (e.Name == (string)(m_name + i))
{
m_log.InfoFormat("[{0}]: Removing old persisted prim {1} from region {2}", m_name, m_name + i, m_scene.RegionInfo.RegionName);
m_scene.DeleteSceneObject((SceneObjectGroup)e, false);
break;
}
}
}
m_scene.ForceClientUpdate();
}
#endregion
#region EventHandlers
@ -255,7 +281,7 @@ namespace Flocking
if (args.Trim ().Length > 0) {
argStr = " <" + args + "> ";
}
m_log.InfoFormat("[{0}]: Adding command {1} - {2} to region '{3}'", m_name, "birds-" + cmd + argStr, help, m_scene.RegionInfo.RegionName);
m_log.InfoFormat("[{0}]: Adding console command {1} - {2} to region {3}", m_name, "birds-" + cmd + argStr, help, m_scene.RegionInfo.RegionName);
//m_scene.AddCommand (this, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
m_console.Commands.AddCommand(m_name, false, "birds-" + cmd, "birds-" + cmd + argStr, help, fn);
}

View File

@ -88,12 +88,12 @@ namespace Flocking
SceneObjectPart rootPart;
if (existing == null) {
m_log.InfoFormat("[{0}]: Adding prim {1} from region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
m_log.InfoFormat("[{0}]: Adding prim {1} in region {2}", m_name, bird.Id, m_scene.RegionInfo.RegionName);
SceneObjectGroup group = findByName (m_birdPrim);
sog = CopyPrim (group, bird.Id);
rootPart = sog.RootPart;
//set prim to phantom
sog.UpdatePrimFlags(rootPart.LocalId, false, true, true, false);
sog.UpdatePrimFlags(rootPart.LocalId, false, false, true, false);
m_sogMap [bird.Id] = sog;
m_scene.AddNewSceneObject (sog, false);
// Fire script on_rez