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 #ifdef SOUND_ON
Kaos* newPlaySound(int i) Kaos* newPlaySound(char* args)
{ {
Kaos* core = rawKaos(); Kaos* core = rawKaos();
PlaySound* self = malloc(sizeof(PlaySound)); 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; self->i = i;
@ -414,10 +424,21 @@ void deletePlaySound(Kaos* target)
} }
#endif #endif
Kaos* newErase(char t, int i) Kaos* newErase(char* args)
{ {
Kaos* core = rawKaos(); Kaos* core = rawKaos();
Erase* self = malloc(sizeof(Erase)); 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->type = t;
self->index = i; self->index = i;
@ -459,11 +480,23 @@ void deleteErase(Kaos* target)
free(target); free(target);
} }
Kaos* newWait(char t, int i) Kaos* newWait(char* args)
{ {
Kaos* core = rawKaos(); Kaos* core = rawKaos();
Wait* self = malloc(sizeof(Wait)); 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->type = t;
self->frames = i; self->frames = i;

4
Kaos.h
View file

@ -120,11 +120,11 @@ void runPlaySound(Kaos* self);
void deletePlaySound(Kaos* target); void deletePlaySound(Kaos* target);
#endif #endif
Kaos* newErase(char t, int i); Kaos* newErase(char* args);
void runErase(Kaos* self); void runErase(Kaos* self);
void deleteErase(Kaos* target); void deleteErase(Kaos* target);
Kaos* newWait(char t, int i); Kaos* newWait(char* args);
void runWait(Kaos* self); void runWait(Kaos* self);
void deleteWait(Kaos* target); void deleteWait(Kaos* target);

View file

@ -258,7 +258,7 @@ int buildKaos(char* props)
fp = &newConversation; fp = &newConversation;
break; break;
case 'W': case 'W':
// fp = &newWait; fp = &newWait;
break; break;
case 'M': case 'M':
fp = &newManip; fp = &newManip;
@ -274,14 +274,14 @@ int buildKaos(char* props)
break; break;
case 'S': case 'S':
#ifdef SOUND_ON #ifdef SOUND_ON
//fp = &newPlaySound; fp = &newPlaySound;
break; break;
#endif #endif
case 'T': case 'T':
fp = &newTeleport; fp = &newTeleport;
break; break;
case 'E': case 'E':
//fp = &newErase; fp = &newErase;
break; break;
} }
if (fp && !(kaosData[slot] = fp(kProps))) if (fp && !(kaosData[slot] = fp(kProps)))