mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-10-02 10:22:52 -04:00
Initial work on larger player positions
This commit is contained in:
parent
f9d011af6e
commit
787a6a2a5a
@ -14,13 +14,14 @@ namespace ClassicalSharp.Network {
|
|||||||
internal int ServerExtensionsCount;
|
internal int ServerExtensionsCount;
|
||||||
internal bool sendHeldBlock, useMessageTypes;
|
internal bool sendHeldBlock, useMessageTypes;
|
||||||
internal int envMapVer = 2, blockDefsExtVer = 2;
|
internal int envMapVer = 2, blockDefsExtVer = 2;
|
||||||
internal bool needD3Fix;
|
internal bool needD3Fix, extEntityPos;
|
||||||
|
|
||||||
public void Reset(Game game) {
|
public void Reset(Game game) {
|
||||||
ServerExtensionsCount = 0;
|
ServerExtensionsCount = 0;
|
||||||
sendHeldBlock = false; useMessageTypes = false;
|
sendHeldBlock = false; useMessageTypes = false;
|
||||||
envMapVer = 2; blockDefsExtVer = 2;
|
envMapVer = 2; blockDefsExtVer = 2;
|
||||||
needD3Fix = false; game.UseCPEBlocks = false;
|
needD3Fix = false; extEntityPos = false;
|
||||||
|
game.UseCPEBlocks = false;
|
||||||
|
|
||||||
NetworkProcessor net = (NetworkProcessor)game.Server;
|
NetworkProcessor net = (NetworkProcessor)game.Server;
|
||||||
net.Reset();
|
net.Reset();
|
||||||
@ -51,6 +52,9 @@ namespace ClassicalSharp.Network {
|
|||||||
blockDefsExtVer = version;
|
blockDefsExtVer = version;
|
||||||
if (version == 1) return;
|
if (version == 1) return;
|
||||||
net.packetSizes[(byte)Opcode.CpeDefineBlockExt] = 88;
|
net.packetSizes[(byte)Opcode.CpeDefineBlockExt] = 88;
|
||||||
|
} else if (ext == "ExtEntityPositions") {
|
||||||
|
//extEntityPos = true;
|
||||||
|
// TODO: need to increase packet sizes accordingly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +63,7 @@ namespace ClassicalSharp.Network {
|
|||||||
"EnvColors", "SelectionCuboid", "BlockPermissions", "ChangeModel", "EnvMapAppearance",
|
"EnvColors", "SelectionCuboid", "BlockPermissions", "ChangeModel", "EnvMapAppearance",
|
||||||
"EnvWeatherType", "HackControl", "MessageTypes", "PlayerClick", "FullCP437",
|
"EnvWeatherType", "HackControl", "MessageTypes", "PlayerClick", "FullCP437",
|
||||||
"LongerMessages", "BlockDefinitions", "BlockDefinitionsExt", "BulkBlockUpdate", "TextColors",
|
"LongerMessages", "BlockDefinitions", "BlockDefinitionsExt", "BulkBlockUpdate", "TextColors",
|
||||||
"EnvMapAspect", "EntityProperty",
|
"EnvMapAspect", "EntityProperty", "ExtEntityPositions",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,16 +257,12 @@ namespace ClassicalSharp.Network.Protocols {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void ReadAbsoluteLocation(byte id, bool interpolate) {
|
internal void ReadAbsoluteLocation(byte id, bool interpolate) {
|
||||||
float x = reader.ReadInt16() / 32f;
|
Vector3 P = reader.ReadPosition(id);
|
||||||
float y = (reader.ReadInt16() - 51) / 32f; // We have to do this.
|
|
||||||
if (id == EntityList.SelfID) y += 22/32f;
|
|
||||||
float z = reader.ReadInt16() / 32f;
|
|
||||||
|
|
||||||
float rotY = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
float rotY = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
||||||
float headX = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
float headX = (float)Utils.PackedToDegrees(reader.ReadUInt8());
|
||||||
|
|
||||||
if (id == EntityList.SelfID) net.receivedFirstPosition = true;
|
if (id == EntityList.SelfID) net.receivedFirstPosition = true;
|
||||||
LocationUpdate update = LocationUpdate.MakePosAndOri(x, y, z, rotY, headX, false);
|
LocationUpdate update = LocationUpdate.MakePosAndOri(P, rotY, headX, false);
|
||||||
net.UpdateLocation(id, update, interpolate);
|
net.UpdateLocation(id, update, interpolate);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -287,9 +283,7 @@ namespace ClassicalSharp.Network.Protocols {
|
|||||||
writer.WriteUInt8((byte)Opcode.EntityTeleport);
|
writer.WriteUInt8((byte)Opcode.EntityTeleport);
|
||||||
|
|
||||||
writer.WriteUInt8((byte)payload); // held block when using HeldBlock, otherwise just 255
|
writer.WriteUInt8((byte)payload); // held block when using HeldBlock, otherwise just 255
|
||||||
writer.WriteInt16((short)(pos.X * 32));
|
writer.WritePosition(pos);
|
||||||
writer.WriteInt16((short)((int)(pos.Y * 32) + 51));
|
|
||||||
writer.WriteInt16((short)(pos.Z * 32));
|
|
||||||
writer.WriteUInt8((byte)Utils.DegreesToPacked(rotY));
|
writer.WriteUInt8((byte)Utils.DegreesToPacked(rotY));
|
||||||
writer.WriteUInt8((byte)Utils.DegreesToPacked(headX));
|
writer.WriteUInt8((byte)Utils.DegreesToPacked(headX));
|
||||||
net.SendPacket();
|
net.SendPacket();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using ClassicalSharp.Entities;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace ClassicalSharp.Network {
|
namespace ClassicalSharp.Network {
|
||||||
|
|
||||||
@ -72,6 +74,14 @@ namespace ClassicalSharp.Network {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3 ReadPosition(byte id) {
|
||||||
|
float x = ReadInt16() / 32f;
|
||||||
|
float y = (ReadInt16() - 51) / 32f; // We have to do this.
|
||||||
|
if (id == EntityList.SelfID) y += 22/32f;
|
||||||
|
float z = ReadInt16() / 32f;
|
||||||
|
return new Vector3(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadString() {
|
public string ReadString() {
|
||||||
int length = GetString(Utils.StringLength);
|
int length = GetString(Utils.StringLength);
|
||||||
return new String(characters, 0, length);
|
return new String(characters, 0, length);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace ClassicalSharp.Network {
|
namespace ClassicalSharp.Network {
|
||||||
|
|
||||||
@ -37,6 +38,12 @@ namespace ClassicalSharp.Network {
|
|||||||
index += Utils.StringLength;
|
index += Utils.StringLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WritePosition(Vector3 pos) {
|
||||||
|
WriteInt16((short)(pos.X * 32));
|
||||||
|
WriteInt16((short)((int)(pos.Y * 32) + 51));
|
||||||
|
WriteInt16((short)(pos.Z * 32));
|
||||||
|
}
|
||||||
|
|
||||||
public void WriteUInt8(byte value) {
|
public void WriteUInt8(byte value) {
|
||||||
buffer[index++] = value;
|
buffer[index++] = value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user