Skip to content
Permalink
Browse files

minor code cleanup (LOCATIONUPDATE_FLAG_YAW -> LOCATIONUPDATE_YAW)

  • Loading branch information
UnknownShadow200 committed Dec 1, 2019
1 parent bb30a3a commit 5355bd66ca3b02ea144f41e75d2aea350647de06
Showing with 42 additions and 42 deletions.
  1. +3 −3 src/Entity.c
  2. +5 −5 src/Entity.h
  3. +11 −11 src/EntityComponents.c
  4. +18 −18 src/Game.c
  5. +3 −3 src/Protocol.c
  6. +2 −2 src/World.c
@@ -35,21 +35,21 @@ float LocationUpdate_Clamp(float degrees) {
static struct LocationUpdate loc_empty;
void LocationUpdate_MakeOri(struct LocationUpdate* update, float yaw, float pitch) {
*update = loc_empty;
update->Flags = LOCATIONUPDATE_FLAG_PITCH | LOCATIONUPDATE_FLAG_YAW;
update->Flags = LOCATIONUPDATE_PITCH | LOCATIONUPDATE_YAW;
update->Pitch = LocationUpdate_Clamp(pitch);
update->Yaw = LocationUpdate_Clamp(yaw);
}

void LocationUpdate_MakePos(struct LocationUpdate* update, Vec3 pos, cc_bool rel) {
*update = loc_empty;
update->Flags = LOCATIONUPDATE_FLAG_POS;
update->Flags = LOCATIONUPDATE_POS;
update->Pos = pos;
update->RelativePos = rel;
}

void LocationUpdate_MakePosAndOri(struct LocationUpdate* update, Vec3 pos, float yaw, float pitch, cc_bool rel) {
*update = loc_empty;
update->Flags = LOCATIONUPDATE_FLAG_POS | LOCATIONUPDATE_FLAG_PITCH | LOCATIONUPDATE_FLAG_YAW;
update->Flags = LOCATIONUPDATE_POS | LOCATIONUPDATE_PITCH | LOCATIONUPDATE_YAW;
update->Pitch = LocationUpdate_Clamp(pitch);
update->Yaw = LocationUpdate_Clamp(yaw);
update->Pos = pos;
@@ -30,11 +30,11 @@ extern const char* const ShadowMode_Names[SHADOW_MODE_COUNT];

enum EntityType { ENTITY_TYPE_NONE, ENTITY_TYPE_PLAYER };

#define LOCATIONUPDATE_FLAG_POS 0x01
#define LOCATIONUPDATE_FLAG_PITCH 0x02
#define LOCATIONUPDATE_FLAG_YAW 0x04
#define LOCATIONUPDATE_FLAG_ROTX 0x08
#define LOCATIONUPDATE_FLAG_ROTZ 0x10
#define LOCATIONUPDATE_POS 0x01
#define LOCATIONUPDATE_PITCH 0x02
#define LOCATIONUPDATE_YAW 0x04
#define LOCATIONUPDATE_ROTX 0x08
#define LOCATIONUPDATE_ROTZ 0x10
/* Represents a location update for an entity. Can be a relative position, full position, and/or an orientation update. */
struct LocationUpdate {
Vec3 Pos;
@@ -347,11 +347,11 @@ void NetInterpComp_SetLocation(struct NetInterpComp* interp, struct LocationUpda
struct InterpState* cur = &interp->Cur;
cc_uint8 flags = update->Flags;

if (flags & LOCATIONUPDATE_FLAG_POS) InterpComp_SetPos(cur, update);
if (flags & LOCATIONUPDATE_FLAG_ROTX) cur->RotX = update->RotX;
if (flags & LOCATIONUPDATE_FLAG_ROTZ) cur->RotZ = update->RotZ;
if (flags & LOCATIONUPDATE_FLAG_PITCH) cur->Pitch = update->Pitch;
if (flags & LOCATIONUPDATE_FLAG_YAW) cur->Yaw = update->Yaw;
if (flags & LOCATIONUPDATE_POS) InterpComp_SetPos(cur, update);
if (flags & LOCATIONUPDATE_ROTX) cur->RotX = update->RotX;
if (flags & LOCATIONUPDATE_ROTZ) cur->RotZ = update->RotZ;
if (flags & LOCATIONUPDATE_PITCH) cur->Pitch = update->Pitch;
if (flags & LOCATIONUPDATE_YAW) cur->Yaw = update->Yaw;

if (!interpolate) {
interp->Prev = *cur; interp->PrevRotY = cur->Yaw;
@@ -400,7 +400,7 @@ void LocalInterpComp_SetLocation(struct InterpComp* interp, struct LocationUpdat
cc_uint8 flags = update->Flags;
float yOffset;

if (flags & LOCATIONUPDATE_FLAG_POS) {
if (flags & LOCATIONUPDATE_POS) {
InterpComp_SetPos(next, update);
/* If server sets Y position exactly on ground, push up a tiny bit */
yOffset = next->Pos.Y - Math_Floor(next->Pos.Y);
@@ -409,20 +409,20 @@ void LocalInterpComp_SetLocation(struct InterpComp* interp, struct LocationUpdat
if (!interpolate) { prev->Pos = next->Pos; entity->Position = next->Pos; }
}

if (flags & LOCATIONUPDATE_FLAG_PITCH) {
if (flags & LOCATIONUPDATE_PITCH) {
LocalInterpComp_Angle(&prev->Pitch, &next->Pitch, update->Pitch, interpolate);
}
if (flags & LOCATIONUPDATE_FLAG_YAW) {
if (flags & LOCATIONUPDATE_YAW) {
LocalInterpComp_Angle(&prev->Yaw, &next->Yaw, update->Yaw, interpolate);
}
if (flags & LOCATIONUPDATE_FLAG_ROTX) {
if (flags & LOCATIONUPDATE_ROTX) {
LocalInterpComp_Angle(&prev->RotX, &next->RotX, update->RotX, interpolate);
}
if (flags & LOCATIONUPDATE_FLAG_ROTZ) {
if (flags & LOCATIONUPDATE_ROTZ) {
LocalInterpComp_Angle(&prev->RotZ, &next->RotZ, update->RotZ, interpolate);
}

if (flags & LOCATIONUPDATE_FLAG_YAW) {
if (flags & LOCATIONUPDATE_YAW) {
if (!interpolate) {
interp->NextRotY = update->Yaw;
entity->RotY = update->Yaw;
@@ -281,21 +281,21 @@ static void Game_OnResize(void* obj) {
Gui_Layout();
}

static void Game_OnNewMapCore(void* obj) {
static void HandleOnNewMap(void* obj) {
struct IGameComponent* comp;
for (comp = comps_head; comp; comp = comp->next) {
if (comp->OnNewMap) comp->OnNewMap();
}
}

static void Game_OnNewMapLoadedCore(void* obj) {
static void HandleOnNewMapLoaded(void* obj) {
struct IGameComponent* comp;
for (comp = comps_head; comp; comp = comp->next) {
if (comp->OnNewMapLoaded) comp->OnNewMapLoaded();
}
}

static void Game_TextureChangedCore(void* obj, struct Stream* src, const String* name) {
static void HandleTextureChanged(void* obj, struct Stream* src, const String* name) {
Bitmap bmp;
cc_result res;

@@ -311,7 +311,7 @@ static void Game_TextureChangedCore(void* obj, struct Stream* src, const String*
}
}

static void Game_OnLowVRAMDetected(void* obj) {
static void HandleLowVRAMDetected(void* obj) {
if (Game_UserViewDistance <= 16) Logger_Abort("Out of video memory!");
Game_UserViewDistance /= 2;
Game_UserViewDistance = max(16, Game_UserViewDistance);
@@ -329,7 +329,7 @@ static void Game_WarnFunc(const String* msg) {
}
}

static void Game_ExtractInitialTexturePack(void) {
static void ExtractInitialTexturePack(void) {
String texPack;
Options_Get(OPT_DEFAULT_TEX_PACK, &game_defTexPack, "default.zip");
TexturePack_ExtractZip_File(&defaultZip);
@@ -426,10 +426,10 @@ static void Game_Load(void) {
Game_UpdateDimensions();
Game_LoadOptions();

Event_RegisterVoid(&WorldEvents.NewMap, NULL, Game_OnNewMapCore);
Event_RegisterVoid(&WorldEvents.MapLoaded, NULL, Game_OnNewMapLoadedCore);
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, Game_TextureChangedCore);
Event_RegisterVoid(&GfxEvents.LowVRAMDetected, NULL, Game_OnLowVRAMDetected);
Event_RegisterVoid(&WorldEvents.NewMap, NULL, HandleOnNewMap);
Event_RegisterVoid(&WorldEvents.MapLoaded, NULL, HandleOnNewMapLoaded);
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, HandleTextureChanged);
Event_RegisterVoid(&GfxEvents.LowVRAMDetected, NULL, HandleLowVRAMDetected);

Event_RegisterVoid(&WindowEvents.Resized, NULL, Game_OnResize);
Event_RegisterVoid(&WindowEvents.Closing, NULL, Game_Free);
@@ -476,7 +476,7 @@ static void Game_Load(void) {
if (comp->Init) comp->Init();
}

Game_ExtractInitialTexturePack();
ExtractInitialTexturePack();
entTaskI = ScheduledTask_Add(GAME_DEF_TICKS, Entities_Tick);

/* set vsync after because it causes a context loss depending on backend */
@@ -500,7 +500,7 @@ void Game_SetFpsLimit(int method) {
Gfx_SetFpsLimit(method == FPS_LIMIT_VSYNC, minFrameTime);
}

static void Game_UpdateViewMatrix(void) {
static void UpdateViewMatrix(void) {
Camera.Active->GetView(&Gfx.View);
Gfx_LoadMatrix(MATRIX_VIEW, &Gfx.View);
FrustumCulling_CalcFrustumEquations(&Gfx.Projection, &Gfx.View);
@@ -553,7 +553,7 @@ static void Game_Render3D(double delta, float t) {
if (!Game_HideGui) HeldBlockRenderer_Render(delta);
}

static void Game_DoScheduledTasks(double time) {
static void PerformScheduledTasks(double time) {
struct ScheduledTask task;
int i;

@@ -627,14 +627,14 @@ static void Game_RenderFrame(double delta) {
InputHandler_SetFOV(Game_ZoomFov);
}

Game_DoScheduledTasks(delta);
PerformScheduledTasks(delta);
entTask = Game_Tasks[entTaskI];
t = (float)(entTask.Accumulator / entTask.Interval);
LocalPlayer_SetInterpPosition(t);

Gfx_Clear();
Camera.CurrentPos = Camera.Active->GetPosition(t);
Game_UpdateViewMatrix();
UpdateViewMatrix();

if (!Gui_GetBlocksWorld() && World.Blocks) {
Game_Render3D(delta, t);
@@ -651,10 +651,10 @@ void Game_Free(void* obj) {
struct IGameComponent* comp;
Atlas_Free();

Event_UnregisterVoid(&WorldEvents.NewMap, NULL, Game_OnNewMapCore);
Event_UnregisterVoid(&WorldEvents.MapLoaded, NULL, Game_OnNewMapLoadedCore);
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, Game_TextureChangedCore);
Event_UnregisterVoid(&GfxEvents.LowVRAMDetected, NULL, Game_OnLowVRAMDetected);
Event_UnregisterVoid(&WorldEvents.NewMap, NULL, HandleOnNewMap);
Event_UnregisterVoid(&WorldEvents.MapLoaded, NULL, HandleOnNewMapLoaded);
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, HandleTextureChanged);
Event_UnregisterVoid(&GfxEvents.LowVRAMDetected, NULL, HandleLowVRAMDetected);

Event_UnregisterVoid(&WindowEvents.Resized, NULL, Game_OnResize);
Event_UnregisterVoid(&WindowEvents.Closing, NULL, Game_Free);
@@ -1230,13 +1230,13 @@ static void CPE_SetEntityProperty(cc_uint8* data) {

switch (type) {
case 0:
update.Flags = LOCATIONUPDATE_FLAG_ROTX;
update.Flags = LOCATIONUPDATE_ROTX;
update.RotX = LocationUpdate_Clamp((float)value); break;
case 1:
update.Flags = LOCATIONUPDATE_FLAG_YAW;
update.Flags = LOCATIONUPDATE_YAW;
update.Yaw = LocationUpdate_Clamp((float)value); break;
case 2:
update.Flags = LOCATIONUPDATE_FLAG_ROTZ;
update.Flags = LOCATIONUPDATE_ROTZ;
update.RotZ = LocationUpdate_Clamp((float)value); break;

case 3:
@@ -14,7 +14,7 @@ struct _WorldData World;
/*########################################################################################################################*
*----------------------------------------------------------World----------------------------------------------------------*
*#########################################################################################################################*/
static void World_NewUuid(void) {
static void GenerateNewUuid(void) {
RNGState rnd;
int i;
Random_SeedFromCurrentTime(&rnd);
@@ -63,7 +63,7 @@ void World_SetNewMap(BlockRaw* blocks, int width, int height, int length) {

if (Env.EdgeHeight == -1) { Env.EdgeHeight = height / 2; }
if (Env.CloudsHeight == -1) { Env.CloudsHeight = height + 2; }
World_NewUuid();
GenerateNewUuid();
}

CC_NOINLINE void World_SetDimensions(int width, int height, int length) {

0 comments on commit 5355bd6

Please sign in to comment.
You can’t perform that action at this time.