Skip to content

Commit

Permalink
fix 64 bit opengl build in launcher not working
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Mar 12, 2019
1 parent bb110a1 commit 97a3d1b
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 184 deletions.
4 changes: 2 additions & 2 deletions src/BlockPhysics.c
Expand Up @@ -131,8 +131,8 @@ static void Physics_ActivateNeighbours(int x, int y, int z, int index) {

static bool Physics_IsEdgeWater(int x, int y, int z) {
return
(Env_EdgeBlock == BLOCK_WATER || Env_EdgeBlock == BLOCK_STILL_WATER)
&& (y >= Env_SidesHeight && y < Env_EdgeHeight)
(Env.EdgeBlock == BLOCK_WATER || Env.EdgeBlock == BLOCK_STILL_WATER)
&& (y >= Env_SidesHeight && y < Env.EdgeHeight)
&& (x == 0 || z == 0 || x == World.MaxX || z == World.MaxZ);
}

Expand Down
30 changes: 15 additions & 15 deletions src/Builder.c
Expand Up @@ -538,17 +538,17 @@ static PackedCol Normal_LightCol(int x, int y, int z, Face face, BlockID block)

switch (face) {
case FACE_XMIN:
return x < offset ? Env_SunXSide : Lighting_Col_XSide_Fast(x - offset, y, z);
return x < offset ? Env.SunXSide : Lighting_Col_XSide_Fast(x - offset, y, z);
case FACE_XMAX:
return x > (World.MaxX - offset) ? Env_SunXSide : Lighting_Col_XSide_Fast(x + offset, y, z);
return x > (World.MaxX - offset) ? Env.SunXSide : Lighting_Col_XSide_Fast(x + offset, y, z);
case FACE_ZMIN:
return z < offset ? Env_SunZSide : Lighting_Col_ZSide_Fast(x, y, z - offset);
return z < offset ? Env.SunZSide : Lighting_Col_ZSide_Fast(x, y, z - offset);
case FACE_ZMAX:
return z > (World.MaxZ - offset) ? Env_SunZSide : Lighting_Col_ZSide_Fast(x, y, z + offset);
return z > (World.MaxZ - offset) ? Env.SunZSide : Lighting_Col_ZSide_Fast(x, y, z + offset);
case FACE_YMIN:
return y <= 0 ? Env_SunYMin : Lighting_Col_YMin_Fast(x, y - offset, z);
return y <= 0 ? Env.SunYMin : Lighting_Col_YMin_Fast(x, y - offset, z);
case FACE_YMAX:
return y >= World.MaxY ? Env_SunCol : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
return y >= World.MaxY ? Env.SunCol : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
}
return invalid; /* should never happen */
}
Expand Down Expand Up @@ -675,7 +675,7 @@ static void NormalBuilder_RenderBlock(int index) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];

col = fullBright ? white :
Builder_X >= offset ? Lighting_Col_XSide_Fast(Builder_X - offset, Builder_Y, Builder_Z) : Env_SunXSide;
Builder_X >= offset ? Lighting_Col_XSide_Fast(Builder_X - offset, Builder_Y, Builder_Z) : Env.SunXSide;
Drawer_XMin(count_XMin, col, loc, &part->fVertices[FACE_XMIN]);
}

Expand All @@ -685,7 +685,7 @@ static void NormalBuilder_RenderBlock(int index) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];

col = fullBright ? white :
Builder_X <= (World.MaxX - offset) ? Lighting_Col_XSide_Fast(Builder_X + offset, Builder_Y, Builder_Z) : Env_SunXSide;
Builder_X <= (World.MaxX - offset) ? Lighting_Col_XSide_Fast(Builder_X + offset, Builder_Y, Builder_Z) : Env.SunXSide;
Drawer_XMax(count_XMax, col, loc, &part->fVertices[FACE_XMAX]);
}

Expand All @@ -695,7 +695,7 @@ static void NormalBuilder_RenderBlock(int index) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];

col = fullBright ? white :
Builder_Z >= offset ? Lighting_Col_ZSide_Fast(Builder_X, Builder_Y, Builder_Z - offset) : Env_SunZSide;
Builder_Z >= offset ? Lighting_Col_ZSide_Fast(Builder_X, Builder_Y, Builder_Z - offset) : Env.SunZSide;
Drawer_ZMin(count_ZMin, col, loc, &part->fVertices[FACE_ZMIN]);
}

