Merge pull request #435 from k0rd/noclip-devel

Workaround for buggy noclip detection in water
This commit is contained in:
Lucas Nicodemus 2012-03-14 21:03:41 -07:00
commit c474dca304
2 changed files with 19 additions and 2 deletions

View file

@ -52,7 +52,14 @@ namespace TShockAPI.DB
{ {
if (reader.Read()) if (reader.Read())
{ {
return new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")); int checkX=reader.Get<int>("X");
int checkY=reader.Get<int>("Y");
//fix leftover inconsistancies
if (checkX==0)
checkX++;
if (checkY==0)
checkY++;
return new Vector2(checkX, checkY);
} }
} }
} }
@ -92,6 +99,7 @@ namespace TShockAPI.DB
{ {
try try
{ {
if ((X != 0) && ( Y !=0)) //invalid pos!
database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, Y , Main.worldID.ToString()); database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, Y , Main.worldID.ToString());
} }
catch (Exception ex) catch (Exception ex)
@ -103,6 +111,7 @@ namespace TShockAPI.DB
{ {
try try
{ {
if ((X != 0) && ( Y !=0)) //invalid pos!
database.Query("UPDATE RememberedPos SET X = @0, Y = @1, IP = @2 WHERE Name = @3 AND WorldID = @4;", X, Y, IP, name, Main.worldID.ToString()); database.Query("UPDATE RememberedPos SET X = @0, Y = @1, IP = @2 WHERE Name = @3 AND WorldID = @4;", X, Y, IP, name, Main.worldID.ToString());
} }
catch (Exception ex) catch (Exception ex)

View file

@ -472,11 +472,19 @@ namespace TShockAPI
{ {
num4 = Main.maxTilesY; num4 = Main.maxTilesY;
} }
for (int c = num; c < num2; c++)
{
for (int d = num3; d< num4; d++)
{
if (Main.tile[c,d].liquid != 0)
return false;
}
}
for (int i = num; i < num2; i++) for (int i = num; i < num2; i++)
{ {
for (int j = num3; j < num4; j++) for (int j = num3; j < num4; j++)
{ {
if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && ((Main.tile[i,j].liquid == 0 )&& !Main.tile[i,j].lava)) if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type] &&(((int)Main.tile[i,j].type !=53) && ((int)Main.tile[i,j].type !=112) && ((int)Main.tile[i,j].type !=116) && ((int)Main.tile[i,j].type !=123)) && !Main.tile[i,j].lava)
{ {
Vector2 vector; Vector2 vector;
vector.X = (float)(i * 16); vector.X = (float)(i * 16);