Index: /cpp/frams/param/param.cpp
===================================================================
--- /cpp/frams/param/param.cpp	(revision 153)
+++ /cpp/frams/param/param.cpp	(revision 154)
@@ -17,114 +17,114 @@
 char MakeCodeGuardHappy;
 
-ParamEntry empty_paramtab[]=
-{ {"Empty",1,0,"Empty",}, {0,0,0,}, }; 
-
-static void czytdotyldy(VirtFILE *f,SString &s)
-{
-SString temp;
-int z;
-char last_char=0;
-while((z=fgetc(f))!=EOF)
-	{
-	if (z=='~')
-		if (last_char!='\\') break;
-	last_char=(char)z;
-	temp+=last_char;
-	}
-s=temp;
-}
-
-static const char *strchrlimit(const char *t,int ch,const char *limit)
-{
-int n=limit-t;
-for (;(n>0)&&*t;t++,n--)
-	if (*t==ch) return t;
-return 0;
+ParamEntry empty_paramtab[] =
+{ { "Empty", 1, 0, "Empty", }, { 0, 0, 0, }, };
+
+static void czytdotyldy(VirtFILE *f, SString &s)
+{
+	SString temp;
+	int z;
+	char last_char = 0;
+	while ((z = fgetc(f)) != EOF)
+	{
+		if (z == '~')
+			if (last_char != '\\') break;
+		last_char = (char)z;
+		temp += last_char;
+	}
+	s = temp;
+}
+
+static const char *strchrlimit(const char *t, int ch, const char *limit)
+{
+	int n = limit - t;
+	for (; (n > 0) && *t; t++, n--)
+		if (*t == ch) return t;
+	return 0;
 }
 
 void ParamInterface::copyFrom(ParamInterface *src)
 {
-int n=getPropCount();
-ExtValue v;
-int j;
-for(int i=0;i<n;i++)
-  if ((!(flags(i)&PARAM_READONLY))
-	  && (*type(i)!='p'))
-	{
-	j=src->findId(id(i));
-	if (j<0) continue;
-	src->get(j,v);
-	set(i,v);
-	}
+	int n = getPropCount();
+	ExtValue v;
+	int j;
+	for (int i = 0; i < n; i++)
+		if ((!(flags(i)&PARAM_READONLY))
+			&& (*type(i) != 'p'))
+		{
+			j = src->findId(id(i));
+			if (j < 0) continue;
+			src->get(j, v);
+			set(i, v);
+		}
 }
 
 void ParamInterface::quickCopyFrom(ParamInterface *src)
 {
-int n=getPropCount();
-ExtValue v;
-for(int i=0;i<n;i++)
-  if ((!(flags(i)&PARAM_READONLY))
-	  && (*type(i)!='p'))
-	  {
-	  src->get(i,v);
-	  set(i,v);
-	  }
-}
-
-int ParamInterface::getMinMax(int prop,long& minumum,long& maximum,long &def)
-{
-const char* t=type(prop)+1;
-while(*t) if (*t==' ') break; else t++;
-return sscanf(t,"%ld %ld %ld",&minumum,&maximum,&def);
-}
-
-int ParamInterface::getMinMax(int prop,double& minumum,double& maximum,double& def)
-{
-const char* t=type(prop)+1;
-while(*t) if (*t==' ') break; else t++;
-return sscanf(t,"%lg %lg %lg",&minumum,&maximum,&def);
+	int n = getPropCount();
+	ExtValue v;
+	for (int i = 0; i < n; i++)
+		if ((!(flags(i)&PARAM_READONLY))
+			&& (*type(i) != 'p'))
+		{
+			src->get(i, v);
+			set(i, v);
+		}
+}
+
+int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long &def)
+{
+	const char* t = type(prop) + 1;
+	while (*t) if (*t == ' ') break; else t++;
+	return sscanf(t, "%ld %ld %ld", &minumum, &maximum, &def);
+}
+
+int ParamInterface::getMinMax(int prop, double& minumum, double& maximum, double& def)
+{
+	const char* t = type(prop) + 1;
+	while (*t) if (*t == ' ') break; else t++;
+	return sscanf(t, "%lg %lg %lg", &minumum, &maximum, &def);
 }
 
 void ParamInterface::setDefault(bool numericonly)
 {
-int n=getPropCount();
-for(int i=0;i<n;i++)
-	setDefault(i,numericonly);
+	int n = getPropCount();
+	for (int i = 0; i < n; i++)
+		setDefault(i, numericonly);
 }
 
 void ParamInterface::setMin()
 {
-int n=getPropCount();
-for(int i=0;i<n;i++)
-	setMin(i);
+	int n = getPropCount();
+	for (int i = 0; i < n; i++)
+		setMin(i);
 }
 
 void ParamInterface::setMax()
 {
-int n=getPropCount();
-for(int i=0;i<n;i++)
-	setMax(i);
-}
-
-void ParamInterface::setDefault(int i,bool numericonly)
-{
-const char *t=type(i);
-switch(*t)
+	int n = getPropCount();
+	for (int i = 0; i < n; i++)
+		setMax(i);
+}
+
+void ParamInterface::setDefault(int i, bool numericonly)
+{
+	const char *t = type(i);
+	switch (*t)
 	{
 	case 'f':
 	{
-	double a=0,b=0,c=0;
-	if (getMinMax(i,a,b,c)<3) c=a;
-	setDouble(i,c);
-	}
-	break;
+		double a = 0, b = 0, c = 0;
+		if (getMinMax(i, a, b, c) < 3) c = a;
+		setDouble(i, c);
+	}
+		break;
 	case 'd':
 	{
-	long a=0,b=0,c=0;
-	if (getMinMax(i,a,b,c)<3) c=a;
-	setInt(i,c);
-	}
-	break;
-	default: if (!numericonly) set(i,"");
+		long a = 0, b = 0, c = 0;
+		if (getMinMax(i, a, b, c) < 3) c = a;
+		setInt(i, c);
+	}
+		break;
+	default: if (!numericonly) set(i, "");
 	}
 }
@@ -132,22 +132,22 @@
 void ParamInterface::setMin(int i)
 {
-const char *t=type(i);
-switch(*t)
+	const char *t = type(i);
+	switch (*t)
 	{
 	case 'f':
 	{
-	double a=0,b=0,c=0;
-	getMinMax(i,a,b,c);
-	setDouble(i,a);
-	}
-	break;
+		double a = 0, b = 0, c = 0;
+		getMinMax(i, a, b, c);
+		setDouble(i, a);
+	}
+		break;
 	case 'd':
 	{
-	long a=0,b=0,c=0;
-	getMinMax(i,a,b,c);
-	setInt(i,a);
-	}
-	break;
-	default: set(i,"");
+		long a = 0, b = 0, c = 0;
+		getMinMax(i, a, b, c);
+		setInt(i, a);
+	}
+		break;
+	default: set(i, "");
 	}
 }
@@ -155,22 +155,22 @@
 void ParamInterface::setMax(int i)
 {
-const char *t=type(i);
-switch(*t)
+	const char *t = type(i);
+	switch (*t)
 	{
 	case 'f':
 	{
-	double a=0,b=0,c=0;
-	getMinMax(i,a,b,c);
-	setDouble(i,b);
-	}
-	break;
+		double a = 0, b = 0, c = 0;
+		getMinMax(i, a, b, c);
+		setDouble(i, b);
+	}
+		break;
 	case 'd':
 	{
-	long a=0,b=0,c=0;
-	getMinMax(i,a,b,c);
-	setInt(i,b);
-	}
-	break;
-	default: set(i,"");
+		long a = 0, b = 0, c = 0;
+		getMinMax(i, a, b, c);
+		setInt(i, b);
+	}
+		break;
+	default: set(i, "");
 	}
 }
@@ -200,177 +200,179 @@
 {int i=findId(prop); if (i>=0) return set(i,v); else return PSET_NOPROPERTY;}
 
