Skip to content

Commit

Permalink
Add flexible tuning of custom icons for Warcraft, Starcraft in icons.…
Browse files Browse the repository at this point in the history
…conf
  • Loading branch information
HarpyWar committed Apr 7, 2014
1 parent f2d3ed2 commit c11af35
Show file tree
Hide file tree
Showing 17 changed files with 891 additions and 16 deletions.
10 changes: 5 additions & 5 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set(OUTPUT_CONFS ad.conf anongame_infos.conf address_translation.conf
bnhelp.conf bnissue.txt bnmaps.conf bnxpcalc.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
bnmotd-zhTW.txt bnmotd-ptBR.txt bnmotd_w3.txt
bnxplevel.conf channel.conf command_groups.conf news.txt realm.conf
sql_DB_layout2.conf sql_DB_layout.conf supportfile.conf topics.conf
tournament.conf versioncheck.conf)
tournament.conf versioncheck.conf icons.conf)
foreach(CONF ${OUTPUT_CONFS})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${CONF}.in ${CMAKE_CURRENT_BINARY_DIR}/${CONF} @ONLY)
endforeach(CONF)
Expand All @@ -25,16 +25,16 @@ if(WITH_BNETD)
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 bnmotd_w3.txt
realm.conf sql_DB_layout.conf sql_DB_layout2.conf supportfile.conf topics.conf
tournament.conf versioncheck.conf)
tournament.conf versioncheck.conf icons.conf)

# special treatement for non .in files
# special treatment for non .in files
install(FILES bnetd_default_user.cdb DESTINATION ${SYSCONFDIR})
endif(WITH_BNETD)

if(WITH_D2CS)
set(D2CS_CONFS d2cs.conf anongame_infos.conf)

# special treatement for non .in files
# special treatment for non .in files
install(FILES d2server.ini DESTINATION ${SYSCONFDIR})
endif(WITH_D2CS)

Expand Down
1 change: 1 addition & 0 deletions conf/bnetd.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ anongame_infos_file = "${SYSCONFDIR}/anongame_infos.conf"
DBlayoutfile = "${SYSCONFDIR}/sql_DB_layout.conf"
supportfile = "${SYSCONFDIR}/supportfile.conf"
transfile = "${SYSCONFDIR}/address_translation.conf"
customicons_file = "${SYSCONFDIR}/icons.conf"

fortunecmd = /usr/games/fortune

Expand Down
1 change: 1 addition & 0 deletions conf/bnetd.conf.win32
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ aliasfile = conf\bnalias.conf
anongame_infos_file = conf\anongame_infos.conf
DBlayoutfile = conf\sql_DB_layout.conf
supportfile = conf\supportfile.conf
customicons_file = conf\icons.conf

fortunecmd = bin\fortune.exe

Expand Down
103 changes: 103 additions & 0 deletions conf/icons.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
##############################################################################
# icons.conf - Custom icons configuration file #
#----------------------------------------------------------------------------#
# #
# Allowed clients: #
# W3XP, WAR3, STAR, SEXP, JSTR, SSHR, W2BN, DRTL, DSHR #
# #
# W3XP: It also disables icon selection from user portrait #
# #
# [icons] table format (first variable always corresponds to icon_key: #
# icon_key | rank | icon_code #
# #
# [stats] output format: #
# initialize variables under a client tag #
# band variables with figure brackets {{var}} #
# use {{variable->rank}} to display an icon rank for a custom variable #
# #
##############################################################################


##############################################################################
# General settings #
#----------------------------------------------------------------------------#

# Enable icon sets below
custom_icons = false



##############################################################################
# Warcraft 3 icon set #
#----------------------------------------------------------------------------#

