1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Any help with bettering my understanding of the main Method

Discussion in 'ServUO Discussion' started by strieder, Nov 6, 2018.

  1. strieder
    Offline

    strieder New Member

    Joined:
    Oct 29, 2018
    Messages:
    2
    Likes Received:
    0
    I've been playing around with ServeUO a bit for the first time trying to understand more about how it works. Please correct me if i'm wrong but my understanding so far is I can see there is the main method that contains a while loop responsible for calling a few important methods that essentially "progress" the world:
    • Mobile/ItemProcessDeltaQueue(); processing changes in the worlds objects like movement, hp updates, death, spawn etc.
    • Pushing packets to clients via NetState.FlushAll()
    • Timer.Slice() seems to be incrementing the servers internal method of keeping time; its "clock"; for when events will happen in the future e.g. curse expires from target.

    Perhaps my biggest area of not understanding is around the kind of helper thread for time keeping and the Timer.Slice() method. One key thing I can see is that sometimes the main thread is taking a very long time to execute the Timer.Slice() method. I can see some synchronisation via locking between this helper thread and the main thread and this is one place they seem to clash. What exactly is Timer.Slice() doing? Does it particularly need to be a part of the main method or could there be any room to offload the processing that the main thread is doing in Timer.Slice() to the helper thread?

    Spoiler

    while (!Closing)
    {
    _Signal.WaitOne();

    Mobile.ProcessDeltaQueue();
    Item.ProcessDeltaQueue();

    Timer.Slice();
    messagePump.Slice();

    NetState.FlushAll();
    NetState.ProcessDisposedQueue();

    if (Slice != null)
    {
    Slice();
    }

    if (sample++ % sampleInterval != 0)
    {
    continue;
    }


    now = TickCount;
    _CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last);
    last = now;
    }
     
  2. Grimoric
    Offline

    Grimoric Member

    Joined:
    Mar 21, 2015
    Messages:
    80
    Likes Received:
    9
    #2 Grimoric, Nov 8, 2018
    Last edited: Nov 8, 2018
Similar Threads: help bettering
Forum Title Date
Script Support Looking for help with Regions (Town Specifically) Yesterday at 10:44 AM
Script Support This is a Nice Little Script - but it has me beat - Help? Thursday at 11:49 PM
General Discussion Client patch help (UOpatch) Nov 2, 2018
Script Support Need some help with a potential script issue. Oct 24, 2018
General Discussion Client Help Oct 17, 2018
General Discussion Alittle help Oct 13, 2018
Script Support Animal Loyalty HELP Oct 11, 2018