Skip to content

Commit

Permalink
Fix last commit not compiling with some compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Dec 1, 2022
1 parent 2d8fe37 commit 93e1491
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
26 changes: 13 additions & 13 deletions src/Animations.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static cc_bool L_rndInited;
static void LavaAnimation_Tick(void) {
BitmapCol pixels[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
BitmapCol* ptr = pixels;
float soupHeat, potHeat, col;
float soupHeat, potHeat, color;
int size, mask, shift;
int x, y, i = 0;
struct Bitmap bmp;
Expand Down Expand Up @@ -85,13 +85,13 @@ static void LavaAnimation_Tick(void) {
if (Random_Float(&L_rnd) <= 0.005f) L_flameHeat[i] = 1.5f * 0.01f;

/* Output the pixel */
col = 2.0f * L_soupHeat[i];
Math_Clamp(col, 0.0f, 1.0f);
color = 2.0f * L_soupHeat[i];
Math_Clamp(color, 0.0f, 1.0f);

*ptr = BitmapCol_Make(
col * 100.0f + 155.0f,
col * col * 255.0f,
col * col * col * col * 128.0f,
color * 100.0f + 155.0f,
color * color * 255.0f,
color * color * color * color * 128.0f,
255);

ptr++; i++;
Expand All @@ -115,7 +115,7 @@ static cc_bool W_rndInited;
static void WaterAnimation_Tick(void) {
BitmapCol pixels[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
BitmapCol* ptr = pixels;
float soupHeat, col;
float soupHeat, color;
int size, mask, shift;
int x, y, i = 0;
struct Bitmap bmp;
Expand Down Expand Up @@ -146,15 +146,15 @@ static void WaterAnimation_Tick(void) {
if (Random_Float(&W_rnd) <= 0.05f) W_flameHeat[i] = 0.5f * 0.05f;

/* Output the pixel */
col = W_soupHeat[i];
Math_Clamp(col, 0.0f, 1.0f);
col = col * col;
color = W_soupHeat[i];
Math_Clamp(color, 0.0f, 1.0f);
color = color * color;

*ptr = BitmapCol_Make(
32.0f + col * 32.0f,
50.0f + col * 64.0f,
32.0f + color * 32.0f,
50.0f + color * 64.0f,
255,
146.0f + col * 50.0f);
146.0f + color * 50.0f);

ptr++; i++;
}
Expand Down
17 changes: 9 additions & 8 deletions src/IsometricDrawer.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ static struct VertexTextured* iso_vertices_base;
static GfxResourceID iso_vb;

static cc_bool iso_cacheInited;
static PackedCol iso_col = PACKEDCOL_WHITE;
static PackedCol iso_colXSide, iso_colZSide, iso_colYBottom;
static PackedCol iso_color = PACKEDCOL_WHITE;
static PackedCol iso_colorXSide, iso_colorZSide, iso_colorYBottom;

#define iso_cosX (0.86602540378443864f) /* cos(30 * MATH_DEG2RAD) */
#define iso_sinX (0.50000000000000000f) /* sin(30 * MATH_DEG2RAD) */
Expand Down Expand Up @@ -42,7 +42,8 @@ static void IsometricDrawer_InitCache(void) {
if (iso_cacheInited) return;

iso_cacheInited = true;
PackedCol_GetShaded(iso_col, &iso_colXSide, &iso_colZSide, &iso_colYBottom);
PackedCol_GetShaded(iso_color,
&iso_colorXSide, &iso_colorZSide, &iso_colorYBottom);

Matrix_RotateY(&rotY, 45.0f * MATH_DEG2RAD);
Matrix_RotateX(&rotX, -30.0f * MATH_DEG2RAD);
Expand Down Expand Up @@ -78,7 +79,7 @@ static void IsometricDrawer_SpriteZQuad(BlockID block, cc_bool firstPart) {
float x1, x2;

if (iso_lastTexIndex != iso_texIndex) IsometricDrawer_Flush();
v.Col = iso_col;
v.Col = iso_color;
Block_Tint(v.Col, block);

x1 = firstPart ? 0.5f : -0.1f;
Expand Down Expand Up @@ -107,7 +108,7 @@ static void IsometricDrawer_SpriteXQuad(BlockID block, cc_bool firstPart) {
float z1, z2;

if (iso_lastTexIndex != iso_texIndex) IsometricDrawer_Flush();
v.Col = iso_col;
v.Col = iso_color;
Block_Tint(v.Col, block);

z1 = firstPart ? 0.5f : -0.1f;
Expand Down Expand Up @@ -175,11 +176,11 @@ void IsometricDrawer_DrawBatch(BlockID block, float size, float x, float y) {
Drawer.Tinted = Blocks.Tinted[block];
Drawer.TintCol = Blocks.FogCol[block];

Drawer_XMax(1, bright ? iso_col : iso_colXSide,
Drawer_XMax(1, bright ? iso_color : iso_colorXSide,
IsometricDrawer_GetTexLoc(block, FACE_XMAX), &iso_vertices);
Drawer_ZMin(1, bright ? iso_col : iso_colZSide,
Drawer_ZMin(1, bright ? iso_color : iso_colorZSide,
IsometricDrawer_GetTexLoc(block, FACE_ZMIN), &iso_vertices);
Drawer_YMax(1, iso_col,
Drawer_YMax(1, iso_color,
IsometricDrawer_GetTexLoc(block, FACE_YMAX), &iso_vertices);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
struct LScreen;
struct FontDesc;
struct Context2D;
struct HttpRequest;

/* The screen/menu currently being shown */
extern struct LScreen* Launcher_Active;
Expand Down
20 changes: 10 additions & 10 deletions src/SelectionBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* Data for a selection box. */
struct SelectionBox {
Vec3 p0, p1;
PackedCol col;
PackedCol color;
float minDist, maxDist;
};

Expand All @@ -30,21 +30,21 @@ static void BuildFaces(struct SelectionBox* box, struct VertexColoured* v) {
SelectionBox_Z(Z0) SelectionBox_Z(Z1) /* ZMin, ZMax */
SelectionBox_X(X0) SelectionBox_X(X1) /* XMin, XMax */
};
PackedCol col;
PackedCol color;
int i, flags;

float offset = box->minDist < 32.0f * 32.0f ? (1/32.0f) : (1/16.0f);
Vec3 coords[2];
Vec3_Add1(&coords[0], &box->p0, -offset);
Vec3_Add1(&coords[1], &box->p1, offset);

col = box->col;
color = box->color;
for (i = 0; i < Array_Elems(faceIndices); i++, v++) {
flags = faceIndices[i];
v->X = coords[(flags ) & 1].X;
v->Y = coords[(flags >> 1) & 1].Y;
v->Z = coords[(flags >> 2) ].Z;
v->Col = col;
v->Col = color;
}
}

Expand All @@ -54,24 +54,24 @@ static void BuildEdges(struct SelectionBox* box, struct VertexColoured* v) {
X0|Y1|Z0, X1|Y1|Z0, X1|Y1|Z0, X1|Y1|Z1, X1|Y1|Z1, X0|Y1|Z1, X0|Y1|Z1, X0|Y1|Z0, /* YMax */
X0|Y0|Z0, X0|Y1|Z0, X1|Y0|Z0, X1|Y1|Z0, X1|Y0|Z1, X1|Y1|Z1, X0|Y0|Z1, X0|Y1|Z1, /* X/Z */
};
PackedCol col;
PackedCol color;
int i, flags;

float offset = box->minDist < 32.0f * 32.0f ? (1/32.0f) : (1/16.0f);
Vec3 coords[2];
Vec3_Add1(&coords[0], &box->p0, -offset);
Vec3_Add1(&coords[1], &box->p1, offset);

col = box->col;
color = box->color;
/* invert R/G/B for surrounding line */
col = (col & PACKEDCOL_A_MASK) | (~col & PACKEDCOL_RGB_MASK);
color = (color & PACKEDCOL_A_MASK) | (~color & PACKEDCOL_RGB_MASK);

for (i = 0; i < Array_Elems(edgeIndices); i++, v++) {
flags = edgeIndices[i];
v->X = coords[(flags ) & 1].X;
v->Y = coords[(flags >> 1) & 1].Y;
v->Z = coords[(flags >> 2) ].Z;
v->Col = col;
v->Col = color;
}
}

Expand Down Expand Up @@ -110,11 +110,11 @@ static cc_uint8 selections_ids[SELECTIONS_MAX];
static GfxResourceID selections_VB, selections_LineVB;
static cc_bool selections_used;

void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol col) {
void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol color) {
struct SelectionBox sel;
IVec3_ToVec3(&sel.p0, p1);
IVec3_ToVec3(&sel.p1, p2);
sel.col = col;
sel.color = color;

Selections_Remove(id);
selections_list[selections_count] = sel;
Expand Down
6 changes: 3 additions & 3 deletions src/SelectionBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ struct IGameComponent;
extern struct IGameComponent Selections_Component;

void Selections_Render(void);
/* Adds or replaces the selection box with the given ID. */
CC_API void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol col);
/* Removes the selection box with the givne ID. */
/* Adds or replaces the selection box with the given ID */
CC_API void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol color);
/* Removes the selection box with the givne ID */
CC_API void Selections_Remove(cc_uint8 id);
#endif

0 comments on commit 93e1491

Please sign in to comment.