Skip to content

Commit 3d097a3

Browse files
committed
Fix printf format flag and argument type incompatibilities
1 parent 388e056 commit 3d097a3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

saving.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define CAST_FLOAT
2828
#endif
2929

30-
bool version_newer(const unsigned char v1[3], const unsigned char v2[3]) // true iff v1 newer than v2
30+
bool version_newer(const unsigned int v1[3], const unsigned int v2[3]) // true iff v1 newer than v2
3131
{
3232
for(unsigned int i=0;i<3;i++)
3333
{
@@ -46,8 +46,8 @@ int loadgame(const char *fn, game *state)
4646
perror("fopen");
4747
return(1);
4848
}
49-
unsigned char s_version[3]={0,0,0};
50-
unsigned char version[3]={VER_MAJ,VER_MIN,VER_REV};
49+
unsigned int s_version[3]={0,0,0};
50+
unsigned int version[3]={VER_MAJ,VER_MIN,VER_REV};
5151
bool warned_pff=false, warned_acid=false;
5252
state->weather.seed=0;
5353
for(unsigned int i=0;i<DIFFICULTY_CLASSES;i++) // default everything to medium
@@ -68,7 +68,7 @@ int loadgame(const char *fn, game *state)
6868
int e=0,f; // poor-man's try...
6969
if(strcmp(tag, "HARR")==0)
7070
{
71-
f=sscanf(dat, "%hhu.%hhu.%hhu\n", s_version, s_version+1, s_version+2);
71+
f=sscanf(dat, "%u.%u.%u\n", s_version, s_version+1, s_version+2);
7272
if(f!=3)
7373
{
7474
fprintf(stderr, "1 Too few arguments to tag \"%s\"\n", tag);
@@ -698,7 +698,7 @@ int savegame(const char *fn, game state)
698698
return(1);
699699
}
700700
char p_id[9];
701-
fprintf(fs, "HARR:%hhu.%hhu.%hhu\n", VER_MAJ, VER_MIN, VER_REV);
701+
fprintf(fs, "HARR:%u.%u.%u\n", VER_MAJ, VER_MIN, VER_REV);
702702
fprintf(fs, "DATE:%02d-%02d-%04d\n", state.now.day, state.now.month, state.now.year);
703703
fprintf(fs, "DClasses:%u\n", DIFFICULTY_CLASSES);
704704
for(unsigned int i=0;i<DIFFICULTY_CLASSES;i++)
@@ -738,9 +738,9 @@ int savegame(const char *fn, game state)
738738
flags |= 1;
739739
fprintf(fs, "Type %u:%u,%u,%s\n", state.fighters[i].type, state.fighters[i].base, flags, p_id);
740740
}
741-
fprintf(fs, "Targets:%hhu\n", ntargs);
741+
fprintf(fs, "Targets:%u\n", ntargs);
742742
for(unsigned int i=0;i<ntargs;i++)
743-
fprintf(fs, "Targ %hhu:"FLOAT","FLOAT","FLOAT","FLOAT"\n", i, CAST_FLOAT state.dmg[i], CAST_FLOAT (targs[i].flak?state.flk[i]*100.0/(double)targs[i].flak:0), CAST_FLOAT state.heat[i], CAST_FLOAT state.flam[i]);
743+
fprintf(fs, "Targ %u:"FLOAT","FLOAT","FLOAT","FLOAT"\n", i, CAST_FLOAT state.dmg[i], CAST_FLOAT (targs[i].flak?state.flk[i]*100.0/(double)targs[i].flak:0), CAST_FLOAT state.heat[i], CAST_FLOAT state.flam[i]);
744744
fprintf(fs, "Weather state:"FLOAT","FLOAT"\n", CAST_FLOAT state.weather.push, CAST_FLOAT state.weather.slant);
745745
for(unsigned int x=0;x<256;x++)
746746
{

version.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#define VER_MAJ 0
2-
#define VER_MIN 2
3-
#define VER_REV 4
1+
#define VER_MAJ 0u
2+
#define VER_MIN 2u
3+
#define VER_REV 4u

0 commit comments

Comments
 (0)