Fixes #1169 on MySQL

This commit is contained in:
White 2016-04-02 11:04:37 +10:30
parent 02e317436e
commit 8bf58dedf4

View file

@ -140,11 +140,18 @@ namespace TShockAPI.DB
"INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner, Z) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10);", "INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner, Z) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10);",
tx, ty, width, height, regionname, worldid, "", 1, "", owner, z); tx, ty, width, height, regionname, worldid, "", 1, "", owner, z);
int id; int id;
using (QueryResult res = database.QueryReader("SELECT Id FROM Regions WHERE RegionName = '@0' AND WorldID = '@1'", regionname, worldid)) using (QueryResult res = database.QueryReader("SELECT Id FROM Regions WHERE RegionName = @0 AND WorldID = @1", regionname, worldid))
{ {
id = res.Get<int>("Id"); if (res.Read())
{
id = res.Get<int>("Id");
}
else
{
return false;
}
} }
var region = new Region(id, new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z); Region region = new Region(id, new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z);
Regions.Add(region); Regions.Add(region);
Hooks.RegionHooks.OnRegionCreated(region); Hooks.RegionHooks.OnRegionCreated(region);
return true; return true;