-int ParamInterface::save(VirtFILE* f,const char* altname,bool force)
-{
-const char *p;
-SString ws;
-int err=0,i;
-bool withname=false;
-if ((altname==NULL)||(altname[0]!=0))
-	{
-	err|=(fputs(altname?altname:getName(),f)==EOF);
-	err|=(fputs(":\n",f)==EOF);
-	withname=true;
-	}
-for (i=0;p=id(i);i++)
-	err|=saveprop(f,i,p,force);
-if (withname)
-	err|=(fputs("\n",f)==EOF);
-return err;
-}
-
-const char* ParamInterface::SERIALIZATION_PREFIX="@Serialized:";
-
-int ParamInterface::saveprop(VirtFILE* f,int i,const char* p,bool force)
-{
-if ((flags(i)&PARAM_DONTSAVE)&&(!force)) return 0;
-const char *typ=type(i);
-if ((*typ=='p')||(*typ=='o')) return 0;
-
-const char *t,*w;
-SString ws;
-int err=0,cr;
-
-err|=(fputs(p,f)==EOF); fputc(':',f);
-cr=0;
-if (*typ=='x')
-	{
-	ExtValue ex;
-	get(i,ex);
-	ws=SString(SERIALIZATION_PREFIX)+ex.serialize();
-	}
-else
-	ws=get(i);
-quoteTilde(ws);
-w=ws;
-if (ws.len()>50) cr=1;
-else for (t=w;*t;t++) if ((*t==10)||(*t==13)) {cr=1; break;}
-if (cr) fputs("~\n",f);
-err|=(fputs(w,f)==EOF);
-err|=(fputs(cr ? "~\n" : "\n",f)==EOF);
-return err;
-}
-
-
-int SimpleAbstractParam::isequal(int i,void* defdata)
+int ParamInterface::save(VirtFILE* f, const char* altname, bool force)
+{
+	const char *p;
+	SString ws;
+	int err = 0, i;
+	bool withname = false;
+	if ((altname == NULL) || (altname[0] != 0))
+	{
+		err |= (fputs(altname ? altname : getName(), f) == EOF);
+		err |= (fputs(":\n", f) == EOF);
+		withname = true;
+	}
+	for (i = 0; p = id(i); i++)
+		err |= saveprop(f, i, p, force);
+	if (withname)
+		err |= (fputs("\n", f) == EOF);
+	return err;
+}
+
+const char* ParamInterface::SERIALIZATION_PREFIX = "@Serialized:";
+
+int ParamInterface::saveprop(VirtFILE* f, int i, const char* p, bool force)
+{
+	if ((flags(i)&PARAM_DONTSAVE) && (!force)) return 0;
+	const char *typ = type(i);
+	if ((*typ == 'p') || (*typ == 'o')) return 0;
+
+	const char *t, *w;
+	SString ws;
+	int err = 0, cr;
+
+	err |= (fputs(p, f) == EOF); fputc(':', f);
+	cr = 0;
+	if (*typ == 'x')
+	{
+		ExtValue ex;
+		get(i, ex);
+		ws = SString(SERIALIZATION_PREFIX) + ex.serialize();
+	}
+	else
+		ws = get(i);
+	quoteTilde(ws);
+	w = ws;
+	if (ws.len() > 50) cr = 1;
+	else for (t = w; *t; t++) if ((*t == 10) || (*t == 13)) { cr = 1; break; }
+	if (cr) fputs("~\n", f);
+	err |= (fputs(w, f) == EOF);
+	err |= (fputs(cr ? "~\n" : "\n", f) == EOF);
+	return err;
+}
+
+
+int SimpleAbstractParam::isequal(int i, void* defdata)
 { // defdata->member == object->member ?
-void *backup=object;
-switch(type(i)[0])
+	void *backup = object;
+	switch (type(i)[0])
 	{
 	case 'd':
-		{
+	{
 		select(defdata);
-		long x=getInt(i);
+		long x = getInt(i);
 		select(backup);
-		return x==getInt(i);
-		}
+		return x == getInt(i);
+	}
 	case 'f':
-		{
+	{
 		select(defdata);
-		double x=getDouble(i);
+		double x = getDouble(i);
 		select(backup);
-		return x==getDouble(i);
-		}
+		return x == getDouble(i);
+	}
 	case 's':
-		{
+	{
 		select(defdata);
-		SString x=getString(i);
+		SString x = getString(i);
 		select(backup);
-		return x==getString(i);
-		}
-	}
-return 1;
-}
-
-void SimpleAbstractParam::save2(SString& f,void *defdata,bool addcr,bool all_names)
-{ // defdata!=NULL -> nie zapisuje wartosci domyslnych
-const char *p;
-int i;
-int needlabel=0;
-int first=1;
-SString val;
-SString t;
-int fl;
-// t+=SString(getName()); t+=':';
-for (i=0;p=id(i);i++)
-	if (!((fl=flags(i))&PARAM_DONTSAVE))
-	{
-	if (defdata && isequal(i,defdata))
-		needlabel=1;
-	else
-		{
-		if (!first) t+=", ";
+		return x == getString(i);
+	}
+	}
+	return 1;
+}
+
+void SimpleAbstractParam::save2(SString& f, void *defdata, bool addcr, bool all_names)
+{ // defdata!=NULL -> does not save default values
+	const char *p;
+	int i;
+	int needlabel = 0;
+	int first = 1;
+	SString val;
+	SString t;
+	int fl;
+	// t+=SString(getName()); t+=':';
+	for (i = 0; p = id(i); i++)
+		if (!((fl = flags(i))&PARAM_DONTSAVE))
+		{
+			if (defdata && isequal(i, defdata))
+				needlabel = 1;
+			else
+			{
+				if (!first) t += ", ";
 #ifndef SAVE_ALL_NAMES
 #ifdef SAVE_SELECTED_NAMES
-		if (needlabel || all_names || !(fl & PARAM_CANOMITNAME))
+				if (needlabel || all_names || !(fl & PARAM_CANOMITNAME))
 #else
-		if (needlabel)
+				if (needlabel)
 #endif
 #endif
-			{ t+=p; t+="="; needlabel=0; }
-		if (type(i)[0]=='s')
-			{ // string - special case
-			SString str=getString(i);
-			if (strContainsOneOf(str,", \\\n\r\t\""))
 				{
-				t+="\"";
-				sstringQuote(str);
-				t+=str;
-				t+="\"";
+					t += p; t += "="; needlabel = 0;
 				}
+				if (type(i)[0] == 's')
+				{ // string - special case
+					SString str = getString(i);
+					if (strContainsOneOf(str, ", \\\n\r\t\""))
+					{
+						t += "\"";
+						sstringQuote(str);
+						t += str;
+						t += "\"";
+					}
+					else
+						t += str;
+				}
+				else
+					t += get(i);
+				first = 0;
+			}
+		}
+	if (addcr)
+		t += "\n";
+	f += t;
+}
+
+int ParamInterface::load(VirtFILE* f)
+{
+	SString buf;
+	int i;
+	const char *p, *p0;
+	int p_len;
+	bool loaded;
+	int fields_loaded = 0;
+	while (loadSStringLine(f, buf))
+	{
+		const char* t = (const char*)buf;
+		p0 = t; while ((*p0 == ' ') || (*p0 == '\t')) p0++;
+		if (!*p0) break;
+		p = strchr(p0, ':'); if (!p) continue;
+		p_len = p - p0;
+		loaded = false;
+		if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD)))
+		{
+			if (p0[p_len + 1] == '~')
+			{
+				SString s;
+				czytdotyldy(f, s);
+				removeCR(s);
+				int ch; while ((ch = fgetc(f)) != EOF) if (ch == '\n') break;
+				unquoteTilde(s);
+				set(i, (const char*)s);
+			}
 			else
-				t+=str;
+			{
+				set(i, p0 + p_len + 1);
 			}
-		else
-	   		t+=get(i);
-		first=0;
-		}
-	}
-if (addcr)
-	t+="\n";
-f+=t;
-}
-
-int ParamInterface::load(VirtFILE* f)
-{
-SString buf;
-int i;
-const char *p,*p0;
-int p_len;
-bool loaded;
-int fields_loaded=0;
-while(loadSStringLine(f,buf))
-	{
-	const char* t=(const char*)buf;
-	p0=t; while ((*p0==' ')||(*p0=='\t')) p0++;
-	if (!*p0) break;
-	p=strchr(p0,':'); if (!p) continue;
-	p_len=p-p0;
-	loaded=false;
-	if (p_len&&((i=findIdn(p0,p_len))>=0)&&(!(flags(i)&PARAM_DONTLOAD)))
-		{
-		if (p0[p_len+1]=='~')
-			{
+			fields_loaded++;
+			loaded = true;
+		}
+		if ((!loaded) && (p0[p_len + 1] == '~'))
+		{ // eat unrecognized multiline field
 			SString s;
-			czytdotyldy(f,s);
-			removeCR(s);
-			int ch; while((ch=fgetc(f))!=EOF) if (ch=='\n') break;
-			unquoteTilde(s);
-			set(i,(const char*)s);
-			}
-		else
-			{
-			set(i,p0+p_len+1);
-			}
-		fields_loaded++;
-		loaded=true;
-		}
-	if ((!loaded) && (p0[p_len+1]=='~'))
-		{ // eat unrecognized multiline field
-		SString s;
-		czytdotyldy(f,s);
-		int ch; while((ch=fgetc(f))!=EOF) if (ch=='\n') break;
-		}
-	}
-return fields_loaded;
+			czytdotyldy(f, s);
+			int ch; while ((ch = fgetc(f)) != EOF) if (ch == '\n') break;
+		}
+	}
+	return fields_loaded;
 }
 
