00001
00002 #ifndef ArmageTron_PARSER_H
00003 #define ArmageTron_PARSER_H
00004
00005 #include "defs.h"
00006 #include "tXmlParser.h"
00007 #include "eCoord.h"
00008 #include "tValue.h"
00009 #include <map>
00010 #include <string>
00011
00012 class eGrid;
00013 class gArena;
00014 class ePoint;
00015 class gGame;
00016 class gWallRim;
00017
00018 #ifdef ENABLE_ZONESV2
00019 #include "zone/zZone.h"
00020 #include "zone/zMisc.h"
00021 #endif
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class gParser : public tXmlResource {
00036
00037 gArena *theArena;
00038 eGrid *theGrid;
00039
00040 REAL rimTexture;
00041
00042 ePoint * DrawRim( eGrid * grid, ePoint * start, eCoord const & stop, REAL h=10000 );
00043
00044 public:
00045 gParser(gArena *anArena, eGrid *aGrid);
00046
00047 void setSizeMultiplier(REAL aSizeMultiplier);
00048 void Parse();
00049 #ifdef ENABLE_ZONESV2
00050 zMonitorPtr getMonitor(string monitorName);
00051 #endif
00052
00053 protected:
00054 bool trueOrFalse(char *str);
00055 char *myxmlGetProp(xmlNodePtr cur, const char *name);
00056 int myxmlGetPropInt(xmlNodePtr cur, const char *name);
00057 float myxmlGetPropFloat(xmlNodePtr cur, const char *name);
00058 bool myxmlGetPropBool(xmlNodePtr cur, const char *name);
00059 #ifdef ENABLE_ZONESV2
00060 Triad myxmlGetPropTriad(xmlNodePtr cur, const char *name);
00061 rColor myxmlGetPropColorFromHex(xmlNodePtr cur, const char *name);
00062 #endif
00063 void myxmlGetDirection(xmlNodePtr cur, float &x, float &y);
00064
00065
00066 bool isElement(const xmlChar *elementName, const xmlChar *searchedElement, const xmlChar * keyword = NULL);
00067 bool isValidAlternative(xmlNodePtr cur, const xmlChar * keyword = NULL);
00068 void processSubAlt(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
00069 bool isValidCodeName(const xmlChar *version);
00070 bool isValidDotNumber(const xmlChar *version);
00071 bool validateVersionSubRange(const xmlChar *subRange, const xmlChar *codeName, const xmlChar *dotVersion);
00072 bool xmlCharSearchReplace(xmlChar *&original, const xmlChar * searchPattern, const xmlChar * replace);
00073 int validateVersionRange(xmlChar *version, const xmlChar * codeName, const xmlChar * dotVersion);
00074 void endElementAlternative(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00075
00076 void parseAxes(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00077 void parseSpawn(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00078 void parseZone(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00079 bool parseZoneArthemis_v1(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00080 #ifdef ENABLE_ZONESV2
00081 void parseZoneArthemis_v2(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00082 void parseZoneBachus(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00083 rColor parseColor(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00084 #endif
00085
00086 void parseWall(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00087
00088 #ifdef ENABLE_ZONESV2
00089 zShapePtr parseShapeCircleArthemis(eGrid *grid, xmlNodePtr cur, short unsigned int idZone, const xmlChar * keyword);
00090 zShapePtr parseShapeCircleBachus(eGrid *grid, xmlNodePtr cur, short unsigned int idZone, const xmlChar * keyword);
00091 zShapePtr parseShapePolygon(eGrid *grid, xmlNodePtr cur, short unsigned int idZone, const xmlChar * keyword);
00092 void parseShape(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword, zShapePtr &shape);
00093 void parseMonitor(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00094
00095 zEffectGroupPtr parseZoneEffectGroup(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00096 zMonitorInfluencePtr parseZoneEffectGroupMonitor(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00097 zEffectorPtr parseZoneEffectGroupEffector(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00098 zSelectorPtr parseZoneEffectGroupSelector(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00099 zValidatorPtr parseZoneEffectGroupValidator(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00100 zZoneInfluencePtr parseZoneEffectGroupZone(eGrid * grid, xmlNodePtr cur, const xmlChar * keyword);
00101
00102 typedef std::map<string, std::set<string> > TeamOwnershipInfo;
00103 typedef std::map<string, std::set<string> >::value_type TeamOwnershipInfoType;
00104 void parseOwnership(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00105 void parseTeamOwnership(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword, TeamOwnershipInfo & team);
00106 #endif
00107 bool parseShapeCircle(eGrid *grid, xmlNodePtr cur, float &x, float &y, float &radius, float &growth, const xmlChar *keyword);
00108
00109 void parseField(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00110 void parseWorld(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
00111 void parseMap(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
00112
00113 void parseSettings(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword = NULL);
00114 void parseSetting(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00115
00116 void parseAlternativeContent(eGrid *grid, xmlNodePtr cur);
00117
00118 void parseWallLine(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00119 void parseWallRect(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00120 void parseObstacleWall(eGrid *grid, xmlNodePtr cur, const xmlChar * keyword);
00121
00122 #ifdef ENABLE_ZONESV2
00123 void myCheapParameterSplitter(const string &str, tFunction &tf, bool addSizeMultiplier=false);
00124 void myCheapParameterSplitter2(const string &str, tPolynomial<nMessage> &tp, bool addSizeMultiplier=false);
00125 #endif
00126
00127
00128 float sizeMultiplier;
00129 #ifdef ENABLE_ZONESV2
00130 int currentFormat;
00131 public:
00132 tValue::Expr::varmap_t vars;
00133 tValue::Expr::funcmap_t functions;
00134 #endif
00135 };
00136
00137 #endif //ArmageTron_PARSER_H
00138