|
You last visited: Today at 15:58
Advertisement
[Guide] How to Create a Graphic User Interface (GUI)
Discussion on [Guide] How to Create a Graphic User Interface (GUI) within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
08/23/2011, 13:47
|
#61
|
elite*gold: 0
Join Date: Jul 2010
Posts: 1,532
Received Thanks: 575
|
Quote:
Originally Posted by Fаng
I was being harsh- but I wasn't flaming. I was telling him the truth. If my friend (who has almost no C# experience and almost no experience with Visual Studio) can pull himself together to figure it out, then I'm forced to conclude that this person has no experience what-so-ever and thus is trying to use a C# guide that he refuses to attempt to understand. Anyone still in this section that doesn't know an ounce of C# is being ignorant (unless they're coding in another language- then good for them o.o). Now stop going off-topic. It's driving me up the wall.
|
You seem to hate anyone who doesn't want to spend their time on learning C#. Just because you decided to spend your time on learning, without asking any questions as you're saying, doesn't mean you can be rude to anyone who doesn't. Ignorance seems to be your favorite word as well, you're calling everyone ignorant whenever they disagree with you or say something you rather not hear. If you decide to release stuff without providing any help on anything, that's fine. But just ignore the ones who ask for help instead of signing up their emails to spam sites. There might be other persons who DO like to help.
Seriously, get a break and get some fresh air.
|
|
|
08/23/2011, 18:57
|
#62
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by Captivate
You seem to hate anyone who doesn't want to spend their time on learning C#. Just because you decided to spend your time on learning, without asking any questions as you're saying, doesn't mean you can be rude to anyone who doesn't. Ignorance seems to be your favorite word as well, you're calling everyone ignorant whenever they disagree with you or say something you rather not hear. If you decide to release stuff without providing any help on anything, that's fine. But just ignore the ones who ask for help instead of signing up their emails to spam sites. There might be other persons who DO like to help.
Seriously, get a break and get some fresh air.
|
What I do to people is none of your business. If people can't read what I write, then they will be punished. If they can't get a clue that I don't want to hear them ask questions (despite how clearly I state that), then I will punish them.
I really don't care. If someone says "Hey... look Fang- I tried doing this for x-amount of hours and I tried a, b, and c, but I just can't figure this out." Then, I would be more than HAPPY to help. But some ass saying "This makes no sense in my opinion." makes me think:
"Uhm, well. x-amount of other people figured it out. The students that follow me were able to figure it out. Many other people figured it out. It only takes about a chapter of C# to figure out it's basic structure, so why is this so hard?"
Honestly, I don't know why people come to a C# release of mine and expect to get away with not knowing C#. That's like going to a job interview for Google and saying "well no, I don't have any experience in coding but I can pretend like I do and copy and paste things."
I'm not a slave.
I'm not a moderator.
I don't have to answer questions. It's not my job.
|
|
|
09/14/2011, 16:53
|
#63
|
elite*gold: 0
Join Date: Jan 2011
Posts: 286
Received Thanks: 71
|
Heya Fangerz! I just wanted to show you the GUI you basically helped me make through the power of this tutorial ^-^
I thought it was pretty neat anyway... Thanks for posting great tutorials!
|
|
|
09/14/2011, 16:56
|
#64
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by xBlackPlagu3x
Heya Fangerz! I just wanted to show you the GUI you basically helped me make through the power of this tutorial ^-^
I thought it was pretty neat anyway... Thanks for posting great tutorials!
|
Not really a GUI, more a tab control with a background-image.
|
|
|
09/14/2011, 17:06
|
#65
|
elite*gold: 0
Join Date: Nov 2009
Posts: 785
Received Thanks: 422
|
Quote:
Originally Posted by xBlackPlagu3x
Heya Fangerz! I just wanted to show you the GUI you basically helped me make through the power of this tutorial ^-^
I thought it was pretty neat anyway... Thanks for posting great tutorials!
|
They're pretty cool
|
|
|
09/14/2011, 18:56
|
#66
|
elite*gold: 0
Join Date: Jan 2011
Posts: 286
Received Thanks: 71
|
Yeah very true Bauss but if you take it by it's core definition (Graphical User Interface) it technically is an Interface used by the User which has Graphical aspects. But yeah, not really a GUI worth putting it up with the rest of them, I was just showing what I could do with my first project working with Windows Forms. It's actually pretty fun =D
Thanks F i n c h i!
I am sorry for the double post but this is so I can show off my latest GUI! A little more complicated than the last one.
This one has fully working buttons except for:
NereticCO (I have not yet "extracted" the client to the directory yet)
Battle of the Champions (The server has not yet been released, I just added it as a button so that I could have it ready for when it IS released)
Demon-Age Chat (I do not yet have the Demon-Age site coded)
|
|
|
10/30/2011, 04:03
|
#67
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Edit: I found an even better way of doing this. Since Actions cause cross threading errors, I made it so the gui invokes a delegate void with a string parameter. That way, the program isn't spammed by that timer.
|
|
|
10/31/2011, 01:23
|
#68
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Quote:
Originally Posted by Fаng
Edit: I found an even better way of doing this. Since Actions cause cross threading errors, I made it so the gui invokes a delegate void with a string parameter. That way, the program isn't spammed by that timer.
|
Yah not using delegates might have been the issue that others were having with it.
Unless you disable it, cross thread calls will not work to control the gui (with most server structures this will be the case). What you're describing it is afaik the microsoft intended way of dealing with it.
I definitely skipped a few pages so not sure if you and korv ever quite agreed but I think much of the disagreement was just missunderstanding.
If you make a super basic winform application (the gui is on the main thread) and anywhere inside the code do something like Thread.Sleep(100), the entire gui will freeze.
Alternatively if you were to start the program, create a new winform from inside it, it's on its own thread and therefor can still be moved around/controlled even if other threads/the main thread are busy doing something.
That would be my only real concern with the way it's described in the little tut you wrote but it's a very small issue. Most listeners and stuff start on their own thread right at the beginning of the program anyways but some servers still use that main thread for certain things.
|
|
|
11/02/2011, 17:23
|
#69
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
CheckForIllegalCrossThreading = false;
Problem solved.
|
|
|
11/06/2011, 02:36
|
#70
|
elite*gold: 0
Join Date: Apr 2009
Posts: 9
Received Thanks: 4
|
I have a doubt
I arrived at the stage of Program.cs, and do not understand WHAT :S could you tell me WHAT to do it?
My Program.cs :
Code:
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Conquer_Online_Server.Network.Sockets;
using Conquer_Online_Server.Network;
using Conquer_Online_Server.Database;
using Conquer_Online_Server.Network.AuthPackets;
using Conquer_Online_Server.Game.ConquerStructures.Society;
using Conquer_Online_Server.Game;
using System.Collections.Generic;
namespace Conquer_Online_Server
{
/*
Packet Nr 13175. Server -> Client, Length : 68, PacketType: 1150
3C 00 7E 04 00 00 00 00 00 00 00 00 00 00 00 00 ;< ~
28 54 29 65 72 6F 61 72 65 00 00 00 00 00 00 00 ;(T)eroare
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
01 00 00 00 00 00 00 00 01 00 00 00 54 51 53 65 ; TQSe
72 76 65 72 ;rver
Packet Nr 13176. Server -> Client, Length : 88, PacketType: 1151
50 00 7F 04 04 00 00 00 0E 91 CF 01 00 00 00 00 ;P ‘Ï
01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ;
01 00 00 00 00 00 00 00 8B C6 19 00 8B C6 19 00 ; ‹Æ ‹Æ
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
54 51 53 65 72 76 65 72 ;TQServer
*/
using System.Net.Sockets;
using System.Net;
class Program
{
public static AsyncSocket AuthServer;
public static AsyncSocket GameServer;
public static int PlayerCap = 400;
public static ServerBase.Counter EntityUID;
public static string GameIP;
public static DayOfWeek Today;
public static ushort GamePort;
public static ushort AuthPort;
public static DateTime StartDate;
public static DateTime RestartDate = DateTime.Now.AddHours(10);
public static DateTime KillProcesss = DateTime.Now.AddSeconds(30);
//public static ServerBase.Thread ThreadExecute = new Conquer_Online_Server.ServerBase.Thread(1000);
public static ServerBase.Thread CompanionThread = new Conquer_Online_Server.ServerBase.Thread(1000);
// public static ServerBase.Thread Sock = new Conquer_Online_Server.ServerBase.Thread(8000);
//public static ServerBase.Thread BlessThread = new ServerBase.Thread(4000);
public static ServerBase.Thread ServerStuff = new ServerBase.Thread(500);
public static ServerBase.Thread ArenaSystem = new Conquer_Online_Server.ServerBase.Thread(2000);
public static Client.GameState[] Values = null;
static void Main(string[] args)
{
Application.ThreadException += Application_ThreadException;
Application.Run(new NotForPublicNotAtAll.NoCrash());
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
SaveException(e.Exception);
}
public static void SaveException(Exception e)
{
if (e.TargetSite.Name == "ThrowInvalidOperationException")
return;
Console.WriteLine(e);
var dt = DateTime.Now;
string date = dt.Month + "-" + dt.Day + "//";
if (!Directory.Exists(Application.StartupPath + ServerBase.Constants.UnhandledExceptionsPath))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath);
if (!Directory.Exists(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date);
if (!Directory.Exists(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name);
string fullPath = Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name + "\\";
string date2 = dt.Hour + "-" + dt.Minute + "-" + (dt.Ticks & 10);
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");
File.WriteAllLines(fullPath + date2 + ".txt", Lines.ToArray());
}
//public static ManagedThreadPoolChecker pool;
public static void StartEngine()
{
EngineThread_Execute();
}
//public static void startpool()
//{
// pool.StartPool();
//}
public static int RandomSeed = 0;
static void EngineThread_Execute()
{
Time32 Start = Time32.Now;
RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
ServerBase.Kernel.Random = new Random(RandomSeed);
StartDate = DateTime.Now;
Console.Title = "DathCo Source Online. Start time: " + StartDate.ToString("dd / MM / yyyy _ hh:mm"); Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Load server configuration.");
string ConfigFileName = "configuration.ini";
ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName);
if (Environment.UserName.ToLower().Contains("impulse"))
{
GameIP = "*****";
GamePort = IniFile.ReadUInt16("Configuration", "GamePort");
AuthPort = IniFile.ReadUInt16("Configuration", "AuthPort");
ServerBase.Constants.ServerName = IniFile.ReadString("Configuration", "ServerName");
Database.DataHolder.CreateConnection("test", "test", IniFile.ReadString("MySql", "Database"), "localhost");
}
else
{
GameIP = IniFile.ReadString("Configuration", "IP");
GamePort = IniFile.ReadUInt16("Configuration", "GamePort");
AuthPort = IniFile.ReadUInt16("Configuration", "AuthPort");
ServerBase.Constants.ServerName = IniFile.ReadString("Configuration", "ServerName");
Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host"));
}
ServerBase.FrameworkTimer.SetPole(1000, 50);
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName);
MySqlReader r = new MySqlReader(cmd);
if (r.Read())
{
EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID"));
Game.Clans.ClanCount = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ClanUID"));
Game.ConquerStructures.Society.Guild.GuildCounter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("GuildID"));
Network.GamePackets.ConquerItem.ItemUID = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ItemUID"));
ServerBase.Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate");
ServerBase.Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate");
ServerBase.Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate");
ServerBase.Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate");
ServerBase.Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple");
ServerBase.Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
ServerBase.Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple");
ServerBase.Constants.ItemDropRate = r.ReadUInt32("ItemDropRate");
ServerBase.Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~');
ServerBase.Constants.WebAccExt = r.ReadString("AccountWebExt");
ServerBase.Constants.WebVoteExt = r.ReadString("VoteWebExt");
ServerBase.Constants.WebDonateExt = r.ReadString("DonateWebExt");
ServerBase.Constants.ServerWebsite = r.ReadString("ServerWebsite");
ServerBase.Constants.ServerGMPass = r.ReadString("ServerGMPass");
PlayerCap = r.ReadInt32("PlayerCap");
Database.DetainedItemTable.Counter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("DetainItemUID"));
}
r.Close();
if (EntityUID.Now == 0)
{
Console.Clear();
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.ReadLine();
return;
}
Console.WriteLine("Iniciando database.");
Database.ConquerItemInformation.Load();
Database.DataHolder.ReadStats();
Database.MonsterInformation.Load();
Database.SpellTable.Load();
Database.ShopFile.Load();
Database.EShopFile.Load();
Database.MapsTable.Load();
Database.NobilityTable.Load();
Database.ArenaTable.Load();
Database.GuildTable.Load();
Database.LotteryTable.Load();
Database.DMaps.Load();
Database.EntityTable.NextUit();
Database.DROP_SOULS.LoadDrops();
Database.Clans.LoadAllClans();
Values = new Client.GameState[0];
new Game.Map(1038, Database.DMaps.MapPaths[1038]);
Game.ConquerStructures.Society.GuildWar.Initiate();
Console.WriteLine("Guild war iniciada.");
Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter();
Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
ServerBase.Kernel.Elite_PK_Tournament = new Conquer_Online_Server.Game.Tournaments.EliteTournament();
ServerBase.Kernel.Elite_PK_Tournament.LoadTop8();
Console.WriteLine("Iniciando sockets.");
AuthServer = new AsyncSocket(AuthPort);
AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection);
AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive);
AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection);
GameServer = new AsyncSocket(GamePort);
GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection);
GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive);
GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection);
Console.WriteLine("Auth server online.");
Console.WriteLine("Game server online.");
Console.WriteLine();
Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");
CompanionThread.Execute += new Action(CompanionThread_Execute);
CompanionThread.Start();
// Sock.Execute += new Action(Trysocket);
// Sock.Start();
//BlessThread.Execute += new Action(BlessThread_Execute);
//BlessThread.Start();
ServerStuff.Execute += new Action(ServerStuff_Execute);
ServerStuff.Start();
ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute);
ArenaSystem.Start();
new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Execute();
GC.Collect();
Console.Clear();
Console.WriteLine("[Source base : BigBoss]");
Console.WriteLine("[Source Editada por JorgeLucas]");
Console.WriteLine("[Server Iniciado......]");
Console.WriteLine();
while (true)
{
CommandsAI(Console.ReadLine());
}
}
public static bool Gild_war = false;
public static void Trysocket()
{
/* if (AuthServer.TryListen(AuthPort))
{
StreamWriter SW = File.AppendText(@"RELOAD.txt");
SW.WriteLine("[" + DateTime.Now.Hour + ": "
+ DateTime.Now.Minute + ": "
+ DateTime.Now.Second + "] RELOAD AUTH_SERVER");
SW.Close();
AuthServer = new AsyncSocket(AuthPort);
AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection);
AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive);
AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection);
Console.WriteLine("RELOAD AUTH_SERVER");
}*/
}
static void AuthServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
{
Client.AuthState authState = new Client.AuthState(obj.Socket);
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = ServerBase.Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
obj.Connector = authState;
}
static void AuthServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
{
if (obj != null)
{
Client.AuthState client = (Client.AuthState)obj.Connector;
if (client != null)
{
client.Disconnect();
}
}
}
static void AuthServer_AnnounceReceive(byte[] packet, Interfaces.ISocketWrapper StO)
{
try
{
Client.AuthState client = (Client.AuthState)StO.Connector;
if (packet.Length == 276)
{
client.Cryptographer.Decrypt(packet);
if (BitConverter.ToUInt16(packet, 2) == 1060)
{
client.Info = new Conquer_Online_Server.Network.AuthPackets.Authentication();
client.Info.Deserialize(packet);
client.Account = new Database.AccountTable(client.Info.Username);
msvcrt.msvcrt.srand(client.PasswordSeed);
byte[] encpw = new byte[16];
var rc5Key = new byte[0x10];
for (int i = 0; i < 0x10; i++)
rc5Key[i] = (byte)msvcrt.msvcrt.rand();
if (client.Info.Username == "")
{
client.Disconnect();
return;
}
if (client.Info.Username == null)
{
client.Disconnect();
return;
}
Buffer.BlockCopy(packet, 132, encpw, 0, 16);
var password = System.Text.Encoding.ASCII.GetString(
(new Network.Cryptography.ConquerPasswordCryptpographer(client.Info.Username)).Decrypt(
(new Network.Cryptography.RC5(rc5Key)).Decrypt(encpw)));
if (password == null)
{
client.Disconnect();
return;
}
password = password.Split('\0')[0];
string NoNumPadNumbers = "";
foreach (char c in password)
{
switch (c.ToString())
{
case "-": NoNumPadNumbers += "0"; break;
case "#": NoNumPadNumbers += "1"; break;
case "(": NoNumPadNumbers += "2"; break;
case "\"": NoNumPadNumbers += "3"; break;
case "%": NoNumPadNumbers += "4"; break;
case "\f": NoNumPadNumbers += "5"; break;
case "'": NoNumPadNumbers += "6"; break;
case "$": NoNumPadNumbers += "7"; break;
case "&": NoNumPadNumbers += "8"; break;
case "!": NoNumPadNumbers += "9"; break;
default: NoNumPadNumbers += c; break;
}
}
password = NoNumPadNumbers;
Network.AuthPackets.Forward Fw = new Network.AuthPackets.Forward();
if (password == client.Account.Password || Environment.UserName.ToLower().Contains("impulse"))
{
//if (player.Account.State == AccountTable.AccountState.Banned)
// Fw.Type = Forward.ForwardType.Banned;
//else
//Fw.Type = Network.AuthPackets.Forward.ForwardType.Ready;
if (client.Account.EntityID == 0)
{
Client.AuthState.nextID += 1;
client.Account.EntityID = Client.AuthState.nextID;
Fw.Identifier = client.Account.EntityID;
}
else
Fw.Identifier = client.Account.EntityID;
Fw.Pasword_Identifier = (uint)password.GetHashCode();
Fw.IP = Program.GameIP;
Fw.Port = Program.GamePort;
client.Send(Fw);
client.Account.Save();
}
else
{
byte[] PacketData = new byte[32];
PacketData[0] = (byte)((ushort)PacketData.Length & 0xff);
PacketData[1] = (byte)(((ushort)PacketData.Length >> 8) & 0xff);
PacketData[2] = (byte)((ushort)0x41f & 0xff);
PacketData[3] = (byte)(((ushort)0x41f >> 8) & 0xff);
PacketData[4] = 0x00;
PacketData[5] = 0x00;
PacketData[6] = 0x00;
PacketData[7] = 0x00;
PacketData[8] = (byte)((ushort)1 & 0xff);
PacketData[9] = (byte)(((ushort)1 >> 8) & 0xff);
PacketData[10] = (byte)(((ushort)1 >> 16) & 0xff);
PacketData[11] = (byte)(((ushort)1 >> 24) & 0xff);
PacketData[12] = 0xd5;
PacketData[13] = 0xca;
PacketData[14] = 0xba;
PacketData[15] = 0xc5;
PacketData[16] = 0xc3;
PacketData[17] = 0xfb;
PacketData[18] = 0xbb;
PacketData[19] = 0xf2;
PacketData[20] = 0xbf;
PacketData[21] = 0xda;
PacketData[22] = 0xc1;
PacketData[23] = 0xee;
PacketData[24] = 0xb4;
PacketData[25] = 0xed;
client.Send(PacketData);
client.Disconnect();
}
}
}
else
{
client.Disconnect();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
static void GameServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
{
if (obj.Connector != null)
{
Client.GameState Client = obj.Connector as Client.GameState;
Client.Disconnect();
}
}
static void GameServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
{
if (obj.Socket == null)
return;
try
{
Client.GameState Client = new Conquer_Online_Server.Client.GameState(obj.Socket);
Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
obj.Connector = Client;
}
catch (Exception Exc) { Console.WriteLine(Exc); }
}
public static void GameServer_AnnounceReceive(byte[] received, Interfaces.ISocketWrapper StO)
{
if (StO != null)
{
Client.GameState client = (Client.GameState)StO.Connector;
if (client == null) return;
if (client.Alive)
{
client.Cryptography.Decrypt(received);
//ReciviedPacets(received, this);
if (client.Exchange)
{
try
{
client.Exchange = false;
client.Action = 1;
ushort position = 7;
uint PacketLen = BitConverter.ToUInt32(received, position); position += 4;
int JunkLen = BitConverter.ToInt32(received, position); position += 4; position += (ushort)JunkLen;
int Len = BitConverter.ToInt32(received, position); position += 4;
byte[] pubKey = new byte[Len];
for (int x = 0; x < Len; x++)
pubKey[x] = received[x + position];
string PubKey = System.Text.ASCIIEncoding.ASCII.GetString(pubKey);
client.Cryptography = client.DHKeyExchance.HandleClientKeyPacket(PubKey, client.Cryptography);
}
catch
{
// _socket.BeginDisconnect(false, DisconnectCallBack, null);
client.Socket.Disconnect(false);
}
}
else
{
if (!client.Exchange && client.Action != 0)
{
client.Handle(received);
}
}
}
}
}
static DateTime LastRandomReset = DateTime.Now;
public static void restart()
{
CommandsAI("@restart");
ServerStuff.Closed = true;
}
public static void save()
{
CommandsAI("@save");
return;
}
static void ServerStuff_Execute()
{
Console.Title = "DathCo Source Online. Start time: " + StartDate.ToString("dd / MM / yyyy _ hh:mm") + ". Players online: " + ServerBase.Kernel.GamePool.Count + "/" + PlayerCap;
ServerBase.Kernel.Elite_PK_Tournament.SendThis();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
if (DateTime.Now > Game.ConquerStructures.Broadcast.LastBroadcast.AddMinutes(1))
{
if (Game.ConquerStructures.Broadcast.Broadcasts.Count > 0)
{
Game.ConquerStructures.Broadcast.CurrentBroadcast = Game.ConquerStructures.Broadcast.Broadcasts[0];
Game.ConquerStructures.Broadcast.Broadcasts.Remove(Game.ConquerStructures.Broadcast.CurrentBroadcast);
Game.ConquerStructures.Broadcast.LastBroadcast = DateTime.Now;
ServerBase.Kernel.SendWorldMessage(new Network.GamePackets.Message(Game.ConquerStructures.Broadcast.CurrentBroadcast.Message, "ALLUSERS", Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityName, System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
}
else
Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
}
DateTime Now = DateTime.Now;
if (Now > LastRandomReset.AddMinutes(10))
{
LastRandomReset = Now;
ServerBase.Kernel.Random = new Random(RandomSeed);
}
Today = Now.DayOfWeek;
if (Now >= RestartDate)
{
CommandsAI("@restart");
ServerStuff.Closed = true;
return;
}
if (Now >= KillProcesss)
{
KillConnections.Kill();
KillProcesss = DateTime.Now.AddSeconds(30);
Console.WriteLine("|KillConnections|");
}
var Values = ServerBase.Kernel.WasInGamePool.Base.ToArray();
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
foreach (KeyValuePair<uint, Client.GameState> vals in Values)
{
Client.GameState client = vals.Value;
if (client.Disconnected2 == true)
return;
if (client == null || client.Entity == null || client.Account == null)
{
ServerBase.Kernel.WasInGamePool.Remove(vals.Key);
return;
}
if (!client.Socket.Connected)
{
Database.EntityTable.SaveEntity(client, conn);
Database.SkillTable.SaveSkills(client, conn);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, conn);
ServerBase.Kernel.WasInGamePool.Remove(vals.Key);
Database.EntityTable.UpdateOnlineStatus(client, false, conn);
Console.WriteLine(client.Entity.Name + " entirely disconnected. [BackupDictionary]");
}
}
}
if (Game.ConquerStructures.Society.GuildWar.IsWar)
{
if (Time32.Now > Game.ConquerStructures.Society.GuildWar.ScoreSendStamp.AddSeconds(3))
{
Game.ConquerStructures.Society.GuildWar.ScoreSendStamp = Time32.Now;
Game.ConquerStructures.Society.GuildWar.SendScores();
}
if (!Game.ConquerStructures.Society.GuildWar.Flame10th)
{
if (Now >= Game.ConquerStructures.Society.GuildWar.StartTime.AddHours(1).AddMinutes(30))
{
Game.ConquerStructures.Society.GuildWar.Flame10th = true;
ServerBase.Kernel.SendWorldMessage(new Network.GamePackets.Message("You can now go and light the last flame which is near the Pole in GuildWar.", System.Drawing.Color.White, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
}
}
else
{
if (Now >= Game.ConquerStructures.Society.GuildWar.StartTime.AddHours(2))
{
Game.ConquerStructures.Society.GuildWar.Flame10th = false;
Game.ConquerStructures.Society.GuildWar.End();
}
}
}
else
{
/* #region TeamWar
if (Now.DayOfWeek == DayOfWeek.Sunday)
{
if ((Now.Hour == 10 && Now.Minute == 59) && Now.Second == 01)
Game.Features.TeamWar.War.Start();
}
if (Game.Features.TeamWar.War.Running)
{
if (Time32.Now > Game.Features.TeamWar.War.LastCheck.AddMinutes(1))
Game.Features.TeamWar.War.Check();
if (Game.Features.TeamWar.War.Teams.Count > 0)
{
foreach (Game.Features.TeamWar.TeamStruct Teams in Game.Features.TeamWar.War.Teams.Values)
{
Teams.Check();
}
}
}
#endregion*/
#region PkWarEvent
if (Now.DayOfWeek == DayOfWeek.Sunday)
{
if (Now.Hour == 19 && Now.Second == 25)
Database.PkWarEvent.ResettopWarrior();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarWarrior();
if (Now.Hour == 15 && Now.Second == 25)
Database.PkWarEvent.ResetTopWeeklyPkWar();
if (Now.Hour == 15 && Now.Minute == 56)
Game.ConquerStructures.Society.GuildWar.WeeklyPkWar();
}
if (Now.DayOfWeek == DayOfWeek.Saturday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopTrojan();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarTrojan();
}
if (Now.DayOfWeek == DayOfWeek.Monday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopNinja();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarNinja();
}
if (Now.DayOfWeek == DayOfWeek.Tuesday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopWater();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarWater();
}
if (Now.DayOfWeek == DayOfWeek.Wednesday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopFire();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarFire();
}
if (Now.DayOfWeek == DayOfWeek.Thursday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopArcher();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarArcher();
if (Now.Hour == 22 && Now.Second == 10)
Database.PkWarEvent.ResettopMonk();
if (Now.Hour == 22 && Now.Minute == 10)
Game.ConquerStructures.Society.GuildWar.ClassPkWarMonk();
}
#endregion
}
}
static void CompanionThread_Execute()
{
Time32 Now = Time32.Now;
lock (Values)
{
System.Threading.Thread.Sleep(10);
int COunt = ServerBase.Kernel.GamePool.Count;
Values = new Client.GameState[COunt];
var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
varr.MoveNext();
for (uint c = 0;
c < COunt;
c++)
{
if (c >= COunt) break;
if (varr.Current != null)
{
Client.GameState clien = (varr.Current as Client.GameState);
Values[c] = varr.Current as Client.GameState;
}
varr.MoveNext();
}
}
foreach (Client.GameState client in Values)
{
if (client == null)
continue;
if (client.Companion != null)
{
short distance = ServerBase.Kernel.GetDistance(client.Companion.X, client.Companion.Y, client.Entity.X, client.Entity.Y);
if (distance >= 8)
{
ushort X = (ushort)(client.Entity.X + ServerBase.Kernel.Random.Next(2));
ushort Y = (ushort)(client.Entity.Y + ServerBase.Kernel.Random.Next(2));
if (!client.Map.SelectCoordonates(ref X, ref Y))
{
X = client.Entity.X;
Y = client.Entity.Y;
}
client.Companion.X = X;
client.Companion.Y = Y;
Network.GamePackets.Data data = new Conquer_Online_Server.Network.GamePackets.Data(true);
data.ID = Network.GamePackets.Data.Jump;
data.dwParam = (uint)((Y << 16) | X);
data.wParam1 = X;
data.wParam2 = Y;
data.UID = client.Companion.UID;
client.Companion.MonsterInfo.SendScreen(data);
}
else if (distance > 4)
{
Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(client.Companion.X, client.Companion.Y, client.Companion.Owner.Entity.X, client.Companion.Owner.Entity.Y);
if (!client.Companion.Move(facing))
{
facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
if (client.Companion.Move(facing))
{
client.Companion.Facing = facing;
Network.GamePackets.GroundMovement move = new Conquer_Online_Server.Network.GamePackets.GroundMovement(true);
move.Direction = facing;
move.UID = client.Companion.UID;
move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
client.Companion.MonsterInfo.SendScreen(move);
}
}
else
{
client.Companion.Facing = facing;
Network.GamePackets.GroundMovement move = new Conquer_Online_Server.Network.GamePackets.GroundMovement(true);
move.Direction = facing;
move.UID = client.Companion.UID;
move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
client.Companion.MonsterInfo.SendScreen(move);
}
}
else
{
var monster = client.Companion;
if (monster.MonsterInfo.InSight == 0)
{
if (client.Entity.AttackPacket != null)
{
if (client.Entity.AttackPacket.AttackType == Network.GamePackets.Attack.Magic)
{
if (client.Entity.AttackPacket.Decoded)
{
if (SpellTable.SpellInformations.ContainsKey((ushort)client.Entity.AttackPacket.Damage))
{
var info = Database.SpellTable.SpellInformations[(ushort)client.Entity.AttackPacket.Damage].Values.ToArray()[client.Spells[(ushort)client.Entity.AttackPacket.Damage].Level];
if (info.CanKill)
{
monster.MonsterInfo.InSight = client.Entity.AttackPacket.Attacked;
}
}
}
}
else
{
monster.MonsterInfo.InSight = client.Entity.AttackPacket.Attacked;
}
}
}
else
{
if (monster.MonsterInfo.InSight > 400000 && monster.MonsterInfo.InSight < 600000 || monster.MonsterInfo.InSight > 800000 && monster.MonsterInfo.InSight != monster.UID)
{
Entity attacked = null;
if (client.Screen.TryGetValue(monster.MonsterInfo.InSight, out attacked))
{
DateTime now_time = DateTime.Now;
if (now_time > monster.AttackStamp.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
{
monster.AttackStamp = now_time;
if (attacked.Dead)
{
monster.MonsterInfo.InSight = 0;
}
else
new Game.Attacking.Handle(null, monster, attacked);
}
}
else
monster.MonsterInfo.InSight = 0;
}
}
}
}
}
}
public static void CommandsAI(string command)
{
if (command == null)
return;
string[] data = command.Split(' ');
switch (data[0])
{
case "@endelite":
{
ServerBase.Kernel.Elite_PK_Tournament.Start = false;
ServerBase.Kernel.Elite_PK_Tournament.Finish();
break;
}
case "@1":
{
Database.EntityTable.ID();
break;
}
case "@startelite":
{
ServerBase.Kernel.Elite_PK_Tournament.Open();
break;
}
case "@threds":
{
ServerBase.FrameworkTimer.ShowThreadStats();
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) % 60) + " minutes.");
break;
}
case "@online":
{
Console.WriteLine("Online players count: " + ServerBase.Kernel.GamePool.Count);
string line = "";
var clientsss = ServerBase.Kernel.GamePool.Values.ToArray();
foreach (Client.GameState pClient in clientsss)
line += pClient.Entity.Name + ",";
if (line != "")
{
line = line.Remove(line.Length - 1);
Console.WriteLine("Players: " + 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":
{
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
var WC = ServerBase.Kernel.GamePool.Values.ToArray();
int total = WC.Length;
foreach (Client.GameState client in WC)
{
client.Account.Save(conn);
Database.EntityTable.SaveEntity(client, conn);
Database.SkillTable.SaveSkills(client, conn);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, conn);
Console.WriteLine(client.Entity.Name + " has been saved! Left to save: " + (total--));
}
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
}
}
break;
case "@playercap":
{
try
{
PlayerCap = int.Parse(data[1]);
}
catch
{
}
break;
}
case "@exit":
{
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
// GameServer.Disable();
// AuthServer.Disable();
CommandsAI("@save");
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
Environment.Exit(0);
}
break;
case "@restart":
{
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
// GameServer.Disable();
//AuthServer.Disable();
CommandsAI("@save");
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
Application.Restart();
Environment.Exit(0);
}
break;
case "@account":
{
Database.AccountTable account = new AccountTable(data[1]);
account.Password = data[2];
account.State = AccountTable.AccountState.Player;
account.Save();
}
break;
}
}
/* public class Game_NewConection
{
private System.Net.Sockets.Socket _socket;
public Game_NewConection(System.Net.Sockets.Socket socket)
{
this._socket = socket;
}
public void CreateConnection()
{
bool change = false;
bool Join = true;
for (int x = 0; x < ServerBase.Kernel.GameBind.Count; x++)
{
if (x >= ServerBase.Kernel.GameBind.Count) break;
if (ServerBase.Kernel.GameBind[x] != null)
{
if (ServerBase.Kernel.GameBind[x].Split(';')[0] == _socket.RemoteEndPoint.ToString().Split(':')[0])
{
change = true;
long date = long.Parse(ServerBase.Kernel.GameBind[x].Split(';')[1].ToString());
DateTime allow = DateTime.FromBinary(date);
if (DateTime.Now.Ticks > allow.AddSeconds(15).Ticks)
{
ServerBase.Kernel.GameBind[x]
= _socket.RemoteEndPoint.ToString().Split(':')[0] + ";"
+ DateTime.Now.Ticks.ToString();
}
else Join = false;
}
}
}
if (Join)
{
if (!change)
ServerBase.Kernel.GameBind.Add(_socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString());
Client.GameState Client = new Conquer_Online_Server.Client.GameState(_socket);
Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
Client.Accepter();
}
else
{
_socket.Disconnect(false);
}
}
}
*/
/* public class NewConnecsion
{
private System.Net.Sockets.Socket _socket;
private SocketServerType Port;
public NewConnecsion(System.Net.Sockets.Socket socket, SocketServerType m_port)
{
if (m_port == Network.SocketServerType.AuthServer)
{
_socket = socket;
Port = m_port;
}
}
public void AuthServer_AnnounceNewConnection()
{
bool change = false;
bool Join = true;
for (int x = 0; x < ServerBase.Kernel.AuthBind.Count; x++)
{
if (x >= ServerBase.Kernel.AuthBind.Count) break;
if (ServerBase.Kernel.AuthBind[x] != null)
{
if (ServerBase.Kernel.AuthBind[x].Split(';')[0] == _socket.RemoteEndPoint.ToString().Split(':')[0])
{
change = true;
long date = long.Parse(ServerBase.Kernel.AuthBind[x].Split(';')[1].ToString());
DateTime allow = DateTime.FromBinary(date);
if (DateTime.Now.Ticks > allow.AddSeconds(15).Ticks)
{
ServerBase.Kernel.AuthBind[x] = _socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString();
}
else Join = false;
}
}
}
if (Join)
{
if (!change)
ServerBase.Kernel.AuthBind.Add(_socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString());
Client.AuthState authState = new Client.AuthState(_socket);
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = ServerBase.Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
authState.Accepter();
}
else
{
_socket.Disconnect(false);
}
}
}*/
}
}
|
|
|
11/06/2011, 23:46
|
#71
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by jlcs157
I have a doubt
I arrived at the stage of Program.cs, and do not understand WHAT :S could you tell me WHAT to do it?
My Program.cs :
Code:
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Conquer_Online_Server.Network.Sockets;
using Conquer_Online_Server.Network;
using Conquer_Online_Server.Database;
using Conquer_Online_Server.Network.AuthPackets;
using Conquer_Online_Server.Game.ConquerStructures.Society;
using Conquer_Online_Server.Game;
using System.Collections.Generic;
namespace Conquer_Online_Server
{
/*
Packet Nr 13175. Server -> Client, Length : 68, PacketType: 1150
3C 00 7E 04 00 00 00 00 00 00 00 00 00 00 00 00 ;< ~
28 54 29 65 72 6F 61 72 65 00 00 00 00 00 00 00 ;(T)eroare
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
01 00 00 00 00 00 00 00 01 00 00 00 54 51 53 65 ; TQSe
72 76 65 72 ;rver
Packet Nr 13176. Server -> Client, Length : 88, PacketType: 1151
50 00 7F 04 04 00 00 00 0E 91 CF 01 00 00 00 00 ;P ‘Ï
01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ;
01 00 00 00 00 00 00 00 8B C6 19 00 8B C6 19 00 ; ‹Æ ‹Æ
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
4E 69 78 5F 4E 69 67 68 74 00 00 00 00 00 00 00 ;Nix_Night
54 51 53 65 72 76 65 72 ;TQServer
*/
using System.Net.Sockets;
using System.Net;
class Program
{
public static AsyncSocket AuthServer;
public static AsyncSocket GameServer;
public static int PlayerCap = 400;
public static ServerBase.Counter EntityUID;
public static string GameIP;
public static DayOfWeek Today;
public static ushort GamePort;
public static ushort AuthPort;
public static DateTime StartDate;
public static DateTime RestartDate = DateTime.Now.AddHours(10);
public static DateTime KillProcesss = DateTime.Now.AddSeconds(30);
//public static ServerBase.Thread ThreadExecute = new Conquer_Online_Server.ServerBase.Thread(1000);
public static ServerBase.Thread CompanionThread = new Conquer_Online_Server.ServerBase.Thread(1000);
// public static ServerBase.Thread Sock = new Conquer_Online_Server.ServerBase.Thread(8000);
//public static ServerBase.Thread BlessThread = new ServerBase.Thread(4000);
public static ServerBase.Thread ServerStuff = new ServerBase.Thread(500);
public static ServerBase.Thread ArenaSystem = new Conquer_Online_Server.ServerBase.Thread(2000);
public static Client.GameState[] Values = null;
static void Main(string[] args)
{
Application.ThreadException += Application_ThreadException;
Application.Run(new NotForPublicNotAtAll.NoCrash());
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
SaveException(e.Exception);
}
public static void SaveException(Exception e)
{
if (e.TargetSite.Name == "ThrowInvalidOperationException")
return;
Console.WriteLine(e);
var dt = DateTime.Now;
string date = dt.Month + "-" + dt.Day + "//";
if (!Directory.Exists(Application.StartupPath + ServerBase.Constants.UnhandledExceptionsPath))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath);
if (!Directory.Exists(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date);
if (!Directory.Exists(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name))
Directory.CreateDirectory(Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name);
string fullPath = Application.StartupPath + "\\" + ServerBase.Constants.UnhandledExceptionsPath + date + e.TargetSite.Name + "\\";
string date2 = dt.Hour + "-" + dt.Minute + "-" + (dt.Ticks & 10);
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");
File.WriteAllLines(fullPath + date2 + ".txt", Lines.ToArray());
}
//public static ManagedThreadPoolChecker pool;
public static void StartEngine()
{
EngineThread_Execute();
}
//public static void startpool()
//{
// pool.StartPool();
//}
public static int RandomSeed = 0;
static void EngineThread_Execute()
{
Time32 Start = Time32.Now;
RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
ServerBase.Kernel.Random = new Random(RandomSeed);
StartDate = DateTime.Now;
Console.Title = "DathCo Source Online. Start time: " + StartDate.ToString("dd / MM / yyyy _ hh:mm"); Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Load server configuration.");
string ConfigFileName = "configuration.ini";
ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName);
if (Environment.UserName.ToLower().Contains("impulse"))
{
GameIP = "*****";
GamePort = IniFile.ReadUInt16("Configuration", "GamePort");
AuthPort = IniFile.ReadUInt16("Configuration", "AuthPort");
ServerBase.Constants.ServerName = IniFile.ReadString("Configuration", "ServerName");
Database.DataHolder.CreateConnection("test", "test", IniFile.ReadString("MySql", "Database"), "localhost");
}
else
{
GameIP = IniFile.ReadString("Configuration", "IP");
GamePort = IniFile.ReadUInt16("Configuration", "GamePort");
AuthPort = IniFile.ReadUInt16("Configuration", "AuthPort");
ServerBase.Constants.ServerName = IniFile.ReadString("Configuration", "ServerName");
Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host"));
}
ServerBase.FrameworkTimer.SetPole(1000, 50);
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName);
MySqlReader r = new MySqlReader(cmd);
if (r.Read())
{
EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID"));
Game.Clans.ClanCount = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ClanUID"));
Game.ConquerStructures.Society.Guild.GuildCounter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("GuildID"));
Network.GamePackets.ConquerItem.ItemUID = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ItemUID"));
ServerBase.Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate");
ServerBase.Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate");
ServerBase.Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate");
ServerBase.Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate");
ServerBase.Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple");
ServerBase.Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
ServerBase.Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple");
ServerBase.Constants.ItemDropRate = r.ReadUInt32("ItemDropRate");
ServerBase.Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~');
ServerBase.Constants.WebAccExt = r.ReadString("AccountWebExt");
ServerBase.Constants.WebVoteExt = r.ReadString("VoteWebExt");
ServerBase.Constants.WebDonateExt = r.ReadString("DonateWebExt");
ServerBase.Constants.ServerWebsite = r.ReadString("ServerWebsite");
ServerBase.Constants.ServerGMPass = r.ReadString("ServerGMPass");
PlayerCap = r.ReadInt32("PlayerCap");
Database.DetainedItemTable.Counter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("DetainItemUID"));
}
r.Close();
if (EntityUID.Now == 0)
{
Console.Clear();
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
Console.ReadLine();
return;
}
Console.WriteLine("Iniciando database.");
Database.ConquerItemInformation.Load();
Database.DataHolder.ReadStats();
Database.MonsterInformation.Load();
Database.SpellTable.Load();
Database.ShopFile.Load();
Database.EShopFile.Load();
Database.MapsTable.Load();
Database.NobilityTable.Load();
Database.ArenaTable.Load();
Database.GuildTable.Load();
Database.LotteryTable.Load();
Database.DMaps.Load();
Database.EntityTable.NextUit();
Database.DROP_SOULS.LoadDrops();
Database.Clans.LoadAllClans();
Values = new Client.GameState[0];
new Game.Map(1038, Database.DMaps.MapPaths[1038]);
Game.ConquerStructures.Society.GuildWar.Initiate();
Console.WriteLine("Guild war iniciada.");
Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter();
Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
ServerBase.Kernel.Elite_PK_Tournament = new Conquer_Online_Server.Game.Tournaments.EliteTournament();
ServerBase.Kernel.Elite_PK_Tournament.LoadTop8();
Console.WriteLine("Iniciando sockets.");
AuthServer = new AsyncSocket(AuthPort);
AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection);
AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive);
AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection);
GameServer = new AsyncSocket(GamePort);
GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection);
GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive);
GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection);
Console.WriteLine("Auth server online.");
Console.WriteLine("Game server online.");
Console.WriteLine();
Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");
CompanionThread.Execute += new Action(CompanionThread_Execute);
CompanionThread.Start();
// Sock.Execute += new Action(Trysocket);
// Sock.Start();
//BlessThread.Execute += new Action(BlessThread_Execute);
//BlessThread.Start();
ServerStuff.Execute += new Action(ServerStuff_Execute);
ServerStuff.Start();
ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute);
ArenaSystem.Start();
new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Execute();
GC.Collect();
Console.Clear();
Console.WriteLine("[Source base : BigBoss]");
Console.WriteLine("[Source Editada por JorgeLucas]");
Console.WriteLine("[Server Iniciado......]");
Console.WriteLine();
while (true)
{
CommandsAI(Console.ReadLine());
}
}
public static bool Gild_war = false;
public static void Trysocket()
{
/* if (AuthServer.TryListen(AuthPort))
{
StreamWriter SW = File.AppendText(@"RELOAD.txt");
SW.WriteLine("[" + DateTime.Now.Hour + ": "
+ DateTime.Now.Minute + ": "
+ DateTime.Now.Second + "] RELOAD AUTH_SERVER");
SW.Close();
AuthServer = new AsyncSocket(AuthPort);
AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection);
AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive);
AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection);
Console.WriteLine("RELOAD AUTH_SERVER");
}*/
}
static void AuthServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
{
Client.AuthState authState = new Client.AuthState(obj.Socket);
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = ServerBase.Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
obj.Connector = authState;
}
static void AuthServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
{
if (obj != null)
{
Client.AuthState client = (Client.AuthState)obj.Connector;
if (client != null)
{
client.Disconnect();
}
}
}
static void AuthServer_AnnounceReceive(byte[] packet, Interfaces.ISocketWrapper StO)
{
try
{
Client.AuthState client = (Client.AuthState)StO.Connector;
if (packet.Length == 276)
{
client.Cryptographer.Decrypt(packet);
if (BitConverter.ToUInt16(packet, 2) == 1060)
{
client.Info = new Conquer_Online_Server.Network.AuthPackets.Authentication();
client.Info.Deserialize(packet);
client.Account = new Database.AccountTable(client.Info.Username);
msvcrt.msvcrt.srand(client.PasswordSeed);
byte[] encpw = new byte[16];
var rc5Key = new byte[0x10];
for (int i = 0; i < 0x10; i++)
rc5Key[i] = (byte)msvcrt.msvcrt.rand();
if (client.Info.Username == "")
{
client.Disconnect();
return;
}
if (client.Info.Username == null)
{
client.Disconnect();
return;
}
Buffer.BlockCopy(packet, 132, encpw, 0, 16);
var password = System.Text.Encoding.ASCII.GetString(
(new Network.Cryptography.ConquerPasswordCryptpographer(client.Info.Username)).Decrypt(
(new Network.Cryptography.RC5(rc5Key)).Decrypt(encpw)));
if (password == null)
{
client.Disconnect();
return;
}
password = password.Split('\0')[0];
string NoNumPadNumbers = "";
foreach (char c in password)
{
switch (c.ToString())
{
case "-": NoNumPadNumbers += "0"; break;
case "#": NoNumPadNumbers += "1"; break;
case "(": NoNumPadNumbers += "2"; break;
case "\"": NoNumPadNumbers += "3"; break;
case "%": NoNumPadNumbers += "4"; break;
case "\f": NoNumPadNumbers += "5"; break;
case "'": NoNumPadNumbers += "6"; break;
case "$": NoNumPadNumbers += "7"; break;
case "&": NoNumPadNumbers += "8"; break;
case "!": NoNumPadNumbers += "9"; break;
default: NoNumPadNumbers += c; break;
}
}
password = NoNumPadNumbers;
Network.AuthPackets.Forward Fw = new Network.AuthPackets.Forward();
if (password == client.Account.Password || Environment.UserName.ToLower().Contains("impulse"))
{
//if (player.Account.State == AccountTable.AccountState.Banned)
// Fw.Type = Forward.ForwardType.Banned;
//else
//Fw.Type = Network.AuthPackets.Forward.ForwardType.Ready;
if (client.Account.EntityID == 0)
{
Client.AuthState.nextID += 1;
client.Account.EntityID = Client.AuthState.nextID;
Fw.Identifier = client.Account.EntityID;
}
else
Fw.Identifier = client.Account.EntityID;
Fw.Pasword_Identifier = (uint)password.GetHashCode();
Fw.IP = Program.GameIP;
Fw.Port = Program.GamePort;
client.Send(Fw);
client.Account.Save();
}
else
{
byte[] PacketData = new byte[32];
PacketData[0] = (byte)((ushort)PacketData.Length & 0xff);
PacketData[1] = (byte)(((ushort)PacketData.Length >> 8) & 0xff);
PacketData[2] = (byte)((ushort)0x41f & 0xff);
PacketData[3] = (byte)(((ushort)0x41f >> 8) & 0xff);
PacketData[4] = 0x00;
PacketData[5] = 0x00;
PacketData[6] = 0x00;
PacketData[7] = 0x00;
PacketData[8] = (byte)((ushort)1 & 0xff);
PacketData[9] = (byte)(((ushort)1 >> 8) & 0xff);
PacketData[10] = (byte)(((ushort)1 >> 16) & 0xff);
PacketData[11] = (byte)(((ushort)1 >> 24) & 0xff);
PacketData[12] = 0xd5;
PacketData[13] = 0xca;
PacketData[14] = 0xba;
PacketData[15] = 0xc5;
PacketData[16] = 0xc3;
PacketData[17] = 0xfb;
PacketData[18] = 0xbb;
PacketData[19] = 0xf2;
PacketData[20] = 0xbf;
PacketData[21] = 0xda;
PacketData[22] = 0xc1;
PacketData[23] = 0xee;
PacketData[24] = 0xb4;
PacketData[25] = 0xed;
client.Send(PacketData);
client.Disconnect();
}
}
}
else
{
client.Disconnect();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
static void GameServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
{
if (obj.Connector != null)
{
Client.GameState Client = obj.Connector as Client.GameState;
Client.Disconnect();
}
}
static void GameServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
{
if (obj.Socket == null)
return;
try
{
Client.GameState Client = new Conquer_Online_Server.Client.GameState(obj.Socket);
Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
obj.Connector = Client;
}
catch (Exception Exc) { Console.WriteLine(Exc); }
}
public static void GameServer_AnnounceReceive(byte[] received, Interfaces.ISocketWrapper StO)
{
if (StO != null)
{
Client.GameState client = (Client.GameState)StO.Connector;
if (client == null) return;
if (client.Alive)
{
client.Cryptography.Decrypt(received);
//ReciviedPacets(received, this);
if (client.Exchange)
{
try
{
client.Exchange = false;
client.Action = 1;
ushort position = 7;
uint PacketLen = BitConverter.ToUInt32(received, position); position += 4;
int JunkLen = BitConverter.ToInt32(received, position); position += 4; position += (ushort)JunkLen;
int Len = BitConverter.ToInt32(received, position); position += 4;
byte[] pubKey = new byte[Len];
for (int x = 0; x < Len; x++)
pubKey[x] = received[x + position];
string PubKey = System.Text.ASCIIEncoding.ASCII.GetString(pubKey);
client.Cryptography = client.DHKeyExchance.HandleClientKeyPacket(PubKey, client.Cryptography);
}
catch
{
// _socket.BeginDisconnect(false, DisconnectCallBack, null);
client.Socket.Disconnect(false);
}
}
else
{
if (!client.Exchange && client.Action != 0)
{
client.Handle(received);
}
}
}
}
}
static DateTime LastRandomReset = DateTime.Now;
public static void restart()
{
CommandsAI("@restart");
ServerStuff.Closed = true;
}
public static void save()
{
CommandsAI("@save");
return;
}
static void ServerStuff_Execute()
{
Console.Title = "DathCo Source Online. Start time: " + StartDate.ToString("dd / MM / yyyy _ hh:mm") + ". Players online: " + ServerBase.Kernel.GamePool.Count + "/" + PlayerCap;
ServerBase.Kernel.Elite_PK_Tournament.SendThis();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
if (DateTime.Now > Game.ConquerStructures.Broadcast.LastBroadcast.AddMinutes(1))
{
if (Game.ConquerStructures.Broadcast.Broadcasts.Count > 0)
{
Game.ConquerStructures.Broadcast.CurrentBroadcast = Game.ConquerStructures.Broadcast.Broadcasts[0];
Game.ConquerStructures.Broadcast.Broadcasts.Remove(Game.ConquerStructures.Broadcast.CurrentBroadcast);
Game.ConquerStructures.Broadcast.LastBroadcast = DateTime.Now;
ServerBase.Kernel.SendWorldMessage(new Network.GamePackets.Message(Game.ConquerStructures.Broadcast.CurrentBroadcast.Message, "ALLUSERS", Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityName, System.Drawing.Color.Red, Network.GamePackets.Message.BroadcastMessage), ServerBase.Kernel.GamePool.Values);
}
else
Game.ConquerStructures.Broadcast.CurrentBroadcast.EntityID = 1;
}
DateTime Now = DateTime.Now;
if (Now > LastRandomReset.AddMinutes(10))
{
LastRandomReset = Now;
ServerBase.Kernel.Random = new Random(RandomSeed);
}
Today = Now.DayOfWeek;
if (Now >= RestartDate)
{
CommandsAI("@restart");
ServerStuff.Closed = true;
return;
}
if (Now >= KillProcesss)
{
KillConnections.Kill();
KillProcesss = DateTime.Now.AddSeconds(30);
Console.WriteLine("|KillConnections|");
}
var Values = ServerBase.Kernel.WasInGamePool.Base.ToArray();
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
foreach (KeyValuePair<uint, Client.GameState> vals in Values)
{
Client.GameState client = vals.Value;
if (client.Disconnected2 == true)
return;
if (client == null || client.Entity == null || client.Account == null)
{
ServerBase.Kernel.WasInGamePool.Remove(vals.Key);
return;
}
if (!client.Socket.Connected)
{
Database.EntityTable.SaveEntity(client, conn);
Database.SkillTable.SaveSkills(client, conn);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, conn);
ServerBase.Kernel.WasInGamePool.Remove(vals.Key);
Database.EntityTable.UpdateOnlineStatus(client, false, conn);
Console.WriteLine(client.Entity.Name + " entirely disconnected. [BackupDictionary]");
}
}
}
if (Game.ConquerStructures.Society.GuildWar.IsWar)
{
if (Time32.Now > Game.ConquerStructures.Society.GuildWar.ScoreSendStamp.AddSeconds(3))
{
Game.ConquerStructures.Society.GuildWar.ScoreSendStamp = Time32.Now;
Game.ConquerStructures.Society.GuildWar.SendScores();
}
if (!Game.ConquerStructures.Society.GuildWar.Flame10th)
{
if (Now >= Game.ConquerStructures.Society.GuildWar.StartTime.AddHours(1).AddMinutes(30))
{
Game.ConquerStructures.Society.GuildWar.Flame10th = true;
ServerBase.Kernel.SendWorldMessage(new Network.GamePackets.Message("You can now go and light the last flame which is near the Pole in GuildWar.", System.Drawing.Color.White, Network.GamePackets.Message.Center), ServerBase.Kernel.GamePool.Values);
}
}
else
{
if (Now >= Game.ConquerStructures.Society.GuildWar.StartTime.AddHours(2))
{
Game.ConquerStructures.Society.GuildWar.Flame10th = false;
Game.ConquerStructures.Society.GuildWar.End();
}
}
}
else
{
/* #region TeamWar
if (Now.DayOfWeek == DayOfWeek.Sunday)
{
if ((Now.Hour == 10 && Now.Minute == 59) && Now.Second == 01)
Game.Features.TeamWar.War.Start();
}
if (Game.Features.TeamWar.War.Running)
{
if (Time32.Now > Game.Features.TeamWar.War.LastCheck.AddMinutes(1))
Game.Features.TeamWar.War.Check();
if (Game.Features.TeamWar.War.Teams.Count > 0)
{
foreach (Game.Features.TeamWar.TeamStruct Teams in Game.Features.TeamWar.War.Teams.Values)
{
Teams.Check();
}
}
}
#endregion*/
#region PkWarEvent
if (Now.DayOfWeek == DayOfWeek.Sunday)
{
if (Now.Hour == 19 && Now.Second == 25)
Database.PkWarEvent.ResettopWarrior();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarWarrior();
if (Now.Hour == 15 && Now.Second == 25)
Database.PkWarEvent.ResetTopWeeklyPkWar();
if (Now.Hour == 15 && Now.Minute == 56)
Game.ConquerStructures.Society.GuildWar.WeeklyPkWar();
}
if (Now.DayOfWeek == DayOfWeek.Saturday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopTrojan();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarTrojan();
}
if (Now.DayOfWeek == DayOfWeek.Monday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopNinja();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarNinja();
}
if (Now.DayOfWeek == DayOfWeek.Tuesday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopWater();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarWater();
}
if (Now.DayOfWeek == DayOfWeek.Wednesday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopFire();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarFire();
}
if (Now.DayOfWeek == DayOfWeek.Thursday)
{
if (Now.Hour == 19 && Now.Second == 40)
Database.PkWarEvent.ResettopArcher();
if (Now.Hour == 19 && Now.Minute == 40)
Game.ConquerStructures.Society.GuildWar.ClassPkWarArcher();
if (Now.Hour == 22 && Now.Second == 10)
Database.PkWarEvent.ResettopMonk();
if (Now.Hour == 22 && Now.Minute == 10)
Game.ConquerStructures.Society.GuildWar.ClassPkWarMonk();
}
#endregion
}
}
static void CompanionThread_Execute()
{
Time32 Now = Time32.Now;
lock (Values)
{
System.Threading.Thread.Sleep(10);
int COunt = ServerBase.Kernel.GamePool.Count;
Values = new Client.GameState[COunt];
var varr = ServerBase.Kernel.GamePool.Values.GetEnumerator();
varr.MoveNext();
for (uint c = 0;
c < COunt;
c++)
{
if (c >= COunt) break;
if (varr.Current != null)
{
Client.GameState clien = (varr.Current as Client.GameState);
Values[c] = varr.Current as Client.GameState;
}
varr.MoveNext();
}
}
foreach (Client.GameState client in Values)
{
if (client == null)
continue;
if (client.Companion != null)
{
short distance = ServerBase.Kernel.GetDistance(client.Companion.X, client.Companion.Y, client.Entity.X, client.Entity.Y);
if (distance >= 8)
{
ushort X = (ushort)(client.Entity.X + ServerBase.Kernel.Random.Next(2));
ushort Y = (ushort)(client.Entity.Y + ServerBase.Kernel.Random.Next(2));
if (!client.Map.SelectCoordonates(ref X, ref Y))
{
X = client.Entity.X;
Y = client.Entity.Y;
}
client.Companion.X = X;
client.Companion.Y = Y;
Network.GamePackets.Data data = new Conquer_Online_Server.Network.GamePackets.Data(true);
data.ID = Network.GamePackets.Data.Jump;
data.dwParam = (uint)((Y << 16) | X);
data.wParam1 = X;
data.wParam2 = Y;
data.UID = client.Companion.UID;
client.Companion.MonsterInfo.SendScreen(data);
}
else if (distance > 4)
{
Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(client.Companion.X, client.Companion.Y, client.Companion.Owner.Entity.X, client.Companion.Owner.Entity.Y);
if (!client.Companion.Move(facing))
{
facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
if (client.Companion.Move(facing))
{
client.Companion.Facing = facing;
Network.GamePackets.GroundMovement move = new Conquer_Online_Server.Network.GamePackets.GroundMovement(true);
move.Direction = facing;
move.UID = client.Companion.UID;
move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
client.Companion.MonsterInfo.SendScreen(move);
}
}
else
{
client.Companion.Facing = facing;
Network.GamePackets.GroundMovement move = new Conquer_Online_Server.Network.GamePackets.GroundMovement(true);
move.Direction = facing;
move.UID = client.Companion.UID;
move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
client.Companion.MonsterInfo.SendScreen(move);
}
}
else
{
var monster = client.Companion;
if (monster.MonsterInfo.InSight == 0)
{
if (client.Entity.AttackPacket != null)
{
if (client.Entity.AttackPacket.AttackType == Network.GamePackets.Attack.Magic)
{
if (client.Entity.AttackPacket.Decoded)
{
if (SpellTable.SpellInformations.ContainsKey((ushort)client.Entity.AttackPacket.Damage))
{
var info = Database.SpellTable.SpellInformations[(ushort)client.Entity.AttackPacket.Damage].Values.ToArray()[client.Spells[(ushort)client.Entity.AttackPacket.Damage].Level];
if (info.CanKill)
{
monster.MonsterInfo.InSight = client.Entity.AttackPacket.Attacked;
}
}
}
}
else
{
monster.MonsterInfo.InSight = client.Entity.AttackPacket.Attacked;
}
}
}
else
{
if (monster.MonsterInfo.InSight > 400000 && monster.MonsterInfo.InSight < 600000 || monster.MonsterInfo.InSight > 800000 && monster.MonsterInfo.InSight != monster.UID)
{
Entity attacked = null;
if (client.Screen.TryGetValue(monster.MonsterInfo.InSight, out attacked))
{
DateTime now_time = DateTime.Now;
if (now_time > monster.AttackStamp.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
{
monster.AttackStamp = now_time;
if (attacked.Dead)
{
monster.MonsterInfo.InSight = 0;
}
else
new Game.Attacking.Handle(null, monster, attacked);
}
}
else
monster.MonsterInfo.InSight = 0;
}
}
}
}
}
}
public static void CommandsAI(string command)
{
if (command == null)
return;
string[] data = command.Split(' ');
switch (data[0])
{
case "@endelite":
{
ServerBase.Kernel.Elite_PK_Tournament.Start = false;
ServerBase.Kernel.Elite_PK_Tournament.Finish();
break;
}
case "@1":
{
Database.EntityTable.ID();
break;
}
case "@startelite":
{
ServerBase.Kernel.Elite_PK_Tournament.Open();
break;
}
case "@threds":
{
ServerBase.FrameworkTimer.ShowThreadStats();
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) % 60) + " minutes.");
break;
}
case "@online":
{
Console.WriteLine("Online players count: " + ServerBase.Kernel.GamePool.Count);
string line = "";
var clientsss = ServerBase.Kernel.GamePool.Values.ToArray();
foreach (Client.GameState pClient in clientsss)
line += pClient.Entity.Name + ",";
if (line != "")
{
line = line.Remove(line.Length - 1);
Console.WriteLine("Players: " + 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":
{
using (var conn = Database.DataHolder.MySqlConnection)
{
conn.Open();
var WC = ServerBase.Kernel.GamePool.Values.ToArray();
int total = WC.Length;
foreach (Client.GameState client in WC)
{
client.Account.Save(conn);
Database.EntityTable.SaveEntity(client, conn);
Database.SkillTable.SaveSkills(client, conn);
Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic, conn);
Console.WriteLine(client.Entity.Name + " has been saved! Left to save: " + (total--));
}
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
}
}
break;
case "@playercap":
{
try
{
PlayerCap = int.Parse(data[1]);
}
catch
{
}
break;
}
case "@exit":
{
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
// GameServer.Disable();
// AuthServer.Disable();
CommandsAI("@save");
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
Environment.Exit(0);
}
break;
case "@restart":
{
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
// GameServer.Disable();
//AuthServer.Disable();
CommandsAI("@save");
if (GuildWar.IsWar)
GuildWar.End();
new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration")
.Set("GuildID", Game.ConquerStructures.Society.Guild.GuildCounter.Now)
.Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now)
.Set("DetainItemUID", Database.DetainedItemTable.Counter.Now).Set("ClanUID", Game.Clans.ClanCount.Now)
.Where("Server", ServerBase.Constants.ServerName).Execute();
Application.Restart();
Environment.Exit(0);
}
break;
case "@account":
{
Database.AccountTable account = new AccountTable(data[1]);
account.Password = data[2];
account.State = AccountTable.AccountState.Player;
account.Save();
}
break;
}
}
/* public class Game_NewConection
{
private System.Net.Sockets.Socket _socket;
public Game_NewConection(System.Net.Sockets.Socket socket)
{
this._socket = socket;
}
public void CreateConnection()
{
bool change = false;
bool Join = true;
for (int x = 0; x < ServerBase.Kernel.GameBind.Count; x++)
{
if (x >= ServerBase.Kernel.GameBind.Count) break;
if (ServerBase.Kernel.GameBind[x] != null)
{
if (ServerBase.Kernel.GameBind[x].Split(';')[0] == _socket.RemoteEndPoint.ToString().Split(':')[0])
{
change = true;
long date = long.Parse(ServerBase.Kernel.GameBind[x].Split(';')[1].ToString());
DateTime allow = DateTime.FromBinary(date);
if (DateTime.Now.Ticks > allow.AddSeconds(15).Ticks)
{
ServerBase.Kernel.GameBind[x]
= _socket.RemoteEndPoint.ToString().Split(':')[0] + ";"
+ DateTime.Now.Ticks.ToString();
}
else Join = false;
}
}
}
if (Join)
{
if (!change)
ServerBase.Kernel.GameBind.Add(_socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString());
Client.GameState Client = new Conquer_Online_Server.Client.GameState(_socket);
Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
Client.Accepter();
}
else
{
_socket.Disconnect(false);
}
}
}
*/
/* public class NewConnecsion
{
private System.Net.Sockets.Socket _socket;
private SocketServerType Port;
public NewConnecsion(System.Net.Sockets.Socket socket, SocketServerType m_port)
{
if (m_port == Network.SocketServerType.AuthServer)
{
_socket = socket;
Port = m_port;
}
}
public void AuthServer_AnnounceNewConnection()
{
bool change = false;
bool Join = true;
for (int x = 0; x < ServerBase.Kernel.AuthBind.Count; x++)
{
if (x >= ServerBase.Kernel.AuthBind.Count) break;
if (ServerBase.Kernel.AuthBind[x] != null)
{
if (ServerBase.Kernel.AuthBind[x].Split(';')[0] == _socket.RemoteEndPoint.ToString().Split(':')[0])
{
change = true;
long date = long.Parse(ServerBase.Kernel.AuthBind[x].Split(';')[1].ToString());
DateTime allow = DateTime.FromBinary(date);
if (DateTime.Now.Ticks > allow.AddSeconds(15).Ticks)
{
ServerBase.Kernel.AuthBind[x] = _socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString();
}
else Join = false;
}
}
}
if (Join)
{
if (!change)
ServerBase.Kernel.AuthBind.Add(_socket.RemoteEndPoint.ToString().Split(':')[0] + ";" + DateTime.Now.Ticks.ToString());
Client.AuthState authState = new Client.AuthState(_socket);
authState.Cryptographer = new Network.Cryptography.AuthCryptography();
Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
pcs.Seed = ServerBase.Kernel.Random.Next();
authState.PasswordSeed = pcs.Seed;
authState.Send(pcs);
authState.Accepter();
}
else
{
_socket.Disconnect(false);
}
}
}*/
}
}
|
Are you fucking joking with me? If you don't know enough about C# to copy and paste things then why are you here?! Common sense not so common anymore? Stick with your console window till you understand 5 minutes worth of studying C#.
|
|
|
11/19/2011, 15:24
|
#72
|
elite*gold: 0
Join Date: Nov 2011
Posts: 68
Received Thanks: 9
|
Here's my outcome.
|
|
|
11/19/2011, 17:47
|
#73
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by PretendTime
Here's my outcome.
|
Looks good. You might want to add a margin to it though so the text isn't on the border of the window.
|
|
|
11/19/2011, 19:44
|
#74
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by PretendTime
Here's my outcome.
|
Looks like the braifnfuck compiler.
|
|
|
11/19/2011, 22:25
|
#75
|
elite*gold: 0
Join Date: Nov 2011
Posts: 68
Received Thanks: 9
|
Quote:
Originally Posted by Fаng
Looks good. You might want to add a margin to it though so the text isn't on the border of the window.
|
Thanks for the advice i didn't even notice that
Quote:
Originally Posted by BaussHacker
Looks like the braifnfuck compiler.
|
What is this "braifnfuck compiler"?
|
|
|
 |