@@ -403,19 +405,19 @@
 int ParamInterface::findId(const char* n)
 {
-int i; const char *p;
-	for (i=0;p=id(i);i++) if (!strcmp(n,p)) return i;
-return -1;
-}
-
-int ParamInterface::findIdn(const char* naz,int n)
-{
-int i; const char *p;
-	for (i=0;p=id(i);i++) if ((!strncmp(naz,p,n))&&(!p[n])) return i;
-return -1;
-}
-
-void ParamInterface::get(int i,ExtValue &ret)
-{
-switch(type(i)[0])
+	int i; const char *p;
+	for (i = 0; p = id(i); i++) if (!strcmp(n, p)) return i;
+	return -1;
+}
+
+int ParamInterface::findIdn(const char* naz, int n)
+{
+	int i; const char *p;
+	for (i = 0; p = id(i); i++) if ((!strncmp(naz, p, n)) && (!p[n])) return i;
+	return -1;
+}
+
+void ParamInterface::get(int i, ExtValue &ret)
+{
+	switch (type(i)[0])
 	{
 	case 'd':	ret.setInt(getInt(i)); break;
@@ -423,6 +425,6 @@
 	case 's':	ret.setString(getString(i)); break;
 	case 'o':	ret.setObject(getObject(i)); break;
-	case 'x':	ret=getExtValue(i); break;
-	default: FMprintf("ParamInterface","get",FMLV_ERROR,"'%s.%s' is not a field",getName(),id(i));
+	case 'x':	ret = getExtValue(i); break;
+	default: FMprintf("ParamInterface", "get", FMLV_ERROR, "'%s.%s' is not a field", getName(), id(i));
 	}
 }
@@ -430,117 +432,117 @@
 static bool stringIsNumeric(const char* str)
 {//   /-?.?[0-9]+/
-if (!str) return false;
-if (*str=='-') str++;
-if (*str=='.') str++;
-return isdigit(*str)!=0;
-}
-
-int ParamInterface::setInt(int i,const char* str)
-{
-if (!stringIsNumeric(str))
-	{
-	long a,b,c;
-	if (getMinMax(i,a,b,c)>=3)
-		return setInt(i,c);
-	else
-		return setInt(i,(long)0);
-	}
-else
-	return setInt(i,ExtValue::getInt(str));
-}
-
-int ParamInterface::setDouble(int i,const char* str)
-{
-if (!stringIsNumeric(str))
-	{
-	double a,b,c;
-	if (getMinMax(i,a,b,c)>=3)
-		return setDouble(i,c);
-	else
-		return setDouble(i,(double)0);
-	}
-else
-	return setDouble(i,ExtValue::getDouble(str));
-}
-
-int ParamInterface::set(int i,const ExtValue &v)
-{
-switch(type(i)[0])
+	if (!str) return false;
+	if (*str == '-') str++;
+	if (*str == '.') str++;
+	return isdigit(*str) != 0;
+}
+
+int ParamInterface::setInt(int i, const char* str)
+{
+	if (!stringIsNumeric(str))
+	{
+		long a, b, c;
+		if (getMinMax(i, a, b, c) >= 3)
+			return setInt(i, c);
+		else
+			return setInt(i, (long)0);
+	}
+	else
+		return setInt(i, ExtValue::getInt(str));
+}
+
+int ParamInterface::setDouble(int i, const char* str)
+{
+	if (!stringIsNumeric(str))
+	{
+		double a, b, c;
+		if (getMinMax(i, a, b, c) >= 3)
+			return setDouble(i, c);
+		else
+			return setDouble(i, (double)0);
+	}
+	else
+		return setDouble(i, ExtValue::getDouble(str));
+}
+
+int ParamInterface::set(int i, const ExtValue &v)
+{
+	switch (type(i)[0])
 	{
 	case 'd':
-		if ((v.type==TInt)||(v.type==TDouble)) return setInt(i,v.getInt());
+		if ((v.type == TInt) || (v.type == TDouble)) return setInt(i, v.getInt());
 		else
-			{
-			if (v.type==TObj)
-				FMprintf("ParamInterface","set",FMLV_WARN,"Getting integer value from object reference (%s)",(const char*)v.getString());
-			return setInt(i,(const char*)v.getString());
-			}
+		{
+			if (v.type == TObj)
+				FMprintf("ParamInterface", "set", FMLV_WARN, "Getting integer value from object reference (%s)", (const char*)v.getString());
+			return setInt(i, (const char*)v.getString());
+		}
 	case 'f':
-		if ((v.type==TInt)||(v.type==TDouble)) return setDouble(i,v.getDouble());
+		if ((v.type == TInt) || (v.type == TDouble)) return setDouble(i, v.getDouble());
 		else
-			{
-			if (v.type==TObj)
-				FMprintf("ParamInterface","set",FMLV_WARN,"Getting floating point value from object reference (%s)",(const char*)v.getString());
-			return setDouble(i,(const char*)v.getString());
-			}
-	case 's': { SString t=v.getString(); return setString(i,t); }
-	case 'o': return setObject(i,v.getObject());
-	case 'x': return setExtValue(i,v);
-	default: FMprintf("ParamInterface","set",FMLV_ERROR,"'%s.%s' is not a field",getName(),id(i));
-	}
-return 0;
-}
-
-int ParamInterface::set(int i,const char *v)
-{
-switch(type(i)[0])
-	{
-	case 'd': return setInt(i,v);
-	case 'f': return setDouble(i,v);
-	case 's': { SString t(v); return setString(i,t); }
+		{
+			if (v.type == TObj)
+				FMprintf("ParamInterface", "set", FMLV_WARN, "Getting floating point value from object reference (%s)", (const char*)v.getString());
+			return setDouble(i, (const char*)v.getString());
+		}
+	case 's': { SString t = v.getString(); return setString(i, t); }
+	case 'o': return setObject(i, v.getObject());
+	case 'x': return setExtValue(i, v);
+	default: FMprintf("ParamInterface", "set", FMLV_ERROR, "'%s.%s' is not a field", getName(), id(i));
+	}
+	return 0;
+}
+
+int ParamInterface::set(int i, const char *v)
+{
+	switch (type(i)[0])
+	{
+	case 'd': return setInt(i, v);
+	case 'f': return setDouble(i, v);
+	case 's': { SString t(v); return setString(i, t); }
 	case 'x':
 	{
-	ExtValue e;
-	const char* after;
-	if (!strncmp(v,SERIALIZATION_PREFIX,strlen(SERIALIZATION_PREFIX)))
-		{
-		after=e.deserialize(v+strlen(SERIALIZATION_PREFIX));
-		if ((after==NULL)||(*after))
-			FMprintf("ParamInterface","set",FMLV_WARN,"serialization format mismatch in %s.%s",(getName()?getName():"<Unknown>"),id(i));
-		}
-	else if ((after=e.parseNumber(v))&&(*after==0)) //consumed the whole string
-		{
-		//OK!
-		}
-	else
-		{
-		e.setString(SString(v));
-		}
-	return setExtValue(i,e);
-	}
-	}
-return 0;
+		ExtValue e;
+		const char* after;
+		if (!strncmp(v, SERIALIZATION_PREFIX, strlen(SERIALIZATION_PREFIX)))
+		{
+			after = e.deserialize(v + strlen(SERIALIZATION_PREFIX));
+			if ((after == NULL) || (*after))
+				FMprintf("ParamInterface", "set", FMLV_WARN, "serialization format mismatch in %s.%s", (getName() ? getName() : "<Unknown>"), id(i));
+		}
+		else if ((after = e.parseNumber(v)) && (*after == 0)) //consumed the whole string
+		{
+			//OK!
+		}
+		else
+		{
+			e.setString(SString(v));
+		}
+		return setExtValue(i, e);
+	}
+	}
+	return 0;
 }
 
 SString ParamInterface::getText(int i)
 {
-const char *t;
-if ((*(t=type(i)))=='d')
-	{
-	for (int j=getInt(i);j>=0;j--) if (t) t=strchr(t+1,'~');
-	if (t)
-		{
-		t++;
-		const char *t2=strchr(t,'~');
-		if (!t2) t2=t+strlen(t);
-		return SString(t,t2-t);
-		}
-	}
-return get(i);
+	const char *t;
+	if ((*(t = type(i))) == 'd')
+	{
+		for (int j = getInt(i); j >= 0; j--) if (t) t = strchr(t + 1, '~');
+		if (t)
+		{
+			t++;
+			const char *t2 = strchr(t, '~');
+			if (!t2) t2 = t + strlen(t);
+			return SString(t, t2 - t);
+		}
+	}
+	return get(i);
 }
 
 SString ParamInterface::get(int i)
 {
-switch(type(i)[0])
+	switch (type(i)[0])
 	{
 	case 'd': return SString::valueOf(getInt(i));
@@ -548,7 +550,7 @@
 	case 's': return getString(i);
 	}
-ExtValue v;
-get(i,v);
-return v.getString();
+	ExtValue v;
+	get(i, v);
+	return v.getString();
 }
 
@@ -558,6 +560,6 @@
 void *SimpleAbstractParam::getTarget(int i)
 {
-return (void*)(((char*)object)+entry(i)->offset);
-//return &(object->*(entry(i)->fldptr));
+	return (void*)(((char*)object) + entry(i)->offset);
+	//return &(object->*(entry(i)->fldptr));
 }
 
@@ -566,15 +568,15 @@
 long SimpleAbstractParam::getInt(int i)
 {
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->fun1)
-	{
-	(*(void(*)(void*,ExtValue*))pe->fun1)(object,&v);
-	return v.getInt();
-	}
-else
-	{
-	void *target=getTarget(i);
-	return *((long*)target);
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->fun1)
+	{
+		(*(void(*)(void*, ExtValue*))pe->fun1)(object, &v);
+		return v.getInt();
+	}
+	else
+	{
+		void *target = getTarget(i);
+		return *((long*)target);
 	}
 }
