Skip to content

Commit

Permalink
fix Linux compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
VitaSmith committed Dec 5, 2021
1 parent cf8470a commit 9d095b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ OBJ=${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${OBJ6}
DEP=${DEP1} ${DEP2} ${DEP3} ${DEP4} ${DEP5} ${DEP6}

# -Wno-sequence-point because *dst++ = dst[-d]; is only ambiguous for people who don't know how CPUs work.
CFLAGS=-std=c99 -pipe -fvisibility=hidden -Wall -Wextra -Werror -Wno-sequence-point -Wno-unknown-pragmas -UNDEBUG -D_GNU_SOURCE -O2
CFLAGS=-std=c99 -pipe -fvisibility=hidden -Wall -Wextra -Werror -Wno-sequence-point -Wno-unknown-pragmas -Wno-strict-aliasing -UNDEBUG -D_GNU_SOURCE -O2
ifeq ($(OS),Windows_NT)
LDFLAGS=-s -municode
else
Expand Down
2 changes: 1 addition & 1 deletion gust_elixir.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int32_t decompress_mem_to_mem(void* pOut_buf, size_t out_buf_len, const void* pS
int main_utf8(int argc, char** argv)
{
int r = -1;
char path[256], *filename = NULL;
char path[256];
uint8_t *buf = NULL, *zbuf = NULL;
uint32_t zsize, lxr_entry_size = sizeof(lxr_entry);
FILE *file = NULL, *dst = NULL;
Expand Down
16 changes: 8 additions & 8 deletions gust_g1t.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static size_t write_dds_header(FILE* fd, enum DDS_FORMAT format, uint32_t width,
dxt10_hdr.arraySize = GET_NB_FRAMES(flags[1]);
if (dxt10_hdr.arraySize == 0)
dxt10_hdr.arraySize = 1;
dxt10_hdr.miscFlag = (flags[2] & G1T_FLAG_CUBE_MAP) ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
dxt10_hdr.miscFlag = (flags[1] & G1T_FLAG_CUBE_MAP) ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
switch (format) {
case DDS_FORMAT_BC7:
dxt10_hdr.dxgiFormat = (flags[0] & G1T_FLAG_SRGB) ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM;
Expand Down Expand Up @@ -585,8 +585,8 @@ int main_utf8(int argc, char** argv)
if (hdr.platform == SONY_PS3 || hdr.platform == NINTENDO_WII || hdr.platform == NINTENDO_WIIU)
data_endianness = big_endian;
hdr.magic = G1TG_MAGIC;
char version_string[5] = { 0 };
snprintf(version_string, 5, "%04d", version);
char version_string[6] = { 0 };
snprintf(version_string, sizeof(version_string), "%04d", version);
hdr.version = getbe32(version_string);
hdr.total_size = 0; // To be rewritten when we're done
hdr.nb_textures = (uint32_t)json_array_get_count(json_textures_array);
Expand Down Expand Up @@ -646,8 +646,8 @@ int main_utf8(int argc, char** argv)
float depth = (depth_str == NULL) ? 0.0f : (float)atof(depth_str);
uint64_t flags[2];
json_to_flags(flags, json_object_get_array(texture_entry, "flags"));
for (int j = 0; j < ARRAYSIZE(tex.flags); j++)
tex.flags[ARRAYSIZE(tex.flags) - j - 1] = (uint8_t)(flags[0] >> (8 * j));
for (size_t j = 0; j < array_size(tex.flags); j++)
tex.flags[array_size(tex.flags) - j - 1] = (uint8_t)(flags[0] >> (8 * j));
flag_table[i] = (uint32_t)(flags[0] >> 40);
uint32_t nb_frames = json_object_get_uint32(texture_entry, "nb_frames");
flags[1] |= ((uint64_t)nb_frames & 0x0f) << 28 | ((uint64_t)nb_frames & 0xf0) << 12;
Expand Down Expand Up @@ -703,7 +703,7 @@ int main_utf8(int argc, char** argv)
tex.z_mipmaps = tex.mipmaps;
tex.mipmaps = swap_tmp;
} else {
for (int j = 0; j < ARRAYSIZE(tex.flags); j++)
for (size_t j = 0; j < array_size(tex.flags); j++)
tex.flags[j] = tex.flags[j] >> 4 | tex.flags[j] << 4;
}
// Write texture header
Expand Down Expand Up @@ -1061,7 +1061,7 @@ int main_utf8(int argc, char** argv)
tex->z_mipmaps = tex->mipmaps;
tex->mipmaps = swap_tmp;
} else {
for (int j = 0; j < ARRAYSIZE(tex->flags); j++)
for (size_t j = 0; j < array_size(tex->flags); j++)
tex->flags[j] = tex->flags[j] >> 4 | tex->flags[j] << 4;
}
if (tex->mipmaps == 0) {
Expand All @@ -1080,7 +1080,7 @@ int main_utf8(int argc, char** argv)
fprintf(stderr, "Please report this error to %s.\n", REPORT_URL);
break;
}
for (int j = 0; j < ARRAYSIZE(tex->flags); j++)
for (size_t j = 0; j < array_size(tex->flags); j++)
flags[0] = flags[0] << 8 | (uint64_t)tex->flags[j];
pos += sizeof(g1t_tex_header);
uint32_t width = 1 << tex->dx;
Expand Down

0 comments on commit 9d095b3

Please sign in to comment.