Fix colours in SpawnEntity packets not being converted into fallback colours for clients that don't support TextColors CPE extension.

This commit is contained in:
UnknownShadow200 2016-04-04 08:48:30 +10:00
parent 2349a81f79
commit cbbb7bda0e
11 changed files with 26 additions and 23 deletions

View File

@ -33,7 +33,7 @@ namespace MCGalaxy {
internal static HandlePlace[] placeHandlers = new Block.HandlePlace[256]; internal static HandlePlace[] placeHandlers = new Block.HandlePlace[256];
/// <summary> Returns whether this block handles the player walking through this block at the given coordinates. </summary> /// <summary> Returns whether this block handles the player walking through this block at the given coordinates. </summary>
/// <remarks>If this returns true, the usual 'checking dirt/grass below' behaviour is skipped. </remarks> /// <remarks>If this returns true, the usual 'death check' behaviour is skipped. </remarks>
public delegate bool HandleWalkthrough(Player p, byte block, ushort x, ushort y, ushort z); public delegate bool HandleWalkthrough(Player p, byte block, ushort x, ushort y, ushort z);
internal static HandleWalkthrough[] walkthroughHandlers = new Block.HandleWalkthrough[256]; internal static HandleWalkthrough[] walkthroughHandlers = new Block.HandleWalkthrough[256];

View File

@ -83,7 +83,7 @@ namespace MCGalaxy.BlockBehaviour {
p.checkpointX = x; p.checkpointY = y; p.checkpointZ = z; p.checkpointX = x; p.checkpointY = y; p.checkpointZ = z;
int index = p.level.PosToInt(x, y, z); int index = p.level.PosToInt(x, y, z);
if (index != p.lastCheckpointIndex) { if (index != p.lastCheckpointIndex) {
p.SendSpawn(0xFF, p.color + p.truename, p.pos[0], (ushort)((y - 1) * 32 + 51), p.pos[2], p.rot[0], p.rot[1]); p.SpawnEntity(p, 0xFF, p.pos[0], (ushort)((y - 1) * 32 + 51), p.pos[2], p.rot[0], p.rot[1]);
p.lastCheckpointIndex = index; p.lastCheckpointIndex = index;
} }
return true; return true;

View File

@ -105,7 +105,7 @@ namespace MCGalaxy.Commands {
} }
void HandleCreate(Player p, string[] parts) { void HandleCreate(Player p, string[] parts) {
if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; } if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; }
if (parts.Length <= 1) { if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a new chatroom name."); Player.SendMessage(p, "You need to provide a new chatroom name.");
return; return;
@ -139,7 +139,7 @@ namespace MCGalaxy.Commands {
} }
if (!canDeleteForce) { if (!canDeleteForce) {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
if (pl != p && pl.Chatroom == room) { if (pl != p && pl.Chatroom == room) {
Player.SendMessage(p, "Sorry, someone else is in the chatroom"); Player.SendMessage(p, "Sorry, someone else is in the chatroom");

View File

@ -63,7 +63,7 @@ namespace MCGalaxy
} }
protected void MessageNeedPerms(Player p, string action, int num = 1) { protected void MessageNeedPerms(Player p, string action, int num = 1) {
int perm = CommandOtherPerms.GetPerm(this, num) int perm = CommandOtherPerms.GetPerm(this, num);
Group grp = Group.findPermInt(perm); Group grp = Group.findPermInt(perm);
if (grp == null) if (grp == null)
Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action); Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action);

View File

@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
foreach (Player pl in players) { foreach (Player pl in players) {
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.Game.Referee) continue; if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.Game.Referee) continue;
p.SendDespawn(pl.id); p.SendDespawn(pl.id);
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], ""); p.SpawnEntity(pl, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
} }
} }

View File