@@ -582,15 +584,15 @@
 double SimpleAbstractParam::getDouble(int i)
 {
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->fun1)
-	{
-	(*(void(*)(void*,ExtValue*))pe->fun1)(object,&v);
-	return v.getDouble();
-	}
-else
-	{
-	void *target=getTarget(i);
-	return *((double*)target);
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->fun1)
+	{
+		(*(void(*)(void*, ExtValue*))pe->fun1)(object, &v);
+		return v.getDouble();
+	}
+	else
+	{
+		void *target = getTarget(i);
+		return *((double*)target);
 	}
 }
@@ -598,15 +600,15 @@
 SString SimpleAbstractParam::getString(int i)
 {
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->fun1)
-	{
-	(*(void(*)(void*,ExtValue*))pe->fun1)(object,&v);
-	return v.getString();
-	}
-else
-	{
-	void *target=getTarget(i);
-	return *((SString*)target);
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->fun1)
+	{
+		(*(void(*)(void*, ExtValue*))pe->fun1)(object, &v);
+		return v.getString();
+	}
+	else
+	{
+		void *target = getTarget(i);
+		return *((SString*)target);
 	}
 }
@@ -614,15 +616,15 @@
 ExtObject SimpleAbstractParam::getObject(int i)
 {
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->fun1)
-	{
-	(*(void(*)(void*,ExtValue*))pe->fun1)(object,&v);
-	return v.getObject();
-	}
-else
-	{
-	void *target=getTarget(i);
-	return *((ExtObject*)target);
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->fun1)
+	{
+		(*(void(*)(void*, ExtValue*))pe->fun1)(object, &v);
+		return v.getObject();
+	}
+	else
+	{
+		void *target = getTarget(i);
+		return *((ExtObject*)target);
 	}
 }
@@ -630,15 +632,15 @@
 ExtValue SimpleAbstractParam::getExtValue(int i)
 {
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->fun1)
-	{
-	(*(void(*)(void*,ExtValue*))pe->fun1)(object,&v);
-	return v;
-	}
-else
-	{
-	void *target=getTarget(i);
-	return *((ExtValue*)target);
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->fun1)
+	{
+		(*(void(*)(void*, ExtValue*))pe->fun1)(object, &v);
+		return v;
+	}
+	else
+	{
+		void *target = getTarget(i);
+		return *((ExtValue*)target);
 	}
 }
@@ -647,313 +649,311 @@
 //////// set
 
