Merge branch 'master' of git.assembla.com:terraria

Conflicts:
	TShockAPI/TShock.cs
This commit is contained in:
high 2011-06-01 04:07:27 -04:00
commit da882cc9db

View file

@ -1,10 +1,17 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; using System.IO;
using System.Net; using System.Net;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Terraria; using Terraria;
using TerrariaAPI; using TerrariaAPI;
using TerrariaAPI.Hooks; using TerrariaAPI.Hooks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Net;
using TShockAPI;
namespace TShockAPI namespace TShockAPI
{ {
@ -45,6 +52,7 @@ namespace TShockAPI
get { return "The administration modification of the future."; } get { return "The administration modification of the future."; }
} }
public TShock(Main game) : base (game)
public TShock(Main game) public TShock(Main game)
: base(game) : base(game)
{ {
@ -80,6 +88,7 @@ namespace TShockAPI
* Hooks: * Hooks:
* */ * */
void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e) private void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
{ {
if (ConfigurationManager.infiniteInvasion) if (ConfigurationManager.infiniteInvasion)
@ -92,6 +101,7 @@ namespace TShockAPI
} }
} }
void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e)
private void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e) private void OnPreGetData(byte id, messageBuffer msg, int idx, int length, HandledEventArgs e)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
@ -101,6 +111,7 @@ namespace TShockAPI
} }
} }
void GetData(GetDataEventArgs e)
private void GetData(GetDataEventArgs e) private void GetData(GetDataEventArgs e)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
@ -129,6 +140,7 @@ namespace TShockAPI
} }
} }
void OnGreetPlayer(int who, HandledEventArgs e)
private void OnGreetPlayer(int who, HandledEventArgs e) private void OnGreetPlayer(int who, HandledEventArgs e)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
@ -151,9 +163,12 @@ namespace TShockAPI
e.Handled = true; e.Handled = true;
} }
void OnChat(int ply, string msg, HandledEventArgs handler)
private void OnChat(int ply, string msg, HandledEventArgs handler) private void OnChat(int ply, string msg, HandledEventArgs handler)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
int x = (int) Main.player[ply].position.X;
int y = (int) Main.player[ply].position.Y;
int x = (int)Main.player[ply].position.X; int x = (int)Main.player[ply].position.X;
int y = (int)Main.player[ply].position.Y; int y = (int)Main.player[ply].position.Y;
@ -226,6 +241,7 @@ namespace TShockAPI
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers(); NetMessage.syncPlayers();
handler.Handled = true; handler.Handled = true;
handler.Handled = true;
} }
if (msg == "/eater") if (msg == "/eater")
{ {
@ -282,6 +298,7 @@ namespace TShockAPI
if (msg.Length > 3 && msg.Substring(0, 3) == "/tp") if (msg.Length > 3 && msg.Substring(0, 3) == "/tp")
{ {
string player = msg.Remove(0, 3).Trim(); string player = msg.Remove(0, 3).Trim();
if (!(Tools.FindPlayer(player) == -1) && !(player == ""))
if (Tools.FindPlayer(player) != -1 && player != "") if (Tools.FindPlayer(player) != -1 && player != "")
{ {
Teleport(ply, Main.player[Tools.FindPlayer(player)].position.X, Main.player[Tools.FindPlayer(player)].position.Y); Teleport(ply, Main.player[Tools.FindPlayer(player)].position.X, Main.player[Tools.FindPlayer(player)].position.Y);
@ -292,6 +309,7 @@ namespace TShockAPI
if (msg.Length > 7 && msg.Substring(0, 7) == "/tphere") if (msg.Length > 7 && msg.Substring(0, 7) == "/tphere")
{ {
string player = msg.Remove(0, 7).Trim(); string player = msg.Remove(0, 7).Trim();
if (!(Tools.FindPlayer(player) == -1) && !(player == ""))
if (Tools.FindPlayer(player) != -1 && player != "") if (Tools.FindPlayer(player) != -1 && player != "")
{ {
Teleport(Tools.FindPlayer(player), Main.player[ply].position.X, Main.player[ply].position.Y); Teleport(Tools.FindPlayer(player), Main.player[ply].position.X, Main.player[ply].position.Y);
@ -300,6 +318,20 @@ namespace TShockAPI
handler.Handled = true; handler.Handled = true;
} }
} }
if (msg.Length > 9 && msg.Substring(0,9) == "/spawnmob")
{
string args = msg.Remove(0, 9).Trim();
int type = 0;
if (int.TryParse(args, out type))
{
if (type >= 1 && type <= 43)
{
var npcid = NPC.NewNPC(x, y, type, 0);
Tools.Broadcast("NPC " + type.ToString() + " spawned with ID " + npcid.ToString());
handler.Handled = true;
}
}
}
} }
if (msg == "/help") if (msg == "/help")
{ {
@ -312,6 +344,8 @@ namespace TShockAPI
} }
} }
void OnJoin(int ply, AllowEventArgs handler)
private void OnJoin(int ply, AllowEventArgs handler) private void OnJoin(int ply, AllowEventArgs handler)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
@ -326,19 +360,24 @@ namespace TShockAPI
} }
} }
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
private void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj) private void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
{ {
} }
void OnPreInit()
private void OnPreInit() private void OnPreInit()
{ {
FileTools.SetupConfig(); FileTools.SetupConfig();
} }
void OnPostInit()
private void OnPostInit() private void OnPostInit()
{ {
} }
void OnUpdate(GameTime time)
private void OnUpdate(GameTime time) private void OnUpdate(GameTime time)
{ {
if (Main.netMode != 2) { return; } if (Main.netMode != 2) { return; }
@ -396,8 +435,22 @@ namespace TShockAPI
} }
} }
public static void Teleport(int ply, int x, int y)
{
Main.player[ply].velocity = new Vector2(0, 0);
NetMessage.SendData(0x0d, -1, -1, "", ply);
Main.player[ply].position.X = x;
Main.player[ply].position.Y = y - 0x2a;
NetMessage.SendData(0x0d, -1, -1, "", ply);
}
public static void Teleport(int ply, float x, float y) public static void Teleport(int ply, float x, float y)
{ {
Main.player[ply].position.X = x;
Main.player[ply].position.Y = y - 0x2a;
NetMessage.SendData(0x0d, -1, -1, "", ply);
int oldx = Main.player[ply].SpawnX; int oldx = Main.player[ply].SpawnX;
int oldy = Main.player[ply].SpawnY; int oldy = Main.player[ply].SpawnY;
Main.player[ply].SpawnX = (int)(x / 16); Main.player[ply].SpawnX = (int)(x / 16);
@ -458,6 +511,7 @@ namespace TShockAPI
Tools.Broadcast(ConfigurationManager.killCount + " copies of Call of Duty smashed."); Tools.Broadcast(ConfigurationManager.killCount + " copies of Call of Duty smashed.");
break; break;
} }
} }
} }
} }