Skip to content

Commit

Permalink
Welcome text for Warcraft 3 is moved into new file conf/bnmotd_w3.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
HarpyWar committed Mar 27, 2014
1 parent d96e102 commit ff8ca94
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(WITH_BNETD)
bnetd_default_user.plain bnhelp.conf bnissue.txt bnmaps.conf bnmotd-enUS.txt
bnmotd-csCZ.txt bnmotd-deDE.txt bnmotd-esES.txt bnmotd-frFR.txt bnmotd-nlNL.txt
bnmotd-plPL.txt bnmotd-ruRU.txt bnmotd-zhCN.txt bnmotd-zhTW.txt bnmotd-ptBR.txt
bnxpcalc.conf bnxplevel.conf channel.conf command_groups.conf news.txt
bnxpcalc.conf bnxplevel.conf channel.conf command_groups.conf news.txt bnmotd_w3.txt
realm.conf sql_DB_layout.conf sql_DB_layout2.conf supportfile.conf topics.conf
tournament.conf versioncheck.conf)

Expand Down
12 changes: 12 additions & 0 deletions conf/bnmotd_w3.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Welcome to the greatest PvPGN server!

|c00FF0000Here |c00FF9933you |c0000CCFFcan |c00A8A8A8 use |c0000CC00coloured |c00FFFF00text |c009999FFas |c00FF66FFfollow|c00FFFFFF:
"|00HEXCOLOR your text here"





(edit this text in conf/bnmotd_w3.txt)

This text will not displayed, because there is limitation of 11 lines
16 changes: 15 additions & 1 deletion src/bnetd/handle_bnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "common/setup_before.h"
#include "handle_bnet.h"

#include <fstream>
#include <sstream>
#include <cstring>
#include <cctype>
Expand Down Expand Up @@ -2700,6 +2701,7 @@ namespace pvpgn
return 0;
}

// motd for warcraft 3 (http://img21.imageshack.us/img21/1808/j2py.png)
static int _client_motdw3(t_connection * c, t_packet const *const packet)
{
t_packet *rpacket;
Expand Down Expand Up @@ -2740,7 +2742,19 @@ namespace pvpgn
bn_int_set(&rpacket->u.server_motd_w3.timestamp, motdd.fnews + 1);
bn_int_set(&rpacket->u.server_motd_w3.timestamp2, SERVER_MOTD_W3_WELCOME);

snprintf(serverinfo, sizeof(serverinfo), "Welcome to the " PVPGN_SOFTWARE " Version " PVPGN_VERSION "\r\n\r\nThere are currently %u user(s) in %u games of %s, and %u user(s) playing %u games and chatting in %u channels in %s.\r\n%s", conn_get_user_count_by_clienttag(conn_get_clienttag(c)), game_get_count_by_clienttag(ctag), clienttag_get_title(conn_get_clienttag(c)), connlist_login_get_length(), gamelist_get_length(), channellist_get_length(), prefs_get_servername(), prefs_get_server_info());

// read text from bnmotd_w3.txt
char const * filename;
char * buff;
std::FILE * fp;

std::ifstream in(filename = prefs_get_motdw3file());
if (in) {
std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
strcpy(serverinfo, contents.substr(0,511).c_str());
} else
eventlog(eventlog_level_error, __FUNCTION__, "Could not open file motdw3 \"%s\" (std::fopen: %s)", filename, std::strerror(errno));


packet_append_string(rpacket, serverinfo);

Expand Down
27 changes: 27 additions & 0 deletions src/bnetd/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace pvpgn
char const * logfile;
char const * loglevels;
char const * motdfile;
char const * motdw3file;
char const * newsfile;
char const * channelfile;
char const * pidfile;
Expand Down Expand Up @@ -193,6 +194,10 @@ namespace pvpgn
static const char *conf_get_motdfile(void);
static int conf_setdef_motdfile(void);

static int conf_set_motdw3file(const char *valstr);
static const char *conf_get_motdw3file(void);
static int conf_setdef_motdw3file(void);

static int conf_set_newsfile(const char *valstr);
static const char *conf_get_newsfile(void);
static int conf_setdef_newsfile(void);
Expand Down Expand Up @@ -697,6 +702,7 @@ namespace pvpgn
{ "logfile", conf_set_logfile, conf_get_logfile, conf_setdef_logfile },
{ "loglevels", conf_set_loglevels, conf_get_loglevels, conf_setdef_loglevels },
{ "motdfile", conf_set_motdfile, conf_get_motdfile, conf_setdef_motdfile },
{ "motdw3file", conf_set_motdw3file, conf_get_motdw3file, conf_setdef_motdw3file },
{ "newsfile", conf_set_newsfile, conf_get_newsfile, conf_setdef_newsfile },
{ "channelfile", conf_set_channelfile, conf_get_channelfile, conf_setdef_channelfile },
{ "pidfile", conf_set_pidfile, conf_get_pidfile, conf_setdef_pidfile },
Expand Down Expand Up @@ -963,6 +969,27 @@ namespace pvpgn
}


extern char const * prefs_get_motdw3file(void)
{
return prefs_runtime_config.motdw3file;
}

static int conf_set_motdw3file(const char *valstr)
{
return conf_set_str(&prefs_runtime_config.motdw3file, valstr, NULL);
}

static int conf_setdef_motdw3file(void)
{
return conf_set_str(&prefs_runtime_config.motdw3file, NULL, BNETD_MOTDW3_FILE);
}

static const char* conf_get_motdw3file(void)
{
return prefs_runtime_config.motdw3file;
}


extern char const * prefs_get_newsfile(void)
{
return prefs_runtime_config.newsfile;
Expand Down
1 change: 1 addition & 0 deletions src/bnetd/prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace pvpgn
extern char const * prefs_get_logfile(void);
extern char const * prefs_get_loglevels(void);
extern char const * prefs_get_motdfile(void);
extern char const * prefs_get_motdw3file(void);
extern char const * prefs_get_newsfile(void);
extern char const * prefs_get_adfile(void);
extern char const * prefs_get_topicfile(void);
Expand Down
1 change: 1 addition & 0 deletions src/common/setup_before.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const char * const BNETD_STORAGE_PATH = "";
const char * const BNETD_REPORT_DIR = "reports";
const char * const BNETD_LOG_FILE = "logs/bnetd.log";
const char * const BNETD_MOTD_FILE = "conf/bnmotd.txt";
const char * const BNETD_MOTDW3_FILE = "conf/bnmotd_w3.txt";
const char * const BNETD_NEWS_DIR = "news";
const char * const BNETD_AD_FILE = "conf/ad.conf";
const char * const BNETD_CHANNEL_FILE = "conf/channel.conf";
Expand Down

0 comments on commit ff8ca94

Please sign in to comment.