file feed map builder can do almost everything the hardwired map can do, just a few kaos types missing
This commit is contained in:
parent
85f5534f1e
commit
b36c9a6d62
2 changed files with 113 additions and 86 deletions
193
WorldData.c
193
WorldData.c
|
@ -29,10 +29,11 @@ void bufferData(enum dataChunks chunk)
|
|||
applySurface(8,8, loadingTxt, screen, NULL);
|
||||
frameAdvance();
|
||||
printf("Loading map chunk\n");
|
||||
if(worldBuilder(chunk) != 0)
|
||||
if(!worldBuilder(chunk))
|
||||
{
|
||||
quit = 1; playing = 0;
|
||||
printf("Fatal map error. Quitting\n");
|
||||
return;
|
||||
};
|
||||
printf("Loaded map chunk\n");
|
||||
}
|
||||
|
@ -59,6 +60,7 @@ int worldBuilder(enum dataChunks chunk)
|
|||
char propsBuffer[998];
|
||||
int savequery;
|
||||
int conditional = 0;
|
||||
int (*fp)(char* props);
|
||||
FILE* worldInfo;
|
||||
|
||||
sprintf(cchunk, "%d", chunk);
|
||||
|
@ -77,7 +79,7 @@ int worldBuilder(enum dataChunks chunk)
|
|||
|
||||
while (fgets(lineBuffer, 1024, worldInfo))
|
||||
{
|
||||
if (lineBuffer[0] == '#') continue;
|
||||
if (!strcmp(lineBuffer,"\n") || !strcmp(lineBuffer,"\r\n")) continue;
|
||||
if (lineBuffer[0] == '<')
|
||||
{
|
||||
conditional = 0;
|
||||
|
@ -88,63 +90,86 @@ int worldBuilder(enum dataChunks chunk)
|
|||
if (sscanf(lineBuffer, "%[^:]: %[^\t\n]", cmdBuffer, propsBuffer) < 2)
|
||||
{
|
||||
printf("World data line malformed\n");
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (hashCmd(cmdBuffer))
|
||||
{
|
||||
case 200: //mkRoom
|
||||
if (buildRoom(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildRoom;
|
||||
break;
|
||||
case 45: //mkKaos
|
||||
if (buildKaos(propsBuffer) != 0) return 1;
|
||||
fp = &buildKaos;
|
||||
break;
|
||||
case 109: //mkTextBox
|
||||
if (buildTextBox(propsBuffer) != 0) return 1;
|
||||
fp = &buildTextBox;
|
||||
break;
|
||||
case 181: //addText
|
||||
if (modTextBox(propsBuffer) != 0) return 1;
|
||||
fp = &modTextBox;
|
||||
break;
|
||||
case 116: //SFX
|
||||
// buildSFX(propsBuffer);
|
||||
case 229: //loadFX
|
||||
fp = &buildSFX;
|
||||
break;
|
||||
case 93: //BGM
|
||||
// buildBGM(propsBuffer);
|
||||
case 125: //BGM
|
||||
fp = &buildBGM;
|
||||
break;
|
||||
case 100: //addSigil
|
||||
// buildSynergy(propsBuffer);
|
||||
fp = &buildSynergy;
|
||||
break;
|
||||
case 47: //addPerson
|
||||
if (buildPerson(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildPerson;
|
||||
break;
|
||||
case 88: //addObstruction
|
||||
if (buildObstruction(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildObstruction;
|
||||
break;
|
||||
case 141: //addImg
|
||||
if (buildFGImage(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildFGImage;
|
||||
break;
|
||||
case 240: //addTrigger
|
||||
if (buildHyper(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildHyper;
|
||||
break;
|
||||
case 148: //chainKaos
|
||||
if (chainKaos(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &chainKaos;
|
||||
break;
|
||||
case 238: //addWarp
|
||||
if (buildWarp(propsBuffer) != 0)
|
||||
return 1;
|
||||
fp = &buildWarp;
|
||||
break;
|
||||
}
|
||||
if (!fp(propsBuffer))
|
||||
return 0;
|
||||
}
|
||||
}}
|
||||
fclose(worldInfo);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildBGM(char* props)
|
||||
{
|
||||
#ifdef SOUND_ON
|
||||
int slot;
|
||||
char filename[256];
|
||||
|
||||
if (sscanf(props, "slot %u, file %[^\t\n]", &slot, filename) != 2)
|
||||
return 0;
|
||||
|
||||
bgmData[slot] = loadBGM(filename);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildSFX(char* props)
|
||||
{
|
||||
#ifdef SOUND_ON
|
||||
int slot;
|
||||
char filename[256];
|
||||
|
||||
if (sscanf(props, "slot %u, file %[^\t\n]", &slot, filename) != 2)
|
||||
return 0;
|
||||
|
||||
sfxData[slot] = loadSFX(filename);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildRoom(char* props)
|
||||
|
@ -154,12 +179,10 @@ int buildRoom(char* props)
|
|||
int breathe;
|
||||
|
||||
if (sscanf(props, "slot %u, sprite %[^,], spd %u", &slot, filename, &breathe) != 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
printf("Building room in map slot %d: bg = %s; spd = %d\n", slot, filename, breathe);
|
||||
mapBuffer[slot] = newRoom(filename, breathe);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildTextBox(char* props)
|
||||
|
@ -169,19 +192,13 @@ int buildTextBox(char* props)
|
|||
|
||||
if (sscanf(props, "slot %u, portrait %[^\n]",
|
||||
&slot, portrait) != 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
printf("building textbox...\n");
|
||||
if (strcmp(portrait, "none") != 0)
|
||||
{
|
||||
dialogueData[slot] = newTextBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
dialogueData[slot] = newGTextBox(loadImage(portrait));
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int modTextBox(char* props)
|
||||
|
@ -190,35 +207,47 @@ int modTextBox(char* props)
|
|||
char textData[64];
|
||||
|
||||
if (sscanf(props, "slot %u, %[^\n]", &slot, textData) != 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("adding line of text to textbox...\n");
|
||||
addText(dialogueData[slot], textData);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildSynergy(char* props)
|
||||
{
|
||||
int rm, x, y, w, h;
|
||||
char d;
|
||||
int spell, effect;
|
||||
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u, spell %u, dir %c, effect %d",
|
||||
&rm, &x, &y, &w, &h, &spell, &d, &effect) != 8)
|
||||
return 0;
|
||||
|
||||
printf("building synergy...\n");
|
||||
addSigil(mapBuffer[rm], newSynergy(spell, d, x, y, w, h, mapBuffer[rm]->eventTriggers[effect]));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildKaos(char* props)
|
||||
{
|
||||
int slot;
|
||||
char kType, kProps[990];
|
||||
int (*fp)(int s, char* props);
|
||||
|
||||
if (sscanf(props, "slot %u, class %c, %[^\n]",
|
||||
&slot, &kType, kProps) != 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
printf("building kaos...\n");
|
||||
switch (kType)
|
||||
{
|
||||
case 'C':
|
||||
if (buildConvo(slot, kProps) != 0) return 1;
|
||||
fp = &buildConvo;
|
||||
break;
|
||||
case 'W':
|
||||
//if (buildWait(slot, kProps) != 0) return 1;
|
||||
// fp = &buildWait;
|
||||
break;
|
||||
case 'M':
|
||||
if (buildManip(slot, kProps) != 0) return 1;
|
||||
fp = &buildManip;
|
||||
break;
|
||||
case 'L':
|
||||
//if (buildLook(slot, kProps) != 0) return 1;
|
||||
|
@ -237,17 +266,19 @@ int buildKaos(char* props)
|
|||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
if (!fp(slot, kProps))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildConvo(int slot, char* kProps)
|
||||
{
|
||||
int tSlot;
|
||||
if (sscanf(kProps, "textbox %u", &tSlot) != 1)
|
||||
return 1;
|
||||
return 0;
|
||||
printf(">>convo\n");
|
||||
kaosData[slot] = newConversation(tSlot);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildManip(int slot, char* kProps)
|
||||
|
@ -257,20 +288,16 @@ int buildManip(int slot, char* kProps)
|
|||
Player* target = hero;
|
||||
if (sscanf(kProps, "room %u, person %u, xSpd %d, ySpd %d",
|
||||
&rm, &pSlot, &x, &y) != 4)
|
||||
{
|
||||
}
|
||||
else if (sscanf(kProps, "player, xSpd %d, ySpd %d",
|
||||
&x, &y) != 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (sscanf(kProps, "player, xSpd %d, ySpd %d",
|
||||
&x, &y) != 2)
|
||||
return 0;
|
||||
|
||||
if (pSlot >= 0)
|
||||
{
|
||||
target = mapBuffer[rm]->people[pSlot];
|
||||
}
|
||||
|
||||
printf(">>manip\n");
|
||||
kaosData[slot] = newManip(target, x, y);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildObstruction(char* props)
|
||||
|
@ -279,12 +306,11 @@ int buildObstruction(char* props)
|
|||
|
||||
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u",
|
||||
&rm, &x, &y, &w, &h) != 5)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Building obstacle...\n");
|
||||
addObstacle(mapBuffer[rm], x, y, w, h);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildFGImage(char* props)
|
||||
|
@ -293,12 +319,11 @@ int buildFGImage(char* props)
|
|||
char filename[256];
|
||||
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u, sprite %[^,], frames %u, dual %u, alpha %u",
|
||||
&rm, &x, &y, &w, &h, filename, &f, &d, &a) !=9)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Building FG Image...\n");
|
||||
addFgObj(mapBuffer[rm], x, y, w, h, filename, f, d, a);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildWarp(char* props)
|
||||
|
@ -306,12 +331,11 @@ int buildWarp(char* props)
|
|||
int r, x, y, w, h, dC, dR, dX, dY;
|
||||
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u, dest %u,%u, dX %d, dY %d",
|
||||
&r, &x, &y, &w, &h, &dC, &dR, &dX, &dY) != 9)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Building warp...\n");
|
||||
addWarp(mapBuffer[r], x, y, w, h, dC, dR, dX, dY);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildHyper(char* props)
|
||||
|
@ -319,13 +343,12 @@ int buildHyper(char* props)
|
|||
int rm, id, tType, x, y, w, h;
|
||||
if (sscanf(props, "room %u, id %u, type %u, x %d, y %d, w %u, h %u",
|
||||
&rm, &id, &tType, &x, &y, &w, &h) != 7)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Building hyperkaos...\n");
|
||||
HyperKaos* temp = newHyperKaos(id, tType, x, y, w, h);
|
||||
addTrigger(mapBuffer[rm], temp);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chainKaos(char* props)
|
||||
|
@ -333,12 +356,11 @@ int chainKaos(char* props)
|
|||
int rm, trig, k;
|
||||
if (sscanf(props, "room %u, trigger %u, kaos %u",
|
||||
&rm, &trig, &k) != 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Chaining kaos...\n");
|
||||
addKaos(mapBuffer[rm]->eventTriggers[trig], kaosData[k]);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buildPerson(char* props)
|
||||
|
@ -348,16 +370,15 @@ int buildPerson(char* props)
|
|||
|
||||
if (sscanf(props, "room %u, sprite %[^,], x %d, y%d",
|
||||
&rm, filename, &x, &y) != 4)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("Building person...\n");
|
||||
Player* temp = newPlayer(filename, x, y);
|
||||
addPerson(mapBuffer[rm], temp);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int countMapThings(char x, enum dataChunks chunk)
|
||||
int countMapThings(enum dataChunks chunk)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ void bufferData(enum dataChunks chunk);
|
|||
|
||||
int worldBuilder(enum dataChunks chunk);
|
||||
|
||||
int buildSFX(char* props);
|
||||
|
||||
int buildBGM(char* props);
|
||||
|
||||
int buildSynergy(char* props);
|
||||
|
||||
int buildRoom(char* props);
|
||||
|
||||
int buildWarp(char* props);
|
||||
|
|
Loading…
Reference in a new issue