mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Implement FastMap CPE extension
This commit is contained in:
parent
76d2196464
commit
5d401d66ce
@ -8,7 +8,7 @@ using OpenTK.Input;
|
|||||||
|
|
||||||
namespace ClassicalSharp.Gui.Screens {
|
namespace ClassicalSharp.Gui.Screens {
|
||||||
// TODO: Hotkey added event for CPE
|
// TODO: Hotkey added event for CPE
|
||||||
public sealed class HotkeyListScreen : FilesScreen {
|
public sealed class HotkeyListScreen : ListScreen {
|
||||||
|
|
||||||
public HotkeyListScreen(Game game) : base(game) {
|
public HotkeyListScreen(Game game) : base(game) {
|
||||||
titleText = "Modify hotkeys";
|
titleText = "Modify hotkeys";
|
||||||
|
@ -5,9 +5,9 @@ using ClassicalSharp.Gui.Widgets;
|
|||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace ClassicalSharp.Gui.Screens {
|
namespace ClassicalSharp.Gui.Screens {
|
||||||
public abstract class FilesScreen : ClickableScreen {
|
public abstract class ListScreen : ClickableScreen {
|
||||||
|
|
||||||
public FilesScreen(Game game) : base(game) {
|
public ListScreen(Game game) : base(game) {
|
||||||
HandlesAllInput = true;
|
HandlesAllInput = true;
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ using OpenTK.Input;
|
|||||||
using BlockID = System.UInt16;
|
using BlockID = System.UInt16;
|
||||||
|
|
||||||
namespace ClassicalSharp.Gui.Screens {
|
namespace ClassicalSharp.Gui.Screens {
|
||||||
public sealed class LoadLevelScreen : FilesScreen {
|
public sealed class LoadLevelScreen : ListScreen {
|
||||||
|
|
||||||
public LoadLevelScreen(Game game) : base(game) {
|
public LoadLevelScreen(Game game) : base(game) {
|
||||||
titleText = "Select a level";
|
titleText = "Select a level";
|
||||||
|
@ -6,7 +6,7 @@ using ClassicalSharp.Textures;
|
|||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace ClassicalSharp.Gui.Screens {
|
namespace ClassicalSharp.Gui.Screens {
|
||||||
public sealed class TexturePackScreen : FilesScreen {
|
public sealed class TexturePackScreen : ListScreen {
|
||||||
|
|
||||||
public TexturePackScreen(Game game) : base(game) {
|
public TexturePackScreen(Game game) : base(game) {
|
||||||
titleText = "Select a texture pack zip";
|
titleText = "Select a texture pack zip";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
|
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>ClassicalSharp</RootNamespace>
|
<RootNamespace>ClassicalSharp</RootNamespace>
|
||||||
<AssemblyName>ClassicalSharp</AssemblyName>
|
<AssemblyName>ClassicalSharp</AssemblyName>
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
@ -84,10 +84,10 @@
|
|||||||
<Compile Include="2D\Drawing\GdiPlusDrawer2D.cs" />
|
<Compile Include="2D\Drawing\GdiPlusDrawer2D.cs" />
|
||||||
<Compile Include="2D\Drawing\IDrawer2D.cs" />
|
<Compile Include="2D\Drawing\IDrawer2D.cs" />
|
||||||
<Compile Include="2D\Screens\ChatScreen.cs" />
|
<Compile Include="2D\Screens\ChatScreen.cs" />
|
||||||
<Compile Include="2D\Screens\ClickableScreen.cs" />
|
|
||||||
<Compile Include="2D\Screens\DeathScreen.cs" />
|
<Compile Include="2D\Screens\DeathScreen.cs" />
|
||||||
<Compile Include="2D\Screens\DisconnectScreen.cs" />
|
<Compile Include="2D\Screens\DisconnectScreen.cs" />
|
||||||
<Compile Include="2D\Screens\InventoryScreen.cs" />
|
<Compile Include="2D\Screens\InventoryScreen.cs" />
|
||||||
|
<Compile Include="2D\Screens\Menu\ClickableScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Overlays\Overlay.cs" />
|
<Compile Include="2D\Screens\Overlays\Overlay.cs" />
|
||||||
<Compile Include="2D\Screens\Overlays\TexIdsOverlay.cs" />
|
<Compile Include="2D\Screens\Overlays\TexIdsOverlay.cs" />
|
||||||
<Compile Include="2D\Screens\Overlays\WarningOverlays.cs" />
|
<Compile Include="2D\Screens\Overlays\WarningOverlays.cs" />
|
||||||
@ -97,7 +97,7 @@
|
|||||||
<Compile Include="2D\Screens\Menu\ClassicOptionsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\ClassicOptionsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\EditHotkeyScreen.cs" />
|
<Compile Include="2D\Screens\Menu\EditHotkeyScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\FilesScreen.cs" />
|
<Compile Include="2D\Screens\Menu\ListScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\GenLevelScreen.cs" />
|
<Compile Include="2D\Screens\Menu\GenLevelScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\GraphicsOptionsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\GraphicsOptionsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\GuiOptionsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\GuiOptionsScreen.cs" />
|
||||||
|
@ -15,14 +15,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, extEntityPos, twoWayPing, blockPerms;
|
internal bool needD3Fix, extEntityPos, twoWayPing, blockPerms, fastMap;
|
||||||
Game game;
|
Game game;
|
||||||
|
|
||||||
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; extEntityPos = false; twoWayPing = false;
|
needD3Fix = false; extEntityPos = false; twoWayPing = false; fastMap = false;
|
||||||
game.SupportsCPEBlocks = false;
|
game.SupportsCPEBlocks = false;
|
||||||
NetworkProcessor net = (NetworkProcessor)game.Server;
|
NetworkProcessor net = (NetworkProcessor)game.Server;
|
||||||
net.Reset();
|
net.Reset();
|
||||||
@ -65,6 +65,9 @@ namespace ClassicalSharp.Network {
|
|||||||
net.writer.ExtendedPositions = true;
|
net.writer.ExtendedPositions = true;
|
||||||
} else if (ext == "TwoWayPing") {
|
} else if (ext == "TwoWayPing") {
|
||||||
twoWayPing = true;
|
twoWayPing = true;
|
||||||
|
} else if (ext == "FastMap") {
|
||||||
|
net.packetSizes[Opcode.LevelInit] += 4;
|
||||||
|
fastMap = true;
|
||||||
}
|
}
|
||||||
#if USE16_BIT
|
#if USE16_BIT
|
||||||
else if (ext == "ExtBlocks") {
|
else if (ext == "ExtBlocks") {
|
||||||
@ -93,9 +96,9 @@ namespace ClassicalSharp.Network {
|
|||||||
public static string[] ClientExtensions = new string[] {
|
public static string[] ClientExtensions = new string[] {
|
||||||
"ClickDistance", "CustomBlocks", "HeldBlock", "EmoteFix", "TextHotKey", "ExtPlayerList",
|
"ClickDistance", "CustomBlocks", "HeldBlock", "EmoteFix", "TextHotKey", "ExtPlayerList",
|
||||||
"EnvColors", "SelectionCuboid", "BlockPermissions", "ChangeModel", "EnvMapAppearance",
|
"EnvColors", "SelectionCuboid", "BlockPermissions", "ChangeModel", "EnvMapAppearance",
|
||||||
"EnvWeatherType", "MessageTypes", "HackControl", "PlayerClick", "FullCP437",
|
"EnvWeatherType", "MessageTypes", "HackControl", "PlayerClick", "FullCP437", "LongerMessages",
|
||||||
"LongerMessages", "BlockDefinitions", "BlockDefinitionsExt", "BulkBlockUpdate", "TextColors",
|
"BlockDefinitions", "BlockDefinitionsExt", "BulkBlockUpdate", "TextColors", "EnvMapAspect",
|
||||||
"EnvMapAspect", "EntityProperty", "ExtEntityPositions", "TwoWayPing", "InventoryOrder", "InstantMOTD",
|
"EntityProperty", "ExtEntityPositions", "TwoWayPing", "InventoryOrder", "InstantMOTD", "FastMap",
|
||||||
#if USE16_BIT
|
#if USE16_BIT
|
||||||
"ExtBlocks",
|
"ExtBlocks",
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,7 +67,21 @@ namespace ClassicalSharp.Network.Protocols {
|
|||||||
void HandlePing() { }
|
void HandlePing() { }
|
||||||
|
|
||||||
void HandleLevelInit() {
|
void HandleLevelInit() {
|
||||||
if (gzipStream != null) return;
|
if (gzipStream == null) StartLoadingState();
|
||||||
|
|
||||||
|
// Fast map puts volume in header, doesn't bother with gzip
|
||||||
|
if (net.cpeData.fastMap) {
|
||||||
|
int size = reader.ReadInt32();
|
||||||
|
gzipHeader.done = true;
|
||||||
|
mapSizeIndex = 4;
|
||||||
|
#if USE16_BIT
|
||||||
|
if (reader.ExtendedBlocks) size *= 2;
|
||||||
|
#endif
|
||||||
|
map = new byte[size];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartLoadingState() {
|
||||||
game.World.Reset();
|
game.World.Reset();
|
||||||
game.WorldEvents.RaiseOnNewMap();
|
game.WorldEvents.RaiseOnNewMap();
|
||||||
|
|
||||||
@ -101,7 +115,8 @@ namespace ClassicalSharp.Network.Protocols {
|
|||||||
void HandleLevelDataChunk() {
|
void HandleLevelDataChunk() {
|
||||||
// Workaround for some servers that send LevelDataChunk before LevelInit
|
// Workaround for some servers that send LevelDataChunk before LevelInit
|
||||||
// due to their async packet sending behaviour.
|
// due to their async packet sending behaviour.
|
||||||
if (gzipStream == null) HandleLevelInit();
|
if (gzipStream == null) StartLoadingState();
|
||||||
|
|
||||||
int usedLength = reader.ReadUInt16();
|
int usedLength = reader.ReadUInt16();
|
||||||
gzippedMap.pos = 0;
|
gzippedMap.pos = 0;
|
||||||
gzippedMap.bufferPos = reader.index;
|
gzippedMap.bufferPos = reader.index;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user