public static void Initialize() { m_clients = new Dictionary <uint, LoLClient>(); if (enet_initialize() < 0) { throw new Exception("Unable to initialize ENet..."); } var address = new ENetAddress(); address.host = SERVER_HOST; address.port = ConfigurationProvider.Instance.Configuration.ServerPort; _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0); if (_server == null) { throw new Exception("Unable to start ENet server..."); } var key = Convert.FromBase64String(SERVER_KEY); if (key.Length <= 0) { throw new Exception("Unable to convert SERVER_KEY..."); } BlowFish = new BlowFish(key); }
static void Main(string[] args) { Console.WriteLine("Yorick " + SERVER_VERSION); WriteToLog.ExecutingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); WriteToLog.LogfileName = "IntWarsSharp.txt"; WriteToLog.CreateLogFile(); ExecutingDirectory = WriteToLog.ExecutingDirectory; System.AppDomain.CurrentDomain.FirstChanceException += Logger.CurrentDomain_FirstChanceException; System.AppDomain.CurrentDomain.UnhandledException += Logger.CurrentDomain_UnhandledException; Logger.LogCoreInfo("Loading Config."); Config.LoadConfig("Settings/GameInfo.json"); Logger.LogCoreInfo("Loading RAF files in filearchives/."); var settings = Settings.Load("Settings/Settings.json"); if (!RAFManager.getInstance().init(System.IO.Path.Combine(settings.RadsPath, "filearchives"))) { Logger.LogCoreError("Couldn't load RAF files. Make sure you have a 'filearchives' directory in the server's root directory. This directory is to be taken from RADS/projects/lol_game_client/"); return; } ItemManager.getInstance().init(); Logger.LogCoreInfo("Game started"); Game g = new Game(); var address = new ENetAddress(); address.host = SERVER_HOST; address.port = SERVER_PORT; if (!g.initialize(address, SERVER_KEY)) { Logger.LogCoreError("Couldn't listen on port " + SERVER_PORT + ", or invalid key"); return; } //Sniffer.getInstance().setGame(g); //var p = Process.Start("SnifferApp.exe"); g.netLoop(); PathNode.DestroyTable(); // Cleanup }
static void Main(string[] args) { Console.WriteLine("Yorick " + SERVER_VERSION); WriteToLog.ExecutingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); WriteToLog.LogfileName = "IntWarsSharp.txt"; WriteToLog.CreateLogFile(); ExecutingDirectory = WriteToLog.ExecutingDirectory; System.AppDomain.CurrentDomain.FirstChanceException += Logger.CurrentDomain_FirstChanceException; System.AppDomain.CurrentDomain.UnhandledException += Logger.CurrentDomain_UnhandledException; Logger.LogCoreInfo("Loading Config."); Config.LoadConfig(); Logger.LogCoreInfo("Loading RAF files in filearchives/."); //var basePath = RAFManager.getInstance().findGameBasePath(); var basePath = @"C:\LolPatcherProxy\Base\RADS\projects\lol_game_client"; if (!RAFManager.getInstance().init(System.IO.Path.Combine(basePath, "filearchives"))) { Logger.LogCoreError("Couldn't load RAF files. Make sure you have a 'filearchives' directory in the server's root directory. This directory is to be taken from RADS/projects/lol_game_client/"); return; } ItemManager.getInstance().init(); Logger.LogCoreInfo("Game started"); Game g = new Game(); var address = new ENetAddress(); address.host = SERVER_HOST; address.port = SERVER_PORT; if (!g.initialize(address, SERVER_KEY)) { Logger.LogCoreError("Couldn't listen on port " + SERVER_PORT + ", or invalid key"); return; } Sniffer.getInstance().setGame(g); // var p = Process.Start("SnifferApp.exe"); g.netLoop(); PathNode.DestroyTable(); // Cleanup }
public static extern ENetPeer* enet_host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount);
public static extern int enet_address_get_host_ip(ref ENetAddress address, byte[] hostIP, IntPtr ipLength);
static extern int native_address_get_host_ip(ref ENetAddress address, byte* hostIP, IntPtr ipLength);
static extern int native_address_set_host(ref ENetAddress address, byte[] hostName);
public override int address_get_host(ref ENetAddress address, byte[] hostName, IntPtr nameLength) { return native_address_get_host(ref address, hostName, nameLength); }
public abstract ENetHost* host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
public abstract ENetPeer* host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data);
public static ENetHost* enet_host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { return Platform.host_create(ref address, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth); }
public static ENetPeer* enet_host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data) { return Platform.host_connect(host, ref address, channelCount, data); }
public abstract int address_get_host_ip(ref ENetAddress address, byte[] hostIP, IntPtr ipLength);
public abstract int address_get_host(ref ENetAddress address, byte[] hostName, IntPtr nameLength);
public abstract int address_set_host(ref ENetAddress address, byte[] hostName);
static extern ENetHost* native_host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
public override int address_set_host(ref ENetAddress address, byte[] hostName) { return native_address_set_host(ref address, hostName); }
public static int enet_address_set_host(ref ENetAddress address, byte[] hostName) { return Platform.address_set_host(ref address, hostName); }
public override int address_get_host_ip(ref ENetAddress address, byte[] hostIP, IntPtr ipLength) { return native_address_get_host_ip(ref address, hostIP, ipLength); }
public static int enet_address_get_host(ref ENetAddress address, byte[] hostName, IntPtr nameLength) { return Platform.address_get_host(ref address, hostName, nameLength); }
static extern int native_address_get_host(ref ENetAddress address, byte* hostName, IntPtr nameLength);
public static int enet_address_get_host_ip(ref ENetAddress address, byte[] hostIP, IntPtr ipLength) { return Platform.address_get_host_ip(ref address, hostIP, ipLength); }
public static extern int enet_address_get_host(ref ENetAddress address, byte[] hostName, IntPtr nameLength);
public override ENetPeer* host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data) { return native_host_connect(host, ref address, channelCount, data); }
public static extern int enet_address_set_host(ref ENetAddress address, byte[] hostName);
public override ENetHost* host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { return native_host_create(ref address, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth); }
public static extern ENetHost* enet_host_create(ref ENetAddress address, IntPtr peerLimit, uint incomingBandwidth, uint outgoingBandwidth);
static extern ENetPeer* native_host_connect(ENetHost* host, ref ENetAddress address, IntPtr channelCount, uint data);
private const double REFRESH_RATE = 16.666; // 60 fps public bool initialize(ENetAddress address, string baseKey) { if (enet_initialize() < 0) { return(false); } _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0); if (_server == null) { return(false); } var key = System.Convert.FromBase64String(baseKey); if (key.Length <= 0) return(false); fixed(byte *s = key) { _blowfish = BlowFishCS.BlowFishCS.BlowFishCreate(s, new IntPtr(16)); } PacketHandlerManager.getInstace().InitHandlers(this); map = new SummonersRift(this); PacketNotifier.setMap(map); //TODO: better lua implementation var id = 1; foreach (var p in Config.players) { var player = new ClientInfo(p.Value.rank, ((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.ribbon, p.Value.icon); player.setName(p.Value.name); player.setSkinNo(p.Value.skin); player.userId = id; // same as StartClient.bat id++; player.setSummoners(strToId(p.Value.summoner1), strToId(p.Value.summoner2)); Champion c = ChampionFactory.getChampionFromType(p.Value.champion, map, GetNewNetID(), (int)player.userId); var pos = c.getRespawnPosition(); c.setPosition(pos.Item1, pos.Item2); c.setTeam((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE); c.levelUp(); player.setChampion(c); var pair = new Pair <uint, ClientInfo>(); pair.Item2 = player; players.Add(pair); } // Uncomment the following to get 2-players /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE); * player2->setName("tseT"); * Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID()); * c2->setPosition(100.f, 273.55f); * c2->setTeam(1); * map->addObject(c2); * player2->setChampion(c2); * player2->setSkinNo(4); * player2->userId = 2; // same as StartClient.bat * player2->setSummoners(SPL_Ignite, SPL_Flash); * * players.push_back(player2);*/ return(_isAlive = true); }
private const double REFRESH_RATE = 16.666; // 60 fps public bool initialize(ENetAddress address, string baseKey) { if (enet_initialize() < 0) return false; _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0); if (_server == null) return false; var key = System.Convert.FromBase64String(baseKey); if (key.Length <= 0) return false; fixed (byte* s = key) { _blowfish = BlowFishCS.BlowFishCS.BlowFishCreate(s, new IntPtr(16)); } PacketHandlerManager.getInstace().InitHandlers(this); map = new SummonersRift(this); PacketNotifier.setMap(map); //TODO: better lua implementation var id = 1; foreach (var p in Config.players) { var player = new ClientInfo(p.Value.rank, ((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.ribbon, p.Value.icon); player.setName(p.Value.name); player.setSkinNo(p.Value.skin); player.userId = id; // same as StartClient.bat id++; player.setSummoners(strToId(p.Value.summoner1), strToId(p.Value.summoner2)); Champion c = ChampionFactory.getChampionFromType(p.Value.champion, map, GetNewNetID(), (int)player.userId); var pos = c.getRespawnPosition(); c.setPosition(pos.Item1, pos.Item2); c.setTeam((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE); c.levelUp(); player.setChampion(c); var pair = new Pair<uint, ClientInfo>(); pair.Item2 = player; players.Add(pair); } // Uncomment the following to get 2-players /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE); player2->setName("tseT"); Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID()); c2->setPosition(100.f, 273.55f); c2->setTeam(1); map->addObject(c2); player2->setChampion(c2); player2->setSkinNo(4); player2->userId = 2; // same as StartClient.bat player2->setSummoners(SPL_Ignite, SPL_Flash); players.push_back(player2);*/ return _isAlive = true; }