Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → [HELP] pvpgn std::time

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 23

1

Topic: [HELP] pvpgn std::time

can you help me ? i have a problem with  std::time

it comes out : There was an error in std::time.

and 1 more question..

how to disable create new account with 3 character ? i want to change it to at least 4 character to create an ID

2

Re: [HELP] pvpgn std::time

gravestar wrote:

and 1 more question..

how to disable create new account with 3 character ? i want to change it to at least 4 character to create an ID


src/common/field_sizes.h

1.const unsigned MIN_USERNAME_LEN = 4;

3

Re: [HELP] pvpgn std::time

Mania wrote:
gravestar wrote:

and 1 more question..

how to disable create new account with 3 character ? i want to change it to at least 4 character to create an ID


src/common/field_sizes.h

1.const unsigned MIN_USERNAME_LEN = 4;

if im do that, i cant to create 2 character with /addacct right ? i mean, when people come to create an ID, in "Create New Account" it must be 4 character.. but admin still cant create 2 or 3 character

4

Re: [HELP] pvpgn std::time

You mean /addacct? Well, seems that MIN_USERNAME_LEN olny acts for create account packet. You have to change /addact command handler.

5

Re: [HELP] pvpgn std::time

xpeh wrote:

You mean /addacct? Well, seems that MIN_USERNAME_LEN olny acts for create account packet. You have to change /addact command handler.

hmm, where i can find /addacct command handler ?

btw, can you solve 1 problem again ?

"std::time error" <<

why std::time error come out ?

6

Re: [HELP] pvpgn std::time

gravestar wrote:

hmm, where i can find /addacct command handler ?

Search for "addact". AFAIR commands.c

gravestar wrote:

btw, can you solve 1 problem again ?

"std::time error" <<

why std::time error come out ?

Sorry, i don't know c(++) above basics.

7

Re: [HELP] pvpgn std::time

xpeh wrote:

Sorry, i don't know c(++) above basics.

оО

8

Re: [HELP] pvpgn std::time

Mania wrote:

оО

Why?

9

Re: [HELP] pvpgn std::time

xpeh wrote:
Mania wrote:

оО

Why?

я думал ты си и питон шаришь)

10

Re: [HELP] pvpgn std::time

Си я знаю настолько, насколько он пересекается с явой.

11

Re: [HELP] pvpgn std::time

please use english big_smile

12

Re: [HELP] pvpgn std::time

gravestar wrote:

can you help me ? i have a problem with  std::time

it comes out : There was an error in std::time.

and 1 more question..

how to disable create new account with 3 character ? i want to change it to at least 4 character to create an ID

Change system create account min 4 character via bnet, and 1 character via command: /addacct

change USER_NAME_MIN in field_sizes.h

#define USER_NAME_MIN           4

add new code in account.h

extern int account_check_name2(char const * name);

add new code in account.cpp

extern int account_check_name2(char const * name)
{
    unsigned int  i;
    char ch;

    if (!name) {
    eventlog(eventlog_level_error, __FUNCTION__,"got NULL name");
    return -1;
    }

    for (i=0; i<strlen(name); i++)
    {
        /* These are the Battle.net rules but they are too strict.
         * We want to allow any characters that wouldn't cause
         * problems so this should test for what is _not_ allowed
         * instead of what is.
         */
        ch = name[i];
    /* hardcoded safety checks */
    if (ch == '/' || ch == '\\') return -1;
        if (isalnum((int)ch)) continue;
    if (strchr(prefs_get_account_allowed_symbols(),ch)) continue;
        return -1;
    }
    if (i>=USER_NAME_MAX)
    return -1;
    return 0;
}

search account_create in account.cpp and change to

