From 3eaf284a600c01cf35d97245b8bf1cb5a157abf5 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sun, 25 Feb 2007 15:38:12 +0000 Subject: - Fixed a compiler warning in char_sql\login.c - Minor source documentation/cleanup. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9917 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 ++ src/login_sql/login.c | 5 +-- src/map/clif.c | 27 +++++++------ src/map/script.c | 107 ++++++++++++++++++++++++++++---------------------- 4 files changed, 82 insertions(+), 60 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index c36e8f9dd..680466855 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/02/27 + * Fixed a compiler warning in char_sql\login.c + * Minor source documentation/cleanup. [FlavioJS] 2007/02/26 * You are allowed to expel guild mates that are not online now. * Corrected damage of BloodDrain diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 0e68cf8ec..394586f4f 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -1444,15 +1444,14 @@ int parse_fromchar(int fd){ int lan_subnetcheck(long p) { int i; - unsigned char *sbn, *msk, *src = (unsigned char *)&p; + //unsigned char *sbn, *msk, *src = (unsigned char *)&p; for(i=0; i MsgStringTable[1040]="You have equipped throwing daggers." +/// gunslinger => MsgStringTable[1175]="Bullets have been equipped." +/// NOT ninja => MsgStringTable[245]="Ammunition has been equipped." int clif_arrow_fail(struct map_session_data *sd,int type) { int fd; @@ -9589,7 +9591,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) (type == 2 && sd->status.base_level <= 40) || pc_setcart(sd,type) ) { - LOG_SUSPICIOUS(sd,"clif_parse_ChangeCart: player doesn't have the required level"); + LOG_SUSPICIOUS(sd,"clif_parse_ChangeCart"); } } @@ -11282,8 +11284,11 @@ void clif_friendslist_send(struct map_session_data *sd) { } } - -// Status for adding friend - 0: successfull 1: not exist/rejected 2: over limit +/// Reply for add friend request: (success => type 0) +/// type=0 : MsgStringTable[821]="You have become friends with (%s)." +/// type=1 : MsgStringTable[822]="(%s) does not want to be friends with you." +/// type=2 : MsgStringTable[819]="Your Friend List is full." +/// type=3 : MsgStringTable[820]="(%s)'s Friend List is full." void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_data *f_sd, int type) { int fd; diff --git a/src/map/script.c b/src/map/script.c index 3edea1b80..eae396d4a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -236,8 +236,8 @@ enum c_op { C_NEG, // - a C_LNOT, // ! a C_NOT, // ~ a - C_R_SHIFT, // a << b - C_L_SHIFT // a >> b + C_R_SHIFT, // a >> b + C_L_SHIFT // a << b }; enum { @@ -567,76 +567,90 @@ void set_label(int l,int pos, const char* script_pos) } } -/*========================================== - * スペース/コメント読み飛ばし - *------------------------------------------ - */ -static const char *skip_space(const char *p) +/// Skips spaces and/or comments. +static +const char* skip_space(const char* p) { - for(;;){ - while(ISSPACE(*p)) + for(;;) + { + while( ISSPACE(*p) ) ++p; - if( *p=='/' && p[1]=='/' ){ + if( *p == '/' && p[1] == '/' ) + {// line comment while(*p && *p!='\n') ++p; - } else if( *p=='/' && p[1]=='*' ){ - p+=2; - if(*p) ++p; - while( *p && (p[-1]!='*' || *p!='/') ) - p++; - if(*p) - ++p; - else - disp_error_message("skip_space: unexpected eof @ block comment",p); - } else + } + else if( *p == '/' && p[1] == '*' ) + {// block comment + p += 2; + for(;;) + { + if( *p == '\0' ) + disp_error_message("script:skip_space: end of file while parsing block comment. expected "CL_BOLD"*/"CL_NORM, p); + if( *p == '*' || p[1] == '/' ) + {// end of block comment + p += 2; + break; + } + } + } + else break; } return p; } -/*========================================== - * 1単語スキップ - *------------------------------------------ - */ -static const char *skip_word(const char *p) +/// Skips a word. +/// A word consists of undercores and/or alfanumeric characters, +/// and valid variable prefixes/postfixes. +static +const char* skip_word(const char* p) { // prefix - if(*p=='.') p++; - if(*p=='$') p++; // MAP鯖内共有変数用 - if(*p=='@') p++; // 一時的変数用(like weiss) - if(*p=='#') p++; // account変数用 - if(*p=='#') p++; // ワールドaccount変数用 - - //# Changing from unsigned char to signed char makes p never be able to go above 0x81, but what IS 0x81 for? [Skotlex] - //# It's for multibyte encodings like Shift-JIS. Unfortunately this can be problematic for singlebyte encodings. - // Using (*p)>>7 would yield the appropriate result but it's better to restrict words to ASCII characters only. [FlavioJS] + switch( *p ) + { + case '@':// temporary char variable + ++p; break; + case '#':// account variable + p += ( p[1] == '#' ? 2 : 1 ); break; + case '.':// npc variable + p += ( p[1] == '@' ? 2 : 1 ); break; + case '$':// global variable + p += ( p[1] == '@' ? 2 : 1 ); break; + } + while( ISALNUM(*p) || *p == '_' ) ++p; + // postfix - if(*p=='$') p++; // 文字列変数 + if( *p == '$' )// string + p++; return p; } -/// Adds a word to str_data -int add_word(const char *p) +/// Adds a word to str_data. +/// @see skip_word +/// @see add_str +static +int add_word(const char* p) { - char *word; + char* word; int len; int i; // Check for a word - len = skip_word(p)-p; + len = skip_word(p) - p; if( len == 0 ) - disp_error_message("add_word: not a word",p); + disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alfanumeric characters, and valid variable prefixes/postfixes.", p); - // Copy the word - CREATE(word,char,len+1); - memcpy(word,p,len); - word[len]=0; + // Duplicate the word + CREATE(word, char, len+1); + memcpy(word, p, len); + word[len] = 0; // add the word - i=add_str(word); + i = add_str(word); aFree(word); return i; } @@ -644,7 +658,8 @@ int add_word(const char *p) /// Parses a function call. /// The argument list can have parenthesis or not. /// The number of arguments is checked. -static const char* parse_callfunc(const char *p, int require_paren) +static +const char* parse_callfunc(const char* p, int require_paren) { const char* p2; const char* arg=NULL; -- cgit v1.2.3-70-g09d2