summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-16 20:44:44 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-16 20:44:44 +0000
commit9f47d257ba5bb985bc6753b0f20b90da18664cd1 (patch)
tree6c3c5c0157298810886561bcadca78bbe86193db /src
parentcf0a0b7d27a81f572c96e4a79c7ea0c407fe9626 (diff)
downloadhercules-9f47d257ba5bb985bc6753b0f20b90da18664cd1.tar.gz
hercules-9f47d257ba5bb985bc6753b0f20b90da18664cd1.tar.bz2
hercules-9f47d257ba5bb985bc6753b0f20b90da18664cd1.tar.xz
hercules-9f47d257ba5bb985bc6753b0f20b90da18664cd1.zip
* Finally fixed mingw problems, managed to build both TXT and SQL
* Fixed the uint32 platform problem (Microsoft failed so I removed it :) * Removed the cbasetypes.h dependency from the mapcache generator * Removed some random compilation warnings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10270 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c16
-rw-r--r--src/char_sql/char.c12
-rw-r--r--src/common/cbasetypes.h21
-rw-r--r--src/common/db.c6
-rw-r--r--src/common/nullpo.h5
-rw-r--r--src/common/showmsg.c4
-rw-r--r--src/common/strlib.h2
-rw-r--r--src/ladmin/ladmin.c4
-rw-r--r--src/login/login.c32
-rw-r--r--src/login_sql/login.c18
-rw-r--r--src/tool/mapcache.c7
11 files changed, 52 insertions, 75 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 0d888f399..5b9b5d87b 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1127,7 +1127,7 @@ int make_new_char(int fd, unsigned char *dat) {
return -1;
}
- if (remove_control_chars((unsigned char *)name)) {
+ if (remove_control_chars(name)) {
char_log("Make new char error (control char received in the name): (connection #%d, account: %d)." RETCODE,
fd, sd->account_id);
return -1;
@@ -2182,7 +2182,7 @@ int parse_tologin(int fd) {
memset(message, '\0', sizeof(message));
memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4));
message[sizeof(message)-1] = '\0';
- remove_control_chars((unsigned char *)message);
+ remove_control_chars(message);
// remove all first spaces
p = message;
while(p[0] == ' ')
@@ -3970,10 +3970,10 @@ int char_lan_config_read(const char *lancfgName) {
continue;
}
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
- remove_control_chars((unsigned char *)w3);
- remove_control_chars((unsigned char *)w4);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
+ remove_control_chars(w3);
+ remove_control_chars(w4);
if(strcmpi(w1, "subnet") == 0) {
@@ -4015,8 +4015,8 @@ int char_config_read(const char *cfgName) {
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
if(strcmpi(w1,"timestamp_format") == 0) {
strncpy(timestamp_format, w2, 20);
} else if(strcmpi(w1,"console_silent")==0){
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 41ce64de7..80743dac9 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -3795,10 +3795,10 @@ int char_lan_config_read(const char *lancfgName) {
continue;
}
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
- remove_control_chars((unsigned char *)w3);
- remove_control_chars((unsigned char *)w4);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
+ remove_control_chars(w3);
+ remove_control_chars(w4);
if(strcmpi(w1, "subnet") == 0) {
@@ -3940,8 +3940,8 @@ int char_config_read(const char *cfgName) {
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
if(strcmpi(w1,"timestamp_format") == 0) {
strncpy(timestamp_format, w2, 20);
} else if(strcmpi(w1,"console_silent")==0){
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 67c5a45db..c066c1ebd 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -53,7 +53,7 @@
#endif
// disable attributed stuff on non-GNU
-#ifndef __GNUC__
+#if !defined(__GNUC__) && !defined(MINGW)
# define __attribute__(x)
#endif
@@ -74,26 +74,10 @@
// Integers with guaranteed _exact_ size.
//////////////////////////////////////////////////////////////////////////
-//////////////////////////////
-#ifdef WIN32
-//////////////////////////////
#define SIZEOF_LONG 4
#define SIZEOF_INT 4
#define HAVE_INT_8_16_32
-typedef __int8 int8;
-typedef __int16 int16;
-typedef __int32 int32;
-typedef signed __int8 sint8;
-typedef signed __int16 sint16;
-typedef signed __int32 sint32;
-
-typedef unsigned __int8 uint8;
-typedef unsigned __int16 uint16;
-typedef unsigned __int32 uint32;
-//////////////////////////////
-#else // GNU
-//////////////////////////////
typedef char int8;
typedef short int16;
typedef int int32;
@@ -105,9 +89,6 @@ typedef signed int sint32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
-//////////////////////////////
-#endif
-//////////////////////////////
#undef UINT8_MIN
#undef UINT16_MIN
diff --git a/src/common/db.c b/src/common/db.c
index 98d7ae032..7d1eb3903 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -600,7 +600,7 @@ static int db_is_key_null(DBType type, DBKey key)
*/
static DBKey db_dup_key(DB_impl db, DBKey key)
{
- unsigned char *str;
+ char *str;
#ifdef DB_ENABLE_STATS
COUNT(db_dup_key);
@@ -609,12 +609,12 @@ static DBKey db_dup_key(DB_impl db, DBKey key)
case DB_STRING:
case DB_ISTRING:
if (db->maxlen) {
- CREATE(str, unsigned char, db->maxlen +1);
+ CREATE(str, char, db->maxlen +1);
memcpy(str, key.str, db->maxlen);
str[db->maxlen] = '\0';
key.str = str;
} else {
- key.str = (unsigned char *)aStrdup((const char *)key.str);
+ key.str = (char *)aStrdup(key.str);
}
return key;
diff --git a/src/common/nullpo.h b/src/common/nullpo.h
index 71525dd00..0238d2b6d 100644
--- a/src/common/nullpo.h
+++ b/src/common/nullpo.h
@@ -19,8 +19,9 @@
#endif
#endif
-#ifdef _WIN32
-#define __attribute__(x) /* nothing */
+
+#if !defined(__GNUC__) && !defined(MINGW)
+# define __attribute__(x) /* nothing */
#endif
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index c61530204..f56c66525 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -349,7 +349,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
// \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1).
uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
int cnt;
- uint32 tmp;
+ DWORD tmp;
COORD origin = {0,0};
if(num==1)
{ // chars from start up to and including cursor
@@ -377,7 +377,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
COORD origin = {0,info.dwCursorPosition.Y};
SHORT cnt;
- uint32 tmp;
+ DWORD tmp;
if(num==1)
{
cnt = info.dwCursorPosition.X + 1;
diff --git a/src/common/strlib.h b/src/common/strlib.h
index db54d2969..5abd07e90 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -8,7 +8,7 @@ char* jstrescape (char* pt);
char* jstrescapecpy (char* pt, const char* spt);
int jmemescapecpy (char* pt, const char* spt, int size);
-int remove_control_chars(char *);
+int remove_control_chars(char* str);
char* trim(char* str);
char* normalize_name(char* str,const char* delims);
const char *stristr(const char *haystack, const char *needle);
diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c
index 66bada1c3..e4a358745 100644
--- a/src/ladmin/ladmin.c
+++ b/src/ladmin/ladmin.c
@@ -4245,8 +4245,8 @@ int ladmin_config_read(const char *cfgName) {
line[sizeof(line)-1] = '\0';
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
- remove_control_chars((unsigned char *) w1);
- remove_control_chars((unsigned char *) w2);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
if(strcmpi(w1,"login_ip")==0){
struct hostent *h = gethostbyname (w2);
diff --git a/src/login/login.c b/src/login/login.c
index 65e3d666e..e948264b2 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -399,14 +399,14 @@ int check_ipmask(uint32 ip, const unsigned char *str)
// scan ip address
- if (sscanf((const char*)str, "%lu.%lu.%lu.%lu/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0)
+ if (sscanf((const char*)str, "%u.%u.%u.%u/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0)
return 0;
p[0] = (uint8)a3; p[1] = (uint8)a2; p[2] = (uint8)a1; p[3] = (uint8)a0;
// scan mask
- if (sscanf((const char*)str+i, "%lu.%lu.%lu.%lu", &a0, &a1, &a2, &a3) == 4) {
+ if (sscanf((const char*)str+i, "%u.%u.%u.%u", &a0, &a1, &a2, &a3) == 4) {
p2[0] = (uint8)a3; p2[1] = (uint8)a2; p2[2] = (uint8)a1; p2[3] = (uint8)a0;
- } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m >= 0 && m <= 32) {
+ } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m <= 32) {
for(i = 32 - m; i < 32; i++)
mask |= (1 << i);
} else {
@@ -439,7 +439,7 @@ int check_ip(uint32 ip)
// If we have an answer, there is no guarantee to have a 100% correct value.
// And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software.
// So, DNS notation isn't authorised for ip checking.
- sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip));
+ sprintf(buf, "%u.%u.%u.%u.", CONVIP(ip));
for(i = 0; i < access_allownum; i++) {
access_ip = access_allow + i * ACO_STRSIZE;
@@ -487,7 +487,7 @@ int check_ladminip(uint32 ip)
// If we have an answer, there is no guarantee to have a 100% correct value.
// And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software.
// So, DNS notation isn't authorised for ip checking.
- sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip));
+ sprintf(buf, "%u.%u.%u.%u.", CONVIP(ip));
for(i = 0; i < access_ladmin_allownum; i++) {
access_ip = access_ladmin_allow + i * ACO_STRSIZE;
@@ -540,7 +540,7 @@ int mmo_auth_tostr(char *str, struct auth_dat *p) {
int i;
char *str_p = str;
- str_p += sprintf(str_p, "%lu\t%s\t%s\t%s\t%c\t%d\t%lu\t%s\t%s\t%ld\t%s\t%s\t%ld\t",
+ str_p += sprintf(str_p, "%u\t%s\t%s\t%s\t%c\t%d\t%u\t%s\t%s\t%ld\t%s\t%s\t%ld\t",
p->account_id, p->userid, p->pass, p->lastlogin,
p->sex == 2 ? 'S' : p->sex == 1 ? 'M' : 'F',
p->logincount, p->state, p->email, p->error_message,
@@ -598,11 +598,11 @@ int mmo_auth_init(void)
memset(memo, 0, sizeof(memo));
// database version reading (v2)
- if (((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t"
+ if (((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t"
"%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n",
&account_id, userid, pass, lastlogin, &sex, &logincount, &state,
email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n)) == 13 && line[n] == '\t') ||
- ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t"
+ ((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t"
"%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]%n",
&account_id, userid, pass, lastlogin, &sex, &logincount, &state,
email, error_message, &connect_until_time, last_ip, memo, &n)) == 12 && line[n] == '\t')) {
@@ -667,8 +667,6 @@ int mmo_auth_init(void)
if (state > 255)
auth_dat[auth_num].state = 100;
- else if (state < 0)
- auth_dat[auth_num].state = 0;
else
auth_dat[auth_num].state = state;
@@ -731,7 +729,7 @@ int mmo_auth_init(void)
account_id_count = account_id + 1;
// Old athena database version reading (v1)
- } else if ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t%n",
+ } else if ((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t%n",
&account_id, userid, pass, lastlogin, &sex, &logincount, &state, &n)) >= 5) {
if (account_id > END_ACCOUNT_NUM) {
ShowError(CL_RED"mmmo_auth_init: an account has an id higher than %d\n", END_ACCOUNT_NUM);
@@ -795,8 +793,6 @@ int mmo_auth_init(void)
if (i >= 7) {
if (state > 255)
auth_dat[auth_num].state = 100;
- else if (state < 0)
- auth_dat[auth_num].state = 0;
else
auth_dat[auth_num].state = state;
} else
@@ -839,7 +835,7 @@ int mmo_auth_init(void)
} else {
int i = 0;
- if (sscanf(line, "%lu\t%%newid%%\n%n", &account_id, &i) == 1 &&
+ if (sscanf(line, "%u\t%%newid%%\n%n", &account_id, &i) == 1 &&
i > 0 && account_id > account_id_count)
account_id_count = account_id;
}
@@ -855,7 +851,7 @@ int mmo_auth_init(void)
sprintf(line, "1 account read in %s,", account_filename);
} else {
ShowStatus("mmo_auth_init: %d accounts read in %s,\n", auth_num, account_filename);
- sprintf(line, "%lu accounts read in %s,", auth_num, account_filename);
+ sprintf(line, "%u accounts read in %s,", auth_num, account_filename);
}
if (GM_count == 0) {
ShowStatus(" of which is no GM account, and ");
@@ -936,7 +932,7 @@ void mmo_auth_sync(void) {
mmo_auth_tostr(line, &auth_dat[k]);
fprintf(fp, "%s" RETCODE, line);
}
- fprintf(fp, "%lu\t%%newid%%\n", account_id_count);
+ fprintf(fp, "%u\t%%newid%%\n", account_id_count);
lock_fclose(fp, account_filename, &lock);
@@ -1946,7 +1942,7 @@ int parse_fromchar(int fd)
memset(tmpstr, '\0', sizeof(tmpstr));
for(i = 0; i < RFIFOREST(fd); i++) {
if ((i & 15) == 0)
- fprintf(logfp, "%04lX ",i);
+ fprintf(logfp, "%04X ",i);
fprintf(logfp, "%02x ", RFIFOB(fd,i));
if (RFIFOB(fd,i) > 0x1f)
tmpstr[i % 16] = RFIFOB(fd,i);
@@ -2008,7 +2004,7 @@ int parse_admin(int fd)
switch(RFIFOW(fd,0)) {
case 0x7530: // Request of the server version
login_log("'ladmin': Sending of the server version (ip: %s)" RETCODE, ip);
- WFIFOHEAD(fd,10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 5929c6da0..ca98740c4 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -41,7 +41,7 @@
struct Login_Config {
uint32 login_ip; // the address to bind to
- unsigned short login_port; // the port to bind to
+ uint16 login_port; // the port to bind to
bool log_login; // whether to log login server actions or not
char date_format[32]; // date format used in messages
bool console; // console input system enabled?
@@ -1758,10 +1758,10 @@ int login_lan_config_read(const char *lancfgName)
continue;
}
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
- remove_control_chars((unsigned char *)w3);
- remove_control_chars((unsigned char *)w4);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
+ remove_control_chars(w3);
+ remove_control_chars(w4);
if(strcmpi(w1, "subnet") == 0) {
@@ -1817,8 +1817,8 @@ int login_config_read(const char* cfgName)
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2)
continue;
- remove_control_chars((unsigned char *)w1);
- remove_control_chars((unsigned char *)w2);
+ remove_control_chars(w1);
+ remove_control_chars(w2);
if(!strcmpi(w1,"timestamp_format")) {
strncpy(timestamp_format, w2, 20);
@@ -1834,7 +1834,7 @@ int login_config_read(const char* cfgName)
if (login_config.login_ip)
ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str));
} else if(!strcmpi(w1,"login_port")) {
- login_config.login_port = (unsigned short)atoi(w2);
+ login_config.login_port = (uint16)atoi(w2);
ShowStatus("set login_port : %s\n",w2);
}
else if (!strcmpi(w1, "log_login"))
@@ -2048,7 +2048,7 @@ int do_init(int argc, char** argv)
new_reg_tick = gettick();
- ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", login_config.login_port);
+ ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port);
return 0;
}
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index 4103e6916..3aa77fd80 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -9,7 +9,6 @@
#include <unistd.h>
#endif
-#include "../common/cbasetypes.h"
#include "grfio.h"
#define MAP_NAME_LENGTH 12
@@ -219,9 +218,9 @@ char *remove_extension(char *mapname)
if (ptr) { //Check and remove extension.
while (ptr[1] && (ptr2 = strchr(ptr+1, '.')))
ptr = ptr2; //Skip to the last dot.
- if(stricmp(ptr,".gat") == 0 ||
- stricmp(ptr,".afm") == 0 ||
- stricmp(ptr,".af2") == 0)
+ if(strcmp(ptr,".gat") == 0 ||
+ strcmp(ptr,".afm") == 0 ||
+ strcmp(ptr,".af2") == 0)
*ptr = '\0'; //Remove extension.
}
return mapname;