static t_account * account_create(char const * username, char const * passhash1)
{
    t_account * account;
    
    if (username && !passhash1) {
    eventlog(eventlog_level_error,__FUNCTION__,"got NULL passhash1");
    return NULL;
    }

    if (username && account_check_name2(username)) {
    eventlog(eventlog_level_error,__FUNCTION__,"got invalid chars in username");
    return NULL;
    }

    account = xmalloc(sizeof(t_account));

    account->name     = NULL;
    account->clanmember = NULL;
    account->attrgroup   = NULL;
    account->friends  = NULL;
    account->teams    = NULL;
    account->conn = NULL;
    FLAG_ZERO(&account->flags);

    account->namehash = 0; /* hash it later before inserting */
    account->uid      = 0; /* hash it later before inserting */

    if (username) { /* actually making a new account */
    /* first check if such a username already owns an account.
     * we search in the memory hash mainly for non-indexed storage types.
     * indexed storage types check themselves if the username exists already 
     * in the storage (see storage_sql.c) */
    if (accountlist_find_account(username)) {
        eventlog(eventlog_level_debug,__FUNCTION__,"user \"%s\" already has an account",username);
        goto err;
    }

    account->attrgroup =  attrgroup_create_newuser(username);
    if(!account->attrgroup) {
        eventlog(eventlog_level_error,__FUNCTION__,"failed to add user");
        goto err;
    }

    account->name = xstrdup(username);

        if (account_set_strattr(account,"BNET\\acct\\username",username)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set username");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set userid");
            goto err;
        }

    if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set passhash1");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\ctime",(unsigned int)now)) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set ctime");
            goto err;
        }
    }

    return account;

err:
    account_destroy(account);
    return NULL;
}

search account_load_new in account.cpp and change to

static t_account * account_load_new(char const * name, unsigned uid)
{
    t_account *account;
    t_attrgroup *attrgroup;

    if (name && account_check_name2(name)) return NULL;

    force_account_add = 1; /* disable the protection */

    attrgroup = attrgroup_create_nameuid(name, uid);
    if (!attrgroup) {
    force_account_add = 0;
    return NULL;
    }

    if (!(account = account_load(attrgroup))) {
        eventlog(eventlog_level_error, __FUNCTION__,"could not load account");
        attrgroup_destroy(attrgroup);
    force_account_add = 0;
        return NULL;
    }

    if (!accountlist_add_account(account)) {
        eventlog(eventlog_level_error, __FUNCTION__,"could not add account to list");
        account_destroy(account);
    force_account_add = 0;
        return NULL;
    }

    force_account_add = 0;

    return account;
}

change code in command.cpp

static int _handle_addacct_command(t_connection * c, char const *text)
{
    unsigned int i,j;
    t_account  * temp;
    t_hash       passhash;
    char         username[USER_NAME_MAX];
    char         pass[256];

    for (i=0; text[i]!=' ' && text[i]!='\0'; i++);
    for (; text[i]==' '; i++);

    for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get username */
    if (j<sizeof(username)-1) username[j++] = text[i];
    username[j] = '\0';

    for (; text[i]==' '; i++); /* skip spaces */
    for (j=0; text[i]!='\0'; i++) /* get pass (spaces are allowed) */
    if (j<sizeof(pass)-1) pass[j++] = text[i];
    pass[j] = '\0';

    if (username[0]=='\0' || pass[0]=='\0') {
    message_send_text(c,message_type_info,c,"Create new account must be at least 1 character long");
    message_send_text(c,message_type_info,c,"usage: /addacct <username> <password>");
        return 0;
    }

    if (account_check_name2(username)<0) {
        message_send_text(c,message_type_error,c,"Account name contains some invalid symbol!");
        return 0;
    }

    /* FIXME: truncate or err on too long password */
    for (i=0; i<strlen(pass); i++)
    if (isupper((int)pass[i])) pass[i] = tolower((int)pass[i]);

    bnet_hash(&passhash,strlen(pass),pass);
    
    snprintf(msgtemp, sizeof(msgtemp), "Trying to add account \"%.64s\" with password \"%.64s\"",username,pass);
    message_send_text(c,message_type_info,c,msgtemp);
    snprintf(msgtemp, sizeof(msgtemp), "Hash is: %.128s",hash_get_str(passhash));
    message_send_text(c,message_type_info,c,msgtemp);

    temp = accountlist_create_account(username,hash_get_str(passhash));
    if (!temp) {
    message_send_text(c,message_type_error,c,"Failed to create account!");
        eventlog(eventlog_level_debug,__FUNCTION__,"[%d] account \"%s\" not created (failed)",conn_get_socket(c),username);
    return 0;
    }
    
    snprintf(msgtemp, sizeof(msgtemp), "Number account \"%.64s\" is: "UID_FORMAT"",username,account_get_uid(temp));
    message_send_text(c,message_type_info,c,msgtemp);
    eventlog(eventlog_level_debug,__FUNCTION__,"[%d] account \"%s\" created",conn_get_socket(c),username);

    return 0;
}

