/
Program.cs
3504 lines (3272 loc) · 194 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using PhoenixProject.Database;
using PhoenixProject.Game;
using PhoenixProject.Game.ConquerStructures.Society;
using PhoenixProject.Network.AuthPackets;
using PhoenixProject.Network.Sockets;
using PhoenixProject.Network.GamePackets;
using PhoenixProject.Network.GamePackets.EventAlert;
namespace PhoenixProject
{
class Program
{
public static void WriteError(Exception ex)
{
Console.WriteLine(ex.ToString() + " (Report this Shit to Kimo!)");
}
public static void WriteLine(Exception Exc)
{
try
{
Console.WriteLine(Exc.ToString());
}
catch { }
}
public static void WriteLine(string Line)
{
try
{
Console.WriteLine(Line);
}
catch { }
}
public static void WriteLine()
{
try
{
Console.WriteLine("");
}
catch { }
}
[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 bool connec = false;
public static bool restarted = false;
public static uint mess = 0;
public static Time32 messtime;
public static long PoolSize = 0;
public static bool IsBetweenTwoPoints(ushort x, ushort y, ushort startx, ushort starty, ushort endx, ushort endy)
{
return (((x >= startx) && (y >= starty)) && ((x <= endx) && (y <= endy)));
}
public static long Carnaval = 0;
public static long Carnaval2 = 0;
public static long Carnaval3 = 0;
public static long MaxOn = 0;
public static KimoDatabase.Database KimoDatabase;
//public static Quests QuestDatabase;
public static long Carnaval4 = 0;
public static Time32 QuizStamp;
public static Time32 KimoTime1;
public static PhoenixProject.Region.MapRegions MapRegions;
public static Time32 KimoTime2;
public static Time32 KimoTime3;
public static Time32 KimoTime4;
public static Time32 KimoTime5;
public static Time32 KimoTime6;
public static Time32 KimoTime7;
public static Time32 KimoTime8;
public static Time32 KimoTime9;
public static Time32 KimoTime10;
public static Time32 KimoTime11;
public static Time32 KimoTime12;
public static Time32 KimoTime13;
public static Time32 KimoTime14;
public static Time32 KimoTime15;
public static Time32 KimoTime16;
//public static SpellTable SpellDatabase;
public static long Carnaval5 = 0;
public static string ConquerDirectory = @"C:\";
public static string QuestInfo = Path.Combine(ConquerDirectory, "Questinfo.ini");
public static string QuestInfo2 = "database\\Questinfo.ini";
public static string Mapr = "database\\region.ini";
public static long Carnaval6 = 0;
public static KinSocket.TqRandom Random;
public static long Carnaval7 = 0;
public static long Carnaval8 = 0;
public static long EliteRank = 0;
public static long WeatherType = 0;
public static int PlayerCap = 400;
public static int BoxX = 43;
public static int DemonCave1 = 0;
public static int DemonCave2 = 0;
public static int DemonCave3 = 0;
public static int Quiz1 = 0;
public static ulong kimo = 2105;
public static ulong kimo2 = 2;
public static ulong kimo3 = 33;
public static string DBName = "";
public static string DBUser = "";
public static string DBPass = "";
public const string PacketSniffingPath = "database\\sniff\\";
public static int BoxY = 50;
public static DateTime m_msgDate;
public static byte m_Counter;
//public static Time32 InviteSendStamp;
//public static Time32 KillConnectionTime;
public static AsyncSocket AuthServer;
public static uint ScreenColor = 0;
public static uint steed = 147;
public static uint lotterytype = 300;
public static uint lotteryprize = 7;
public static AsyncSocket GameServer;
public static ServerBase.Counter EntityUID;
public static string GameIP;
public static DayOfWeek Today;
public static ushort GamePort;
public static ushort AuthPort;
public static uint nextID = 0;
public static uint nextClanid = 0;
public static uint nextEntityID = 0;
public static uint nextGuildID = 0;
public static DateTime StartDate;
public static DateTime Refresh;
public static System.Timers.Timer MyTimer;
public static DateTime RestartDate = StartDate.AddHours(12);
public static Thread[] Threads = new Thread[4];
static byte counter = 0;
static byte Equation = 0;
public static ServerBase.Threads kimoz6 = new ServerBase.Threads(200);
public static ServerBase.Threads kimoz5 = new ServerBase.Threads(1000);
public static ServerBase.Threads kimoz4 = new ServerBase.Threads(1000);
public static ServerBase.Threads kimoz3 = new ServerBase.Threads(1000);
public static ServerBase.Threads kimoz2 = new ServerBase.Threads(1000);
public static ServerBase.Threads kimoz1 = new ServerBase.Threads(100);
public static ServerBase.Threads kimo_ = new PhoenixProject.ServerBase.Threads(1000);
public static ServerBase.Threads SystemMessages = new ServerBase.Threads(1000);
public static ServerBase.Threads ServerStuff = new ServerBase.Threads(1000);
public static ServerBase.Threads ArenaSystem = new PhoenixProject.ServerBase.Threads(1000);
public static void StartThreads()
{
/*MyTimer = new System.Timers.Timer(1000);
MyTimer.AutoReset = true;
MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack5);
MyTimer.Start();*/
/* Program.Factory = new KinSocket.ProcessFactory(20);
Program.Factory.AddProcess(new Action(ServerStuff_Execute));
Program.Factory.AddProcess(new Action(kimo_Execute));
Program.Factory.AddProcess(new Action(SystemMessages_Execute));
Program.Factory.AddProcess(new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute));
Program.Factory.AddProcess(new Action(FactoryHandles.OnMobTimer));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerAction));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerAttack));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerBuff));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerMisc));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerReceive));
Program.Factory.AddProcess(new Action(FactoryHandles.OnPlayerSave));
Program.Factory.AddProcess(new Action(FactoryHandles.OnTimerPet));
Program.Factory.Start();*/
Threads[0] = new Thread(new ThreadStart(Game.ConquerStructures.Arena.ArenaSystem_Execute));
Threads[1] = new Thread(new ThreadStart(kimo_Execute));
Threads[2] = new Thread(new ThreadStart(SystemMessages_Execute));
Threads[3] = new Thread(new ThreadStart(ServerStuff_Execute));
////Threads[4] = new Thread(new ThreadStart(Kimoz1_Execute));
//Threads[5] = new Thread(new ThreadStart(Kimoz2_Execute));
// Threads[6] = new Thread(new ThreadStart(Kimoz3_Execute));
// Threads[7] = new Thread(new ThreadStart(Kimoz4_Execute));
//Threads[8] = new Thread(new ThreadStart(Kimoz5_Execute));
//Threads[9] = new Thread(new ThreadStart(Kimoz6_Execute));
foreach (Thread _t in Threads)
{
counter++;
_t.Start();
Equation = counter; Equation -= 1;
}
Console.WriteLine("Threads Started Compelete!!");
}
public static Client.GameState[] Values = null;
public static Server GUI;
static void Main(string[] args)
{
//Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.Run(new NotForPublicNotAtAll.NoCrash());
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
SaveException(e.Exception);
}
static void CurrentDomain_UnhandledException
(object sender, UnhandledExceptionEventArgs e)
{
try
{
OutOfMemoryException ex = (OutOfMemoryException)e.ExceptionObject;
SaveException2(ex);
}
finally
{
// Application.Exit();
}
}
public static void SaveException(Exception e)
{
if (e.TargetSite.Name == "ThrowInvalidOperationException")
return;
if (e.Message.Contains("String reference not set"))
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;
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());
}
public static void SaveException2(OutOfMemoryException e)
{
if (e.TargetSite.Name == "ThrowInvalidOperationException")
return;
if (e.Message.Contains("String reference not set"))
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;
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());
}
public static void StartEngine()
{
EngineThread_Execute();
}
public static int RandomSeed = 0;
static DateTime LastRandomReset = DateTime.Now;
public static KinSocket.ProcessFactory Factory;
#region Thread Processes
static void EngineThread_Execute()
{
/*var proc = System.Diagnostics.Process.GetCurrentProcess();
proc.PriorityBoostEnabled = true;
proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;*/
var proc = System.Diagnostics.Process.GetCurrentProcess();
proc.PriorityBoostEnabled = true;
proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
if (DateTime.Now.DayOfYear > 365)
{
return;
}
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;
// Application.Run(new Server().ShowDialog());
Console.Title = "TQ Conquer Server Loading....."; Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
IntPtr hWnd = FindWindow(null, Console.Title);
Console.WriteLine("|------( TheHunter#3 5692-2013 )------|");
Console.WriteLine("|------( ----All Rights bk to Kimo Source---- )------|");
Console.WriteLine(">>>>>>>>Loading.....................");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Load server configuration! !");
string ConfigFileName = "configuration.ini";
ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName);
{
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"));
}
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName);
PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
if (r.Read())
{
//EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID"));
Game.ConquerStructures.Society.Guild.GuildCounter = new PhoenixProject.ServerBase.Counter(r.ReadUInt32("GuildID"));
Network.GamePackets.ConquerItem.ItemUID = new PhoenixProject.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");
PlayerCap = r.ReadInt32("PlayerCap");
}
r.Close();
Console.WriteLine("Initializing database.");
// Database.Quests.Load();
Console.WriteLine("Initializing database Succes.");
Program.ServerRrestart = true;
Database.NameChange.UpdateNames();
Game.KimoEvents.LordsWarTime();
Game.KimoEvents.CaptureTeamTime();
Game.KimoEvents.GWstartTime();
Game.KimoEvents.GWEndTime();
Game.KimoEvents.DisCityTime();
Game.KimoEvents.DemonCaveTime();
Game.KimoEvents.ElitePKTime();
Game.KimoEvents.SkillTeamTime();
Game.KimoEvents.SpouseTime();
Game.KimoEvents.ClassTime();
Game.KimoEvents.EliteGWTime();
Game.KimoEvents.ClanWarTime();
//TreasureBox Game.KimoEvents.TreasureTime();
Game.KimoEvents.WeeklyTime();
Game.KimoEvents.DonationWarTime();
Database.GameUpdatess.LoadRates();
Database.Messagess.LoadRates();
Database.HelpDesk.LoadRates();
Database.ConquerItemInformation.Load();
// Database.ItemLog.CleanUp();
Game.Flags.LoadFlags();
Database.DataHolder.ReadStats();
Database.MonsterInformation.Load();
Database.SpellTable.Load();
Console.WriteLine("New Spells loaded.");
Database.ShopFile.Load();
Database.MapsTable.Load();
Game.PrizeNPC.Load();
Database.NobilityTable.Load();
Database.ArenaTable.Load();
Database.GuildTable.Load();
Database.LotteryTable.Load();
Database.DROP_SOULS.LoadDrops();
Database.DROP_SOULS.LoadJar();
Refinery.Load();
Database.DMaps.Load();
Database.QuizData.Load();
Database.EntityTable.LoadPlayersVots();
Values = new Client.GameState[0];
/* foreach (Database.MapsTable.MapInformation map in Database.MapsTable.MapInformations.Values)
{
if (map.ID == map.BaseID)
{
new Game.Map(map.ID, Database.DMaps.MapPaths[map.BaseID]);
Console.WriteLine(" " + map.ID + "");
Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + "");
}
}*/
new Game.Map(1038, Database.DMaps.MapPaths[1038]);
new Game.Map(2071, Database.DMaps.MapPaths[2071]);
new Game.Map(1509, Database.DMaps.MapPaths[1509]);
Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + "");
Game.ConquerStructures.Society.GuildWar.Initiate();
Console.WriteLine("Guild war initializated.");
Game.ClanWar.Initiate();
Console.WriteLine("Clan war initializated.");
Game.ConquerStructures.Society.EliteGuildWar.EliteGwint();
Console.WriteLine("Elite Guild war initializated.");
Database.rates.LoadRates();
Database.EntityTable.NextEntity();
EntityUID = new ServerBase.Counter(Program.nextEntityID);
if (EntityUID.Now == 0) // i fixed the bug, now it shows what it's supposed to, you have database problems
{
Console.Clear();
Console.WriteLine("Database error. Please check your MySQL. Server will now close.");
return;
}
Console.WriteLine("Loading Game Clans.");
Database.Clans.LoadAllClans();
Database.EntityTable.NextUit();
Database.EntityTable.NextEntity();
Database.Clans.NextClan();
Database.EntityTable.NextGuild();
ServerBase.FrameworkTimer.SetPole(100000, 100000);
// ServerBase.FrameworkTimer.SetPole(100, 50);
//System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ServerBase.FrameworkTimer.DoNothing));
Values = new Client.GameState[0];
Database.DMaps.LoadHouse();
Console.WriteLine("House Table Loaded.");
Program.MapRegions = new PhoenixProject.Region.MapRegions();
Program.MapRegions.Load();
Console.WriteLine("MapRegions Loaded.");
Game.Tournaments.EliteTournament.LoadTop8();
Console.WriteLine("ElitePk Winner Loaded.");
Console.WriteLine("Flower Table Loaded.");
SystemMessages.Execute += new Action(SystemMessages_Execute);
SystemMessages.Start();
kimo_.Execute += new Action(kimo_Execute);
kimo_.Start();
ServerStuff.Execute += new Action(ServerStuff_Execute);
ServerStuff.Start();
ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute);
ArenaSystem.Start();
kimoz6.Execute += new Action(Kimoz6_Execute);
kimoz6.Start();
kimoz5.Execute += new Action(Kimoz5_Execute);
kimoz5.Start();
kimoz4.Execute += new Action(Kimoz4_Execute);
kimoz4.Start();
kimoz3.Execute += new Action(Kimoz3_Execute);
kimoz3.Start();
kimoz2.Execute += new Action(Kimoz2_Execute);
kimoz2.Start();
kimoz1.Execute += new Action(Kimoz1_Execute);
kimoz1.Start();
//StartThreads();
// Console.Title = "[" + Database.rates.servername + "]Phoenix Conquer Project. Start time: " + StartDate.ToString("dd MM yyyy hh:mm") + "";
new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Where("Online", 1).Execute();
Console.Title = "[" + Database.rates.servername + "] TheHunter Source. Start time: " + Program.StartDate.ToString("dd MM yyyy hh:mm") + ". Players online: " + ServerBase.Kernel.GamePool.Count + "/" + Program.PlayerCap + " Max Online: " + Program.MaxOn + "";
Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter();
Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
Console.WriteLine("Initializing 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("|------[ >>>>>Server Loaded<<<<< ]------|");
Console.WriteLine("|------[ Coded and Edited by theHunter ]------|");
Console.WriteLine("|--------Call_mee_aly@hotmail.com-----|");
Console.WriteLine("|------------01116315131---------|");
Console.WriteLine("|----All Rights bk to TheHunter#3 Source----|");
Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds.");
Program.ServerRrestart = false;
GC.Collect();
while (true)
{
CommandsAI(Console.ReadLine());
}
}
static void Kimoz6_Execute()
{
lock (Values)
Values = ServerBase.Kernel.GamePool.Values.ToArray();
Time32 Now = Time32.Now;
// KimoTime1 = Time32.Now;
foreach (Client.GameState client in Values)
{
if (client.Socket != null)
{
if (client.Socket.Connected)
{
if (client.Entity.HandleTiming)
{
#region Training points
if (client.Entity.HeavenBlessing > 0 && !client.Entity.Dead)
{
if (Now > client.LastTrainingPointsUp.AddMinutes(10))
{
client.OnlineTrainingPoints += 10;
if (client.OnlineTrainingPoints >= 30)
{
client.OnlineTrainingPoints -= 30;
client.IncreaseExperience(client.ExpBall / 100, false);
}
client.LastTrainingPointsUp = Now;
client.Entity.Update(Network.GamePackets.Update.OnlineTraining, client.OnlineTrainingPoints, false);
}
}
#endregion
#region Minning
if (client.Mining && !client.Entity.Dead)
{
if (Now >= client.MiningStamp.AddSeconds(2))
{
client.MiningStamp = Now;
Game.ConquerStructures.Mining.Mine(client);
}
}
#endregion
#region MentorPrizeSave
if (Now > client.LastMentorSave.AddSeconds(5))
{
Database.KnownPersons.SaveApprenticeInfo(client.AsApprentice);
client.LastMentorSave = Now;
}
#endregion
#region Attackable
if (client.JustLoggedOn)
{
client.JustLoggedOn = false;
client.ReviveStamp = Now;
}
if (!client.Attackable)
{
if (Now > client.ReviveStamp.AddSeconds(5))
{
client.Attackable = true;
}
}
#endregion
#region DoubleExperience
if (client.Entity.DoubleExperienceTime > 0)
{
if (Now > client.Entity.DoubleExpStamp.AddMilliseconds(1000))
{
client.Entity.DoubleExpStamp = Now;
client.Entity.DoubleExperienceTime--;
}
}
#endregion
#region HeavenBlessing
if (client.Entity.HeavenBlessing > 0)
{
if (Now > client.Entity.HeavenBlessingStamp.AddMilliseconds(1000))
{
client.Entity.HeavenBlessingStamp = Now;
client.Entity.HeavenBlessing--;
}
}
#endregion
#region Enlightment
if (client.Entity.EnlightmentTime > 0)
{
if (Now >= client.Entity.EnlightmentStamp.AddMinutes(1))
{
client.Entity.EnlightmentStamp = Now;
client.Entity.EnlightmentTime--;
if (client.Entity.EnlightmentTime % 10 == 0 && client.Entity.EnlightmentTime > 0)
client.IncreaseExperience(Game.Attacking.Calculate.Percent((int)client.ExpBall, .10F), false);
}
}
#endregion
#region PKPoints
if (Now >= client.Entity.PKPointDecreaseStamp.AddMinutes(5))
{
client.Entity.PKPointDecreaseStamp = Now;
if (client.Entity.PKPoints > 0)
{
client.Entity.PKPoints--;
}
else
client.Entity.PKPoints = 0;
}
#endregion
#region OverHP
if (client.Entity.FullyLoaded)
{
if (client.Entity.Hitpoints > client.Entity.MaxHitpoints && client.Entity.MaxHitpoints > 1 && !client.Entity.Transformed)
{
client.Entity.Hitpoints = client.Entity.MaxHitpoints;
}
}
#endregion
#region Stamina
if (Now > client.Entity.StaminaStamp.AddMilliseconds(500))
{
if (client.Entity.Vigor < client.Entity.MaxVigor)
{
if (client.Entity.Vigor + 3 < client.Entity.MaxVigor)
{
client.Entity.Vigor += (ushort)(3 + (client.Entity.Action == Game.Enums.ConquerAction.Sit ? 2 : 0));
{
Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
vigor.VigorValue = client.Entity.Vigor;
vigor.Send(client);
}
}
else
{
client.Entity.Vigor = (ushort)client.Entity.MaxVigor;
{
Network.GamePackets.Vigor vigor = new Network.GamePackets.Vigor(true);
vigor.VigorValue = client.Entity.Vigor;
vigor.Send(client);
}
}
}
if (!client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
{
int limit = 0;
if (client.Entity.HeavenBlessing > 0)
limit = 50;
if (client.Entity.Stamina != 100 + limit)
{
if (client.Entity.Action == Game.Enums.ConquerAction.Sit || !client.Equipment.Free(18))
{
if (client.Entity.Stamina <= 93 + limit)
{
client.Entity.Stamina += 7;
}
else
{
if (client.Entity.Stamina != 100 + limit)
client.Entity.Stamina = (byte)(100 + limit);
}
}
else
{
if (client.Entity.Stamina <= 97 + limit)
{
client.Entity.Stamina += 3;
}
else
{
if (client.Entity.Stamina != 100 + limit)
client.Entity.Stamina = (byte)(100 + limit);
}
}
}
client.Entity.StaminaStamp = Now;
}
}
#endregion
#region SoulShackle
if (client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.SoulShackle))
{
if (Now > client.Entity.ShackleStamp.AddSeconds(client.Entity.ShackleTime))
{
client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.SoulShackle);
}
}
#endregion
#region Freeze
if (client.Entity.ContainsFlag(Network.GamePackets.Update.Flags2.IceBlock))
{
if (Now > client.Entity.FreezeStamp.AddSeconds(client.Entity.FreezeTime))
{
client.Entity.RemoveFlag(Network.GamePackets.Update.Flags2.IceBlock);
}
}
#endregion
#region AzureShield
if (client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.AzureShield))
{
if (Now > client.Entity.MagicShieldStamp.AddSeconds(client.Entity.MagicShieldTime))
{
client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.AzureShield);
}
}
#endregion
#region Die Delay
if (client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Dead) && !client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Ghost))
{
if (Now > client.Entity.DeathStamp.AddSeconds(2))
{
client.Entity.AddFlag(Network.GamePackets.Update.Flags.Ghost);
if (client.Entity.Body % 10 < 3)
client.Entity.TransformationID = 99;
else
client.Entity.TransformationID = 98;
client.SendScreenSpawn(client.Entity, true);
}
}
#endregion
#region SkillTeam
if (client.Entity.MapID == 7009)
{
if (client.Entity.MapID == 7009)
{
Game.KimoSkillWar.SkillTeamRes(client);
}
}
#endregion
#region CaptureFlag
if (client.Entity.MapID == 2060)
{
if (client.Entity.MapID == 2060)
{
Game.Team.CaptureRes(client);
}
}
#endregion
}
}
}
}
// Thread.Sleep(200);
}
static void Kimoz5_Execute()
{
lock (Values)
Values = ServerBase.Kernel.GamePool.Values.ToArray();
Time32 Now = Time32.Now;
KimoTime2 = Time32.Now;
foreach (Client.GameState client in Values)
{
if (client.Socket != null)
{
if (client.Socket.Connected)
{
if (client.Entity.HandleTiming)
{
#region CharacterThread_Execute
if (client.Entity.BlackSpots)
{
if (Now >= client.Entity.BlackSpotTime.AddSeconds(client.Entity.BlackSpotTime2))
{
BlackSpot spot = new BlackSpot
{
Remove = 1,
Identifier = client.Entity.UID
};
client.Send((byte[])spot);
client.Entity.BlackSpots = false;
client.Entity.BlackSpotTime2 = 0;
client.Entity.BlackSpotCheck = 0;
}
else
{
if (client.Entity.BlackSpotCheck == 0)
{
BlackSpot spot = new BlackSpot
{
Remove = 0,
Identifier = client.Entity.UID
};
client.Send((byte[])spot);
client.Entity.BlackSpotCheck = 1;
}
}
}
/* if (ActivePOPUP == 99995)
{
if (Now > LastPopUPCheck.AddSeconds(20))
{
Owner.Disconnect();
}
}*/
/* if (Owner.popups == 0)
{//kimo
Owner.popups = 1;
Owner.Send(new Network.GamePackets.Message("" + PhoenixProject.Database.rates.PopUpURL + "", System.Drawing.Color.Red, Network.GamePackets.Message.Website));
}*/
if (Database.rates.Night == 1)
{
if (client.Entity.MapID == 701)
{
Random disco = new Random();
uint discocolor = (uint)disco.Next(50000, 999999999);
//Program.ScreenColor = discocolor;
//ScreenColor = Program.ScreenColor;
PhoenixProject.Network.GamePackets.Data datas = new PhoenixProject.Network.GamePackets.Data(true);
datas.UID = client.Entity.UID;
datas.ID = 104;
datas.dwParam = discocolor;
client.Send(datas);
}
else
{
if (DateTime.Now.Minute >= 40 && DateTime.Now.Minute <= 45)// Program.ScreenColor = 5855577
{
PhoenixProject.Network.GamePackets.Data datas = new PhoenixProject.Network.GamePackets.Data(true);
datas.UID = client.Entity.UID;
datas.ID = 104;
datas.dwParam = 5855577;
client.Send(datas);
}
else
{
PhoenixProject.Network.GamePackets.Data datas = new PhoenixProject.Network.GamePackets.Data(true);
datas.UID = client.Entity.UID;
datas.ID = 104;
datas.dwParam = 0;
client.Send(datas);
}
}
}
if (DateTime.Now.DayOfYear > 365)
{
client.Disconnect();
return;
}
if (DateTime.Now.Hour == 16 && DateTime.Now.Minute >= 20 && DateTime.Now.Second == 00)
{
if (client.Entity.MapID == 7777)
{
client.Entity.Teleport(1002, 391, 371);
}
}
if (Now > client.Entity.InviteSendStamp.AddSeconds(5) && client.Entity.invite)
{
Game.ClanWar.ScoreSendStamp = Time32.Now;
client.Entity.invite = false;
//Console.WriteLine("a7a");
}
/*if (Now > LastPopUPCheck.AddMinutes(30))
{
if (!ServerBase.Constants.PKForbiddenMaps.Contains(Owner.Map.BaseID))
{
if (!ServerBase.Constants.PKFreeMaps.Contains(MapID))
{
if (MapID < 1000000)
{
ActivePOPUP = 99995;
Owner.Send(new Network.GamePackets.NpcReply(6, "Are You Here? Please Press OK or Cancel To verrify You are Not Using any sort of Bots."));
LastPopUPCheck = Time32.Now;
}
}
}
}*/
if (DateTime.Now.Hour == Game.KimoEvents.EBHour && DateTime.Now.Minute == 05 && DateTime.Now.Second == 15)
{
if (DateTime.Now.Hour == Game.KimoEvents.EBHour && DateTime.Now.Minute == 05 && DateTime.Now.Second == 15)
{
if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead)
{
EventAlert alert = new EventAlert
{
StrResID = 10533,
Countdown = 30,
UK12 = 1
};
client.Entity.StrResID = 10533;
client.Send((byte[])alert);
//return;
}
}
}
if (DateTime.Now.Hour == Game.KimoEvents.DWHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
if (DateTime.Now.Hour == Game.KimoEvents.DWHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
Network.GamePackets.NpcReply npc = new Network.GamePackets.NpcReply(6, "DonationCps War has Started! You Wana Join?");
npc.OptionID = 237;
client.Send(npc.ToArray());
//return;
}
Program.DemonCave3 = 0;
}
if (DateTime.Now.DayOfWeek != DayOfWeek.Saturday && DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
{
if (DateTime.Now.Hour == Game.KimoEvents.ClanHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
Program.kimo = 1313;
Program.kimo2 = 7;
testpacket str = new testpacket(true);
client.Send(str);
//ClanWar;
}
}
if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday && DateTime.Now.Hour == (Game.KimoEvents.GWEEndHour - 1) && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday && DateTime.Now.Hour == (Game.KimoEvents.GWEEndHour - 1) && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)
{
if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead)
{
EventAlert alert = new EventAlert
{
StrResID = 10515,
Countdown = 30,
UK12 = 1
};
client.Entity.StrResID = 10515;
client.Send((byte[])alert);
//return;
}
}
}
if (DateTime.Now.Hour == Game.KimoEvents.SKHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 30)
{
if (DateTime.Now.Hour == Game.KimoEvents.SKHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 30)
{
if (client.Map.BaseID != 6001 && client.Map.BaseID != 6000 && !client.Entity.Dead)
{
EventAlert alert = new EventAlert
{
StrResID = 10541,
Countdown = 30,
UK12 = 1
};
client.Entity.StrResID = 10541;
client.Send((byte[])alert);
}
//return;
}
}
if (DateTime.Now.Hour == Game.KimoEvents.CFHour && DateTime.Now.Minute == 00 && DateTime.Now.Second == 00)