bool LumpRemapper::LoadMap() { if(loaded) return true; if(Wads.GetNumLumps() == 0) return false; int lump = Wads.GetNumForName(mapLumpName); if(lump == -1) { printf("\n"); return false; } FWadLump mapLump = Wads.OpenLumpNum(lump); char* mapData = new char[Wads.LumpLength(lump)]; mapLump.Read(mapData, Wads.LumpLength(lump)); Scanner sc(mapData, Wads.LumpLength(lump)); sc.SetScriptIdentifier(Wads.GetLumpFullName(lump)); delete[] mapData; ParseMap(sc); loaded = true; return true; }
void MessagePackReader::ParseMap32() { log_trace(); unsigned length; if (is_.Read( reinterpret_cast<char*>(&length), 4 ) != 4) anyrpc_throw(AnyRpcErrorTermination, "Parsing was terminated"); length = _msgpack_be32( length ); ParseMap( length ); }
void MessagePackReader::ParseMap16() { log_trace(); unsigned short length; if (is_.Read( reinterpret_cast<char*>(&length), 2 ) != 2) anyrpc_throw(AnyRpcErrorTermination, "Parsing was terminated"); length = _msgpack_be16( length ); // compiling for mingw had problem when this was combined with the next line ParseMap( length ); }
void SceneLevel::init() { if (inited) return; ParseMap("media/maps/map2.txt"); ObjectsFactory * fact = ObjectsFactory::instance(); player = fact->get_player(); //enemy = fact->get_enemy(0); //GameObject* panel1 = new PanelModel(0, Vector3(-3.5, 0.0, 0), 0.7); //GameObject* panel2 = new PanelModel(1, Vector3(3.5, 0.0, 0), 0.7); //GameObject* floor = new PlainModel(2, 0.7); //GameObject* box1 = new BoxModel(3, Vector3(2.5, 1.0, 2.5), 1); //player = new PlayerModel(4); bullet = new BulletModel(5, Vector3(1.0, 1.0, 1.0)); //enemy = new EnemyModel(6); //game_objects.push_back(panel1); //game_objects.push_back(panel2); //game_objects.push_back(floor); //game_objects.push_back(box1); //game_objects.push_back(player); //game_objects.push_back(bullet); //game_objects.push_back(enemy); camera = new Camera(player, 1.2); camera->set_behind(); //camera->set_infront(); //camera->set_ontop(); //game_objects, &plane, &cData, camera //fact->add_obstacle(panel1); //fact->add_obstacle(panel2); //fact->add_obstacle(floor); //fact->add_obstacle(box1); //fact->add_player(player); //fact->add_enemy(enemy); fact->add_bulet(bullet); fact->add_camera(camera); fact->set_plane(&plane); fact->set_collision_data(&cData); set_init(); lstatus = LevelStatus::PLAY; };
void LumpRemapper::LoadMap(const char* name, const char* data, unsigned int length) { if(loaded) return; Scanner sc(data, length); sc.SetScriptIdentifier(name); ParseMap(sc); loaded = true; }
static void ParseMapInfo(VScriptParser* sc) { guard(ParseMapInfo); bool HexenMode = false; // Set up default map info. mapInfo_t Default; SetMapDefaults(Default); while (!sc->AtEnd()) { if (sc->Check("map")) { ParseMap(sc, HexenMode, Default); } else if (sc->Check("defaultmap")) { SetMapDefaults(Default); ParseMapCommon(sc, &Default, HexenMode); } else if (sc->Check("adddefaultmap")) { ParseMapCommon(sc, &Default, HexenMode); } else if (sc->Check("clusterdef")) { ParseClusterDef(sc); } else if (sc->Check("episode")) { ParseEpisodeDef(sc); } else if (sc->Check("clearepisodes")) { EpisodeDefs.Clear(); } else if (sc->Check("skill")) { ParseSkillDef(sc); } else if (sc->Check("clearskills")) { SkillDefs.Clear(); } else { sc->Error(va("Invalid command %s", *sc->String)); } } delete sc; sc = NULL; unguard; }
void JsonReader::ParseValue() { log_trace(); // Look at the next character to determine the type of parsing to perform switch (is_.Peek()) { case 'n': ParseNull(); break; case 't': ParseTrue(); break; case 'f': ParseFalse(); break; case '"': ParseString(); break; case '{': ParseMap(); break; case '[': ParseArray(); break; default : ParseNumber(); } }
BOOL CMapInfo::SetIdent( LPCTSTR lpszMapIdent ) { GEOPOINT pt; GEOSIZE sz; long scale; m_strMapIdent = lpszMapIdent; if( MPT_INVALID != m_mapType && ParseMap( lpszMapIdent, m_mapType, pt, sz, scale ) ) { m_btmleftOfMap = pt; m_sizeOfMap = sz; m_scale = scale; m_gcpArray[0].m_ptGeoCoord.X = pt.X; m_gcpArray[0].m_ptGeoCoord.Y = pt.Y; m_gcpArray[1].m_ptGeoCoord.X = pt.X + sz.dX; m_gcpArray[1].m_ptGeoCoord.Y = pt.Y; m_gcpArray[2].m_ptGeoCoord.X = pt.X + sz.dX; m_gcpArray[2].m_ptGeoCoord.Y = pt.Y + sz.dY; m_gcpArray[3].m_ptGeoCoord.X = pt.X; m_gcpArray[3].m_ptGeoCoord.Y = pt.Y + sz.dY; return TRUE; } return FALSE; }
BOOL CMapInfo::SetType( TOPOMAPTYPE mapType ) { GEOPOINT pt; GEOSIZE sz; long scale; m_mapType = mapType; if( !m_strMapIdent.IsEmpty() && ParseMap( m_strMapIdent, mapType, pt, sz, scale ) ) { m_btmleftOfMap = pt; m_sizeOfMap = sz; m_scale = scale; m_gcpArray[0].m_ptGeoCoord.X= pt.X; m_gcpArray[0].m_ptGeoCoord.Y = pt.Y; m_gcpArray[1].m_ptGeoCoord.X = pt.X + sz.dX; m_gcpArray[1].m_ptGeoCoord.Y = pt.Y; m_gcpArray[2].m_ptGeoCoord.X = pt.X + sz.dX; m_gcpArray[2].m_ptGeoCoord.Y = pt.Y + sz.dY; m_gcpArray[3].m_ptGeoCoord.X = pt.X; m_gcpArray[3].m_ptGeoCoord.Y = pt.Y + sz.dY; return TRUE; } return FALSE; }
void MQuestScenarioCatalogue::ParseStandardScenario(MXmlElement& element) { char szTemp[256]=""; int n = 0; char szAttrValue[256]; char szAttrName[64]; char szTagName[128]; MQuestScenarioInfo* pScenarioInfo = new MQuestScenarioInfo(); pScenarioInfo->bSpecialScenario = false; int nAttrCount = element.GetAttributeCount(); for (int i = 0; i < nAttrCount; i++) { element.GetAttribute(i, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_TITLE)) { strcpy_safe(pScenarioInfo->szTitle, szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_QL)) { pScenarioInfo->nQL = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_DC)) { pScenarioInfo->fDC = (float)atof(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_MAPSET)) { pScenarioInfo->nMapSet = QuestMapNameToID(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_XP)) { pScenarioInfo->nXPReward = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_BP)) { pScenarioInfo->nBPReward = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_SECTOR_XP)) { pScenarioInfo->nSectorXP = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_SECTOR_BP)) { pScenarioInfo->nSectorBP = atoi(szAttrValue); } } int iChildCount = element.GetChildNodeCount(); MXmlElement chrElement; for (int i = 0; i < iChildCount; i++) { chrElement = element.GetChildNode(i); chrElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!_stricmp(szTagName, MTOK_SCENARIO_SACRI_ITEM)) { ParseSacriItem(chrElement, pScenarioInfo); } else if (!_stricmp(szTagName, MTOK_SCENARIO_REWARD_ITEM)) { ParseRewardItem(chrElement, pScenarioInfo); } else if (!_stricmp(szTagName, MTOK_SCENARIO_MAP)) { ParseMap(chrElement, pScenarioInfo); } } pScenarioInfo->nID = CalcStandardScenarioID(pScenarioInfo->nMapSet, pScenarioInfo->nQL); Insert(pScenarioInfo); }
/* GetEnds * * Get the location where the boxes are to be moved. */ uint8_t GetEnds(uint8_t levelIndex, uint8_t *endpos) { return ParseMap(levelIndex,EndMap,endpos); }
/* GetBoxes * * Copy an array of box positions within our level. These are the initial * box positions. This assumes the boxpos array is at least MAXBOXES in size */ uint8_t GetBoxes(uint8_t levelIndex, uint8_t *boxpos) { return ParseMap(levelIndex,BoxMap,boxpos); }
LLSDValue Parser::Parse(ticpp::Node * node, bool returnEmpty) { if(!node) { boost::throw_exception(SyntaxException("LLSD XML ERROR")); } if(node->Type() != TiXmlNode::ELEMENT || node->Type() == TiXmlNode::TEXT) { if(returnEmpty) { return LLSDValue(); } return Parse(node->NextSibling()); } std::string nodeN = node->Value(); if(LookupTable.count(nodeN) > 0) { LLSDValue result; ticpp::Node * tmp = node->FirstChild(false); switch(LookupTable[nodeN]) { case LLSDValue::VT_INTEGER: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_INTEGER, tmp->Value()); } else { result = Int32(0); } return result; case LLSDValue::VT_REAL: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_REAL, tmp->Value()); } else { result = Real64(0); } return result; case LLSDValue::VT_STRING: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_STRING, tmp->Value()); } else { result = ""; } return result; case LLSDValue::VT_DATE: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_DATE, tmp->Value()); } else { result = LLDate(); } return result; case LLSDValue::VT_UUID: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_UUID, tmp->Value()); } else { result = LLUUID::Zero; } return result; case LLSDValue::VT_BOOLEAN: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result.xml_decode(LLSDValue::VT_BOOLEAN, tmp->Value()); } else { result = false; } return result; case LLSDValue::VT_BINARY: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result = base64_decode<LLSDValue::Binary>(tmp->Value()); } else { result = LLSDValue::Binary(); } return result; case LLSDValue::VT_URI: if(tmp && tmp->Type() == TiXmlNode::TEXT) { result = LLURI(tmp->Value()); } else { result = LLURI(); } return result; case LLSDValue::VT_MAP: return ParseMap(node); case LLSDValue::VT_ARRAY: return ParseArray(node); case LLSDValue::VT_UNDEF: default: return result; } } ticpp::Iterator<ticpp::Node> elems; for(elems = elems.begin(node); elems != elems.end(); ++elems) { return Parse(elems.Get()); } return LLSDValue(); }
int YamlHelper::ParseMap(MapYaml& mapYaml) { mapYaml.clear(); const char*& pValue = (const char*&) m_newEvent.data.scalar.value; bool bKey = true; char* pKey = NULL; int res = 1; bool bDone = false; while (!bDone) { GetNextEvent(true); switch(m_newEvent.type) { case YAML_STREAM_END_EVENT: res = 0; bDone = true; break; case YAML_MAPPING_START_EVENT: { MapValue mapValue; mapValue.value = ""; mapValue.subMap = new MapYaml; mapYaml[std::string(pKey)] = mapValue; res = ParseMap(*mapValue.subMap); if (!res) throw std::string("ParseMap: premature end of file during map parsing"); bKey = true; // possibly more key,value pairs in this map } break; case YAML_MAPPING_END_EVENT: bDone = true; break; case YAML_SCALAR_EVENT: if (bKey) { pKey = _strdup(pValue); } else { MapValue mapValue; mapValue.value = pValue; mapValue.subMap = NULL; mapYaml[std::string(pKey)] = mapValue; delete [] pKey; pKey = NULL; } bKey = bKey ? false : true; break; case YAML_SEQUENCE_START_EVENT: case YAML_SEQUENCE_END_EVENT: throw std::string("ParseMap: Sequence event unsupported"); } } if (pKey) delete [] pKey; return res; }
Map *MapLoader::Load(const std::string &name) { auto data = FileReadString(this->prefix+name); return ParseMap(data); }
nsresult nsMorkReader::Read(nsIFile *aFile) { nsCOMPtr<nsIFileInputStream> stream = do_CreateInstance(NS_LOCALFILEINPUTSTREAM_CONTRACTID); NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE); nsresult rv = stream->Init(aFile, PR_RDONLY, 0, 0); NS_ENSURE_SUCCESS(rv, rv); mStream = do_QueryInterface(stream); NS_ASSERTION(mStream, "file input stream must impl nsILineInputStream"); nsCLineString line; rv = ReadLine(line); if (!line.EqualsLiteral("// <!-- <mdb:mork:z v=\"1.4\"/> -->")) { return NS_ERROR_FAILURE; // unexpected file format } IndexMap columnMap; NS_ENSURE_TRUE(columnMap.Init(), NS_ERROR_OUT_OF_MEMORY); while (NS_SUCCEEDED(ReadLine(line))) { // Trim off leading spaces PRUint32 idx = 0, len = line.Length(); while (idx < len && line[idx] == ' ') { ++idx; } if (idx >= len) { continue; } const nsCSubstring &l = Substring(line, idx); // Look at the line to figure out what section type this is if (StringBeginsWith(l, NS_LITERAL_CSTRING("< <(a=c)>"))) { // Column map. We begin by creating a hash of column id to column name. StringMap columnNameMap; NS_ENSURE_TRUE(columnNameMap.Init(), NS_ERROR_OUT_OF_MEMORY); rv = ParseMap(l, &columnNameMap); NS_ENSURE_SUCCESS(rv, rv); // Now that we have the list of columns, we put them into a flat array. // Rows will have value arrays of the same size, with indexes that // correspond to the columns array. As we insert each column into the // array, we also make an entry in columnMap so that we can look up the // index given the column id. mColumns.SetCapacity(columnNameMap.Count()); AddColumnClosure closure(&mColumns, &columnMap); columnNameMap.EnumerateRead(AddColumn, &closure); if (NS_FAILED(closure.result)) { return closure.result; } } else if (StringBeginsWith(l, NS_LITERAL_CSTRING("<("))) { // Value map rv = ParseMap(l, &mValueMap); NS_ENSURE_SUCCESS(rv, rv); } else if (l[0] == '{' || l[0] == '[') { // Table / table row rv = ParseTable(l, columnMap); NS_ENSURE_SUCCESS(rv, rv); } else { // Don't know, hopefully don't care } } return NS_OK; }