Finish change system create account min 4 character via bnet, and 1 character via command: /addacct

13

Re: [HELP] pvpgn std::time

Zeloit wrote:
gravestar wrote:

can you help me ? i have a problem with  std::time

it comes out : There was an error in std::time.

and 1 more question..

how to disable create new account with 3 character ? i want to change it to at least 4 character to create an ID

Change system create account min 4 character via bnet, and 1 character via command: /addacct

change USER_NAME_MIN in field_sizes.h

#define USER_NAME_MIN           4

add new code in account.h

extern int account_check_name2(char const * name);

add new code in account.cpp

extern int account_check_name2(char const * name)
{
    unsigned int  i;
    char ch;

    if (!name) {
    eventlog(eventlog_level_error, __FUNCTION__,"got NULL name");
    return -1;
    }

    for (i=0; i<strlen(name); i++)
    {
        /* These are the Battle.net rules but they are too strict.
         * We want to allow any characters that wouldn't cause
         * problems so this should test for what is _not_ allowed
         * instead of what is.
         */
        ch = name[i];
    /* hardcoded safety checks */
    if (ch == '/' || ch == '\\') return -1;
        if (isalnum((int)ch)) continue;
    if (strchr(prefs_get_account_allowed_symbols(),ch)) continue;
        return -1;
    }
    if (i>=USER_NAME_MAX)
    return -1;
    return 0;
}

search account_create in account.cpp and change to

static t_account * account_create(char const * username, char const * passhash1)
{
    t_account * account;
    
    if (username && !passhash1) {
    eventlog(eventlog_level_error,__FUNCTION__,"got NULL passhash1");
    return NULL;
    }

    if (username && account_check_name2(username)) {
    eventlog(eventlog_level_error,__FUNCTION__,"got invalid chars in username");
    return NULL;
    }

    account = xmalloc(sizeof(t_account));

    account->name     = NULL;
    account->clanmember = NULL;
    account->attrgroup   = NULL;
    account->friends  = NULL;
    account->teams    = NULL;
    account->conn = NULL;
    FLAG_ZERO(&account->flags);

    account->namehash = 0; /* hash it later before inserting */
    account->uid      = 0; /* hash it later before inserting */

    if (username) { /* actually making a new account */
    /* first check if such a username already owns an account.
     * we search in the memory hash mainly for non-indexed storage types.
     * indexed storage types check themselves if the username exists already 
     * in the storage (see storage_sql.c) */
    if (accountlist_find_account(username)) {
        eventlog(eventlog_level_debug,__FUNCTION__,"user \"%s\" already has an account",username);
        goto err;
    }

    account->attrgroup =  attrgroup_create_newuser(username);
    if(!account->attrgroup) {
        eventlog(eventlog_level_error,__FUNCTION__,"failed to add user");
        goto err;
    }

    account->name = xstrdup(username);

        if (account_set_strattr(account,"BNET\\acct\\username",username)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set username");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set userid");
            goto err;
        }

    if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set passhash1");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\ctime",(unsigned int)now)) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set ctime");
            goto err;
        }
    }

    return account;

err:
    account_destroy(account);
    return NULL;
}

search account_load_new in account.cpp and change to

static t_account * account_load_new(char const * name, unsigned uid)
{
    t_account *account;
    t_attrgroup *attrgroup;

    if (name && account_check_name2(name)) return NULL;

    force_account_add = 1; /* disable the protection */

    attrgroup = attrgroup_create_nameuid(name, uid);
    if (!attrgroup) {
    force_account_add = 0;
    return NULL;
    }

    if (!(account = account_load(attrgroup))) {
        eventlog(eventlog_level_error, __FUNCTION__,"could not load account");
        attrgroup_destroy(attrgroup);
    force_account_add = 0;
        return NULL;
    }

    if (!accountlist_add_account(account)) {
        eventlog(eventlog_level_error, __FUNCTION__,"could not add account to list");
        account_destroy(account);
    force_account_add = 0;
        return NULL;
    }

    force_account_add = 0;

    return account;
}

change code in command.cpp

static int _handle_addacct_command(t_connection * c, char const *text)
{
    unsigned int i,j;
    t_account  * temp;
    t_hash       passhash;
    char         username[USER_NAME_MAX];
    char         pass[256];

    for (i=0; text[i]!=' ' && text[i]!='\0'; i++);
    for (; text[i]==' '; i++);

    for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get username */
    if (j<sizeof(username)-1) username[j++] = text[i];
    username[j] = '\0';

    for (; text[i]==' '; i++); /* skip spaces */
    for (j=0; text[i]!='\0'; i++) /* get pass (spaces are allowed) */
    if (j<sizeof(pass)-1) pass[j++] = text[i];
    pass[j] = '\0';

    if (username[0]=='\0' || pass[0]=='\0') {
    message_send_text(c,message_type_info,c,"Create new account must be at least 1 character long");
    message_send_text(c,message_type_info,c,"usage: /addacct <username> <password>");
        return 0;
    }

    if (account_check_name2(username)<0) {
        message_send_text(c,message_type_error,c,"Account name contains some invalid symbol!");
        return 0;
    }

    /* FIXME: truncate or err on too long password */
    for (i=0; i<strlen(pass); i++)
    if (isupper((int)pass[i])) pass[i] = tolower((int)pass[i]);

    bnet_hash(&passhash,strlen(pass),pass);
    
    snprintf(msgtemp, sizeof(msgtemp), "Trying to add account \"%.64s\" with password \"%.64s\"",username,pass);
    message_send_text(c,message_type_info,c,msgtemp);
    snprintf(msgtemp, sizeof(msgtemp), "Hash is: %.128s",hash_get_str(passhash));
    message_send_text(c,message_type_info,c,msgtemp);

    temp = accountlist_create_account(username,hash_get_str(passhash));
    if (!temp) {
    message_send_text(c,message_type_error,c,"Failed to create account!");
        eventlog(eventlog_level_debug,__FUNCTION__,"[%d] account \"%s\" not created (failed)",conn_get_socket(c),username);
    return 0;
    }
    
    snprintf(msgtemp, sizeof(msgtemp), "Number account \"%.64s\" is: "UID_FORMAT"",username,account_get_uid(temp));
    message_send_text(c,message_type_info,c,msgtemp);
    eventlog(eventlog_level_debug,__FUNCTION__,"[%d] account \"%s\" created",conn_get_socket(c),username);

    return 0;
}

Finish change system create account min 4 character via bnet, and 1 character via command: /addacct


the code is error
please fix the code

14

Re: [HELP] pvpgn std::time

the code is work on pvpgn 1.8.5

if you using pvpgn 1.99 you need add code

std::

before

snprintf

ex:

std::snprintf

15

Re: [HELP] pvpgn std::time

Zeloit wrote:

the code is work on pvpgn 1.8.5

if you using pvpgn 1.99 you need add code

std::

before

snprintf

ex:

std::snprintf

help zeloit plis

16 (edited by Zeloit 05.11.2013 04:13)

Re: [HELP] pvpgn std::time

change USER_NAME_MAX to MAX_USERNAME_LEN

17

Re: [HELP] pvpgn std::time

Zeloit wrote:

change USER_NAME_MAX to MAX_USERNAME_LEN

thanks, works perfectly

18

Re: [HELP] pvpgn std::time

Zeloit wrote:

change USER_NAME_MAX to MAX_USERNAME_LEN

please make tutorial for 1.99-svn

19

