Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 07-11-2007, 03:56 AM   #1 (permalink)
Forum Novice
 
Join Date: Sep 2003
Age: 21
Posts: 216
Send a message via AIM to A Cow Send a message via Yahoo to A Cow
Default More than one server

Ok.. heres the deal.. that "More than one server in server list" got me thinking.. shit that would be cool.. have like a test server and then live..

so for the past 4 hours ive been rescripting ServerList.cs ( to no avil )

Code:
// RunUO
// Serverlist.cs
// Tyson Clark ( tyson@tysonclark.com )
using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;

namespace Server.Misc
{
    public class ServerList
    {
        int NumOfServers = 2; // Number of Servers ( Including Server A )

        // YOUR SERVERS NAME
        public const string ServerName = "ServerA"; // Server A's Name AKA Login Server
        public const string ServerNameB = "ServerB"; // Server B's Name
        //public const string ServerNameA = "ServerC"; // Server C's Name
        //public const string ServerNameA = "ServerD"; // Server D's Name
        //public const string ServerNameA = "ServerE"; // Server E's Name
        //public const string ServerNameA = "ServerF"; // Server F's Name
        //public const string ServerNameA = "ServerG"; // Server G's Name

        // SERVER ADDRESSES
        public static string Address = "192.168.1.142"; // Server A's IP AKA Login Server's IP
        public static string AddressB = "192.168.1.142"; // Server B's IP
        //public static string AddressC   = "aoa.servebeer.com"; // Server C's IP
        //public static string AddressD   = "aoa.servebeer.com"; // Server D's IP
        //public static string AddressE   = "aoa.servebeer.com"; // Server E's IP
        //public static string AddressF   = "aoa.servebeer.com"; // Server F's IP
        //public static string AddressG   = "aoa.servebeer.com"; // Server G's IP

        // SERVER PORTS
        public const int PortA = 2593;  // Server A's Port
        public const int PortB = 2594;  // Server B's Port
        //public const int PortC = 2595;  // Server C's Port
        //public const int PortD = 2596;  // Server D's Port
        //public const int PortE = 2597;  // Server E's Port    
        //public const int PortF = 2598;  // Server F's Port
        //public const int PortG = 2599;  // Server G's Port



        // ======================================================================================================================================
        // Initialization
        // ======================================================================================================================================
        public static void Initialize()
        {
            Listener.Port = 2594;  //THIS SERVER's port
            EventSink.ServerList += new ServerListEventHandler(EventSink_ServerList);

            Console.WriteLine("MultiServerList 2.0.1.1a");
            Console.WriteLine("By Tyson Clark (tyson@tysonclark.com)");
            Console.WriteLine("Adding Other Servers to list (god i hope)");
        }

        // ======================================================================================================================================
        // EventSink_ServerList
        // ======================================================================================================================================
        public static void EventSink_ServerList(ServerListEventArgs e)
        {
            try
            {

                IPAddress ipAddrA;
                IPAddress ipAddrB;
                //IPAddress ipAddrC;
                //IPAddress ipAddrD;
                //IPAddress ipAddrE;
                //IPAddress ipAddrF;
                //IPAddress ipAddrG;

                bool bIpAddrA = Resolve(Address != null && !IsLocalMachine(e.State) ? Address : Dns.GetHostName(), out ipAddrA);
                bool bIpAddrB = Resolve(AddressB != null && !IsLocalMachine(e.State) ? Address : Dns.GetHostName(), out ipAddrB);
                //bool bIpAddrC = Resolve( AddressC != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrC );
                //bool bIpAddrD = Resolve( AddressD != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrD );
                //bool bIpAddrE = Resolve( AddressE != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrE );
                //bool bIpAddrF = Resolve( AddressF != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrF );
                //bool bIpAddrG = Resolve( AddressG != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrG );

                // cout the current server info
                Console.WriteLine("This Server Shit (address you gota know port tho is real)");
                Console.Write(ipAddrA);
                Console.Write(":");
                Console.Write(Listener.Port);
                Console.WriteLine(" ");
                // ----------------------------------------------------
                // Setup Server List
                // ----------------------------------------------------
                if (bIpAddrA)
                {
                    Console.Write("Server A Address ");
                    Console.Write(ipAddrA);
                    Console.Write(":");
                    Console.Write(PortA);
                    Console.WriteLine(" ");
                    e.AddServer(ServerName, new IPEndPoint(ipAddrA, PortA));
                }
                else
                    e.Rejected = true;

                if (bIpAddrB)
                {
                    Console.Write("Server B Address ");
                    Console.Write(ipAddrB);
                    Console.Write(":");
                    Console.Write(PortB);
                    Console.WriteLine(" ");
                    e.AddServer(ServerNameB, new IPEndPoint(ipAddrB, PortB));
                }
                else
                    e.Rejected = true;


                //if ( bIpAddrC )
                //    e.AddServer(ServerNameC, new IPEndPoint(ipAddrC, PortC));
                //else
                //    e.Rejected = true;


                //if ( bIpAddrD )
                //    e.AddServer(ServerNameD, new IPEndPoint(ipAddrD, PortD));
                //else 
                //    e.Rejected = true;


                //if ( bIpAddrE )
                //    e.AddServer(ServerNameE, new IPEndPoint(ipAddrE, PortE));
                // else 
                //    e.Rejected = true;


                //if ( bIpAddrF )
                //    e.AddServer(ServerNameF, new IPEndPoint(ipAddrF, PortF));
                // else 
                //    e.Rejected = true;


                //if ( bIpAddrG )
                //    e.AddServer(ServerNameG, new IPEndPoint(ipAddrG, PortG));
                // else 
                //    e.Rejected = true;                

            }
            catch
            {
                e.Rejected = true;
            }
        }

