viewing paste Unknown #5867 | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
Index: src/common/socket.c
===================================================================
--- src/common/socket.c (revision 17326)
+++ src/common/socket.c (working copy)
@@ -43,7 +43,7 @@
 /////////////////////////////////////////////////////////////////////
 #if defined(WIN32)
 /////////////////////////////////////////////////////////////////////
-// windows portability layer 
+// windows portability layer
 
 typedef int socklen_t;
 
@@ -89,7 +89,7 @@
 
 /// Inserts the socket into the global array of sockets.
 /// Returns a new fd associated with the socket.
-/// If there are too many sockets it closes the socket, sets an error and 
+/// If there are too many sockets it closes the socket, sets an error and
 //  returns -1 instead.
 /// Since fd 0 is reserved, it returns values in the range [1,FD_SETSIZE[.
 ///
@@ -273,20 +273,15 @@
  *--------------------------------------*/
 void set_nonblocking(int fd, unsigned long yes)
 {
-   // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. 
-   // The argp parameter is zero if nonblocking is to be disabled. 
+   // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s.
+   // The argp parameter is zero if nonblocking is to be disabled.
    if( sIoctl(fd, FIONBIO, &yes) != 0 )
        ShowError("set_nonblocking: Failed to set socket #%d to non-blocking mode (%s) - Please report this!!!\n", fd, error_msg());
 }
 
-void setsocketopts(int fd)
-{
-   struct timeval timeout;
+void setsocketopts(int fd,int delay_timeout){
    int yes = 1; // reuse fix
 
-   timeout.tv_sec = 10;
-   timeout.tv_usec = 0;
-
 #if !defined(WIN32)
    // set SO_REAUSEADDR to true, unix only. on windows this option causes
    // the previous owner of the socket to give up, which is not desirable
@@ -297,11 +292,6 @@
 #endif
 #endif
 
-   if (setsockopt (fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof(timeout)) < 0)
-       ShowError("setsockopt failed\n");
-   if (setsockopt (fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,sizeof(timeout)) < 0)
-       ShowError("setsockopt failed\n");
-
    // Set the socket into no-delay mode; otherwise packets get delayed for up to 200ms, likely creating server-side lag.
    // The RO protocol is mainly single-packet request/response, plus the FIFO model already does packet grouping anyway.
    sSetsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, sizeof(yes));
@@ -315,6 +305,16 @@
    if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&opt, sizeof(opt)) )
        ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd);
    }
