mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Do a Database.TableExists check when deleting and renaming level portals/mbs/zone tables.
This commit is contained in:
parent
5ace7cd08c
commit
6e1dcc72f1
@ -57,19 +57,18 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
//safe against SQL injections because foundLevel is being checked and,
|
//safe against SQL injections because foundLevel is being checked and,
|
||||||
//newName is being split and partly checked on illegal characters reserved for Windows.
|
//newName is being split and partly checked on illegal characters reserved for Windows.
|
||||||
if (Server.useMySQL)
|
string syntax = Server.useMySQL
|
||||||
Database.Execute(String.Format("RENAME TABLE `Block{0}` TO `Block{1}`, " +
|
? "RENAME TABLE `{2}{0}` TO `{2}{1}`" : "ALTER TABLE `{2}{0}` RENAME TO `{2}{1}`";
|
||||||
"`Portals{0}` TO `Portals{1}`, " +
|
Database.Execute(String.Format(syntax, src, dst, "Blocks"));
|
||||||
"`Messages{0}` TO `Messages{1}`, " +
|
|
||||||
"`Zone{0}` TO `Zone{1}`", src, dst));
|
object locker = ThreadSafeCache.DBCache.Get(src);
|
||||||
else {
|
lock (locker) {
|
||||||
using (BulkTransaction helper = SQLiteBulkTransaction.Create()) { // ensures that it's either all work, or none work.
|
if (Database.TableExists("Portals" + src))
|
||||||
helper.Execute(String.Format("ALTER TABLE `Block{0}` RENAME TO `Block{1}`", src, dst));
|
Database.Execute(String.Format(syntax, src, dst, "Portals"));
|
||||||
helper.Execute(String.Format("ALTER TABLE `Portals{0}` RENAME TO `Portals{1}`", src, dst));
|
if (Database.TableExists("Messages" + src))
|
||||||
helper.Execute(String.Format("ALTER TABLE `Messages{0}` RENAME TO `Messages{1}`", src, dst));
|
Database.Execute(String.Format(syntax, src, dst, "Messages"));
|
||||||
helper.Execute(String.Format("ALTER TABLE `Zone{0}` RENAME TO `Zone{1}`", src, dst));
|
if (Database.TableExists("Zone" + src))
|
||||||
helper.Commit();
|
Database.Execute(String.Format(syntax, src, dst, "Zone"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,8 +127,11 @@ namespace MCGalaxy {
|
|||||||
Database.Execute("DROP TABLE `Block" + name + "`");
|
Database.Execute("DROP TABLE `Block" + name + "`");
|
||||||
object locker = ThreadSafeCache.DBCache.Get(name);
|
object locker = ThreadSafeCache.DBCache.Get(name);
|
||||||
lock (locker) {
|
lock (locker) {
|
||||||
|
if (Database.TableExists("Portals" + name))
|
||||||
Database.Execute("DROP TABLE `Portals" + name + "`");
|
Database.Execute("DROP TABLE `Portals" + name + "`");
|
||||||
|
if (Database.TableExists("Messages" + name))
|
||||||
Database.Execute("DROP TABLE `Messages" + name + "`");
|
Database.Execute("DROP TABLE `Messages" + name + "`");
|
||||||
|
if (Database.TableExists("Zone" + name))
|
||||||
Database.Execute("DROP TABLE `Zone" + name + "`");
|
Database.Execute("DROP TABLE `Zone" + name + "`");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public bool HasWait {
|
public bool HasWait {
|
||||||
get { return (Raw & TypeBitsMask) == Wait
|
get { return (Raw & TypeBitsMask) == Wait
|
||||||
|| ((Raw >> 3) & TypeBitsMask) == Wait);
|
|| ((Raw >> 3) & TypeBitsMask) == Wait;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user