summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorKisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-09 12:50:24 +0000
committerKisuka <Kisuka@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-09 12:50:24 +0000
commit5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0 (patch)
tree1f546bf12a99017b41ae2fd90e0ac452f97b0282 /src/common
parentb4208257ea0906e375024f811d8e51208d539d35 (diff)
downloadhercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.gz
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.bz2
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.tar.xz
hercules-5cca96bf950bcd9586ab04f0e0f2b5d9a556c5e0.zip
* Merged changes from trunk [14688:14739/trunk].
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14740 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/mmo.h9
-rw-r--r--src/common/socket.c18
-rw-r--r--src/common/socket.h2
-rw-r--r--src/common/strlib.c3
-rw-r--r--src/common/strlib.h6
-rw-r--r--src/common/utils.c72
-rw-r--r--src/common/utils.h3
7 files changed, 74 insertions, 39 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 92adf8af0..39a5717ab 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -38,6 +38,7 @@
// 20100629 - 2010-06-29aRagexeRE+ - 0x2d0, 0xaa, 0x2d1, 0x2d2
// 20100721 - 2010-07-21aRagexeRE+ - 0x6b, 0x6d
// 20100727 - 2010-07-27aRagexeRE+ - 0x6b, 0x6d
+// 20100803 - 2010-08-03aRagexeRE+ - 0x6b, 0x6d, 0x827, 0x828, 0x829, 0x82a, 0x82b, 0x82c, 0x842, 0x843
#ifndef PACKETVER
#define PACKETVER 20081126
@@ -53,8 +54,6 @@
#define PACKETVER 20071106
#endif
-#define FIFOSIZE_SERVERLINK 256*1024
-
//Remove/Comment this line to disable sc_data saving. [Skotlex]
#define ENABLE_SC_SAVING
//Remove/Comment this line to disable server-side hot-key saving support [Skotlex]
@@ -85,7 +84,7 @@
#define MAX_ZENY 1000000000
#define MAX_FAME 1000000000
#define MAX_CART 100
-#define MAX_SKILL 1020
+#define MAX_SKILL 2536
#define GLOBAL_REG_NUM 256
#define ACCOUNT_REG_NUM 64
#define ACCOUNT_REG2_NUM 16
@@ -95,7 +94,7 @@
#define MIN_WALK_SPEED 0
#define MAX_WALK_SPEED 1000
#define MAX_STORAGE 600
-#define MAX_GUILD_STORAGE 1000
+#define MAX_GUILD_STORAGE 600
#define MAX_PARTY 12
#define MAX_GUILD 16+10*6 // increased max guild members +6 per 1 extension levels [Lupus]
#define MAX_GUILDPOSITION 20 // increased max guild positions to accomodate for all members [Valaris] (removed) [PoW]
@@ -350,6 +349,8 @@ struct mmo_charstatus {
#endif
bool show_equip;
short rename;
+
+ time_t delete_date;
};
typedef enum mail_status {
diff --git a/src/common/socket.c b/src/common/socket.c
index ff667cf2e..0a576e517 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -543,18 +543,16 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF
return 0;
}
-static int delete_session(int fd)
+static void delete_session(int fd)
{
- if (fd <= 0 || fd >= FD_SETSIZE)
- return -1;
- if (session[fd]) {
+ if( session_isValid(fd) )
+ {
aFree(session[fd]->rdata);
aFree(session[fd]->wdata);
aFree(session[fd]->session_data);
aFree(session[fd]);
session[fd] = NULL;
}
- return 0;
}
int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size)
@@ -584,7 +582,7 @@ int realloc_writefifo(int fd, size_t addition)
if( session[fd]->wdata_size + addition > session[fd]->max_wdata )
{ // grow rule; grow in multiples of WFIFO_SIZE
newsize = WFIFO_SIZE;
- while( session[fd]->wdata_size + addition > newsize ) newsize += newsize;
+ while( session[fd]->wdata_size + addition > newsize ) newsize += WFIFO_SIZE;
}
else
if( session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE)
@@ -667,9 +665,9 @@ int WFIFOSET(int fd, size_t len)
// always keep a WFIFO_SIZE reserve in the buffer
// For inter-server connections, let the reserve be 1/4th of the link size.
- newreserve = s->wdata_size + ( s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE);
+ newreserve = s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE;
- // readjust the buffer to the newly chosen size
+ // readjust the buffer to include the chosen reserve
realloc_writefifo(fd, newreserve);
#ifdef SEND_SHORTLIST
@@ -1333,10 +1331,12 @@ void send_shortlist_add_fd(int fd)
int i;
int bit;
- if( fd < 0 || fd >= FD_SETSIZE )
+ if( !session_isValid(fd) )
return;// out of range
+
i = fd/32;
bit = fd%32;
+
if( (send_shortlist_set[i]>>bit)&1 )
return;// already in the list
diff --git a/src/common/socket.h b/src/common/socket.h
index 0a740a63f..2f0ec6081 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -9,6 +9,7 @@
#endif
#ifdef WIN32
+ #define WIN32_LEAN_AND_MEAN // otherwise winsock2.h includes full windows.h
#include <winsock2.h>
typedef long in_addr_t;
#else
@@ -19,6 +20,7 @@
#include <time.h>
+#define FIFOSIZE_SERVERLINK 256*1024
// socket I/O macros
#define RFIFOHEAD(fd)
diff --git a/src/common/strlib.c b/src/common/strlib.c
index a0cba906c..66f281ffc 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <errno.h>
@@ -241,7 +240,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts)
}
#endif
-#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN)
+#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
/* Find the length of STRING, but scan at most MAXLEN characters.
If no '\0' terminator is found in that many characters, return MAXLEN. */
size_t strnlen (const char* string, size_t maxlen)
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 23f1e191a..3f4f984cf 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -9,6 +9,10 @@
#endif
#include <stdarg.h>
+#define __USE_GNU // required to enable strnlen on some platforms
+#include <string.h>
+#undef __USE_GNU
+
char* jstrescape (char* pt);
char* jstrescapecpy (char* pt, const char* spt);
int jmemescapecpy (char* pt, const char* spt, int size);
@@ -24,7 +28,7 @@ const char *stristr(const char *haystack, const char *needle);
char* _strtok_r(char* s1, const char* s2, char** lasts);
#endif
-#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN)
+#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
size_t strnlen (const char* string, size_t maxlen);
#endif
diff --git a/src/common/utils.c b/src/common/utils.c
index 12123784f..f1813ea41 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -5,6 +5,7 @@
#include "../common/mmo.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"
+#include "socket.h"
#include "utils.h"
#include <stdio.h>
@@ -25,39 +26,64 @@
#include <sys/stat.h>
#endif
-// generate a hex dump of the first 'length' bytes of 'buffer'
-void dump(FILE* fp, const unsigned char* buffer, int length)
+
+/// Dumps given buffer into file pointed to by a handle.
+void WriteDump(FILE* fp, const void* buffer, size_t length)
{
- int i, j;
+ size_t i;
+ char hex[48+1], ascii[16+1];
- fprintf(fp, " Hex ASCII\n");
- fprintf(fp, " ----------------------------------------------- ----------------");
+ fprintf(fp, "--- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F 0123456789ABCDEF\n");
+ ascii[16] = 0;
- for (i = 0; i < length; i += 16)
+ for( i = 0; i < length; i++ )
{
- fprintf(fp, "\n%p ", &buffer[i]);
- for (j = i; j < i + 16; ++j)
+ char c = RBUFB(buffer,i);
+
+ ascii[i%16] = ISCNTRL(c) ? '.' : c;
+ sprintf(hex+(i%16)*3, "%02X ", RBUFB(buffer,i));
+
+ if( (i%16) == 15 )
{
- if (j < length)
- fprintf(fp, "%02hX ", buffer[j]);
- else
- fprintf(fp, " ");
+ fprintf(fp, "%03X %s %s\n", i/16, hex, ascii);
}
+ }
+
+ if( (i%16) != 0 )
+ {
+ ascii[i%16] = 0;
+ fprintf(fp, "%03X %-48s %-16s\n", i/16, hex, ascii);
+ }
+}
+
- fprintf(fp, " | ");
+/// Dumps given buffer on the console.
+void ShowDump(const void* buffer, size_t length)
+{
+ size_t i;
+ char hex[48+1], ascii[16+1];
+
+ ShowDebug("--- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F 0123456789ABCDEF\n");
+ ascii[16] = 0;
+
+ for( i = 0; i < length; i++ )
+ {
+ char c = RBUFB(buffer,i);
+
+ ascii[i%16] = ISCNTRL(c) ? '.' : c;
+ sprintf(hex+(i%16)*3, "%02X ", RBUFB(buffer,i));
- for (j = i; j < i + 16; ++j)
+ if( (i%16) == 15 )
{
- if (j < length) {
- if (buffer[j] > 31 && buffer[j] < 127)
- fprintf(fp, "%c", buffer[j]);
- else
- fprintf(fp, ".");
- } else
- fprintf(fp, " ");
+ ShowDebug("%03X %s %s\n", i/16, hex, ascii);
}
}
- fprintf(fp, "\n");
+
+ if( (i%16) != 0 )
+ {
+ ascii[i%16] = 0;
+ ShowDebug("%03X %-48s %-16s\n", i/16, hex, ascii);
+ }
}
@@ -183,6 +209,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
findfile(tmppath, pat, func);
}
}//end while
+
+ closedir(dir);
}
#endif
diff --git a/src/common/utils.h b/src/common/utils.h
index 5cf3ff3cf..2fe078615 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -11,7 +11,8 @@
#include <stdio.h> // FILE*
// generate a hex dump of the first 'length' bytes of 'buffer'
-void dump(FILE* fp, const unsigned char* buffer, int length);
+void WriteDump(FILE* fp, const void* buffer, size_t length);
+void ShowDump(const void* buffer, size_t length);
void findfile(const char *p, const char *pat, void (func)(const char*));
bool exists(const char* filename);