Skip to content

Commit

Permalink
/icon enhancements:
Browse files Browse the repository at this point in the history
* removed clienttag from the command syntax
* simple syntax for normal user: /icon [code]
* complex syntax for operator/admin: /icon set|add|del|list [username] [code]
* add aliases for icon codes in icons.conf (users can use alias name instead of code)
* refactoring customicons function names #10
  • Loading branch information
HarpyWar committed Apr 29, 2014
1 parent 8638b17 commit 36deb11
Show file tree
Hide file tree
Showing 10 changed files with 581 additions and 104 deletions.
49 changes: 26 additions & 23 deletions conf/bnhelp.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# You can enter comments by starting a line with #. Comments extend to the #
# end of the line. #
# Tabs replaces with 3 spaces. #
# Empty lines are ignored. #
# Empty lines are ignored. #
# #
##############################################################################

Expand Down Expand Up @@ -223,7 +223,7 @@

%kill
--------------------------------------------------------
/kill {<username>|#<socket>} [<min>]
/kill {<username>|#<socket>} [min]
Disconnects <player> from the server and bans the player's IP address for [min] minutes.

Example: /kill nomad 5
Expand Down Expand Up @@ -325,10 +325,11 @@

%lock lockacct
--------------------------------------------------------
/lock <player> (alias: /lockacct)
/lock <player> [hours] [reason] (alias: /lockacct)
Locks <player>'s account to prevent him/her from logging in with it.
Set [hours] = 0 to ban permanently.

Example: /lock nomad
Example: /lock nomad 0 bye noob!

%unlock unlockacct
--------------------------------------------------------
Expand All @@ -339,10 +340,11 @@

%mute muteacct
--------------------------------------------------------
/mute <player> (alias: /muteacct)
/mute <player> [hours] [reason] (alias: /muteacct)
Mutes <player>'s account to prevent him/her from talking on channels.
Set [hours] = 0 to mute permanently.

Example: /mute nomad
Example: /mute nomad 6 stop spam!

%unmute unmuteacct
--------------------------------------------------------
Expand Down Expand Up @@ -374,11 +376,11 @@
--------------------------------------------------------
/mail <command> [options]
--------------------------------------------------------
/mail send <receiver> <message>
/mail [s]end <receiver> <message>
Sends mail to <receiver> with <message>.
/mail read [index]
/mail [r]ead [index]
Reads mail [index]
/mail delete {all|<index>}
/mail [del]ete {all|<index>}
Deletes mail <index> or [all] mail.

%flag
Expand Down Expand Up @@ -410,8 +412,6 @@
Deletes IP address <IP> or <index>
/ipban a[dd] <IP> [time]
Bans IP address <IP> for [time] minutes. [time] = 0 - permanent ban
/ipban h[elp]
Displays help for this command.

%set
--------------------------------------------------------
Expand Down Expand Up @@ -576,15 +576,18 @@ Commands for clan chieftain:

%icon
--------------------------------------------------------
/icon <username> [code] [gametag]
Set custom usericon. If [gametag] is empty then last user clienttag is used.
Set [code] = null to enable default icon.

Example: /icon nomad W3D6
Example: /icon nomad EYES SEXP






/icon [name]
Set custom icon for normal user.
Use /icon without [name] to display list of available icons in your stash.
--------------------------------------------------------
Syntax for operator/admin:
/icon [a]dd <username> <icon>
Add icon into user stash
/icon [d]el <username> <icon>
Remove icon from user stash
/icon [s]et <username> <icon>
Set custom icon to user without adding it in user stash
/icon [l]ist <username>
Display icons in user's stash
/icon [l]ist
Display availaible icons in server stash that can be assigned to users
2 changes: 1 addition & 1 deletion conf/command_groups.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
1 /bitsinfo
1 /latency /ping /p
1 /topic
1 /icon

# /////////////////////////////
# ///// Operator commands /////
Expand Down Expand Up @@ -168,7 +169,6 @@
7 /set
7 /commandgroups /cg
7 /clearstats
7 /icon

8 /shutdown /rehash /find /save

Expand Down
21 changes: 17 additions & 4 deletions conf/icons.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
# band variables with figure brackets {{var}} #
# use {{variable->rank}} to display an icon rank for a custom variable #
# #
# [iconstash] list of available icons that admins can set to user with /icon #
# icon_alias | icon_code #
# /icon can be set by alias or code, and it's not necessary to add alias #
# in the table. icon_alias or icon_code can not equal "default" #
# #
##############################################################################


Expand All @@ -23,13 +28,12 @@
#----------------------------------------------------------------------------#

# Enable icon sets below
custom_icons = false
custom_icons = true



##############################################################################
# Warcraft 3 icon set #
# Use MPQ editor to edit icons-WAR3.bni (just change extension bni->mpq) #
#----------------------------------------------------------------------------#

[W3XP]
Expand Down Expand Up @@ -64,12 +68,16 @@ 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]

[iconstash]
smile BOMB
starcraft SEXP
warcraft WAR3
diablo DRTL
[/iconstash]


##############################################################################
# Starcraft icon set #
# Use Bni Icon Builder to edit icons.bni (icons_STAR.bni is not used) #
# https://github.com/HarpyWar/bni-icon-builder #
#----------------------------------------------------------------------------#

[SEXP]
Expand Down Expand Up @@ -104,3 +112,8 @@ Ladder games: [{{rating1->rank}}] {{rating1}} pts ({{wins1}}/{{losses1}}/{{disco
Normal games: [{{rating0->rank}}] {{rating0}} pts ({{wins0}}/{{losses0}}/{{disconnects0}})
[/stats]

[iconstash]
demon EYES
warcraft WAR3
diablo DRTL
[/iconstash]
29 changes: 29 additions & 0 deletions src/bnetd/account_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,35 @@ namespace pvpgn
return -1;
}


/* value = icons delimeted by space */
extern int account_set_user_iconstash(t_account * account, t_clienttag clienttag, char const * value)
{
char key[256];
char clienttag_str[5];

std::sprintf(key, "Record\\%s\\iconstash", tag_uint_to_str(clienttag_str, clienttag));
if (value)
return account_set_strattr(account, key, value);
else
return account_set_strattr(account, key, "NULL");
}

extern char const * account_get_user_iconstash(t_account * account, t_clienttag clienttag)
{
char key[256];
char const * retval;
char clienttag_str[5];

std::sprintf(key, "Record\\%s\\iconstash", tag_uint_to_str(clienttag_str, clienttag));
retval = account_get_strattr(account, key);

if ((retval) && ((std::strcmp(retval, "NULL") != 0)))
return retval;
else
return NULL;
}

//BlacKDicK 04/20/2003
extern int account_set_user_icon(t_account * account, t_clienttag clienttag, char const * usericon)
{
Expand Down
2 changes: 2 additions & 0 deletions src/bnetd/account_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ namespace pvpgn
extern int account_get_profile_calcs(t_account * account, int xp, unsigned int level);
extern unsigned int account_get_icon_profile(t_account * account, t_clienttag clienttag);

extern int account_set_user_iconstash(t_account * account, t_clienttag clienttag, char const * value);
extern char const * account_get_user_iconstash(t_account * account, t_clienttag clienttag);
extern int account_set_user_icon(t_account * account, t_clienttag clienttag, char const * usericon);
extern char const * account_get_user_icon(t_account * account, t_clienttag clienttag);
extern unsigned int account_icon_to_profile_icon(char const * icon, t_account * account, t_clienttag ctag);
Expand Down
2 changes: 1 addition & 1 deletion src/bnetd/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ namespace pvpgn
const char *text;

// if text is not empty
if (text = get_custom_stats_text(account, clienttag_uint))
if (text = customicons_get_stats_text(account, clienttag_uint))
{
// split by lines
char* output_array = strtok((char*)text, "\n");
Expand Down
4 changes: 2 additions & 2 deletions src/bnetd/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ namespace pvpgn
t_icon_info * icon;

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

// FIXME: it replaces tag with icon on a client side for all clients (HarpyWar)
Expand Down Expand Up @@ -3751,7 +3751,7 @@ namespace pvpgn
t_icon_info * icon;

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

acctlevel = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/bnetd/handle_anongame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ namespace pvpgn
{
// get current custom icon
t_icon_info * icon;
if (icon = get_custom_icon(acc, clienttag))
if (icon = customicons_get_icon_by_account(acc, clienttag))
std::memcpy(&rpacket->u.server_findanongame_iconreply.curricon, icon->icon_code, 4);
}
else if ((uicon = account_get_user_icon(acc, clienttag)))
Expand Down
Loading

0 comments on commit 36deb11

Please sign in to comment.