From d44ebdba522eb862573988b7a4f746fd819c361e Mon Sep 17 00:00:00 2001 From: flowtron Date: Wed, 26 May 2010 20:58:19 +0000 Subject: [PATCH] usedotfracs - anti-I18L re:float git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5066 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/command.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source/src/command.cpp b/source/src/command.cpp index 62eb5f30..97a6b605 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -274,15 +274,37 @@ void intret(int v) commandret = newstring(t); } +VARP(usedotfracs, 0, 0, 1); + const char *floatstr(float v) { + static string l; + ftoa(l, 0.5); static int n = 0; static string t[3]; n = (n + 1)%3; ftoa(t[n], v); + if(usedotfracs) + { + // evil make floating-point-char be "." function + // TODO - cleanup + string o; + copystring(o, newstring(t[n])); + string r,b; + r[0] = '\0'; + int c; + for(c=strlen(o)-1; c>=0; c--) + { + if( t[n][c] == l[1] ) formatstring(b)("%c%s", '.', r); + else formatstring(b)("%c%s", o[c], &r); + copystring(r,b); + } + copystring(t[n], r); + } return t[n]; } + void floatret(float v) { commandret = newstring(floatstr(v));