aboutsummaryrefslogtreecommitdiff
path: root/netslide.c
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2017-08-17 15:27:52 -0400
committerFranklin Wei <franklin@rockbox.org>2020-12-07 19:27:19 -0500
commitb1f691f2deb0b59c6e237241e1995c5d95f37ffa (patch)
tree499df3c5baf7fbb9943909f0eb4d48db386b444c /netslide.c
parentb4b86bbdbeb99c9fd9cfa6b61454047eb5e8fe20 (diff)
downloadpuzzles-b1f691f2deb0b59c6e237241e1995c5d95f37ffa.zip
puzzles-b1f691f2deb0b59c6e237241e1995c5d95f37ffa.tar.gz
puzzles-b1f691f2deb0b59c6e237241e1995c5d95f37ffa.tar.bz2
puzzles-b1f691f2deb0b59c6e237241e1995c5d95f37ffa.tar.xz
Introduce ftoa() as a replacement for the %g format specifier
Not all platforms support printing floats, this is a more portable (if uglier) way.
Diffstat (limited to 'netslide.c')
-rw-r--r--netslide.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/netslide.c b/netslide.c
index a2e3281..14af2a6 100644
--- a/netslide.c
+++ b/netslide.c
@@ -242,7 +242,10 @@ static char *encode_params(const game_params *params, bool full)
if (params->wrapping)
ret[len++] = 'w';
if (full && params->barrier_probability)
- len += sprintf(ret+len, "b%g", params->barrier_probability);
+ {
+ len += sprintf(ret+len, "b");
+ len += ftoa(ret + len, params->barrier_probability);
+ }
/* Shuffle limit is part of the limited parameters, because we have to
* provide the target move count. */
if (params->movetarget)
@@ -276,7 +279,7 @@ static config_item *game_configure(const game_params *params)
ret[3].name = "Barrier probability";
ret[3].type = C_STRING;
- sprintf(buf, "%g", params->barrier_probability);
+ ftoa(buf, params->barrier_probability);
ret[3].u.string.sval = dupstr(buf);
ret[4].name = "Number of shuffling moves";