Added login user count colorization (#3651)

Credits to @4144 for his implementation of the feature.
This commit is contained in:
Lemongrass3110 2018-11-05 21:42:25 +01:00 committed by GitHub
parent 13006e19a6
commit caab654fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 2 deletions

View File

@ -110,6 +110,16 @@ start_limited_time: -1
// NOTE: Will not work with clients that use <passwordencrypt>
use_MD5_passwords: no
// User count colorization on login window (requires PACKETVER >= 20170726)
// Disable colorization and description in general?
usercount_disable: no
// Amount of users that will display in green
usercount_low: 200
// Amount of users that will display in yellow
usercount_medium: 500
// Amount of users that will display in red
usercount_high: 1000
// Ipban features
ipban_enable: yes
// Dynamic password failure ipban system

View File

@ -439,6 +439,24 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd,
}
}
int login_get_usercount( int users ){
#if PACKETVER >= 20170726
if( login_config.usercount_disable ){
return 4; // Removes count and colorization completely
}else if( users <= login_config.usercount_low ){
return 0; // Green => Smooth
}else if( users <= login_config.usercount_medium ){
return 1; // Yellow => Normal
}else if( users <= login_config.usercount_high ){
return 2; // Red => Busy
}else{
return 3; // Purple => Crowded
}
#else
return users;
#endif
}
/**
* Test to determine if an IP come from LAN or WAN.
* @param ip: ip to check if in auth network
@ -628,7 +646,15 @@ bool login_config_read(const char* cfgName, bool normal) {
nnode->next = login_config.client_hash_nodes;
login_config.client_hash_nodes = nnode;
}
} else if(strcmpi(w1, "chars_per_account") == 0) { //maxchars per account [Sirius]
} else if (!strcmpi(w1, "usercount_disable"))
login_config.usercount_disable = config_switch(w2);
else if (!strcmpi(w1, "usercount_low"))
login_config.usercount_low = atoi(w2);
else if (!strcmpi(w1, "usercount_medium"))
login_config.usercount_medium = atoi(w2);
else if (!strcmpi(w1, "usercount_high"))
login_config.usercount_high = atoi(w2);
else if(strcmpi(w1, "chars_per_account") == 0) { //maxchars per account [Sirius]
login_config.char_per_account = atoi(w2);
if( login_config.char_per_account <= 0 || login_config.char_per_account > MAX_CHARS ) {
if( login_config.char_per_account > MAX_CHARS ) {
@ -699,6 +725,10 @@ void login_set_defaults() {
login_config.client_hash_check = 0;
login_config.client_hash_nodes = NULL;
login_config.usercount_disable = false;
login_config.usercount_low = 200;
login_config.usercount_medium = 500;
login_config.usercount_high = 1000;
login_config.char_per_account = MAX_CHARS - MAX_CHAR_VIP - MAX_CHAR_BILLING;
#ifdef VIP_ENABLE
login_config.vip_sys.char_increase = MAX_CHAR_VIP;

View File

@ -97,6 +97,11 @@ struct Login_Config {
char msgconf_name[256]; /// name of msg_conf config file
char lanconf_name[256]; /// name of lan config file
bool usercount_disable; /// Disable colorization and description in general?
int usercount_low; /// Amount of users that will display in green
int usercount_medium; /// Amount of users that will display in yellow
int usercount_high; /// Amount of users that will display in red
int char_per_account; /// number of characters an account can have
#ifdef VIP_ENABLE
struct {
@ -228,4 +233,6 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con
*/
int login_mmo_auth(struct login_session_data* sd, bool isServer);
int login_get_usercount( int users );
#endif /* LOGIN_HPP */

View File

@ -139,7 +139,7 @@ static void logclif_auth_ok(struct login_session_data* sd) {
WFIFOL(fd,header+n*size) = htonl((subnet_char_ip) ? subnet_char_ip : ch_server[i].ip);
WFIFOW(fd,header+n*size+4) = ntows(htons(ch_server[i].port)); // [!] LE byte order here [!]
memcpy(WFIFOP(fd,header+n*size+6), ch_server[i].name, 20);
WFIFOW(fd,header+n*size+26) = ch_server[i].users;
WFIFOW(fd,header+n*size+26) = login_get_usercount( ch_server[i].users );
WFIFOW(fd,header+n*size+28) = ch_server[i].type;
WFIFOW(fd,header+n*size+30) = ch_server[i].new_;
#if PACKETVER >= 20170315