summaryrefslogtreecommitdiff
path: root/src/char_sql/int_storage.c
diff options
context:
space:
mode:
author(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-24 03:12:42 +0000
committer(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-24 03:12:42 +0000
commit817a048b554ed05fda836a9b55e0dc9a816334b7 (patch)
tree1ff6297e35e9c286198b0e5201f186d4cdb9f4c5 /src/char_sql/int_storage.c
parentb50b9537644c77a4a9e03e5ad0e8d7ee3a952401 (diff)
downloadhercules-817a048b554ed05fda836a9b55e0dc9a816334b7.tar.gz
hercules-817a048b554ed05fda836a9b55e0dc9a816334b7.tar.bz2
hercules-817a048b554ed05fda836a9b55e0dc9a816334b7.tar.xz
hercules-817a048b554ed05fda836a9b55e0dc9a816334b7.zip
A lot of changes. login and char server compile under both TXT and SQL under g++. Same for the convertors (login and char). One change that I felt iffy about, but it worked, was the char* buf -> unsinged char* bug in clif.c
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@975 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/int_storage.c')
-rw-r--r--src/char_sql/int_storage.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c
index e2d4010a1..b93fc5b7d 100644
--- a/src/char_sql/int_storage.c
+++ b/src/char_sql/int_storage.c
@@ -24,7 +24,7 @@ int storage_tosql(int account_id,struct storage *p){
struct itemtemp mapitem;
for(i=0;i<MAX_STORAGE;i++){
if(p->storage[i].nameid>0){
- if(itemdb_isequip(p->storage[i].nameid)==1){
+ if(itemdb_isequip(p->storage[i].nameid)==1){
mapitem.equip[eqcount].flag=0;
mapitem.equip[eqcount].id = p->storage[i].id;
mapitem.equip[eqcount].nameid=p->storage[i].nameid;
@@ -39,7 +39,7 @@ int storage_tosql(int account_id,struct storage *p){
mapitem.equip[eqcount].card[3] = p->storage[i].card[3];
eqcount++;
}
- else if(itemdb_isequip(p->storage[i].nameid)==0){
+ else if(itemdb_isequip(p->storage[i].nameid)==0){
mapitem.notequip[noteqcount].flag=0;
mapitem.notequip[noteqcount].id = p->storage[i].id;
mapitem.notequip[noteqcount].nameid=p->storage[i].nameid;
@@ -66,18 +66,18 @@ int storage_tosql(int account_id,struct storage *p){
// DB -> storage data conversion
int storage_fromsql(int account_id, struct storage *p){
int i=0;
-
+
memset(p,0,sizeof(struct storage)); //clean up memory
p->storage_amount = 0;
p->account_id = account_id;
-
+
// storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
sprintf(tmp_sql,"SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`card0`,`card1`,`card2`,`card3` FROM `%s` WHERE `account_id`='%d'",storage_db, account_id);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
}
sql_res = mysql_store_result(&mysql_handle) ;
-
+
if (sql_res) {
while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch
p->storage[i].id= atoi(sql_row[0]);
@@ -95,7 +95,7 @@ int storage_fromsql(int account_id, struct storage *p){
}
mysql_free_result(sql_res);
}
-
+
printf ("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount);
return 1;
}
@@ -108,7 +108,7 @@ int guild_storage_tosql(int guild_id, struct guild_storage *p){
struct itemtemp mapitem;
for(i=0;i<MAX_GUILD_STORAGE;i++){
if(p->storage[i].nameid>0){
- if(itemdb_isequip(p->storage[i].nameid)==1){
+ if(itemdb_isequip(p->storage[i].nameid)==1){
mapitem.equip[eqcount].flag=0;
mapitem.equip[eqcount].id = p->storage[i].id;
mapitem.equip[eqcount].nameid=p->storage[i].nameid;
@@ -123,7 +123,7 @@ int guild_storage_tosql(int guild_id, struct guild_storage *p){
mapitem.equip[eqcount].card[3] = p->storage[i].card[3];
eqcount++;
}
- else if(itemdb_isequip(p->storage[i].nameid)==0){
+ else if(itemdb_isequip(p->storage[i].nameid)==0){
mapitem.notequip[noteqcount].flag=0;
mapitem.notequip[noteqcount].id = p->storage[i].id;
mapitem.notequip[noteqcount].nameid=p->storage[i].nameid;
@@ -163,7 +163,7 @@ int guild_storage_fromsql(int guild_id, struct guild_storage *p){
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
}
sql_res = mysql_store_result(&mysql_handle) ;
-
+
if (sql_res) {
while((sql_row = mysql_fetch_row(sql_res))) { //start to fetch
p->storage[i].id= atoi(sql_row[0]);
@@ -188,14 +188,14 @@ int guild_storage_fromsql(int guild_id, struct guild_storage *p){
//---------------------------------------------------------
// storage data initialize
int inter_storage_sql_init(){
-
+
//memory alloc
printf("interserver storage memory initialize....(%d byte)\n",sizeof(struct storage));
- storage_pt=aCalloc(sizeof(struct storage), 1);
- guild_storage_pt=aCalloc(sizeof(struct guild_storage), 1);
+ storage_pt = (struct storage*)aCalloc(sizeof(struct storage), 1);
+ guild_storage_pt = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1);
memset(storage_pt,0,sizeof(struct storage));
memset(guild_storage_pt,0,sizeof(struct guild_storage));
-
+
return 1;
}
// 倉庫データ削除
@@ -243,7 +243,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id)
{
int guild_exist=0;
WFIFOW(fd,0)=0x3818;
-
+
// Check if guild exists, I may write a function for this later, coz I use it several times.
//printf("- Check if guild %d exists\n",g->guild_id);
sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id);
@@ -257,7 +257,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id)
//printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes"));
}
mysql_free_result(sql_res) ; //resource free
-
+
if(guild_exist==1) {
guild_storage_fromsql(guild_id,guild_storage_pt);
WFIFOW(fd,2)=sizeof(struct guild_storage)+12;
@@ -296,7 +296,7 @@ int mapif_parse_LoadStorage(int fd){
int mapif_parse_SaveStorage(int fd){
int account_id=RFIFOL(fd,4);
int len=RFIFOW(fd,2);
-
+
if(sizeof(struct storage)!=len-8){
printf("inter storage: data size error %d %d\n",sizeof(struct storage),len-8);
}else{
@@ -335,7 +335,7 @@ int mapif_parse_SaveGuildStorage(int fd)
//printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes"));
}
mysql_free_result(sql_res) ; //resource free
-
+
if(guild_exist==1) {
memcpy(guild_storage_pt,RFIFOP(fd,12),sizeof(struct guild_storage));
guild_storage_tosql(guild_id,guild_storage_pt);