"DP_QC_RANDOMVEC "
"DP_QC_SINCOSSQRTPOW "
//"DP_QC_STRINGBUFFERS " //[515]: not needed ?
+"DP_QC_STRINGCOLORFUNCTIONS "
"DP_QC_TRACEBOX "
//"DP_QC_TRACETOSS "
"DP_QC_TRACE_MOVETYPE_HITMODEL "
VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
-NULL, // #476
-NULL, // #477
+VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
+VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
NULL, // #478
NULL, // #479
e10, e10 // #480-499 (LordHavoc)
char *vm_m_extensions =
"DP_CINEMATIC_DPV "
-"DP_QC_ASINACOSATANATAN2TAN";
+"DP_QC_ASINACOSATANATAN2TAN "
+"DP_QC_STRINGCOLORFUNCTIONS";
/*
=========
VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
- 0,0,0,0,0, // 480
+ VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
+ VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
+ 0,0,0, // 480
e10, // 490
e10, // 500
e100, // 600
PRVM_G_FLOAT(OFS_RETURN) = 0;
}
+// DRESK - Decolorized String
+/*
+=========
+VM_strdecolorize
+
+string strdecolorize(string s)
+=========
+*/
+// string (string s) strdecolorize = #472; // returns the passed in string with color codes stripped
+void VM_strdecolorize(void)
+{
+ char *szNewString;
+ const char *szString;
+ size_t nCnt;
+ int nPos;
+ int nFillPos;
+ int bFinished;
+ nPos = 0;
+ nFillPos = 0;
+ nCnt = 0;
+ bFinished = 0;
+
+ // Prepare Strings
+ VM_SAFEPARMCOUNT(1,VM_strdecolorize);
+ szString = PRVM_G_STRING(OFS_PARM0);
+ szNewString = VM_GetTempString();
+
+ while(!bFinished)
+ { // Traverse through String
+ if( szString[nPos] == '\n' || szString[nPos] == '\r' || szString[nPos] <= 0)
+ { // String End Found
+ szNewString[nFillPos++] = szString[nPos];
+ bFinished = 1;
+ }
+ else
+ if( szString[nPos] == STRING_COLOR_TAG)
+ { // Color Code Located
+ if( szString[nPos + 1] == STRING_COLOR_TAG)
+ { // Valid Characters to Include
+ szNewString[nFillPos++] = szString[nPos];
+ nPos = nPos + 1;
+ szNewString[nFillPos++] = szString[nPos];
+ }
+ else
+ if( szString[nPos + 1] >= '0' && szString[nPos + 1] <= '9' )
+ { // Color Code Found; Increment Position
+ nPos = nPos + 1;
+ }
+ else
+ { // Unknown Color Code; Include
+ szNewString[nFillPos++] = szString[nPos];
+ nPos = nPos + 1;
+ }
+ }
+ else
+ // Include Character
+ szNewString[nFillPos++] = szString[nPos];
+
+ // Increment Position
+ nPos = nPos + 1;
+ }
+
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(szNewString);
+}
+
+// DRESK - String Length (not counting color codes)
+/*
+=========
+VM_strlennocol
+
+float strlennocol(string s)
+=========
+*/
+// float(string s) strlennocol = #471; // returns how many characters are in a string not including color codes
+// For example, ^2Dresk returns a length of 5
+void VM_strlennocol(void)
+{
+ const char *szString;
+ size_t nCnt;
+ int nPos;
+ int bFinished;
+ nPos = 0;
+ nCnt = 0;
+ bFinished = 0;
+
+ VM_SAFEPARMCOUNT(1,VM_strlennocol);
+
+ szString = PRVM_G_STRING(OFS_PARM0);
+ if(szString)
+ { // Valid String
+ while(!bFinished)
+ { // Count Characters
+ // SV_BroadcastPrintf("Position '%d'; Character '%c'; Length '%d'\n", nPos, szString[nPos], nCnt);
+
+ if( szString[nPos] == '\n' || szString[nPos] == '\r' || szString[nPos] <= 0)
+ { // String End Found
+ // SV_BroadcastPrintf("Found End of String at '%d'\n", nPos);
+ bFinished = 1;
+ }
+ else
+ if( szString[nPos] == STRING_COLOR_TAG)
+ { // Color Code Located
+ if( szString[nPos + 1] == STRING_COLOR_TAG)
+ { // Increment Length; Skip Color Code
+ nCnt = nCnt + 1;
+ nPos = nPos + 1;
+ }
+ else
+ if( szString[nPos + 1] >= '0' && szString[nPos + 1] <= '9' )
+ { // Color Code Found; Increment Position
+ // SV_BroadcastPrintf("Found Color Codes at '%d'\n", nPos);
+ nPos = nPos + 1;
+ }
+ else
+ { // Unknown Color Code; Increment Length!
+ nPos = nPos + 1;
+ nCnt = nCnt + 1;
+ }
+ }
+ else
+ // Increment String Length
+ nCnt = nCnt + 1;
+
+ // Increment Position
+ nPos = nPos + 1;
+ }
+ PRVM_G_FLOAT(OFS_RETURN) = nCnt;
+ }
+ else
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+}
+
/*
=========
VM_strcat
"DP_QC_RANDOMVEC "
"DP_QC_SINCOSSQRTPOW "
"DP_QC_STRINGBUFFERS "
+"DP_QC_STRINGCOLORFUNCTIONS "
"DP_QC_TRACEBOX "
"DP_QC_TRACETOSS "
"DP_QC_TRACE_MOVETYPE_HITMODEL "
VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
-NULL, // #476
-NULL, // #477
+VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
+VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
NULL, // #478
NULL, // #479
e10, e10 // #480-499 (LordHavoc)