Переглянути джерело

- Added a message to @clearweather stating when climate changes will dispel.
- Corrected @hidenpc saying that it's command name was "@npcoff"
- Updated itemdb reading on the char-sql server so that it reads both item_db and item_db2 files (totally untested yet as I can't compile SQL here x.x)


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

skotlex 19 роки тому
батько
коміт
dfac028631
5 змінених файлів з 125 додано та 91 видалено
  1. 6 0
      Changelog-Trunk.txt
  2. 1 0
      conf-tmpl/msg_athena.conf
  3. 98 75
      src/char_sql/itemdb.c
  4. 18 15
      src/char_sql/itemdb.h
  5. 2 1
      src/map/atcommand.c

+ 6 - 0
Changelog-Trunk.txt

@@ -3,6 +3,12 @@ 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/08/30
+	* Added a message to @clearweather stating when climate changes will
+	  dispel. [Skotlex]
+	* Corrected @hidenpc saying that it's command name was "@npcoff" [Skotlex]
+	* Updated itemdb reading on the char-sql server so that it reads both
+	  item_db and item_db2 files (totally untested yet) [Skotlex]
 2006/08/29
 	* Added printing out whenever the irc-module attempts to connect, to debug
 	  whether the map-server lag is due to this or not. [Skotlex]

+ 1 - 0
conf-tmpl/msg_athena.conf

@@ -302,6 +302,7 @@
 288: You are no longer killable
 289: The player is now killable
 290: The player is no longer killable
+291: Weather effects will dispell on warp/refresh
 // Guild Castles Number
 // --------------------
 299: ?? Castles

+ 98 - 75
src/char_sql/itemdb.c

@@ -96,100 +96,123 @@ static int itemdb_readdb(void)
 {
 	FILE *fp;
 	char line[1024];
-	int ln=0;
+	int ln=0,lines=0;
 	int nameid,j;
-	char *str[128],*p,*np;
+	char *str[32],*p,*np;
 	struct item_data *id;
-
-	sprintf(line, "%s/item_db.txt", db_path);
-	fp=fopen(line,"r");
-	if(fp==NULL){
-		ShowError("can't read %s\n", str);
-		exit(1);
-	}
-	while(fgets(line,1020,fp)){
-		if(line[0]=='/' && line[1]=='/')
-			continue;
-		memset(str,0,sizeof(str));
-		for(j=0,np=p=line;j<17 && p;j++){
-			str[j]=p;
-			p=strchr(p,',');
-			if(p){ *p++=0; np=p; }
+	int i=0;
+	char *filename[]={ "item_db.txt","item_db2.txt" };
+
+	for(i=0;i<2;i++){
+		sprintf(line, "%s/%s", db_path, filename[i]);
+		fp=fopen(line,"r");
+		if(fp==NULL){
+			if(i>0)
+				continue;
+			ShowFatalError("can't read %s\n",line);
+			exit(1);
 		}
-		if(str[0]==NULL)
-			continue;
-
-		nameid=atoi(str[0]);
-		if(nameid<=0 || nameid>=20000)
-			continue;
-		ln++;
 
-		//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Gender,Loc,wLV,eLV,View
-		id=itemdb_search(nameid);
-		memcpy(id->name,str[1],ITEM_NAME_LENGTH-1);
-		memcpy(id->jname,str[2],ITEM_NAME_LENGTH-1);
-		id->type=atoi(str[3]);
+		lines=0;
+		while(fgets(line,1020,fp)){
+			lines++;
+			if(line[0]=='/' && line[1]=='/')
+				continue;
+			malloc_tsetdword(str,0,sizeof(str));
+			for(j=0,np=p=line;j<4 && p;j++){
+				str[j]=p;
+				p=strchr(p,',');
+				if(p){ *p++=0; np=p; }
+			}
+			if(str[0]==NULL)
+				continue;
 
+			nameid=atoi(str[0]);
+			if(nameid<=0)
+				continue;
+			if (j < 4)
+			{	//Crash-fix on broken item lines. [Skotlex]
+				ShowWarning("Reading %s: Insufficient fields for item with id %d, skipping.\n", filename[i], nameid);
+				continue;
+			}
+			ln++;
+
+			//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View
+			id=itemdb_search(nameid);
+			strncpy(id->name, str[1], ITEM_NAME_LENGTH-1);
+			strncpy(id->jname, str[2], ITEM_NAME_LENGTH-1);
+			id->type=atoi(str[3]);
+			if (id->type == IT_DELAYCONSUME)
+				id->type = IT_USABLE;
+		}
+		fclose(fp);
+		if (ln > 0) {
+			ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,filename[i]);
+		}
+		ln=0;	// reset to 0
 	}
-	fclose(fp);
-	ShowStatus("done reading item_db.txt (count=%d)\n",ln);
 	return 0;
 }
 
 static int itemdb_read_sqldb(void) // sql item_db read, shortened version of map-server item_db read [Valaris]
 {
-	unsigned int nameid; 	// Type should be "unsigned short int", but currently isn't for compatibility with numdb_insert()
+	unsigned short nameid;
 	struct item_data *id;
+	char *item_db_name[] = { item_db_db, item_db2_db };
+	long unsigned int ln = 0;
+	int i;	
 
 	// ----------
 
-	// Output query to retrieve all rows from the item database table
-	sprintf(tmp_sql, "SELECT * FROM `%s`", item_db_db);
-
-	// Execute the query; if the query execution fails, output an error
-	if (mysql_query(&mysql_handle, tmp_sql)) {
-		ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
-		ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
-	}
-
-	// Store the query result
-	sql_res = mysql_store_result(&mysql_handle);
-
-	// If the storage of the query result succeeded
-	if (sql_res) {
-		// Parse each row in the query result into sql_row
-		while ((sql_row = mysql_fetch_row(sql_res))) {
-			nameid = atoi(sql_row[0]);
-
-			// If the identifier is not within the valid range, process the next row
-			if (nameid == 0 || nameid >= 20000)	{	// Should ">= 20000" be "> 20000"?
-				continue;
+	for (i = 0; i < 2; i++) {
+		sprintf(tmp_sql, "SELECT * FROM `%s`", item_db_name[i]);
+
+		// Execute the query; if the query execution succeeded...
+		if (mysql_query(&mmysql_handle, tmp_sql) == 0) {
+			sql_res = mysql_store_result(&mmysql_handle);
+
+			// If the storage of the query result succeeded...
+			if (sql_res) {
+				// Parse each row in the query result into sql_row
+				while ((sql_row = mysql_fetch_row(sql_res)))
+				{	/*Table structure is:
+					00  id
+					01  name_english
+					02  name_japanese
+					03  type
+					...
+					*/
+					nameid = atoi(sql_row[0]);
+
+					// If the identifier is not within the valid range, process the next row
+					if (nameid == 0)
+						continue;
+
+					ln++;
+
+					// ----------
+         		id=itemdb_search(nameid);
+					
+					strncpy(id->name, sql_row[1], ITEM_NAME_LENGTH-1);
+					strncpy(id->jname, sql_row[2], ITEM_NAME_LENGTH-1);
+
+					id->type = atoi(sql_row[3]);
+					if (id->type == IT_DELAYCONSUME)
+						id->type = IT_USABLE;
+				}
+				ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", ln, item_db_name[i]);
+				ln = 0;
+			} else {
+				ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mmysql_handle));
+				ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
 			}
 
-			// ----------
-
-			// Update/Insert row into the item database
-         id=itemdb_search(nameid);
-
-			memcpy(id->name, sql_row[1], ITEM_NAME_LENGTH-1);
-			memcpy(id->jname, sql_row[2], ITEM_NAME_LENGTH-1);
-
-			id->type = atoi(sql_row[3]);
-		}
-
-		// If the retrieval failed, output an error
-		if (mysql_errno(&mysql_handle)) {
-			ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
+			// Free the query result
+			mysql_free_result(sql_res);
+		} else {
+			ShowSQL("DB error (%s) - %s\n",item_db_name[i], mysql_error(&mmysql_handle));
 			ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
 		}
-
-		ShowInfo("read %s done (count = %lu)\n", item_db_db, (unsigned long) mysql_num_rows(sql_res));
-
-		// Free the query result
-		mysql_free_result(sql_res);
-	} else {
-		ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
-		ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
 	}
 
 	return 0;

+ 18 - 15
src/char_sql/itemdb.h

@@ -5,25 +5,28 @@
 #define _ITEMDB_H_
 #include "mmo.h"
 
+//FIXME: Maybe it would be better to move this enum to mmo.h,
+//instead of having it twice on the map server and here? [Skotlex]
+enum {
+	IT_HEALING = 0,
+	IT_UNKNOWN, //1
+	IT_USABLE,  //2
+	IT_ETC,     //3
+	IT_WEAPON,  //4
+	IT_ARMOR,   //5
+	IT_CARD,    //6
+	IT_PETEGG,  //7
+	IT_PETARMOR,//8
+	IT_UNKNOWN2,//9
+	IT_AMMO,    //10
+	IT_DELAYCONSUME,//11
+	IT_MAX 
+} item_types;
+
 struct item_data {
 	int nameid;
 	char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];
-	int value_buy,value_sell,value_notdc,value_notoc;
 	int type;
-	int class_;
-	int sex;
-	int equip;
-	int weight;
-	int atk;
-	int def;
-	int range;
-	int slot;
-	int look;
-	int elv;
-	int wlv;
-	char *use_script;	// 回復とかも全部この中でやろうかなと
-	char *equip_script;	// 攻撃,防御の属性設定もこの中で可能かな?
-	char available;
 };
 
 struct item_data* itemdb_search(int nameid);

+ 2 - 1
src/map/atcommand.c

@@ -6184,7 +6184,7 @@ int atcommand_hidenpc(const int fd, struct map_session_data* sd,
 	malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
 
 	if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
-		clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
+		clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
 		return -1;
 	}
 
@@ -8355,6 +8355,7 @@ atcommand_clearweather(
 	map[sd->bl.m].flag.fireworks=0;
 	map[sd->bl.m].flag.leaves=0;
 	clif_weather(sd->bl.m);
+	clif_displaymessage(fd, msg_txt(291));
 	
 	return 0;
 }