Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cfsndserv bugs and fixes



I found a couple bugs in the client sound server as well, and have attached
fixes:

1) If the sound configuration file line has no spaces between the volume and
the symbolic (ie: only tabs), and if the symbolic is a multi-word string
enclosed in quotes, then the symbolic won't be stored properly.  This stems
from cfsndserv.c in line 148 where the strchr(' ') comes before the
strchr('\t').  This means that the line will be searched for spaces before it
is searched for tabs.  It will find the space in the middle of the symbolic
name before it finds the tab separator, and process it incorrectly.  Simply
switching the search order to look for a tab first fixes the problem.

2) If a sound number is not specified in the sound configuration file on the
first sound in a group, then the server incorrectly numbers the sound at 1
instead of 0.  Initializing lastnum to -1 instead of 0 fixes this problem. 
Since newnum can only ever be lastnum + 1 (when it is set by lastnum at all),
this is safe.

The attached .diff fixes both problems.  Two hours of debugging so that I
could get my magic bullet spell to sound like a bullet instead of a tinkling
bell.  Sheesh, I need to get a life. :)

        Kurt.

--- ../client-clean/cfsndserv.c	Mon Jul 12 00:20:01 1999
+++ cfsndserv.c	Mon Jan 17 04:17:05 2000
@@ -111,16 +111,16 @@
     char *cp,*volume,*symbolic,*cp1,filename[512];
 
     if (line[0]=='#' || line[0]=='\n') return;
 
     if (!strcmp(line,"Standard Sounds:\n")) {
-	lastnum=0; 
+	lastnum=-1; 
 	readtype=1;
 	return;
     }
     if (!strcmp(line,"Spell Sounds:\n")) {
-	lastnum=0; 
+	lastnum=-1; 
 	readtype=2;
 	return;
     }
     if (!readtype) {
 #ifdef SOUND_DEBUG
@@ -143,11 +143,11 @@
     
     volume=cp;
 
     /* No symbolic name or number - that is ok */
     cp1=cp;
-    if (!(cp=strchr(cp1,' ')) && !(cp=strchr(cp1,'\t'))) {
+    if (!(cp=strchr(cp1,'\t')) && !(cp=strchr(cp1,' '))) {
 	newnum=lastnum+1;
 	symbolic=NULL;
     } else {	/* We think we have a symbolic name */
 	/* Don't need to nulterm the volume, since we atoi it anyways */
 	while (*cp!='\0' && (*cp==' ' || *cp=='\t'))