From 9ae9329b7e5600875e2b92d75f708c044f533552 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 24 Aug 2017 15:04:46 +1000 Subject: [PATCH] Fix backspace from last two commits --- ClassicalSharp/Utils/Utils.cs | 7 +++- src/Client/AnimatedComp.h | 1 + src/Client/Client.vcxproj | 3 +- src/Client/Client.vcxproj.filters | 9 ++--- src/Client/{LocationUpdate.c => Entity.c} | 36 +++++++++++++++-- src/Client/Entity.h | 33 +++++++++++++++- src/Client/LocationUpdate.h | 48 ----------------------- 7 files changed, 74 insertions(+), 63 deletions(-) rename src/Client/{LocationUpdate.c => Entity.c} (57%) delete mode 100644 src/Client/LocationUpdate.h diff --git a/ClassicalSharp/Utils/Utils.cs b/ClassicalSharp/Utils/Utils.cs index 376f0ad3a..1953c7b96 100644 --- a/ClassicalSharp/Utils/Utils.cs +++ b/ClassicalSharp/Utils/Utils.cs @@ -185,8 +185,11 @@ namespace ClassicalSharp { "█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\u00a0"; public static bool IsValidInputChar(char c, bool supportsCP437) { - bool isCP437 = UnicodeToCP437(c) != c; - return supportsCP437 || !isCP437; + if (c == '?') return true; + byte cp437 = UnicodeToCP437(c); + if (cp437 == '?') return false; // not code page 437 + + return supportsCP437 || (cp437 == c); } public static byte UnicodeToCP437(char c) { diff --git a/src/Client/AnimatedComp.h b/src/Client/AnimatedComp.h index 4318e2537..0d3248fa1 100644 --- a/src/Client/AnimatedComp.h +++ b/src/Client/AnimatedComp.h @@ -31,4 +31,5 @@ void AnimatedComp_DoTilt(Real32* tilt, bool reduce); static void AnimatedComp_CalcHumanAnim(AnimatedComp* anim, Real32 idleXRot, Real32 idleZRot); static void AnimatedComp_PerpendicularAnim(AnimatedComp* anim, Real32 flapSpeed, Real32 idleXRot, Real32 idleZRot, bool left); +#endif #endif \ No newline at end of file diff --git a/src/Client/Client.vcxproj b/src/Client/Client.vcxproj index 1e8e4d747..f7f2cf90b 100644 --- a/src/Client/Client.vcxproj +++ b/src/Client/Client.vcxproj @@ -207,7 +207,6 @@ - @@ -279,7 +278,7 @@ - + diff --git a/src/Client/Client.vcxproj.filters b/src/Client/Client.vcxproj.filters index c28bd14f4..c06d1032b 100644 --- a/src/Client/Client.vcxproj.filters +++ b/src/Client/Client.vcxproj.filters @@ -345,9 +345,6 @@ Header Files\Rendering\Map - - Header Files\Entities - Header Files\Entities\Model @@ -521,9 +518,6 @@ Source Files\Rendering\Map - - Source Files\Entities - Source Files\Math @@ -569,5 +563,8 @@ Source Files\Entities\Model + + Source Files\Entities + \ No newline at end of file diff --git a/src/Client/LocationUpdate.c b/src/Client/Entity.c similarity index 57% rename from src/Client/LocationUpdate.c rename to src/Client/Entity.c index d15c7d822..d7fc74dca 100644 --- a/src/Client/LocationUpdate.c +++ b/src/Client/Entity.c @@ -1,6 +1,8 @@ #if 0 -#include "LocationUpdate.h" +#include "Entity.h" #include "ExtMath.h" +#include "World.h" +#include "Block.h" Real32 LocationUpdate_Clamp(Real32 degrees) { degrees = Math_Mod(degrees, 360.0f); @@ -19,7 +21,6 @@ void LocationUpdate_Construct(LocationUpdate* update, Real32 x, Real32 y, Real32 update->RelativePosition = relPos; } - #define exc LocationUpdate_Excluded void LocationUpdate_Empty(LocationUpdate* update) { LocationUpdate_Construct(update, 0.0f, 0.0f, 0.0f, exc, exc, exc, exc, false, false); @@ -33,8 +34,35 @@ void LocationUpdate_MakePos(LocationUpdate* update, Vector3 pos, bool rel) { LocationUpdate_Construct(update, pos.X, pos.Y, pos.Z, exc, exc, exc, exc, true, rel); } -void LocationUpdate_MakePosAndOri(LocationUpdate* update, Vector3 pos, - Real32 rotY, Real32 headX, bool rel) { +void LocationUpdate_MakePosAndOri(LocationUpdate* update, Vector3 pos, Real32 rotY, Real32 headX, bool rel) { LocationUpdate_Construct(update, pos.X, pos.Y, pos.Z, exc, rotY, exc, headX, true, rel); } + +bool Entity_TouchesAny(AABB* bounds, TouchesAny_Condition condition) { + Vector3I bbMin, bbMax; + Vector3I_Floor(&bbMin, &bounds->Min); + Vector3I_Floor(&bbMax, &bounds->Max); + AABB blockBB; + Vector3 v; + + /* Order loops so that we minimise cache misses */ + for (Int32 y = bbMin.Y; y <= bbMax.Y; y++) { + v.Y = (Real32)y; + for (Int32 z = bbMin.Z; z <= bbMax.Z; z++) { + v.Z = (Real32)z; + for (Int32 x = bbMin.X; x <= bbMax.X; x++) { + if (!World_IsValidPos(x, y, z)) continue; + v.X = (Real32)x; + + BlockID block = World_GetBlock(x, y, z); + Vector3_Add(&blockBB.Min, &v, &Block_MinBB[block]); + Vector3_Add(&blockBB.Max, &v, &Block_MaxBB[block]); + + if (!AABB_Intersects(&blockBB, bounds)) continue; + if (condition(block)) return true; + } + } + } + return false; +} #endif \ No newline at end of file diff --git a/src/Client/Entity.h b/src/Client/Entity.h index f73d099f2..c55c5be11 100644 --- a/src/Client/Entity.h +++ b/src/Client/Entity.h @@ -13,8 +13,39 @@ /* Constant offset used to avoid floating point roundoff errors. */ #define Entity_Adjustment 0.001f +/* Constant value specifying an angle is not included in an orientation update. */ +#define LocationUpdate_Excluded -100000.31415926535f -typedef bool(*TouchesAny_Condition)(BlockID block); +typedef bool (*TouchesAny_Condition)(BlockID block); + +/* Represents a location update for an entity. +This can be a relative position, full position, and/or an orientation update. */ +typedef struct LocationUpdate_ { + /* Position of the update (if included). */ + Vector3 Pos; + /* Orientation of the update (if included). If not, has the value of LocationUpdate_Excluded. */ + Real32 RotX, RotY, RotZ, HeadX; + /* Whether this update includes an absolute or relative position. */ + bool IncludesPosition; + /* Whether the positon is absolute, or relative to the last positionreceived from the server. */ + bool RelativePosition; +} LocationUpdate; + +/* Clamps the given angle so it lies between [0, 360). */ +Real32 LocationUpdate_Clamp(Real32 degrees); + +/* Constructs a location update with values for every field. +You should generally prefer using the alternative constructors. */ +void LocationUpdate_Construct(LocationUpdate* update, Real32 x, Real32 y, Real32 z, + Real32 rotX, Real32 rotY, Real32 rotZ, Real32 headX, bool incPos, bool relPos); +/* Constructs a location update that does not have any position or orientation information. */ +void LocationUpdate_Empty(LocationUpdate* update); +/* Constructs a location update that only consists of orientation information. */ +void LocationUpdate_MakeOri(LocationUpdate* update, Real32 rotY, Real32 headX); +/* Constructs a location update that only consists of position information. */ +void LocationUpdate_MakePos(LocationUpdate* update, Vector3 pos, bool rel); +/* Constructs a location update that consists of position and orientation information. */ +void LocationUpdate_MakePosAndOri(LocationUpdate* update, Vector3 pos, Real32 rotY, Real32 headX, bool rel); /* Contains a model, along with position, velocity, and rotation. May also contain other fields and properties. */ diff --git a/src/Client/LocationUpdate.h b/src/Client/LocationUpdate.h deleted file mode 100644 index 48c45e755..000000000 --- a/src/Client/LocationUpdate.h +++ /dev/null @@ -1,48 +0,0 @@ -#if 0 -#ifndef CS_LOCATIONUPDATE_H -#define CS_LOCATIONUPDATE_H -#include "Typedefs.h" -#include "Vectors.h" -/* Represents a location (position and/or orientation) update for an entity. -Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3 -*/ - -/* Stores data that describes either a relative position, -full position, or an orientation update for an entity. */ -typedef struct LocationUpdate_ { - /* Position of the update (if included). */ - Vector3 Pos; - /* Orientation of the update (if included). If not, has the value of LocationUpdate_Excluded. */ - Real32 RotX, RotY, RotZ, HeadX; - /* Whether this update includes an absolute or relative position. */ - bool IncludesPosition; - /* Whether the positon is absolute, or relative to the last positionreceived from the server. */ - bool RelativePosition; -} LocationUpdate; - - -/* Constant value specifying an angle is not included in an orientation update. */ -#define LocationUpdate_Excluded -100000.31415926535f - -/* Clamps the given angle so it lies between [0, 360). */ -Real32 LocationUpdate_Clamp(Real32 degrees); - - -/* Constructs a location update with values for every field. -You should generally prefer using the alternative constructors. */ -void LocationUpdate_Construct(LocationUpdate* update, Real32 x, Real32 y, Real32 z, - Real32 rotX, Real32 rotY, Real32 rotZ, Real32 headX, bool incPos, bool relPos); - -/* Constructs a location update that does not have any position or orientation information. */ -void LocationUpdate_Empty(LocationUpdate* update); - -/* Constructs a location update that only consists of orientation information. */ -void LocationUpdate_MakeOri(LocationUpdate* update, Real32 rotY, Real32 headX); - -/* Constructs a location update that only consists of position information. */ -void LocationUpdate_MakePos(LocationUpdate* update, Vector3 pos, bool rel); - -/* Constructs a location update that consists of position and orientation information. */ -void LocationUpdate_MakePosAndOri(LocationUpdate* update, Vector3 pos, - Real32 rotY, Real32 headX, bool rel); -#endif \ No newline at end of file