Made functions uppercase, like all of terraria's functions, to keep it consistent

This commit is contained in:
Maverick Motherfucker 2011-05-29 19:24:57 -07:00
parent e599e985b3
commit 5e91f13916
6 changed files with 115 additions and 115 deletions

View file

@ -37,11 +37,11 @@ namespace Terraria
SKELETRON=2
}
public static void showUpdateMinder(int ply)
public static void ShowUpdateReminder(int ply)
{
if (!shownVersion)
{
if (isAdmin(findPlayer(ply)))
if (IsAdmin(FindPlayer(ply)))
{
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)");
@ -52,10 +52,10 @@ namespace Terraria
float[] color = { 255, 255, 000 };
if (Convert.ToDouble(changes[0]) > version)
{
sendMessage(ply, "This server is out of date. Version " + changes[0] + " is out.", color);
SendMessage(ply, "This server is out of date. Version " + changes[0] + " is out.", color);
for (int i = 1; i <= changes.Length; i++)
{
sendMessage(ply, changes[i], color);
SendMessage(ply, changes[i], color);
}
}
}
@ -68,7 +68,7 @@ namespace Terraria
}
}
public static void incrementKills()
public static void IncrementKills()
{
killCount++;
Random r = new Random();
@ -78,35 +78,35 @@ namespace Terraria
switch (random)
{
case 0:
ShankShock.broadcast("You call that a lot? " + killCount + " goblins killed!");
ShankShock.Broadcast("You call that a lot? " + killCount + " goblins killed!");
break;
case 1:
ShankShock.broadcast("Fatality! " + killCount + " goblins killed!");
ShankShock.Broadcast("Fatality! " + killCount + " goblins killed!");
break;
case 2:
ShankShock.broadcast("Number of 'noobs' killed to date: " + killCount);
ShankShock.Broadcast("Number of 'noobs' killed to date: " + killCount);
break;
case 3:
ShankShock.broadcast("Duke Nukem would be proud. " + killCount + " goblins killed.");
ShankShock.Broadcast("Duke Nukem would be proud. " + killCount + " goblins killed.");
break;
case 4:
ShankShock.broadcast("You call that a lot? " + killCount + " goblins killed!");
ShankShock.Broadcast("You call that a lot? " + killCount + " goblins killed!");
break;
case 5:
ShankShock.broadcast(killCount + " copies of Call of Duty smashed.");
ShankShock.Broadcast(killCount + " copies of Call of Duty smashed.");
break;
}
}
}
public static bool onWhitelist(string ip)
public static bool OnWhitelist(string ip)
{
if (!enableWhitelist) { return true; }
if (!System.IO.File.Exists(saveDir +"whitelist.txt")) { createFile(saveDir + "whitelist.txt"); TextWriter tw = new StreamWriter(saveDir + "whitelist.txt"); tw.WriteLine("127.0.0.1"); tw.Close(); }
if (!System.IO.File.Exists(saveDir +"whitelist.txt")) { CreateFile(saveDir + "whitelist.txt"); TextWriter tw = new StreamWriter(saveDir + "whitelist.txt"); tw.WriteLine("127.0.0.1"); tw.Close(); }
TextReader tr = new StreamReader(saveDir + "whitelist.txt");
string whitelist = tr.ReadToEnd();
ip = getRealIP(ip);
ip = GetRealIP(ip);
if (whitelist.Contains(ip)) { return true; } else { return false; }
}
@ -135,7 +135,7 @@ namespace Terraria
}
private static string getPlayers()
private static string GetPlayers()
{
string str = "";
for (int i = 0; i < 8; i++)
@ -155,14 +155,14 @@ namespace Terraria
return str;
}
public static void showmotd(int ply)
public static void ShowMOTD(int ply)
{
string foo = "";
TextReader tr = new StreamReader(saveDir + "motd.txt");
while ((foo = tr.ReadLine()) != null)
{
foo = foo.Replace("%map%", Main.worldName);
foo = foo.Replace("%players%", getPlayers());
foo = foo.Replace("%players%", GetPlayers());
if (foo.Substring(0, 1) == "%" && foo.Substring(12, 1) == "%") //Look for a beginning color code.
{
string possibleColor = foo.Substring(0, 13);
@ -177,7 +177,7 @@ namespace Terraria
pC[0] = Clamp(Convert.ToInt32(pCc[0]), 255, 0);
pC[1] = Clamp(Convert.ToInt32(pCc[1]), 255, 0);
pC[2] = Clamp(Convert.ToInt32(pCc[2]), 255, 0);
sendMessage(ply, foo, pC);
SendMessage(ply, foo, pC);
continue;
}
catch (Exception e)
@ -186,7 +186,7 @@ namespace Terraria
}
}
}
sendMessage(ply, foo);
SendMessage(ply, foo);
}
tr.Close();
}
@ -202,12 +202,12 @@ namespace Terraria
return result;
}
private static void createFile(string file)
private static void CreateFile(string file)
{
using (FileStream fs = File.Create(file)) { }
}
private static void keepTilesUpToDate()
private static void KeepTilesUpToDate()
{
TextReader tr = new StreamReader(saveDir + "tiles.txt");
string file = tr.ReadToEnd();
@ -215,42 +215,42 @@ namespace Terraria
if (!file.Contains("0x3d"))
{
System.IO.File.Delete(saveDir + "tiles.txt");
createFile(saveDir + "tiles.txt");
CreateFile(saveDir + "tiles.txt");
TextWriter tw = new StreamWriter(saveDir + "tiles.txt");
tw.Write("0x03, 0x05, 0x14, 0x25, 0x18, 0x18, 0x20, 0x1b, 0x34, 0x48, 0x33, 0x3d, 0x47, 0x49, 0x4a, 0x35, 0x3d, 0x3e, 0x45, 0x47, 0x49, 0x4a,");
tw.Close();
}
}
public static void setupConfiguration()
public static void SetupConfig()
{
if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); }
if (!System.IO.File.Exists(saveDir + "tiles.txt"))
{
createFile(saveDir + "tiles.txt");
CreateFile(saveDir + "tiles.txt");
TextWriter tw = new StreamWriter(saveDir + "tiles.txt");
tw.Write("0x03, 0x05, 0x14, 0x25, 0x18, 0x18, 0x20, 0x1b, 0x34, 0x48, 0x33, 0x3d, 0x47, 0x49, 0x4a, 0x35, 0x3d, 0x3e, 0x45, 0x47, 0x49, 0x4a,");
tw.Close();
}
if (!System.IO.File.Exists(saveDir + "motd.txt")) {
createFile(saveDir + "motd.txt");
CreateFile(saveDir + "motd.txt");
TextWriter tw = new StreamWriter(saveDir + "motd.txt");
tw.WriteLine("This server is running TShock. Type /help for a list of commands.");
tw.WriteLine("%255,000,000%Current map: %map%");
tw.WriteLine("Current players: %players%");
tw.Close(); }
if (!System.IO.File.Exists(saveDir +"bans.txt")) { createFile(saveDir + "bans.txt"); }
if (!System.IO.File.Exists(saveDir +"cheaters.txt")) { createFile(saveDir + "cheaters.txt"); }
if (!System.IO.File.Exists(saveDir +"admins.txt")) { createFile(saveDir + "admins.txt"); }
if (!System.IO.File.Exists(saveDir +"grief.txt")) { createFile(saveDir + "grief.txt"); }
if (!System.IO.File.Exists(saveDir +"bans.txt")) { CreateFile(saveDir + "bans.txt"); }
if (!System.IO.File.Exists(saveDir +"cheaters.txt")) { CreateFile(saveDir + "cheaters.txt"); }
if (!System.IO.File.Exists(saveDir +"admins.txt")) { CreateFile(saveDir + "admins.txt"); }
if (!System.IO.File.Exists(saveDir +"grief.txt")) { CreateFile(saveDir + "grief.txt"); }
if (!System.IO.File.Exists(saveDir +"config.txt"))
{
createFile(saveDir + "config.txt");
CreateFile(saveDir + "config.txt");
TextWriter tw = new StreamWriter(saveDir + "config.txt");
tw.WriteLine("true,50,4,700,true,true,7777,false,false,false,false,false");
tw.Close();
}
keepTilesUpToDate();
KeepTilesUpToDate();
TextReader tr = new StreamReader(saveDir + "config.txt");
string config = tr.ReadToEnd();
config = config.Replace("\n", "");
@ -285,7 +285,7 @@ namespace Terraria
Netplay.serverPort = serverPort;
}
public static bool tileOnWhitelist(byte tile)
public static bool TileOnWhitelist(byte tile)
{
int _tile = (int)tile;
TextReader tr2 = new StreamReader(saveDir + "tiles.txt");
@ -299,23 +299,23 @@ namespace Terraria
return tileWhitelist.Contains(hexValue);
}
public static void setupJsonConfiguration()
public static void SetupJsonConfig()
{
throw new NotImplementedException();
}
public static void handleGrief(int ply)
public static void HandleGrief(int ply)
{
if (banTnt) { _writeGrief(ply); }
ShankShock.broadcast(findPlayer(ply) + " was " + (banTnt ? "banned " : "kicked ") + "for kill tile abuse.");
if (kickTnt) { kick(ply); }
ShankShock.Broadcast(FindPlayer(ply) + " was " + (banTnt ? "banned " : "kicked ") + "for kill tile abuse.");
if (kickTnt) { Kick(ply); }
}
private static void _writeGrief(int ply)
{
TextWriter tw = new StreamWriter(saveDir + "grief.txt", true);
tw.WriteLine("[" + Main.player[ply].name + "] [" + getRealIP(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint.ToString()) + "]");
tw.WriteLine("[" + Main.player[ply].name + "] [" + GetRealIP(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint.ToString()) + "]");
tw.Close();
}
@ -329,7 +329,7 @@ namespace Terraria
}
else
{
createFile(saveDir + "errors.txt");
CreateFile(saveDir + "errors.txt");
TextWriter tw = new StreamWriter(saveDir + "errors.txt", true);
tw.WriteLine(err);
tw.Close();
@ -338,7 +338,7 @@ namespace Terraria
public static void _writeban(int ply)
{
string ip = ShankShock.getRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
string ip = ShankShock.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
TextWriter tw = new StreamWriter(saveDir + "bans.txt", true);
tw.WriteLine("[" + Main.player[ply].name + "] " + "[" + ip + "]");
tw.Close();
@ -346,7 +346,7 @@ namespace Terraria
public static void _writecheater(int ply)
{
string ip = ShankShock.getRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
string ip = ShankShock.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
string cheaters = "";
TextReader tr = new StreamReader(saveDir + "cheaters.txt");
cheaters = tr.ReadToEnd();
@ -357,30 +357,30 @@ namespace Terraria
sw.Close();
}
public static void kick(int ply)
public static void Kick(int ply)
{
Netplay.serverSock[ply].kill = true;
Netplay.serverSock[ply].Reset();
NetMessage.syncPlayers();
}
public static void handleCheater(int ply)
public static void HandleCheater(int ply)
{
string cheater = ShankShock.findPlayer(ply);
string ip = ShankShock.getRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
string cheater = ShankShock.FindPlayer(ply);
string ip = ShankShock.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
_writecheater(ply);
if (!kickCheater) { return; }
Netplay.serverSock[ply].kill = true;
Netplay.serverSock[ply].Reset();
NetMessage.syncPlayers();
ShankShock.broadcast(cheater + " was " + (banCheater ? "banned " : "kicked ") + "for cheating.");
ShankShock.Broadcast(cheater + " was " + (banCheater ? "banned " : "kicked ") + "for cheating.");
}
public static bool checkGrief(String ip)
public static bool CheckGreif(String ip)
{
ip = getRealIP(ip);
ip = GetRealIP(ip);
if (!banTnt) { return false; }
TextReader tr = new StreamReader(saveDir + "grief.txt");
string list = tr.ReadToEnd();
@ -389,9 +389,9 @@ namespace Terraria
return list.Contains(ip);
}
public static bool checkCheat(String ip)
public static bool CheckCheat(String ip)
{
ip = getRealIP(ip);
ip = GetRealIP(ip);
if (!banCheater) { return false; }
TextReader tr = new StreamReader(saveDir + "cheaters.txt");
string trr = tr.ReadToEnd();
@ -402,7 +402,7 @@ namespace Terraria
return false;
}
public static bool checkBanned(String p)
public static bool CheckBanned(String p)
{
String ip = p.Split(':')[0];
TextReader tr = new StreamReader(saveDir + "bans.txt");
@ -414,17 +414,17 @@ namespace Terraria
return false;
}
public static void sendMessage(int ply, string msg, float[] color)
public static void SendMessage(int ply, string msg, float[] color)
{
NetMessage.SendData(0x19, ply, -1, msg, 8, color[0], color[1], color[2]);
}
public static void sendMessage(int ply, string message)
public static void SendMessage(int ply, string message)
{
NetMessage.SendData(0x19, ply, -1, message, 8, 0f, 255f, 0f);
}
public static int findPlayer(string ply)
public static int FindPlayer(string ply)
{
int pl = -1;
for (int i = 0; i < Main.player.Length; i++)
@ -438,7 +438,7 @@ namespace Terraria
return pl;
}
public static string findPlayer(int ply)
public static string FindPlayer(int ply)
{
for (int i = 0; i < Main.player.Length; i++)
{
@ -450,17 +450,17 @@ namespace Terraria
return "null";
}
public static void broadcast(string msg)
public static void Broadcast(string msg)
{
for (int i = 0; i < Main.player.Length; i++)
{
sendMessage(i, msg);
SendMessage(i, msg);
}
}
public static bool isAdmin(string ply)
public static bool IsAdmin(string ply)
{
string remoteEndPoint = Convert.ToString((Netplay.serverSock[ShankShock.findPlayer(ply)].tcpClient.Client.RemoteEndPoint));
string remoteEndPoint = Convert.ToString((Netplay.serverSock[ShankShock.FindPlayer(ply)].tcpClient.Client.RemoteEndPoint));
string[] remoteEndPointIP = remoteEndPoint.Split(':');
TextReader tr = new StreamReader(saveDir + "admins.txt");
string adminlist = tr.ReadToEnd();
@ -472,7 +472,7 @@ namespace Terraria
return false;
}
public static string getRealIP(string mess)
public static string GetRealIP(string mess)
{
return mess.Split(':')[0];
}