From: Anders R. <ma...@us...> - 2005-02-28 02:25:19
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21588/src/common/util Modified Files: psstring.cpp Log Message: - Fixed substituion of vars in NPC responses. - Removed unused variable lastresponce from psNPCDialog Index: psstring.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/util/psstring.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** psstring.cpp 31 Jan 2005 20:44:05 -0000 1.15 --- psstring.cpp 28 Feb 2005 02:24:38 -0000 1.16 *************** *** 43,46 **** --- 43,47 ---- while (end< (int) Length() && isdigit(Data[end])) end++; + end--; return true; *************** *** 55,79 **** size_t lensub = strlen(sub); if ( IsEmpty() || !lensub || lensub>Length() ) ! return -1; if ( caseInsense ) { ! while ( start <= Length() - lensub ) ! { ! if (strncasecmp(sub, Data + start, lensub) != 0) ! start++; ! else ! return start; ! } ! return -1; ! } ! else ! { ! char* pWhere = strstr(Data + start, sub); ! if (pWhere) ! return pWhere - Data; ! else ! return -1; ! } } --- 56,80 ---- size_t lensub = strlen(sub); if ( IsEmpty() || !lensub || lensub>Length() ) ! return -1; if ( caseInsense ) { ! while ( start <= Length() - lensub ) ! { ! if (strncasecmp(sub, Data + start, lensub) != 0) ! start++; ! else ! return start; ! } ! return -1; ! } ! else ! { ! char* pWhere = strstr(Data + start, sub); ! if (pWhere) ! return pWhere - Data; ! else ! return -1; ! } } *************** *** 81,85 **** { if ( IsEmpty() || sub.IsEmpty() || sub.Length()>Length() ) ! return -1; if ( caseInsense ) --- 82,86 ---- { if ( IsEmpty() || sub.IsEmpty() || sub.Length()>Length() ) ! return -1; if ( caseInsense ) *************** *** 92,96 **** { if ( toupper(pWhere[x]) != toupper(sub[x]) ) ! break; } if ( x < sub.Length() ) --- 93,97 ---- { if ( toupper(pWhere[x]) != toupper(sub[x]) ) ! break; } if ( x < sub.Length() ) *************** *** 111,115 **** { if ( pWhere[x] != sub[x] ) ! break; } if ( x < sub.Length() ) --- 112,116 ---- { if ( pWhere[x] != sub[x] ) ! break; } if ( x < sub.Length() ) *************** *** 124,131 **** void psString::GetSubString(psString& str, size_t from, size_t to) { ! str.Clear(); if ( from > Size || from > to ) ! return; size_t len = to-from; --- 125,132 ---- void psString::GetSubString(psString& str, size_t from, size_t to) { ! str.Clear(); if ( from > Size || from > to ) ! return; size_t len = to-from; *************** *** 140,145 **** if (pos > Size) { ! buff=""; ! return; } --- 141,146 ---- if (pos > Size) { ! buff=""; ! return; } *************** *** 148,152 **** (wantPunct || !ispunct(Data[start])) ) ! start--; if (isspace(Data[start]) || (!wantPunct && ispunct(Data[start]))) start++; --- 149,153 ---- (wantPunct || !ispunct(Data[start])) ) ! start--; if (isspace(Data[start]) || (!wantPunct && ispunct(Data[start]))) start++; *************** *** 156,160 **** (wantPunct || !ispunct(Data[end])) ) ! end++; GetSubString(buff,start,end); --- 157,161 ---- (wantPunct || !ispunct(Data[end])) ) ! end++; GetSubString(buff,start,end); *************** *** 170,174 **** { if (from >= Size || from>to) ! return; DeleteAt(from, to-from); } --- 171,175 ---- { if (from >= Size || from>to) ! return; DeleteAt(from, to-from); } *************** *** 195,207 **** int where; size_t len = strlen(what); ! if ( (where = FindSubString(what)) > -1 ) { ! size_t pos = where; ! DeleteAt(where, len); ! Insert(pos, with); ! return true; } else ! return false; } --- 196,208 ---- int where; size_t len = strlen(what); ! if ( (where = FindSubString(what,0,false)) > -1 ) { ! size_t pos = where; ! DeleteAt(where, len); ! Insert(pos, with); ! return true; } else ! return false; } *************** *** 209,219 **** { if (!Data || !other.Data) ! return 0; size_t i; for (i=0; i<Length(); i++) { ! if (Data[i] != other.Data[i]) ! return i; } return i; --- 210,220 ---- { if (!Data || !other.Data) ! return 0; size_t i; for (i=0; i<Length(); i++) { ! if (Data[i] != other.Data[i]) ! return i; } return i; |