Expand All @@ -705,7 +705,7 @@ static void NormalBuilder_RenderBlock(int index) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];

col = fullBright ? white :
Builder_Z <= (World.MaxZ - offset) ? Lighting_Col_ZSide_Fast(Builder_X, Builder_Y, Builder_Z + offset) : Env_SunZSide;
Builder_Z <= (World.MaxZ - offset) ? Lighting_Col_ZSide_Fast(Builder_X, Builder_Y, Builder_Z + offset) : Env.SunZSide;
Drawer_ZMax(count_ZMax, col, loc, &part->fVertices[FACE_ZMAX]);
}

Expand Down Expand Up @@ -1221,10 +1221,10 @@ static void Adv_PreStretchTiles(int x1, int y1, int z1) {
adv_bitFlags = Builder_BitFlags;

for (i = 0; i <= 4; i++) {
adv_lerp[i] = PackedCol_Lerp(Env_ShadowCol, Env_SunCol, i / 4.0f);
adv_lerpX[i] = PackedCol_Lerp(Env_ShadowXSide, Env_SunXSide, i / 4.0f);
adv_lerpZ[i] = PackedCol_Lerp(Env_ShadowZSide, Env_SunZSide, i / 4.0f);
adv_lerpY[i] = PackedCol_Lerp(Env_ShadowYMin, Env_SunYMin, i / 4.0f);
adv_lerp[i] = PackedCol_Lerp(Env.ShadowCol, Env.SunCol, i / 4.0f);
adv_lerpX[i] = PackedCol_Lerp(Env.ShadowXSide, Env.SunXSide, i / 4.0f);
adv_lerpZ[i] = PackedCol_Lerp(Env.ShadowZSide, Env.SunZSide, i / 4.0f);
adv_lerpY[i] = PackedCol_Lerp(Env.ShadowYMin, Env.SunYMin, i / 4.0f);
}
}

