mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
fix issues when map motds use code page 437
This commit is contained in:
parent
e473598c92
commit
50ca28e74b
@ -74,7 +74,7 @@ namespace MCGalaxy {
|
||||
public static void WriteAscii(string str, byte[] array, int offset) {
|
||||
int count = Math.Min(str.Length, StringSize);
|
||||
for (int i = 0; i < count; i++) {
|
||||
char raw = str[i];
|
||||
char raw = str[i].UnicodeToCp437();
|
||||
array[offset + i] = raw >= '\u0080' ? (byte)'?' : (byte)raw;
|
||||
}
|
||||
for (int i = count; i < StringSize; i++)
|
||||
@ -84,7 +84,7 @@ namespace MCGalaxy {
|
||||
public static void WriteCP437(string str, byte[] array, int offset) {
|
||||
int count = Math.Min(str.Length, StringSize);
|
||||
for (int i = 0; i < count; i++)
|
||||
array[offset + i] = (byte)str[i];
|
||||
array[offset + i] = (byte)str[i].UnicodeToCp437();
|
||||
for (int i = count; i < StringSize; i++)
|
||||
array[offset + i] = (byte)' ';
|
||||
}
|
||||
|
@ -64,5 +64,6 @@ namespace MCGalaxy {
|
||||
public const byte CpeSetTextColor = 39;
|
||||
public const byte CpeSetMapEnvUrl = 40;
|
||||
public const byte CpeSetMapEnvProperty = 41;
|
||||
public const byte CpeSetEntityProperty = 42;
|
||||
}
|
||||
}
|
||||
|
@ -172,5 +172,13 @@ namespace MCGalaxy {
|
||||
NetUtils.WriteI32(value, buffer, 2);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static byte[] EntityProperty(EntityProp prop, int value) {
|
||||
byte[] buffer = new byte[6];
|
||||
buffer[0] = Opcode.CpeSetEntityProperty;
|
||||
buffer[1] = (byte)prop;
|
||||
NetUtils.WriteI32(value, buffer, 2);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,6 @@ namespace MCGalaxy {
|
||||
|
||||
public void SendMessage(byte id, string message, bool colorParse = true) {
|
||||
message = Chat.Format(message, this, colorParse);
|
||||
message.UnicodeToCp437InPlace();
|
||||
|
||||
int totalTries = 0;
|
||||
if (MessageRecieve != null)
|
||||
|
@ -16,33 +16,17 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace MCGalaxy {
|
||||
public partial class Player {
|
||||
public int ClickDistance = 0;
|
||||
public int CustomBlocks = 0;
|
||||
public int HeldBlock = 0;
|
||||
public int TextHotKey = 0;
|
||||
public int ExtPlayerList = 0;
|
||||
public int EnvColors = 0;
|
||||
public int SelectionCuboid = 0;
|
||||
public int BlockPermissions = 0;
|
||||
public int ChangeModel = 0;
|
||||
public int EnvMapAppearance = 0;
|
||||
public int EnvWeatherType = 0;
|
||||
public int HackControl = 0;
|
||||
public int EmoteFix = 0;
|
||||
public int MessageTypes = 0;
|
||||
public int LongerMessages = 0;
|
||||
public int FullCP437 = 0;
|
||||
public int BlockDefinitions = 0;
|
||||
public int BlockDefinitionsExt = 0;
|
||||
public int TextColors = 0;
|
||||
public int BulkBlockUpdate = 0;
|
||||
public int EnvMapAspect = 0;
|
||||
public int PlayerClick = 0;
|
||||
public int ClickDistance, CustomBlocks, HeldBlock, TextHotKey;
|
||||
public int ExtPlayerList, EnvColors, SelectionCuboid, BlockPermissions;
|
||||
public int ChangeModel, EnvMapAppearance, EnvWeatherType, HackControl;
|
||||
public int EmoteFix, MessageTypes, LongerMessages, FullCP437;
|
||||
public int BlockDefinitions, BlockDefinitionsExt, TextColors, BulkBlockUpdate;
|
||||
public int EnvMapAspect, PlayerClick, EntityProperty;
|
||||
|
||||
// these are checked frequently, so avoid overhead of HasCpeExt
|
||||
public bool hasCustomBlocks, hasBlockDefs,
|
||||
hasTextColors, hasChangeModel, hasExtList;
|
||||
|
||||
@ -105,6 +89,8 @@ namespace MCGalaxy {
|
||||
EnvMapAspect = version; break;
|
||||
case CpeExt.PlayerClick:
|
||||
PlayerClick = version; break;
|
||||
case CpeExt.EntityProperty:
|
||||
EntityProperty = version; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,6 +269,7 @@ namespace MCGalaxy {
|
||||
public const string BulkBlockUpdate = "BulkBlockUpdate";
|
||||
public const string EnvMapAspect = "EnvMapAspect";
|
||||
public const string PlayerClick = "PlayerClick";
|
||||
public const string EntityProperty = "EntityProperty";
|
||||
}
|
||||
|
||||
public enum CpeMessageType : byte {
|
||||
@ -296,4 +283,8 @@ namespace MCGalaxy {
|
||||
CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5,
|
||||
WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8,
|
||||
}
|
||||
|
||||
public enum EntityProp : byte {
|
||||
RotX = 0, RotY = 1, RotZ = 2,
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
|
||||
static char Cp437ToUnicode(char c) {
|
||||
public static char Cp437ToUnicode(this char c) {
|
||||
if (c < 0x20) {
|
||||
return FullCP437Handler.ControlCharReplacements[c];
|
||||
} else if (c < 0x7F) {
|
||||
@ -77,7 +77,7 @@ namespace MCGalaxy {
|
||||
return '?';
|
||||
}
|
||||
|
||||
static char UnicodeToCp437(char c) {
|
||||
public static char UnicodeToCp437(this char c) {
|
||||
int cpIndex = 0;
|
||||
if (c >= ' ' && c <= '~') {
|
||||
return c;
|
||||
|
Loading…
x
Reference in New Issue
Block a user