|
Similar Threads
|
[HELP] How do i create a custom interface?
09/04/2015 - EO PServer Hosting - 7 Replies
Hey guys ,
Im just wondering if you could tell me or link me a guide of how to create a custom interface for eudemons online because i have no idea and i think that you all could help me i've saw it before on a few other servers.
Thankyou from lewis :)
|
[HOW TO] Create a New Interface
11/27/2010 - Metin2 PServer Guides & Strategies - 30 Replies
Ich hoffe das TuT gab es nicht schonmal... Wenn doch sry, habe in der SuFu nichts gefunden :-(
So fangen wir an :
Was brauchen wir?
-Einen Client
-Die entpackten Etc.eix/epk Dateien
-Irgendeinen Server
Was müssen wir tun?
|
TAPLG Tester Needed (User Interface)
01/30/2007 - World of Warcraft - 3 Replies
As some of you might know im creating a Leveling Guide Addon for WoW, its for alliance, all races and all classes.
Its currently still in the developing state and as for now only the race Draenei level 1-12 is finished. This guid will go up to level 70.
I need a tester to check if its working the way i entended it to.
If someone is interested please PM your icq number to me so we can talk more detailed.
Only the first 5 will be abel to test this and give me feedback, i will post here...
|
FtH User Interface (Complete Interface)
09/05/2006 - World of Warcraft - 10 Replies
Hallo ,
ich will euch das wohl beste Interface nicht vorenthalten. For the Horde hat mit seiner ersten Version seines eigenen Interfaces schon gute arbeit geleistet. Aber das naja nich mehr ganz aktuele ist noch besser.
http://web4.h60972.serverkompetenz.net/for...p?th readid=3465 <- DL Link.
Dort gibt es aber auch den kompletten Guide zu dem Interface.
Achja FTH benutzt X-Raid , nicht jedem seine Sache. Das Interface ist aber auch mit CT_RAID kompatibel.
|
User Interface von wow
12/10/2004 - WoW Guides & Templates - 2 Replies
auf worldofwarcraft.com wurde heute ein eigenes Tool gebastelt um User Interfaces zu basteln!
links:
Tool
Tutorial
worldofwarcraft.com
ps: mmhh xml? ähm ist das das xml, was man auch bei selhtml ne einführung drüber bekommt?
|
All times are GMT +1. The time now is 15:59.
|
|