+   if(delay_timeout){
+       struct timeval timeout;
+       timeout.tv_sec = 10;
+       timeout.tv_usec = 0;
+
+       if (sSetsockopt (fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof(timeout)) < 0)
+           ShowError("setsocketopts: Unable to set SO_RCVTIMEO timeout for connection #%d!\n");
+       if (sSetsockopt (fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,sizeof(timeout)) < 0)
+           ShowError("setsocketopts: Unable to set SO_SNDTIMEO timeout for connection #%d!\n");
+   }
 }
 
 /*======================================
@@ -439,7 +439,7 @@
        return -1;
    }
 
-   setsocketopts(fd);
+   setsocketopts(fd,0);
    set_nonblocking(fd, 1);
 
 #ifndef MINICORE
@@ -484,7 +484,7 @@
        return -1;
    }
 
-   setsocketopts(fd);
+   setsocketopts(fd,0);
    set_nonblocking(fd, 1);
 
    server_address.sin_family      = AF_INET;
@@ -512,7 +512,7 @@
    return fd;
 }
 
-int make_connection(uint32 ip, uint16 port, bool silent) {
+int make_connection(uint32 ip, uint16 port, bool silent,int timeout) {
    struct sockaddr_in remote_address;
    int fd;
    int result;
@@ -536,7 +536,7 @@
        return -1;
    }
 
-   setsocketopts(fd);
+   setsocketopts(fd,timeout);
 
    remote_address.sin_family      = AF_INET;
    remote_address.sin_addr.s_addr = htonl(ip);
@@ -1163,7 +1163,7 @@
        if(session[i])
            do_close(i);
 
-   // session[0] ‚̃_ƒ~[ƒf[ƒ^‚ðíœ
+   // session[0] �̃_�~�[�f�[�^���폜
    aFree(session[0]->rdata);
    aFree(session[0]->wdata);
    aFree(session[0]);
Index: src/common/socket.h
===================================================================
--- src/common/socket.h (revision 17326)
+++ src/common/socket.h (working copy)
@@ -113,7 +113,7 @@
 // Function prototype declaration
 
 int make_listen_bind(uint32 ip, uint16 port);
-int make_connection(uint32 ip, uint16 port, bool silent);
+int make_connection(uint32 ip, uint16 port, bool silent, int timeout);
 int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size);
 int realloc_writefifo(int fd, size_t addition);
 int WFIFOSET(int fd, size_t len);
@@ -145,7 +145,7 @@
 
 void set_eof(int fd);
 
-/// Use a shortlist of sockets instead of iterating all sessions for sockets 
+/// Use a shortlist of sockets instead of iterating all sessions for sockets
 /// that have data to send or need eof handling.
 /// Adapted to use a static array instead of a linked list.
 ///
Index: src/config/core.h
===================================================================
--- src/config/core.h   (revision 17326)
+++ src/config/core.h   (working copy)
@@ -29,7 +29,7 @@
 
 /// Uncomment to disable rAthena's anonymous stat report
 /// We kindly ask you to consider keeping it enabled, it helps us improve rAthena.
-//#define STATS_OPT_OUT
+#define STATS_OPT_OUT
 
 /// uncomment to enable query_sql script command and mysql logs to function on it's own thread
 /// be aware this feature is under tests and you should use at your own risk, we however
Index: src/map/script.c
===================================================================
--- src/map/script.c    (revision 17326)
+++ src/map/script.c    (working copy)
@@ -623,7 +623,7 @@
    }
 }
 
-// Returns name of currently running function 
+// Returns name of currently running function
 static char* script_getfuncname(struct script_state *st)
 {
    int i;
@@ -6055,8 +6055,7 @@
  *------------------------------------------*/
 BUILDIN_FUNC(countitem)
 {
-   int nameid, i;
-   int count = 0;
+   int i, count = 0;
    struct item_data* id = NULL;
    struct script_data* data;
 
@@ -6081,13 +6080,12 @@
    }
 
    if(script_lastdata(st) == 2) { // For countitem() function
-       nameid = id->nameid;
+       int nameid = id->nameid;
        for(i = 0; i < MAX_INVENTORY; i++)
            if(sd->status.inventory[i].nameid == nameid)
                count += sd->status.inventory[i].amount;
    } else { // For countitem2() function
        struct item tmp_it;
-       int iden, ref, attr, c1, c2, c3, c4;
        tmp_it.nameid = id->nameid;
        tmp_it.identify = script_getnum(st, 3);
        tmp_it.refine = script_getnum(st, 4);
@@ -6109,7 +6107,7 @@
    return 0;
 }
 
-int checkweight_sub(TBL_PC *sd,int nbargs,int *eitemid,int *eamount)
+int checkweight_sub(TBL_PC *sd,int nbargs,int32 *eitemid,int32 *eamount)
 {
    struct item_data* id = NULL;
    int nameid,amount;
@@ -6122,14 +6120,14 @@
            continue;
        id = itemdb_exists(eitemid[i]);
        if( id == NULL ) {
-           ShowError("buildin_checkweight: Invalid item '%d'.\n", eitemid[i]);
+           ShowError("checkweight_sub: Invalid item '%d'.\n", eitemid[i]);
            return 0;
        }
        nameid = id->nameid;
 
        amount = eamount[i];
        if( amount < 1 ) {
-           ShowError("buildin_checkweight: Invalid amount '%d'.\n", eamount[i]);
+           ShowError("checkweight_sub: Invalid amount '%d'.\n", eamount[i]);
            return 0;
        }
 
@@ -6167,7 +6165,7 @@
    struct map_session_data* sd;
    struct script_data* data;
    struct item_data* id = NULL;
-   int nameid[128], amount[128];
+   int32 nameid[SCRIPT_MAX_ARRAYSIZE], amount[SCRIPT_MAX_ARRAYSIZE];
    uint16 nbargs,i,j=0;
 
    if( ( sd = script_rid2sd(st) ) == NULL )
@@ -6201,10 +6199,9 @@
    return 0;
 }
 
