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
|
||||
*.o
|
||||
*.so
|
||||
/bin/*
|
||||
/obj/*
|
||||
*/bin/*
|
||||
*/obj/*
|
||||
bin/*
|
||||
obj/*
|
||||
|
||||
# Packages #
|
||||
############
|
||||
|
|
@ -41,7 +43,17 @@ Thumbs.db
|
|||
*.suo
|
||||
*.sdf
|
||||
*.opensdf
|
||||
<<<<<<< HEAD
|
||||
*.csproj.user
|
||||
=======
|
||||
>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f
|
||||
*.cache
|
||||
*.txt
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
*.pdb
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> ef60c83b40be0a7948d3cb0381cc6e4526a9b2d6
|
||||
=======
|
||||
*.csproj.user
|
||||
>>>>>>> 3ccdba9f51710ccb56e021dd10e53eea3614f21f
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ namespace TShockAPI
|
|||
{
|
||||
public class TShock : TerrariaPlugin
|
||||
{
|
||||
private uint[] tileThreshold = new uint[Main.maxPlayers];
|
||||
|
||||
public static string saveDir = "./tshock/";
|
||||
private static double version = 3;
|
||||
private static bool shownVersion = false;
|
||||
|
||||
public static bool killGuide = true;
|
||||
public static int invasionMultiplier = 1;
|
||||
|
|
@ -56,19 +56,46 @@ namespace TShockAPI
|
|||
|
||||
public TShock(Main game) : base (game)
|
||||
{
|
||||
GameHooks.OnPreInitialize += OnPreInit;
|
||||
GameHooks.OnPostInitialize += OnPostInit;
|
||||
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
||||
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
||||
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
||||
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
|
||||
NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer);
|
||||
GameHooks.OnPreInitialize += OnPreInit;
|
||||
GameHooks.OnPostInitialize += OnPostInit;
|
||||
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
||||
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
||||
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
||||
NetHooks.OnPreGetData += GetData;
|
||||
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
|
||||
NetHooks.OnGreetPlayer += new NetHooks.GreetPlayerD(OnGreetPlayer);
|
||||
NetHooks.OnPreGetData += new NetHooks.GetDataD(OnPreGetData);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
int plr = who; //legacy support
|
||||
|
|
@ -144,7 +171,22 @@ namespace TShockAPI
|
|||
|
||||
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 ip = GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
|
||||
|
||||
WriteGrief(ply);
|
||||
WriteCheater(ply);
|
||||
if (!kickCheater) { return; }
|
||||
Netplay.serverSock[ply].kill = true;
|
||||
|
|
@ -451,7 +494,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
public static T Clamp<T>(T value, T max, T min)
|
||||
where T : System.IComparable<T>
|
||||
where T : System.IComparable<T>
|
||||
{
|
||||
T result = value;
|
||||
if (value.CompareTo(max) > 0)
|
||||
|
|
@ -477,7 +520,7 @@ namespace TShockAPI
|
|||
private static string GetPlayers()
|
||||
{
|
||||
string str = "";
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < Main.maxPlayers; i++)
|
||||
{
|
||||
if (Main.player[i].active)
|
||||
{
|
||||
|
|
@ -493,6 +536,5 @@ namespace TShockAPI
|
|||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\..\Program Files %28x86%29\Steam\steamapps\common\terraria\plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -30,7 +30,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>lbolt.ico</ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue