From 64444d7479d095032ed55113f334d4b2e7e3a62d Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 30 Nov 2005 00:47:59 +0000 Subject: [PATCH] Added support for printing hex (heheh... doesn't work right, but better than nothing) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1628 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- plugins/qvm_api.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/plugins/qvm_api.c b/plugins/qvm_api.c index 75c5123e8..1a621ca24 100644 --- a/plugins/qvm_api.c +++ b/plugins/qvm_api.c @@ -88,7 +88,54 @@ retry: *buffer++ = _int; tokens++; break; + case 'x': + _int = va_arg(vargs, int); + if (_int < 0) + { + if (--maxlen < 0) + {*buffer++='\0';return tokens;} + *buffer++ = '-'; + _int *= -1; + } + i = sizeof(tempbuffer)-2; + tempbuffer[sizeof(tempbuffer)-1] = '\0'; + while(_int) + { + tempbuffer[i] = _int%16 + '0'; + _int/=16; + i--; + } + string = tempbuffer+i+1; + + if (!*string) + { + i=61; + string = tempbuffer+i+1; + string[0] = '0'; + string[1] = '\0'; + } + + precision -= 62-i; + while (precision>0) + { + string--; + if (use0s) + *string = '0'; + else + *string = ' '; + precision--; + } + + while (*string) + { + if (--maxlen < 0) + {*buffer++='\0';return tokens;} + *buffer++ = *string++; + } + tokens++; + break; case 'd': + case 'u': case 'i': _int = va_arg(vargs, int); if (_int < 0)