2
#ifndef ArmageTron_PARSER_H
3
#define ArmageTron_PARSER_H
6
#include <libxml/parser.h>
7
#include <libxml/tree.h>
17
Note to the reader: In the full World idea, the parser should,
18
when called, create a full world structure, from the Empire down,
19
and just return a pointer to it(He, whats to forbit a server from
20
running 2 independant games?).
22
Due to the limitations of the current code, it is best to have a
23
pointer to the gGame, the gArena and the gGrid.
29
gArena *theArena; /*Patch: All the world structure should be created by the parser*/
30
eGrid *theGrid; /*Patch: All the world structure should be created by the parser*/
32
xmlDocPtr doc; /* The map xml document */
34
REAL rimTexture; /* The rim wall texture coordinate */
36
ePoint * DrawRim( eGrid * grid, ePoint * start, eCoord const & stop, REAL h=10000 ); /* Draws a rim wall segment */
39
gParser(gArena *anArena, eGrid *aGrid);
40
// gParser(const gGame *aGame, gArena *anArena, tControlledPTR<eGrid> aGrid);
41
/*Sorry, I just cant figure when you'd want to load without
42
validating, or revalidate a document. So I joined both
44
bool LoadAndValidateMapXML(char const *uri, FILE* docfd, char const * filepath );
45
void InstantiateMap(float sizeMultiplier);
48
bool trueOrFalse(char *str);
49
char *myxmlGetProp(xmlNodePtr cur, const char *name);
50
int myxmlGetPropInt(xmlNodePtr cur, const char *name);
51
float myxmlGetPropFloat(xmlNodePtr cur, const char *name);
52
bool myxmlGetPropBool(xmlNodePtr cur, const char *name);
53
void myxmlGetDirection(xmlNodePtr cur, float &x, float &y);
55
// bool isElement(const xmlChar *elementName, const xmlChar *searchedElement);
56
bool isElement(const xmlChar *elementName, const xmlChar *searchedElement, const xmlChar * keyword = NULL);
57
bool isValidAlternative(xmlNodePtr cur, const xmlChar * keyword = NULL);
58
void processSubAlt(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
59
bool isValidCodeName(const xmlChar *version);
60
bool isValidDotNumber(const xmlChar *version);
61
bool validateVersionSubRange(const xmlChar *subRange, const xmlChar *codeName, const xmlChar *dotVersion);
62
bool xmlCharSearchReplace(xmlChar *&original, const xmlChar * searchPattern, const xmlChar * replace);
63
int validateVersionRange(xmlChar *version, const xmlChar * codeName, const xmlChar * dotVersion);
64
void endElementAlternative(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
66
void parseAxes(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
67
void parseSpawn(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
68
void parseZone(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
69
void parseWall(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
71
bool parseShapeCircle(eGrid *grid, xmlNodePtr cur, float &x, float &y, float &radius, float &growth, const xmlChar * keyword);
73
void parseField(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
74
void parseWorld(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
75
void parseMap(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
77
void parseSettings(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
78
void parseSetting(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
80
void parseAlternativeContent(eGrid *grid, xmlNodePtr cur);
81
/* Experimental features*/
82
void parseWallLine(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
83
void parseWallRect(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
84
void parseObstacleWall(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
86
/* This is a hack that will bring shame to my decendants for many generations: */
90
#endif //ArmageTron_PARSER_H