aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2019-03-10 19:18:05 -0700
committerDerek Stevens <nilix@nilfm.cc>2019-03-10 19:18:05 -0700
commite4793cd973d31916a365c2d54723bd88771aa3ac (patch)
treecf0122d5cfb23ae82f28e4ad698f8e5ab6601207
parentf53665d989065b7e6a7314b904050357698fb048 (diff)
finished converting all Kaos constructors to form: newKaos(char* args)
-rw-r--r--Kaos.c39
-rw-r--r--Kaos.h4
-rw-r--r--WorldData.c6
3 files changed, 41 insertions, 8 deletions
diff --git a/Kaos.c b/Kaos.c
index b6861ab..de62882 100644
--- a/Kaos.c
+++ b/Kaos.c
@@ -387,10 +387,20 @@ void deleteFaceEachother(Kaos* target)
}
#ifdef SOUND_ON
-Kaos* newPlaySound(int i)
+Kaos* newPlaySound(char* args)
{
Kaos* core = rawKaos();
PlaySound* self = malloc(sizeof(PlaySound));
+ int i;
+
+ if (sscanf(args, "slot %d", &i) != 1)
+ {
+ free(core);
+ free(self);
+ core = NULL;
+ self = NULL;
+ return core;
+ }
self->i = i;
@@ -414,10 +424,21 @@ void deletePlaySound(Kaos* target)
}
#endif
-Kaos* newErase(char t, int i)
+Kaos* newErase(char* args)
{
Kaos* core = rawKaos();
Erase* self = malloc(sizeof(Erase));
+ char t;
+ int i;
+
+ if (sscanf(args, "objType %c, slot %d", &t, &i) != 2)
+ {
+ free(core);
+ free(self);
+ core = NULL;
+ self = NULL;
+ return core;
+ }
self->type = t;
self->index = i;
@@ -459,11 +480,23 @@ void deleteErase(Kaos* target)
free(target);
}
-Kaos* newWait(char t, int i)
+Kaos* newWait(char* args)
{
Kaos* core = rawKaos();
Wait* self = malloc(sizeof(Wait));
+ char t;
+ int i;
+
+ if (sscanf(args, "wType %c, time %d", &t, &i) != 2)
+ {
+ free(core);
+ free(self);
+ core = NULL;
+ self = NULL;
+ return core;
+ }
+
self->type = t;
self->frames = i;
diff --git a/Kaos.h b/Kaos.h
index 41cd9f8..1209c19 100644
--- a/Kaos.h
+++ b/Kaos.h
@@ -120,11 +120,11 @@ void runPlaySound(Kaos* self);
void deletePlaySound(Kaos* target);
#endif
-Kaos* newErase(char t, int i);
+Kaos* newErase(char* args);
void runErase(Kaos* self);
void deleteErase(Kaos* target);
-Kaos* newWait(char t, int i);
+Kaos* newWait(char* args);
void runWait(Kaos* self);
void deleteWait(Kaos* target);
diff --git a/WorldData.c b/WorldData.c
index 6ed2410..19538d5 100644
--- a/WorldData.c
+++ b/WorldData.c
@@ -258,7 +258,7 @@ int buildKaos(char* props)
fp = &newConversation;
break;
case 'W':
-// fp = &newWait;
+ fp = &newWait;
break;
case 'M':
fp = &newManip;
@@ -274,14 +274,14 @@ int buildKaos(char* props)
break;
case 'S':
#ifdef SOUND_ON
- //fp = &newPlaySound;
+ fp = &newPlaySound;
break;
#endif
case 'T':
fp = &newTeleport;
break;
case 'E':
- //fp = &newErase;
+ fp = &newErase;
break;
}
if (fp && !(kaosData[slot] = fp(kProps)))