summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2010-01-10 19:11:13 +0100
committerBardur Arantsson <bardur@scientician.net>2010-01-10 19:32:02 +0100
commitfc7620691b3dff4b502042d889fd75bb85170c16 (patch)
tree372f8a18d127d06127b51bb3601ffdf97c8bbff8 /src
parent3d46b09fe21dfdea43b0e4e224363ecb67a0fb9b (diff)
Refactor version string construction to a function.
Diffstat (limited to 'src')
-rw-r--r--src/cmd4.c4
-rw-r--r--src/cmovie.c4
-rw-r--r--src/externs.h1
-rw-r--r--src/files.c30
-rw-r--r--src/variable.c18
-rw-r--r--src/wizard1.c19
6 files changed, 44 insertions, 32 deletions
diff --git a/src/cmd4.c b/src/cmd4.c
index 919adddc..897fc063 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -2937,8 +2937,8 @@ void do_cmd_version(void)
call_lua("get_module_info", "(s,d)", "s", "author", 2, &email);
/* Silly message */
- msg_format("You are playing %s %d.%d.%d%s made by %s (%s).",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS,
+ msg_format("You are playing %s made by %s (%s).",
+ get_version_string(),
author, email);
call_lua("patchs_display", "()", "");
}
diff --git a/src/cmovie.c b/src/cmovie.c
index da4dee63..d7a3fa17 100644
--- a/src/cmovie.c
+++ b/src/cmovie.c
@@ -365,8 +365,8 @@ void do_record_cmovie(cptr cmovie)
}
/* First thing: Record clear screen then enable the recording */
- fprintf(movfile, "# Generated by %s %ld.%ld.%ld\n",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+ fprintf(movfile, "# Generated by %s\n",
+ get_version_string());
fprintf(movfile, "C:\n");
last_paused = 0;
do_movies = 1;
diff --git a/src/externs.h b/src/externs.h
index 9cff66f2..68e44bbe 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -609,6 +609,7 @@ extern s32b DUNGEON_DEATH;
extern deity_type *deity_info;
extern s32b max_gods;
extern timer_type *gl_timers;
+extern const char *get_version_string();
/* plots.c */
extern FILE *hook_file;
diff --git a/src/files.c b/src/files.c
index d4c09bb1..a35aac66 100644
--- a/src/files.c
+++ b/src/files.c
@@ -3132,8 +3132,7 @@ errr file_character(cptr name, bool full)
/* Begin dump */
- fprintf(fff, " [%s %ld.%ld.%ld%s Character Sheet]\n\n",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ fprintf(fff, " [%s Character Sheet]\n\n", get_version_string());
/* Display player */
@@ -3942,8 +3941,7 @@ bool show_file(cptr name, cptr what, int line, int mode)
/* Show a general "title" */
- prt(format("[%s %ld.%ld.%ld, %s, Line %d/%d]", game_module,
- VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
+ prt(format("[%s, %s, Line %d/%d]", get_version_string(),
h_ptr->caption, line, size), 0, 0);
/* Prompt -- menu screen */
@@ -4555,8 +4553,8 @@ void html_screenshot(cptr name)
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
"<head>\n");
- fprintf(htm, "<meta name=\"GENERATOR\" content=\"%s %ld.%ld.%ld\"/>\n",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+ fprintf(htm, "<meta name=\"GENERATOR\" content=\"%s\"/>\n",
+ get_version_string());
fprintf(htm, "<title>%s</title>\n", name);
fprintf(htm, "</head>\n"
"<body>\n"
@@ -6185,8 +6183,8 @@ static errr top_twenty(void)
tmp = WIPE(&the_score, high_score);
/* Save the version */
- sprintf(the_score.what, "%lu.%lu.%lu",
- VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+ sprintf(the_score.what, "%ld.%ld.%ld",
+ (long int) VERSION_MAJOR, (long int) VERSION_MINOR, (long int) VERSION_PATCH);
/* Calculate and save the points */
sprintf(the_score.pts, "%9lu", (long)total_points());
@@ -6283,8 +6281,8 @@ errr predict_score(void)
/* Save the version */
- sprintf(the_score.what, "%lu.%lu.%lu",
- VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
+ sprintf(the_score.what, "%ld.%ld.%ld",
+ (long int) VERSION_MAJOR, (long int) VERSION_MINOR, (long int) VERSION_PATCH);
/* Calculate and save the points */
sprintf(the_score.pts, "%9lu", (long)total_points());
@@ -6495,14 +6493,14 @@ void close_game(void)
add_note_type(NOTE_WINNER);
}
- irc_disconnect_aux(format("Retired; %s %ld.%ld.%ld rules",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH), FALSE);
+ irc_disconnect_aux(format("Retired; %s rules",
+ get_version_string()), FALSE);
kingly();
}
else
{
- irc_disconnect_aux(format("Killed by %s; %s %ld.%ld.%ld rules",
- died_from, game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH),
+ irc_disconnect_aux(format("Killed by %s; %s rules",
+ died_from, get_version_string()),
FALSE);
}
@@ -6558,8 +6556,8 @@ void close_game(void)
add_note_type(NOTE_SAVE_GAME);
}
- irc_disconnect_aux(format("Alive... for the time being; %s %ld.%ld.%ld rules",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH),
+ irc_disconnect_aux(format("Alive... for the time being; %s rules",
+ get_version_string()),
FALSE);
/* Prompt for scores XXX XXX XXX */
diff --git a/src/variable.c b/src/variable.c
index 453c5209..8527405f 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1626,3 +1626,21 @@ s32b max_gods = MAX_GODS_INIT;
* Timers
*/
timer_type *gl_timers = NULL;
+
+/**
+ * Get the version string.
+ */
+const char *get_version_string()
+{
+ static char version_str[80];
+ static bool initialized = 0;
+ if (!initialized) {
+ sprintf(version_str, "%s %ld.%ld.%ld%s",
+ game_module,
+ (long int) VERSION_MAJOR,
+ (long int) VERSION_MINOR,
+ (long int) VERSION_PATCH, IS_CVS);
+ initialized = TRUE;
+ }
+ return version_str;
+}
diff --git a/src/wizard1.c b/src/wizard1.c
index 04c5fb0b..226d1be7 100644
--- a/src/wizard1.c
+++ b/src/wizard1.c
@@ -392,8 +392,7 @@ static void spoil_obj_desc(cptr fname)
/* Header */
- sprintf(buf, "Basic Items Spoilers for %s %ld.%ld.%ld%s",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ sprintf(buf, "Basic Items Spoilers for %s", get_version_string());
spoiler_underline(buf);
spoiler_blanklines(2);
@@ -1118,8 +1117,7 @@ static void print_header(void)
{
char buf[80];
- sprintf(buf, "Artifact Spoilers for %s %ld.%ld.%ld%s",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ sprintf(buf, "Artifact Spoilers for %s", get_version_string());
spoiler_underline(buf);
}
@@ -1376,8 +1374,7 @@ static void spoil_mon_desc(cptr fname)
C_MAKE(who, max_r_idx, s16b);
/* Dump the header */
- sprintf(buf, "Monster Spoilers for %s %ld.%ld.%ld%s",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ sprintf(buf, "Monster Spoilers for %s", get_version_string());
spoiler_underline(buf);
spoiler_blanklines(2);
@@ -1522,8 +1519,7 @@ static void spoil_mon_info(cptr fname)
/* Dump the header */
- sprintf(buf, "Monster Spoilers for %s %ld.%ld.%ld%s",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ sprintf(buf, "Monster Spoilers for %s", get_version_string());
spoiler_underline(buf);
spoiler_blanklines(2);
@@ -2485,9 +2481,9 @@ static void spoil_bateries(cptr fname)
"|||||oy\n"
"~~~~~01|Spoilers|Essences\n"
"~~~~~02|Alchemist|Essence Spoiler\n"
- "#####REssence Spoiler for %s %ld.%ld.%ld%s\n"
+ "#####REssence Spoiler for %s\n"
"#####R-----------------------------------\n\n",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ get_version_string());
/*New code starts here -*/
@@ -2687,8 +2683,7 @@ static void spoil_spells(cptr fname)
}
/* Dump the header */
- sprintf(buf, "Spell Spoiler (Skill Level 50) for %s %ld.%ld.%ld%s",
- game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, IS_CVS);
+ sprintf(buf, "Spell Spoiler (Skill Level 50) for %s", get_version_string());
spoiler_underline(buf);
/* Dump the bookless magic powers in alphabetical order */