mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 06:43:25 -04:00
Merge branch 'master' of github.com:Hetal728/MCGalaxy
This commit is contained in:
commit
a4737d324a
@ -56,7 +56,14 @@ namespace MCGalaxy {
|
||||
|
||||
if (i >= red && i <= white)
|
||||
Properties[i].KilledByLava = true;
|
||||
if (i == air || i == shrub || (i >= yellowflower && i <= redmushroom)) {
|
||||
Properties[i].KilledByLava = true;
|
||||
Properties[i].KilledByWater = true;
|
||||
}
|
||||
}
|
||||
// Block specific properties
|
||||
Properties[wood].KilledByLava = true; Properties[trunk].KilledByLava = true;
|
||||
Properties[sponge].KilledByLava = true; Properties[bookcase].KilledByLava = true;
|
||||
SetupDefaultNames();
|
||||
}
|
||||
|
||||
|
108
Blocks/Block.cs
108
Blocks/Block.cs
@ -21,23 +21,9 @@ namespace MCGalaxy
|
||||
{
|
||||
public sealed partial class Block
|
||||
{
|
||||
public static bool Walkthrough(byte type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case air:
|
||||
case water:
|
||||
case waterstill:
|
||||
case lava:
|
||||
case lavastill:
|
||||
case yellowflower:
|
||||
case redflower:
|
||||
case mushroom:
|
||||
case redmushroom:
|
||||
case shrub:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public static bool Walkthrough(byte type) {
|
||||
return type == air || type == shrub || (type >= water && type <= lavastill)
|
||||
&& (type >= yellowflower && type <= redmushroom);
|
||||
}
|
||||
|
||||
public static bool AllowBreak(byte type)
|
||||
@ -98,35 +84,14 @@ namespace MCGalaxy
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Placable(byte type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
// case Block.air:
|
||||
// case Block.grass:
|
||||
case Block.blackrock:
|
||||
case Block.water:
|
||||
case Block.waterstill:
|
||||
case Block.lava:
|
||||
case Block.lavastill:
|
||||
return false;
|
||||
}
|
||||
return type < Block.CpeCount;
|
||||
public static bool Placable(byte type) {
|
||||
return !(type == blackrock || (type >= water && type <= lavastill))
|
||||
&& type < Block.CpeCount;
|
||||
}
|
||||
|
||||
public static bool RightClick(byte type, bool countAir = false)
|
||||
{
|
||||
public static bool RightClick(byte type, bool countAir = false) {
|
||||
if (countAir && type == Block.air) return true;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Block.water:
|
||||
case Block.lava:
|
||||
case Block.waterstill:
|
||||
case Block.lavastill:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return type >= water && type <= lavastill;
|
||||
}
|
||||
|
||||
public static bool OPBlocks(byte type) { return Properties[type].OPBlock; }
|
||||
@ -169,60 +134,17 @@ namespace MCGalaxy
|
||||
public static bool BuildIn(byte type)
|
||||
{
|
||||
if (type == op_water || type == op_lava || Block.portal(type) || Block.mb(type)) return false;
|
||||
|
||||
switch (Block.Convert(type))
|
||||
{
|
||||
case water:
|
||||
case lava:
|
||||
case waterstill:
|
||||
case lavastill:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
type = Block.Convert(type);
|
||||
return type >= water && type <= lavastill;
|
||||
}
|
||||
|
||||
public static bool Mover(byte type) {
|
||||
return walkthroughHandlers[type] != null;
|
||||
}
|
||||
public static bool Mover(byte type) { return walkthroughHandlers[type] != null; }
|
||||
|
||||
public static bool FireKill(byte type) {
|
||||
return type != Block.air && LavaKill(type);
|
||||
}
|
||||
public static bool FireKill(byte type) { return type != air && Properties[type].KilledByLava; }
|
||||
|
||||
public static bool LavaKill(byte type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Block.air:
|
||||
case Block.wood:
|
||||
case Block.shrub:
|
||||
case Block.trunk:
|
||||
case Block.leaf:
|
||||
case Block.sponge:
|
||||
case Block.yellowflower:
|
||||
case Block.redflower:
|
||||
case Block.mushroom:
|
||||
case Block.redmushroom:
|
||||
case Block.bookcase:
|
||||
return true;
|
||||
}
|
||||
return Properties[type].KilledByLava;
|
||||
}
|
||||
public static bool WaterKill(byte type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Block.air:
|
||||
case Block.shrub:
|
||||
case Block.leaf:
|
||||
case Block.yellowflower:
|
||||
case Block.redflower:
|
||||
case Block.mushroom:
|
||||
case Block.redmushroom:
|
||||
return true;
|
||||
}
|
||||
return Properties[type].KilledByWater;
|
||||
}
|
||||
public static bool LavaKill(byte type) { return Properties[type].KilledByLava; }
|
||||
|
||||
public static bool WaterKill(byte type) { return Properties[type].KilledByWater; }
|
||||
|
||||
public static bool LightPass(byte type, byte extType, BlockDefinition[] defs) {
|
||||
switch (Convert(type)) {
|
||||
|
@ -208,8 +208,7 @@ namespace MCGalaxy.Commands {
|
||||
return;
|
||||
}
|
||||
if (pl.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "You can't force someone of a higher or equal rank to join a chatroom.");
|
||||
return;
|
||||
MessageTooHighRank(p, "force-join", false); return;
|
||||
}
|
||||
|
||||
if (pl.spyChatRooms.Contains(room)) {
|
||||
@ -234,8 +233,7 @@ namespace MCGalaxy.Commands {
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, name);
|
||||
if (pl == null) return;
|
||||
if (pl.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "You can't kick someone of a higher or equal rank from a chatroom.");
|
||||
return;
|
||||
MessageTooHighRank(p, "kick from a chatroom", false); return;
|
||||
}
|
||||
|
||||
Player.SendMessage(pl, "You were kicked from the chat room '" + pl.Chatroom + "'");
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.SendMessage(p, "You cannot %cdeath-hug %Sat your current rank."); return;
|
||||
}
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "You can't %cdeath-hug %Ssomeone of greater rank."); return;
|
||||
MessageTooHighRank(p, "&cdeath-hug%S", true); return;
|
||||
}
|
||||
who.HandleDeath(Block.rock, " died from a %cdeadly hug.");
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ namespace MCGalaxy.Commands
|
||||
Level.SaveSettings(p.level);
|
||||
}
|
||||
} else if (cmd == "GUNS") {
|
||||
Command.all.Find("allowguns").Use(p, null);
|
||||
Command.all.Find("allowguns").Use(p, "");
|
||||
} else if (cmd == "PERVISIT") {
|
||||
string rank = value == "" ? Server.defaultRank : value;
|
||||
Command.all.Find("pervisit").Use(p, rank);
|
||||
|
@ -70,6 +70,17 @@ namespace MCGalaxy
|
||||
else
|
||||
Player.SendMessage(p, "Only " + grp.color + grp.name + "%s+ can " + action);
|
||||
}
|
||||
|
||||
protected void MessageTooHighRank(Player p, string action, bool canAffectOwnRank) {
|
||||
MessageTooHighRank(p, action, p.group, canAffectOwnRank);
|
||||
}
|
||||
|
||||
protected void MessageTooHighRank(Player p, string action, Group grp, bool canAffectGroup) {
|
||||
if (canAffectGroup)
|
||||
Player.SendMessage(p, "Can only " + action + " players ranked " + grp.color + grp.name + " %Sor below");
|
||||
else
|
||||
Player.SendMessage(p, "Can only " + action + " players ranked below " + grp.color + grp.name);
|
||||
}
|
||||
}
|
||||
|
||||
public struct CommandPerm {
|
||||
|
@ -204,7 +204,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, target);
|
||||
if (who == null) return;
|
||||
if (p.group.Permission < who.group.Permission) {
|
||||
Player.SendMessage(p, "You can't send rules to someone of a higher rank than yourself!!"); return;
|
||||
MessageTooHighRank(p, "send countdown rules", true); return;
|
||||
} else {
|
||||
Player.SendMessage(who, "Countdown rules sent to you by " + p.color + p.name);
|
||||
Player.SendMessage(who, "The aim of the game is to stay alive the longest.");
|
||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands {
|
||||
return;
|
||||
}
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot slap someone ranked higher than you!"); return;
|
||||
MessageTooHighRank(p, "slap", true); return;
|
||||
}
|
||||
|
||||
ushort curX = (ushort)(who.pos[0] / 32), curY = (ushort)(who.pos[1] / 32), curZ = (ushort)(who.pos[2] / 32);
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands
|
||||
who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && p.group.Permission < who.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot send /oprules to a higher or same ranked player."); return;
|
||||
MessageTooHighRank(p, "send /oprules", false); return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,14 +95,14 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
bool CheckPerms(string name, Group group, Player p) {
|
||||
if ((int)group.Permission >= CommandOtherPerms.GetPerm(this)) {
|
||||
string highest = Group.findPermInt(CommandOtherPerms.GetPerm(this)).name;
|
||||
Player.SendMessage(p, "You can't ban players ranked " + highest + " or higher!"); return false;
|
||||
Group grp = Group.findPermInt(CommandOtherPerms.GetPerm(this));
|
||||
MessageTooHighRank(p, "ban", grp, false); return false;
|
||||
}
|
||||
if (group.Permission == LevelPermission.Banned) {
|
||||
Player.SendMessage(p, name + " is already banned."); return false;
|
||||
}
|
||||
if (p != null && group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot ban a person ranked equal or higher than you."); return false;
|
||||
MessageTooHighRank(p, "ban", false); return false;
|
||||
}
|
||||
|
||||
group.playerList.Remove(name);
|
||||
|
@ -95,7 +95,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
if (who == null) { Player.SendMessage(p, "Could not find player."); return; }
|
||||
else if (who == p) { Player.SendMessage(p, "Cannot follow yourself."); return; }
|
||||
else if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot follow someone of equal or greater rank."); return; }
|
||||
else if (who.group.Permission >= p.group.Permission) { MessageTooHighRank(p, "follow", false); return;}
|
||||
else if (who.following != "") { Player.SendMessage(p, who.DisplayName + " is already following " + who.following); return; }
|
||||
|
||||
if (!p.hidden) Command.all.Find("hide").Use(p, "");
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands
|
||||
if (who == null) return;
|
||||
if (p == who) { Player.SendMessage(p, "Cannot freeze yourself."); return; }
|
||||
if (p != null && who.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot freeze someone of equal or greater rank."); return;
|
||||
MessageTooHighRank(p, "freeze", false); return;
|
||||
}
|
||||
|
||||
string frozenby = (p == null) ? "(console)" : p.ColoredName;
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (!who.jailed) {
|
||||
if (p != null &&who.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot jail someone of equal or greater rank."); return;
|
||||
MessageTooHighRank(p, "jail", false); return;
|
||||
}
|
||||
Player.SendMessage(p, "You jailed " + who.DisplayName);
|
||||
Player.GlobalDespawn(who, false);
|
||||
|
@ -37,7 +37,9 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot joker someone of equal or greater rank."); return; }
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "joker", true); return;
|
||||
}
|
||||
|
||||
if (!who.joker) {
|
||||
if (stealth) {
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands
|
||||
Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower());
|
||||
} else {
|
||||
if (p != null && who.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return;
|
||||
MessageTooHighRank(p, "mute", false); return;
|
||||
}
|
||||
who.muted = true;
|
||||
Player.SendChatFrom(who, who.color + who.DisplayName + " %Shas been &8muted", false);
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
if (who.group.Permission >= p.group.Permission)
|
||||
{
|
||||
Player.SendMessage(p, "Cannot use this on someone of equal or greater rank."); return;
|
||||
MessageTooHighRank(p, "hide", false); return;
|
||||
}
|
||||
Command.all.Find("hide").Use(who, "");
|
||||
Player.SendMessage(p, "Used /hide on " + who.color + who.name + "%S.");
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
if (source == null || target == null) return;
|
||||
if (p.group.Permission < source.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot force a player of higher rank to tp to another player."); return;
|
||||
MessageTooHighRank(p, "teleport", true); return;
|
||||
}
|
||||
Player.SendMessage(p, "Attempting to teleport " + source.name + " to " + target.name + ".");
|
||||
Command.all.Find("tp").Use(source, target.name);
|
||||
|
@ -57,7 +57,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (who.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot possess someone of equal or greater rank."); return;
|
||||
MessageTooHighRank(p, "possess", false); return;
|
||||
}
|
||||
|
||||
if (who.possess != "") {
|
||||
|
@ -55,8 +55,8 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
if (who == null) {
|
||||
return;
|
||||
} else if (who.group.Permission > p.group.Permission && p != who) {
|
||||
Player.SendMessage(p, "Cannot reload the map of someone higher than you."); return;
|
||||
} else if (who.group.Permission > p.group.Permission && p != who) {
|
||||
MessageTooHighRank(p, "reload the map for", true); return;
|
||||
}
|
||||
ReloadMap(p, who, true);
|
||||
}
|
||||
|
@ -76,8 +76,11 @@ namespace MCGalaxy.Commands
|
||||
Player.SendMessage(p, "Cannot change the rank to or from \"" + banned.name + "\"."); return false;
|
||||
}
|
||||
if (p != null && (group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)) {
|
||||
Player.SendMessage(p, "Cannot change the rank of someone of or to a rank equal or higher to yours."); return false;
|
||||
MessageTooHighRank(p, "change the rank of", false); return false;
|
||||
}
|
||||
if (p != null && (newRank.Permission >= p.group.Permission)) {
|
||||
Player.SendMessage(p, "Cannot change the rank of a player to a rank equal or higher to yours."); return false;
|
||||
}
|
||||
|
||||
if (who != null) {
|
||||
Group.because(who, newRank);
|
||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy.Commands {
|
||||
if (!Player.ValidName(target)) { Player.SendMessage(p, "Invalid name \"" + target + "\"."); return; }
|
||||
Group grp = who == null ? PlayerInfo.GetGroup(target) : who.group;
|
||||
if (p != null && grp.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot temp ban someone of the same or higher rank."); return;
|
||||
MessageTooHighRank(p, "temp ban", false); return;
|
||||
}
|
||||
|
||||
int minutes = 60;
|
||||
|
@ -66,7 +66,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
void UndoOnlinePlayer(Player p, Player who, CatchPos cpos, ushort x, ushort y, ushort z) {
|
||||
if (p != who && who.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
|
||||
MessageTooHighRank(p, "undo", false); return;
|
||||
}
|
||||
|
||||
UndoOnlineDrawOp op = new UndoOnlineDrawOp();
|
||||
@ -84,7 +84,7 @@ namespace MCGalaxy.Commands {
|
||||
void UndoOfflinePlayer(Player p, string whoName, CatchPos cpos, ushort x, ushort y, ushort z) {
|
||||
Group group = Group.findPlayerGroup(whoName);
|
||||
if (group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
|
||||
MessageTooHighRank(p, "undo", false); return;
|
||||
}
|
||||
|
||||
UndoOfflineDrawOp op = new UndoOfflineDrawOp();
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
if (who == null) return;
|
||||
if (who == p) { Player.SendMessage(p, "you can't warn yourself"); return; }
|
||||
if (p != null && p.group.Permission <= who.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot warn a player of equal or higher rank."); return;
|
||||
MessageTooHighRank(p, "warn", false); return;
|
||||
}
|
||||
|
||||
string reason = args.Length == 1 ? "you know why." : args[1];
|
||||
|
@ -40,8 +40,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (p != null && muter.group.Permission > p.group.Permission)
|
||||
{
|
||||
Player.SendMessage(p, "You cannot xmute someone ranked higher than you!");
|
||||
return;
|
||||
MessageTooHighRank(p, "xmute", true); return;
|
||||
}
|
||||
if (p == muter)
|
||||
{
|
||||
|
@ -30,19 +30,21 @@ namespace MCGalaxy.Commands {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.Split(' ');
|
||||
string scope = args[0].ToLower();
|
||||
if (scope == "local") scope = "level";
|
||||
if (scope == "localzip") scope = "levelzip";
|
||||
|
||||
if (args.Length == 1) {
|
||||
if (scope == "level")
|
||||
Player.SendMessage(p, "Level terrain: " + GetPath(p.level.terrainUrl));
|
||||
else if (scope == "levelzip")
|
||||
if (scope == "level")
|
||||
Player.SendMessage(p, "Level terrain: " + GetPath(p.level.terrainUrl));
|
||||
else if (scope == "levelzip")
|
||||
Player.SendMessage(p, "Level tex pack: " + GetPath(p.level.texturePackUrl));
|
||||
else if (scope == "global")
|
||||
Player.SendMessage(p, "Global terrain: " + GetPath(Server.defaultTerrainUrl));
|
||||
else if (scope == "globalzip")
|
||||
Player.SendMessage(p, "Global tex pack: " + GetPath(Server.defaultTexturePackUrl));
|
||||
else
|
||||
Help(p);
|
||||
return;
|
||||
Player.SendMessage(p, "Global terrain: " + GetPath(Server.defaultTerrainUrl));
|
||||
else if (scope == "globalzip")
|
||||
Player.SendMessage(p, "Global tex pack: " + GetPath(Server.defaultTexturePackUrl));
|
||||
else
|
||||
Help(p);
|
||||
return;
|
||||
}
|
||||
|
||||
string url = args[1];
|
||||
@ -58,6 +60,7 @@ namespace MCGalaxy.Commands {
|
||||
if ((scope == "globalzip" || scope == "levelzip") && !(url == "" || url.EndsWith(".zip"))) {
|
||||
p.SendMessage("The texture pack URL must end in a .zip"); return;
|
||||
}
|
||||
if (url.Length > 64) { p.SendMessage("The URL must be 64 characters or less."); return; }
|
||||
|
||||
if (scope == "global") {
|
||||
Server.defaultTerrainUrl = url;
|
||||
@ -75,15 +78,15 @@ namespace MCGalaxy.Commands {
|
||||
p.level.texturePackUrl = url;
|
||||
p.SendMessage("Set level's texture pack to " + args[1]);
|
||||
UpdateLevel(p, true);
|
||||
} else {
|
||||
Help(p);
|
||||
}
|
||||
}
|
||||
|
||||
static string GetPath(string url) {
|
||||
return url == "" ? "(none)" : url;
|
||||
}
|
||||
static string GetPath(string url) { return url == "" ? "(none)" : url; }
|
||||
|
||||
void UpdateGlobally(Player p, bool zip) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
bool hasExt = pl.HasCpeExt(CpeExt.EnvMapAppearance) || pl.HasCpeExt(CpeExt.EnvMapAppearance, 2);
|
||||
string url = zip ? pl.level.texturePackUrl : pl.level.terrainUrl;
|
||||
@ -94,7 +97,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
void UpdateLevel(Player p, bool zip) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
bool hasExt = pl.HasCpeExt(CpeExt.EnvMapAppearance) || pl.HasCpeExt(CpeExt.EnvMapAppearance, 2);
|
||||
if (hasExt && pl.level == p.level)
|
||||
|
@ -87,7 +87,7 @@ namespace MCGalaxy.Commands
|
||||
void UndoOnlinePlayer(Player p, long seconds, Player who) {
|
||||
if (p != null && p != who) {
|
||||
if (who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
|
||||
MessageTooHighRank(p, "undo", true); return;
|
||||
}
|
||||
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can undo other players."); return; }
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot change the color of someone of greater rank"); return;
|
||||
MessageTooHighRank(p, "change the color of", true); return;
|
||||
}
|
||||
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
if (p == null || p == who || p.group.Permission > who.group.Permission) {
|
||||
Player.SendChatFrom(who, args[1]);
|
||||
} else {
|
||||
Player.SendMessage(p, "You cannot impersonate a player of equal or greater rank.");
|
||||
MessageTooHighRank(p, "impersonate", false); return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands
|
||||
if (who == null) return;
|
||||
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot toggle invincibility for someone of higher rank");return;
|
||||
MessageTooHighRank(p, "toggle invinciblity", true); return;
|
||||
}
|
||||
|
||||
if (who.invincible)
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
p.HandleDeath(Block.rock, " was killed by " + who.color + who.DisplayName);
|
||||
Player.SendMessage(p, "Cannot kill someone of higher rank"); return;
|
||||
MessageTooHighRank(p, "kill", true); return;
|
||||
}
|
||||
who.HandleDeath(Block.rock, deathMessage, explode);
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ namespace MCGalaxy.Commands
|
||||
Level where = LevelInfo.Find(param[1]);
|
||||
if (who == null) return;
|
||||
if (where == null) { Player.SendMessage(p, "Could not find level specified"); return; }
|
||||
if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot move someone of greater rank"); return; }
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "move", true); return;
|
||||
}
|
||||
|
||||
Command.all.Find("goto").Use(who, where.name);
|
||||
if (who.level == where)
|
||||
@ -70,7 +72,9 @@ namespace MCGalaxy.Commands
|
||||
{
|
||||
who = PlayerInfo.FindOrShowMatches(p, param[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot move someone of greater rank"); return; }
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "move", true); return;
|
||||
}
|
||||
message = message.Substring(message.IndexOf(' ') + 1);
|
||||
}
|
||||
else
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot change the nick of someone of greater rank"); return;
|
||||
MessageTooHighRank(p, "change the nick of", true); return;
|
||||
}
|
||||
|
||||
string newName = parts.Length > 1 ? parts[1] : "";
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
|
||||
Player target = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
if (target == null) return;
|
||||
if (p != null && p.group.Permission < target.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot use this on someone of equal or greater rank."); return;
|
||||
MessageTooHighRank(p, "send commands for", true); return;
|
||||
}
|
||||
if (parts.Length == 1) {
|
||||
Player.SendMessage(p, "No command name given."); return;
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p.group.Permission < who.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot summon someone ranked higher than you!"); return;
|
||||
MessageTooHighRank(p, "summon", true); return;
|
||||
}
|
||||
|
||||
if (p.level != who.level)
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot change the title of someone of greater rank"); return;
|
||||
MessageTooHighRank(p, "change the title of", true); return;
|
||||
}
|
||||
|
||||
string newTitle = parts.Length > 1 ? parts[1] : "";
|
||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
if (!Server.higherranktp && p.group.Permission < target.group.Permission) {
|
||||
Player.SendMessage(p, "You cannot teleport to a player of higher rank!"); return;
|
||||
MessageTooHighRank(p, "teleport to", true); return;
|
||||
}
|
||||
p.beforeTeleportMap = p.level.name;
|
||||
p.beforeTeleportPos = p.pos;
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.SendMessage(p, "Use /spawn to respawn yourself."); return;
|
||||
}
|
||||
if (p != null && pl.group.Permission >= p.group.Permission) {
|
||||
Player.SendMessage(p, "Cannot respawn someone of greater or same rank"); return;
|
||||
MessageTooHighRank(p, "respawn", false); return;
|
||||
}
|
||||
|
||||
Command.all.Find("spawn").Use(pl, "");
|
||||
|
@ -27,6 +27,21 @@ namespace MCGalaxy.Games {
|
||||
public sealed partial class ZombieGame {
|
||||
|
||||
void MainLoop() {
|
||||
// Make sure that in the worst case, we do not crash the entire server.
|
||||
try {
|
||||
MainLoopCore();
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
Player.GlobalMessage("&cZombie survival disabled due to an error.");
|
||||
try {
|
||||
ResetState();
|
||||
} catch (Exception ex2) {
|
||||
Server.ErrorLog(ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainLoopCore() {
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
if (!initialChangeLevel) {
|
||||
ChooseNextLevel();
|
||||
@ -110,19 +125,19 @@ namespace MCGalaxy.Games {
|
||||
List<Player> DoRoundCountdown() {
|
||||
while (true) {
|
||||
RoundStart = DateTime.UtcNow.AddSeconds(30);
|
||||
CurLevel.ChatLevel("%4Round Start:%f 30...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 30...");
|
||||
Thread.Sleep(20000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 10...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 10...");
|
||||
Thread.Sleep(10000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 5...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 5...");
|
||||
Thread.Sleep(1000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 4...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 4...");
|
||||
Thread.Sleep(1000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 3...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 3...");
|
||||
Thread.Sleep(1000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 2...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 2...");
|
||||
Thread.Sleep(1000); if (!Running) return null;
|
||||
CurLevel.ChatLevel("%4Round Start:%f 1...");
|
||||
CurLevel.ChatLevel("&4Round Start:&f 1...");
|
||||
Thread.Sleep(1000); if (!Running) return null;
|
||||
int nonRefPlayers = 0;
|
||||
List<Player> players = new List<Player>();
|
||||
@ -136,7 +151,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
if (nonRefPlayers >= 2) return players;
|
||||
CurLevel.ChatLevel(Colors.red + "ERROR: Need 2 or more players to play");
|
||||
CurLevel.ChatLevel("&cNeed 2 or more players to start a round.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace MCGalaxy.Games {
|
||||
Player[] players = p.Game.Infected ? Infected.Items : Alive.Items;
|
||||
string type = p.Game.Infected ? " &cto zombies%S: " : " &ato humans%S: ";
|
||||
foreach (Player pl in players)
|
||||
pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1));
|
||||
pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1));
|
||||
return true;
|
||||
} else if (message[0] == '`' && message.Length > 1) {
|
||||
if (p.Game.Team == null) {
|
||||
@ -122,7 +122,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) {
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight2, "");
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight2, "");
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
||||
if (RoundInProgress && lvl.name.CaselessEq(CurLevelName)) {
|
||||
if (Running && p != null) {
|
||||
@ -152,30 +152,36 @@ namespace MCGalaxy.Games {
|
||||
return;
|
||||
}
|
||||
|
||||
p.SendCpeMessage(CpeMessageType.Status1, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status2, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status3, "");
|
||||
ResetCpeMessages(p);
|
||||
Alive.Remove(p);
|
||||
Infected.Remove(p);
|
||||
if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName))
|
||||
UpdateAllPlayerStatus();
|
||||
}
|
||||
|
||||
|
||||
void ResetCpeMessages(Player p) {
|
||||
p.SendCpeMessage(CpeMessageType.Status1, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status2, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status3, "");
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight2, "");
|
||||
}
|
||||
|
||||
public override bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) {
|
||||
if (!oldLvl.name.CaselessEq(CurLevelName)) return true;
|
||||
if (lvl.name.CaselessEq(CurLevelName)) return true;
|
||||
|
||||
if (RoundInProgress && !p.Game.Referee) {
|
||||
p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!oldLvl.name.CaselessEq(CurLevelName)) return true;
|
||||
if (lvl.name.CaselessEq(CurLevelName)) return true;
|
||||
|
||||
if (RoundInProgress && !p.Game.Referee) {
|
||||
p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PlayerMoneyChanged(Player p) {
|
||||
if (!Running || !p.level.name.CaselessEq(CurLevelName)) return;
|
||||
string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
|
||||
string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive");
|
||||
string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
|
||||
string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive");
|
||||
p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg);
|
||||
}
|
||||
}
|
||||
|
@ -203,15 +203,18 @@ namespace MCGalaxy.Games {
|
||||
RoundInProgress = false;
|
||||
RoundStart = DateTime.MinValue;
|
||||
RoundEnd = DateTime.MinValue;
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
pl.Game.RatedMap = false;
|
||||
pl.Game.PledgeSurvive = false;
|
||||
if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName))
|
||||
continue;
|
||||
ResetCpeMessages(pl);
|
||||
}
|
||||
|
||||
LastLevelName = "";
|
||||
CurLevelName = "";
|
||||
CurLevel = null;
|
||||
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
pl.Game.RatedMap = false;
|
||||
pl.Game.PledgeSurvive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatePlayerStatus(Player p) {
|
||||
|
@ -83,8 +83,8 @@ namespace MCGalaxy {
|
||||
AddExtension(enc.GetString(message, 0, 64).Trim(), NetUtils.ReadI32(message, 64));
|
||||
extensionCount--;
|
||||
if (extensionCount <= 0 && !finishedCpeLogin) {
|
||||
CompleteLoginProcess();
|
||||
finishedCpeLogin = true;
|
||||
CompleteLoginProcess();
|
||||
finishedCpeLogin = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,13 +105,13 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void SendRaw(int id) {
|
||||
byte[] buffer = new [] { (byte)id };
|
||||
SendRaw(buffer);
|
||||
byte[] buffer = new [] { (byte)id };
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
public void SendRaw(int id, byte data) {
|
||||
byte[] buffer = new [] { (byte)id, data };
|
||||
SendRaw(buffer);
|
||||
byte[] buffer = new [] { (byte)id, data };
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
[Obsolete("Include the opcode in the array to avoid an extra temp allocation.")]
|
||||
@ -135,7 +135,7 @@ namespace MCGalaxy {
|
||||
socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, delegate(IAsyncResult result) { }, null);
|
||||
buffer = null;
|
||||
} catch (SocketException e) {
|
||||
buffer = null;
|
||||
buffer = null;
|
||||
Disconnect();
|
||||
#if DEBUG
|
||||
Server.ErrorLog(e);
|
||||
@ -147,7 +147,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void SendBlankMessage() {
|
||||
byte[] buffer = new byte[66];
|
||||
byte[] buffer = new byte[66];
|
||||
buffer[0] = Opcode.Message;
|
||||
NetUtils.WriteAscii("", buffer, 2);
|
||||
SendRaw(buffer);
|
||||
@ -174,14 +174,14 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void SendMessage(string message) {
|
||||
SendMessage(0, Server.DefaultColor + message, true);
|
||||
SendMessage(0, Server.DefaultColor + message, true);
|
||||
}
|
||||
|
||||
public void SendMessage(string message, bool colorParse) {
|
||||
SendMessage(0, Server.DefaultColor + message, colorParse);
|
||||
}
|
||||
|
||||
public void SendMessage(byte id, string message, bool colorParse = true) {
|
||||
public void SendMessage(byte id, string message, bool colorParse = true) {
|
||||
message = ConvertMessage(message, colorParse);
|
||||
int totalTries = 0;
|
||||
if ( MessageRecieve != null )
|
||||
@ -225,7 +225,7 @@ namespace MCGalaxy {
|
||||
else return;
|
||||
}
|
||||
message = ConvertMessage(message, colorParse);
|
||||
|
||||
|
||||
byte[] buffer = new byte[66];
|
||||
buffer[0] = Opcode.Message;
|
||||
buffer[1] = (byte)id;
|
||||
@ -240,7 +240,7 @@ namespace MCGalaxy {
|
||||
if (colorParse)
|
||||
message = Colors.EscapeColors(message);
|
||||
StringBuilder sb = new StringBuilder(message);
|
||||
if (colorParse)
|
||||
if (colorParse)
|
||||
ParseColors(sb);
|
||||
|
||||
Chat.ApplyTokens(sb, this, colorParse);
|
||||
@ -297,14 +297,14 @@ namespace MCGalaxy {
|
||||
|
||||
if (level.motd == "ignore") {
|
||||
NetUtils.WriteAscii(Server.name, buffer, 2);
|
||||
if (!String.IsNullOrEmpty(group.MOTD) )
|
||||
NetUtils.WriteAscii(group.MOTD, buffer, 66);
|
||||
else
|
||||
NetUtils.WriteAscii(Server.motd, buffer, 66);
|
||||
if (!String.IsNullOrEmpty(group.MOTD) )
|
||||
NetUtils.WriteAscii(group.MOTD, buffer, 66);
|
||||
else
|
||||
NetUtils.WriteAscii(Server.motd, buffer, 66);
|
||||
} else {
|
||||
NetUtils.WriteAscii(level.motd, buffer, 2);
|
||||
if (level.motd.Length > 64)
|
||||
NetUtils.WriteAscii(level.motd.Substring(64), buffer, 66);
|
||||
NetUtils.WriteAscii(level.motd, buffer, 2);
|
||||
if (level.motd.Length > 64)
|
||||
NetUtils.WriteAscii(level.motd.Substring(64), buffer, 66);
|
||||
}
|
||||
|
||||
bool canPlace = Block.canPlace(this, Block.blackrock);
|
||||
@ -331,8 +331,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
SendRaw(Opcode.LevelInitialise);
|
||||
int totalRead = 0;
|
||||
while (totalRead < usedLength) {
|
||||
int totalRead = 0;
|
||||
while (totalRead < usedLength) {
|
||||
byte[] packet = new byte[1028]; // need each packet separate for Mono
|
||||
packet[0] = Opcode.LevelDataChunk;
|
||||
short length = (short)Math.Min(buffer.Length - totalRead, 1024);
|
||||
@ -340,7 +340,7 @@ namespace MCGalaxy {
|
||||
Buffer.BlockCopy(buffer, totalRead, packet, 3, length);
|
||||
packet[1027] = (byte)(100 * (float)totalRead / buffer.Length);
|
||||
|
||||
SendRaw(packet);
|
||||
SendRaw(packet);
|
||||
if (ip != "127.0.0.1")
|
||||
Thread.Sleep(Server.updateTimer.Interval > 1000 ? 100 : 10);
|
||||
totalRead += length;
|
||||
@ -380,12 +380,22 @@ namespace MCGalaxy {
|
||||
return success;
|
||||
}
|
||||
|
||||
byte[] CompressRawMap(out int usedLength) {
|
||||
unsafe byte[] CompressRawMap(out int usedLength) {
|
||||
const int bufferSize = 64 * 1024;
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
MemoryStream temp = new MemoryStream();
|
||||
int bIndex = 0;
|
||||
|
||||
// Store locally instead of performing func call for every block in map
|
||||
byte* conv = stackalloc byte[256];
|
||||
byte* convCPE = stackalloc byte[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
conv[i] = Block.Convert((byte)i);
|
||||
if (!hasCustomBlocks) {
|
||||
for (int i = 0; i < 256; i++)
|
||||
convCPE[i] = Block.ConvertCPE((byte)i);
|
||||
}
|
||||
|
||||
using (GZipStream compressor = new GZipStream(temp, CompressionMode.Compress, true)) {
|
||||
NetUtils.WriteI32(level.blocks.Length, buffer, 0);
|
||||
compressor.Write(buffer, 0, sizeof(int));
|
||||
@ -398,7 +408,7 @@ namespace MCGalaxy {
|
||||
if (hasBlockDefs) buffer[bIndex] = level.GetExtTile(i);
|
||||
else buffer[bIndex] = level.GetFallbackExtTile(i);
|
||||
} else {
|
||||
buffer[bIndex] = Block.Convert(block);
|
||||
buffer[bIndex] = conv[block];
|
||||
}
|
||||
|
||||
bIndex++;
|
||||
@ -410,10 +420,10 @@ namespace MCGalaxy {
|
||||
for (int i = 0; i < level.blocks.Length; ++i) {
|
||||
byte block = level.blocks[i];
|
||||
if (block == Block.custom_block) {
|
||||
if (hasBlockDefs) buffer[bIndex] = Block.ConvertCPE(level.GetExtTile(i));
|
||||
else buffer[bIndex] = Block.ConvertCPE(level.GetFallbackExtTile(i));
|
||||
if (hasBlockDefs) buffer[bIndex] = convCPE[level.GetExtTile(i)];
|
||||
else buffer[bIndex] = convCPE[level.GetFallbackExtTile(i)];
|
||||
} else {
|
||||
buffer[bIndex] = Block.Convert(Block.ConvertCPE(level.blocks[i]));
|
||||
buffer[bIndex] = convCPE[conv[block]];
|
||||
}
|
||||
|
||||
bIndex++;
|
||||
@ -421,7 +431,7 @@ namespace MCGalaxy {
|
||||
compressor.Write(buffer, 0, bufferSize); bIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bIndex > 0) compressor.Write(buffer, 0, bIndex);
|
||||
}
|
||||
usedLength = (int)temp.Length;
|
||||
@ -429,12 +439,12 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void RemoveOldLevelCustomBlocks(Level oldLevel) {
|
||||
BlockDefinition[] defs = oldLevel.CustomBlockDefs;
|
||||
for (int i = Block.CpeCount; i < 256; i++) {
|
||||
BlockDefinition def = defs[i];
|
||||
if (def == null || def == BlockDefinition.GlobalDefs[i]) continue;
|
||||
SendRaw(Opcode.CpeRemoveBlockDefinition, (byte)i);
|
||||
}
|
||||
BlockDefinition[] defs = oldLevel.CustomBlockDefs;
|
||||
for (int i = Block.CpeCount; i < 256; i++) {
|
||||
BlockDefinition def = defs[i];
|
||||
if (def == null || def == BlockDefinition.GlobalDefs[i]) continue;
|
||||
SendRaw(Opcode.CpeRemoveBlockDefinition, (byte)i);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendSpawn(byte id, string name, ushort x, ushort y, ushort z, byte rotx, byte roty) {
|
||||
@ -445,12 +455,12 @@ namespace MCGalaxy {
|
||||
NetUtils.WriteU16(x, buffer, 66);
|
||||
NetUtils.WriteU16(y, buffer, 68);
|
||||
NetUtils.WriteU16(z, buffer, 70);
|
||||
buffer[72] = rotx;
|
||||
buffer[72] = rotx;
|
||||
buffer[73] = roty;
|
||||
SendRaw(buffer);
|
||||
|
||||
if (HasCpeExt(CpeExt.ChangeModel))
|
||||
UpdateModels();
|
||||
UpdateModels();
|
||||
}
|
||||
|
||||
public void SendPos(byte id, ushort x, ushort y, ushort z, byte rotx, byte roty) {
|
||||
@ -466,13 +476,13 @@ namespace MCGalaxy {
|
||||
pos[0] = x; pos[1] = y; pos[2] = z;
|
||||
rot[0] = rotx; rot[1] = roty;
|
||||
|
||||
byte[] buffer = new byte[10];
|
||||
byte[] buffer = new byte[10];
|
||||
buffer[0] = Opcode.EntityTeleport;
|
||||
buffer[1] = id;
|
||||
NetUtils.WriteU16(x, buffer, 2);
|
||||
NetUtils.WriteU16(y, buffer, 4);
|
||||
NetUtils.WriteU16(z, buffer, 6);
|
||||
buffer[8] = rotx;
|
||||
buffer[8] = rotx;
|
||||
buffer[9] = roty;
|
||||
SendRaw(buffer);
|
||||
}
|
||||
@ -482,8 +492,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
//TODO: Figure a way to SendPos without changing rotation
|
||||
public void SendDespawn(byte id) {
|
||||
SendRaw(Opcode.RemoveEntity, id);
|
||||
public void SendDespawn(byte id) {
|
||||
SendRaw(Opcode.RemoveEntity, id);
|
||||
}
|
||||
|
||||
public void SendBlockchange(ushort x, ushort y, ushort z, byte type) {
|
||||
@ -497,14 +507,14 @@ namespace MCGalaxy {
|
||||
NetUtils.WriteU16(z, buffer, 5);
|
||||
|
||||
if (type == Block.custom_block) {
|
||||
if (hasBlockDefs)
|
||||
buffer[7] = level.GetExtTile(x, y, z);
|
||||
else
|
||||
buffer[7] = level.GetFallbackExtTile(x, y, z);
|
||||
if (hasBlockDefs)
|
||||
buffer[7] = level.GetExtTile(x, y, z);
|
||||
else
|
||||
buffer[7] = level.GetFallbackExtTile(x, y, z);
|
||||
} else if (hasCustomBlocks) {
|
||||
buffer[7] = Block.Convert(type);
|
||||
buffer[7] = Block.Convert(type);
|
||||
} else {
|
||||
buffer[7] = Block.Convert(Block.ConvertCPE(type));
|
||||
buffer[7] = Block.Convert(Block.ConvertCPE(type));
|
||||
}
|
||||
SendRaw(buffer);
|
||||
}
|
||||
@ -521,27 +531,27 @@ namespace MCGalaxy {
|
||||
NetUtils.WriteU16(z, buffer, 5);
|
||||
|
||||
if (type == Block.custom_block) {
|
||||
if (hasBlockDefs)
|
||||
buffer[7] = extType;
|
||||
else
|
||||
buffer[7] = level.GetFallback(extType);
|
||||
if (hasBlockDefs)
|
||||
buffer[7] = extType;
|
||||
else
|
||||
buffer[7] = level.GetFallback(extType);
|
||||
} else if (hasCustomBlocks) {
|
||||
buffer[7] = Block.Convert(type);
|
||||
buffer[7] = Block.Convert(type);
|
||||
} else {
|
||||
buffer[7] = Block.Convert(Block.ConvertCPE(type));
|
||||
buffer[7] = Block.Convert(Block.ConvertCPE(type));
|
||||
}
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
void SendKick(string message, bool sync) {
|
||||
byte[] buffer = new byte[65];
|
||||
buffer[0] = Opcode.Kick;
|
||||
NetUtils.WriteAscii(message, buffer, 1);
|
||||
SendRaw(buffer, sync);
|
||||
byte[] buffer = new byte[65];
|
||||
buffer[0] = Opcode.Kick;
|
||||
NetUtils.WriteAscii(message, buffer, 1);
|
||||
SendRaw(buffer, sync);
|
||||
}
|
||||
|
||||
void SendPing() {
|
||||
SendRaw(Opcode.Ping);
|
||||
void SendPing() {
|
||||
SendRaw(Opcode.Ping);
|
||||
}
|
||||
|
||||
void SendExtInfo( byte count ) {
|
||||
@ -553,14 +563,14 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void SendExtEntry( string name, int version ) {
|
||||
byte[] buffer = new byte[69];
|
||||
buffer[0] = Opcode.CpeExtEntry;
|
||||
byte[] buffer = new byte[69];
|
||||
buffer[0] = Opcode.CpeExtEntry;
|
||||
NetUtils.WriteAscii(name, buffer, 1);
|
||||
NetUtils.WriteI32(version, buffer, 65);
|
||||
SendRaw(buffer, true);
|
||||
}
|
||||
|
||||
public void SendClickDistance( short distance ) {
|
||||
public void SendClickDistance( short distance ) {
|
||||
byte[] buffer = new byte[3];
|
||||
buffer[0] = Opcode.CpeSetClickDistance;
|
||||
NetUtils.WriteI16(distance, buffer, 1);
|
||||
@ -668,8 +678,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void SendSetMapAppearance( string url, byte sideblock, byte edgeblock, short sidelevel ) {
|
||||
byte[] buffer = new byte[69];
|
||||
buffer[0] = Opcode.CpeEnvSetMapApperance;
|
||||
byte[] buffer = new byte[69];
|
||||
buffer[0] = Opcode.CpeEnvSetMapApperance;
|
||||
NetUtils.WriteAscii(url, buffer, 1);
|
||||
buffer[65] = sideblock;
|
||||
buffer[66] = edgeblock;
|
||||
@ -677,10 +687,10 @@ namespace MCGalaxy {
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
public void SendSetMapAppearanceV2( string url, byte sideblock, byte edgeblock, short sidelevel,
|
||||
public void SendSetMapAppearanceV2( string url, byte sideblock, byte edgeblock, short sidelevel,
|
||||
short cloudHeight, short maxFog ) {
|
||||
byte[] buffer = new byte[73];
|
||||
buffer[0] = Opcode.CpeEnvSetMapApperance;
|
||||
byte[] buffer = new byte[73];
|
||||
buffer[0] = Opcode.CpeEnvSetMapApperance;
|
||||
NetUtils.WriteAscii(url, buffer, 1);
|
||||
buffer[65] = sideblock;
|
||||
buffer[66] = edgeblock;
|
||||
@ -694,7 +704,7 @@ namespace MCGalaxy {
|
||||
SendRaw(Opcode.CpeEnvWeatherType, weather);
|
||||
}
|
||||
|
||||
void SendHackControl( byte allowflying, byte allownoclip, byte allowspeeding, byte allowrespawning,
|
||||
void SendHackControl( byte allowflying, byte allownoclip, byte allowspeeding, byte allowrespawning,
|
||||
byte allowthirdperson, short maxjumpheight ) {
|
||||
byte[] buffer = new byte[8];
|
||||
buffer[0] = Opcode.CpeHackControl;
|
||||
@ -708,11 +718,11 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void UpdatePosition() {
|
||||
//pingDelayTimer.Stop();
|
||||
byte[] packet = NetUtils.GetPositionPacket(id, pos, oldpos, rot, oldrot, MakePitch(), false);
|
||||
oldpos = pos; oldrot = rot;
|
||||
if (packet == null) return;
|
||||
|
||||
//pingDelayTimer.Stop();
|
||||
byte[] packet = NetUtils.GetPositionPacket(id, pos, oldpos, rot, oldrot, MakePitch(), false);
|
||||
oldpos = pos; oldrot = rot;
|
||||
if (packet == null) return;
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
if (p != this && p.level == level) p.SendRaw(packet);
|
||||
@ -720,12 +730,12 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
byte MakePitch() {
|
||||
if (Server.flipHead || flipHead)
|
||||
if (rot[1] > 64 && rot[1] < 192)
|
||||
return rot[1];
|
||||
else
|
||||
return 128;
|
||||
return rot[1];
|
||||
if (Server.flipHead || flipHead)
|
||||
if (rot[1] > 64 && rot[1] < 192)
|
||||
return rot[1];
|
||||
else
|
||||
return 128;
|
||||
return rot[1];
|
||||
}
|
||||
|
||||
internal void CloseSocket() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user