@ -269,7 +269,7 @@ namespace MCGalaxy.Commands
case "lvl": case "lvl":
case "map": case "map":
case "m": case "m":
if ((CheckAdditionalPerm(p)) if (CheckAdditionalPerm(p))
{ {
foreach (Player who in p.level.players) foreach (Player who in p.level.players)
{ {
@ -289,7 +289,7 @@ namespace MCGalaxy.Commands
case "pls": case "pls":
case "pl": case "pl":
case "p": case "p":
if CheckAdditionalPerm(p)) if (CheckAdditionalPerm(p))
{ {
TntWarsGame gm = TntWarsGame.GetTntWarsGame(p); TntWarsGame gm = TntWarsGame.GetTntWarsGame(p);
if (gm == null) if (gm == null)

View File

@ -74,7 +74,7 @@ namespace MCGalaxy.Commands
if (p.hidden) if (p.hidden)
{ {
if (who != null) if (who != null)
p.SendSpawn(who.id, who.color + who.truename, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); p.SpawnEntity(who, who.id, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
if (!stealth) if (!stealth)
{ {
Command.all.Find("hide").Use(p, ""); Command.all.Find("hide").Use(p, "");
@ -104,7 +104,7 @@ namespace MCGalaxy.Commands
if (p.following != "") if (p.following != "")
{ {
who = PlayerInfo.Find(p.following); who = PlayerInfo.Find(p.following);
p.SendSpawn(who.id, who.color + who.truename, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); p.SpawnEntity(who, who.id, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
} }
who = PlayerInfo.Find(message); who = PlayerInfo.Find(message);
p.following = who.name; p.following = who.name;

View File

@ -144,7 +144,7 @@ namespace MCGalaxy.Commands {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
if (pl.level != p.level || pl.hidden || p == pl) continue; if (pl.level != p.level || pl.hidden || p == pl) continue;
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], ""); p.SpawnEntity(pl, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
} }
Player.GlobalSpawn(p, x, y, z, rotX, rotY, true); Player.GlobalSpawn(p, x, y, z, rotX, rotY, true);

View File

@ -89,7 +89,7 @@ namespace MCGalaxy.Games
ushort y1 = (ushort)((1 + y) * 32); ushort y1 = (ushort)((1 + y) * 32);
ushort z1 = (ushort)((0.5 + z) * 32); ushort z1 = (ushort)((0.5 + z) * 32);
rotx = spawns[rnd].rotx; rotx = spawns[rnd].rotx;
p.SendSpawn(0xFF, p.name, x1, y1, z1, (byte)rotx, 0); p.SpawnEntity(p, 0xFF, x1, y1, z1, (byte)rotx, 0);
//p.health = 100; //p.health = 100;
} }
else else
@ -99,7 +99,7 @@ namespace MCGalaxy.Games
ushort z = (ushort)((0.5 + mapOn.spawnz) * 32); ushort z = (ushort)((0.5 + mapOn.spawnz) * 32);
ushort rotx = mapOn.rotx; ushort rotx = mapOn.rotx;
ushort roty = mapOn.roty; ushort roty = mapOn.roty;
p.SendSpawn(0xFF, p.name, x, y, z, (byte)rotx, (byte)roty); p.SpawnEntity(p, 0xFF, x, y, z, (byte)rotx, (byte)roty);
} }
//p.spawning = false; //p.spawning = false;
} }

View File

@ -65,7 +65,7 @@ namespace MCGalaxy.Games {
player.SendMessage("Sending you to the correct map."); player.SendMessage("Sending you to the correct map.");
Command.all.Find("goto").Use(player, mapon.name); Command.all.Find("goto").Use(player, mapon.name);
} }
player.SendSpawn(0xFF, player.color + player.truename, x1, y1, z1, (byte)0, (byte)0); p.SpawnEntity(p, 0xFF, x1, y1, z1, 0, 0);
} }
squaresLeft.Clear(); squaresLeft.Clear();

View File

@ -475,27 +475,30 @@ namespace MCGalaxy {
if ((p.hidden || p.Game.Referee) && !self) continue; if ((p.hidden || p.Game.Referee) && !self) continue;
if (p != other) { if (p != other) {
SpawnEntity(p, other, p.id, x, y, z, rotx, roty, possession); other.SpawnEntity(p, p.id, x, y, z, rotx, roty, possession);
} else if (self) { } else if (self) {
other.pos = new ushort[3] { x, y, z }; other.rot = new byte[2] { rotx, roty }; other.pos = new ushort[3] { x, y, z }; other.rot = new byte[2] { rotx, roty };
other.oldpos = other.pos; other.basepos = other.pos; other.oldrot = other.rot; other.oldpos = other.pos; other.basepos = other.pos; other.oldrot = other.rot;
SpawnEntity(p, other, 0xFF, x, y, z, rotx, roty, possession); other.SpawnEntity(other, 0xFF, x, y, z, rotx, roty, possession);
} }
} }
} }
internal static void SpawnEntity(Player p, Player dst, byte id, ushort x, ushort y, ushort z, internal void SpawnEntity(Player p, byte id, ushort x, ushort y, ushort z,
byte rotx, byte roty, string possession = "") { byte rotx, byte roty, string possession = "") {
if (!Server.zombie.Running || !p.Game.Infected) { if (!Server.zombie.Running || !p.Game.Infected) {
dst.SendSpawn(id, p.color + p.truename + possession, x, y, z, rotx, roty); return; string col = p.color;
if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !HasCpeExt(CpeExt.TextColors))
col = "&" + Colors.GetFallback(col[1]);
SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty); return;
} }
if (Server.zombie.ZombieName != "" && !dst.Game.Aka) if (Server.zombie.ZombieName != "" && !Game.Aka)
dst.SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty); SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
else else
dst.SendSpawn(id, Colors.red + p.truename + possession, x, y, z, rotx, roty); SendSpawn(id, Colors.red + p.truename + possession, x, y, z, rotx, roty);
if (dst.HasCpeExt(CpeExt.ChangeModel) && id != 0xFF) if (HasCpeExt(CpeExt.ChangeModel) && id != 0xFF)
dst.SendChangeModel(id, "zombie"); SendChangeModel(id, "zombie");
} }
public static void GlobalDespawn(Player p, bool self) { public static void GlobalDespawn(Player p, bool self) {