-BUILDIN_FUNC(checkweight2)
-{
+BUILDIN_FUNC(checkweight2){
    //variable sub checkweight
-   int nameid[128], amount[128], i;
+   int32 nameid[SCRIPT_MAX_ARRAYSIZE], amount[SCRIPT_MAX_ARRAYSIZE], i;
 
    //variable for array parsing
    struct script_data* data_it;
@@ -6222,7 +6219,7 @@
    data_nb = script_getdata(st, 3);
 
    if( !data_isreference(data_it) || !data_isreference(data_nb)) {
-       ShowError("script:checkweight2: parameter not a variable\n");
+       ShowError("buildin_checkweight2: parameter not a variable\n");
        script_pushint(st,0);
        return 1;// not a variable
    }
@@ -6235,19 +6232,19 @@
    name_nb = reference_getname(data_nb);
 
    if( not_array_variable(*name_it) || not_array_variable(*name_nb)) {
-       ShowError("script:checkweight2: illegal scope\n");
+       ShowError("buildin_checkweight2: illegal scope\n");
        script_pushint(st,0);
        return 1;// not supported
    }
    if(is_string_variable(name_it) || is_string_variable(name_nb)) {
-       ShowError("script:checkweight2: illegal type, need int\n");
+       ShowError("buildin_checkweight2: illegal type, need int\n");
        script_pushint(st,0);
        return 1;// not supported
    }
    nb_it = getarraysize(st, id_it, idx_it, 0, reference_getref(data_it));
    nb_nb = getarraysize(st, id_nb, idx_nb, 0, reference_getref(data_nb));
    if(nb_it != nb_nb) {
-       ShowError("Size mistmatch: nb_it=%d, nb_nb=%d\n",nb_it,nb_nb);
+       ShowError("buildin_checkweight2: Size mistmatch: nb_it=%d, nb_nb=%d\n",nb_it,nb_nb);
        script_pushint(st,0);
        return 1;
    }
@@ -9842,11 +9839,10 @@
    TBL_NPC * nd = map_id2nd(st->oid);
    struct block_list* bl;
    enum sc_type type;
-   int tick, val1, val2, val3, rate, flag, isitem;
-   int val4 = 0;
+   int tick, val1, val2, val3, val4=0, rate, flag, isitem;
    char start_type;
    const char* command = script_getfuncname(st);
-   
+
    if(strstr(command, "4"))
        start_type = 4;
    else if(strstr(command, "2"))
@@ -9878,7 +9874,7 @@
    }
 
    //solving if script from npc or item
-   isitem = (nd && nd->bl.id == fake_nd->bl.id || rate != 2)?true:false;
+   isitem = (nd && nd->bl.id == fake_nd->bl.id || flag != 2)?true:false;
 
    switch(start_type) {
        case 1:
@@ -15049,7 +15045,7 @@
 }
 
 /*=======================================================
- * Add or Update a mob drop temporarily [Akinari] 
+ * Add or Update a mob drop temporarily [Akinari]
  * Original Idea By: [Lupus]
  *
  * addmonsterdrop <mob_id or name>,<item_id>,<rate>;
@@ -15078,7 +15074,7 @@
 
    if(mob) { //We got a valid monster, check for available drop slot
        for(i = 0; i < MAX_MOB_DROP; i++) {
-           if(mob->dropitem[i].nameid) { 
+           if(mob->dropitem[i].nameid) {
                if(mob->dropitem[i].nameid == item_id) { //If it equals item_id we update that drop
                    c = i;
                    break;
@@ -15104,7 +15100,7 @@
 }
 
 /*=======================================================
- * Delete a mob drop temporarily [Akinari] 
+ * Delete a mob drop temporarily [Akinari]
  * Original Idea By: [Lupus]
  *
  * delmonsterdrop <mob_id or name>,<item_id>;
@@ -15130,7 +15126,7 @@
 
    if(mob) { //We got a valid monster, check for item drop on monster
        for(i = 0; i < MAX_MOB_DROP; i++) {
-           if(mob->dropitem[i].nameid == item_id) { 
+           if(mob->dropitem[i].nameid == item_id) {
                mob->dropitem[i].nameid = 0;
                mob->dropitem[i].p = 0;
                script_pushint(st,1);
Index: src/map/chrif.c
===================================================================
--- src/map/chrif.c (revision 17326)
+++ src/map/chrif.c (working copy)
@@ -1511,7 +1511,7 @@
        }
 
        chrif_state = 0;
-       char_fd = make_connection(char_ip, char_port,false);
+       char_fd = make_connection(char_ip, char_port,false,10);
 
        if (char_fd == -1)//Attempt to connect later. [Skotlex]
            return 0;
@@ -1554,13 +1554,9 @@
 
 #ifndef STATS_OPT_OUT
    WFIFOHEAD(char_fd,len + 2);
-
    WFIFOW(char_fd,0) = 0x3008;
-
    memcpy(WFIFOP(char_fd,2), buf, len);
-
    WFIFOSET(char_fd,len + 2);
-
    flush_fifo(char_fd); /* ensure it's sent now. */
 #endif
 
Index: src/map/skill.c
===================================================================
--- src/map/skill.c (revision 17326)
+++ src/map/skill.c (working copy)
@@ -1840,7 +1840,7 @@
 
    if( sd && status_isdead(bl) ) {
        int sp = 0, hp = 0;
-       if( attack_type&(BF_WEAPON|BF_SHORT) == (BF_WEAPON|BF_SHORT) ) {
+       if( (attack_type&(BF_WEAPON|BF_SHORT)) == (BF_WEAPON|BF_SHORT) ) {
            sp += sd->bonus.sp_gain_value;
            sp += sd->sp_gain_race[status_get_race(bl)];
            sp += sd->sp_gain_race[is_boss(bl)?RC_BOSS:RC_NONBOSS];
@@ -5119,11 +5119,11 @@
            do {
                i = rnd() % MAX_SKILL_ABRA_DB;
                abra_skill_id = skill_abra_db[i].skill_id;
+               abra_skill_lv = min(skill_lv, skill_get_max(abra_skill_id));
            } while (abra_skill_id == 0 ||
-               skill_abra_db[i].req_lv > skill_lv || //Required lv for it to appear
-               rnd()%10000 >= skill_abra_db[i].per
+               rnd()%10000 >= skill_abra_db[i].per[abra_skill_lv]
            );
-           abra_skill_lv = min(skill_lv, skill_get_max(abra_skill_id));
+
            clif_skill_nodamage (src, bl, skill_id, skill_lv, 1);
 
            if( sd )
@@ -17582,7 +17582,7 @@
                        static const int dx[] = {-1,-1,-1,-1, 0, 0, 0, 0, 1, 1, 1, 1,
                                     -5,-5,-5,-5,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-2,-2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
                                     -1,-1,-1, 0, 0, 0, 1, 1, 1};
-                       static const int dy[] = { 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 
+                       static const int dy[] = { 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3,
                                      0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3, 0,-1,-2,-3,
                                     -4,-5,-6,-4,-5,-6,-4,-5,-6};
                        skill_unit_layout[pos].count = 53;
@@ -18166,7 +18166,7 @@
 
 
 static bool skill_parse_row_abradb(char* split[], int columns, int current)
-{// skill_id,DummyName,RequiredHocusPocusLevel,Rate
+{// skill_id,DummyName,RatePerLvl
    uint16 skill_id = atoi(split[0]);
    if( !skill_get_index(skill_id) || !skill_get_max(skill_id) )
    {
@@ -18180,8 +18180,8 @@
    }
 
    skill_abra_db[current].skill_id = skill_id;
-   skill_abra_db[current].req_lv = atoi(split[2]);
-   skill_abra_db[current].per = atoi(split[3]);
+   safestrncpy(skill_abra_db[current].name, trim(split[1]), sizeof(skill_abra_db[current].name)); //store dummyname
+   skill_split_atoi(split[2],skill_abra_db[current].per);
 
    return true;
 }
Index: src/map/skill.h
===================================================================
--- src/map/skill.h (revision 17326)
+++ src/map/skill.h (working copy)
@@ -217,8 +217,8 @@
 
 struct s_skill_abra_db {
    uint16 skill_id;
-   int req_lv;
-   int per;
+   char name[NAME_LENGTH];
+   int per[MAX_SKILL_LEVEL];
 };
 extern struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
 
Index: src/char/char.c
===================================================================
--- src/char/char.c (revision 17326)
+++ src/char/char.c (working copy)
@@ -3431,7 +3431,7 @@
                int sfd;/* stat server fd */
                RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */
 
-               if( (sfd = make_connection(host2ip("stats.rathena.org"),(uint16)25421,true) ) == -1 ) {
+               if( (sfd = make_connection(host2ip("stats.rathena.org"),(uint16)25421,true,10) ) == -1 ) {
                    RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
                    break;/* connection not possible, we drop the report */
                }
@@ -4520,7 +4520,7 @@
        return 0;
 
    ShowInfo("Attempt to connect to login-server...\n");
-   login_fd = make_connection(login_ip, login_port, false);
+   login_fd = make_connection(login_ip, login_port, false,10);
    if (login_fd == -1)
    {   //Try again later. [Skotlex]
        login_fd = 0;
Viewed 1432 times, submitted by lighta.