[W3XP]
solo_level = "Record\W3XP\solo_level"
solo_xp = "Record\W3XP\solo_xp"
solo_wins = "Record\W3XP\solo_wins"
solo_losses = "Record\W3XP\solo_losses"
team_level = "Record\W3XP\team_level"
team_xp = "Record\W3XP\team_xp"
team_wins = "Record\W3XP\team_wins"
team_losses = "Record\W3XP\team_losses"
ffa_level = "Record\W3XP\ffa_level"
ffa_xp = "Record\W3XP\ffa_xp"
ffa_wins = "Record\W3XP\ffa_wins"
ffa_losses = "Record\W3XP\ffa_losses"
username = "BNET\acct\username"

[icons]
0 Beginner KBKB
1 Dungeon KBKD
2 Expert KBKE
3 Mid KBKM
4 Pro KBKP
5 World KBKW
6 Universe WCYB
[/icons]

[stats]
{{username}}'s record:
Solo games: [{{solo_level->rank}}] {{solo_xp}} xp ({{solo_wins}} - {{solo_losses}})
Team games: [{{team_level->rank}}] {{team_xp}} xp ({{team_wins}} - {{team_losses}})
FFA games: [{{ffa_level->rank}}] {{ffa_xp}} xp ({{ffa_wins}} - {{ffa_losses}})
[/stats]



##############################################################################
# Starcraft icon set #
#----------------------------------------------------------------------------#

[SEXP]
rating1 = "Record\SEXP\1_rating"
wins1 = "Record\SEXP\1_wins"
losses1 = "Record\SEXP\1_losses"
disconnects1 = "Record\SEXP\1_disconnects"
rating0 = "Record\SEXP\0_rating"
wins0 = "Record\SEXP\0_wins"
losses0 = "Record\SEXP\0_losses"
disconnects0 = "Record\SEXP\0_disconnects"
username = "BNET\acct\username"

[icons]
1000 n00b NOOB
1250 Chobo+ CHO1
1500 Chobo++ CHO2
1750 Chobo+++ CHO3
2000 Hasu+ HAS1
2300 Hasu++ HAS2
2650 Hasu+++ HAS3
3000 Gosu+ GOS1
3300 Gosu++ GOS2
3650 Gosu+++ GOS3
4000 Mega Gosu GOSU
5500 Father MEGA
[/icons]

[stats]
{{username}}'s record:
Ladder games: [{{rating1->rank}}] {{rating1}} pts ({{wins1}}/{{losses1}}/{{disconnects1}})
Normal games: [{{rating0->rank}}] {{rating0}} pts ({{wins0}}/{{losses0}}/{{disconnects0}})
[/stats]

30 changes: 29 additions & 1 deletion src/bnetd/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "clan.h"
#include "common/setup_after.h"
#include "common/flags.h"
#include "icons.h"

#include "attrlayer.h"

Expand Down Expand Up @@ -2185,6 +2186,29 @@ namespace pvpgn

clienttag_uint = tag_case_str_to_uint(clienttag);


// custom stats
if (prefs_get_custom_icons() == 1)
{
const char *text;

// if text is not empty
if (text = get_custom_stats_text(account, clienttag_uint))
{
// split by lines
char* output_array = strtok((char*)text, "\n");
while (output_array)
{
message_send_text(c, message_type_info, c, output_array);
output_array = strtok(NULL, "\n");
}
xfree((char*)text);

return 0;
}
}