Expand Down Expand Up @@ -1263,5 +1263,5 @@ void Builder_Init(void) {

void Builder_OnNewMapLoaded(void) {
Builder_SidesLevel = max(0, Env_SidesHeight);
Builder_EdgeLevel = max(0, Env_EdgeHeight);
Builder_EdgeLevel = max(0, Env.EdgeHeight);
}
2 changes: 1 addition & 1 deletion src/Entity.c
Expand Up @@ -63,7 +63,7 @@ void LocationUpdate_MakePosAndOri(struct LocationUpdate* update, Vector3 pos, fl
static PackedCol Entity_GetCol(struct Entity* e) {
Vector3 eyePos = Entity_GetEyePosition(e);
Vector3I pos; Vector3I_Floor(&pos, &eyePos);
return World_Contains(pos.X, pos.Y, pos.Z) ? Lighting_Col(pos.X, pos.Y, pos.Z) : Env_SunCol;
return World_Contains(pos.X, pos.Y, pos.Z) ? Lighting_Col(pos.X, pos.Y, pos.Z) : Env.SunCol;
}

void Entity_Init(struct Entity* e) {
Expand Down
8 changes: 4 additions & 4 deletions src/EntityComponents.c
Expand Up @@ -570,10 +570,10 @@ static bool ShadowComponent_GetBlocks(struct Entity* e, int x, int y, int z, str
for (i = 0; y >= 0 && i < 4; y--) {
if (!outside) {
block = World_GetBlock(x, y, z);
} else if (y == Env_EdgeHeight - 1) {
block = Blocks.Draw[Env_EdgeBlock] == DRAW_GAS ? BLOCK_AIR : BLOCK_BEDROCK;
} else if (y == Env.EdgeHeight - 1) {
block = Blocks.Draw[Env.EdgeBlock] == DRAW_GAS ? BLOCK_AIR : BLOCK_BEDROCK;
} else if (y == Env_SidesHeight - 1) {
block = Blocks.Draw[Env_SidesBlock] == DRAW_GAS ? BLOCK_AIR : BLOCK_BEDROCK;
block = Blocks.Draw[Env.SidesBlock] == DRAW_GAS ? BLOCK_AIR : BLOCK_BEDROCK;
} else {
block = BLOCK_AIR;
}
Expand All @@ -593,7 +593,7 @@ static bool ShadowComponent_GetBlocks(struct Entity* e, int x, int y, int z, str
}

if (i < 4) {
cur->Block = Env_EdgeBlock; cur->Y = 0.0f;
cur->Block = Env.EdgeBlock; cur->Y = 0.0f;
ShadowComponent_CalcAlpha(posY, cur);
i++; cur++;
}
Expand Down
56 changes: 28 additions & 28 deletions src/EnvRenderer.c
Expand Up @@ -61,7 +61,7 @@ static void EnvRenderer_CalcFog(float* density, PackedCol* col) {
*density = 0.0f;
/* Blend fog and sky together */
blend = EnvRenderer_BlendFactor((float)Game_ViewDistance);
*col = PackedCol_Lerp(Env_FogCol, Env_SkyCol, blend);
*col = PackedCol_Lerp(Env.FogCol, Env.SkyCol, blend);
}
}

Expand All @@ -88,7 +88,7 @@ static void EnvRenderer_UpdateFogNormal(float fogDensity, PackedCol fogCol) {
if (fogDensity != 0.0f) {
Gfx_SetFogMode(FOG_EXP);
Gfx_SetFogDensity(fogDensity);
} else if (Env_ExpFog) {
} else if (Env.ExpFog) {
Gfx_SetFogMode(FOG_EXP);
/* f = 1-z/end f = e^(-dz)
solve for f = 0.01 gives:
Expand Down Expand Up @@ -132,8 +132,8 @@ void EnvRenderer_RenderClouds(double deltaTime) {
float offset;
struct Matrix m;

if (!clouds_vb || Env_CloudsHeight < -2000) return;
offset = (float)(Game.Time / 2048.0f * 0.6f * Env_CloudsSpeed);
if (!clouds_vb || Env.CloudsHeight < -2000) return;
offset = (float)(Game.Time / 2048.0f * 0.6f * Env.CloudsSpeed);

m = Matrix_Identity; m.Row3.X = offset; /* translate X axis */
Gfx_LoadMatrix(MATRIX_TEXTURE, &m);
Expand All @@ -157,7 +157,7 @@ static void EnvRenderer_DrawCloudsY(int x1, int z1, int x2, int z2, int y, Verte
float offset = (float)Math_CeilDiv(-x1, 2048);

VertexP3fT2fC4b v;
v.Y = (float)y + 0.1f; v.Col = Env_CloudsCol;
v.Y = (float)y + 0.1f; v.Col = Env.CloudsCol;

for (; x1 < endX; x1 += axisSize) {
x2 = x1 + axisSize;
Expand Down Expand Up @@ -197,7 +197,7 @@ static void EnvRenderer_UpdateClouds(void) {
ptr = Mem_Alloc(clouds_vertices, sizeof(VertexP3fT2fC4b), "temp clouds vertices");
}

EnvRenderer_DrawCloudsY(x1, z1, x2, z2, Env_CloudsHeight, ptr);
EnvRenderer_DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, ptr);
clouds_vb = Gfx_CreateVb(ptr, VERTEX_FORMAT_P3FT2FC4B, clouds_vertices);

if (clouds_vertices > ENV_SMALL_VERTICES) Mem_Free(ptr);
Expand Down Expand Up @@ -238,7 +238,7 @@ void EnvRenderer_RenderSky(double deltaTime) {
static void EnvRenderer_DrawSkyY(int x1, int z1, int x2, int z2, int y, VertexP3fC4b* vertices) {
int endX = x2, endZ = z2, startZ = z1, axisSize = EnvRenderer_AxisSize();
VertexP3fC4b v;
v.Y = (float)y; v.Col = Env_SkyCol;
v.Y = (float)y; v.Col = Env.SkyCol;

for (; x1 < endX; x1 += axisSize) {
x2 = x1 + axisSize;
Expand Down Expand Up @@ -276,7 +276,7 @@ static void EnvRenderer_UpdateSky(void) {
ptr = Mem_Alloc(sky_vertices, sizeof(VertexP3fC4b), "temp sky vertices");
}

height = max((World.Height + 2), Env_CloudsHeight) + 6;
height = max((World.Height + 2), Env.CloudsHeight) + 6;
EnvRenderer_DrawSkyY(x1, z1, x2, z2, height, ptr);
sky_vb = Gfx_CreateVb(ptr, VERTEX_FORMAT_P3FC4B, sky_vertices);

Expand Down Expand Up @@ -304,8 +304,8 @@ void EnvRenderer_RenderSkybox(double deltaTime) {
/* Base skybox rotation */
m = Matrix_Identity;
rotTime = (float)(Game.Time * 2 * MATH_PI); /* So speed of 1 rotates whole skybox every second */
Matrix_RotateY(&rotY, Env_SkyboxHorSpeed * rotTime); Matrix_MulBy(&m, &rotY);
Matrix_RotateX(&rotX, Env_SkyboxVerSpeed * rotTime); Matrix_MulBy(&m, &rotX);
Matrix_RotateY(&rotY, Env.SkyboxHorSpeed * rotTime); Matrix_MulBy(&m, &rotY);
Matrix_RotateX(&rotX, Env.SkyboxVerSpeed * rotTime); Matrix_MulBy(&m, &rotX);

/* Rotate around camera */
pos = Camera.CurrentPos;
Expand Down Expand Up @@ -349,7 +349,7 @@ static void EnvRenderer_UpdateSkybox(void) {
Gfx_DeleteVb(&skybox_vb);
if (EnvRenderer_Minimal) return;

for (i = 0; i < SKYBOX_COUNT; i++) { vertices[i].Col = Env_SkyboxCol; }
for (i = 0; i < SKYBOX_COUNT; i++) { vertices[i].Col = Env.SkyboxCol; }
skybox_vb = Gfx_CreateVb(vertices, VERTEX_FORMAT_P3FT2FC4B, SKYBOX_COUNT);
}

Expand Down Expand Up @@ -406,7 +406,7 @@ static int EnvRenderer_CalcRainHeightAt(int x, int maxY, int z, int hIndex) {
static float EnvRenderer_RainHeight(int x, int z) {
int hIndex, height;
int y;
if (!World_ContainsXZ(x, z)) return (float)Env_EdgeHeight;
if (!World_ContainsXZ(x, z)) return (float)Env.EdgeHeight;

hIndex = Weather_Pack(x, z);
height = Weather_Heightmap[hIndex];
Expand Down Expand Up @@ -441,7 +441,7 @@ void EnvRenderer_OnBlockChanged(int x, int y, int z, BlockID oldBlock, BlockID n
static float EnvRenderer_RainAlphaAt(float x) {
/* Wolfram Alpha: fit {0,178},{1,169},{4,147},{9,114},{16,59},{25,9} */
float falloff = 0.05f * x * x - 7 * x;
return 178 + falloff * Env_WeatherFade;
return 178 + falloff * Env.WeatherFade;
}

void EnvRenderer_RenderWeather(double deltaTime) {
Expand All @@ -457,7 +457,7 @@ void EnvRenderer_RenderWeather(double deltaTime) {
float worldV, v1, v2;
float x1,y1,z1, x2,y2,z2;

weather = Env_Weather;
weather = Env.Weather;
if (weather == WEATHER_SUNNY) return;
if (!Weather_Heightmap) EnvRenderer_InitWeatherHeightmap();
Gfx_BindTexture(weather == WEATHER_RAINY ? rain_tex : snow_tex);
Expand All @@ -470,13 +470,13 @@ void EnvRenderer_RenderWeather(double deltaTime) {
pos.Y += 64;
pos.Y = max(World.Height, pos.Y);

speed = (weather == WEATHER_RAINY ? 1.0f : 0.2f) * Env_WeatherSpeed;
speed = (weather == WEATHER_RAINY ? 1.0f : 0.2f) * Env.WeatherSpeed;
vOffset = (float)Game.Time * speed;
particles = weather == WEATHER_RAINY;
weather_accumulator += deltaTime;

ptr = vertices;
v.Col = Env_SunCol;
v.Col = Env.SunCol;

for (dx = -WEATHER_EXTENT; dx <= WEATHER_EXTENT; dx++) {
for (dz = -WEATHER_EXTENT; dz <= WEATHER_EXTENT; dz++) {
Expand Down Expand Up @@ -542,7 +542,7 @@ static int sides_vertices, edges_vertices;
static bool sides_fullBright, edges_fullBright;
static TextureLoc edges_lastTexLoc, sides_lastTexLoc;

void EnvRenderer_RenderBorders(BlockID block, GfxResourceID vb, GfxResourceID tex, int count) {
static void EnvRenderer_RenderBorders(BlockID block, GfxResourceID vb, GfxResourceID tex, int count) {
if (!vb) return;

Gfx_SetTexturing(true);
Expand All @@ -560,7 +560,7 @@ void EnvRenderer_RenderBorders(BlockID block, GfxResourceID vb, GfxResourceID te
}

void EnvRenderer_RenderMapSides(double delta) {
EnvRenderer_RenderBorders(Env_SidesBlock,
EnvRenderer_RenderBorders(Env.SidesBlock,
sides_vb, sides_tex, sides_vertices);
}

Expand All @@ -570,7 +570,7 @@ void EnvRenderer_RenderMapEdges(double delta) {
int yVisible = min(0, Env_SidesHeight);
if (Camera.CurrentPos.Y < yVisible && sides_vb) return;

EnvRenderer_RenderBorders(Env_EdgeBlock,
EnvRenderer_RenderBorders(Env.EdgeBlock,
edges_vb, edges_tex, edges_vertices);
}

Expand Down Expand Up @@ -598,8 +598,8 @@ static void EnvRenderer_CalcBorderRects(Rect2D* rects) {
}

static void EnvRenderer_UpdateBorderTextures(void) {
EnvRenderer_MakeBorderTex(&edges_tex, Env_EdgeBlock);
EnvRenderer_MakeBorderTex(&sides_tex, Env_SidesBlock);
EnvRenderer_MakeBorderTex(&edges_tex, Env.EdgeBlock);
EnvRenderer_MakeBorderTex(&sides_tex, Env.SidesBlock);
}

#define Borders_HorOffset(block) (Blocks.RenderMinBB[block].X - Blocks.MinBB[block].X)
Expand Down Expand Up @@ -696,7 +696,7 @@ static void EnvRenderer_UpdateMapSides(void) {

if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&sides_vb);
block = Env_SidesBlock;
block = Env.SidesBlock;

if (Blocks.Draw[block] == DRAW_GAS) return;
EnvRenderer_CalcBorderRects(rects);
Expand All @@ -719,7 +719,7 @@ static void EnvRenderer_UpdateMapSides(void) {
cur = ptr;

sides_fullBright = Blocks.FullBright[block];
col = sides_fullBright ? white : Env_ShadowCol;
col = sides_fullBright ? white : Env.ShadowCol;
Block_Tint(col, block)

for (i = 0; i < 4; i++) {
Expand Down Expand Up @@ -755,7 +755,7 @@ static void EnvRenderer_UpdateMapEdges(void) {

if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&edges_vb);
block = Env_EdgeBlock;
block = Env.EdgeBlock;

if (Blocks.Draw[block] == DRAW_GAS) return;
EnvRenderer_CalcBorderRects(rects);
Expand All @@ -773,10 +773,10 @@ static void EnvRenderer_UpdateMapEdges(void) {
cur = ptr;

edges_fullBright = Blocks.FullBright[block];
col = edges_fullBright ? white : Env_SunCol;
col = edges_fullBright ? white : Env.SunCol;
Block_Tint(col, block)

y = (float)Env_EdgeHeight;
y = (float)Env.EdgeHeight;
for (i = 0; i < 4; i++) {
r = rects[i];
EnvRenderer_DrawBorderY(r.X, r.Y, r.X + r.Width, r.Y + r.Height, y, col,
Expand Down Expand Up @@ -869,10 +869,10 @@ static void EnvRenderer_ViewDistanceChanged(void* obj) {

static void EnvRenderer_EnvVariableChanged(void* obj, int envVar) {
if (envVar == ENV_VAR_EDGE_BLOCK) {
EnvRenderer_MakeBorderTex(&edges_tex, Env_EdgeBlock);
EnvRenderer_MakeBorderTex(&edges_tex, Env.EdgeBlock);
EnvRenderer_UpdateMapEdges();
} else if (envVar == ENV_VAR_SIDES_BLOCK) {
EnvRenderer_MakeBorderTex(&sides_tex, Env_SidesBlock);
EnvRenderer_MakeBorderTex(&sides_tex, Env.SidesBlock);
EnvRenderer_UpdateMapSides();
} else if (envVar == ENV_VAR_EDGE_HEIGHT || envVar == ENV_VAR_SIDES_OFFSET) {
EnvRenderer_UpdateMapEdges();
Expand Down

0 comments on commit 97a3d1b

Please sign in to comment.