* Fix C++ compilation issues.
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14955 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
36bac9f797
commit
9703374f8a
4
3rdparty/msinttypes/include/stdint.h
vendored
4
3rdparty/msinttypes/include/stdint.h
vendored
@ -47,8 +47,12 @@
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#ifdef __cplusplus
|
||||
#if _MSC_VER < 1300
|
||||
extern "C++" {
|
||||
#else
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
Date Added
|
||||
|
||||
2011/09/08
|
||||
* Fix C++ compilation issues. [FlavioJS]
|
||||
2011/09/05
|
||||
* Add consistency checks to the shortlist. [FlavioJS]
|
||||
* Restrict intif_quest_save to sql only. txt char-server doesn't support the packet and disconnects the map-server.
|
||||
|
@ -436,7 +436,7 @@ int search_character_online(int aid, int cid)
|
||||
{
|
||||
//Look for online character.
|
||||
struct online_char_data* character;
|
||||
character = idb_get(online_char_db, aid);
|
||||
character = (struct online_char_data*)idb_get(online_char_db, aid);
|
||||
if(character &&
|
||||
character->char_id == cid &&
|
||||
character->server > -1)
|
||||
@ -2208,7 +2208,7 @@ int parse_fromlogin(int fd)
|
||||
memcpy(sd->email, RFIFOP(fd,6), 40);
|
||||
sd->expiration_time = (time_t)RFIFOL(fd,46);
|
||||
sd->gmlevel = RFIFOB(fd,50);
|
||||
safestrncpy(sd->birthdate, RFIFOP(fd,51), sizeof(sd->birthdate));
|
||||
safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate));
|
||||
|
||||
// continued from char_auth_ok...
|
||||
if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level )
|
||||
|
@ -1964,7 +1964,7 @@ int parse_fromlogin(int fd)
|
||||
memcpy(sd->email, RFIFOP(fd,6), 40);
|
||||
sd->expiration_time = (time_t)RFIFOL(fd,46);
|
||||
sd->gmlevel = RFIFOB(fd,50);
|
||||
safestrncpy(sd->birthdate, RFIFOP(fd,51), sizeof(sd->birthdate));
|
||||
safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,51), sizeof(sd->birthdate));
|
||||
|
||||
// continued from char_auth_ok...
|
||||
if( max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level )
|
||||
|
@ -77,6 +77,12 @@
|
||||
// portable printf/scanf format macros and integer definitions
|
||||
// NOTE: Visual C++ uses <inttypes.h> and <stdint.h> provided in /3rdparty
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __cplusplus
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
@ -326,4 +332,27 @@ typedef char bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set a pointer variable to a pointer value.
|
||||
#ifdef __cplusplus
|
||||
template <typename T1, typename T2>
|
||||
void SET_POINTER(T1*&var, T2* p)
|
||||
{
|
||||
var = static_cast<T1*>(p);
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
void SET_FUNCPOINTER(T1& var, T2 p)
|
||||
{
|
||||
char ASSERT_POINTERSIZE[sizeof(T1) == sizeof(void*) && sizeof(T2) == sizeof(void*)?1:-1];// 1 if true, -1 if false
|
||||
union{ T1 out; T2 in; } tmp;// /!\ WARNING casting a pointer to a function pointer is against the C++ standard
|
||||
tmp.in = p;
|
||||
var = tmp.out;
|
||||
}
|
||||
#else
|
||||
#define SET_POINTER(var,p) (var) = (p)
|
||||
#define SET_FUNCPOINTER(var,p) (var) = (p)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _CBASETYPES_H_ */
|
||||
|
@ -994,8 +994,8 @@ void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... );
|
||||
do{ \
|
||||
if( (__n) > VECTOR_CAPACITY(__vec) ) \
|
||||
{ /* increase size */ \
|
||||
if( VECTOR_CAPACITY(__vec) == 0 ) VECTOR_DATA(__vec) = aMalloc((__n)*sizeof(VECTOR_FIRST(__vec))); /* allocate new */ \
|
||||
else VECTOR_DATA(__vec) = aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec))); /* reallocate */ \
|
||||
if( VECTOR_CAPACITY(__vec) == 0 ) SET_POINTER(VECTOR_DATA(__vec), aMalloc((__n)*sizeof(VECTOR_FIRST(__vec)))); /* allocate new */ \
|
||||
else SET_POINTER(VECTOR_DATA(__vec), aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec)))); /* reallocate */ \
|
||||
memset(VECTOR_DATA(__vec)+VECTOR_LENGTH(__vec), 0, (VECTOR_CAPACITY(__vec)-VECTOR_LENGTH(__vec))*sizeof(VECTOR_FIRST(__vec))); /* clear new data */ \
|
||||
VECTOR_CAPACITY(__vec) = (__n); /* update capacity */ \
|
||||
} \
|
||||
@ -1007,7 +1007,7 @@ void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... );
|
||||
} \
|
||||
else if( (__n) < VECTOR_CAPACITY(__vec) ) \
|
||||
{ /* reduce size */ \
|
||||
VECTOR_DATA(__vec) = aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec))); /* reallocate */ \
|
||||
SET_POINTER(VECTOR_DATA(__vec), aRealloc(VECTOR_DATA(__vec),(__n)*sizeof(VECTOR_FIRST(__vec)))); /* reallocate */ \
|
||||
VECTOR_CAPACITY(__vec) = (__n); /* update capacity */ \
|
||||
if( VECTOR_LENGTH(__vec) > (__n) ) VECTOR_LENGTH(__vec) = (__n); /* update length */ \
|
||||
} \
|
||||
|
@ -223,17 +223,17 @@ unsigned long grfio_crc32 (const unsigned char* buf, unsigned int len)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Grf data sub : zip decode
|
||||
int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen)
|
||||
int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen)
|
||||
{
|
||||
return uncompress(dest, destLen, source, sourceLen);
|
||||
return uncompress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Grf data sub : zip encode
|
||||
int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen)
|
||||
int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen)
|
||||
{
|
||||
return compress(dest, destLen, source, sourceLen);
|
||||
return compress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ char *grfio_find_file(char *fname);
|
||||
int grfio_size(char*); // GRFIO data file size get
|
||||
unsigned long grfio_crc32(const unsigned char *buf, unsigned int len);
|
||||
|
||||
int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen);
|
||||
int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen);
|
||||
int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
|
||||
int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
|
||||
|
||||
#endif /* _GRFIO_H_ */
|
||||
|
@ -50,7 +50,7 @@ typedef void Plugin_Event_Func(void);
|
||||
#define PLUGIN_MAP 8
|
||||
#define PLUGIN_CORE 16
|
||||
|
||||
#define IMPORT_SYMBOL(s,n) (s) = plugin_call_table[n]
|
||||
#define IMPORT_SYMBOL(s,n) SET_FUNCPOINTER((s), plugin_call_table[n])
|
||||
|
||||
#define SYMBOL_SERVER_TYPE 0
|
||||
#define SYMBOL_SERVER_NAME 1
|
||||
|
@ -245,7 +245,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts)
|
||||
If no '\0' terminator is found in that many characters, return MAXLEN. */
|
||||
size_t strnlen (const char* string, size_t maxlen)
|
||||
{
|
||||
const char* end = memchr (string, '\0', maxlen);
|
||||
const char* end = (const char*)memchr(string, '\0', maxlen);
|
||||
return end ? (size_t) (end - string) : maxlen;
|
||||
}
|
||||
#endif
|
||||
@ -980,7 +980,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
|
||||
|
||||
// allocate enough memory for the maximum requested amount of columns plus the reserved one
|
||||
fields_length = maxcols+1;
|
||||
fields = aMalloc(fields_length*sizeof(char*));
|
||||
fields = (char**)aMalloc(fields_length*sizeof(char*));
|
||||
|
||||
// process rows one by one
|
||||
while( fgets(line, sizeof(line), fp) )
|
||||
|
@ -283,7 +283,7 @@ static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc)
|
||||
return false;
|
||||
|
||||
// check if the account_id is free
|
||||
tmp = idb_get(accounts, account_id);
|
||||
tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp != NULL )
|
||||
{// error condition - entry already present
|
||||
ShowError("account_db_txt_create: cannot create account %d:'%s', this id is already occupied by %d:'%s'!\n", account_id, acc->userid, account_id, tmp->userid);
|
||||
@ -316,7 +316,7 @@ static bool account_db_txt_remove(AccountDB* self, const int account_id)
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
//TODO: find out if this really works
|
||||
struct mmo_account* tmp = idb_remove(accounts, account_id);
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_remove(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// error condition - entry not present
|
||||
ShowError("account_db_txt_remove: no such account with id %d\n", account_id);
|
||||
@ -337,7 +337,7 @@ static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc)
|
||||
int account_id = acc->account_id;
|
||||
|
||||
// retrieve previous data
|
||||
struct mmo_acount* tmp = idb_get(accounts, account_id);
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// error condition - entry not found
|
||||
return false;
|
||||
@ -360,7 +360,7 @@ static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, co
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
// retrieve data
|
||||
struct mmo_account* tmp = idb_get(accounts, account_id);
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// entry not found
|
||||
return false;
|
||||
|
@ -11160,7 +11160,7 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
|
||||
return;
|
||||
}
|
||||
|
||||
guild_change_emblem(sd, emblem_len, emblem);
|
||||
guild_change_emblem(sd, emblem_len, (const char*)emblem);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
|
@ -2676,7 +2676,7 @@ static char *map_init_mapcache(FILE *fp)
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
// Allocate enough space
|
||||
CREATE(buffer, unsigned char, size);
|
||||
CREATE(buffer, char, size);
|
||||
|
||||
// No memory? Return..
|
||||
nullpo_ret(buffer);
|
||||
@ -2699,7 +2699,7 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
|
||||
int i;
|
||||
struct map_cache_main_header *header = (struct map_cache_main_header *)buffer;
|
||||
struct map_cache_map_info *info = NULL;
|
||||
unsigned char *p = buffer + sizeof(struct map_cache_main_header);
|
||||
char *p = buffer + sizeof(struct map_cache_main_header);
|
||||
|
||||
for(i = 0; i < header->map_count; i++) {
|
||||
info = (struct map_cache_map_info *)p;
|
||||
@ -2906,8 +2906,8 @@ int map_readallmaps (void)
|
||||
int i;
|
||||
FILE* fp=NULL;
|
||||
int maps_removed = 0;
|
||||
unsigned char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made
|
||||
unsigned char map_cache_decode_buffer[MAX_MAP_SIZE];
|
||||
char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made
|
||||
char map_cache_decode_buffer[MAX_MAP_SIZE];
|
||||
|
||||
if( enable_grf )
|
||||
ShowStatus("Loading maps (using GRF files)...\n");
|
||||
|
@ -3964,6 +3964,21 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
|
||||
static const struct {
|
||||
char str[32];
|
||||
enum MobSkillState id;
|
||||
} state[] = {
|
||||
{ "any", MSS_ANY }, //All states except Dead
|
||||
{ "idle", MSS_IDLE },
|
||||
{ "walk", MSS_WALK },
|
||||
{ "loot", MSS_LOOT },
|
||||
{ "dead", MSS_DEAD },
|
||||
{ "attack", MSS_BERSERK }, //Retaliating attack
|
||||
{ "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs)
|
||||
{ "chase", MSS_RUSH }, //Chase escaping target
|
||||
{ "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs)
|
||||
{ "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
|
||||
};
|
||||
static const struct {
|
||||
char str[32];
|
||||
int id;
|
||||
} cond1[] = {
|
||||
{ "always", MSC_ALWAYS },
|
||||
{ "myhpltmaxrate", MSC_MYHPLTMAXRATE },
|
||||
@ -4001,17 +4016,6 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
|
||||
{ "blind", SC_BLIND },
|
||||
{ "hiding", SC_HIDING },
|
||||
{ "sight", SC_SIGHT },
|
||||
}, state[] = {
|
||||
{ "any", MSS_ANY }, //All states except Dead
|
||||
{ "idle", MSS_IDLE },
|
||||
{ "walk", MSS_WALK },
|
||||
{ "loot", MSS_LOOT },
|
||||
{ "dead", MSS_DEAD },
|
||||
{ "attack", MSS_BERSERK }, //Retaliating attack
|
||||
{ "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs)
|
||||
{ "chase", MSS_RUSH }, //Chase escaping target
|
||||
{ "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs)
|
||||
{ "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
|
||||
}, target[] = {
|
||||
{ "target", MST_TARGET },
|
||||
{ "randomtarget", MST_RANDOM },
|
||||
|
@ -2340,7 +2340,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
|
||||
nd->speed = 200;
|
||||
nd->src_id = src_id;
|
||||
nd->bl.type = BL_NPC;
|
||||
nd->subtype = type;
|
||||
nd->subtype = (enum npc_subtype)type;
|
||||
switch( type )
|
||||
{
|
||||
case SCRIPT:
|
||||
|
@ -73,8 +73,8 @@
|
||||
struct pcrematch_entry {
|
||||
struct pcrematch_entry* next;
|
||||
char* pattern;
|
||||
pcre* pcre;
|
||||
pcre_extra* pcre_extra;
|
||||
pcre* pcre_;
|
||||
pcre_extra* pcre_extra_;
|
||||
char* label;
|
||||
};
|
||||
|
||||
@ -108,8 +108,8 @@ struct npc_parse {
|
||||
*/
|
||||
void finalize_pcrematch_entry(struct pcrematch_entry* e)
|
||||
{
|
||||
pcre_free(e->pcre);
|
||||
pcre_free(e->pcre_extra);
|
||||
pcre_free(e->pcre_);
|
||||
pcre_free(e->pcre_extra_);
|
||||
aFree(e->pattern);
|
||||
aFree(e->label);
|
||||
}
|
||||
@ -316,8 +316,8 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c
|
||||
struct pcrematch_entry *e = create_pcrematch_entry(s);
|
||||
e->pattern = aStrdup(pattern);
|
||||
e->label = aStrdup(label);
|
||||
e->pcre = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL);
|
||||
e->pcre_extra = pcre_study(e->pcre, 0, &err);
|
||||
e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL);
|
||||
e->pcre_extra_ = pcre_study(e->pcre_, 0, &err);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,7 +373,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
|
||||
int offsets[2*10 + 10]; // 1/3 reserved for temp space requred by pcre_exec
|
||||
|
||||
// perform pattern match
|
||||
int r = pcre_exec(e->pcre, e->pcre_extra, msg, len, 0, 0, offsets, ARRAYLENGTH(offsets));
|
||||
int r = pcre_exec(e->pcre_, e->pcre_extra_, msg, len, 0, 0, offsets, ARRAYLENGTH(offsets));
|
||||
if (r > 0)
|
||||
{
|
||||
// save out the matched strings
|
||||
|
@ -901,7 +901,7 @@ int add_word(const char* p)
|
||||
disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alfanumeric characters, and valid variable prefixes/postfixes.", p);
|
||||
|
||||
// Duplicate the word
|
||||
word = aMalloc(len+1);
|
||||
word = (char*)aMalloc(len+1);
|
||||
memcpy(word, p, len);
|
||||
word[len] = 0;
|
||||
|
||||
|
@ -184,7 +184,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
|
||||
searchstore_clear(sd);
|
||||
|
||||
// allocate max. amount of results
|
||||
sd->searchstore.items = aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
|
||||
sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
|
||||
|
||||
// search
|
||||
s.search_sd = sd;
|
||||
@ -215,7 +215,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
|
||||
if( sd->searchstore.count )
|
||||
{
|
||||
// reclaim unused memory
|
||||
sd->searchstore.items = aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
|
||||
sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
|
||||
|
||||
// present results
|
||||
clif_search_store_info_ack(sd);
|
||||
|
@ -2723,7 +2723,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
|
||||
|
||||
/// Recalculates parts of an object's battle status according to the specified flags.
|
||||
/// @param flag bitfield of values from enum scb_flag
|
||||
void status_calc_bl_main(struct block_list *bl, enum scb_flag flag)
|
||||
void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
|
||||
{
|
||||
const struct status_data *b_status = status_get_base_status(bl);
|
||||
struct status_data *status = status_get_status_data(bl);
|
||||
|
@ -1293,7 +1293,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap);
|
||||
int status_change_clear(struct block_list* bl, int type);
|
||||
int status_change_clear_buffs(struct block_list* bl, int type);
|
||||
|
||||
#define status_calc_bl(bl, flag) status_calc_bl_(bl, flag, false)
|
||||
#define status_calc_bl(bl, flag) status_calc_bl_(bl, (enum scb_flag)(flag), false)
|
||||
#define status_calc_mob(md, first) status_calc_bl_(&(md)->bl, SCB_ALL, first)
|
||||
#define status_calc_pet(pd, first) status_calc_bl_(&(pd)->bl, SCB_ALL, first)
|
||||
#define status_calc_pc(sd, first) status_calc_bl_(&(sd)->bl, SCB_ALL, first)
|
||||
|
@ -88,7 +88,12 @@ sigfunc *compat_signal(int signo, sigfunc *func)
|
||||
*/
|
||||
#ifdef CYGWIN
|
||||
#define FOPEN_ freopen
|
||||
#ifdef __cplusplus
|
||||
extern "C" void cygwin_stackdump();
|
||||
#else
|
||||
extern void cygwin_stackdump();
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define FOPEN_(fn,m,s) fopen(fn,m)
|
||||
#endif
|
||||
@ -186,7 +191,7 @@ int sig_final ()
|
||||
*/
|
||||
int sig_init ()
|
||||
{
|
||||
void (*func) = sig_dump;
|
||||
void (*func)(int) = sig_dump;
|
||||
#ifdef CYGWIN // test if dumper is enabled
|
||||
char *buf = getenv ("CYGWIN");
|
||||
if (buf && strstr(buf, "error_start") != NULL)
|
||||
|
@ -246,7 +246,7 @@ void process_args(int argc, char *argv[])
|
||||
|
||||
}
|
||||
|
||||
int do_init(int argc, char *argv[])
|
||||
int do_init(int argc, char** argv)
|
||||
{
|
||||
FILE *list;
|
||||
char line[1024];
|
||||
|
Loading…
x
Reference in New Issue
Block a user