-int SimpleAbstractParam::setInt(int i,long x)
-{
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->flags&PARAM_READONLY) return PSET_RONLY;
-long xcopy=x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
-long a=0,b=0;
-int result=0;
-const char* t=pe->type+1;
-while(*t) if (*t==' ') break; else t++;
-if (sscanf(t,"%ld %ld",&a,&b)==2)
-	if (a<=b) // jezeli max<min to znaczy ze min/max nie obowiazuje
-		{
-		if (x<a) {x=a; result=PSET_HITMIN;}
-		else if (x>b) {x=b; result=PSET_HITMAX;}
-		}
-
-if (pe->fun2)
-	{
-	v.setInt(x);
-	result |= (*(int(*)(void*,const ExtValue*))pe->fun2)(object,&v);
-	}
-else
-	{
-	void *target=getTarget(i);
-	if (dontcheckchanges || (*((long*)target)!=x))
+int SimpleAbstractParam::setInt(int i, long x)
+{
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->flags&PARAM_READONLY) return PSET_RONLY;
+	long xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
+	long a = 0, b = 0;
+	int result = 0;
+	const char* t = pe->type + 1;
+	while (*t) if (*t == ' ') break; else t++;
+	if (sscanf(t, "%ld %ld", &a, &b) == 2)
+		if (a <= b) // if max<min then the min/max constraint check is not supported
+		{
+			if (x<a) { x = a; result = PSET_HITMIN; }
+			else if (x>b) { x = b; result = PSET_HITMAX; }
+		}
+
+	if (pe->fun2)
+	{
+		v.setInt(x);
+		result |= (*(int(*)(void*, const ExtValue*))pe->fun2)(object, &v);
+	}
+	else
+	{
+		void *target = getTarget(i);
+		if (dontcheckchanges || (*((long*)target) != x))
+		{
+			result |= PSET_CHANGED;
+			*((long*)target) = x;
+		}
+	}
+	messageOnExceedRange(i, result, xcopy);
+	return result;
+}
+
+int SimpleAbstractParam::setDouble(int i, double x)
+{
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->flags&PARAM_READONLY) return PSET_RONLY;
+	double xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
+	double a = 0, b = 0;
+	int result = 0;
+	const char* t = pe->type + 1;
+	while (*t) if (*t == ' ') break; else t++;
+	if (sscanf(t, "%lg %lg", &a, &b) == 2)
+		if (a <= b) // if max<min then the min/max constraint check is not supported
+		{
+			if (x<a) { x = a; result = PSET_HITMIN; }
+			else if (x>b) { x = b; result = PSET_HITMAX; }
+		}
+
+	if (pe->fun2)
+	{
+		v.setDouble(x);
+		result |= (*(int(*)(void*, const ExtValue*))pe->fun2)(object, &v);
+	}
+	else
+	{
+		void *target = getTarget(i);
+		if (dontcheckchanges || (*((double*)target) != x))
+		{
+			result |= PSET_CHANGED;
+			*((double*)target) = x;
+		}
+	}
+	messageOnExceedRange(i, result, xcopy);
+	return result;
+}
+
+int SimpleAbstractParam::setString(int i, const SString& x)
+{
+	ExtValue v;
+	SString vs;
+	const SString *xx = &x;
+	ParamEntry *pe = entry(i);
+	if (pe->flags&PARAM_READONLY) return PSET_RONLY;
+	SString xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
+	const char* t = pe->type + 1;
+	while (*t) if (*t == ' ') break; else t++;
+	long a = 0, b = 0;
+	int result = 0;
+	if (sscanf(t, "%ld %ld", &a, &b) == 2)
+	{
+		if ((x.len() > b) && (b > 0))
+		{
+			vs = x.substr(0, b);
+			xx = &vs;
+			result |= PSET_HITMAX;
+		}
+	}
+
+	if (pe->fun2)
+	{
+		v.setString(*xx);
+		result |= (*(int(*)(void*, const ExtValue*))pe->fun2)(object, &v);
+	}
+	else
+	{
+		void *target = getTarget(i);
+		if (dontcheckchanges || (!(*((SString*)target) == *xx)))
+		{
+			result |= PSET_CHANGED;
+			*((SString*)target) = x;
+		}
+	}
+	messageOnExceedRange(i, result, xcopy);
+	return result;
+}
+
+int SimpleAbstractParam::setObject(int i, const ExtObject& x)
+{
+	ExtValue v;
+	ParamEntry *pe = entry(i);
+	if (pe->flags&PARAM_READONLY) return PSET_RONLY;
+	ExtObject xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
+	if (pe->fun2)
+	{
+		v.setObject(x);
+		int result = (*(int(*)(void*, const ExtValue*))pe->fun2)(object, &v);
+		messageOnExceedRange(i, result, xcopy);
+		return result;
+	}
+	else
+	{
+		void *target = getTarget(i);
+		*((ExtObject*)target) = x;
+		return PSET_CHANGED;
+	}
+}
+
+int SimpleAbstractParam::setExtValue(int i, const ExtValue& x)
+{
+	ParamEntry *pe = entry(i);
+	if (pe->flags&PARAM_READONLY) return PSET_RONLY;
+	ExtValue xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
+	if (pe->fun2)
+	{
+		int result = (*(int(*)(void*, const ExtValue*))pe->fun2)(object, &x);
+		messageOnExceedRange(i, result, xcopy);
+		return result;
+	}
+	else
+	{
+		void *target = getTarget(i);
+		*((ExtValue*)target) = x;
+		return PSET_CHANGED;
+	}
+}
+
+void SimpleAbstractParam::call(int i, ExtValue *args, ExtValue *ret)
+{
+	ParamEntry *pe = entry(i);
+	if (!pe) return;
+	if (pe->fun1 && (pe->type[0] == 'p'))
+		(*(void(*)(void*, ExtValue*, ExtValue*))pe->fun1)(object, args, ret);
+	else
+	{
+		FMprintf("SimpleAbstractParam", "call", FMLV_ERROR,
+			(*pe->type != 'p') ? "'%s.%s' is not a function" : "Internal error - undefined function pointer for '%s.%s'", getName(), pe->id);
+	}
+}
+
+void SimpleAbstractParam::setDefault(bool numericonly)
+{
+	bool save = dontcheckchanges;
+	dontcheckchanges = 1;
+	ParamInterface::setDefault(numericonly);
+	dontcheckchanges = save;
+}
+
+void SimpleAbstractParam::setDefault(int i, bool numericonly)
+{
+	bool save = dontcheckchanges;
+	dontcheckchanges = 1;
+	ParamInterface::setDefault(i, numericonly);
+	dontcheckchanges = save;
+}
+
+// Returns the address of the beginning of the line.
+// len = line length (without \n).
+// 0 may mean the line with length=0 or the end of the SString.
+// poz is advanced to the beginning of the next line.
+// A typical loop: for(poz=0;poz<s.d;) {line=getline(s,poz,len);...
+static const char *getline(const SString &s, int &poz, int &len)
+{
+	const char *beg = (const char*)s + poz;
+	if (poz >= s.len()) { poz = s.len(); len = 0; return (const char*)s + s.len(); }
+	const char *lf = strchr(beg, '\n');
+	if (!lf) { lf = (const char*)s + s.len() - 1; poz = s.len(); }
+	else { poz = (lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }
+	while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break;
+	len = lf - beg + 1;
+	return beg;
+}
+
+int ParamInterface::load2(const SString &s, int &poz)
+{
+	int i; // the index number of the parameter
+	int tmpi;
+	int len;
+	int ret;
+	int fields_loaded = 0;
+	const char *t, *lin, *end;
+	const char *equals_sign, *comma_sign;
+	char remember;
+	const char *quote, *quote2;
+	const char *value, *valstop;
+	SString tmpvalue;
+	if (poz >= s.len()) return fields_loaded;
+	t = (const char*)s + poz;
+
+	lin = getline(s, poz, len); // all fields must be encoded in a single line
+	if (!len) return fields_loaded; // empty line = end
+	i = 0;
+	end = lin + len;
+	while (t < end)
+	{
+		// processing a single field
+		while (strchr(" \n\r\t", *t)) if (t<end) t++; else return fields_loaded;
+
+		comma_sign = strchrlimit(t, ',', end); if (!comma_sign) comma_sign = end;
+		quote = strchrlimit(t, '\"', comma_sign);
+		if (quote)
+		{
+			quote2 = skipQuoteString(quote + 1, end);
+			if (quote2>comma_sign)
 			{
-			result |= PSET_CHANGED;
-			*((long*)target)=x;
+				comma_sign = strchrlimit(quote2 + 1, ',', end);
+				if (!comma_sign) comma_sign = end;
 			}
-	}
-    messageOnExceedRange(i,result,xcopy);
-	return result;
-}
-
-int SimpleAbstractParam::setDouble(int i,double x)
-{
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->flags&PARAM_READONLY) return PSET_RONLY;
-double xcopy=x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
-double a=0,b=0;
-int result=0;
-const char* t=pe->type+1;
-while(*t) if (*t==' ') break; else t++;
-if (sscanf(t,"%lg %lg",&a,&b)==2)
-	if (a<=b) // jezeli max<min to znaczy ze min/max nie obowiazuje
-		{
-		if (x<a) {x=a; result=PSET_HITMIN;}
-		else if (x>b) {x=b; result=PSET_HITMAX;}
-		}
-
-if (pe->fun2)
-	{
-	v.setDouble(x);
-	result |= (*(int(*)(void*,const ExtValue*))pe->fun2)(object,&v);
-	}
-else
-	{
-	void *target=getTarget(i);
-	if (dontcheckchanges || (*((double*)target)!=x))
-		{
-		result|=PSET_CHANGED;
-		*((double*)target)=x;
-		}
-	}
-    messageOnExceedRange(i,result,xcopy);
-	return result;
-}
-
-int SimpleAbstractParam::setString(int i,const SString& x)
-{
-ExtValue v;
-SString vs;
-const SString *xx=&x;
-ParamEntry *pe=entry(i);
-if (pe->flags&PARAM_READONLY) return PSET_RONLY;
-SString xcopy=x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
-const char* t=pe->type+1;
-while(*t) if (*t==' ') break; else t++;
-long a=0,b=0;
-int result=0;
-if (sscanf(t,"%ld %ld",&a,&b)==2)
-	{
-	if ((x.len()>b)&&(b>0))
-		{
-		vs=x.substr(0,b);
-		xx=&vs;
-		result|=PSET_HITMAX;
-		}
-	}
-
-if (pe->fun2)
-	{
-	v.setString(*xx);
-	result |= (*(int(*)(void*,const ExtValue*))pe->fun2)(object,&v);
-	}
-else
-	{
-	void *target=getTarget(i);
-	if (dontcheckchanges || (!(*((SString*)target) == *xx)))
-		{
-		result|=PSET_CHANGED;
-		*((SString*)target)=x;
-		}
-	}
-    messageOnExceedRange(i,result,xcopy);
-	return result;
-}
-
-int SimpleAbstractParam::setObject(int i,const ExtObject& x)
-{
-ExtValue v;
-ParamEntry *pe=entry(i);
-if (pe->flags&PARAM_READONLY) return PSET_RONLY;
-ExtObject xcopy=x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
-if (pe->fun2)
-	{
-	v.setObject(x);
-	int result=(*(int(*)(void*,const ExtValue*))pe->fun2)(object,&v);
-    messageOnExceedRange(i,result,xcopy);
-    return result;
-	}
-else
-	{
-	void *target=getTarget(i);
-	*((ExtObject*)target)=x;
-	return PSET_CHANGED;
-	}
-}
-
-int SimpleAbstractParam::setExtValue(int i,const ExtValue& x)
-{
-ParamEntry *pe=entry(i);
-if (pe->flags&PARAM_READONLY) return PSET_RONLY;
-ExtValue xcopy=x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
-if (pe->fun2)
-	{
-	int result=(*(int(*)(void*,const ExtValue*))pe->fun2)(object,&x);
-    messageOnExceedRange(i,result,xcopy);
-    return result;
-	}
-else
-	{
-	void *target=getTarget(i);
-	*((ExtValue*)target)=x;
-	return PSET_CHANGED;
-	}
-}
-
-void SimpleAbstractParam::call(int i,ExtValue *args,ExtValue *ret)
-{
-ParamEntry *pe=entry(i);
-if (!pe) return;
-if (pe->fun1 && (pe->type[0]=='p'))
-	(*(void(*)(void*,ExtValue*,ExtValue*))pe->fun1)(object,args,ret);
-else
-	{
-	FMprintf("SimpleAbstractParam","call",FMLV_ERROR,
-		 (*pe->type!='p')?"'%s.%s' is not a function":"Internal error - undefined function pointer for '%s.%s'",getName(),pe->id);
-	}
-}
-
-void SimpleAbstractParam::setDefault(bool numericonly)
-{
-bool save=dontcheckchanges;
-dontcheckchanges=1;
-ParamInterface::setDefault(numericonly);
-dontcheckchanges=save;
-}
-
-void SimpleAbstractParam::setDefault(int i,bool numericonly)
-{
-bool save=dontcheckchanges;
-dontcheckchanges=1;
-ParamInterface::setDefault(i,numericonly);
-dontcheckchanges=save;
-}
-
-// zwraca adres poczatku linii
-// len = dlugosc linii (bez \n)
-// 0 moze oznaczac linie dlugosci 0 lub koniec SStringa
-// poz jest przesuwane na poczatek nastepnej linii
-// typowa petla: for(poz=0;poz<s.d;) {line=getline(s,poz,len);...
-static const char *getline(const SString &s,int &poz,int &len)
-{
-const char *beg=(const char*)s+poz;
-if (poz>=s.len()) {poz=s.len(); len=0; return (const char*)s+s.len();}
-const char *lf=strchr(beg,'\n');
-if (!lf) { lf=(const char*)s+s.len()-1; poz=s.len(); }
-else {poz=(lf-(const char*)s)+1; if (poz>s.len()) poz=s.len();}
-while (lf>=beg) if ((*lf=='\n')||(*lf=='\r')) lf--; else break;
-len=lf-beg+1;
-return beg;
-}
-
-int ParamInterface::load2(const SString &s,int &poz)
-{
-int i; // numer akt. parametru
-int tmpi;
-int len;
-int ret;
-int fields_loaded=0;
-const char *t,*lin,*end;
-const char *rownasie,*przecinek;
-char remember;
-const char *quote,*quote2;
-const char *value,*valstop;
-SString tmpvalue;
-if (poz>=s.len()) return fields_loaded;
-t=(const char*)s+poz;
-
-// na razie wszystko musi byc w jednej linii...
-lin=getline(s,poz,len);
-if (!len) return fields_loaded; // pusta linia = koniec
-i=0;
-end=lin+len;
-while(t<end)
-{
-// przetwarzanie jednego par
-while (strchr(" \n\r\t",*t)) if (t<end) t++; else return fields_loaded;
-
-przecinek=strchrlimit(t,',',end); if (!przecinek) przecinek=end;
-quote=strchrlimit(t,'\"',przecinek);
-if (quote)
-	{
-	quote2=skipQuoteString(quote+1,end);
-	if (quote2>przecinek)
-		{
-		przecinek=strchrlimit(quote2+1,',',end);
-		if (!przecinek) przecinek=end;
-		}
-	rownasie=strchrlimit(t,'=',quote);
-	}
-else
-	{
-	rownasie=strchrlimit(t,'=',przecinek);
-	quote2=0;
-	}
-if (rownasie==t) { t++; rownasie=0; }
-if (przecinek==t)	// skip empty value
-	{
-	t++; i++;
-	continue;
-	}
-if (rownasie) // have parameter name
-	{
-	tmpi=findIdn(t,rownasie-t);
-	i=tmpi;
-	if (tmpi<0)
-		FMprintf("Param","load2",FMLV_WARN,"Unknown property name for '%s' (ignored)",getName());
-	t=rownasie+1; // t=value
-	}
+			equals_sign = strchrlimit(t, '=', quote);
+		}
+		else
+		{
+			equals_sign = strchrlimit(t, '=', comma_sign);
+			quote2 = 0;
+		}
+		if (equals_sign == t) { t++; equals_sign = 0; }
+		if (comma_sign == t)	// skip empty value
+		{
+			t++; i++;
+			continue;
+		}
+		if (equals_sign) // have parameter name
+		{
+			tmpi = findIdn(t, equals_sign - t);
+			i = tmpi;
+			if (tmpi < 0)
+				FMprintf("Param", "load2", FMLV_WARN, "Unknown property name for '%s' (ignored)", getName());
+			t = equals_sign + 1; // t=value
+		}
 #ifdef WARN_MISSING_NAME
-else
+		else
 #ifdef SAVE_SELECTED_NAMES
-if (!(flags(i)&PARAM_CANOMITNAME))
+			if (!(flags(i)&PARAM_CANOMITNAME))
 #endif
-	{
-	FMprintf("Param","load2",FMLV_WARN,"Missing property name in '%s' (assuming '%s')",
-		 getName(),id(i)?id(i):"unknown property?");
-	}
+			{
+				FMprintf("Param", "load2", FMLV_WARN, "Missing property name in '%s' (assuming '%s')",
+					getName(), id(i) ? id(i) : "unknown property?");
+			}
 #endif
-if ((i>=0)&&id(i))
-	{
-	value=t;
-	if (quote)
-		{
-		tmpvalue.copyFrom(quote+1,quote2-quote-1);
-		sstringUnquote(tmpvalue);
-		value=tmpvalue;
-		valstop=quote2;
-		}
-	else
-		if (przecinek<end) valstop=przecinek; else valstop=end;
-
-	remember=*valstop;
-	*(char*)valstop=0;
-	ret=set(i,value);
-	fields_loaded++;
-	if (ret&(PSET_HITMAX|PSET_HITMIN))
-		FMprintf("Param","load2",FMLV_WARN,"Adjusted '%s' in '%s' (was too %s)",
-			id(i),getName(),(ret&PSET_HITMAX)?"big":"small");
-	*(char*)valstop=remember;
-	}
-
-if (i>=0) i++;
+		if ((i >= 0) && id(i))
+		{
+			value = t;
+			if (quote)
+			{
+				tmpvalue.copyFrom(quote + 1, quote2 - quote - 1);
+				sstringUnquote(tmpvalue);
+				value = tmpvalue;
+				valstop = quote2;
+			}
+			else
+				if (comma_sign < end) valstop = comma_sign; else valstop = end;
+
+			remember = *valstop;
+			*(char*)valstop = 0;
+			ret = set(i, value);
+			fields_loaded++;
+			if (ret&(PSET_HITMAX | PSET_HITMIN))
+				FMprintf("Param", "load2", FMLV_WARN, "Adjusted '%s' in '%s' (was too %s)",
+				id(i), getName(), (ret&PSET_HITMAX) ? "big" : "small");
+			*(char*)valstop = remember;
+		}
+
+		if (i >= 0) i++;
 #ifdef __CODEGUARD__ 
-if (przecinek<end-1) t=przecinek+1; else return fields_loaded;
+		if (comma_sign<end-1) t=comma_sign+1; else return fields_loaded;
 #else
-t=przecinek+1;
+		t = comma_sign + 1;
 #endif
-}
-return fields_loaded;
-}
-
-int Param::grmember(int g,int a)
-{
-if ((getGroupCount()<2)&&(!g))
-	return (a<getPropCount())?a:-9999;
-
-ParamEntry *e=entry(0);
-int x=0,i=0;
-for (;e->id;i++,e++)
-	{
-	if (e->group==g) 
-		if (a==x) return i; else x++;
-	}
-return -9999;
-}
-
+	}
+	return fields_loaded;
+}
+
+int Param::grmember(int g, int a)
+{
+	if ((getGroupCount() < 2) && (!g))
+		return (a < getPropCount()) ? a : -9999;
+
+	ParamEntry *e = entry(0);
+	int x = 0, i = 0;
+	for (; e->id; i++, e++)
+	{
+		if (e->group == g)
+			if (a == x) return i; else x++;
+	}
+	return -9999;
+}
Index: /cpp/frams/param/param.h
===================================================================
--- /cpp/frams/param/param.h	(revision 153)
+++ /cpp/frams/param/param.h	(revision 154)
@@ -33,19 +33,18 @@
 #define PARAM_DEPRECATED	8192
 
