mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 14:17:29 -04:00
Now with 4.256% less redundant looking up of DataRows.
This commit is contained in:
parent
4be21585a9
commit
41c10d2b16
@ -65,16 +65,16 @@ namespace MCGalaxy.Commands
|
||||
for (int i = 0; i < Blocks.Rows.Count; i++)
|
||||
{
|
||||
foundOne = true;
|
||||
Username = Blocks.Rows[i]["Username"].ToString();
|
||||
TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//Server.s.Log(Blocks.Rows[i]["Type"].ToString());
|
||||
BlockUsed = Block.Name(Convert.ToByte(Blocks.Rows[i]["Type"])).ToString();
|
||||
Deleted = Convert.ToBoolean(Blocks.Rows[i]["Deleted"]);
|
||||
DataRow row = Blocks.Rows[i];
|
||||
Username = row["Username"].ToString().Trim();
|
||||
TimePerformed = DateTime.Parse(row["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
BlockUsed = Block.Name(Convert.ToByte(row["Type"])).ToString();
|
||||
Deleted = Convert.ToBoolean(row["Deleted"]);
|
||||
|
||||
if (!Deleted)
|
||||
Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "%S, using &3" + BlockUsed);
|
||||
Player.SendMessage(p, "&3Created by " + Server.FindColor(Username) + Username + "%S, using &3" + BlockUsed);
|
||||
else
|
||||
Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim()+ "%S, using &3" + BlockUsed);
|
||||
Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username) + Username + "%S, using &3" + BlockUsed);
|
||||
Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
|
||||
}
|
||||
|
||||
|
@ -112,12 +112,16 @@ namespace MCGalaxy.Commands {
|
||||
//safe against SQL injections because no user input is given here
|
||||
using (DataTable Messages = Database.fillData("SELECT * FROM `Messages" + p.level.name + "`")) {
|
||||
if (p.showMBs) {
|
||||
for (int i = 0; i < Messages.Rows.Count; i++)
|
||||
p.SendBlockchange(ushort.Parse(Messages.Rows[i]["X"].ToString()), ushort.Parse(Messages.Rows[i]["Y"].ToString()), ushort.Parse(Messages.Rows[i]["Z"].ToString()), Block.MsgWhite);
|
||||
for (int i = 0; i < Messages.Rows.Count; i++) {
|
||||
DataRow row = Messages.Rows[i];
|
||||
p.SendBlockchange(ushort.Parse(row["X"].ToString()), ushort.Parse(row["Y"].ToString()), ushort.Parse(row["Z"].ToString()), Block.MsgWhite);
|
||||
}
|
||||
Player.SendMessage(p, "Now showing &a" + Messages.Rows.Count + " %SMBs.");
|
||||
} else {
|
||||
for (int i = 0; i < Messages.Rows.Count; i++)
|
||||
p.SendBlockchange(ushort.Parse(Messages.Rows[i]["X"].ToString()), ushort.Parse(Messages.Rows[i]["Y"].ToString()), ushort.Parse(Messages.Rows[i]["Z"].ToString()), p.level.GetTile(ushort.Parse(Messages.Rows[i]["X"].ToString()), ushort.Parse(Messages.Rows[i]["Y"].ToString()), ushort.Parse(Messages.Rows[i]["Z"].ToString())));
|
||||
for (int i = 0; i < Messages.Rows.Count; i++) {
|
||||
DataRow row = Messages.Rows[i];
|
||||
p.RevertBlock(ushort.Parse(row["X"].ToString()), ushort.Parse(row["Y"].ToString()), ushort.Parse(row["Z"].ToString()));
|
||||
}
|
||||
Player.SendMessage(p, "Now hiding MBs.");
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace MCGalaxy.Commands {
|
||||
} else {
|
||||
for (int i = 0; i < Portals.Rows.Count; i++) {
|
||||
DataRow row = Portals.Rows[i];
|
||||
if (Portals.Rows[i]["ExitMap"].ToString() == p.level.name)
|
||||
if (row["ExitMap"].ToString() == p.level.name)
|
||||
p.RevertBlock(U16(row["ExitX"]), U16(row["ExitY"]), U16(row["ExitZ"]));
|
||||
p.RevertBlock(U16(row["EntryX"]), U16(row["EntryY"]), U16(row["EntryZ"]));
|
||||
}
|
||||
|
@ -609,13 +609,14 @@ namespace MCGalaxy
|
||||
Zone Zn;
|
||||
for (int i = 0; i < ZoneDB.Rows.Count; ++i)
|
||||
{
|
||||
Zn.smallX = ushort.Parse(ZoneDB.Rows[i]["SmallX"].ToString());
|
||||
Zn.smallY = ushort.Parse(ZoneDB.Rows[i]["SmallY"].ToString());
|
||||
Zn.smallZ = ushort.Parse(ZoneDB.Rows[i]["SmallZ"].ToString());
|
||||
Zn.bigX = ushort.Parse(ZoneDB.Rows[i]["BigX"].ToString());
|
||||
Zn.bigY = ushort.Parse(ZoneDB.Rows[i]["BigY"].ToString());
|
||||
Zn.bigZ = ushort.Parse(ZoneDB.Rows[i]["BigZ"].ToString());
|
||||
Zn.Owner = ZoneDB.Rows[i]["Owner"].ToString();
|
||||
DataRow row = ZoneDB.Rows[i];
|
||||
Zn.smallX = ushort.Parse(row["SmallX"].ToString());
|
||||
Zn.smallY = ushort.Parse(row["SmallY"].ToString());
|
||||
Zn.smallZ = ushort.Parse(row["SmallZ"].ToString());
|
||||
Zn.bigX = ushort.Parse(row["BigX"].ToString());
|
||||
Zn.bigY = ushort.Parse(row["BigY"].ToString());
|
||||
Zn.bigZ = ushort.Parse(row["BigZ"].ToString());
|
||||
Zn.Owner = row["Owner"].ToString();
|
||||
level.ZoneList.Add(Zn);
|
||||
}
|
||||
}
|
||||
@ -632,37 +633,39 @@ namespace MCGalaxy
|
||||
// level.StartPhysics();
|
||||
//};
|
||||
//level.physChecker.Start();
|
||||
//level.season = new SeasonsCore(level);
|
||||
|
||||
try
|
||||
{
|
||||
DataTable foundDB = Database.fillData("SELECT * FROM `Portals" + givenName + "`");
|
||||
|
||||
for (int i = 0; i < foundDB.Rows.Count; ++i)
|
||||
{
|
||||
DataRow row = foundDB.Rows[i];
|
||||
if (
|
||||
!Block.portal(level.GetTile(ushort.Parse(foundDB.Rows[i]["EntryX"].ToString()),
|
||||
ushort.Parse(foundDB.Rows[i]["EntryY"].ToString()),
|
||||
ushort.Parse(foundDB.Rows[i]["EntryZ"].ToString()))))
|
||||
!Block.portal(level.GetTile(ushort.Parse(row["EntryX"].ToString()),
|
||||
ushort.Parse(row["EntryY"].ToString()),
|
||||
ushort.Parse(row["EntryZ"].ToString()))))
|
||||
{
|
||||
Database.executeQuery("DELETE FROM `Portals" + givenName + "` WHERE EntryX=" +
|
||||
foundDB.Rows[i]["EntryX"] + " AND EntryY=" +
|
||||
foundDB.Rows[i]["EntryY"] + " AND EntryZ=" +
|
||||
foundDB.Rows[i]["EntryZ"]);
|
||||
row["EntryX"] + " AND EntryY=" +
|
||||
row["EntryY"] + " AND EntryZ=" +
|
||||
row["EntryZ"]);
|
||||
}
|
||||
}
|
||||
foundDB = Database.fillData("SELECT * FROM `Messages" + givenName + "`");
|
||||
|
||||
for (int i = 0; i < foundDB.Rows.Count; ++i)
|
||||
{
|
||||
DataRow row = foundDB.Rows[i];
|
||||
if (
|
||||
!Block.mb(level.GetTile(ushort.Parse(foundDB.Rows[i]["X"].ToString()),
|
||||
ushort.Parse(foundDB.Rows[i]["Y"].ToString()),
|
||||
ushort.Parse(foundDB.Rows[i]["Z"].ToString()))))
|
||||
!Block.mb(level.GetTile(ushort.Parse(row["X"].ToString()),
|
||||
ushort.Parse(row["Y"].ToString()),
|
||||
ushort.Parse(row["Z"].ToString()))))
|
||||
{
|
||||
//givenName is safe against SQL injections, it gets checked in CmdLoad.cs
|
||||
Database.executeQuery("DELETE FROM `Messages" + givenName + "` WHERE X=" +
|
||||
foundDB.Rows[i]["X"] + " AND Y=" + foundDB.Rows[i]["Y"] +
|
||||
" AND Z=" + foundDB.Rows[i]["Z"]);
|
||||
row["X"] + " AND Y=" + row["Y"] +
|
||||
" AND Z=" + row["Z"]);
|
||||
}
|
||||
}
|
||||
foundDB.Dispose();
|
||||
|
Loading…
x
Reference in New Issue
Block a user