summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-26 10:37:45 +0000
commit49e9510c432987393d10ec1b8b1c2d416c9feb42 (patch)
tree4d930ebf1094ad5972cb8ba20b89d12ce74d4f3c /src/char_sql
parentfda87bd7ef5a71f4f5d5e604de1b15c58763efdd (diff)
downloadhercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.gz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.bz2
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.tar.xz
hercules-49e9510c432987393d10ec1b8b1c2d416c9feb42.zip
Adjusted eAthena code to compile cleanly in C++ mode.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/char.c40
-rw-r--r--src/char_sql/int_auction.c4
-rw-r--r--src/char_sql/int_guild.c6
-rw-r--r--src/char_sql/int_homun.c2
-rw-r--r--src/char_sql/int_mail.c4
-rw-r--r--src/char_sql/int_party.c4
-rw-r--r--src/char_sql/inter.c29
7 files changed, 43 insertions, 46 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 9112265da..ab243e217 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -232,7 +232,7 @@ void set_char_online(int map_id, int char_id, int account_id)
}
}
- character = idb_ensure(online_char_db, account_id, create_online_char_data);
+ character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data);
if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id)
{
//char == 99 <- Character logging in, so someone has logged in while one
@@ -257,7 +257,7 @@ void set_char_online(int map_id, int char_id, int account_id)
if (char_id != 99)
{ //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it.
struct mmo_charstatus *cp;
- cp = idb_get(char_db_,char_id);
+ cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
inter_guild_CharOnline(char_id, cp?cp->guild_id:-1);
}
if (login_fd > 0 && !session[login_fd]->flag.eof)
@@ -281,7 +281,7 @@ void set_char_offline(int char_id, int account_id)
}
else
{
- struct mmo_charstatus* cp = idb_get(char_db_,char_id);
+ struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(char_db_,char_id);
inter_guild_CharOffline(char_id, cp?cp->guild_id:-1);
if (cp)
idb_remove(char_db_,char_id);
@@ -290,7 +290,7 @@ void set_char_offline(int char_id, int account_id)
Sql_ShowDebug(sql_handle);
}
- if ((character = idb_get(online_char_db, account_id)) != NULL)
+ if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL)
{ //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex]
if( character->server > -1 )
server[character->server].users--;
@@ -442,9 +442,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if (char_id!=p->char_id) return 0;
#ifndef TXT_SQL_CONVERT
- cp = idb_ensure(char_db_, char_id, create_charstatus);
+ cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus);
#else
- cp = aCalloc(1, sizeof(struct mmo_charstatus));
+ cp = (struct mmo_charstatus*)aCalloc(1, sizeof(struct mmo_charstatus));
#endif
StringBuf_Init(&buf);
@@ -1141,7 +1141,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
SqlStmt_Free(stmt);
StringBuf_Destroy(&buf);
- cp = idb_ensure(char_db_, char_id, create_charstatus);
+ cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus);
memcpy(cp, p, sizeof(struct mmo_charstatus));
return 1;
}
@@ -1613,7 +1613,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
return;
}
- if( online_check && (character = idb_get(online_char_db, sd->account_id)) != NULL )
+ if( online_check && (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL )
{ // check if character is not online already. [Skotlex]
if (character->server > -1)
{ //Character already online. KICK KICK KICK
@@ -1898,7 +1898,7 @@ int parse_fromlogin(int fd)
return 0;
if(!char_gm_read) {
- unsigned char buf[32000];
+ unsigned char buf[32000]; //FIXME: this will crash
if (gm_account != NULL)
aFree(gm_account);
gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
@@ -1926,7 +1926,7 @@ int parse_fromlogin(int fd)
{
struct online_char_data* character;
int aid = RFIFOL(fd,2);
- if ((character = idb_get(online_char_db, aid)) != NULL)
+ if ((character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL)
{ //Kick out this player.
if( character->server > -1 )
{ //Kick it from the map server it is on.
@@ -2118,7 +2118,7 @@ int char_send_fame_list(int fd)
void char_update_fame_list(int type, int index, int fame)
{
- char buf[9];
+ unsigned char buf[8];
WBUFW(buf,0) = 0x2b22;
WBUFB(buf,2) = type;
WBUFB(buf,3) = index;
@@ -2346,7 +2346,7 @@ int parse_frommap(int fd)
for(i = 0; i < server[id].users; i++) {
aid = RFIFOL(fd,6+i*8);
cid = RFIFOL(fd,6+i*8+4);
- character = idb_ensure(online_char_db, aid, create_online_char_data);
+ character = (struct online_char_data*)idb_ensure(online_char_db, aid, create_online_char_data);
if (character->server > -1 && character->server != id)
{
ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
@@ -2375,7 +2375,7 @@ int parse_frommap(int fd)
}
//Check account only if this ain't final save. Final-save goes through because of the char-map reconnect
if (RFIFOB(fd,12) || (
- (character = idb_get(online_char_db, aid)) != NULL &&
+ (character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL &&
character->char_id == cid))
{
struct mmo_charstatus char_dat;
@@ -2435,7 +2435,7 @@ int parse_frommap(int fd)
if (map_id >= 0)
map_fd = server[map_id].fd;
//Char should just had been saved before this packet, so this should be safe. [Skotlex]
- char_data = uidb_get(char_db_,RFIFOL(fd,14));
+ char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
if (char_data == NULL)
{ //Really shouldn't happen.
mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
@@ -2460,7 +2460,7 @@ int parse_frommap(int fd)
memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
WFIFOSET(map_fd, WFIFOW(map_fd,2));
- data = idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data);
+ data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data);
data->char_id = char_data->char_id;
data->server = map_id; //Update server where char is.
@@ -2683,7 +2683,7 @@ int parse_frommap(int fd)
char esc_motd[sizeof(motd)*2+1];
char esc_server_name[sizeof(server_name)*2+1];
- strncpy(motd, RFIFOP(fd,10), 255); //First copy it to make sure the motd fits.
+ strncpy(motd, (char*)RFIFOP(fd,10), 255); //First copy it to make sure the motd fits.
motd[255] = '\0';
Sql_EscapeString(sql_handle, esc_motd, motd);
Sql_EscapeString(sql_handle, esc_server_name, server_name);
@@ -2851,7 +2851,7 @@ int parse_char(int fd)
{
if (sd != NULL)
{ // already authed client
- struct online_char_data* data = idb_get(online_char_db, sd->account_id);
+ struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
if (!data || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
set_char_offline(99,sd->account_id);
if (data && data->fd == fd)
@@ -3202,8 +3202,8 @@ int parse_char(int fd)
if (RFIFOREST(fd) < 60)
return 0;
{
- char* l_user = RFIFOP(fd,2);
- char* l_pass = RFIFOP(fd,26);
+ char* l_user = (char*)RFIFOP(fd,2);
+ char* l_pass = (char*)RFIFOP(fd,26);
l_user[23] = '\0';
l_pass[23] = '\0';
ARR_FIND( 0, MAX_MAP_SERVERS, i, server[i].fd <= 0 );
@@ -3466,7 +3466,7 @@ int ping_login_server(int tid, unsigned int tick, int id, int data)
static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data)
{
struct online_char_data* character;
- if ((character = idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid)
+ if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid)
{ //Mark it offline due to timeout.
character->waiting_disconnect = -1;
set_char_offline(character->char_id, character->account_id);
diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c
index 15b316bb8..84f0ff424 100644
--- a/src/char_sql/int_auction.c
+++ b/src/char_sql/int_auction.c
@@ -30,7 +30,7 @@ static int auction_count(int char_id, bool buy)
DBKey key;
iter = auction_db_->iterator(auction_db_);
- for( auction = iter->first(iter,&key); iter->exists(iter); auction = iter->next(iter,&key) )
+ for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) )
{
if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) )
i++;
@@ -262,7 +262,7 @@ static void mapif_parse_Auction_requestlist(int fd)
memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH);
iter = auction_db_->iterator(auction_db_);
- for( auction = iter->first(iter,&key); iter->exists(iter); auction = iter->next(iter,&key) )
+ for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) )
{
if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) ||
(type == 1 && auction->type != IT_WEAPON) ||
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 93b915886..3ff05ddf1 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -59,7 +59,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, int data)
state = 1;
iter = guild_db_->iterator(guild_db_);
- for( g = iter->first(iter,&key); iter->exists(iter); g = iter->next(iter,&key) )
+ for( g = (struct guild*)iter->first(iter,&key); iter->exists(iter); g = (struct guild*)iter->next(iter,&key) )
{
if( state == 0 && g->guild_id == last_id )
state++; //Save next guild in the list.
@@ -374,7 +374,7 @@ struct guild * inter_guild_fromsql(int guild_id)
if( guild_id <= 0 )
return NULL;
- g = idb_get(guild_db_, guild_id);
+ g = (struct guild*)idb_get(guild_db_, guild_id);
if( g )
return g;
@@ -1852,7 +1852,7 @@ int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value)
case 1:
if( gc.guild_id!=value ){
int gid=(value)?value:gc.guild_id;
- struct guild *g=idb_get(guild_db_, gid);
+ struct guild *g = (struct guild*)idb_get(guild_db_, gid);
if(log_inter)
inter_log("guild %s (id=%d) %s castle id=%d\n",
(g)?g->name:"??" ,gid, (value)?"occupy":"abandon", castle_id);
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index 4e596ef28..591ab219d 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -302,7 +302,7 @@ int inter_homunculus_parse_frommap(int fd){
case 0x3091: mapif_load_homunculus(fd); break;
case 0x3092: mapif_save_homunculus(fd, RFIFOW(fd,4), (struct s_homunculus*) RFIFOP(fd, 8)); break;
case 0x3093: mapif_delete_homunculus(fd); break; // doesn't need to be parse, very simple packet...
- case 0x3094: mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOP(fd, 10)); break;
+ case 0x3094: mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), (char*)RFIFOP(fd, 10)); break;
default:
return 0;
}
diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c
index 86a076b0d..963647200 100644
--- a/src/char_sql/int_mail.c
+++ b/src/char_sql/int_mail.c
@@ -53,7 +53,7 @@ static int mail_fromsql(int char_id, struct mail_data* md)
Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- Sql_GetData(sql_handle, 8, &data, NULL); msg->status = atoi(data);
+ Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
item = &msg->item;
Sql_GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
@@ -169,7 +169,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- Sql_GetData(sql_handle, 8, &data, NULL); msg->status = atoi(data);
+ Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
Sql_GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
Sql_GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index a51b8def0..a4769ebd6 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -211,7 +211,7 @@ struct party_data *inter_party_fromsql(int party_id)
return NULL;
//Load from memory
- p = idb_get(party_db_, party_id);
+ p = (struct party_data*)idb_get(party_db_, party_id);
if( p != NULL )
return p;
@@ -498,7 +498,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
}
}
- p= aCalloc(1, sizeof(struct party_data));
+ p = (struct party_data*)aCalloc(1, sizeof(struct party_data));
memcpy(p->party.name,name,NAME_LENGTH);
p->party.exp=0;
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 089e93740..4f856211d 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -485,8 +485,9 @@ int mapif_wis_message(struct WisData *wd)
return 0;
}
+
// Wis sending result
-int mapif_wis_end(struct WisData *wd,int flag)
+int mapif_wis_end(struct WisData *wd, int flag)
{
unsigned char buf[27];
@@ -497,15 +498,11 @@ int mapif_wis_end(struct WisData *wd,int flag)
return 0;
}
-int mapif_account_reg(int fd,unsigned char *src)
+// Account registry transfer to map-server
+static void mapif_account_reg(int fd, unsigned char *src)
{
-// unsigned char buf[WBUFW(src,2)]; <- Hey, can this really be done? [Skotlex]
- unsigned char *buf = aCalloc(1,WBUFW(src,2)); // [Lance] - Skot... Dynamic allocation is better :D
- memcpy(WBUFP(buf,0),src,WBUFW(src,2));
- WBUFW(buf, 0)=0x3804;
- mapif_sendallwos(fd, buf, WBUFW(buf,2));
- aFree(buf);
- return 0;
+ WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
+ mapif_sendallwos(fd, src, WBUFW(src,2));
}
// Send the requested account_reg
@@ -524,8 +521,8 @@ int mapif_account_reg_reply(int fd,int account_id,int char_id, int type)
}else{
int i,p;
for (p=13,i = 0; i < reg->reg_num && p < 5000; i++) {
- p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].value)+1;
+ p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place.
+ p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].value)+1;
}
WFIFOW(fd,2)=p;
if (p>= 5000)
@@ -605,7 +602,7 @@ int check_ttl_wisdata(void)
wis_delnum = 0;
wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick);
for(i = 0; i < wis_delnum; i++) {
- struct WisData *wd = idb_get(wis_db, wis_dellist[i]);
+ struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]);
ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst);
// removed. not send information after a timeout. Just no answer for the player
//mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
@@ -710,7 +707,7 @@ int mapif_parse_WisReply(int fd)
id = RFIFOL(fd,2);
flag = RFIFOB(fd,6);
- wd = idb_get(wis_db, id);
+ wd = (struct WisData*)idb_get(wis_db, id);
if (wd == NULL)
return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
@@ -755,10 +752,10 @@ int mapif_parse_Registry(int fd)
return 1;
}
for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
- sscanf(RFIFOP(fd,p), "%31c%n",reg->reg[j].str,&len);
+ sscanf((char*)RFIFOP(fd,p), "%31c%n",reg->reg[j].str,&len);
reg->reg[j].str[len]='\0';
p +=len+1; //+1 to skip the '\0' between strings.
- sscanf(RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len);
+ sscanf((char*)RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len);
reg->reg[j].value[len]='\0';
p +=len+1;
}
@@ -802,7 +799,7 @@ int mapif_parse_NameChangeRequest(int fd)
account_id = RFIFOL(fd,2);
char_id = RFIFOL(fd,6);
type = RFIFOB(fd,10);
- name = RFIFOP(fd,11);
+ name = (char*)RFIFOP(fd,11);
// Check Authorised letters/symbols in the name
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised