-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
12802 lines (12579 loc) · 643 KB
/
Main.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
namespace Terraria
{
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
public class Main : Game
{
public static Texture2D antLionTexture;
public static float armorAlpha = 1f;
public static Texture2D[] armorArmTexture = new Texture2D[0x11];
public static Texture2D[] armorBodyTexture = new Texture2D[0x11];
public static Texture2D[] armorHeadTexture = new Texture2D[0x1d];
public static bool armorHide = false;
public static Texture2D[] armorLegTexture = new Texture2D[0x10];
public static bool autoGen = false;
public static bool autoJoin = false;
public static bool autoPass = false;
public static bool autoPause = false;
public static bool autoSave = true;
public static bool autoShutdown = false;
public static int[] availableRecipe = new int[Recipe.maxRecipes];
public static float[] availableRecipeY = new float[Recipe.maxRecipes];
public static int background = 0;
public static int[] backgroundHeight = new int[7];
public static Texture2D[] backgroundTexture = new Texture2D[7];
public static int[] backgroundWidth = new int[7];
private static int backSpaceCount = 0;
private int bgScroll;
public static Texture2D blackTileTexture;
public static bool bloodMoon = false;
public static Texture2D boneArmTexture;
public static float bottomWorld = 38400f;
public static Texture2D bubbleTexture;
public static float[] buffAlpha = new float[0x13];
public static string buffString = "";
public static Texture2D[] buffTexture = new Texture2D[0x13];
public static float caveParrallax = 1f;
public static string cBuff = "B";
public static string cDown = "S";
public static Texture2D cdTexture;
public static Texture2D chain2Texture;
public static Texture2D chain3Texture;
public static Texture2D chain4Texture;
public static Texture2D chain5Texture;
public static Texture2D chain6Texture;
public static Texture2D chainTexture;
public static Texture2D chat2Texture;
public static Texture2D chatBackTexture;
public static int chatLength = 600;
public static int numChatLines = 7;
public static ChatLine[] chatLine = new ChatLine[numChatLines];
public static bool chatMode = false;
public static bool chatRelease = false;
public static string chatText = "";
public static Texture2D chatTexture;
public static string cHeal = "H";
public static int checkForSpawns = 0;
public static Chest[] chest = new Chest[0x3e8];
public static string cInv = "Escape";
public static string cJump = "Space";
public static string cLeft = "A";
public static Player clientPlayer = new Player();
public static Cloud[] cloud = new Cloud[100];
public static int cloudLimit = 100;
public static Texture2D[] cloudTexture = new Texture2D[4];
public static string cMana = "M";
private int colorDelay;
public static CombatText[] combatText = new CombatText[100];
public static bool craftGuide = false;
public static float craftingAlpha = 1f;
public static bool craftingHide = false;
public static string cRight = "D";
public static string cThrowItem = "Q";
public static string cUp = "W";
public int curMusic;
public static int curRelease = 12;
public static float cursorAlpha = 0f;
public static Color cursorColor = Color.White;
public static int cursorColorDirection = 1;
public static float cursorScale = 0f;
public static Texture2D cursorTexture;
public const double dayLength = 54000.0;
public static bool dayTime = true;
public static bool dedServ = false;
public static string defaultIP = "184.164.146.50";
private int[] displayHeight = new int[0x63];
private int[] displayWidth = new int[0x63];
public static int drawTime = 0;
public static int dungeonTiles;
public static int dungeonX;
public static int dungeonY;
public static Dust[] dust = new Dust[0x3e8];
public static Texture2D dustTexture;
public static bool editSign = false;
public static AudioEngine engine;
public static int evilTiles;
private static float exitScale = 0.8f;
public static int fadeCounter = 0;
public static Texture2D fadeTexture;
public static bool fixedTiming = false;
private int focusColor;
private int focusMenu = -1;
public static int focusRecipe;
public static SpriteFont fontCombatText;
public static SpriteFont fontDeathText;
public static SpriteFont fontItemStack;
public static SpriteFont fontMouseText;
public static int frameRate = 0;
public static bool frameRelease = false;
public static bool gameMenu = true;
public static bool gamePaused = false;
public static string getIP = defaultIP;
public static string getPort = Convert.ToString(Netplay.serverPort);
public static Gore[] gore = new Gore[0xc9];
public static Texture2D[] goreTexture = new Texture2D[0x63];
public static bool grabSky = false;
private GraphicsDeviceManager graphics;
public static Item guideItem = new Item();
public static bool hasFocus = true;
public static Color hcColor = new Color(200, 0x7d, 0xff);
public static Texture2D heartTexture;
public static int helpText = 0;
public static bool hideUI = false;
public static float[] hotbarScale = new float[] { 1f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f };
public static bool ignoreErrors = true;
private static KeyboardState inputText;
public static bool inputTextEnter = false;
public static int invasionDelay = 0;
public static int invasionSize = 0;
public static int invasionType = 0;
public static int invasionWarn = 0;
public static double invasionX = 0.0;
public static Texture2D inventoryBackTexture;
private static float inventoryScale = 0.75f;
public static Item[] item = new Item[0xc9];
public static string[] itemName = new string[0x1000]; //Mod: added more items
public static ItemText[] itemText = new ItemText[100];
public static Texture2D[] itemTexture = new Texture2D[0x1000]; //Mod: added more items
public static int jungleTiles;
public static KeyboardState keyState = Keyboard.GetState();
public static int lastItemUpdate;
public static int lastNPCUpdate;
public static float leftWorld = 0f;
public static string libPath = "";
public static Liquid[] liquid = new Liquid[Liquid.resLiquid];
public static LiquidBuffer[] liquidBuffer = new LiquidBuffer[0x2710];
public static Texture2D[] liquidTexture = new Texture2D[2];
public static Player[] loadPlayer = new Player[5];
public static string[] loadPlayerPath = new string[5];
public static string[] loadWorld = new string[0x3e7];
public static string[] loadWorldPath = new string[0x3e7];
private float logoRotation;
private float logoRotationDirection = 1f;
private float logoRotationSpeed = 1f;
private float logoScale = 1f;
private float logoScaleDirection = 1f;
private float logoScaleSpeed = 1f;
public static Texture2D logoTexture;
public static int magmaBGFrame = 0;
public static int magmaBGFrameCounter = 0;
public static Texture2D manaTexture;
public const int maxBackgrounds = 7;
public const int maxBuffs = 0x13;
public const int maxChests = 0x3e8;
public const int maxClouds = 100;
public const int maxCloudTypes = 4;
public const int maxCombatText = 100;
public const int maxDust = 0x3e8;
public const int maxGore = 200;
public const int maxGoreTypes = 0x63;
public const int maxHair = 0x11;
public const int maxInventory = 0x2c;
public const int maxItems = 200;
public const int maxItemSounds = 0x10;
public const int maxItemText = 100;
public const int maxItemTypes = 0x147;
public static int maxItemUpdates = 10;
public const int maxLiquidTypes = 2;
private static int maxMenuItems = 13;
public const int maxMusic = 8;
public static int maxNetPlayers = 0xff;
public const int maxNPCHitSounds = 3;
public const int maxNPCKilledSounds = 4;
public const int maxNPCs = 0x3e8;
public const int maxNPCTypes = 70;
public static int maxNPCUpdates = 15;
public const int maxPlayers = 0xff;
public const int maxProjectiles = 0x3e8;
public const int maxProjectileTypes = 0x37;
public static int maxScreenH = 0x4b0;
public static int maxScreenW = 0x780;
public static int maxSectionsX = (maxTilesX / 200);
public static int maxSectionsY = (maxTilesY / 150);
public const int maxStars = 130;
public const int maxStarTypes = 5;
public const int maxTileSets = 0x56;
public static float rightWorld = 134400f;
public static int maxTilesX = ((((int) rightWorld) / 0x10) + 1);
public static int maxTilesY = ((((int) bottomWorld) / 0x10) + 1);
public const int maxWallTypes = 14;
private float[] menuItemScale = new float[maxMenuItems];
public static int menuMode = 0;
public static bool menuMultiplayer = false;
public static bool menuServer = false;
public static int meteorTiles;
private const int MF_BYPOSITION = 0x400;
public static int minScreenH = 600;
public static int minScreenW = 800;
public static short moonModY = 0;
public static int moonPhase = 0;
public static Texture2D moonTexture;
public static string motd = "";
public static Color mouseColor = new Color(0xff, 50, 0x5f);
private static bool mouseExit = false;
public static bool mouseHC = false;
public static Item mouseItem = new Item();
public static bool mouseLeftRelease = false;
public static bool mouseRightRelease = false;
public static MouseState mouseState = Mouse.GetState();
public static byte mouseTextColor = 0;
public static int mouseTextColorChange = 1;
public static Microsoft.Xna.Framework.Audio.Cue[] music = new Microsoft.Xna.Framework.Audio.Cue[8];
public static float[] musicFade = new float[8];
public static float musicVolume = 0.75f;
public static int myPlayer = 0;
public static int netMode = 0;
public static int netPlayCounter;
public int newMusic;
public static string newWorldName = "";
public const double nightLength = 32400.0;
public static Texture2D ninjaTexture;
public static NPC[] npc = new NPC[0x3e9];
public static bool npcChatFocus1 = false;
public static bool npcChatFocus2 = false;
public static bool npcChatFocus3 = false;
public static bool npcChatRelease = false;
public static string npcChatText = "";
public static int[] npcFrameCount = new int[] {
1, 2, 2, 3, 6, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 0x10, 14, 0x10, 14, 15, 0x10, 2, 10, 1, 0x10, 0x10, 0x10, 3, 1, 15,
3, 1, 3, 1, 1, 0x10, 0x10, 1, 1, 1, 3, 3, 15, 3, 7, 7,
4, 5, 5, 5, 3, 3, 0x10, 6, 3, 6, 6, 2, 5, 3, 2, 7,
7, 4, 2, 8, 1, 5
};
public static int npcShop = 0;
public static Texture2D[] npcTexture = new Texture2D[70];
public const int numArmorBody = 0x11;
public const int numArmorHead = 0x1d;
public const int numArmorLegs = 0x10;
public static int numAvailableRecipes;
//public static int numChatLines = 7;
public static int numClouds = cloudLimit;
private int numDisplayModes;
public static int numDust = 0x3e8;
private static int numLoadPlayers = 0;
private static int numLoadWorlds = 0;
public static int numStars;
private static KeyboardState oldInputText;
public static MouseState oldMouseState = Mouse.GetState();
public static string oldStatusText = "";
public static Player[] player = new Player[0x100];
public static Texture2D playerBeltTexture;
public static Texture2D playerEyesTexture;
public static Texture2D playerEyeWhitesTexture;
public static Texture2D[] playerHairTexture = new Texture2D[0x11];
public static Texture2D playerHands2Texture;
public static Texture2D playerHandsTexture;
public static Texture2D playerHeadTexture;
public static bool playerInventory = false;
public static Texture2D playerPantsTexture;
public static string SavePath = (Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\My Games\Terraria");
public static string PlayerPath = (SavePath + @"\Players");
public static string playerPathName;
public static Texture2D playerShirtTexture;
public static Texture2D playerShoesTexture;
public static Texture2D playerUnderShirt2Texture;
public static Texture2D playerUnderShirtTexture;
public static Projectile[] projectile = new Projectile[0x3e9];
public static Texture2D[] projectileTexture = new Texture2D[0x37];
[ThreadStatic]
public static Random rand;
public static Texture2D raTexture;
public static Recipe[] recipe = new Recipe[Recipe.maxRecipes];
public static bool releaseUI = false;
public static bool resetClouds = true;
public static Texture2D reTexture;
public static double rockLayer;
private static Stopwatch saveTime = new Stopwatch();
public static int saveTimer = 0;
public static int screenHeight = 600;
public static Vector2 screenLastPosition;
public static Vector2 screenPosition;
public static int screenWidth = 800;
public const int sectionHeight = 150;
public const int sectionWidth = 200;
private Color selColor = Color.White;
private int selectedMenu = -1;
private int selectedPlayer;
private int selectedWorld;
public static bool serverStarting = false;
private int setKey = -1;
public Chest[] shop = new Chest[6];
public static bool showFrameRate = false;
public static bool showItemOwner = false;
public static bool showSpam = false;
public static bool showSplash = true;
public static Texture2D shroomCapTexture;
public static Sign[] sign = new Sign[0x3e8];
public static bool signBubble = false;
public static string signText = "";
public static int signX = 0;
public static int signY = 0;
public static bool skipMenu = false;
public static Microsoft.Xna.Framework.Audio.SoundBank soundBank;
public static SoundEffect soundCoins;
public static SoundEffect[] soundDig = new SoundEffect[3];
public static SoundEffect soundDoorClosed;
public static SoundEffect soundDoorOpen;
public static SoundEffect soundDoubleJump;
public static SoundEffect[] soundFemaleHit = new SoundEffect[3];
public static SoundEffect soundGrab;
public static SoundEffect soundGrass;
public static SoundEffectInstance soundInstanceCoins;
public static SoundEffectInstance[] soundInstanceDig = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstanceDoorClosed;
public static SoundEffectInstance soundInstanceDoorOpen;
public static SoundEffectInstance soundInstanceDoubleJump;
public static SoundEffectInstance[] soundInstanceFemaleHit = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstanceGrab;
public static SoundEffectInstance soundInstanceGrass;
public static SoundEffectInstance[] soundInstanceItem = new SoundEffectInstance[0x11];
public static SoundEffectInstance soundInstanceMenuClose;
public static SoundEffectInstance soundInstanceMenuOpen;
public static SoundEffectInstance soundInstanceMenuTick;
public static SoundEffectInstance[] soundInstanceNPCHit = new SoundEffectInstance[4];
public static SoundEffectInstance[] soundInstanceNPCKilled = new SoundEffectInstance[5];
public static SoundEffectInstance[] soundInstancePlayerHit = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstancePlayerKilled;
public static SoundEffectInstance[] soundInstanceRoar = new SoundEffectInstance[2];
public static SoundEffectInstance soundInstanceRun;
public static SoundEffectInstance soundInstanceShatter;
public static SoundEffectInstance[] soundInstanceSplash = new SoundEffectInstance[2];
public static SoundEffectInstance[] soundInstanceTink = new SoundEffectInstance[3];
public static SoundEffectInstance[] soundInstanceZombie = new SoundEffectInstance[3];
public static SoundEffect[] soundItem = new SoundEffect[0x11];
public static SoundEffect soundMenuClose;
public static SoundEffect soundMenuOpen;
public static SoundEffect soundMenuTick;
public static SoundEffect[] soundNPCHit = new SoundEffect[4];
public static SoundEffect[] soundNPCKilled = new SoundEffect[5];
public static SoundEffect[] soundPlayerHit = new SoundEffect[3];
public static SoundEffect soundPlayerKilled;
public static SoundEffect[] soundRoar = new SoundEffect[2];
public static SoundEffect soundRun;
public static SoundEffect soundShatter;
public static SoundEffect[] soundSplash = new SoundEffect[2];
public static SoundEffect[] soundTink = new SoundEffect[3];
public static float soundVolume = 1f;
public static SoundEffect[] soundZombie = new SoundEffect[3];
public static int spamCount = 0;
public static int spawnTileX;
public static int spawnTileY;
private int splashCounter;
public static Texture2D splashTexture;
private SpriteBatch spriteBatch;
public static int stackCounter = 0;
public static int stackDelay = 7;
public static int stackSplit;
public static Star[] star = new Star[130];
public static Texture2D[] starTexture = new Texture2D[5];
public static string statusText = "";
public static bool stopTimeOuts = false;
public static Texture2D sun2Texture;
public static short sunModY = 0;
public static Texture2D sunTexture;
public static Color[] teamColor = new Color[5];
public static int teamCooldown = 0;
public static int teamCooldownLen = 300;
public static Texture2D teamTexture;
public static Texture2D textBackTexture;
private int textBlinkerCount;
private int textBlinkerState;
public static Tile[,] tile = new Tile[maxTilesX, maxTilesY];
//Mod: added extra tiles
public static bool[] tileAlch = new bool[0xff];
public static bool[] tileBlockLight = new bool[0xff];
public static Color tileColor;
public static bool[] tileCut = new bool[0xff];
public static bool[] tileDungeon = new bool[0xff];
public static bool[] tileFrameImportant = new bool[0xff];
public static bool[] tileLavaDeath = new bool[0xff];
public static string[] tileName = new string[0xff];
public static bool[] tileNoAttach = new bool[0xff];
public static bool[] tileNoFail = new bool[0xff];
public static int[] tileShine = new int[0xff];
public static bool tilesLoaded = false;
public static bool[] tileSolid = new bool[0xff];
public static bool[] tileSolidTop = new bool[0xff];
public static bool[] tileStone = new bool[0xff];
public static bool[] tileTable = new bool[0xff];
public static Texture2D[] tileTexture = new Texture2D[0xff];
public static bool[] tileWaterDeath = new bool[0xff];
//EndMod
public static double time = 13500.0;
public static int timeOut = 120;
public bool toggleFullscreen;
private static Item toolTip = new Item();
public static float topWorld = 0f;
public static Texture2D[] treeBranchTexture = new Texture2D[3];
public static Texture2D[] treeTopTexture = new Texture2D[3];
private Process tServer = new Process();
public static int updateTime = 0;
public static bool verboseNetplay = false;
public static string versionNumber = "v1.0.5";
public static string versionNumber2 = "v1.0.5";
public static bool[] wallHouse = new bool[14];
public static Texture2D[] wallTexture = new Texture2D[14];
public static Microsoft.Xna.Framework.Audio.WaveBank waveBank;
public static float windSpeed = 0f;
public static float windSpeedSpeed = 0f;
public static int worldID;
public static string worldName = "";
public static string WorldPath = (SavePath + @"\Worlds");
public static string worldPathName;
public static double worldSurface;
//Mod
public static bool commandInvasion = false;
public static string adminPassword = "1234";
public static int minAddedTiles = 254;
public static int maxAddedTiles = 254;
public static int minAddedItems = 4095;
public static int maxAddedItems = 4095;
public Main()
{
this.graphics = new GraphicsDeviceManager(this);
base.Content.RootDirectory = "Content";
}
public void autoCreate(string newOpt)
{
if (newOpt == "0")
{
autoGen = false;
}
else if (newOpt == "1")
{
maxTilesX = 0x1068;
maxTilesY = 0x4b0;
autoGen = true;
}
else if (newOpt == "2")
{
maxTilesX = 0x189c;
maxTilesY = 0x708;
autoGen = true;
}
else if (newOpt == "3")
{
maxTilesX = 0x20d0;
maxTilesY = 0x960;
autoGen = true;
}
}
public void AutoHost()
{
menuMultiplayer = true;
menuServer = true;
menuMode = 1;
}
public void AutoJoin(string IP)
{
defaultIP = IP;
getIP = IP;
Netplay.SetIP(defaultIP);
autoJoin = true;
}
public void AutoPass()
{
autoPass = true;
}
public void autoShut()
{
autoShutdown = true;
}
public static double CalculateDamage(int Damage, int Defense)
{
double num = Damage - (Defense * 0.5);
if (num < 1.0)
{
num = 1.0;
}
return num;
}
public static void CursorColor()
{
cursorAlpha += cursorColorDirection * 0.015f;
if (cursorAlpha >= 1f)
{
cursorAlpha = 1f;
cursorColorDirection = -1;
}
if (cursorAlpha <= 0.6)
{
cursorAlpha = 0.6f;
cursorColorDirection = 1;
}
float num = (cursorAlpha * 0.3f) + 0.7f;
byte r = (byte) (mouseColor.R * cursorAlpha);
byte g = (byte) (mouseColor.G * cursorAlpha);
byte b = (byte) (mouseColor.B * cursorAlpha);
byte a = (byte) (255f * num);
cursorColor = new Color(r, g, b, a);
cursorScale = ((cursorAlpha * 0.3f) + 0.7f) + 0.1f;
}
public void DedServ()
{
rand = new Random();
if (autoShutdown)
{
string lpWindowName = "terraria" + rand.Next(0x7fffffff);
Console.Title = lpWindowName;
IntPtr hWnd = FindWindow(null, lpWindowName);
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0);
}
}
else
{
Console.Title = "Terraria Server " + versionNumber2;
}
dedServ = true;
showSplash = false;
this.Initialize();
while ((worldPathName == null) || (worldPathName == ""))
{
LoadWorlds();
bool flag = true;
while (flag)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
for (int i = 0; i < numLoadWorlds; i++)
{
Console.WriteLine(string.Concat(new object[] { i + 1, '\t', '\t', loadWorld[i] }));
}
Console.WriteLine(string.Concat(new object[] { "n", '\t', '\t', "New World" }));
Console.WriteLine("d <number>" + '\t' + "Delete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string str2 = Console.ReadLine();
try
{
Console.Clear();
}
catch
{
}
if ((str2.Length >= 2) && (str2.Substring(0, 2).ToLower() == "d "))
{
try
{
int index = Convert.ToInt32(str2.Substring(2)) - 1;
if (index < numLoadWorlds)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("Really delete " + loadWorld[index] + "?");
Console.Write("(y/n): ");
if (Console.ReadLine().ToLower() == "y")
{
EraseWorld(index);
}
}
}
catch
{
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
if ((str2 == "n") || (str2 == "N"))
{
bool flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("1" + '\t' + "Small");
Console.WriteLine("2" + '\t' + "Medium");
Console.WriteLine("3" + '\t' + "Large");
Console.WriteLine("");
Console.Write("Choose size: ");
string str4 = Console.ReadLine();
try
{
switch (Convert.ToInt32(str4))
{
case 1:
maxTilesX = 0x1068;
maxTilesY = 0x4b0;
flag2 = false;
goto Label_034C;
case 2:
maxTilesX = 0x189c;
maxTilesY = 0x708;
flag2 = false;
goto Label_034C;
case 3:
maxTilesX = 0x20d0;
maxTilesY = 0x960;
flag2 = false;
goto Label_034C;
}
}
catch
{
}
Label_034C:
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Enter world name: ");
newWorldName = Console.ReadLine();
if (((newWorldName != "") && (newWorldName != " ")) && (newWorldName != null))
{
flag2 = false;
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
worldName = newWorldName;
worldPathName = nextLoadWorld();
menuMode = 10;
WorldGen.CreateNewWorld();
flag2 = false;
while (menuMode == 10)
{
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
try
{
int num4 = Convert.ToInt32(str2) - 1;
if ((num4 < 0) || (num4 >= numLoadWorlds))
{
continue;
}
bool flag3 = true;
while (flag3)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Max players (press enter for 8): ");
string str5 = Console.ReadLine();
try
{
if (str5 == "")
{
str5 = "8";
}
int num5 = Convert.ToInt32(str5);
if ((num5 <= 0xff) && (num5 >= 1))
{
maxNetPlayers = num5;
maxNetPlayers = 255; //Mod
flag3 = false;
}
flag3 = false;
}
catch
{
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
flag3 = true;
while (flag3)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Server port (press enter for 7777): ");
string str6 = Console.ReadLine();
try
{
if (str6 == "")
{
str6 = "7777";
}
int num6 = Convert.ToInt32(str6);
if (num6 <= 0xffff)
{
Netplay.serverPort = num6;
flag3 = false;
}
}
catch
{
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Server password (press enter for none): ");
Netplay.password = Console.ReadLine();
worldPathName = loadWorldPath[num4];
flag = false;
try
{
Console.Clear();
}
catch
{
}
continue;
}
catch
{
continue;
}
}
}
try
{
Console.Clear();
}
catch
{
}
WorldGen.serverLoadWorld();
Console.WriteLine("Terraria Server " + versionNumber);
Console.WriteLine("");
while (!Netplay.ServerUp)
{
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
}
try
{
Console.Clear();
}
catch
{
}
Console.WriteLine("Terraria Server " + versionNumber);
Console.WriteLine("");
Console.WriteLine("Listening on port " + Netplay.serverPort);
Console.WriteLine("Type 'help' for a list of commands.");
Console.WriteLine("");
Console.Title = "Terraria Server: " + worldName;
Stopwatch stopwatch = new Stopwatch();
if (!autoShutdown)
{
startDedInput();
}
stopwatch.Start();
double num7 = 16.666666666666668;
double num8 = 0.0;
while (!Netplay.disconnect)
{
double elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
if ((elapsedMilliseconds + num8) >= num7)
{
num8 += elapsedMilliseconds - num7;
stopwatch.Reset();
stopwatch.Start();
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
if (num8 > 1000.0)
{
num8 = 1000.0;
}
if (Netplay.anyClients)
{
this.Update(new GameTime());
}
double num10 = stopwatch.ElapsedMilliseconds + num8;
if (num10 < num7)
{
int millisecondsTimeout = ((int) (num7 - num10)) - 1;
if (millisecondsTimeout > 1)
{
Thread.Sleep(millisecondsTimeout);
if (!Netplay.anyClients)
{
num8 = 0.0;
Thread.Sleep(10);
}
}
}
}
Thread.Sleep(0);
}
}
protected override void Draw(GameTime gameTime)
{
if (!dedServ)
{
if (((screenWidth != base.GraphicsDevice.Viewport.Width) || (screenHeight != base.GraphicsDevice.Viewport.Height)) && gamePaused)
{
Lighting.resize = true;
}
screenWidth = base.GraphicsDevice.Viewport.Width;
screenHeight = base.GraphicsDevice.Viewport.Height;
bool flag = false;
if (screenWidth > maxScreenW)
{
screenWidth = maxScreenW;
flag = true;
}
if (screenHeight > maxScreenH)
{
screenHeight = maxScreenH;
flag = true;
}
if (screenWidth < minScreenW)
{
screenWidth = minScreenW;
flag = true;
}
if (screenHeight < minScreenH)
{
screenHeight = minScreenH;
flag = true;
}
if (flag)
{
this.graphics.PreferredBackBufferWidth = screenWidth;
this.graphics.PreferredBackBufferHeight = screenHeight;
this.graphics.ApplyChanges();
}
}
CursorColor();
drawTime++;
screenLastPosition = screenPosition;
if (stackSplit == 0)
{
stackCounter = 0;
stackDelay = 7;
}
else
{
stackCounter++;
if (stackCounter >= 30)
{
stackDelay--;
if (stackDelay < 2)
{
stackDelay = 2;
}
stackCounter = 0;
}
}
mouseTextColor = (byte) (mouseTextColor + ((byte) mouseTextColorChange));
if (mouseTextColor >= 250)
{
mouseTextColorChange = -4;
}
if (mouseTextColor <= 0xaf)
{
mouseTextColorChange = 4;
}
if (myPlayer >= 0)
{
player[myPlayer].mouseInterface = false;
}
toolTip = new Item();
if (!gameMenu && (netMode != 2))
{
int x = mouseState.X;
int y = mouseState.Y;
if (x < 0)
{
x = 0;
}
if (x > screenWidth)
{
x = screenWidth;
}
if (y < 0)
{
y = 0;
}
if (y > screenHeight)
{
y = screenHeight;
}
screenPosition.X = (player[myPlayer].position.X + (player[myPlayer].width * 0.5f)) - (screenWidth * 0.5f);
screenPosition.Y = (player[myPlayer].position.Y + (player[myPlayer].height * 0.5f)) - (screenHeight * 0.5f);
screenPosition.X = (int) screenPosition.X;
screenPosition.Y = (int) screenPosition.Y;
}
if (!gameMenu && (netMode != 2))
{
if (screenPosition.X < ((leftWorld + 336f) + 16f))
{
screenPosition.X = (leftWorld + 336f) + 16f;
}
else if ((screenPosition.X + screenWidth) > ((rightWorld - 336f) - 32f))
{
screenPosition.X = ((rightWorld - screenWidth) - 336f) - 32f;
}
if (screenPosition.Y < ((topWorld + 336f) + 16f))
{
screenPosition.Y = (topWorld + 336f) + 16f;
}
else if ((screenPosition.Y + screenHeight) > ((bottomWorld - 336f) - 32f))
{
screenPosition.Y = ((bottomWorld - screenHeight) - 336f) - 32f;
}
}
if (showSplash)
{
this.DrawSplash(gameTime);
}
else