From 53d4cb5c798563c20e4602d5a65eefe00a0ac47c Mon Sep 17 00:00:00 2001
From: ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>
Date: Tue, 4 Jan 2011 18:59:50 +0000
Subject: * Added support for removal of trailing comments to sv_readdb
 (bugreport:4680). - Disabled monster BACSOJIN_T (1996) whose drop White Snake
 Hat (5411) is not enabled (was hidden by '//', which would cause errors now)
 (since r14412).

git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14649 54d463be-8e91-2dee-dedb-b68131a5f0ec
---
 Changelog-Trunk.txt |  2 ++
 db/Changelog.txt    |  3 +++
 db/mob_db.txt       |  2 +-
 db/mob_skill_db.txt | 24 ++++++++++++------------
 src/common/strlib.c | 10 +++++++---
 5 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index cbefe77b9..07a4689a1 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,5 +1,7 @@
 Date	Added
 
+2011/01/04
+	* Added support for removal of trailing comments to sv_readdb (bugreport:4680). [Ai4rei]
 2011/01/01
 	* Fixed local files could not be aliased with resnametable.txt in grfio (bugreport:2203, since r5152). [Ai4rei]
 	* Cleanups to grfio. [Ai4rei]
diff --git a/db/Changelog.txt b/db/Changelog.txt
index 47a00da35..4ed83b1e2 100644
--- a/db/Changelog.txt
+++ b/db/Changelog.txt
@@ -8,6 +8,9 @@
 	1475 Equestrian's Spear:	NEED INFO.
 	13005 Angelic Wing Dagger:	NEED INFO.
 =======================
+
+2011/01/04
+	* Rev. 14649 Disabled monster BACSOJIN_T (1996) whose drop White Snake Hat (5411) is not enabled (was hidden by '//', which would cause errors now) (since r14412). [Ai4rei]
 2010/12/30
 	* Rev. 14643 Updated mapcache up to 2010-12-01. Adds Bifrost, Dewata and Malangdo maps. [Ai4rei]
 	* Rev. 14641 Bug fixes. Not much else. :3
diff --git a/db/mob_db.txt b/db/mob_db.txt
index a24f48884..61c7f8890 100644
--- a/db/mob_db.txt
+++ b/db/mob_db.txt
@@ -1048,7 +1048,7 @@
 1993,NAGA,Naga,Naga,111,46708,0,30360,16348,3,8000,8800,38,15,113,42,30,108,122,13,10,12,2,2,42,0x3695,150,400,864,432,0,0,0,0,0,0,0,0,2389,10,2134,10,1485,10,926,5000,936,3500,954,2000,1408,20,0,0,0,0,0,0
 1994,LUCIOLA_VESPA,Luciola Vespa,Luciola Vespa,104,32600,0,16300,11410,1,9000,9900,29,5,104,56,30,20,116,4,10,12,1,4,24,0x7795,110,1000,864,432,0,0,0,0,0,0,0,0,2744,2,955,9000,939,9000,518,300,992,160,526,200,943,3000,0,0,0,0,4445,1
 1995,PINGUICULA,Pinguicula,Pinguicula,80,13680,0,6840,3420,1,600,720,25,5,102,23,30,10,86,2,10,12,1,3,62,0x308D,150,700,600,360,0,0,0,0,0,0,0,0,2745,1,1980,10,2270,10,7100,5000,7198,2000,7188,3000,712,1000,0,0,0,0,0,0
-1996,BACSOJIN_T,Bacsojin,White Lady,85,253221,0,45250,16445,3,1868,6124,20,55,52,65,44,112,152,35,10,12,2,7,64,0x37B5,130,576,960,480,0,0,0,0,0,0,0,0,//5411,500,2638,80,2639,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+//1996,BACSOJIN_T,Bacsojin,White Lady,85,253221,0,45250,16445,3,1868,6124,20,55,52,65,44,112,152,35,10,12,2,7,64,0x37B5,130,576,960,480,0,0,0,0,0,0,0,0,5411,500,2638,80,2639,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 1997,G_TATACHO,Tatacho,Tatacho,106,39500,0,0,0,2,10000,11000,20,17,106,40,30,25,115,6,10,12,1,2,22,0x108B,150,1000,768,360,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 1998,G_HILLSRION,Hillslion,Hillslion,105,34600,0,0,0,1,5000,5500,28,15,105,60,30,15,115,5,10,12,0,2,22,0x308D,100,400,780,576,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 1999,CENTIPEDE_LARVA,Centipede Larva,Centipede Larva,80,12000,0,3600,4800,2,948,1115,20,20,80,33,15,3,75,10,10,12,0,4,25,0x3795,150,1000,792,336,0,0,0,0,0,0,0,0,2406,9,732,50,0,0,1042,5335,912,5000,955,9000,943,2500,0,0,0,0,4452,1
diff --git a/db/mob_skill_db.txt b/db/mob_skill_db.txt
index 94f32f08b..81de7614f 100644
--- a/db/mob_skill_db.txt
+++ b/db/mob_skill_db.txt
@@ -5471,18 +5471,18 @@
 1995,Pinguicula@NPC_STOP,attack,342,1,500,500,5000,no,target,always,0,,,,,,30,
 1995,Pinguicula@NPC_EMOTION,chase,197,1,200,0,5000,yes,self,always,0,19,0x81,,,,,
 1995,Pinguicula@NPC_EMOTION,idle,197,1,2000,0,5000,yes,self,always,0,6,0x3885,,,,,
