World Created when server starts

edited July 2010 in Photon Server
The way the MMO Demo is setup is that the world is created when the first player signs on. How could I go about changing that so that the world is created when the server starts?

Thanks in advance for any input!

Comments

  • I'm not too deep into the MMO Demo but PhotonApplication Setup() or Initialize() should be fine to setup your world. Then you would remove it on TearDown() and remove the player-dependent code anywhere else.
  • Here is how I do it...

    Find the File PhotonApplication.cs in your server and use the code in the link below.. the code has comments explaining what goes where, the key thing is to create your world inside the Initialize() Function
    http://pastebin.com/eYVkGAxt

    If that doesnt work let me know...

    A better idea is to put all that in a separate class and create an instance of the class inside the PhotonApplication.cs file, and then call a function that will do the work, that is actually how I do it to start everything I need on the server, like the world and the npcs...
  • Thanks zoultrex. That sort of worked. It creates the world when the server starts but then it also creates a 2nd world when the first client signs on so I guess I am going to have to figure out how to keep it from creating a world when the client signs on.
  • I also had that problem before when I wasnt using MmoWorldCache

    It was before:
    WorldOne = new MmoWorld(WorldOneName, WorldOneTopLeft, WorldOneBotRight, WorldOneDimention);
    
    Then i changed it to...
     WorldOneCreate = MmoWorldCache.Instance.TryCreate(
         WorldOneName, WorldOneTopLeft, WorldOneBotRight, WorldOneDimention, out WorldOne);
    
    ...and that solved

    Also make sure that both names are exactly the same
  • I have that

    WorldOneCreate = MmoWorldCache.Instance.TryCreate(
    WorldOneName, WorldOneTopLeft, WorldOneBotRight, WorldOneDimention, out WorldOne
    );

    I believe the names are the same but I will check
  • Also I am having a hard time figuring this out:

    WorldOneTopLeft = new[] { 1f, 1f };
    WorldOneBotRight = new float[] { 60000f, 60000f };
    WorldOneDimention = new float[] { 3000f, 3000f };

    In Unity I have 9 terrain pieces in a 3x3 square each terrain piece is 2000x2000. The first one is located at 0,0 and the last one at 4000,4000 so in total it takes up 6000 by 6000. Do I have the Photon size setup correctly?

    WorldOneTopLeft = new[] { 1f, 1f };
    WorldOneBotRight = new float[] { 60000f, 60000f };
    WorldOneDimention = new float[] { 3000f, 3000f };
  • I copied those settings from my the settings file in the UnityIslandsDemo.
    It looks like that both worlds must have exactly the same size or you would get an error.

    My settings in the client to match the server are:
            const int BoxesVertical = 20;
            const int BoxesHorizontal = 20;
            const int EdgeLengthVertical = 1000;
            const int EdgeLengthHorizontal = 1000;
    
            const int IntervalSend = 30;
            const int Velocity = 1;
            const bool SendReliable = false;
    
            const bool UseTcp = false;
            const string ServerAddress = "192.168.1.2:5055";
            const string ApplicationName = "MmoDemo";
            const string WorldName = "WorldOne";
    
            int[] tileDimensions = new int[2];
            tileDimensions[0] = EdgeLengthHorizontal;
            tileDimensions[1] = EdgeLengthVertical;
    
            int[] gridSize = new int[2];
            gridSize[0] = BoxesHorizontal * EdgeLengthHorizontal;
            gridSize[1] = BoxesVertical * EdgeLengthVertical;
    

    The key thing here for the size is the grid array:
    gridSize[0] = BoxesHorizontal * EdgeLengthHorizontal;
    gridSize[1] = BoxesVertical * EdgeLengthVertical;
    So you have 20 * 1000 = 20000
    And the tiles are 1000.

    I dont have to work with the terrain in my game now so I left those as they are and they work fine for me.
  • BorisBoris ✭✭
    If the first one is located at 0,0 you should probably put the top left to {0,0}.
    The bottom right would then be {5999f,5999f}.
    The server's tile dimensions are invisible to the client. The optimal setting reduces the number of subscribed items together with the interest area size to the minimum (to what you want to display). The mmo island demo uses a tile size of {1000f,1000f} with 20 tiles in each direction and a default minimum interest area size (view distance) of {501f,501f} and a maximum size of {1500f,1500f}.
  • BorisBoris ✭✭
    one quick warning: Internally each float is multiplied times 100 and integers are used for calculation. In case you initialize the world dimensions with integer arrays you have to multiply each value with 100.
  • BorisBoris ✭✭
    and one more hint: test your world (tile) settings with the mmo demo's wingrid client. You can change the dimensions in the app.config. Just make sure to change the world name with it - the client will ignore the other configured values if the server already created a world with the same name and use the server's world configuration instead.
Sign In or Register to comment.