|
المشاركات 407 |
+التقييم 0.21 |
تاريخ التسجيل May 2019 |
الاقامة |
نظام التشغيل |
رقم العضوية 248 |
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using SomailProject.Network;
using SomailProject.Database;
using SomailProject.Network.Sockets;
using SomailProject.Network.AuthPackets;
using SomailProject.Game;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using SomailProject.Network.GamePackets;
using SomailProject.Client;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading;
using SomailProject;
using SomailProject.Network.GamePackets.Union;
using ProtoBuf;
using SomailProject.MaTrix;
using SomailProject.Game.MsgServer;
namespace SomailProject
{
class Program
{
public static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Application_ThreadException);
Time32 Start = Time32.Now;
RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
Kernel.Random = new FastRandom(RandomSeed);
StartDate = DateTime.Now;
Console.Title = "Samuel-Dawod"; Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("_-_-_-_-_-_ ♥ Conquer Matrix ♥ _-_-_-_-_-_");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Load server configuration");
string ConfigFileName = "SomailProject.ini";
IniFile IniFile = new IniFile(ConfigFileName);
GameIP = IniFile.ReadString("configuration", "IP");
GamePort = IniFile.ReadUInt16("configuration", "GamePort");
AuthPort = new List<ushort>()
{
IniFile.ReadUInt16("configuration", "AuthPort"),
};
Constants.ServerName = IniFile.ReadString("configuration", "ServerName");
TestingMode = IniFile.ReadString("configuration", "TestMode", "0") == "1" ? true : false;
AllTest = IniFile.ReadString("configuration", "AllTest", "0") == "1" ? true : false;
rates.Load(IniFile);
Database.DataHolder.CreateConnection(
IniFile.ReadString("MySql", "Host", "localhost"),
IniFile.ReadString("MySql", "Username", "root"),
IniFile.ReadString("MySql", "Password", "az4des123"),
IniFile.ReadString("MySql", "Database", "cq"));
PrestigeStars = 54;
EntityUID = new Counter(0);
bool x = false;
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
{
cmd.Select("configuration").Where("Server", Constants.ServerName);
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
{
EntityUID = new Counter(r.ReadUInt32("EntityID"));
Game.ConquerStructures.Society.Guild.GuildCounter = new SomailProject.Counter(r.ReadUInt32("GuildID"));
ConquerItem.ItemUID = new Counter(r.ReadUInt32("ItemUID"));
Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate");
Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate");
Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate");
Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate");
Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple");
if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) x = true;
Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple");
Constants.ItemDropRate = r.ReadUInt32("ItemDropRate");
Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~');
Constants.WebAccExt = r.ReadString("AccountWebExt");
Constants.WebVoteExt = r.ReadString("VoteWebExt");
Constants.WebDonateExt = r.ReadString("DonateWebExt");
Constants.ServerWebsite = r.ReadString("ServerWebsite");
Constants.ServerGMPass = r.ReadString("ServerGMPass");
PlayerCap = r.ReadInt32("PlayerCap");
Union.UnionCounter = new Counter(r.ReadUInt32("UnionID"));
Database.EntityVariableTable.Load(0, out Vars);
VoteSystem.Count = r.ReadInt32("VotesCount");
}
}
}
if (EntityUID.Now == 0)
{
Console.Clear();
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.ReadLine();
return;
}
{
Console.WriteLine("Initializing Database.");
Console.WriteLine("Loading The Hard Things");
Database.ConquerItemInformation.Load();
Database.ConquerItemTable.ClearNulledItems();
InnerPowerTable.LoadDBInformation();
#region WardRobe
WardRobe.Load_coatstorage_type();
WardRobe.Load_title_type();
#endregion
InnerPowerTable.Load();
PerfectionTable.LoadItemRefineAttribute();
if (x) MsgSignIn.Reset();
PerfectionTable.LoadItemRefineEffect();
PerfectionTable.LoadItemRefineEffectEX();
Database.Flowers.LoadFlowers();
Database.SignInTable.Load();
Database.MonsterInformation.Load();
Database.MapsTable.Load();
SomailProject.MaTrix.SoulProtection.Load();
World = new World();
World.Init();
Map.CreateTimerFactories();
Database.SignInTable.Load();
Database.DMaps.LoadMapPaths();
Database.DMaps.LoadMap(700);
DMaps.LoadMap(2068);
Database.DMaps.LoadMap(3868);
Database.DMaps.LoadMap(3935);
Database.DMaps.LoadMap(10137);
Copra.QuestInfo.Load();
Database.VipTable.LoadAllVips();
Database.SpellTable.Load();
Database.ShopFile.Load();
Database.HonorShop.Load();
Database.RacePointShop.Load();
VoteSystem.Load();
Database.ChampionShop.Load();
new MsgUserAbilityScore().LoadWallOfPrestige();
PrestigeRank.LoadRanking();
Console.WriteLine("WallOfPrestigeRank Initilizied");
Database.EShopFile.Load();
Database.EShopV2File.Load();
Database.AddingInformationTable.Load();
Database.LotteryTable.Load();
Database.vipLottery.Load();
Copra.Roulette.Database.Roulettes.Load();
Copra.Way2Heroes.Load();
Database.ConquerItemTable.ClearNulledItems();
Refinery.Load();
Values = new Client.GameState[0];
new Game.Map(1002, Database.DMaps.MapPaths[1002]);
new Game.Map(1038, Database.DMaps.MapPaths[1038]);
new Game.Map(2071, Database.DMaps.MapPaths[2071]);
new Game.Map(2057, Database.DMaps.MapPaths[2057]);
new Game.Map(4000, Database.DMaps.MapPaths[4000]);
new Game.Map(4003, Database.DMaps.MapPaths[4003]);
new Game.Map(4006, Database.DMaps.MapPaths[4006]);
new Game.Map(4008, Database.DMaps.MapPaths[4008]);
new Game.Map(4020, Database.DMaps.MapPaths[4020]);
if (DMaps.LoadMap(1038))
Game.GuildWar.Initiate();
if (DMaps.LoadMap(10380))
Game.SuperGuildWar.Initiate();
new Game.Map(1509, Database.DMaps.MapPaths[1509]);
new Game.Map(10002, 2021, Database.DMaps.MapPaths[2021]);
new Game.Map(8883, 1004, Database.DMaps.MapPaths[1004]);
Constants.PKFreeMaps.Add(8883);
Game.EliteGuildWar.EliteGwint();
Database.DataHolder.ReadStats();
Database.IPBan.Load();
JiangHuTable.LoadStatus();
JiangHuTable.LoadRanks();
Database.NobilityTable.Load();
Database.ArenaTable.Load();
Database.TeamArenaTable.Load();
Database.GuildTable.Load();
UnionTable.Load();
AuctionBase.Load();
Database.ChiTable.LoadAllChi();
StorageItem.Load();
Clan.LoadClans();
Kernel.Magic.Load();
TutorInfo.Load();
Database.Disdain.Load();
Tranformation.Int();
Kernel.AtributeStatus.Load();
AtributesStatus.LoadExpInfo();
RebornInfo = new RebornInfomations();
RebornInfo.Load();
Game.Screen.CreateTimerFactories();
new MsgEquipRefineRank().UpdateRanking();
Database.ConquerItemTable.ClearNulledItems();
Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
World.CreateTournaments();
new MySqlCommand(MySqlCommandType.Update).Update("entities").Set("Online", 0).Execute();
Console.WriteLine("Initializing Sockets.");
AuthServer = new ServerSocket[AuthPort.Count];
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i] = new ServerSocket();
AuthServer[i].OnClientConnect += AuthServer_OnClientConnect;
AuthServer[i].OnClientReceive += AuthServer_OnClientReceive;
AuthServer[i].OnClientDisconnect += AuthServer_OnClientDisconnect;
AuthServer[i].Enable(AuthPort[i], "0.0.0.0");
Console.WriteLine("Auth " + i + " server online.");
}
{
GameServer = new ServerSocket();
GameServer.OnClientConnect += GameServer_OnClientConnect;
GameServer.OnClientReceive += GameServer_OnClientReceive;
GameServer.OnClientDisconnect += GameServer_OnClientDisconnect;
GameServer.Enable(GamePort, "0.0.0.0");
Console.WriteLine("Game server online.");
Console.WriteLine("Web server online.");
Copra.Pet.CreateTimerFactories();
AI.CreateTimerFactories();
var client = new GameState(null);
client.Entity = new Entity(EntityFlag.Monster, false);
client.Entity.MapID = 1002;
Npcs npc = new Npcs(client);
var req = new NpcRequest();
req.Deserialize(new byte[28]);
Npcs.GetDialog(req, client);
client = null;
SomailProject.Booths.Load();
}
Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");
Console.WriteLine("[********************** ♥ [Samuel.Dawod] ♥ **********************]");
SomailHandler += SomailConsole_CloseEvent;
SetConsoleCtrlHandler(SomailHandler, true);
GC.Collect();
WorkConsole();
}
}
public static int PrestigeStars = 0;
public static RebornInfomations RebornInfo;
public static Encoding Encoding = ASCIIEncoding.Default;
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public static int PlayerCap = 1000;
public static bool ALEXPC = false;
public static bool NemesisTyrantSpanwed = false;
public static long MaxOn = 0;
public static long MaxEntitys = 0;
public static ServerSocket[] AuthServer;
public static int CpuUse = 0;
public static ServerSocket GameServer;
public static Counter EntityUID;
public static string GameIP;
public static bool SpookAlive = false;
public static DayOfWeek Today;
public static ushort GamePort;
public static List<ushort> AuthPort;
public static DateTime StartDate;
public static bool reseted = false;
public static uint ScreenColor = 0;
public static DateTime RestartDate = DateTime.Now.AddHours(24);
public static bool restarted = false;
public static bool WarEnd = false;
public static bool uniquepk = false;
public static uint mess = 0;
public static World World;
public static Client.GameState[] GamePool = new Client.GameState[0];
public static Client.GameState[] Values = new Client.GameState[0];
public static VariableVault Vars;
public static long WeatherType = 0L;
public static bool TestingMode = false;
public static bool AllTest = false;
public static bool SnowBa = true;
public static bool Nemesis = true;
public static bool ThrillingSpook = true;
public static uint PhysicalDamage = 100;// + 150%
public static bool SwordMaster = true;
public static bool TeratoDragon = true;
public static bool SnowSoul = true;
public static int RandomSeed = 0;
public static short GetDistance(ushort X, ushort Y, ushort X2, ushort Y2)
{
return (short)Math.Sqrt((X - X2) * (X - X2) + (Y - Y2) * (Y - Y2));
}
#region Translate
public static void SaveTranslate()
{
var file = Environment.CurrentDirectory + "Translate.txt";
if (File.Exists(file))
File.Delete(file);
StreamWriter writer = new StreamWriter(File.Create(file), Encoding);
writer.AutoFlush = true;
foreach (var item in Kernel.Translateed)
writer.WriteLine(item.Key + "@@" + item.Value);
writer.Close();
}
public static void LoadTranslate()
{
var file = Environment.CurrentDirectory + "Translate.txt";
if (File.Exists(file))
{
string[] text = File.ReadAllLines(file, Encoding);
for (int x = 0; x < text.Length; x++)
{
string line = text[x];
string[] split = line.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length < 1)
continue;
var key = split[0];
if (split.Length < 2)
continue;
var value = split[1];
if (!Kernel.Translateed.ContainsKey(key))
Kernel.Translateed.Add(key, value);
}
}
}
#endregion
#region VersionChecker
//if (VersionChecker.IsValidVersion() == false)
//{
// MessageBox.Show("Your Trial Version has expired, Please get the Full version |Contact 011 42 72 19 32");
// SomailProject.Console.WriteLine("Enter Password:");
// Program.Password = Console.ReadLine();
// if (ClassExtensions.Get64HashCode(Program.Password) != 4586181316755855993)
// {
// MessageBox.Show("Your Trial Version has expired, Please get the Full version |Contact 011 42 72 19 32");
// SomailProject.Console.WriteLine("Thx. For Waiting...!");
// SomailProject.Console.WriteLine("Wrong Password!");
// SomailProject.Console.WriteLine("If Want To make this Source Work");
// SomailProject.Console.WriteLine("You need to put the right Password. !");
// SomailProject.Console.ReadLine();
// MessageBox.Show("You Will Get Hacked. | Contact 011 42 72 19 32");
// System.Console.ForegroundColor = System.ConsoleColor.DarkGreen;
// System.Console.WindowLeft = System.Console.WindowTop = 0;
// System.Console.WindowHeight = System.Console.BufferHeight = System.Console.LargestWindowHeight;
// System.Console.WindowWidth = System.Console.BufferWidth = System.Console.LargestWindowWidth;
// System.Console.CursorVisible = false;
// int width, height;
// int[] y;
// int[] l;
// Initialize(out width, out height, out y, out l);
// int ms;
// while (true)
// {
// DateTime t1 = DateTime.Now;
// CopraStep(width, height, y, l);
// ms = 10 - (int)((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds;
// if (ms > 0)
// System.Threading.Thread.Sleep(ms);
// if (System.Console.KeyAvailable)
// if (System.Console.ReadKey().Key == ConsoleKey.F5)
// Initialize(out width, out height, out y, out l);
// }
// // Environment.Exit(0);
// }
// elsez
// {
// VersionChecker.TrialEnd();
// MessageBox.Show("Your Trial Version has Renewed, To get the Full version");
// }
// return;
//}
//else
//{
// VersionChecker chk = new VersionChecker();
//}
#endregion VersionChecker
#region Closing Events
private static bool SomailConsole_CloseEvent(CtrlType sig)
{
Save();
return true;
}
private static Native.ConsoleEventHandler SomailHandler;
[DllImport("Kernel32")]
private static extern bool SetConsoleCtrlHandler(Native.ConsoleEventHandler handler, bool add);
private delegate bool EventHandler(CtrlType sig);
#endregion
public static bool Save(bool Exit = false)
{
try
{
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
foreach (Client.GameState client in Program.Values)
{
SaveTranslate();
Database.JiangHuTable.FullSave(client);
Database.EntityTable.SaveEntity(client);
Database.SkillTable.SaveClientSpells(client);
Database.SkillTable.SaveProficiencies(client);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic);
Database.TeamArenaTable.SaveArenaStatistics(client.TeamArenaStatistic);
client.WardRobe.Save();
}
}
Database.InnerPowerTable.Save();
Database.Flowers.SaveFlowers();
AuctionBase.Save();
Game.ClanWarArena.Save();
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", Constants.ServerName))
{
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
{
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("EntityID", EntityUID.Now).Set("ServerKingdom", Kernel.ServerKingdom).Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now).Where("Server", Constants.ServerName).Execute();
if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) MsgSignIn.Reset();
}
}
}
using (var cmd = new MySqlCommand(MySqlCommandType.Update).Update("configuration"))
cmd.Set("LastDailySignReset", DateTime.Now.Month).Execute();
Console.WriteLine("Saving cmd Done.");
//if (Exit)
// Environment.Exit(0);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return true;
}
#region Exceptions & Logs
public static void AddVendorLog(String vendor, string buying, string moneyamount, ConquerItem Item)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\VendorLogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("{0} HAS BOUGHT AN ITEM : {2} FROM {1} SHOP - for {3}", vendor, buying, Item.ToLog(), moneyamount);
file.WriteLine("------------------------------------------------------------------------------------");
file.Close();
}
}
public static void AddGMCommand(string gm, string commandStr)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\GMCommandsLog\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(gm + commandStr);
file.Close();
}
}
public static void RemoveCps(string text)
{
try
{
text = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + text;
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\RemoveCps\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true);
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(text);
file.Close();
}
}
catch (Exception ex) { Console.WriteLine(ex); }
}
public static void AddCpsWin(string text)
{
try
{
text = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + text;
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\AddWinCps\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(text);
file.Close();
}
}
catch (Exception ex) { Console.WriteLine(ex); }
}
public static void AddDropLog(String Name, ConquerItem Item)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\droplogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
string path = NewPath + "\\" + DateTime.Now.Day + ".txt";
if (!File.Exists(path)) File.AppendAllText(path, "");
string text = "------------------------------------------------------------------------------------"
+ Environment.NewLine + string.Format("Entity {0} HAS DROPPED AN ITEM : {1} -", Name, Item.ToLog())
+ Environment.NewLine + "------------------------------------------------------------------------------------";
File.AppendAllText(path, text);
}
public static void AddTradeLog(Game.ConquerStructures.Trade first, String firstN, Game.ConquerStructures.Trade second, String secondN)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "database\\Security\\Trade\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine("************************************************************************************");
file.WriteLine("First Person TradeLog ({0}) -", firstN);
file.WriteLine("Gold Traded: " + first.Money);
file.WriteLine("Conquer Points Traded: " + first.ConquerPoints);
for (int i = 0; i < first.Items.Count; i++)
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("Item : " + first.Items[i].ToLog());
file.WriteLine("------------------------------------------------------------------------------------");
}
file.WriteLine("Second Person TradeLog ({0}) -", secondN);
file.WriteLine("Gold Traded: " + second.Money);
file.WriteLine("Conquer Points Traded: " + second.ConquerPoints);
for (int i = 0; i < second.Items.Count; i++)
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("Item : " + second.Items[i].ToLog());
file.WriteLine("------------------------------------------------------------------------------------");
}
file.WriteLine("************************************************************************************");
}
}
public static void AddMobLog(string War, string name, uint CPs = 0, uint item = 0)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\MobLogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
if (CPs != 0)
file.WriteLine(name + " got " + CPs + " CPs from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
else
file.WriteLine(name + " got " + item + " Item from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
}
}
public static void AddWarLog(string War, string CPs, string name)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\Warlogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(name + " got " + CPs + " CPs from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
}
}
static void Application_ThreadException(object sender, UnhandledExceptionEventArgs e)
{
SaveException(e.ExceptionObject as Exception);
}
public static void SaveException(Exception e)
{
Console.WriteLine(e);
var dt = DateTime.Now;
string date = dt.Month + "-" + dt.Day + "//";
if (!Directory.Exists(Application.StartupPath + Constants.UnhandledExceptionsPath))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath);
if (!Directory.Exists(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date);
if (!Directory.Exists(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name);
string fullPath = Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name + "\\";
string date2 = dt.Hour + "-" + dt.Minute;
List<string> Lines = new List<string>();
Lines.Add("----Exception message----");
Lines.Add(e.Message);
Lines.Add("----End of exception message----\r\n");
Lines.Add("----Stack trace----");
Lines.Add(e.StackTrace);
Lines.Add("----End of stack trace----\r\n");
//Lines.Add("----Data from exception----");
//foreach (KeyValuePair<object, object> data in e.Data)
// Lines.Add(data.Key.ToString() + "->" + data.Value.ToString());
//Lines.Add("----End of data from exception----\r\n");
File.WriteAllLines(fullPath + date2 + ".txt", Lines.ToArray());
}
#endregion
private static void WorkConsole()
{
while (true)
{
try
{
CommandsAI(Console.ReadLine());
}
catch (Exception e) { Console.WriteLine(e); }
}
}
public static DateTime LastRandomReset = DateTime.Now;
public static Network.GamePackets.BlackSpotPacket BlackSpotPacket = new Network.GamePackets.BlackSpotPacket();
public static bool MyPC = true;
public static void CommandsAI(string command)
{
try
{
if (command == null)
return;
string[] data = command.Split(' ');
switch (data[0])
{
case "@testmode":
{
if (TestingMode)
{
TestingMode = false;
Console.WriteLine("Test Mode Off");
}
else
{
TestingMode = true;
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server will exit for 5 min to fix some bugs, please be paitent" }), System.Drawing.Color.Black, 0x7db), Program.Values);
CommandsAI("@save");
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Database.EntityVariableTable.Save(0, Vars);
var WC = Program.Values.ToArray();
foreach (Client.GameState client in WC)
{
if (client.Account.State != AccountTable.AccountState.ProjectManager)
{
client.Send("Server will exit for 5 min to fix some bugs, please be paitent !");
client.Disconnect();
}
}
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Console.WriteLine("Test Mode On");
}
break;
}
case "@clear":
{
Console.Clear();
SomailProject.Console.WriteLine("Consle and program Cleared ");
break;
}
case "@sh":
{
Console.WriteLine(Program.SnowBa);
break;
}
case "@sh1":
{
Program.SnowBa = true;
break;
}
case "@sh2":
{
Program.SnowBa = false;
break;
}
case "@Copra":
case "@bigbos":
SomailProject.Console.WriteLine("Server will restart after 10 minutes.");
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 5 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 4 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 4 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 3 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 3 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 2 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 2 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 1 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 1 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
SomailProject.Console.WriteLine("Server will exit after 1 minute.");
CommandsAI("@save");
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The Server restarted, Please log in after 5 minutes ", System.Drawing.Color.Orange, 0x7db), Program.Values);
try
{
CommandsAI("@restart");
}
catch
{
SomailProject.Console.WriteLine("Server cannot exit");
}
break;
case "@flushbans":
{
Database.IPBan.Load();
break;
}
case "@alivetime":
{
DateTime now = DateTime.Now;
TimeSpan t2 = new TimeSpan(StartDate.ToBinary());
TimeSpan t1 = new TimeSpan(now.ToBinary());
Console.WriteLine("The server has been online " + (int)(t1.TotalHours - t2.TotalHours) + " hours, " + (int)((t1.TotalMinutes - t2.TotalMinutes) % 1) + " minutes.");
break;
}
case "@online":
{
Console.WriteLine("Online Entitys count: " + Kernel.GamePool.Count);
string line = "";
foreach (Client.GameState pClient in Program.Values)
line += pClient.Entity.Name + ",";
if (line != "")
{
line = line.Remove(line.Length - 1);
Console.WriteLine("Entitys: " + line);
}
break;
}
case "@memoryusage":
{
var proc = System.Diagnostics.Process.GetCurrentProcess();
Console.WriteLine("Thread count: " + proc.Threads.Count);
Console.WriteLine("Memory set(MB): " + ((double)((double)proc.WorkingSet64 / 1024)) / 1024);
proc.Close();
break;
}
case "@save":
{
Save();
}
break;
case "@PlayerCap":
{
try
{
PlayerCap = int.Parse(data[1]);
}
catch
{
}
break;
}
case "@skill":
{
Game.Features.Tournaments.SkillPk.SkillTournament.Open();
foreach (var clien in Kernel.GamePool.Values)
{
if (clien.Team == null)
clien.Team = new Game.ConquerStructures.Team(clien);
Game.Features.Tournaments.SkillPk.SkillTournament.Join(clien, 3);
}
break;
}
case "@team":
{
Game.Features.Tournaments.TeamPk.TeamTournament.Open();
foreach (var clien in Kernel.GamePool.Values)
{
if (clien.Team == null)
clien.Team = new Game.ConquerStructures.Team(clien);
Game.Features.Tournaments.TeamPk.TeamTournament.Join(clien, 3);
}
break;
}
case "@exit":
{
Program.Save(true);
CommandsAI("@save");
GameServer.Disable();
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i].Disable();
}
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Database.EntityVariableTable.Save(0, Vars);
var WC = Program.Values.ToArray();
Parallel.ForEach(Program.Values, client =>
{
client.Send(" Server will exit for 5 min to Solve The Problem, please be paitent ");
client.Disconnect();
});
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { " Server will exit for 5 min to Solve The Problem, please be paitent " }), System.Drawing.Color.Black, 0x7db), Program.Values);
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Environment.Exit(0);
}
break;
case "serverpass":
{
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
{
cmd.Select("configuration").Where("Server", Constants.ServerName);
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
Constants.ServerGMPass = r.ReadString("ServerGMPass");
}
}
break;
}
case "@pressure":
{
Console.WriteLine("Genr: " + World.GenericThreadPool.ToString());
Console.WriteLine("Send: " + World.SendPool.ToString());
Console.WriteLine("Recv: " + World.ReceivePool.ToString());
break;
}
case "@restart":
{
try
{
Program.Save();
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server Will Be Restart Now !" }), System.Drawing.Color.Black, 0x7db), Program.Values);
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
var WC = Program.Values.ToArray();
foreach (Client.GameState client in WC)
{
client.Send(" Server Will Be Restart Now ");
client.Disconnect();
}
GameServer.Disable();
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i].Disable();
}
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Application.Restart();
Environment.Exit(0);
}
catch (Exception e)
{
Console.WriteLine(e);
Console.ReadLine();
}
}
break;
case "@account":
{
Database.AccountTable account = new AccountTable(data[1]);
account.Password = data[2];
account.State = AccountTable.AccountState.Entity;
account.Save();
}
break;
case "@process":
{
HandleClipboardPacket(command);
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public static void WriteLine(string Line)
{
try
{
Console.WriteLine(Line);
}
catch { }
}
public static void HandleClipboardPacket(string cmd)
{
string[] pData = cmd.Split(' ');
long off = 0, type = 0, val = 0;
if (pData.Length > 1)
{
string[] oData = pData[1].Split(':');
if (oData.Length == 3)
{
off = long.Parse(oData[0]);
type = long.Parse(oData[1]);
if (oData[2] == "u")
val = 1337;
else
val = long.Parse(oData[2]);
}
}
string Data = OSClipboard.GetText();
string[] num = Data.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
byte[] packet = new byte[num.Length + 8];
for (int i = 0; i < num.Length; i++)
packet[i] = byte.Parse(num[i], System.Globalization.NumberStyles.HexNumber);
Writer.WriteUInt16((ushort)(packet.Length - 8), 0, packet);
if (off != 0)
{
switch (type)
{
case 1:
{
packet[(int)off] = (byte)val;
break;
}
case 2:
{
Writer.WriteUInt16((ushort)val, (int)off, packet);
break;
}
case 4:
{
Writer.WriteUInt32((uint)val, (int)off, packet);
break;
}
case 8:
{
Writer.WriteUInt64((ulong)val, (int)off, packet);
break;
}
}
}
foreach (var client in Program.Values)
{
if (val == 1337 && type == 4)
Writer.WriteUInt32(client.Entity.UID, (int)off, packet);
client.Send(packet);
}
}
private static void GameServer_OnClientReceive(byte[] buffer, int length, ClientWrapper obj)
{
if (obj.Connector == null)
{
obj.Disconnect();
}
else
{
GameState connector = obj.Connector as GameState;
if (connector.Exchange)
{
connector.Exchange = false;
connector.Action = (byte)1;
COServer.Network.Cryptography.GameCryptography gameCryptography = new COServer.Network.Cryptography.GameCryptography(Encoding.Default.GetBytes(Constants.GameCryptographyKey));
byte[] numArray = new byte[length];
Array.Copy((Array)buffer, (Array)numArray, length);
gameCryptography.Decrypt(numArray, length);
bool flag = false;
int offset = 0;
for (int x = 0; x < 80; x++)
{
if (BitConverter.ToInt32(numArray, x) == 128)
{
if (length >= 205)
{
offset = x;
flag = true;
connector.Cryptography.Decrypt(buffer, length - 40);
}
else
{
offset = x;
connector.Cryptography.Decrypt(buffer, length);
}
}
}
int int32 = BitConverter.ToInt32(buffer, offset);
int index1 = offset + 4;
if (int32 != 128)
{
connector.Disconnect(true);
}
else
{
byte[] bytes = new byte[128];
int index2 = 0;
while (index2 < int32)
{
bytes[index2] = buffer[index1];
++index2;
++index1;
}
string PublicKey = Encoding.Default.GetString(bytes);
connector.Cryptography = connector.DHKeyExchange.HandleClientKeyPacket(PublicKey, connector.Cryptography);
if (!flag)
return;
byte[] buffer1 = new byte[40];
Buffer.BlockCopy((Array)buffer, length - 40, (Array)buffer1, 0, 40);
processData(buffer1, 40, connector);
}
}
else
processData(buffer, length, connector);
}
}
private static void processData(byte[] buffer, int length, Client.GameState Client)
{
Client.Cryptography.Decrypt(buffer, length);
Client.Queue.Enqueue(buffer, length);
if (Client.Queue.CurrentLength > 1224)
{
Console.WriteLine("[Disconnect]Reason:The packet size is too big. " + Client.Queue.CurrentLength);
Client.Disconnect();
return;
}
while (Client.Queue.CanDequeue())
{
byte[] data = Client.Queue.Dequeue();
try
{
Network.PacketHandler.HandlePacket(data, Client);
}
catch (Exception e)
{
if (e.ToString().Contains("Index"))
{
return;
}
else
{
Network.PacketHandler.HandlePacket(data, Client);
}
}
}
}
static void GameServer_OnClientConnect(ClientWrapper obj)
{
Client.GameState client = new Client.GameState(obj);
client.Send(client.DHKeyExchange.CreateServerKeyPacket());
obj.Connector = client;
}
static void GameServer_OnClientDisconnect(ClientWrapper obj)
{
if (obj.Connector != null)
(obj.Connector as Client.GameState).Disconnect();
else
obj.Disconnect();
}
public static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3)
{
var player = arg3.Connector as Client.AuthClient;
AuthClient authClient = arg3.Connector as AuthClient;
player.Cryptographer.Decrypt(buffer, length);
player.Queue.Enqueue(buffer, length);
while (player.Queue.CanDequeue())
{
byte[] packet = player.Queue.Dequeue();
ushort len = BitConverter.ToUInt16(packet, 0);
if (len == 312)
{
player.Info = new Authentication();
player.Info.Deserialize(packet);
player.Account = new AccountTable(player.Info.Username);
if (!LoginBruteForce.AcceptJoin(arg3.IP))
{
Console.WriteLine(string.Concat(new string[] { "Client > ", player.Info.Username, "was blocked address", arg3.IP, "!" }));
arg3.Disconnect();
break;
}
Forward Fw = new Forward();
Console.WriteLine("UserName: {0} Password: {1} ServerName: {2} Online", player.Info.Username, player.Info.Password, player.Info.Server);
if (player.Account.Username == player.Info.Username && player.Account.exists)
{
if (player.Account.Password == player.Info.Password && player.Account.exists)
{
Fw.Identifier = player.Account.GenerateKey();
Kernel.AwaitingPool[Fw.Identifier] = player.Account;
Fw.IP = GameIP;
Fw.Port = GamePort;
}
else
{
LoginBruteForce.ClientRegistred(arg3.IP);
Fw.Type = Forward.ForwardType.InvalidInfo;
}
}
else
{
Fw.Type = Forward.ForwardType.WrongAccount;
}
player.Send(Fw);
}
}
}
static void AuthServer_OnClientDisconnect(ClientWrapper obj)
{
obj.Disconnect();
}
static void AuthServer_OnClientConnect(ClientWrapper obj)
{
Client.AuthClient authState;
obj.Connector = (authState = new Client.AuthClient(obj));
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
//Protection.LoaderProgram.CLientsPass.Clear();
//Protection.LoaderProgram.CLientsPass.Add(authState.PasswordSeed, "");
}
internal static Client.GameState FindClient(string name)
{
return Values.FirstOrDefault(p => p.Entity.Name == name);
}
#region Copra Style
static bool thistime = false;
private static void CopraStep(int width, int height, int[] y, int[] l)
{
int x;
thistime = !thistime;
for (x = 0; x < width; ++x)
{
if (x % 11 == 10)
{
if (!thistime)
continue;
System.Console.ForegroundColor = System.ConsoleColor.Red;
}
else
{
System.Console.ForegroundColor = System.ConsoleColor.DarkGreen;
System.Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
System.Console.Write(R);
System.Console.ForegroundColor = System.ConsoleColor.Green;
}
System.Console.SetCursorPosition(x, y[x]);
System.Console.Write(R);
y[x] = inBoxY(y[x] + 1, height);
System.Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
System.Console.Write(' ');
}
}
private static void Initialize(out int width, out int height, out int[] y, out int[] l)
{
int h1;
int h2 = (h1 = (height = System.Console.WindowHeight) / 2) / 2;
width = System.Console.WindowWidth - 1;
y = new int[width];
l = new int[width];
int x;
System.Console.Clear();
for (x = 0; x < width; ++x)
{
y[x] = r.Next(height);
l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
}
}
static Random r = new Random();
public static DateTime KingsTime;
static char R
{
get
{
int t = r.Next(10);
if (t <= 2)
return (char)('0' + r.Next(10));
else if (t <= 4)
return (char)('a' + r.Next(27));
else if (t <= 6)
return (char)('A' + r.Next(27));
else
return (char)(r.Next(32, 255));
}
}
public static int inBoxY(int n, int height)
{
n = n % height;
if (n < 0)
return n + height;
else
return n;
}
#endregion Copra Style
internal static void WriteLine(string p, ushort MsgId, short p_2)
{
throw new NotImplementedException();
}
public static int Carnaval { get; set; }
public static int Carnaval2 { get; set; }
public static int Carnaval3 { get; set; }
public static uint NextItemID { get; set; }
public static uint ExpRateSpell = 2;
public static string GetString(byte[] data, int position, int count)
{
var str = Program.Encoding.GetString(data, position, count);
str = str.Replace("\0", "").Replace("\r", "");
return str;
}
public static string GetString(byte[] data)
{
var str = Program.Encoding.GetString(data);
str = str.Replace("\0", "").Replace("\r", "");
return str;
}
public static List<ushort> EventsMap = new List<ushort>()
{
50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 50012, 50013, 50014, 50015, 50016, 50017, 1508, 1518, 2014, 1507,
};
}
public class Copra_Times
{
public static DateTime now
{
get
{
return DateTime.Now;
}
}
public class Start
{
public static bool SnowBanshee
{
get
{
return ((now.Minute == 57 || now.Minute == 27) && now.Second == 30);
}
}
public static bool ThrillingSpook
{
get
{
return ((now.Minute == 5 || now.Minute == 35) && now.Second == 30);
}
}
public static bool NemesisTyrant
{
get
{
return ((now.Minute == 15 || now.Minute == 45) && now.Second == 30);
}
}
public static bool SkyWar
{
get
{
return (now.Hour == 1 || now.Hour == 13) && now.Minute == 10 && now.Second == 1;
}
}
public static bool TheTeam
{
get
{
return (now.Hour == 14 || now.Hour == 2) && now.Minute == 10 && now.Second == 1;
}
}
public static bool EliteGW
{
get
{
return (now.Hour == 17 && now.Minute == 0);
}
}
public static bool SkillTeam
{
get
{
return (now.Hour == 22) && now.Minute == 00;
}
}
public static bool TeamPK
{
get
{
return (now.Hour == 19) && now.Minute == 00;
}
}
public static bool CTF
{
get
{
return (now.Hour == 19 && now.Minute == 0) || (now.Hour == 12 && now.Minute == 0);
}
}
public static bool NobiltyWarPole
{
get
{
return (now.Hour == 22 && now.Minute == 30) || (now.Hour == 4 && now.Minute == 0);
}
}
public static bool GuildScoreWar
{
get
{
return (now.Hour == 12 && now.Minute == 0) || (now.Hour == 23 && now.Minute == 0);
}
}
public static bool ClassWar
{
get
{
return (now.Hour == 18 && now.Minute == 0) || (now.Hour == 8 && now.Minute == 0);
}
}
public static bool HeroOfGame
{
get
{
return now.Minute == 30;
}
}
public static bool FBSS
{
get
{
return now.Minute == 25;
}
}
public static bool FBSS2
{
get
{
return now.Minute >= 25 && now.Minute < 28;
}
}
public static int hunterthief = 42;
public static int dashbash = 46;
public static int chase = 45;
public static int dizzy = 49;
public static bool Nobilty
{
get
{
return now.Minute >= 20 && now.Minute <= 24;
}
}
}
public class End
{
public static bool FBSS
{
get
{
return now.Minute >= 28;
}
}
public static int hunterthief = 45;
public static int dashbash = 48;
public static bool Cyclone
{
get
{
return now.Minute == 29;
}
}
public static int chase = 45;
public static int dizzy2 = 50;
public static bool Nobilty
{
get
{
return now.Minute >= 25;
}
}
public static bool EliteGW
{
get
{
return now.Hour == 18;
}
}
}
}
public class rates
{
public static uint GuildWar;
public static uint ChangeName;
public static uint king;
public static uint prince;
public static uint EliteGw;
public static uint SkillTeam1;
public static uint SkillTeam2;
public static uint SkillTeam3;
public static uint SkillTeam4;
public static uint WeeklyPk;
public static uint topguild;
public static uint mrconquer;
public static uint uniquepk;
public static uint Portals;
public static uint heroofgame;
public static uint NobilityPrize;
public static uint lastman;
public static uint Daily;
public static uint fbss;
public static uint Poles;
public static uint Clanwarday;
public static uint soulp6;
public static uint soulp7;
public static uint changebody;
public static uint ref6;
public static uint Twar;
public static uint stwar;
public static uint ctf;
public static uint cps;
public static uint ClanwarCity;
public static uint ClassPk;
public static uint DeathMatchs;
public static uint lobby;
public static uint hunter;
public static uint thief;
public static uint housepromete;
public static uint itembox;
public static uint houseupgrade;
public static uint MonthlyPk;
public static uint TopSpouse;
public static uint Bosses;
public static uint Night;
public static uint Broadcast;
public static uint GuildFee;
public static uint TeleportFee;
public static uint DragonBall;
public static uint Meteor;
public static string VoteUrl;
public static string coder = "RaMbO";
public static uint Reincarnation;
public static uint donationrate;
public static string servername { get { return Constants.ServerName; } }
public static void Load(IniFile IniFile)
{
DragonBall = IniFile.ReadUInt32("Rates", "DragonBall");
Meteor = IniFile.ReadUInt32("Rates", "Meteor");
GuildWar = IniFile.ReadUInt32("Rates", "GuildWar");
EliteGw = IniFile.ReadUInt32("Rates", "questday");
Bosses = IniFile.ReadUInt32("Rates", "Bosses");
Broadcast = IniFile.ReadUInt32("Rates", "Broadcast");
TeleportFee = IniFile.ReadUInt32("Rates", "TeleportFee");
GuildFee = IniFile.ReadUInt32("Rates", "GuildFee");
king = IniFile.ReadUInt32("Rates", "king");
prince = IniFile.ReadUInt32("Rates", "prince");
Reincarnation = IniFile.ReadUInt32("Rates", "Reincarnation");
MonthlyPk = IniFile.ReadUInt32("Rates", "MonthlyPk");
TopSpouse = IniFile.ReadUInt32("Rates", "TopSpouse");
ChangeName = IniFile.ReadUInt32("Rates", "ChangeName");
housepromete = IniFile.ReadUInt32("Rates", "housepromete");
itembox = IniFile.ReadUInt32("Rates", "itembox");
Night = IniFile.ReadUInt32("Rates", "Night");
VoteUrl = IniFile.ReadString("Rates", "VoteUrl");
Portals = IniFile.ReadUInt32("Rates", "Portals");
coder = IniFile.ReadString("Rates", "coder");
SkillTeam1 = IniFile.ReadUInt32("Rates", "SkillTeam1");
SkillTeam2 = IniFile.ReadUInt32("Rates", "SkillTeam2");
SkillTeam3 = IniFile.ReadUInt32("Rates", "SkillTeam3");
SkillTeam4 = IniFile.ReadUInt32("Rates", "SkillTeam4");
soulp6 = IniFile.ReadUInt32("Rates", "soulp6");
soulp7 = IniFile.ReadUInt32("Rates", "soulp7");
ref6 = IniFile.ReadUInt32("Rates", "ref6");
changebody = IniFile.ReadUInt32("Rates", "changebody");
uniquepk = IniFile.ReadUInt32("Rates", "uniquepk");
WeeklyPk = IniFile.ReadUInt32("Rates", "WeeklyPk");
fbss = IniFile.ReadUInt32("Rates", "fbss");
Poles = IniFile.ReadUInt32("Rates", "Poles");
Clanwarday = IniFile.ReadUInt32("Rates", "Clanwarday");
lastman = IniFile.ReadUInt32("Rates", "lastman");
Daily = IniFile.ReadUInt32("Rates", "Daily");
topguild = IniFile.ReadUInt32("Rates", "topguild");
mrconquer = IniFile.ReadUInt32("Rates", "mrconquer");
NobilityPrize = IniFile.ReadUInt32("Rates", "NobilityPrize");
heroofgame = IniFile.ReadUInt32("Rates", "heroofgame");
Twar = IniFile.ReadUInt32("Rates", "Twar");
stwar = IniFile.ReadUInt32("Rates", "stwar");
ctf = IniFile.ReadUInt32("Rates", "ctf");
cps = IniFile.ReadUInt32("Rates", "cps");
ClanwarCity = IniFile.ReadUInt32("Rates", "ClanwarCity");
ClassPk = IniFile.ReadUInt32("Rates", "ClassPk");
DeathMatchs = IniFile.ReadUInt32("Rates", "DeathMatchs");
lobby = IniFile.ReadUInt32("Rates", "lobby");
hunter = IniFile.ReadUInt32("Rates", "hunter");
thief = IniFile.ReadUInt32("Rates", "thief");
donationrate = IniFile.ReadUInt32("Rates", "donationrate");
}
}
}
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using SomailProject.Network;
using SomailProject.Database;
using SomailProject.Network.Sockets;
using SomailProject.Network.AuthPackets;
using SomailProject.Game;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using SomailProject.Network.GamePackets;
using SomailProject.Client;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading;
using SomailProject;
using SomailProject.Network.GamePackets.Union;
using ProtoBuf;
using SomailProject.MaTrix;
using SomailProject.Game.MsgServer;
namespace SomailProject
{
class Program
{
public static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Application_ThreadException);
Time32 Start = Time32.Now;
RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
Kernel.Random = new FastRandom(RandomSeed);
StartDate = DateTime.Now;
Console.Title = "Samuel-Dawod"; Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("_-_-_-_-_-_ ♥ Conquer Matrix ♥ _-_-_-_-_-_");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Load server configuration");
string ConfigFileName = "SomailProject.ini";
IniFile IniFile = new IniFile(ConfigFileName);
GameIP = IniFile.ReadString("configuration", "IP");
GamePort = IniFile.ReadUInt16("configuration", "GamePort");
AuthPort = new List<ushort>()
{
IniFile.ReadUInt16("configuration", "AuthPort"),
};
Constants.ServerName = IniFile.ReadString("configuration", "ServerName");
TestingMode = IniFile.ReadString("configuration", "TestMode", "0") == "1" ? true : false;
AllTest = IniFile.ReadString("configuration", "AllTest", "0") == "1" ? true : false;
rates.Load(IniFile);
Database.DataHolder.CreateConnection(
IniFile.ReadString("MySql", "Host", "localhost"),
IniFile.ReadString("MySql", "Username", "root"),
IniFile.ReadString("MySql", "Password", "az4des123"),
IniFile.ReadString("MySql", "Database", "cq"));
PrestigeStars = 54;
EntityUID = new Counter(0);
bool x = false;
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
{
cmd.Select("configuration").Where("Server", Constants.ServerName);
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
{
EntityUID = new Counter(r.ReadUInt32("EntityID"));
Game.ConquerStructures.Society.Guild.GuildCounter = new SomailProject.Counter(r.ReadUInt32("GuildID"));
ConquerItem.ItemUID = new Counter(r.ReadUInt32("ItemUID"));
Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate");
Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate");
Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate");
Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate");
Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple");
if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) x = true;
Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple");
Constants.ItemDropRate = r.ReadUInt32("ItemDropRate");
Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~');
Constants.WebAccExt = r.ReadString("AccountWebExt");
Constants.WebVoteExt = r.ReadString("VoteWebExt");
Constants.WebDonateExt = r.ReadString("DonateWebExt");
Constants.ServerWebsite = r.ReadString("ServerWebsite");
Constants.ServerGMPass = r.ReadString("ServerGMPass");
PlayerCap = r.ReadInt32("PlayerCap");
Union.UnionCounter = new Counter(r.ReadUInt32("UnionID"));
Database.EntityVariableTable.Load(0, out Vars);
VoteSystem.Count = r.ReadInt32("VotesCount");
}
}
}
if (EntityUID.Now == 0)
{
Console.Clear();
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.ReadLine();
return;
}
{
Console.WriteLine("Initializing Database.");
Console.WriteLine("Loading The Hard Things");
Database.ConquerItemInformation.Load();
Database.ConquerItemTable.ClearNulledItems();
InnerPowerTable.LoadDBInformation();
#region WardRobe
WardRobe.Load_coatstorage_type();
WardRobe.Load_title_type();
#endregion
InnerPowerTable.Load();
PerfectionTable.LoadItemRefineAttribute();
if (x) MsgSignIn.Reset();
PerfectionTable.LoadItemRefineEffect();
PerfectionTable.LoadItemRefineEffectEX();
Database.Flowers.LoadFlowers();
Database.SignInTable.Load();
Database.MonsterInformation.Load();
Database.MapsTable.Load();
SomailProject.MaTrix.SoulProtection.Load();
World = new World();
World.Init();
Map.CreateTimerFactories();
Database.SignInTable.Load();
Database.DMaps.LoadMapPaths();
Database.DMaps.LoadMap(700);
DMaps.LoadMap(2068);
Database.DMaps.LoadMap(3868);
Database.DMaps.LoadMap(3935);
Database.DMaps.LoadMap(10137);
Copra.QuestInfo.Load();
Database.VipTable.LoadAllVips();
Database.SpellTable.Load();
Database.ShopFile.Load();
Database.HonorShop.Load();
Database.RacePointShop.Load();
VoteSystem.Load();
Database.ChampionShop.Load();
new MsgUserAbilityScore().LoadWallOfPrestige();
PrestigeRank.LoadRanking();
Console.WriteLine("WallOfPrestigeRank Initilizied");
Database.EShopFile.Load();
Database.EShopV2File.Load();
Database.AddingInformationTable.Load();
Database.LotteryTable.Load();
Database.vipLottery.Load();
Copra.Roulette.Database.Roulettes.Load();
Copra.Way2Heroes.Load();
Database.ConquerItemTable.ClearNulledItems();
Refinery.Load();
Values = new Client.GameState[0];
new Game.Map(1002, Database.DMaps.MapPaths[1002]);
new Game.Map(1038, Database.DMaps.MapPaths[1038]);
new Game.Map(2071, Database.DMaps.MapPaths[2071]);
new Game.Map(2057, Database.DMaps.MapPaths[2057]);
new Game.Map(4000, Database.DMaps.MapPaths[4000]);
new Game.Map(4003, Database.DMaps.MapPaths[4003]);
new Game.Map(4006, Database.DMaps.MapPaths[4006]);
new Game.Map(4008, Database.DMaps.MapPaths[4008]);
new Game.Map(4020, Database.DMaps.MapPaths[4020]);
if (DMaps.LoadMap(1038))
Game.GuildWar.Initiate();
if (DMaps.LoadMap(10380))
Game.SuperGuildWar.Initiate();
new Game.Map(1509, Database.DMaps.MapPaths[1509]);
new Game.Map(10002, 2021, Database.DMaps.MapPaths[2021]);
new Game.Map(8883, 1004, Database.DMaps.MapPaths[1004]);
Constants.PKFreeMaps.Add(8883);
Game.EliteGuildWar.EliteGwint();
Database.DataHolder.ReadStats();
Database.IPBan.Load();
JiangHuTable.LoadStatus();
JiangHuTable.LoadRanks();
Database.NobilityTable.Load();
Database.ArenaTable.Load();
Database.TeamArenaTable.Load();
Database.GuildTable.Load();
UnionTable.Load();
AuctionBase.Load();
Database.ChiTable.LoadAllChi();
StorageItem.Load();
Clan.LoadClans();
Kernel.Magic.Load();
TutorInfo.Load();
Database.Disdain.Load();
Tranformation.Int();
Kernel.AtributeStatus.Load();
AtributesStatus.LoadExpInfo();
RebornInfo = new RebornInfomations();
RebornInfo.Load();
Game.Screen.CreateTimerFactories();
new MsgEquipRefineRank().UpdateRanking();
Database.ConquerItemTable.ClearNulledItems();
Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
World.CreateTournaments();
new MySqlCommand(MySqlCommandType.Update).Update("entities").Set("Online", 0).Execute();
Console.WriteLine("Initializing Sockets.");
AuthServer = new ServerSocket[AuthPort.Count];
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i] = new ServerSocket();
AuthServer[i].OnClientConnect += AuthServer_OnClientConnect;
AuthServer[i].OnClientReceive += AuthServer_OnClientReceive;
AuthServer[i].OnClientDisconnect += AuthServer_OnClientDisconnect;
AuthServer[i].Enable(AuthPort[i], "0.0.0.0");
Console.WriteLine("Auth " + i + " server online.");
}
{
GameServer = new ServerSocket();
GameServer.OnClientConnect += GameServer_OnClientConnect;
GameServer.OnClientReceive += GameServer_OnClientReceive;
GameServer.OnClientDisconnect += GameServer_OnClientDisconnect;
GameServer.Enable(GamePort, "0.0.0.0");
Console.WriteLine("Game server online.");
Console.WriteLine("Web server online.");
Copra.Pet.CreateTimerFactories();
AI.CreateTimerFactories();
var client = new GameState(null);
client.Entity = new Entity(EntityFlag.Monster, false);
client.Entity.MapID = 1002;
Npcs npc = new Npcs(client);
var req = new NpcRequest();
req.Deserialize(new byte[28]);
Npcs.GetDialog(req, client);
client = null;
SomailProject.Booths.Load();
}
Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");
Console.WriteLine("[********************** ♥ [Samuel.Dawod] ♥ **********************]");
SomailHandler += SomailConsole_CloseEvent;
SetConsoleCtrlHandler(SomailHandler, true);
GC.Collect();
WorkConsole();
}
}
public static int PrestigeStars = 0;
public static RebornInfomations RebornInfo;
public static Encoding Encoding = ASCIIEncoding.Default;
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public static int PlayerCap = 1000;
public static bool ALEXPC = false;
public static bool NemesisTyrantSpanwed = false;
public static long MaxOn = 0;
public static long MaxEntitys = 0;
public static ServerSocket[] AuthServer;
public static int CpuUse = 0;
public static ServerSocket GameServer;
public static Counter EntityUID;
public static string GameIP;
public static bool SpookAlive = false;
public static DayOfWeek Today;
public static ushort GamePort;
public static List<ushort> AuthPort;
public static DateTime StartDate;
public static bool reseted = false;
public static uint ScreenColor = 0;
public static DateTime RestartDate = DateTime.Now.AddHours(24);
public static bool restarted = false;
public static bool WarEnd = false;
public static bool uniquepk = false;
public static uint mess = 0;
public static World World;
public static Client.GameState[] GamePool = new Client.GameState[0];
public static Client.GameState[] Values = new Client.GameState[0];
public static VariableVault Vars;
public static long WeatherType = 0L;
public static bool TestingMode = false;
public static bool AllTest = false;
public static bool SnowBa = true;
public static bool Nemesis = true;
public static bool ThrillingSpook = true;
public static uint PhysicalDamage = 100;// + 150%
public static bool SwordMaster = true;
public static bool TeratoDragon = true;
public static bool SnowSoul = true;
public static int RandomSeed = 0;
public static short GetDistance(ushort X, ushort Y, ushort X2, ushort Y2)
{
return (short)Math.Sqrt((X - X2) * (X - X2) + (Y - Y2) * (Y - Y2));
}
#region Translate
public static void SaveTranslate()
{
var file = Environment.CurrentDirectory + "Translate.txt";
if (File.Exists(file))
File.Delete(file);
StreamWriter writer = new StreamWriter(File.Create(file), Encoding);
writer.AutoFlush = true;
foreach (var item in Kernel.Translateed)
writer.WriteLine(item.Key + "@@" + item.Value);
writer.Close();
}
public static void LoadTranslate()
{
var file = Environment.CurrentDirectory + "Translate.txt";
if (File.Exists(file))
{
string[] text = File.ReadAllLines(file, Encoding);
for (int x = 0; x < text.Length; x++)
{
string line = text[x];
string[] split = line.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length < 1)
continue;
var key = split[0];
if (split.Length < 2)
continue;
var value = split[1];
if (!Kernel.Translateed.ContainsKey(key))
Kernel.Translateed.Add(key, value);
}
}
}
#endregion
#region VersionChecker
//if (VersionChecker.IsValidVersion() == false)
//{
// MessageBox.Show("Your Trial Version has expired, Please get the Full version |Contact 011 42 72 19 32");
// SomailProject.Console.WriteLine("Enter Password:");
// Program.Password = Console.ReadLine();
// if (ClassExtensions.Get64HashCode(Program.Password) != 4586181316755855993)
// {
// MessageBox.Show("Your Trial Version has expired, Please get the Full version |Contact 011 42 72 19 32");
// SomailProject.Console.WriteLine("Thx. For Waiting...!");
// SomailProject.Console.WriteLine("Wrong Password!");
// SomailProject.Console.WriteLine("If Want To make this Source Work");
// SomailProject.Console.WriteLine("You need to put the right Password. !");
// SomailProject.Console.ReadLine();
// MessageBox.Show("You Will Get Hacked. | Contact 011 42 72 19 32");
// System.Console.ForegroundColor = System.ConsoleColor.DarkGreen;
// System.Console.WindowLeft = System.Console.WindowTop = 0;
// System.Console.WindowHeight = System.Console.BufferHeight = System.Console.LargestWindowHeight;
// System.Console.WindowWidth = System.Console.BufferWidth = System.Console.LargestWindowWidth;
// System.Console.CursorVisible = false;
// int width, height;
// int[] y;
// int[] l;
// Initialize(out width, out height, out y, out l);
// int ms;
// while (true)
// {
// DateTime t1 = DateTime.Now;
// CopraStep(width, height, y, l);
// ms = 10 - (int)((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds;
// if (ms > 0)
// System.Threading.Thread.Sleep(ms);
// if (System.Console.KeyAvailable)
// if (System.Console.ReadKey().Key == ConsoleKey.F5)
// Initialize(out width, out height, out y, out l);
// }
// // Environment.Exit(0);
// }
// elsez
// {
// VersionChecker.TrialEnd();
// MessageBox.Show("Your Trial Version has Renewed, To get the Full version");
// }
// return;
//}
//else
//{
// VersionChecker chk = new VersionChecker();
//}
#endregion VersionChecker
#region Closing Events
private static bool SomailConsole_CloseEvent(CtrlType sig)
{
Save();
return true;
}
private static Native.ConsoleEventHandler SomailHandler;
[DllImport("Kernel32")]
private static extern bool SetConsoleCtrlHandler(Native.ConsoleEventHandler handler, bool add);
private delegate bool EventHandler(CtrlType sig);
#endregion
public static bool Save(bool Exit = false)
{
try
{
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
foreach (Client.GameState client in Program.Values)
{
SaveTranslate();
Database.JiangHuTable.FullSave(client);
Database.EntityTable.SaveEntity(client);
Database.SkillTable.SaveClientSpells(client);
Database.SkillTable.SaveProficiencies(client);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic);
Database.TeamArenaTable.SaveArenaStatistics(client.TeamArenaStatistic);
client.WardRobe.Save();
}
}
Database.InnerPowerTable.Save();
Database.Flowers.SaveFlowers();
AuctionBase.Save();
Game.ClanWarArena.Save();
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", Constants.ServerName))
{
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
{
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("EntityID", EntityUID.Now).Set("ServerKingdom", Kernel.ServerKingdom).Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now).Where("Server", Constants.ServerName).Execute();
if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) MsgSignIn.Reset();
}
}
}
using (var cmd = new MySqlCommand(MySqlCommandType.Update).Update("configuration"))
cmd.Set("LastDailySignReset", DateTime.Now.Month).Execute();
Console.WriteLine("Saving cmd Done.");
//if (Exit)
// Environment.Exit(0);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return true;
}
#region Exceptions & Logs
public static void AddVendorLog(String vendor, string buying, string moneyamount, ConquerItem Item)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\VendorLogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("{0} HAS BOUGHT AN ITEM : {2} FROM {1} SHOP - for {3}", vendor, buying, Item.ToLog(), moneyamount);
file.WriteLine("------------------------------------------------------------------------------------");
file.Close();
}
}
public static void AddGMCommand(string gm, string commandStr)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\GMCommandsLog\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(gm + commandStr);
file.Close();
}
}
public static void RemoveCps(string text)
{
try
{
text = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + text;
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\RemoveCps\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true);
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(text);
file.Close();
}
}
catch (Exception ex) { Console.WriteLine(ex); }
}
public static void AddCpsWin(string text)
{
try
{
text = "[" + DateTime.Now.ToString("HH:mm:ss") + "]" + text;
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\AddWinCps\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(text);
file.Close();
}
}
catch (Exception ex) { Console.WriteLine(ex); }
}
public static void AddDropLog(String Name, ConquerItem Item)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\droplogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
string path = NewPath + "\\" + DateTime.Now.Day + ".txt";
if (!File.Exists(path)) File.AppendAllText(path, "");
string text = "------------------------------------------------------------------------------------"
+ Environment.NewLine + string.Format("Entity {0} HAS DROPPED AN ITEM : {1} -", Name, Item.ToLog())
+ Environment.NewLine + "------------------------------------------------------------------------------------";
File.AppendAllText(path, text);
}
public static void AddTradeLog(Game.ConquerStructures.Trade first, String firstN, Game.ConquerStructures.Trade second, String secondN)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "database\\Security\\Trade\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine("************************************************************************************");
file.WriteLine("First Person TradeLog ({0}) -", firstN);
file.WriteLine("Gold Traded: " + first.Money);
file.WriteLine("Conquer Points Traded: " + first.ConquerPoints);
for (int i = 0; i < first.Items.Count; i++)
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("Item : " + first.Items[i].ToLog());
file.WriteLine("------------------------------------------------------------------------------------");
}
file.WriteLine("Second Person TradeLog ({0}) -", secondN);
file.WriteLine("Gold Traded: " + second.Money);
file.WriteLine("Conquer Points Traded: " + second.ConquerPoints);
for (int i = 0; i < second.Items.Count; i++)
{
file.WriteLine("------------------------------------------------------------------------------------");
file.WriteLine("Item : " + second.Items[i].ToLog());
file.WriteLine("------------------------------------------------------------------------------------");
}
file.WriteLine("************************************************************************************");
}
}
public static void AddMobLog(string War, string name, uint CPs = 0, uint item = 0)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\MobLogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
if (CPs != 0)
file.WriteLine(name + " got " + CPs + " CPs from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
else
file.WriteLine(name + " got " + item + " Item from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
}
}
public static void AddWarLog(string War, string CPs, string name)
{
String folderN = DateTime.Now.Year + "-" + DateTime.Now.Month,
Path = "gmlogs\\Warlogs\\",
NewPath = System.IO.Path.Combine(Path, folderN);
if (!File.Exists(NewPath + folderN))
{
System.IO.Directory.CreateDirectory(System.IO.Path.Combine(Path, folderN));
}
if (!File.Exists(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
using (System.IO.FileStream fs = System.IO.File.Create(NewPath + "\\" + DateTime.Now.Day + ".txt"))
{
fs.Close();
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(NewPath + "\\" + DateTime.Now.Day + ".txt", true))
{
file.WriteLine(name + " got " + CPs + " CPs from the [" + War + "] as prize at " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
}
}
static void Application_ThreadException(object sender, UnhandledExceptionEventArgs e)
{
SaveException(e.ExceptionObject as Exception);
}
public static void SaveException(Exception e)
{
Console.WriteLine(e);
var dt = DateTime.Now;
string date = dt.Month + "-" + dt.Day + "//";
if (!Directory.Exists(Application.StartupPath + Constants.UnhandledExceptionsPath))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath);
if (!Directory.Exists(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date);
if (!Directory.Exists(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name))
Directory.CreateDirectory(Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name);
string fullPath = Application.StartupPath + "\\" + Constants.UnhandledExceptionsPath + date + e.TargetSite.Name + "\\";
string date2 = dt.Hour + "-" + dt.Minute;
List<string> Lines = new List<string>();
Lines.Add("----Exception message----");
Lines.Add(e.Message);
Lines.Add("----End of exception message----\r\n");
Lines.Add("----Stack trace----");
Lines.Add(e.StackTrace);
Lines.Add("----End of stack trace----\r\n");
//Lines.Add("----Data from exception----");
//foreach (KeyValuePair<object, object> data in e.Data)
// Lines.Add(data.Key.ToString() + "->" + data.Value.ToString());
//Lines.Add("----End of data from exception----\r\n");
File.WriteAllLines(fullPath + date2 + ".txt", Lines.ToArray());
}
#endregion
private static void WorkConsole()
{
while (true)
{
try
{
CommandsAI(Console.ReadLine());
}
catch (Exception e) { Console.WriteLine(e); }
}
}
public static DateTime LastRandomReset = DateTime.Now;
public static Network.GamePackets.BlackSpotPacket BlackSpotPacket = new Network.GamePackets.BlackSpotPacket();
public static bool MyPC = true;
public static void CommandsAI(string command)
{
try
{
if (command == null)
return;
string[] data = command.Split(' ');
switch (data[0])
{
case "@testmode":
{
if (TestingMode)
{
TestingMode = false;
Console.WriteLine("Test Mode Off");
}
else
{
TestingMode = true;
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server will exit for 5 min to fix some bugs, please be paitent" }), System.Drawing.Color.Black, 0x7db), Program.Values);
CommandsAI("@save");
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Database.EntityVariableTable.Save(0, Vars);
var WC = Program.Values.ToArray();
foreach (Client.GameState client in WC)
{
if (client.Account.State != AccountTable.AccountState.ProjectManager)
{
client.Send("Server will exit for 5 min to fix some bugs, please be paitent !");
client.Disconnect();
}
}
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Console.WriteLine("Test Mode On");
}
break;
}
case "@clear":
{
Console.Clear();
SomailProject.Console.WriteLine("Consle and program Cleared ");
break;
}
case "@sh":
{
Console.WriteLine(Program.SnowBa);
break;
}
case "@sh1":
{
Program.SnowBa = true;
break;
}
case "@sh2":
{
Program.SnowBa = false;
break;
}
case "@Copra":
case "@bigbos":
SomailProject.Console.WriteLine("Server will restart after 10 minutes.");
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 5 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 4 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 4 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 3 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 3 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 2 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 2 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 1 minute 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 1 minute, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The server will be brought down for maintenance in 30 second, Please exit the game now.", System.Drawing.Color.Orange, 0x7db), Program.Values);
SomailProject.Console.WriteLine("Server will exit after 1 minute.");
CommandsAI("@save");
System.Threading.Thread.Sleep(0x7530);
Kernel.SendWorldMessage(new SomailProject.Network.GamePackets.Message("The Server restarted, Please log in after 5 minutes ", System.Drawing.Color.Orange, 0x7db), Program.Values);
try
{
CommandsAI("@restart");
}
catch
{
SomailProject.Console.WriteLine("Server cannot exit");
}
break;
case "@flushbans":
{
Database.IPBan.Load();
break;
}
case "@alivetime":
{
DateTime now = DateTime.Now;
TimeSpan t2 = new TimeSpan(StartDate.ToBinary());
TimeSpan t1 = new TimeSpan(now.ToBinary());
Console.WriteLine("The server has been online " + (int)(t1.TotalHours - t2.TotalHours) + " hours, " + (int)((t1.TotalMinutes - t2.TotalMinutes) % 1) + " minutes.");
break;
}
case "@online":
{
Console.WriteLine("Online Entitys count: " + Kernel.GamePool.Count);
string line = "";
foreach (Client.GameState pClient in Program.Values)
line += pClient.Entity.Name + ",";
if (line != "")
{
line = line.Remove(line.Length - 1);
Console.WriteLine("Entitys: " + line);
}
break;
}
case "@memoryusage":
{
var proc = System.Diagnostics.Process.GetCurrentProcess();
Console.WriteLine("Thread count: " + proc.Threads.Count);
Console.WriteLine("Memory set(MB): " + ((double)((double)proc.WorkingSet64 / 1024)) / 1024);
proc.Close();
break;
}
case "@save":
{
Save();
}
break;
case "@PlayerCap":
{
try
{
PlayerCap = int.Parse(data[1]);
}
catch
{
}
break;
}
case "@skill":
{
Game.Features.Tournaments.SkillPk.SkillTournament.Open();
foreach (var clien in Kernel.GamePool.Values)
{
if (clien.Team == null)
clien.Team = new Game.ConquerStructures.Team(clien);
Game.Features.Tournaments.SkillPk.SkillTournament.Join(clien, 3);
}
break;
}
case "@team":
{
Game.Features.Tournaments.TeamPk.TeamTournament.Open();
foreach (var clien in Kernel.GamePool.Values)
{
if (clien.Team == null)
clien.Team = new Game.ConquerStructures.Team(clien);
Game.Features.Tournaments.TeamPk.TeamTournament.Join(clien, 3);
}
break;
}
case "@exit":
{
Program.Save(true);
CommandsAI("@save");
GameServer.Disable();
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i].Disable();
}
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Database.EntityVariableTable.Save(0, Vars);
var WC = Program.Values.ToArray();
Parallel.ForEach(Program.Values, client =>
{
client.Send(" Server will exit for 5 min to Solve The Problem, please be paitent ");
client.Disconnect();
});
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { " Server will exit for 5 min to Solve The Problem, please be paitent " }), System.Drawing.Color.Black, 0x7db), Program.Values);
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Environment.Exit(0);
}
break;
case "serverpass":
{
using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
{
cmd.Select("configuration").Where("Server", Constants.ServerName);
using (MySqlReader r = new MySqlReader(cmd))
{
if (r.Read())
Constants.ServerGMPass = r.ReadString("ServerGMPass");
}
}
break;
}
case "@pressure":
{
Console.WriteLine("Genr: " + World.GenericThreadPool.ToString());
Console.WriteLine("Send: " + World.SendPool.ToString());
Console.WriteLine("Recv: " + World.ReceivePool.ToString());
break;
}
case "@restart":
{
try
{
Program.Save();
Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server Will Be Restart Now !" }), System.Drawing.Color.Black, 0x7db), Program.Values);
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
var WC = Program.Values.ToArray();
foreach (Client.GameState client in WC)
{
client.Send(" Server Will Be Restart Now ");
client.Disconnect();
}
GameServer.Disable();
for (int i = 0; i < AuthServer.Length; i++)
{
AuthServer[i].Disable();
}
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.Update).Update("configuration").Set("ItemUID", ConquerItem.ItemUID.Now).Where("Server", Constants.ServerName).Execute();
Application.Restart();
Environment.Exit(0);
}
catch (Exception e)
{
Console.WriteLine(e);
Console.ReadLine();
}
}
break;
case "@account":
{
Database.AccountTable account = new AccountTable(data[1]);
account.Password = data[2];
account.State = AccountTable.AccountState.Entity;
account.Save();
}
break;
case "@process":
{
HandleClipboardPacket(command);
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public static void WriteLine(string Line)
{
try
{
Console.WriteLine(Line);
}
catch { }
}
public static void HandleClipboardPacket(string cmd)
{
string[] pData = cmd.Split(' ');
long off = 0, type = 0, val = 0;
if (pData.Length > 1)
{
string[] oData = pData[1].Split(':');
if (oData.Length == 3)
{
off = long.Parse(oData[0]);
type = long.Parse(oData[1]);
if (oData[2] == "u")
val = 1337;
else
val = long.Parse(oData[2]);
}
}
string Data = OSClipboard.GetText();
string[] num = Data.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
byte[] packet = new byte[num.Length + 8];
for (int i = 0; i < num.Length; i++)
packet[i] = byte.Parse(num[i], System.Globalization.NumberStyles.HexNumber);
Writer.WriteUInt16((ushort)(packet.Length - 8), 0, packet);
if (off != 0)
{
switch (type)
{
case 1:
{
packet[(int)off] = (byte)val;
break;
}
case 2:
{
Writer.WriteUInt16((ushort)val, (int)off, packet);
break;
}
case 4:
{
Writer.WriteUInt32((uint)val, (int)off, packet);
break;
}
case 8:
{
Writer.WriteUInt64((ulong)val, (int)off, packet);
break;
}
}
}
foreach (var client in Program.Values)
{
if (val == 1337 && type == 4)
Writer.WriteUInt32(client.Entity.UID, (int)off, packet);
client.Send(packet);
}
}
static void GameServer_OnClientReceive(byte[] buffer, int length, ClientWrapper obj)
{
if (obj.Connector == null)
{
obj.Disconnect();
return;
}
Client.GameState Client = obj.Connector as Client.GameState;
if (Client.Exchange)
{
Client.Exchange = false;
Client.Action = 1;
var crypto = new Network.Cryptography.GameCryptography(Program.Encoding.GetBytes(Constants.GameCryptographyKey));
if (Program.TestingMode)
crypto = new Network.Cryptography.GameCryptography(Program.Encoding.GetBytes(Constants.GameCryptographyKey));
byte[] otherData = new byte[length];
Array.Copy(buffer, otherData, length);
crypto.Decrypt(otherData, length);
bool extra = false;
int pos = 0;
if (BitConverter.ToInt32(otherData, length - 140) == 128)
{
pos = length - 140;
Client.Cryptography.Decrypt(buffer, length);
}
else if (BitConverter.ToInt32(otherData, length - 176) == 128)
{
pos = length - 176;
extra = true;
Client.Cryptography.Decrypt(buffer, length - 36);
}
int len = BitConverter.ToInt32(buffer, pos); pos += 4;
if (len != 128)
{
Client.Disconnect();
return;
}
byte[] pubKey = new byte[128];
for (int x = 0; x < len; x++, pos++) pubKey[x] = buffer[pos];
string PubKey = System.Text.Encoding.Default.GetString(pubKey);
Client.Cryptography = Client.DHKeyExchange.HandleClientKeyPacket(PubKey, Client.Cryptography);
if (extra)
{
byte[] data = new byte[36];
Buffer.BlockCopy(buffer, length - 36, data, 0, 36);
processData(data, 36, Client);
}
}
else
{
processData(buffer, length, Client);
}
}
private static void processData(byte[] buffer, int length, Client.GameState Client)
{
Client.Cryptography.Decrypt(buffer, length);
Client.Queue.Enqueue(buffer, length);
if (Client.Queue.CurrentLength > 1224)
{
Console.WriteLine("[Disconnect]Reason:The packet size is too big. " + Client.Queue.CurrentLength);
Client.Disconnect();
return;
}
while (Client.Queue.CanDequeue())
{
byte[] data = Client.Queue.Dequeue();
try
{
Network.PacketHandler.HandlePacket(data, Client);
}
catch (Exception e)
{
if (e.ToString().Contains("Index"))
{
return;
}
else
{
Network.PacketHandler.HandlePacket(data, Client);
}
}
}
}
static void GameServer_OnClientConnect(ClientWrapper obj)
{
Client.GameState client = new Client.GameState(obj);
client.Send(client.DHKeyExchange.CreateServerKeyPacket());
obj.Connector = client;
}
static void GameServer_OnClientDisconnect(ClientWrapper obj)
{
if (obj.Connector != null)
(obj.Connector as Client.GameState).Disconnect();
else
obj.Disconnect();
}
static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3)
{
var Entity = arg3.Connector as Client.AuthClient;
Entity.Cryptographer.Decrypt(buffer, length);
Entity.Queue.Enqueue(buffer, length);
while (Entity.Queue.CanDequeue())
{
byte[] packet = Entity.Queue.Dequeue();
ushort len = BitConverter.ToUInt16(packet, 0);
ushort id = BitConverter.ToUInt16(packet, 2);
if (len == 312)
{
Entity.Info = new Authentication();
Entity.Info.Deserialize(packet);
Entity.Account = new AccountTable(Entity.Info.Username);
string passdone = "";
msvcrt.msvcrt.srand(Entity.PasswordSeed);
Forward Fw = new Forward();
if (Entity.Account.Password == Entity.Info.Password && Entity.Account.exists)
Fw.Type = Forward.ForwardType.Ready;
else
Fw.Type = Forward.ForwardType.InvalidInfo;
//if (IPBan.IsBanned(arg3.IP))
//{
// Fw.Type = Forward.ForwardType.Banned;
// Entity.Send(Fw);
// return;
//}
if (Fw.Type == Network.AuthPackets.Forward.ForwardType.Ready)
{
Fw.Identifier = Entity.Account.GenerateKey();
Kernel.AwaitingPool[Fw.Identifier] = Entity.Account;
Fw.IP = GameIP;
Fw.Port = GamePort;
}
Entity.Send(Fw);
}
}
}
static void AuthServer_OnClientDisconnect(ClientWrapper obj)
{
obj.Disconnect();
}
static void AuthServer_OnClientConnect(ClientWrapper obj)
{
Client.AuthClient authState;
obj.Connector = (authState = new Client.AuthClient(obj));
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
//Protection.LoaderProgram.CLientsPass.Clear();
//Protection.LoaderProgram.CLientsPass.Add(authState.PasswordSeed, "");
}
internal static Client.GameState FindClient(string name)
{
return Values.FirstOrDefault(p => p.Entity.Name == name);
}
#region Copra Style
static bool thistime = false;
private static void CopraStep(int width, int height, int[] y, int[] l)
{
int x;
thistime = !thistime;
for (x = 0; x < width; ++x)
{
if (x % 11 == 10)
{
if (!thistime)
continue;
System.Console.ForegroundColor = System.ConsoleColor.Red;
}
else
{
System.Console.ForegroundColor = System.ConsoleColor.DarkGreen;
System.Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
System.Console.Write(R);
System.Console.ForegroundColor = System.ConsoleColor.Green;
}
System.Console.SetCursorPosition(x, y[x]);
System.Console.Write(R);
y[x] = inBoxY(y[x] + 1, height);
System.Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
System.Console.Write(' ');
}
}
private static void Initialize(out int width, out int height, out int[] y, out int[] l)
{
int h1;
int h2 = (h1 = (height = System.Console.WindowHeight) / 2) / 2;
width = System.Console.WindowWidth - 1;
y = new int[width];
l = new int[width];
int x;
System.Console.Clear();
for (x = 0; x < width; ++x)
{
y[x] = r.Next(height);
l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
}
}
static Random r = new Random();
public static DateTime KingsTime;
static char R
{
get
{
int t = r.Next(10);
if (t <= 2)
return (char)('0' + r.Next(10));
else if (t <= 4)
return (char)('a' + r.Next(27));
else if (t <= 6)
return (char)('A' + r.Next(27));
else
return (char)(r.Next(32, 255));
}
}
public static int inBoxY(int n, int height)
{
n = n % height;
if (n < 0)
return n + height;
else
return n;
}
#endregion Copra Style
internal static void WriteLine(string p, ushort MsgId, short p_2)
{
throw new NotImplementedException();
}
public static int Carnaval { get; set; }
public static int Carnaval2 { get; set; }
public static int Carnaval3 { get; set; }
public static uint NextItemID { get; set; }
public static uint ExpRateSpell = 2;
public static string GetString(byte[] data, int position, int count)
{
var str = Program.Encoding.GetString(data, position, count);
str = str.Replace("\0", "").Replace("\r", "");
return str;
}
public static string GetString(byte[] data)
{
var str = Program.Encoding.GetString(data);
str = str.Replace("\0", "").Replace("\r", "");
return str;
}
public static List<ushort> EventsMap = new List<ushort>()
{
50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 50012, 50013, 50014, 50015, 50016, 50017, 1508, 1518, 2014, 1507,
};
}
public class Copra_Times
{
public static DateTime now
{
get
{
return DateTime.Now;
}
}
public class Start
{
public static bool SnowBanshee
{
get
{
return ((now.Minute == 57 || now.Minute == 27) && now.Second == 30);
}
}
public static bool ThrillingSpook
{
get
{
return ((now.Minute == 5 || now.Minute == 35) && now.Second == 30);
}
}
public static bool NemesisTyrant
{
get
{
return ((now.Minute == 15 || now.Minute == 45) && now.Second == 30);
}
}
public static bool SkyWar
{
get
{
return (now.Hour == 1 || now.Hour == 13) && now.Minute == 10 && now.Second == 1;
}
}
public static bool TheTeam
{
get
{
return (now.Hour == 14 || now.Hour == 2) && now.Minute == 10 && now.Second == 1;
}
}
public static bool EliteGW
{
get
{
return (now.Hour == 17 && now.Minute == 0);
}
}
public static bool SkillTeam
{
get
{
return (now.Hour == 22) && now.Minute == 00;
}
}
public static bool TeamPK
{
get
{
return (now.Hour == 19) && now.Minute == 00;
}
}
public static bool CTF
{
get
{
return (now.Hour == 19 && now.Minute == 0) || (now.Hour == 12 && now.Minute == 0);
}
}
public static bool NobiltyWarPole
{
get
{
return (now.Hour == 22 && now.Minute == 30) || (now.Hour == 4 && now.Minute == 0);
}
}
public static bool GuildScoreWar
{
get
{
return (now.Hour == 12 && now.Minute == 0) || (now.Hour == 23 && now.Minute == 0);
}
}
public static bool ClassWar
{
get
{
return (now.Hour == 18 && now.Minute == 0) || (now.Hour == 8 && now.Minute == 0);
}
}
public static bool HeroOfGame
{
get
{
return now.Minute == 30;
}
}
public static bool FBSS
{
get
{
return now.Minute == 25;
}
}
public static bool FBSS2
{
get
{
return now.Minute >= 25 && now.Minute < 28;
}
}
public static int hunterthief = 42;
public static int dashbash = 46;
public static int chase = 45;
public static int dizzy = 49;
public static bool Nobilty
{
get
{
return now.Minute >= 20 && now.Minute <= 24;
}
}
}
public class End
{
public static bool FBSS
{
get
{
return now.Minute >= 28;
}
}
public static int hunterthief = 45;
public static int dashbash = 48;
public static bool Cyclone
{
get
{
return now.Minute == 29;
}
}
public static int chase = 45;
public static int dizzy2 = 50;
public static bool Nobilty
{
get
{
return now.Minute >= 25;
}
}
public static bool EliteGW
{
get
{
return now.Hour == 18;
}
}
}
}
public class rates
{
public static uint GuildWar;
public static uint ChangeName;
public static uint king;
public static uint prince;
public static uint EliteGw;
public static uint SkillTeam1;
public static uint SkillTeam2;
public static uint SkillTeam3;
public static uint SkillTeam4;
public static uint WeeklyPk;
public static uint topguild;
public static uint mrconquer;
public static uint uniquepk;
public static uint Portals;
public static uint heroofgame;
public static uint NobilityPrize;
public static uint lastman;
public static uint Daily;
public static uint fbss;
public static uint Poles;
public static uint Clanwarday;
public static uint soulp6;
public static uint soulp7;
public static uint changebody;
public static uint ref6;
public static uint Twar;
public static uint stwar;
public static uint ctf;
public static uint cps;
public static uint ClanwarCity;
public static uint ClassPk;
public static uint DeathMatchs;
public static uint lobby;
public static uint hunter;
public static uint thief;
public static uint housepromete;
public static uint itembox;
public static uint houseupgrade;
public static uint MonthlyPk;
public static uint TopSpouse;
public static uint Bosses;
public static uint Night;
public static uint Broadcast;
public static uint GuildFee;
public static uint TeleportFee;
public static uint DragonBall;
public static uint Meteor;
public static string VoteUrl;
public static string coder = "RaMbO";
public static uint Reincarnation;
public static uint donationrate;
public static string servername { get { return Constants.ServerName; } }
public static void Load(IniFile IniFile)
{
DragonBall = IniFile.ReadUInt32("Rates", "DragonBall");
Meteor = IniFile.ReadUInt32("Rates", "Meteor");
GuildWar = IniFile.ReadUInt32("Rates", "GuildWar");
EliteGw = IniFile.ReadUInt32("Rates", "questday");
Bosses = IniFile.ReadUInt32("Rates", "Bosses");
Broadcast = IniFile.ReadUInt32("Rates", "Broadcast");
TeleportFee = IniFile.ReadUInt32("Rates", "TeleportFee");
GuildFee = IniFile.ReadUInt32("Rates", "GuildFee");
king = IniFile.ReadUInt32("Rates", "king");
prince = IniFile.ReadUInt32("Rates", "prince");
Reincarnation = IniFile.ReadUInt32("Rates", "Reincarnation");
MonthlyPk = IniFile.ReadUInt32("Rates", "MonthlyPk");
TopSpouse = IniFile.ReadUInt32("Rates", "TopSpouse");
ChangeName = IniFile.ReadUInt32("Rates", "ChangeName");
housepromete = IniFile.ReadUInt32("Rates", "housepromete");
itembox = IniFile.ReadUInt32("Rates", "itembox");
Night = IniFile.ReadUInt32("Rates", "Night");
VoteUrl = IniFile.ReadString("Rates", "VoteUrl");
Portals = IniFile.ReadUInt32("Rates", "Portals");
coder = IniFile.ReadString("Rates", "coder");
SkillTeam1 = IniFile.ReadUInt32("Rates", "SkillTeam1");
SkillTeam2 = IniFile.ReadUInt32("Rates", "SkillTeam2");
SkillTeam3 = IniFile.ReadUInt32("Rates", "SkillTeam3");
SkillTeam4 = IniFile.ReadUInt32("Rates", "SkillTeam4");
soulp6 = IniFile.ReadUInt32("Rates", "soulp6");
soulp7 = IniFile.ReadUInt32("Rates", "soulp7");
ref6 = IniFile.ReadUInt32("Rates", "ref6");
changebody = IniFile.ReadUInt32("Rates", "changebody");
uniquepk = IniFile.ReadUInt32("Rates", "uniquepk");
WeeklyPk = IniFile.ReadUInt32("Rates", "WeeklyPk");
fbss = IniFile.ReadUInt32("Rates", "fbss");
Poles = IniFile.ReadUInt32("Rates", "Poles");
Clanwarday = IniFile.ReadUInt32("Rates", "Clanwarday");
lastman = IniFile.ReadUInt32("Rates", "lastman");
Daily = IniFile.ReadUInt32("Rates", "Daily");
topguild = IniFile.ReadUInt32("Rates", "topguild");
mrconquer = IniFile.ReadUInt32("Rates", "mrconquer");
NobilityPrize = IniFile.ReadUInt32("Rates", "NobilityPrize");
heroofgame = IniFile.ReadUInt32("Rates", "heroofgame");
Twar = IniFile.ReadUInt32("Rates", "Twar");
stwar = IniFile.ReadUInt32("Rates", "stwar");
ctf = IniFile.ReadUInt32("Rates", "ctf");
cps = IniFile.ReadUInt32("Rates", "cps");
ClanwarCity = IniFile.ReadUInt32("Rates", "ClanwarCity");
ClassPk = IniFile.ReadUInt32("Rates", "ClassPk");
DeathMatchs = IniFile.ReadUInt32("Rates", "DeathMatchs");
lobby = IniFile.ReadUInt32("Rates", "lobby");
hunter = IniFile.ReadUInt32("Rates", "hunter");
thief = IniFile.ReadUInt32("Rates", "thief");
donationrate = IniFile.ReadUInt32("Rates", "donationrate");
}
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
سورس احمد فتحى الى كان منزله | ابو مروان | سورسات كونكر | 66 | يوم أمس 11:36 PM |
مشكله فى سورس احمد فتحى | taha | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-12-08 07:40 PM |
بكتات الدخول سورس احمد فاتحي | midoazoz | تطوير سيرفرات كونكر | 9 | 2019-11-29 03:39 AM |
بخصوص السورس بتاع احمد فتحي بكتات الدخول | midoazoz | تطوير سيرفرات كونكر | 3 | 2019-11-19 05:41 PM |
سورس احمد فتحي | salahsayed | مشكلات السيرفيرات كونكر الشخصيه | 4 | 2019-09-30 07:11 AM |