summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorgreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-07-11 22:07:39 +0000
committergreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-07-11 22:07:39 +0000
commit3ec480937ea4f48e37762d93fadb7909f31eea83 (patch)
tree6ec6f169c5bab16652d2f03311e87ae1a1b45041 /src/map/map.c
parent665602e6e9eb89f6bf87e15473c2a42974b7cce1 (diff)
downloadhercules-3ec480937ea4f48e37762d93fadb7909f31eea83.tar.gz
hercules-3ec480937ea4f48e37762d93fadb7909f31eea83.tar.bz2
hercules-3ec480937ea4f48e37762d93fadb7909f31eea83.tar.xz
hercules-3ec480937ea4f48e37762d93fadb7909f31eea83.zip
Fixed bugreport:6187 @reloadscript now reload map config files seeking for npcs.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16403 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/map/map.c b/src/map/map.c
index de71d0e84..9a5350e2d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3338,6 +3338,52 @@ int map_config_read(char *cfgName)
return 0;
}
+void map_reloadnpc_sub(char *cfgName)
+{
+ char line[1024], w1[1024], w2[1024];
+ FILE *fp;
+
+ fp = fopen(cfgName,"r");
+ if( fp == NULL )
+ {
+ ShowError("Map configuration file not found at: %s\n", cfgName);
+ return;
+ }
+
+ while( fgets(line, sizeof(line), fp) )
+ {
+ char* ptr;
+
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+ if( (ptr = strstr(line, "//")) != NULL )
+ *ptr = '\n'; //Strip comments
+ if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
+ continue;
+
+ //Strip trailing spaces
+ ptr = w2 + strlen(w2);
+ while (--ptr >= w2 && *ptr == ' ');
+ ptr++;
+ *ptr = '\0';
+
+ if (strcmpi(w1, "npc") == 0)
+ npc_addsrcfile(w2);
+ else if (strcmpi(w1, "import") == 0)
+ map_reloadnpc_sub(w2);
+ else
+ ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
+ }
+
+ fclose(fp);
+}
+
+void map_reloadnpc()
+{
+ npc_addsrcfile("clear"); // this will clear the current script list
+ map_reloadnpc_sub(MAP_CONF_NAME);
+}
+
int inter_config_read(char *cfgName)
{
char line[1024],w1[1024],w2[1024];