diff options
author | Lupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-03 21:24:00 +0000 |
---|---|---|
committer | Lupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-03-03 21:24:00 +0000 |
commit | ceb9d10efbedfb55d5f25da49d4a9f2fd754542d (patch) | |
tree | d564e247d1f178debdee702601fce0e5160e033d /src/char_sql/int_guild.c | |
parent | 637d569d39efde3667c2388a2c748371f616cf6e (diff) | |
download | hercules-ceb9d10efbedfb55d5f25da49d4a9f2fd754542d.tar.gz hercules-ceb9d10efbedfb55d5f25da49d4a9f2fd754542d.tar.bz2 hercules-ceb9d10efbedfb55d5f25da49d4a9f2fd754542d.tar.xz hercules-ceb9d10efbedfb55d5f25da49d4a9f2fd754542d.zip |
SQL: Castles data saving bugfix (fully working! tested during WOE on 100 players, 19 guilds)
added 2 bugreports
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1201 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/int_guild.c')
-rw-r--r-- | src/char_sql/int_guild.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 8e71935ab..2f294bade 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -528,28 +528,23 @@ static int _set_guild_castle(void *key, void *data, va_list ap) { int inter_guildcastle_tosql(struct guild_castle *gc) { struct guild_castle *gcopy; - // `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`) - if(gc == NULL || gc->castle_id < 0 ){ //gc->castle_id can be == 0 (for the 1st castle it's == 0) [Lupus] return 0; } + //printf("[Guild Castle %02i]: Save...\n",gc->castle_id); + gcopy = numdb_search(castle_db_,gc->castle_id); + if (gcopy == NULL) { + gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); + numdb_insert(castle_db_, gc->castle_id, gcopy); + } else { + //if the castle data hasn't been changed, then we don't write it into SQL + if ((gc->guild_id == gcopy->guild_id ) && ( gc->economy == gcopy->economy ) && ( gc->defense == gcopy->defense ) && ( gc->triggerE == gcopy->triggerE ) && ( gc->triggerD == gcopy->triggerD ) && ( gc->nextTime == gcopy->nextTime ) && ( gc->payTime == gcopy->payTime ) && ( gc->createTime == gcopy->createTime ) && ( gc->visibleC == gcopy->visibleC ) && ( gc->visibleG0 == gcopy->visibleG0 ) && ( gc->visibleG1 == gcopy->visibleG1 ) && ( gc->visibleG2 == gcopy->visibleG2 ) && ( gc->visibleG3 == gcopy->visibleG3 ) && ( gc->visibleG4 == gcopy->visibleG4 ) && ( gc->visibleG5 == gcopy->visibleG5 ) && ( gc->visibleG6 == gcopy->visibleG6 ) && ( gc->visibleG7 == gcopy->visibleG7 ) && ( gc->Ghp0 == gcopy->Ghp0 ) && ( gc->Ghp1 == gcopy->Ghp1 ) && ( gc->Ghp2 == gcopy->Ghp2 ) && ( gc->Ghp3 == gcopy->Ghp3 ) && ( gc->Ghp4 == gcopy->Ghp4 ) && ( gc->Ghp5 == gcopy->Ghp5 ) && ( gc->Ghp6 == gcopy->Ghp6 ) && ( gc->Ghp7 == gcopy->Ghp7 )) + return 0; + } + //printf("[Guild Castle %02i]: Save... ->SQL\n",gc->castle_id); + memcpy(gcopy, gc, sizeof(struct guild_castle)); - if( gc->guild_id > 0) { //we just update the castle - printf("[Guild Castle %02i]: Save...\n",gc->castle_id); - - gcopy = numdb_search(castle_db_,gc->castle_id); - if (gcopy == NULL) { - gcopy = (struct guild_castle *) aMalloc(sizeof(struct guild_castle)); - numdb_insert(castle_db_, gc->castle_id, gcopy); - } else { - //if the castle data hasn't been changed, then we don't write it into SQL - if ((gc->guild_id == gcopy->guild_id ) && ( gc->economy == gcopy->economy ) && ( gc->defense == gcopy->defense ) && ( gc->triggerE == gcopy->triggerE ) && ( gc->triggerD == gcopy->triggerD ) && ( gc->nextTime == gcopy->nextTime ) && ( gc->payTime == gcopy->payTime ) && ( gc->createTime == gcopy->createTime ) && ( gc->visibleC == gcopy->visibleC ) && ( gc->visibleG0 == gcopy->visibleG0 ) && ( gc->visibleG1 == gcopy->visibleG1 ) && ( gc->visibleG2 == gcopy->visibleG2 ) && ( gc->visibleG3 == gcopy->visibleG3 ) && ( gc->visibleG4 == gcopy->visibleG4 ) && ( gc->visibleG5 == gcopy->visibleG5 ) && ( gc->visibleG6 == gcopy->visibleG6 ) && ( gc->visibleG7 == gcopy->visibleG7 ) && ( gc->Ghp0 == gcopy->Ghp0 ) && ( gc->Ghp1 == gcopy->Ghp1 ) && ( gc->Ghp2 == gcopy->Ghp2 ) && ( gc->Ghp3 == gcopy->Ghp3 ) && ( gc->Ghp4 == gcopy->Ghp4 ) && ( gc->Ghp5 == gcopy->Ghp5 ) && ( gc->Ghp6 == gcopy->Ghp6 ) && ( gc->Ghp7 == gcopy->Ghp7 )) - return 0; - } - printf("[Guild Castle %02i]: Save... ->SQL\n",gc->castle_id); - memcpy(gcopy, gc, sizeof(struct guild_castle)); - - sprintf(tmp_sql,"REPLACE INTO `%s` " + sprintf(tmp_sql,"REPLACE INTO `%s` " "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)" @@ -558,26 +553,13 @@ int inter_guildcastle_tosql(struct guild_castle *gc) gc->createTime, gc->visibleC, gc->visibleG0, gc->visibleG1, gc->visibleG2, gc->visibleG3, gc->visibleG4, gc->visibleG5, gc->visibleG6, gc->visibleG7, gc->Ghp0, gc->Ghp1, gc->Ghp2, gc->Ghp3, gc->Ghp4, gc->Ghp5, gc->Ghp6, gc->Ghp7); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - return 0; - } - } else { - sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='-1' WHERE `castle_id`='%d'",guild_db, gc->castle_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - return 0; - } - - sprintf(tmp_sql,"UPDATE `%s` SET `castle_id`='%d' WHERE `guild_id`='%d'",guild_db, gc->castle_id,gc->guild_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - return 0; - } + //printf(" %s\n",tmp_sql); + + if(mysql_query(&mysql_handle, tmp_sql) ) { + printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); + return 0; } + db_foreach(guild_db_, _set_guild_castle, gc->castle_id,gc->guild_id); return 0; |