finished converting all Kaos constructors to form: newKaos(char* args)

This commit is contained in:
Iris Lightshard 2019-03-10 19:18:05 -07:00
parent f53665d989
commit e4793cd973
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
3 changed files with 41 additions and 8 deletions

39
Kaos.c
View file

@ -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;

4
Kaos.h
View file

@ -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);

View file

@ -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)))