From 9869fbfde5ac1519a3e6255307eebf0352bcc5ff Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 27 Jul 2018 01:02:41 +1000 Subject: [PATCH] fix C client not compiling on linux (oops) --- ClassicalSharp/Entities/LocationUpdate.cs | 121 ++++++++++------------ ClassicalSharp/Network/Protocols/CPE.cs | 2 +- src/Client/Entity.c | 4 - src/Client/Entity.h | 1 - src/Client/NixPlatform.c | 6 +- src/Client/PacketHandlers.c | 2 +- src/Client/WinWindow.c | 2 +- 7 files changed, 63 insertions(+), 75 deletions(-) diff --git a/ClassicalSharp/Entities/LocationUpdate.cs b/ClassicalSharp/Entities/LocationUpdate.cs index 0833930f8..d773cdd8f 100644 --- a/ClassicalSharp/Entities/LocationUpdate.cs +++ b/ClassicalSharp/Entities/LocationUpdate.cs @@ -1,65 +1,58 @@ -// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 -using System; -using OpenTK; - -namespace ClassicalSharp.Entities { - - public static class LocationUpdateFlag { - public const byte Pos = 0x01; - public const byte HeadX = 0x02; - public const byte HeadY = 0x04; - public const byte RotX = 0x08; - public const byte RotZ = 0x10; - } - - public struct LocationUpdate { - public Vector3 Pos; - public float HeadX, HeadY, RotX, RotZ; - public byte Flags; - /// True if position is relative to the last position received from server - public bool RelativePos; - - public static float Clamp(float degrees) { - // Make sure angle is in [0, 360) - degrees = degrees % 360; - if (degrees < 0) degrees += 360; - return degrees; - } - - const float NaN = float.NaN; - - /// Constructs a location update that does not have any position or orientation information. - public static LocationUpdate Empty() { - return default(LocationUpdate); - } - - /// Constructs a location update that only consists of orientation information. - public static LocationUpdate MakeOri(float rotY, float headX) { - LocationUpdate update = default(LocationUpdate); - update.Flags = LocationUpdateFlag.HeadX | LocationUpdateFlag.HeadY; - update.HeadX = Clamp(headX); - update.HeadY = Clamp(rotY); - return update; - } - - /// Constructs a location update that only consists of position information. - public static LocationUpdate MakePos(Vector3 pos, bool rel) { - LocationUpdate update = default(LocationUpdate); - update.Flags = LocationUpdateFlag.Pos; - update.Pos = pos; - update.RelativePos = rel; - return update; - } - - /// Constructs a location update that consists of position and orientation information. - public static LocationUpdate MakePosAndOri(Vector3 pos, float rotY, float headX, bool rel) { - LocationUpdate update = default(LocationUpdate); - update.Flags = LocationUpdateFlag.Pos | LocationUpdateFlag.HeadX | LocationUpdateFlag.HeadY; - update.HeadX = Clamp(headX); - update.HeadY = Clamp(rotY); - update.Pos = pos; - update.RelativePos = rel; - return update; - } - } +// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 +using System; +using OpenTK; + +namespace ClassicalSharp.Entities { + + public static class LocationUpdateFlag { + public const byte Pos = 0x01; + public const byte HeadX = 0x02; + public const byte HeadY = 0x04; + public const byte RotX = 0x08; + public const byte RotZ = 0x10; + } + + public struct LocationUpdate { + public Vector3 Pos; + public float HeadX, HeadY, RotX, RotZ; + public byte Flags; + /// True if position is relative to the last position received from server + public bool RelativePos; + + public static float Clamp(float degrees) { + // Make sure angle is in [0, 360) + degrees = degrees % 360; + if (degrees < 0) degrees += 360; + return degrees; + } + + /// Constructs a location update that only consists of orientation information. + public static LocationUpdate MakeOri(float rotY, float headX) { + LocationUpdate update = default(LocationUpdate); + update.Flags = LocationUpdateFlag.HeadX | LocationUpdateFlag.HeadY; + update.HeadX = Clamp(headX); + update.HeadY = Clamp(rotY); + return update; + } + + /// Constructs a location update that only consists of position information. + public static LocationUpdate MakePos(Vector3 pos, bool rel) { + LocationUpdate update = default(LocationUpdate); + update.Flags = LocationUpdateFlag.Pos; + update.Pos = pos; + update.RelativePos = rel; + return update; + } + + /// Constructs a location update that consists of position and orientation information. + public static LocationUpdate MakePosAndOri(Vector3 pos, float rotY, float headX, bool rel) { + LocationUpdate update = default(LocationUpdate); + update.Flags = LocationUpdateFlag.Pos | LocationUpdateFlag.HeadX | LocationUpdateFlag.HeadY; + update.HeadX = Clamp(headX); + update.HeadY = Clamp(rotY); + update.Pos = pos; + update.RelativePos = rel; + return update; + } + } } \ No newline at end of file diff --git a/ClassicalSharp/Network/Protocols/CPE.cs b/ClassicalSharp/Network/Protocols/CPE.cs index a4ede5722..018977b30 100644 --- a/ClassicalSharp/Network/Protocols/CPE.cs +++ b/ClassicalSharp/Network/Protocols/CPE.cs @@ -377,7 +377,7 @@ namespace ClassicalSharp.Network.Protocols { Entity entity = game.Entities.List[id]; if (entity == null) return; - LocationUpdate update = LocationUpdate.Empty(); + LocationUpdate update = default(LocationUpdate); switch (type) { case 0: diff --git a/src/Client/Entity.c b/src/Client/Entity.c index 499e22e59..9e7fc58d9 100644 --- a/src/Client/Entity.c +++ b/src/Client/Entity.c @@ -32,10 +32,6 @@ Real32 LocationUpdate_Clamp(Real32 degrees) { } struct LocationUpdate loc_empty; -void LocationUpdate_Empty(struct LocationUpdate* update) { - *update = loc_empty; -} - void LocationUpdate_MakeOri(struct LocationUpdate* update, Real32 rotY, Real32 headX) { *update = loc_empty; update->Flags = LOCATIONUPDATE_FLAG_HEADX | LOCATIONUPDATE_FLAG_HEADY; diff --git a/src/Client/Entity.h b/src/Client/Entity.h index c883ba85b..ff3e63e1a 100644 --- a/src/Client/Entity.h +++ b/src/Client/Entity.h @@ -49,7 +49,6 @@ struct LocationUpdate { /* Clamps the given angle so it lies between [0, 360). */ Real32 LocationUpdate_Clamp(Real32 degrees); -void LocationUpdate_Empty(struct LocationUpdate* update); void LocationUpdate_MakeOri(struct LocationUpdate* update, Real32 rotY, Real32 headX); void LocationUpdate_MakePos(struct LocationUpdate* update, Vector3 pos, bool rel); void LocationUpdate_MakePosAndOri(struct LocationUpdate* update, Vector3 pos, Real32 rotY, Real32 headX, bool rel); diff --git a/src/Client/NixPlatform.c b/src/Client/NixPlatform.c index a636951e4..3fc5680bc 100644 --- a/src/Client/NixPlatform.c +++ b/src/Client/NixPlatform.c @@ -48,9 +48,9 @@ static void Platform_InitDisplay(void) { /* TODO: Use Xinerama and XRandR for querying these */ struct DisplayDevice device = { 0 }; - device.BoundsWidth = DisplayWidth(display, screen); - device.Bounds.Height = DisplayHeight(display, screen); - device.BitsPerPixel = DefaultDepth(display, screen); + device.Bounds.Width = DisplayWidth(display, screen); + device.Bounds.Height = DisplayHeight(display, screen); + device.BitsPerPixel = DefaultDepth(display, screen); DisplayDevice_Default = device; DisplayDevice_Meta[0] = display; diff --git a/src/Client/PacketHandlers.c b/src/Client/PacketHandlers.c index eafbd0466..659ef05f3 100644 --- a/src/Client/PacketHandlers.c +++ b/src/Client/PacketHandlers.c @@ -1102,7 +1102,7 @@ static void CPE_SetEntityProperty(struct Stream* stream) { struct Entity* entity = Entities_List[id]; if (!entity) return; - struct LocationUpdate update; LocationUpdate_Empty(&update); + struct LocationUpdate update = { 0 }; Real32 scale; switch (type) { diff --git a/src/Client/WinWindow.c b/src/Client/WinWindow.c index 5fdb54839..70e08dd88 100644 --- a/src/Client/WinWindow.c +++ b/src/Client/WinWindow.c @@ -447,7 +447,7 @@ void Window_GetClipboardText(STRING_TRANSIENT String* value) { if (!hGlobal) { CloseClipboard(); return; } LPVOID src = GlobalLock(hGlobal); - UInt8 c; + UChar c; if (isUnicode) { UInt16* text = (UInt16*)src; for (; *text; text++) {