zerodowned

Moderator
It's a bit of an old submission and I figured this was a better place to post the issue.
Link to script:https://www.servuo.com/archive/tresdnis-staff-instances.290/

If a player is on someone else's instance map on restart, their Logout map will turn null or internal and unable to log in.
The owner of the instance will be able to log in just fine; and if the player happens to have an instance of their own, their log out will be changed to it instead and able to log in just fine.

I've been trying to figure out a way to make it save the map for all players. I set a secondary property on the player to record their last map before going internal, but it too turns null for everyone but the owner.

I've come up with a patch to send the player to a valid login area if their logout map is null.
 
In worst case scenarios, if the PlayerMobile Map is null on server load, all their equipment, including bank and pack, gets deleted by CleanUp. This leaves you with a totally blank character. I found out the hard way, glad you didn't have to lol!
 
Do not mean to derail this in any way but that is very interesting to know! Ive played around with adding in multiple versions of a facet on Map.cs in the past and have also gotten "stuck" in the internal map.

My one question is - sometimes after a few days I will start up my server and get "cleanup detected inaccessible items including 20 bank boxes" what causes this? Something I have always wondered :)
 
Do not mean to derail this in any way but that is very interesting to know! Ive played around with adding in multiple versions of a facet on Map.cs in the past and have also gotten "stuck" in the internal map.
I have multiple versions of existing maps and have encountered no issue.

Just this script is causing issues, I believe because it's not "hard coded" into server.map.cs
I just can't figure out why the owner has no problems with the map saving as their logout place but everyone else does.
 
Still trying to figure this out.

in the Deserializer for BaseInstance it sets up each map again.

Code:
Instances.SetupInstance(this);

snippet for Instance.SetupInstance
Code:
public static void SetupInstance(BaseInstance instance)
  {
  if (instance == null)
  return;

  int id = GetMapID(instance.MapCopy);
  int definition = NextAvailableDefinition();
  int width = GetMapWidth(instance.MapCopy);
  int height = GetMapHeight(instance.MapCopy);

  Map newMap = new Map(id, definition, id, width, height, 0, instance.InstanceName, MapRules.FeluccaRules);

  Map.Maps[definition] = newMap;
  Map.AllMaps.Add(newMap);
  instance.MapDefinition = definition;

  instance.InstanceOwner.Map = Map.Maps[definition];

  CurrentInstances.Add(instance);  
  }

So I had the idea to try loading the BaseInstance automatically when the world loads. Since it only seems to be creating the instance when the owner logs in.

Code:
private static void EventSink_ServerStarted ()
     {
       foreach( BaseInstance baseInstance in World.Items.Values )
       {
         Instances.SetupInstance(baseInstance);
      
       }
}
However it throws an error
System.InvalidCastException: Unable to cast object of type 'Server.Misc.TreasuresOfTokunoPersistance' to type 'Tresdni.Instances.BaseInstance'.

Can't figure out why. I can't find any connection between these two scripts.
 
Try it this way:

Code:
    private static void EventSink_ServerStarted ()
    {
        foreach( Item i in World.Items.Values )
        {
            if (i is BaseInstance)
                Instances.SetupInstance(i as BaseInstance);
        }
    }
 
I've got Linq going now with my stuff after Voxpire showed me it's power. It's a awesome way of handling iterations

Code:
private static void EventSink_ServerStarted ()
   {
       foreach( BaseInstance bi in World.Items.Values.OfType<BaseInstance>())
       {
		Instances.SetupInstance(bi);
       }
   }

Linq here handles getting a list of your baseinstances from the values of the dictionary, the list will also cast them for you so you'll be dealing with the baseinstance right off the bat.

Quick and easy way to filter out the list and get only the items needed.
 
I forgot to mention that Linq was introduced in .net 3.5 I believe it was, so your core needs to be running with that and have access to the Linq lib.
 
Well it fixed the issue with compiling but the instance map is still coming up null for everyone by the instance owner
 
Back