-// wynik z param::set() to kombinacja bitow:
-
+// the result of param::set() is a combination of bits:
+
+// read-only: cannot modify
 #define PSET_RONLY	1
-// oznacza,ze nie mozna zmienic
-
+
+// value has been modified
 #define PSET_CHANGED	2
-// zaawansowane: wartosc zostala zmieniona
-
+
+//value has been adjusted because it tried to exceed min or max
 #define PSET_HITMIN	4
 #define PSET_HITMAX	8
-// wartosc zostala dopasowana do min lub max
-
+
+// useful combination: need to get and display the value so that a user knows that the value they tried to set has been rejected or changed
 #define PSET_WARN (PSET_RONLY | PSET_HITMIN | PSET_HITMAX)
-// pozyteczna kombinacja - oznacza, ze nalezy pobrac i wyswietlic
-// wartosc, zeby uzytkownik wiedzial, ze jego propozycja jest odrzucona
 
 #define PSET_NOPROPERTY	16
@@ -57,105 +56,105 @@
 {
 public:
-virtual int getGroupCount()=0; ///< @return number of property groups
-virtual int getPropCount()=0; ///< @return number of properties
-
-virtual const char* getName()=0;
-virtual const char* getDescription() {return 0;}
-virtual ParamEntry *getParamTab() const {return NULL;}
-
-int findId(const char *n);	///< find id number for internal name
-int findIdn(const char *naz,int n);
-
-virtual const char *id(int i)=0;	///< get internal name
-virtual const char *name(int i)=0;	///< get human readable name
-
-/** get type description.
-    first character defines basic datatype:
-    - d = integer
-    - f = floating point
-    - s = string
-    - o = ExtObject
-    - x = ExtValue (universal datatype)
- */
-virtual const char *type(int i)=0;	
-
-virtual const char *help(int i)=0;	///< get long description (tooltip)
-
-virtual int flags(int i)=0;		///< get flags
-
-virtual int group(int i)=0;		///< get group id for a property
-virtual const char *grname(int gi)=0;	///< get group name
-virtual int grmember(int gi,int n)=0;	///< get property id for n'th member of group "gi"
-
-virtual void call(int i,ExtValue* args,ExtValue *ret)=0;
-
-void get(int,ExtValue &retval);	///< most universal get, can be used for every datatype
-
-virtual SString getString(int)=0;	///< get string value, you can only use this for "s" type property
-virtual long getInt(int)=0;	///< get long value, you can only use this for "d" type property
-virtual double getDouble(int)=0;	///< get double value, you can only use this for "f" type property
-virtual ExtObject getObject(int)=0;	///< get object reference, you can only use this for "o" type property
-virtual ExtValue getExtValue(int)=0;	///< get extvalue object, you can only use this for "x" type property
-
-SString get(int);		///< old style get, can convert long or double to string
-SString getText(int);		///< like getString, returns enumeration label for subtype "d 0 n ~enum1~enum2...
-
-SString getStringById(const char*prop);  ///< get string value, you can only use this for "s" type property
-long getIntById(const char* prop);    ///< get long value, you can only use this for "d" type property
-double getDoubleById(const char* prop);///< get double value, you can only use this for "f" type property
-ExtObject getObjectById(const char* prop);///< get object reference, you can only use this for "o" type property
-ExtValue getExtValueById(const char* prop);///< get extvalue object, you can only use this for "x" type property
-ExtValue getById(const char* prop);
-
-int setInt(int i,const char* str);
-int setDouble(int i,const char* str);
-virtual int setInt(int,long)=0;		///< set long value, you can only use this for "d" type prop
-virtual int setDouble(int,double)=0;	///< set double value, you can only use this for "f" type prop
-virtual int setString(int,const SString &)=0; 	///< set string value, you can only use this for "s" type prop
-virtual int setObject(int,const ExtObject &)=0; 	///< set object reference, you can only use this for "o" type prop
-virtual int setExtValue(int,const ExtValue &)=0;	///< 4 in 1
-
-int set(int,const ExtValue &);///< most universal set, can be used for every datatype
-
-int set(int,const char*);		///< oldstyle set, can convert string to long or double
-
-int setIntById(const char* prop,long);///< set long value, you can only use this for "d" type prop
-int setDoubleById(const char* prop,double);///< set double value, you can only use this for "f" type prop
-int setStringById(const char* prop,const SString &);///< set string value, you can only use this for "s" type prop
-int setObjectById(const char* prop,const ExtObject &);///< set object reference, you can only use this for "o" type prop
-int setExtValueById(const char* prop,const ExtValue &);	///< for ExtValue types only
-int setById(const char* prop,const ExtValue &);///< can be used for all property types
-
-/** get valid minimum, maximum and default value for property 'prop'
-    @return 0 if min/max/def information is not available */
-int getMinMax(int prop,long& minumum,long& maximum,long& def);
-/** get valid minimum, maximum and default value for property 'prop'
-    @return 0 if min/max/def information is not available */
-int getMinMax(int prop,double& minumum,double& maximum,double& def);
-
-virtual void setDefault(bool numericonly=false);
-virtual void setDefault(int i,bool numericonly=false);
-void setMin();
-void setMax();
-void setMin(int i);
-void setMax(int i);
-
-/** copy all property values from other ParamInterface object */
-void copyFrom(ParamInterface *src);
-
-/** copy all property values from compatible ParamInterface object.
-    this method is more efficient than copyFrom,
-    but can be used only if the other object has the same properties sequence, eg:
-    - any two Param objects having common paramtab
-    - any ParamInterface object and the Param with paramtab constructed by ParamObject::makeParamTab
- */
-void quickCopyFrom(ParamInterface *src);
-
-int save(VirtFILE*,const char* altname=NULL,bool force=0);
-int saveprop(VirtFILE*,int i,const char* p,bool force=0);
-int load(VirtFILE*);///< @return number of fields loaded
-int load2(const SString &,int &);///< @return number of fields loaded
-
-static const char* SERIALIZATION_PREFIX;
+	virtual int getGroupCount() = 0; ///< @return the number of property groups
+	virtual int getPropCount() = 0; ///< @return the number of properties
+
+	virtual const char* getName() = 0;
+	virtual const char* getDescription() { return 0; }
+	virtual ParamEntry *getParamTab() const { return NULL; }
+
+	int findId(const char *n);	///< find id number for internal name
+	int findIdn(const char *naz, int n);
+
+	virtual const char *id(int i) = 0;	///< get internal name
+	virtual const char *name(int i) = 0;	///< get the human-readable name
+
+	/** get type description.
+		first character defines basic datatype:
+		- d = integer
+		- f = floating point
+		- s = string
+		- o = ExtObject
+		- x = ExtValue (universal datatype)
+		*/
+	virtual const char *type(int i) = 0;
+
+	virtual const char *help(int i) = 0;	///< get long description (tooltip)
+
+	virtual int flags(int i) = 0;		///< get flags
+
+	virtual int group(int i) = 0;		///< get group id for a property
+	virtual const char *grname(int gi) = 0;	///< get group name
+	virtual int grmember(int gi, int n) = 0;	///< get property id for n'th member of group "gi"
+
+	virtual void call(int i, ExtValue* args, ExtValue *ret) = 0;
+
+	void get(int, ExtValue &retval);	///< most universal get, can be used for every datatype
+
+	virtual SString getString(int) = 0;	///< get string value, you can only use this for "s" type property
+	virtual long getInt(int) = 0;	///< get long value, you can only use this for "d" type property
+	virtual double getDouble(int) = 0;	///< get double value, you can only use this for "f" type property
+	virtual ExtObject getObject(int) = 0;	///< get object reference, you can only use this for "o" type property
+	virtual ExtValue getExtValue(int) = 0;	///< get extvalue object, you can only use this for "x" type property
+
+	SString get(int);		///< old style get, can convert long or double to string
+	SString getText(int);		///< like getString, returns enumeration label for subtype "d 0 n ~enum1~enum2...
+
+	SString getStringById(const char*prop);  ///< get string value, you can only use this for "s" type property
+	long getIntById(const char* prop);    ///< get long value, you can only use this for "d" type property
+	double getDoubleById(const char* prop);///< get double value, you can only use this for "f" type property
+	ExtObject getObjectById(const char* prop);///< get object reference, you can only use this for "o" type property
+	ExtValue getExtValueById(const char* prop);///< get extvalue object, you can only use this for "x" type property
+	ExtValue getById(const char* prop);
+
+	int setInt(int i, const char* str);
+	int setDouble(int i, const char* str);
+	virtual int setInt(int, long) = 0;		///< set long value, you can only use this for "d" type prop
+	virtual int setDouble(int, double) = 0;	///< set double value, you can only use this for "f" type prop
+	virtual int setString(int, const SString &) = 0; 	///< set string value, you can only use this for "s" type prop
+	virtual int setObject(int, const ExtObject &) = 0; 	///< set object reference, you can only use this for "o" type prop
+	virtual int setExtValue(int, const ExtValue &) = 0;	///< 4 in 1
+
+	int set(int, const ExtValue &);///< most universal set, can be used for every datatype
+
+	int set(int, const char*);		///< oldstyle set, can convert string to long or double
+
+	int setIntById(const char* prop, long);///< set long value, you can only use this for "d" type prop
+	int setDoubleById(const char* prop, double);///< set double value, you can only use this for "f" type prop
+	int setStringById(const char* prop, const SString &);///< set string value, you can only use this for "s" type prop
+	int setObjectById(const char* prop, const ExtObject &);///< set object reference, you can only use this for "o" type prop
+	int setExtValueById(const char* prop, const ExtValue &); ///< for ExtValue types only
+	int setById(const char* prop, const ExtValue &);///< can be used for all property types
+
+	/** get valid minimum, maximum and default value for property 'prop'
+		@return 0 if min/max/def information is not available */
+	int getMinMax(int prop, long& minumum, long& maximum, long& def);
+	/** get valid minimum, maximum and default value for property 'prop'
+		@return 0 if min/max/def information is not available */
+	int getMinMax(int prop, double& minumum, double& maximum, double& def);
+
+	virtual void setDefault(bool numericonly = false);
+	virtual void setDefault(int i, bool numericonly = false);
+	void setMin();
+	void setMax();
+	void setMin(int i);
+	void setMax(int i);
+
+	/** copy all property values from other ParamInterface object */
+	void copyFrom(ParamInterface *src);
+
+	/** Copy all property values from compatible ParamInterface object.
+		This method is more efficient than copyFrom,
+		but can be used only if the other object has the same properties sequence, e.g.:
+		- any two Param objects having common paramtab
+		- any ParamInterface object and the Param with paramtab constructed by ParamObject::makeParamTab
+		*/
+	void quickCopyFrom(ParamInterface *src);
+
+	int save(VirtFILE*, const char* altname = NULL, bool force = 0);
+	int saveprop(VirtFILE*, int i, const char* p, bool force = 0);
+	int load(VirtFILE*);///< @return the number of fields loaded
+	int load2(const SString &, int &);///< @return the number of fields loaded
+
+	static const char* SERIALIZATION_PREFIX;
 };
 
