ensiform Posted September 11, 2005 Share Posted September 11, 2005 char * QDECL va2( char *format, ... ) { va_list argptr; #define MAX_VA_STRING 32000 static char temp_buffer[MAX_VA_STRING]; static char string[MAX_VA_STRING]; // in case va is called by nested functions static int index = 0; char *buf; int len; va_start (argptr, format); vsprintf (temp_buffer, format,argptr); va_end (argptr); if ((len = strlen(temp_buffer)) >= MAX_VA_STRING) { Com_Error( ERR_DROP, "Attempted to overrun string in call to va2()\n" ); } if (len + index >= MAX_VA_STRING-1) { index = 0; } buf = &string[index]; memcpy( buf, temp_buffer, len+1 ); index += len + 1; return buf; } modified this to be a circular list, to further prevent stepping on/using previous strings dont overwrite the va in q_shared.c as its used by the engine and u cannot modify it Link to comment Share on other sites More sharing options...
Tinny Posted September 11, 2005 Share Posted September 11, 2005 Thanks dude, have you noticed any problem's its fixed? Link to comment Share on other sites More sharing options...
ensiform Posted September 13, 2005 Author Share Posted September 13, 2005 haven't actually used it in q3, but it seems fine in q3. i wouldnt exactly go around replacing all instances of va( ... ) to va2( ... ) though. Link to comment Share on other sites More sharing options...
stubert Posted September 14, 2005 Share Posted September 14, 2005 i invented a better wheel yesteday soon i'll be famous Link to comment Share on other sites More sharing options...
Astelraid Posted September 14, 2005 Share Posted September 14, 2005 its probrably stupid question but what is it for? Link to comment Share on other sites More sharing options...
razorace Posted September 14, 2005 Share Posted September 14, 2005 va is used as a general string parser for JKA. It's mainly for adding variable values to strings. For example, you'd use va to make the following.... "I have 10 health remaining!" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.