From 2b265ea0eb5825eccd3b9b072b5014bacf0d16d7 Mon Sep 17 00:00:00 2001 From: Oxore Date: Wed, 11 Jul 2018 07:04:47 +0300 Subject: Migrate displayable text to utf32 --- src/engine.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/engine.c') diff --git a/src/engine.c b/src/engine.c index 59de551..a087fd2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "common.h" #include "idlist.h" @@ -75,8 +74,11 @@ static void render_score_value(void *obj) struct text *text = obj; if (!strcmp(text->type, "score.value")) { if (!text->text) - text->text = malloc(sizeof(char) * BUFSIZ); - sprintf(text->text, "%d", game.scoreCurrent); + text->text = calloc(BUFSIZ, sizeof(char)); + char *a = calloc(BUFSIZ, sizeof(char)); + sprintf(a, "%d", game.scoreCurrent); + utf8to32_strcpy(text->text, a); + free(a); } } @@ -85,8 +87,11 @@ static void render_level_value(void *obj) struct text *text = obj; if (!strcmp(text->type, "level.value")) { if (!text->text) - text->text = malloc(sizeof(char) * BUFSIZ); - sprintf(text->text, "%d", game.level); + text->text = calloc(BUFSIZ, sizeof(char)); + char *a = calloc(BUFSIZ, sizeof(char)); + sprintf(a, "%d", game.level); + utf8to32_strcpy(text->text, a); + free(a); } } -- cgit v1.2.3