@@ -193,109 +192,113 @@
 struct ParamEntry
 {
-const char *id;
-short group,flags;
-const char *name,*type;
-long offset;
-void *fun1; ///< procedure or get
-void *fun2; ///< set
-const char *help;
-};
-
-struct ParamEntryConstructor: public ParamEntry
+	const char *id;
+	short group, flags;
+	const char *name, *type;
+	long offset;
+	void *fun1; ///< procedure or get
+	void *fun2; ///< set
+	const char *help;
+};
+
+struct ParamEntryConstructor : public ParamEntry
 {
 public:
-ParamEntryConstructor(const char *_id,short _group=0,short _flags=0,const char *_name=0,const char *_type=0,long _offset=0,void *_fun1=0, void *_fun2=0, const char *_help=0)
-{id=_id;group=_group;flags=_flags;name=_name;type=_type;offset=_offset;fun1=_fun1;fun2=_fun2;help=_help;}
-};
-
-class SimpleAbstractParam: public virtual ParamInterface
+	ParamEntryConstructor(const char *_id, short _group = 0, short _flags = 0, const char *_name = 0, const char *_type = 0, long _offset = 0, void *_fun1 = 0, void *_fun2 = 0, const char *_help = 0)
+	{
+		id = _id; group = _group; flags = _flags; name = _name; type = _type; offset = _offset; fun1 = _fun1; fun2 = _fun2; help = _help;
+	}
+};
+
+class SimpleAbstractParam : public virtual ParamInterface
 {
 protected:
-virtual void *getTarget(int i);
-virtual ParamEntry *entry(int i)=0;
-const char* myname;
-bool dontcheckchanges;
+	virtual void *getTarget(int i);
+	virtual ParamEntry *entry(int i) = 0;
+	const char* myname;
+	bool dontcheckchanges;
 
 public:
-void *object;
-
-const char* getName() {return myname;}
-void setName(const char* n) {myname=n;}
-
-/**
-	@param t ParamEntry table
-	@param o controlled object
-	@param n Param's name
-*/
-SimpleAbstractParam(void* o=0,const char*n=0):myname(n),dontcheckchanges(0),object(o) {}
-void setDontCheckChanges(bool x) {dontcheckchanges=x;}
-
-void select(void *o) {object=o;}
-void* getSelected() {return object;}
-
-const char *id(int i) {return (i>=getPropCount())?0:entry(i)->id;}
-const char *name(int i) {return entry(i)->name;}
-const char *type(int i) {return entry(i)->type;}
-const char *help(int i) {return entry(i)->help;}
-int flags(int i) {return entry(i)->flags;}
-int group(int i) {return entry(i)->group;}
-void call(int i,ExtValue* args,ExtValue *ret);
-
-SString getString(int);
-long getInt(int);
-double getDouble(int);
-ExtObject getObject(int);
-ExtValue getExtValue(int);
-
-template<typename T> void messageOnExceedRange(int i,int setflags, T valuetoset) ///< prints a warning when setflags indicates that allowed param range has been exceeded during set
-{
-	if (setflags & (PSET_HITMIN | PSET_HITMAX))
-    {
-        SString svaluetoset=SString::valueOf(valuetoset); //converts any type to SString
-    	SString actual=get(i);
-		FMprintf("Param","set",FMLV_WARN,"Setting '%s.%s = %s' exceeded allowed range (too %s). Adjusted to %s.",
-				 getName(),id(i),(const char*)svaluetoset,(setflags&PSET_HITMAX)?"big":"small",(const char*)actual);
-    }
-}                          
-
-int setInt(int,long);
-int setDouble(int,double);
-int setString(int,const SString &);
-int setObject(int,const ExtObject &);
-int setExtValue(int,const ExtValue &);
-
-int isequal(int i,void* defdata);
-void save2(SString&,void *defdata,bool addcr=true,bool all_names=true);
-
-virtual void setDefault(bool numericonly=false);
-virtual void setDefault(int i,bool numericonly=false);
-};
-
-class Param: public SimpleAbstractParam
+	void *object;
+
+	const char* getName() { return myname; }
+	void setName(const char* n) { myname = n; }
+
+	/**
+		@param t ParamEntry table
+		@param o controlled object
+		@param n Param's name
+		*/
+	SimpleAbstractParam(void* o = 0, const char*n = 0) :myname(n), dontcheckchanges(0), object(o) {}
+	void setDontCheckChanges(bool x) { dontcheckchanges = x; }
+
+	void select(void *o) { object = o; }
+	void* getSelected() { return object; }
+
+	const char *id(int i) { return (i >= getPropCount()) ? 0 : entry(i)->id; }
+	const char *name(int i) { return entry(i)->name; }
+	const char *type(int i) { return entry(i)->type; }
+	const char *help(int i) { return entry(i)->help; }
+	int flags(int i) { return entry(i)->flags; }
+	int group(int i) { return entry(i)->group; }
+	void call(int i, ExtValue* args, ExtValue *ret);
+
+	SString getString(int);
+	long getInt(int);
+	double getDouble(int);
+	ExtObject getObject(int);
+	ExtValue getExtValue(int);
+
+	template<typename T> void messageOnExceedRange(int i, int setflags, T valuetoset) ///< prints a warning when setflags indicates that allowed param range has been exceeded during set
+	{
+		if (setflags & (PSET_HITMIN | PSET_HITMAX))
+		{
+			SString svaluetoset = SString::valueOf(valuetoset); //converts any type to SString
+			SString actual = get(i);
+			FMprintf("Param", "set", FMLV_WARN, "Setting '%s.%s = %s' exceeded allowed range (too %s). Adjusted to %s.",
+				getName(), id(i), (const char*)svaluetoset, (setflags&PSET_HITMAX) ? "big" : "small", (const char*)actual);
+		}
+	}
+
+	int setInt(int, long);
+	int setDouble(int, double);
+	int setString(int, const SString &);
+	int setObject(int, const ExtObject &);
+	int setExtValue(int, const ExtValue &);
+
+	int isequal(int i, void* defdata);
+	void save2(SString&, void *defdata, bool addcr = true, bool all_names = true);
+
+	virtual void setDefault(bool numericonly = false);
+	virtual void setDefault(int i, bool numericonly = false);
+};
+
+class Param : public SimpleAbstractParam
 {
 protected:
-ParamEntry *entry(int i) {return tab+tab[0].group+i;}
+	ParamEntry *entry(int i) { return tab + tab[0].group + i; }
 public:
-ParamEntry *tab;
-/**
-	@param t ParamEntry table
-	@param o controlled object
-	@param n Param's name
-*/
-
-Param(ParamEntry *t=0,void* o=0,const char*n=0):SimpleAbstractParam(o,n),tab(t)
-{if (!n&&tab) myname=tab[0].name;}
-
-Param(const Param& p):SimpleAbstractParam(p.object,p.myname),tab(p.tab) {}
-void operator=(const Param&p) {object=p.object; myname=p.myname; tab=p.tab;}
-
-const char* getDescription() {return tab[0].type;}
-
-int getGroupCount() {return tab[0].group;}
-int getPropCount() {return tab[0].flags;}
-const char *grname(int i) {return (i<getGroupCount())?tab[i].id:0;}
-int grmember(int,int);
-void setParamTab(ParamEntry *t,int dontupdatename=0) {tab=t; if ((!dontupdatename)&&tab) myname=tab[0].name; }
-ParamEntry *getParamTab() const {return tab;}
+	ParamEntry *tab;
+	/**
+		@param t ParamEntry table
+		@param o controlled object
+		@param n Param's name
+		*/
+
+	Param(ParamEntry *t = 0, void* o = 0, const char*n = 0) :SimpleAbstractParam(o, n), tab(t)
+	{
+		if (!n&&tab) myname = tab[0].name;
+	}
+
+	Param(const Param& p) :SimpleAbstractParam(p.object, p.myname), tab(p.tab) {}
+	void operator=(const Param&p) { object = p.object; myname = p.myname; tab = p.tab; }
+
+	const char* getDescription() { return tab[0].type; }
+
+	int getGroupCount() { return tab[0].group; }
+	int getPropCount() { return tab[0].flags; }
+	const char *grname(int i) { return (i < getGroupCount()) ? tab[i].id : 0; }
+	int grmember(int, int);
+	void setParamTab(ParamEntry *t, int dontupdatename = 0) { tab = t; if ((!dontupdatename) && tab) myname = tab[0].name; }
+	ParamEntry *getParamTab() const { return tab; }
 };
 
