Merge branch 'api' of git.assembla.com:terraria into api
Conflicts: TShockAPI/TShock.cs
This commit is contained in:
commit
338997739b
5 changed files with 72 additions and 17 deletions
16
.gitignore
vendored
16
.gitignore
vendored
|
|
@ -6,8 +6,10 @@
|
||||||
*.exe
|
*.exe
|
||||||
*.o
|
*.o
|
||||||
*.so
|
*.so
|
||||||
/bin/*
|
*/bin/*
|
||||||
/obj/*
|
*/obj/*
|
||||||
|
bin/*
|
||||||
|
obj/*
|
||||||
|
|
||||||
# Packages #
|
# Packages #
|
||||||
############
|
############
|
||||||
|
|
@ -41,7 +43,17 @@ Thumbs.db
|
||||||
*.suo
|
*.suo
|
||||||
*.sdf
|
*.sdf
|
||||||
*.opensdf
|
*.opensdf
|
||||||
|
<<<<<<< HEAD
|
||||||
|
*.csproj.user
|
||||||
|
=======
|
||||||
|
>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f
|
||||||
*.cache
|
*.cache
|
||||||
*.txt
|
*.txt
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
*.pdb
|
*.pdb
|
||||||
|
<<<<<<< HEAD
|
||||||
|
>>>>>>> ef60c83b40be0a7948d3cb0381cc6e4526a9b2d6
|
||||||
|
=======
|
||||||
*.csproj.user
|
*.csproj.user
|
||||||
|
>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
public class TShock : TerrariaPlugin
|
public class TShock : TerrariaPlugin
|
||||||
{
|
{
|
||||||
|
private uint[] tileThreshold = new uint[Main.maxPlayers];
|
||||||
|
|
||||||
public static string saveDir = "./tshock/";
|
public static string saveDir = "./tshock/";
|
||||||
private static double version = 3;
|
|
||||||
private static bool shownVersion = false;
|
|
||||||
|
|
||||||
public static bool killGuide = true;
|
public static bool killGuide = true;
|
||||||
public static int invasionMultiplier = 1;
|
public static int invasionMultiplier = 1;
|
||||||
|
|
@ -56,19 +56,46 @@ namespace TShockAPI
|
||||||
|
|
||||||
public TShock(Main game) : base (game)
|
public TShock(Main game) : base (game)
|
||||||
{
|
{
|
||||||
GameHooks.OnPreInitialize += OnPreInit;
|
GameHooks.OnPreInitialize += OnPreInit;
|
||||||
GameHooks.OnPostInitialize += OnPostInit;
|
GameHooks.OnPostInitialize += OnPostInit;
|
||||||
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
||||||
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
||||||
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
||||||
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
|
NetHooks.OnPreGetData += GetData;
|
||||||
NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer);
|
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
|
||||||
|
NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer);
|
||||||
|
NetHooks.OnPreGetData += new NetHooks.GetDataD(OnPreGetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hooks:
|
* Hooks:
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e)
|
||||||
|
{
|
||||||
|
if (id == 0x1e && permaPvp)
|
||||||
|
{
|
||||||
|
e.Handled = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e)
|
||||||
|
{
|
||||||
|
int n = 5;
|
||||||
|
byte[] buf = msg.readBuffer;
|
||||||
|
if (id == 17)
|
||||||
|
{
|
||||||
|
byte type = buf[n];
|
||||||
|
n++;
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
tileThreshold[msg.whoAmI]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void OnGreetPlayer(int who, HandledEventArgs e)
|
void OnGreetPlayer(int who, HandledEventArgs e)
|
||||||
{
|
{
|
||||||
int plr = who; //legacy support
|
int plr = who; //legacy support
|
||||||
|
|
@ -144,7 +171,22 @@ namespace TShockAPI
|
||||||
|
|
||||||
void OnUpdate(GameTime time)
|
void OnUpdate(GameTime time)
|
||||||
{
|
{
|
||||||
|
for (uint i = 0; i < Main.maxPlayers; i++)
|
||||||
|
{
|
||||||
|
if (tileThreshold[i] >= 5)
|
||||||
|
{
|
||||||
|
if (Main.player[i] != null)
|
||||||
|
{
|
||||||
|
WriteGrief((int)i);
|
||||||
|
Kick((int)i, "Fuck you bomb spam or some other fucking shit");
|
||||||
|
}
|
||||||
|
tileThreshold[i] = 0;
|
||||||
|
}
|
||||||
|
else if (tileThreshold[i] > 0)
|
||||||
|
{
|
||||||
|
tileThreshold[i]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -333,6 +375,7 @@ namespace TShockAPI
|
||||||
string cheater = FindPlayer(ply);
|
string cheater = FindPlayer(ply);
|
||||||
string ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
|
string ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
|
||||||
|
|
||||||
|
WriteGrief(ply);
|
||||||
WriteCheater(ply);
|
WriteCheater(ply);
|
||||||
if (!kickCheater) { return; }
|
if (!kickCheater) { return; }
|
||||||
Netplay.serverSock[ply].kill = true;
|
Netplay.serverSock[ply].kill = true;
|
||||||
|
|
@ -451,7 +494,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Clamp<T>(T value, T max, T min)
|
public static T Clamp<T>(T value, T max, T min)
|
||||||
where T : System.IComparable<T>
|
where T : System.IComparable<T>
|
||||||
{
|
{
|
||||||
T result = value;
|
T result = value;
|
||||||
if (value.CompareTo(max) > 0)
|
if (value.CompareTo(max) > 0)
|
||||||
|
|
@ -477,7 +520,7 @@ namespace TShockAPI
|
||||||
private static string GetPlayers()
|
private static string GetPlayers()
|
||||||
{
|
{
|
||||||
string str = "";
|
string str = "";
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < Main.maxPlayers; i++)
|
||||||
{
|
{
|
||||||
if (Main.player[i].active)
|
if (Main.player[i].active)
|
||||||
{
|
{
|
||||||
|
|
@ -493,6 +536,5 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>..\..\Program Files %28x86%29\Steam\steamapps\common\terraria\plugins\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -30,7 +30,8 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationIcon>lbolt.ico</ApplicationIcon>
|
<ApplicationIcon>
|
||||||
|
</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue