fix C client not compiling on linux (oops)

This commit is contained in:
UnknownShadow200 2018-07-27 01:02:41 +10:00
parent 4fcd1d9c2b
commit 9869fbfde5
7 changed files with 63 additions and 75 deletions

View File

@ -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;
/// <summary> True if position is relative to the last position received from server </summary>
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;
/// <summary> Constructs a location update that does not have any position or orientation information. </summary>
public static LocationUpdate Empty() {
return default(LocationUpdate);
}
/// <summary> Constructs a location update that only consists of orientation information. </summary>
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;
}
/// <summary> Constructs a location update that only consists of position information. </summary>
public static LocationUpdate MakePos(Vector3 pos, bool rel) {
LocationUpdate update = default(LocationUpdate);
update.Flags = LocationUpdateFlag.Pos;
update.Pos = pos;
update.RelativePos = rel;
return update;
}
/// <summary> Constructs a location update that consists of position and orientation information. </summary>
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;
/// <summary> True if position is relative to the last position received from server </summary>
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;
}
/// <summary> Constructs a location update that only consists of orientation information. </summary>
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;
}
/// <summary> Constructs a location update that only consists of position information. </summary>
public static LocationUpdate MakePos(Vector3 pos, bool rel) {
LocationUpdate update = default(LocationUpdate);
update.Flags = LocationUpdateFlag.Pos;
update.Pos = pos;
update.RelativePos = rel;
return update;
}
/// <summary> Constructs a location update that consists of position and orientation information. </summary>
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;
}
}
}

View File

@ -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:

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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++) {