From a99cabc018383476143cea2952c9d58b2ef83c95 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Tue, 5 Mar 2019 18:01:45 -0800 Subject: [PATCH] more construct(char* args) for kaos constructors --- Kaos.c | 13 ++++++++++++- Kaos.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Kaos.c b/Kaos.c index ee970e6..82ed6f5 100644 --- a/Kaos.c +++ b/Kaos.c @@ -60,11 +60,22 @@ void deleteConversation(Kaos* target) free(target); } -Kaos* newChoice(char* q, char* a1, char* a2, HyperKaos* p1, HyperKaos* p2) +Kaos* newChoice(char* args) { + char q[32], a1[32], a2[32]; + int p1, p2; Kaos* core = rawKaos(); Choice* self = malloc(sizeof(Choice)); + if (sscanf(args, "q %[^,], a1 %[^,], a2 %[^,], p1 %d, p2 %d", q, a1, a2, &p1, &p2) != 5) + { + free(core); + free(self); + self = NULL; + core = NULL; + return core; + } + self->question = TTF_RenderText_Solid(font, q, textColor); self->answ1 = TTF_RenderText_Solid(font, a1, textColor); self->answ2 = TTF_RenderText_Solid(font, a2, textColor); diff --git a/Kaos.h b/Kaos.h index 5d5eddf..0be4ca8 100644 --- a/Kaos.h +++ b/Kaos.h @@ -95,7 +95,7 @@ Kaos* newConversation(char* args); void runConversation(Kaos* self); void deleteConversation(Kaos* target); -Kaos* newChoice(char* q, char* a1, char* a2, HyperKaos* p1, HyperKaos* p2); +Kaos* newChoice(char* args); void runChoice(Kaos* self); void deleteChoice(Kaos* target);