summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2010-01-10 19:30:28 +0100
committerBardur Arantsson <bardur@scientician.net>2010-01-10 19:32:02 +0100
commit20087ac085b472a1238ac0ca78a2cd9d4e24c18d (patch)
tree5df1ecde8d61a979e58c329a3eab711581620aca
parentd324d9c0ac98e74db26e5dd5c6e379c1fc18cff3 (diff)
Fixes for 64 bit compatibility.
- Fix skill value display in character dump on 64 bit machines. - Fix format strings and add casts to *printf() invocations.
-rw-r--r--changes.txt1
-rw-r--r--src/cmd4.c6
-rw-r--r--src/cmd7.c2
-rw-r--r--src/files.c4
-rw-r--r--src/init1.c2
-rw-r--r--src/notes.c8
-rw-r--r--src/skills.c7
-rw-r--r--src/status.c49
-rw-r--r--src/util.c4
-rw-r--r--src/wizard1.c6
-rw-r--r--src/wizard2.c6
11 files changed, 45 insertions, 50 deletions
diff --git a/changes.txt b/changes.txt
index c740e5b3..e298b98a 100644
--- a/changes.txt
+++ b/changes.txt
@@ -2,6 +2,7 @@ T.o.M.E 2.3.7 (ah)
- Remove item pval from antimagic field strength calculation since it
may be both non-zero and invisible (to the player).
+- Miscellaneous 64 bit fixes.
T.o.M.E 2.3.6 (ah)
diff --git a/src/cmd4.c b/src/cmd4.c
index 897fc063..c66f0fbc 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -3963,7 +3963,7 @@ static void do_cmd_knowledge_kill_count(void)
}
else
{
- fprintf(fff, "You have defeated %lu enemies.\n\n", Total);
+ fprintf(fff, "You have defeated %ld enemies.\n\n", (long int) Total);
}
}
@@ -4017,7 +4017,7 @@ static void do_cmd_knowledge_kill_count(void)
}
fprintf(fff, "----------------------------------------------\n");
- fprintf(fff, " Total: %lu creature%s killed.\n", Total, (Total == 1 ? "" : "s"));
+ fprintf(fff, " Total: %ld creature%s killed.\n", (long int) Total, (Total == 1 ? "" : "s"));
/* Close the file */
my_fclose(fff);
@@ -4310,7 +4310,7 @@ static void do_cmd_knowledge_quests(void)
fprintf(fff, "Kill them all to get it back.\n");
}
fprintf(fff, "Number: %d, Killed: %ld.\n",
- random_quests[dun_level].type, quest[QUEST_RANDOM].data[0]);
+ random_quests[dun_level].type, (long int) quest[QUEST_RANDOM].data[0]);
fprintf(fff, "\n");
}
/* MUST be a lua quest */
diff --git a/src/cmd7.c b/src/cmd7.c
index 123822a6..a6ae232f 100644
--- a/src/cmd7.c
+++ b/src/cmd7.c
@@ -1279,7 +1279,7 @@ int show_flags(byte group, int pval)
sprintf(ttt, "%c) %s (exp %ld)",
(items < 26) ? I2A(items) : ('0' + items - 26),
al_name + a_select_flags[i].desc,
- a_select_flags[i].xp);
+ (long int) a_select_flags[i].xp);
/* Note: Somebody is VERY clever, and it wasn't me. Text printed as
* TERM_DARK is actually printed as TERM_BLUE *SPACES* to prevent the
diff --git a/src/files.c b/src/files.c
index a35aac66..c3166f4a 100644
--- a/src/files.c
+++ b/src/files.c
@@ -3296,7 +3296,7 @@ errr file_character(cptr name, bool full)
else if (Total == 1)
fprintf(fff, "\n You have defeated one enemy.");
else
- fprintf(fff, "\n You have defeated %lu enemies.", Total);
+ fprintf(fff, "\n You have defeated %ld enemies.", (long int) Total);
}
hook_file = fff;
@@ -3317,7 +3317,7 @@ errr file_character(cptr name, bool full)
get_month_name(bst(DAY, turn), wizard, FALSE), buf2);
fprintf(fff,
(death ? "\n Your adventure lasted %ld day%s." : "\n You have been adventuring for %ld day%s."),
- days, (days == 1) ? "" : "s");
+ (long int) days, (days == 1) ? "" : "s");
}
fprintf (fff, "\n\n");
diff --git a/src/init1.c b/src/init1.c
index 927b8dc4..6f702a89 100644
--- a/src/init1.c
+++ b/src/init1.c
@@ -3060,7 +3060,7 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Process 'C' for "sensing" */
if ((buf[0] == 'C') && (buf[2] == 'C'))
{
- s32b s[3];
+ long int s[3];
char h, m;
/* Scan for the values */
diff --git a/src/notes.c b/src/notes.c
index 8cfc08ae..11b1ed4f 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -94,8 +94,8 @@ void add_note(char *note, char code)
strncpy(buf, note, 60);
/* Get date and time */
- sprintf(long_day, "%ld:%02ld %s, %s", (bst(HOUR, turn) % 12 == 0) ? 12 : (bst(HOUR, turn) % 12),
- bst(MINUTE, turn), (bst(HOUR, turn) < 12) ? "AM" : "PM", get_month_name(bst(DAY, turn), FALSE,
+ sprintf(long_day, "%ld:%02ld %s, %s", (long int) ((bst(HOUR, turn) % 12 == 0) ? 12 : (bst(HOUR, turn) % 12)),
+ (long int) bst(MINUTE, turn), (bst(HOUR, turn) < 12) ? "AM" : "PM", get_month_name(bst(DAY, turn), FALSE,
FALSE));
/* Get depth */
@@ -124,8 +124,8 @@ void add_note_type(int note_number)
strftime(true_long_day, 30, "%Y-%m-%d at %H:%M:%S", localtime(&ct));
/* Get the date */
- sprintf(buf, "%ld", bst(YEAR, turn) + START_YEAR);
- sprintf(long_day, "%ld:%02ld %s the %s of III %s", (bst(HOUR, turn) % 12 == 0) ? 12 : (bst(HOUR, turn) % 12), bst(MINUTE, turn), (bst(HOUR, turn) < 12) ? "AM" : "PM", get_month_name(bst(DAY, turn), FALSE, FALSE), buf);
+ sprintf(buf, "%ld", (long int) (bst(YEAR, turn) + START_YEAR));
+ sprintf(long_day, "%ld:%02ld %s the %s of III %s", (long int) ((bst(HOUR, turn) % 12 == 0) ? 12 : (bst(HOUR, turn) % 12)), (long int) bst(MINUTE, turn), (bst(HOUR, turn) < 12) ? "AM" : "PM", get_month_name(bst(DAY, turn), FALSE, FALSE), buf);
/* Work out what to do */
switch (note_number)
diff --git a/src/skills.c b/src/skills.c
index 07166072..5eb653b0 100644
--- a/src/skills.c
+++ b/src/skills.c
@@ -257,11 +257,10 @@ void dump_skills(FILE *fff)
strcat(buf, format(" - %s", s_info[i].name + s_name));
}
- fprintf(fff, "%-49s%s%02ld.%03ld [%01ld.%03ld]",
+ fprintf(fff, "%-49s%s%06.3f [%05.3f]",
buf, s_info[i].value < 0 ? "-" : " ",
- ABS(s_info[i].value) / SKILL_STEP,
- ABS(s_info[i].value) % SKILL_STEP,
- s_info[i].mod / 1000, s_info[i].mod % 1000);
+ ((double) ABS(s_info[i].value)) / SKILL_STEP,
+ ((double) s_info[i].mod) / 1000);
}
fprintf(fff, "\n");
diff --git a/src/status.c b/src/status.c
index de531593..37b683c5 100644
--- a/src/status.c
+++ b/src/status.c
@@ -492,31 +492,26 @@ static void status_bival(s32b val, byte ypos, byte xpos)
static void status_numeric(s32b val, byte ypos, byte xpos)
{
- if (val == 0)
- c_put_str(TERM_WHITE, ".", ypos, xpos);
- else if (val < 0)
- {
- val *= -1;
- if (val > 9)
- c_put_str(TERM_RED, "*", ypos, xpos);
- else
- {
- char strnum[2];
- sprintf(strnum, "%lu", val);
- c_put_str(TERM_RED, strnum, ypos, xpos);
- }
- }
- else if (val > 0)
- {
- if (val > 9)
- c_put_str(TERM_GREEN, "*", ypos, xpos);
- else
- {
- char strnum[2];
- sprintf(strnum, "%lu", val);
- c_put_str(TERM_GREEN, strnum, ypos, xpos);
- }
+ u32b magnitude = ABS(val);
+ int color = TERM_WHITE; /* default */
+ char strnum[2];
+
+ if (val<0) {
+ color = TERM_RED;
+ };
+ if (val>0) {
+ color = TERM_GREEN;
+ };
+
+ if (magnitude == 0) {
+ sprintf(strnum, ".");
+ } if (magnitude > 9) {
+ sprintf(strnum, "*");
+ } else {
+ sprintf(strnum, "%lu", (unsigned long int) magnitude);
}
+
+ c_put_str(color, strnum, ypos, xpos);
}
static void status_count(s32b val1, int v1, s32b val2, int v2, s32b val3, int v3, s32b val4, int v4, byte ypos, byte xpos)
@@ -746,11 +741,11 @@ static void status_companion(void)
fprintf(fff, "#####BCompanion: %s\n", m_name);
- fprintf(fff, " Lev/Exp : [[[[[G%d / %ld]\n", m_ptr->level, m_ptr->exp);
- if (m_ptr->level < MONSTER_LEVEL_MAX) fprintf(fff, " Next lvl: [[[[[G%ld]\n", MONSTER_EXP((s32b)m_ptr->level + 1));
+ fprintf(fff, " Lev/Exp : [[[[[G%d / %ld]\n", m_ptr->level, (long int) m_ptr->exp);
+ if (m_ptr->level < MONSTER_LEVEL_MAX) fprintf(fff, " Next lvl: [[[[[G%ld]\n", (long int) MONSTER_EXP((s32b)m_ptr->level + 1));
else fprintf(fff, " Next lvl: [[[[[G****]\n");
- fprintf(fff, " HP : [[[[[G%ld / %ld]\n", m_ptr->hp, m_ptr->maxhp);
+ fprintf(fff, " HP : [[[[[G%ld / %ld]\n", (long int) m_ptr->hp, (long int) m_ptr->maxhp);
fprintf(fff, " AC : [[[[[G%d]\n", m_ptr->ac);
fprintf(fff, " Speed : [[[[[G%d]\n", m_ptr->mspeed - 110);
diff --git a/src/util.c b/src/util.c
index b199a2a2..d9557086 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3624,7 +3624,7 @@ s32b get_quantity(cptr prompt, s32b max)
if (!prompt)
{
/* Build a prompt */
- sprintf(tmp, "Quantity (1-%ld): ", max);
+ sprintf(tmp, "Quantity (1-%ld): ", (long int) max);
/* Use that prompt */
prompt = tmp;
@@ -3635,7 +3635,7 @@ s32b get_quantity(cptr prompt, s32b max)
amt = 1;
/* Build the default */
- sprintf(buf, "%ld", amt);
+ sprintf(buf, "%ld", (long int) amt);
/* Ask for a quantity */
if (!get_string(prompt, buf, 9)) return (0);
diff --git a/src/wizard1.c b/src/wizard1.c
index 226d1be7..066e5d20 100644
--- a/src/wizard1.c
+++ b/src/wizard1.c
@@ -355,7 +355,7 @@ static void kind_info(char *buf, char *dam, char *wgt, int *lev, s32b *val, int
/* Weight */
- sprintf(wgt, "%3ld.%ld", q_ptr->weight / 10, q_ptr->weight % 10);
+ sprintf(wgt, "%3ld.%ld", (long int) (q_ptr->weight / 10), (long int) (q_ptr->weight % 10));
}
@@ -891,7 +891,7 @@ static void analyze_pval (object_type *o_ptr, pval_info_type *p_ptr)
affects_list = p_ptr->pval_affects;
/* Create the "+N" string */
- sprintf(p_ptr->pval_desc, "%s%ld", POSITIZE(o_ptr->pval), o_ptr->pval);
+ sprintf(p_ptr->pval_desc, "%s%ld", POSITIZE(o_ptr->pval), (long int) o_ptr->pval);
/* First, check to see if the pval affects all stats */
if ((f1 & all_stats) == all_stats)
@@ -1082,7 +1082,7 @@ static void analyze_misc (object_type *o_ptr, char *misc_desc)
sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
a_ptr->level, a_ptr->rarity,
- a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
+ a_ptr->weight / 10, a_ptr->weight % 10, (long int) a_ptr->cost);
}
diff --git a/src/wizard2.c b/src/wizard2.c
index 31c74de5..99d0eb41 100644
--- a/src/wizard2.c
+++ b/src/wizard2.c
@@ -791,7 +791,7 @@ static void wiz_tweak_item(object_type *o_ptr)
#endif
p = "Enter new 'pval' setting: ";
- sprintf(tmp_val, "%ld", o_ptr->pval);
+ sprintf(tmp_val, "%ld", (long int) o_ptr->pval);
if (!get_string(p, tmp_val, 5)) return;
o_ptr->pval = atoi(tmp_val);
wiz_display_item(o_ptr);
@@ -803,7 +803,7 @@ static void wiz_tweak_item(object_type *o_ptr)
wiz_display_item(o_ptr);
p = "Enter new 'pval3' setting: ";
- sprintf(tmp_val, "%ld", o_ptr->pval3);
+ sprintf(tmp_val, "%ld", (long int) o_ptr->pval3);
if (!get_string(p, tmp_val, 5)) return;
o_ptr->pval3 = atoi(tmp_val);
wiz_display_item(o_ptr);
@@ -845,7 +845,7 @@ static void wiz_tweak_item(object_type *o_ptr)
wiz_display_item(o_ptr);
p = "Enter new 'obj exp' setting: ";
- sprintf(tmp_val, "%ld", o_ptr->exp);
+ sprintf(tmp_val, "%ld", (long int) o_ptr->exp);
if (!get_string(p, tmp_val, 9)) return;
wiz_display_item(o_ptr);
o_ptr->exp = atoi(tmp_val);