Index: /cpp/frams/util/rndutil.cpp
===================================================================
--- /cpp/frams/util/rndutil.cpp	(revision 153)
+++ /cpp/frams/util/rndutil.cpp	(revision 154)
@@ -9,39 +9,41 @@
 unsigned short pseudornd(short x)
 {
-static long seed=0;
-long y;
-if (x<=0) {seed=-x; return 0;}
-seed=(y=(3677*seed+3680)&0x7fffffff)-1;
-return (unsigned short)(((unsigned short)y)%(x));//rzutowanie y->unsigned short to pewnie blad bo zmniejsza wartosc ktorej sie potem robi modulo, ale pseudornd sluzy chyba tylko do generowania randomowych world map? i modulo i tak jest tam bardzo male, lepiej niczego nie zmieniac bo po co maja pliki z ustawieniami zmienic swoje przypadkowe znaczenie
+	static long seed = 0;
+	long y;
+	if (x <= 0) { seed = -x; return 0; }
+	seed = (y = (3677 * seed + 3680) & 0x7fffffff) - 1;
+	return (unsigned short)(((unsigned short)y) % (x)); //rzutowanie y->unsigned short to pewnie blad bo zmniejsza wartosc ktorej sie potem robi modulo, ale pseudornd sluzy chyba tylko do generowania randomowych world map? i modulo i tak jest tam bardzo male, lepiej niczego nie zmieniac bo po co maja pliki z ustawieniami zmienic swoje przypadkowe znaczenie
 }
 
 double CustomRnd(double *tab)
 {
-double *range=tab+1+2*randomN((int)(0.5+tab[0]));
-return range[0]+rnd0N(range[1]-range[0]);
+	double *range = tab + 1 + 2 * randomN((int)(0.5 + tab[0]));
+	return range[0] + rnd0N(range[1] - range[0]);
 }
 
 double RandomGener::Uni(double begin, double end)
 {
-return begin+rnd01*(end-begin);
+	return begin + rnd01*(end - begin);
 }
 
 double RandomGener::GaussStd()
 {
-if (isNextGauss) {isNextGauss=0; return nextGauss;}
-double v1,v2,s;
-do {
-v1=2*rnd01-1; //-1..1
-v2=2*rnd01-1; //-1..1
-s=v1*v1+v2*v2;
-} while (s>=1);
-double mult=sqrt(-2*log(s)/s);
-nextGauss=v2*mult;
-isNextGauss=1;
-return v1*mult;
+	if (isNextGauss) { isNextGauss = 0; return nextGauss; }
+	double v1, v2, s;
+	do {
+		v1 = 2 * rnd01 - 1; //-1..1
+		v2 = 2 * rnd01 - 1; //-1..1
+		s = v1*v1 + v2*v2;
+	} while (s >= 1);
+	double mult = sqrt(-2 * log(s) / s);
+	nextGauss = v2*mult;
+	isNextGauss = 1;
+	return v1*mult;
 }
 
-double RandomGener::Gauss(double m,double s)
-{return m+s*GaussStd();}
+double RandomGener::Gauss(double m, double s)
+{
+	return m + s*GaussStd();
+}
 
 RandomGener RndGen;