switch (clienttag_uint)
{
case CLIENTTAG_BNCHATBOT_UINT:
Expand Down Expand Up @@ -4679,7 +4703,7 @@ namespace pvpgn
value = arg3;

// disallow get/set value for password hash and username (hash can be cracked easily, account name should be permanent)
if (std::strcmp(key, "bnet\\acct\\passhash1") == 0 || std::strcmp(key, "bnet\\acct\\username") == 0 || std::strcmp(key, "bnet\\username") == 0)
if (strcasecmp(key, "bnet\\acct\\passhash1") == 0 || strcasecmp(key, "bnet\\acct\\username") == 0 || strcasecmp(key, "bnet\\username") == 0)
{
message_send_text(c, message_type_info, c, "Access denied due to security reason.");
return 0;
Expand Down Expand Up @@ -4709,6 +4733,10 @@ namespace pvpgn
return 0;
}

// unset value
if (strcasecmp(value, "null") == 0)
value = NULL;

std::sprintf(msgtemp, "for \"%s\" (%.64s = \"%.128s\")", account_get_name(account), key, value);

if (account_set_strattr(account, key, value) < 0)
Expand Down
48 changes: 43 additions & 5 deletions src/bnetd/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "attrlayer.h"
#include "anongame_wol.h"
#include "common/setup_after.h"
#include "icons.h"

namespace pvpgn
{
Expand Down Expand Up @@ -2521,13 +2522,14 @@ namespace pvpgn
return 0;
}


/* Player icon that displayed in a channel in all games (except Warcraft 3) */
extern char const * conn_get_playerinfo(t_connection const * c)
{
t_account * account;
static char playerinfo[MAX_PLAYERINFO_STR];
t_clienttag clienttag;
char revtag[5];
char const * usericon;

if (!c)
{
Expand All @@ -2547,7 +2549,22 @@ namespace pvpgn
}
tag_uint_to_revstr(revtag, clienttag);

if (clienttag == CLIENTTAG_BNCHATBOT_UINT)
// allow set icon to a user directly from the database (override default tag always if not null)
if (usericon = account_get_user_icon(account, clienttag))
std::sprintf(revtag, usericon);

// if custom_icons is enabled then set a custom client tag by player rating
if (prefs_get_custom_icons() == 1)
{
t_icon_info * icon;

// do not override userselectedicon if it's not null
if (!usericon && (icon = get_custom_icon(account, clienttag)))
strcpy(revtag, icon->icon_code);

std::strcpy(playerinfo, revtag);
}
else if (clienttag == CLIENTTAG_BNCHATBOT_UINT)
{
std::strcpy(playerinfo, revtag); /* FIXME: what to return here? */
}
Expand Down Expand Up @@ -3674,6 +3691,7 @@ namespace pvpgn
return count;
}

/* Warcraft 3 icon that displayed in a channel */
extern int conn_update_w3_playerinfo(t_connection * c)
{
t_account * account;
Expand Down Expand Up @@ -3725,15 +3743,35 @@ namespace pvpgn
while ((*clantag_str) == 0) clantag_str++;
}

if (acctlevel == 0) {
// allow set icon to a user directly from the database (override default icon always if not null)
usericon = account_get_user_icon(account, clienttag);

// if custom stats is enabled then set a custom client icon by player rating
if (prefs_get_custom_icons() == 1)
{
t_icon_info * icon;

// do not override userselectedicon if it's not null
if (!usericon && (icon = get_custom_icon(account, clienttag)))
usericon = xstrdup(icon->icon_code);

acctlevel = 0;
if (clantag)
std::sprintf(tempplayerinfo, "%s %s %u %s", revtag, usericon, acctlevel, clantag_str);
else
std::sprintf(tempplayerinfo, "%s %s %u", revtag, usericon, acctlevel);
}
// default icon "WAR3" or "W3XP"
else if (acctlevel == 0 && !usericon) {
if (clantag)
std::sprintf(tempplayerinfo, "%s %s 0 %s", revtag, revtag, clantag_str);
else
std::strcpy(tempplayerinfo, revtag);
eventlog(eventlog_level_info, __FUNCTION__, "[%d] %s", conn_get_socket(c), revtag);
}
else {
usericon = account_get_user_icon(account, clienttag);
// display race icon with a level number
else
{
if (!usericon) {
if (clantag)
std::sprintf(tempplayerinfo, "%s %1u%c3W %u %s", revtag, raceiconnumber, raceicon, acctlevel, clantag_str);
Expand Down
Loading

0 comments on commit c11af35

Please sign in to comment.