Skip to content

Commit

Permalink
Extract FILENAMES["motd"] into a static variable
Browse files Browse the repository at this point in the history
  • Loading branch information
BevapDin committed Nov 17, 2019
1 parent 6604c7e commit fd71a90
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/path_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static void update_datadir();
static void update_config_dir();
static void update_pathname( const std::string &name, const std::string &path );

static std::string motd_value;

/** Map where we store filenames */
std::map<std::string, std::string> FILENAMES;

Expand Down Expand Up @@ -100,7 +102,7 @@ void update_datadir()
// Shared files
update_pathname( "title", FILENAMES["titledir"] + "en.title" );
update_pathname( "halloween", FILENAMES["titledir"] + "en.halloween" );
update_pathname( "motd", FILENAMES["motddir"] + "en.motd" );
motd_value = FILENAMES["datadir"] + "motd/" + "en.motd";
update_pathname( "credits", FILENAMES["creditsdir"] + "en.credits" );
update_pathname( "names", FILENAMES["namesdir"] + "en.json" );
}
Expand Down Expand Up @@ -143,12 +145,13 @@ void PATH_INFO::set_standard_filenames()
// Shared files
update_pathname( "title", FILENAMES["titledir"] + "en.title" );
update_pathname( "halloween", FILENAMES["titledir"] + "en.halloween" );
update_pathname( "motd", FILENAMES["motddir"] + "en.motd" );
motd_value = FILENAMES["datadir"] + "motd/" + "en.motd";
update_pathname( "credits", FILENAMES["creditsdir"] + "en.credits" );
update_pathname( "names", FILENAMES["namesdir"] + "en.json" );

update_pathname( "savedir", FILENAMES["user_dir"] + "save/" );
update_pathname( "memorialdir", FILENAMES["user_dir"] + "memorial/" );

#if defined(USE_XDG_DIR)
const char *user_dir;
std::string dir;
Expand Down Expand Up @@ -430,7 +433,7 @@ std::string PATH_INFO::credits()

std::string PATH_INFO::motd()
{
return find_translated_file( FILENAMES["motddir"], ".motd", FILENAMES["motd"] );
return find_translated_file( FILENAMES["motddir"], ".motd", motd_value );
}

std::string PATH_INFO::title( const bool halloween_theme )
Expand Down Expand Up @@ -483,5 +486,5 @@ void PATH_INFO::set_autopickup( const std::string &autopickup )

void PATH_INFO::set_motd( const std::string &motd )
{
update_pathname( "motd", motd );
motd_value = motd;
}

0 comments on commit fd71a90

Please sign in to comment.