Attempting to encode and decode file.

This commit is contained in:
Ryan "Lofenyy" Medeiros 2023-06-26 12:19:40 -06:00
parent 93b8d190fe
commit 70f2f767f4
7 changed files with 113 additions and 2 deletions

View File

@ -376,6 +376,28 @@ int saveMap()
int loadMap()
{
cfg_t *cMFT;
cfg_t *cMap;
cfg_t *cBase;
cfg_t *cInfo;
cfg_t *cItem;
cfg_t *cDoor;
cfg_t *cChar;
cfg_t *cMon;
char buffer[255];
//Prompt for our file name
echo();
mvprintw(0,0,"Load name? ");
getnstr(buffer, 255);
//Open our map file
cMFT = cfg_init(oMFT, CFGF_NONE);
if(cfg_parse(cMFT, buffer) == CFG_PARSE_ERROR) return 1;
return 0;
}

View File

@ -65,4 +65,78 @@ struct maps
struct maps *map = NULL;
uint_fast8_t nMap = 0;
cfg_opt_t oMon[] =
{
CFG_INT("type", 0, CFGF_NONE),
CFG_INT("level", 0, CFGF_NONE),
CFG_END()
};
cfg_opt_t oBase[] =
{
CFG_INT("x", 0, CFGF_NONE),
CFG_INT("y", 0, CFGF_NONE),
CFG_INT("c", 0, CFGF_NONE),
CFG_INT("type", 0, CFGF_NONE),
CFG_INT("walk", 0, CFGF_NONE),
CFG_END()
};
cfg_opt_t oInfo[] =
{
CFG_INT("x", 0, CFGF_NONE),
CFG_INT("y", 0, CFGF_NONE),
CFG_STR("dialog", "Dialog not found.", CFGF_NONE),
CFG_END()
};
cfg_opt_t oItem[] =
{
CFG_INT("x", 0, CFGF_NONE),
CFG_INT("y", 0, CFGF_NONE),
CFG_INT("ID", 0, CFGF_NONE),
CFG_END()
};
cfg_opt_t oDoor[] =
{
CFG_INT("x", 0, CFGF_NONE),
CFG_INT("y", 0, CFGF_NONE),
CFG_INT("type", 0, CFGF_NONE),
CFG_INT("c", 0, CFGF_NONE),
CFG_INT("ID", 0, CFGF_NONE),
CFG_INT("nx", 0, CFGF_NONE),
CFG_INT("ny", 0, CFGF_NONE),
CFG_END()
};
cfg_opt_t oChar[] =
{
CFG_INT("x", 0, CFGF_NONE),
CFG_INT("y", 0, CFGF_NONE),
CFG_INT("type", 0, CFGF_NONE),
CFG_INT("move", 0, CFGF_NONE),
CFG_STR("name", "Name not found.", CFGF_NONE),
CFG_STR("dialog1", "Dialog 1 not found.", CFGF_NONE),
CFG_STR("dialog2", "Dialog 2 not found.", CFGF_NONE),
CFG_SEC("mon", oMon, CFGF_TITLE | CFGF_MULTI),
CFG_END()
};
cfg_opt_t oMap[] =
{
CFG_SEC("Base", oBase, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("Info", oInfo, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("Item", oItem, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("Door", oDoor, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("Char", oChar, CFGF_TITLE | CFGF_MULTI),
CFG_END()
};
cfg_opt_t oMFT[] =
{
CFG_SEC("Map", oMap, CFGF_TITLE | CFGF_MULTI),
CFG_END()
};
#include "Maps.c"

View File

@ -233,7 +233,7 @@ int main()
if(k == KEY_LEFT) x--;
if(k == KEY_RIGHT) x++;
if(k == KEY_F(5)) saveMap();
//if(k == KEY_F(6)) loadMap();
if(k == KEY_F(6)) loadMap();
//if(k == KEY_F(7)) copyMap();
if(k == KEY_F(8)) turnTip();
if(k == KEY_F(9)) tool = !tool;

10
Test Normal file
View File

@ -0,0 +1,10 @@
Map 0
{
Base 0
{
x = 1
y = 1
c = 1
}
}

View File

@ -17,7 +17,7 @@ fi
if [ "$1" == "editMap" ]
then
gcc ../Source/editMaps2.c -lncurses -g -o3 -Wall -o editMaps
gcc ../Source/editMaps2.c -lncurses -lconfuse -g -o3 -Wall -o editMaps
fi
if [ "$1" == "run_editMap" ]

4
f Normal file
View File

@ -0,0 +1,4 @@
Map 0
{
}

1
log Normal file
View File

@ -0,0 +1 @@
Test:3: no such option 'Bass'