2018-09-20 01:27:47 +00:00
|
|
|
#include <stdio.h>
|
2019-02-04 07:53:50 +00:00
|
|
|
#include <string.h>
|
2018-11-13 21:30:59 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-09-20 01:27:47 +00:00
|
|
|
#include "SDL/SDL.h"
|
|
|
|
#include "SDL/SDL_image.h"
|
|
|
|
#include "SDL/SDL_ttf.h"
|
|
|
|
#include "SDL/SDL_mixer.h"
|
|
|
|
|
|
|
|
#include "enum.h"
|
2018-11-13 21:08:21 +00:00
|
|
|
|
2018-09-20 01:27:47 +00:00
|
|
|
#include "Engine.h"
|
|
|
|
#include "Player.h"
|
|
|
|
#include "Room.h"
|
|
|
|
#include "Kaos.h"
|
|
|
|
#include "HyperKaos.h"
|
|
|
|
#include "TextBox.h"
|
2018-09-24 18:41:09 +00:00
|
|
|
#include "Scene.h"
|
2018-11-13 21:08:21 +00:00
|
|
|
#include "Synergy.h"
|
2019-02-04 07:53:50 +00:00
|
|
|
#include "WorldData.h"
|
2018-09-20 01:27:47 +00:00
|
|
|
|
|
|
|
typedef struct timer Timer;
|
|
|
|
#include "extern.h"
|
|
|
|
|
|
|
|
void bufferData(enum dataChunks chunk)
|
|
|
|
{
|
|
|
|
hasMusic = 0;
|
2019-02-04 07:53:50 +00:00
|
|
|
applySurface(8,8, loadingTxt, screen, NULL);
|
2019-01-09 22:26:38 +00:00
|
|
|
frameAdvance();
|
2018-10-13 03:35:45 +00:00
|
|
|
printf("Loading map chunk\n");
|
2019-02-10 05:00:11 +00:00
|
|
|
if(!worldBuilder(chunk))
|
2019-02-04 07:53:50 +00:00
|
|
|
{
|
|
|
|
quit = 1; playing = 0;
|
|
|
|
printf("Fatal map error. Quitting\n");
|
2019-02-10 05:00:11 +00:00
|
|
|
return;
|
2019-02-04 07:53:50 +00:00
|
|
|
};
|
|
|
|
printf("Loaded map chunk\n");
|
|
|
|
}
|
2018-11-13 21:30:59 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
int hashCmd(char* x)
|
|
|
|
{
|
|
|
|
int hash = 7951;
|
|
|
|
int coef = 181;
|
|
|
|
while (*x)
|
|
|
|
{
|
|
|
|
hash += coef*(*x);
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
hash %= 256;
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
int worldBuilder(enum dataChunks chunk)
|
|
|
|
{
|
|
|
|
char datafile[256];
|
|
|
|
char lineBuffer[1024];
|
2019-02-09 01:23:13 +00:00
|
|
|
char cmdBuffer[24];
|
2019-02-04 07:53:50 +00:00
|
|
|
char cchunk[4];
|
|
|
|
char propsBuffer[998];
|
|
|
|
int savequery;
|
|
|
|
int conditional = 0;
|
2019-02-10 05:00:11 +00:00
|
|
|
int (*fp)(char* props);
|
2019-02-04 07:53:50 +00:00
|
|
|
FILE* worldInfo;
|
|
|
|
|
|
|
|
sprintf(cchunk, "%d", chunk);
|
|
|
|
|
|
|
|
strcpy(datafile, "mapdata/");
|
|
|
|
strcat(datafile, cchunk);
|
|
|
|
strcat(datafile, ".txt");
|
|
|
|
|
|
|
|
worldInfo = fopen(datafile, "r");
|
|
|
|
|
|
|
|
if (!worldInfo)
|
|
|
|
{
|
|
|
|
printf("Couldn't read world data\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
while (fgets(lineBuffer, 1024, worldInfo))
|
|
|
|
{
|
2019-02-10 05:00:11 +00:00
|
|
|
if (!strcmp(lineBuffer,"\n") || !strcmp(lineBuffer,"\r\n")) continue;
|
2019-02-04 07:53:50 +00:00
|
|
|
if (lineBuffer[0] == '<')
|
2018-09-20 01:27:47 +00:00
|
|
|
{
|
2019-02-04 07:53:50 +00:00
|
|
|
conditional = 0;
|
|
|
|
continue;
|
2018-09-20 01:27:47 +00:00
|
|
|
}
|
2019-02-04 07:53:50 +00:00
|
|
|
if (!conditional)
|
|
|
|
{
|
2019-02-09 01:23:13 +00:00
|
|
|
if (sscanf(lineBuffer, "%[^:]: %[^\t\n]", cmdBuffer, propsBuffer) < 2)
|
2019-02-04 07:53:50 +00:00
|
|
|
{
|
|
|
|
printf("World data line malformed\n");
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-09 01:23:13 +00:00
|
|
|
switch (hashCmd(cmdBuffer))
|
2019-02-04 07:53:50 +00:00
|
|
|
{
|
|
|
|
case 200: //mkRoom
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildRoom;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 45: //mkKaos
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildKaos;
|
2019-02-04 07:53:50 +00:00
|
|
|
break;
|
|
|
|
case 109: //mkTextBox
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildTextBox;
|
2019-02-04 07:53:50 +00:00
|
|
|
break;
|
|
|
|
case 181: //addText
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &modTextBox;
|
2019-02-04 07:53:50 +00:00
|
|
|
break;
|
2019-02-10 05:00:11 +00:00
|
|
|
case 229: //loadFX
|
|
|
|
fp = &buildSFX;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-03-06 01:26:01 +00:00
|
|
|
case 125: //loadBGM
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildBGM;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 100: //addSigil
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildSynergy;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 47: //addPerson
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildPerson;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 88: //addObstruction
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildObstruction;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 141: //addImg
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildFGImage;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 240: //addTrigger
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildHyper;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-08 22:38:55 +00:00
|
|
|
case 148: //chainKaos
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &chainKaos;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
case 238: //addWarp
|
2019-02-10 05:00:11 +00:00
|
|
|
fp = &buildWarp;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
2019-02-10 05:00:11 +00:00
|
|
|
if (!fp(propsBuffer))
|
|
|
|
return 0;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
fclose(worldInfo);
|
2019-02-10 05:00:11 +00:00
|
|
|
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;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
int buildRoom(char* props)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
char filename[256];
|
|
|
|
int breathe;
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
if (sscanf(props, "slot %u, sprite %[^,], spd %u", &slot, filename, &breathe) != 3)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
2019-02-04 07:53:50 +00:00
|
|
|
printf("Building room in map slot %d: bg = %s; spd = %d\n", slot, filename, breathe);
|
|
|
|
mapBuffer[slot] = newRoom(filename, breathe);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
int buildTextBox(char* props)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
char portrait[256];
|
|
|
|
|
|
|
|
if (sscanf(props, "slot %u, portrait %[^\n]",
|
|
|
|
&slot, portrait) != 2)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("building textbox...\n");
|
|
|
|
if (strcmp(portrait, "none") != 0)
|
|
|
|
dialogueData[slot] = newTextBox();
|
|
|
|
else
|
|
|
|
dialogueData[slot] = newGTextBox(loadImage(portrait));
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-09 01:23:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int modTextBox(char* props)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
char textData[64];
|
|
|
|
|
|
|
|
if (sscanf(props, "slot %u, %[^\n]", &slot, textData) != 2)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("adding line of text to textbox...\n");
|
|
|
|
addText(dialogueData[slot], textData);
|
2019-02-10 05:00:11 +00:00
|
|
|
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;
|
2019-02-09 01:23:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int buildKaos(char* props)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
char kType, kProps[990];
|
2019-03-06 01:26:01 +00:00
|
|
|
Kaos* (*fp)(char* args);
|
2019-02-09 01:23:13 +00:00
|
|
|
|
|
|
|
if (sscanf(props, "slot %u, class %c, %[^\n]",
|
|
|
|
&slot, &kType, kProps) != 3)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("building kaos...\n");
|
|
|
|
switch (kType)
|
|
|
|
{
|
|
|
|
case 'C':
|
2019-03-06 01:26:01 +00:00
|
|
|
fp = &newConversation;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
|
|
|
case 'W':
|
2019-02-10 05:00:11 +00:00
|
|
|
// fp = &buildWait;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
|
|
|
case 'M':
|
2019-03-06 01:26:01 +00:00
|
|
|
fp = &newManip;
|
2019-02-09 01:23:13 +00:00
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
//if (buildLook(slot, kProps) != 0) return 1;
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
// if (buildFaceEachother(slot, kProps) != 0) return 1;
|
|
|
|
break;
|
|
|
|
case 'Y':
|
|
|
|
//if (buildChoice(slot, kProps) != 0) return 1;
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
// if (buildSound(slot, kProps) != 0) return 1;
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
//if (buildTeleport(slot, kProps) != 0) return 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2019-03-06 01:26:01 +00:00
|
|
|
if (!(kaosData[slot] = fp(kProps)))
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
return 1;
|
2019-02-09 01:23:13 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
int buildObstruction(char* props)
|
|
|
|
{
|
|
|
|
int rm, x, y, w, h;
|
|
|
|
|
|
|
|
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u",
|
|
|
|
&rm, &x, &y, &w, &h) != 5)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("Building obstacle...\n");
|
2019-02-08 22:38:55 +00:00
|
|
|
addObstacle(mapBuffer[rm], x, y, w, h);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-08 22:38:55 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:54:48 +00:00
|
|
|
int buildFGImage(char* props)
|
|
|
|
{
|
|
|
|
int rm, x, y, w, h, f, d, a;
|
|
|
|
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)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("Building FG Image...\n");
|
|
|
|
addFgObj(mapBuffer[rm], x, y, w, h, filename, f, d, a);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-08 22:54:48 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
int buildWarp(char* props)
|
|
|
|
{
|
|
|
|
int r, x, y, w, h, dC, dR, dX, dY;
|
2019-02-08 22:38:55 +00:00
|
|
|
if (sscanf(props, "room %u, x %d, y %d, w %u, h %u, dest %u,%u, dX %d, dY %d",
|
2019-02-04 07:53:50 +00:00
|
|
|
&r, &x, &y, &w, &h, &dC, &dR, &dX, &dY) != 9)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
printf("Building warp...\n");
|
2019-02-04 07:53:50 +00:00
|
|
|
addWarp(mapBuffer[r], x, y, w, h, dC, dR, dX, dY);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-04 07:53:50 +00:00
|
|
|
}
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
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)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
printf("Building hyperkaos...\n");
|
|
|
|
HyperKaos* temp = newHyperKaos(id, tType, x, y, w, h);
|
|
|
|
addTrigger(mapBuffer[rm], temp);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-08 22:38:55 +00:00
|
|
|
}
|
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
int chainKaos(char* props)
|
|
|
|
{
|
|
|
|
int rm, trig, k;
|
|
|
|
if (sscanf(props, "room %u, trigger %u, kaos %u",
|
|
|
|
&rm, &trig, &k) != 3)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-09 01:23:13 +00:00
|
|
|
printf("Chaining kaos...\n");
|
|
|
|
addKaos(mapBuffer[rm]->eventTriggers[trig], kaosData[k]);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-09 01:23:13 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
int buildPerson(char* props)
|
|
|
|
{
|
|
|
|
int rm, x, y;
|
|
|
|
char filename[256];
|
|
|
|
|
|
|
|
if (sscanf(props, "room %u, sprite %[^,], x %d, y%d",
|
|
|
|
&rm, filename, &x, &y) != 4)
|
2019-02-10 05:00:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-02-08 22:38:55 +00:00
|
|
|
printf("Building person...\n");
|
|
|
|
Player* temp = newPlayer(filename, x, y);
|
|
|
|
addPerson(mapBuffer[rm], temp);
|
2019-02-10 05:00:11 +00:00
|
|
|
return 1;
|
2019-02-08 22:38:55 +00:00
|
|
|
}
|
|
|
|
|
2019-03-06 01:26:01 +00:00
|
|
|
int* countMapThings(int* count, enum dataChunks chunk)
|
2019-02-04 07:53:50 +00:00
|
|
|
{
|
|
|
|
char datafile[256];
|
|
|
|
char lineBuffer[1024];
|
2019-03-06 01:26:01 +00:00
|
|
|
char cmdBuffer[24];
|
|
|
|
char propsBuffer[998];
|
2019-02-04 07:53:50 +00:00
|
|
|
char cchunk[4];
|
2018-11-13 21:08:21 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
FILE* worldInfo;
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
sprintf(cchunk, "%d", chunk);
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
strcpy(datafile, "mapdata/");
|
|
|
|
strcat(datafile, cchunk);
|
|
|
|
strcat(datafile, ".txt");
|
2018-09-20 01:27:47 +00:00
|
|
|
|
2019-02-04 07:53:50 +00:00
|
|
|
worldInfo = fopen(datafile, "r");
|
|
|
|
while (fgets(lineBuffer, 1024, worldInfo))
|
|
|
|
{
|
2019-03-06 01:26:01 +00:00
|
|
|
sscanf(lineBuffer, "%[^:]: %[^\t\n]", cmdBuffer, propsBuffer);
|
|
|
|
switch(hashCmd(cmdBuffer))
|
|
|
|
{
|
|
|
|
case 200:
|
|
|
|
count[0]++;
|
|
|
|
break;
|
|
|
|
case 45:
|
|
|
|
count[1]++;
|
|
|
|
break;
|
|
|
|
case 109:
|
|
|
|
count[2]++;
|
|
|
|
break;
|
|
|
|
case 229:
|
|
|
|
count[3]++;
|
|
|
|
break;
|
|
|
|
case 125:
|
|
|
|
count[4]++;
|
|
|
|
break;
|
|
|
|
}
|
2018-10-13 03:35:45 +00:00
|
|
|
}
|
2019-02-04 07:53:50 +00:00
|
|
|
return count;
|
2018-09-20 01:27:47 +00:00
|
|
|
}
|
|
|
|
|
2019-03-06 01:26:01 +00:00
|
|
|
void dataPurge(int* objs)
|
2018-09-20 01:27:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
2019-03-06 01:26:01 +00:00
|
|
|
for (i = 0; i < objs[0]; i++)
|
2018-09-20 01:27:47 +00:00
|
|
|
deleteRoom(mapData[i]);
|
2019-03-06 01:26:01 +00:00
|
|
|
for (i = 0; i < objs[2]; i++)
|
2018-09-20 01:27:47 +00:00
|
|
|
deleteTextBox(dialogueData[i]);
|
2019-03-06 01:26:01 +00:00
|
|
|
for (i = 0; i < objs[1]; i++)
|
2018-09-20 01:27:47 +00:00
|
|
|
kaosData[i]->destroy(kaosData[i]);
|
2018-11-13 21:30:59 +00:00
|
|
|
|
|
|
|
#ifdef SOUND_ON
|
2019-03-06 01:26:01 +00:00
|
|
|
for (i = 0; i < objs[3]; i++)
|
2018-09-20 01:27:47 +00:00
|
|
|
Mix_FreeMusic(bgmData[i]);
|
2019-03-06 01:26:01 +00:00
|
|
|
for (i = 0; i < objs[4]; i++)
|
2018-09-20 01:27:47 +00:00
|
|
|
Mix_FreeChunk(sfxData[i]);
|
2018-11-13 21:30:59 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-20 01:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void unloadData(enum dataChunks chunk)
|
|
|
|
{
|
2019-03-06 01:26:01 +00:00
|
|
|
int thingsCount[5] = {0,0,0,0,0};
|
2018-10-13 03:35:45 +00:00
|
|
|
printf("Unloading old map chunk\n");
|
2019-03-06 01:26:01 +00:00
|
|
|
dataPurge(countMapThings(thingsCount, chunk));
|
2018-10-13 03:35:45 +00:00
|
|
|
printf("Unloaded old map chunk\n");
|
2018-09-20 01:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pushBufferData()
|
|
|
|
{
|
2018-10-13 03:35:45 +00:00
|
|
|
printf("Pushing map buffer\n");
|
2018-09-20 01:27:47 +00:00
|
|
|
mapData = mapBuffer;
|
|
|
|
mapBuffer = (Room**)malloc(64*sizeof(Room*));
|
2018-11-13 21:30:59 +00:00
|
|
|
|
|
|
|
#ifdef SOUND_ON
|
2018-09-20 01:27:47 +00:00
|
|
|
if (hasMusic)
|
|
|
|
Mix_PlayMusic(bgmData[0], -1);
|
2018-11-13 21:30:59 +00:00
|
|
|
#endif
|
|
|
|
|
2018-11-13 21:08:21 +00:00
|
|
|
printf("Map buffer clean\n");
|
2018-09-20 01:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pager()
|
|
|
|
{
|
|
|
|
if (thisChunk != nextChunk)
|
|
|
|
{
|
2018-11-13 21:30:59 +00:00
|
|
|
|
|
|
|
#ifdef SOUND_ON
|
2018-09-20 01:27:47 +00:00
|
|
|
if (Mix_PlayingMusic())
|
|
|
|
{
|
|
|
|
Mix_HaltMusic();
|
|
|
|
}
|
2018-11-13 21:30:59 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-20 01:27:47 +00:00
|
|
|
unloadData(thisChunk);
|
|
|
|
pushBufferData();
|
|
|
|
thisChunk=nextChunk;
|
|
|
|
}
|
|
|
|
}
|