Explorar o código

SQL: Castles data saving bugfix (fully working! tested during WOE on 100 players, 19 guilds)

added 2 bugreports

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1201 54d463be-8e91-2dee-dedb-b68131a5f0ec
Lupus %!s(int64=20) %!d(string=hai) anos
pai
achega
b0c8088a8e
Modificáronse 3 ficheiros con 33 adicións e 45 borrados
  1. 2 0
      Changelog-SVN.txt
  2. 12 8
      Dev/bugs.txt
  3. 19 37
      src/char_sql/int_guild.c

+ 2 - 0
Changelog-SVN.txt

@@ -1,5 +1,7 @@
 Date	Added
 
+04/02
+	* Fixed SQL Guild Castle Saving (now fully working, tested on 100 players during WOE) [Lupus]
 03/02
 	* Fixed SQL Guild Castle Saving (partial, yet it doesn't clear GuildID when you abandon a castle) [Lupus]
 	  + added 2 fixes by POW (Mac Guild Position fix, Max Guild Members fix)

+ 12 - 8
Dev/bugs.txt

@@ -305,12 +305,6 @@ Problem:	Rogues Skill "back stab" works without PREPARING arrows.
 Assigned:	Celest
 Progress:	100%
 
-Problem:	Party EXP share bug
-		When one member enter, re-enter the server sometimes it happens you
-		can share EXP with memebers of ANY LEVEL.
-Assigned:	N/A
-Progress:	0%
-
 Problem:	Skill Delays Bug (Hunters)
 		When you use a skill then Equip Another kind of arrows,
 		you can immediately cast another SKILL. (Bind skills on hot keys and... u get a killing machine)
@@ -367,7 +361,7 @@ Problem:	ABRAKADABRA (HOCUS POCUS)
 Assigned:	N/A
 Progress:	0%
 
-Problem:	Arrows Dupe
+Problem:	Arrows Dupe (or random amount change)
 		You should prepare/remove arrows while trade. And have both - names and unnamed arrows ^_-
 Assigned:	N/A
 Progress:	0%
@@ -389,8 +383,18 @@ Problem:	ICE WALL
 Assigned:	N/A
 Progress:	0%
 
-Problem:	Castles Again!
+Problem:	SQL Castles Again!
 		The casltes data isn't being saved at all.
 		During WOE everything acts like it was at the previous Castles save bug time.
+Assigned:	Lupus
+Progress:	100%
+
+Problem:	Party EXP share bug
+		1. Create a party
+		2. Invite a member
+		3. Kick him out the party
+		4. Invite him again.
+		Now he can get His 100% EXP + 100% Yours EXP (in the party window you look like you're off )
+			* SQL parties have been fixed in Freya (but the whole file int_party.c has been rewritten there)
 Assigned:	N/A
 Progress:	0%

+ 19 - 37
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;