Re: [HELP] pvpgn std::time

http://forums.harpywar.com/extensions/hcs_image_uploader/uploads/0/5500/5585/thumb/p18aljgn4r5n010jqeu11joqkk1.JPG

Please Help Me!

20 (edited by Zeloit 30.11.2013 12:11)

Re: [HELP] pvpgn std::time

Satria wrote:

http://forums.harpywar.com/extensions/hcs_image_uploader/uploads/0/5500/5585/thumb/p18aljgn4r5n010jqeu11joqkk1.JPG

Please Help Me!

this is error in file acccount.cpp line 108
open file account.cpp and show me that code

21

Re: [HELP] pvpgn std::time

http://forums.harpywar.com/extensions/hcs_image_uploader/uploads/0/5500/5587/thumb/p18allo8gj1ipd149mg87lhf2td1.JPG

thats

Added: 30.11.2013 16:34

static t_account * account_create(char const * username, char const * passhash1)
{
    t_account * account;
    
    if (username && !passhash1) {
    eventlog(eventlog_level_error,__FUNCTION__,"got NULL passhash1");
    return NULL;
    }

    if (username && account_check_name2(username)) {
    eventlog(eventlog_level_error,__FUNCTION__,"got invalid chars in username");
    return NULL;
    }

    account = xmalloc(sizeof(t_account));

    account->name     = NULL;
    account->clanmember = NULL;
    account->attrgroup   = NULL;
    account->friends  = NULL;
    account->teams    = NULL;
    account->conn = NULL;
    FLAG_ZERO(&account->flags);

    account->namehash = 0; /* hash it later before inserting */
    account->uid      = 0; /* hash it later before inserting */

    if (username) { /* actually making a new account */
    /* first check if such a username already owns an account.
     * we search in the memory hash mainly for non-indexed storage types.
     * indexed storage types check themselves if the username exists already 
     * in the storage (see storage_sql.c) */
    if (accountlist_find_account(username)) {
        eventlog(eventlog_level_debug,__FUNCTION__,"user \"%s\" already has an account",username);
        goto err;
    }

    account->attrgroup =  attrgroup_create_newuser(username);
    if(!account->attrgroup) {
        eventlog(eventlog_level_error,__FUNCTION__,"failed to add user");
        goto err;
    }

    account->name = xstrdup(username);

        if (account_set_strattr(account,"BNET\\acct\\username",username)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set username");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set userid");
            goto err;
        }

    if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set passhash1");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\ctime",(unsigned int)now)) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set ctime");
            goto err;
        }
    }

    return account;

err:
    account_destroy(account);
    return NULL;
}

    if (username) { /* actually making a new account */
    /* first check if such a username already owns an account.
     * we search in the memory hash mainly for non-indexed storage types.
     * indexed storage types check themselves if the username exists already
     * in the storage (see storage_sql.c) */
    if (accountlist_find_account(username)) {
        eventlog(eventlog_level_debug,__FUNCTION__,"user \"%s\" already has an account",username);
        goto err;
    }

    account->attrgroup =  attrgroup_create_newuser(username);
    if(!account->attrgroup) {
        eventlog(eventlog_level_error,__FUNCTION__,"failed to add user");
        goto err;
    }

    account->name = xstrdup(username);

        if (account_set_strattr(account,"BNET\\acct\\username",username)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set username");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set userid");
            goto err;
        }

    if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set passhash1");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\ctime",(unsigned int)now)) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set ctime");
            goto err;
        }
    }

    return account;

err:
    account_destroy(account);
    return NULL;
}

22

Re: [HELP] pvpgn std::time

change

account = xmalloc(sizeof(t_account));

to

account = (t_account*)xmalloc(sizeof(t_account));

23

Re: [HELP] pvpgn std::time

Zeloit wrote:

change

account = xmalloc(sizeof(t_account));

to

account = (t_account*)xmalloc(sizeof(t_account));

Worked
Thanks Zeloit big_smile

Posts: 23

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 1 guest, 0 registered users

forums.pvpgn.pro → [EN] The Source Code → [HELP] pvpgn std::time