        public static bool Resolve(string addr, out IPAddress outValue)
        {

            if (IPAddress.TryParse(addr, out outValue))
                return true;

            try
            {
                IPHostEntry iphe = Dns.GetHostEntry(addr);

                if (iphe.AddressList.Length > 0)
                {
                    outValue = iphe.AddressList[iphe.AddressList.Length - 1];
                    return true;
                }
            }
            catch
            {
            }

            outValue = IPAddress.None;
            return false;
        }
        private static bool IsLocalMachine(NetState state)
        {
            Socket sock = state.Socket;

            IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;

            if (IPAddress.IsLoopback(theirAddress))
                return true;

            bool contains = false;

            IPHostEntry iphe = Dns.GetHostEntry(Dns.GetHostName());

            for (int i = 0; !contains && i < iphe.AddressList.Length; ++i)
                contains = theirAddress.Equals(iphe.AddressList[i]);

            return contains;
        }
    }
}
The servers show up on the list but no mater what one you pick it goes to server A
__________________
There is only one ruler of the internet
A Cow
"whats my shards ip?" on your shard go to this address HTTP://WWW.IPCHICKEN.COM
A Cow is offline   Reply With Quote
Old 07-11-2007, 04:15 AM   #2 (permalink)
Forum Novice
 
Join Date: Sep 2003
Age: 21
Posts: 216
Send a message via AIM to A Cow Send a message via Yahoo to A Cow
Default

Probably going to need the network programer for RunUO to help me here.. i tried going thro the source code but it wouldnt compile right with breakpoints...


BTW you guys gota fix your "full %" to

NumOfPeoplePlaying / MaxPlayers

instead of... 0
__________________
There is only one ruler of the internet
A Cow
"whats my shards ip?" on your shard go to this address HTTP://WWW.IPCHICKEN.COM
A Cow is offline   Reply With Quote
Old 07-11-2007, 08:01 AM   #3 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,427
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

I suggest you read carefully through this thread:

ServerList.cs 2.2

You might get some ideas to help you fix it.
Lokai is offline   Reply With Quote
Old 07-11-2007, 02:23 PM   #4 (permalink)
Forum Novice
 
Join Date: Sep 2003
Age: 21
Posts: 216
Send a message via AIM to A Cow Send a message via Yahoo to A Cow
Default

yea thats where i orignaly got the idea from but im having a problem where it always connects to listern.Port it doesnt ever seemt to go elsewhere..
__________________
There is only one ruler of the internet
A Cow
"whats my shards ip?" on your shard go to this address HTTP://WWW.IPCHICKEN.COM
A Cow is offline   Reply With Quote
Old 09-03-2007, 08:12 PM   #5 (permalink)
Lurker
 
Join Date: Aug 2007
Posts: 3
Default

ok I actually got this to work, 2 servers same machine, i had to modify serverlist 2.2 to work correctly behind router, and also added code to automatically create an account on the additional servers if it didnt already exist.

so if you want to test go to server name is mail.alphanetworksva.com port 2593, if you chose zarobhr that is server that you intially log into and account is created before server select screnn is displayed, but if you chose test then it will now create an account on second server.
zarobhr is offline   Reply With Quote
Old 09-16-2007, 01:53 PM   #6 (permalink)
Forum Expert
 
Join Date: May 2003
Posts: 469
Send a message via AIM to Rooster2
Default Already been done..

If you do searches for my name, you'll find a script that does this.. It was done years ago.. I found the original sitting on the scripts area, which is is what I posted for someone else long time ago.. The original multi-shard script might still be in the scripts area, not sure?? (kinda making a comeback here to UO after a really long hiatus, lol).. But this has been done, search around. Not only for multiple local shards, but to create a 'network' of shards over the internet with "affiliates", friends, or those you trust...
__________________
Quote:
Originally Posted by Ravatar
:!: *Best Thread of the Day* :!:



The Good: It's a really good UOA clone.
The Bad: It's not a UO emulator.
The Ugly: You are going to get flamed badly for this :)
Rooster has spoken.
Rooster2 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5