-1996,Bacsojin@NPC_INVISIBLE,chase,353,1,2000,1000,30000,yes,target,always,0,,,,,,29,
-1996,Bacsojin@PR_SANCTUARY,attack,70,10,2000,0,10000,yes,target,always,0,,,,,,18,
-1996,Bacsojin@HP_ASSUMPTIO,idle,361,5,10000,500,100000,yes,self,always,0,,,,,,,
-1996,Bacsojin@HP_ASSUMPTIO,chase,361,5,10000,500,100000,yes,self,always,0,,,,,,,
-1996,Bacsojin@HP_ASSUMPTIO,attack,361,5,10000,500,100000,yes,self,always,0,,,,,,,
-1996,Bacsojin@WZ_WATERBALL,chase,86,3,2000,1000,5000,yes,target,always,0,,,,,,,
-1996,Bacsojin@WZ_WATERBALL,attack,86,5,1000,0,5000,yes,target,always,0,,,,,,,
-1996,Bacsojin@NPC_STOP,attack,342,1,2000,500,15000,yes,target,always,0,,,,,,6,
-1996,Bacsojin@AL_TELEPORT,idle,26,1,1000,0,30000,yes,self,always,0,,,,,,,
-1996,Bacsojin@NPC_SUMMONSLAVE,idle,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
-1996,Bacsojin@NPC_SUMMONSLAVE,attack,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
-1996,Bacsojin@NPC_SUMMONSLAVE,chase,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
+//1996,Bacsojin@NPC_INVISIBLE,chase,353,1,2000,1000,30000,yes,target,always,0,,,,,,29,
+//1996,Bacsojin@PR_SANCTUARY,attack,70,10,2000,0,10000,yes,target,always,0,,,,,,18,
+//1996,Bacsojin@HP_ASSUMPTIO,idle,361,5,10000,500,100000,yes,self,always,0,,,,,,,
+//1996,Bacsojin@HP_ASSUMPTIO,chase,361,5,10000,500,100000,yes,self,always,0,,,,,,,
+//1996,Bacsojin@HP_ASSUMPTIO,attack,361,5,10000,500,100000,yes,self,always,0,,,,,,,
+//1996,Bacsojin@WZ_WATERBALL,chase,86,3,2000,1000,5000,yes,target,always,0,,,,,,,
+//1996,Bacsojin@WZ_WATERBALL,attack,86,5,1000,0,5000,yes,target,always,0,,,,,,,
+//1996,Bacsojin@NPC_STOP,attack,342,1,2000,500,15000,yes,target,always,0,,,,,,6,
+//1996,Bacsojin@AL_TELEPORT,idle,26,1,1000,0,30000,yes,self,always,0,,,,,,,
+//1996,Bacsojin@NPC_SUMMONSLAVE,idle,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
+//1996,Bacsojin@NPC_SUMMONSLAVE,attack,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
+//1996,Bacsojin@NPC_SUMMONSLAVE,chase,196,1,10000,0,5000,yes,self,slavele,1,,,,,,,
 1997,Tatacho@AL_TELEPORT,idle,26,1,10000,0,0,yes,self,rudeattacked,,,,,,,,
 1997,Tatacho@BS_HAMMERFALL,attack,110,3,500,1500,5000,no,target,always,0,,,,,,,
 1997,Tatacho@NPC_EMOTION,chase,197,1,200,0,5000,yes,self,always,0,19,0x81,,,,,
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 019e2d629..a0cba906c 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -925,6 +925,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
 	char** fields; // buffer for fields ([0] is reserved)
 	int columns, fields_length;
 	char path[1024], line[1024];
+	char* match;
 
 	snprintf(path, sizeof(path), "%s/%s", directory, filename);
 
@@ -944,9 +945,12 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
 	while( fgets(line, sizeof(line), fp) )
 	{
 		lines++;
-		if( line[0] == '/' && line[1] == '/' )
-			continue;
-		//TODO: strip trailing // comment
+
+		if( ( match = strstr(line, "//") ) != NULL )
+		{// strip comments
+			match[0] = 0;
+		}
+
 		//TODO: strip trailing whitespace
 		if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
 			continue;
-- 
cgit v1.2.3-70-g09d2