Prechádzať zdrojové kódy

* [Fixed]:
- MAPREGSQL overloading SQL table with temperory map registries.
- Incorrect perfomance calculation for MAPREGSQL loading and saving.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7310 54d463be-8e91-2dee-dedb-b68131a5f0ec

Lance 19 rokov pred
rodič
commit
ec2fc0e437
3 zmenil súbory, kde vykonal 15 pridanie a 8 odobranie
  1. 5 0
      Changelog-Trunk.txt
  2. 1 0
      src/map/clif.c
  3. 9 8
      src/map/script.c

+ 5 - 0
Changelog-Trunk.txt

@@ -3,6 +3,11 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/06/23
+	* [Fixed]:
+	  - MAPREGSQL overloading SQL table with temperory map registries.
+	  - Incorrect perfomance calculation for MAPREGSQL loading and saving. [Lance]
+
 2006/06/22
 	* Guessed and added support for the packets 0x22a (idle) and 0x22b (spawn).
 	  This should complete the required packets for PACKETVER 7. [Skotlex]

+ 1 - 0
src/map/clif.c

@@ -7638,6 +7638,7 @@ int clif_refresh(struct map_session_data *sd) {
 	clif_updatestatus(sd,SP_MAXWEIGHT);
 	clif_updatestatus(sd,SP_WEIGHT);
 	map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
+	clif_weather_check(sd);
 	return 0;
 }
 

+ 9 - 8
src/map/script.c

@@ -11682,9 +11682,10 @@ int mapreg_setreg(int num,int val)
 #endif
 
 	if(val!=0) {
-
+		if(idb_put(mapreg_db,num,(void*)val))
+			;
 #if !defined(TXT_ONLY) && defined(MAPREGSQL)
-		if(name[1] != '@' && idb_get(mapreg_db,num) == NULL) {
+		else if(name[1] != '@') {
 			sprintf(tmp_sql,"INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%d')",mapregsql_db,mapregsql_db_varname,mapregsql_db_index,mapregsql_db_value,jstrescapecpy(tmp_str,name),i,val);
 			if(mysql_query(&mmysql_handle,tmp_sql)){
 				ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle));
@@ -11692,7 +11693,6 @@ int mapreg_setreg(int num,int val)
 			}
 		}
 #endif
-		idb_put(mapreg_db,num,(void*)val);
 	// else
 	} else { // [zBuffer]
 #if !defined(TXT_ONLY) && defined(MAPREGSQL)
@@ -11744,7 +11744,8 @@ int mapreg_setregstr(int num,const char *str)
 	if (idb_put(mapregstr_db,num,p))
 		;
 #if !defined(TXT_ONLY) && defined(MAPREGSQL)
-	else { //put returned null, so we must insert.
+	else if(name[1] != '@'){ //put returned null, so we must insert.
+		// Someone is causing a database size infinite increase here without name[1] != '@' [Lance]
 		sprintf(tmp_sql,"INSERT INTO `%s`(`%s`,`%s`,`%s`) VALUES ('%s','%d','%s')",mapregsql_db,mapregsql_db_varname,mapregsql_db_index,mapregsql_db_value,jstrescapecpy(tmp_str,name),i,jstrescapecpy(tmp_str2,p));
 		if(mysql_query(&mmysql_handle,tmp_sql)){
 			ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle));
@@ -11804,7 +11805,7 @@ static int script_load_mapreg(void)
 	| varname | index | value |
 	+-------------------------+
 	*/
-	int perfomance = gettick_nocache();
+	unsigned int perfomance = (unsigned int)time(NULL);
 	sprintf(tmp_sql,"SELECT * FROM `%s`",mapregsql_db);
 	ShowInfo("Querying script_load_mapreg ...\n");
 	if(mysql_query(&mmysql_handle, tmp_sql) ) {
@@ -11836,7 +11837,7 @@ static int script_load_mapreg(void)
 	ShowInfo("Freeing results...\n");
 	mysql_free_result(sql_res);
 	mapreg_dirty=0;
-	perfomance = (gettick_nocache() - perfomance) / 1000;
+	perfomance = ((unsigned int)time(NULL) - perfomance);
 	ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance);
 	return 0;
 #endif /* TXT_ONLY */
@@ -11912,10 +11913,10 @@ static int script_save_mapreg(void)
 	mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub,fp);
 	lock_fclose(fp,mapreg_txt,&lock);
 #else
-	int perfomance = (int)time(NULL);
+	unsigned int perfomance = (unsigned int)time(NULL);
 	mapreg_db->foreach(mapreg_db,script_save_mapreg_intsub);  // [zBuffer]
 	mapregstr_db->foreach(mapregstr_db,script_save_mapreg_strsub);
-	perfomance = ((int)time(NULL) - perfomance) / 1000;
+	perfomance = ((int)time(NULL) - perfomance);
 	if(perfomance > 2)
 		ShowWarning("Slow Query: MapregSQL Saving @ %d second(s).\n", perfomance);
 #endif