void SharedTangibleObjectTemplate::parseFileData(IffStream* iffStream) { iffStream->openChunk('PCNT'); int variableCount = iffStream->getInt(); iffStream->closeChunk('PCNT'); for (int i = 0; i < variableCount; ++i) { Chunk* chunk = iffStream->openChunk(); if (chunk == NULL) continue; if (chunk->getChunkID() == 'XXXX') { String varName; chunk->readString(varName); parseVariableData(varName, chunk); } else { Logger::console.error("WTF AM I OPENING AGAIN"); } iffStream->closeChunk(); } }
void PlayerCreatureTemplate::readObject(LuaObject* templateData) { SharedCreatureObjectTemplate::readObject(templateData); lua_State* L = templateData->getLuaState(); if (!templateData->isValidTable()) return; int i = 0; lua_pushnil(L); while (lua_next(L, -2) != 0) { // 'key' is at index -2 and 'value' at index -1 //printf("%s - %s\n", // lua_tostring(L, -2), lua_typename(L, lua_type(L, -1))); int type = lua_type(L, -2); if (type == LUA_TSTRING) { size_t len = 0; const char* varName = lua_tolstring(L, -2, &len); parseVariableData(varName, templateData); } else { lua_pop(L, 1); } ++i; } return; }
void SharedWeaponObjectTemplate::parseFileData(IffStream* iffStream) { iffStream->openChunk('PCNT'); int variableCount = iffStream->getInt(); iffStream->closeChunk('PCNT'); for (int i = 0; i < variableCount; ++i) { //while (iffStream->getRemainingSubChunksNumber() > 0) { Chunk* chunk = iffStream->openChunk('XXXX'); if (chunk == NULL) continue; String varName; iffStream->getString(varName); //std::cout << "parsing wtf shit:[" << varName.toStdString() << "]\n"; parseVariableData(varName, chunk); iffStream->closeChunk(); } }
/** * @brief Parses a variable assignment block. */ int GdbMiParser::parseVariableData(TreeNode *thisNode, QList<Token*> *tokenList) { Token *token; TreeNode *childNode = NULL; int rc = 0; if(tokenList->isEmpty()) return -1; // Take the first item token = tokenList->takeFirst(); assert(token != NULL); if(token == NULL) return -1; if(token->getType() == Token::KEY_LEFT_BRACE) { do { // Double braces? if(tokenList->isEmpty()) return -1; Token *token2 = tokenList->first(); if(token2->getType() == Token::KEY_LEFT_BRACE) { rc = parseVariableData(thisNode, tokenList); token = tokenList->takeFirst(); } else { // Get name QString name; if(tokenList->isEmpty()) return -1; Token *nameTok = tokenList->takeFirst(); assert(nameTok != NULL); name = nameTok->getString(); // Is it a "static varType" type? if(tokenList->isEmpty()) return -1; Token *extraNameTok = tokenList->first(); if(extraNameTok->getType() == Token::VAR) { extraNameTok = tokenList->takeFirst(); name += " " + extraNameTok->getString(); } // Get equal sign if(tokenList->isEmpty()) return -1; Token *eqToken = tokenList->first(); assert(eqToken != NULL); if(eqToken->getType() == Token::KEY_EQUAL) { eqToken = tokenList->takeFirst(); // Create treenode childNode = new TreeNode; childNode->setName(name); thisNode->addChild(childNode); // Get variable data rc = parseVariableData(childNode, tokenList); // End of the data token = tokenList->takeFirst(); } else if(eqToken->getType() == Token::KEY_COMMA) { token = tokenList->isEmpty() ? NULL : tokenList->takeFirst(); } else if(eqToken->getType() == Token::KEY_RIGHT_BRACE) { if(thisNode->getChildCount() == 0) thisNode->setData(nameTok->getString()); // Triggered by for example: "'{','<No data fields>', '}'" token = tokenList->isEmpty() ? NULL : tokenList->takeFirst(); } else { errorMsg("Unknown token. Expected '=', Got:'%s'", stringToCStr(eqToken->getString())); // End of the data token = tokenList->isEmpty() ? NULL : tokenList->takeFirst(); } } }while(token != NULL && token->getType() == Token::KEY_COMMA); // if(token == NULL) errorMsg("Unexpected end of token"); else if (token->getType() != Token::KEY_RIGHT_BRACE) errorMsg("Unknown token. Expected '}', Got:'%s'", stringToCStr(token->getString())); } else { QString valueStr; QString defValueStr = token->getString(); thisNode->setAddress(defValueStr.toLongLong(0,0)); // Was the previous token only an address and the next token is the actual data? (Eg: '0x0001 "string"' ) if(tokenList->isEmpty()) return -1; Token *nextTok = tokenList->first(); while( nextTok->getType() == Token::VAR || nextTok->getType() == Token::C_STRING) { nextTok = tokenList->takeFirst(); if(nextTok->getType() == Token::C_STRING) valueStr = "\"" + nextTok->getString() + "\""; else { if(valueStr.isEmpty()) valueStr = nextTok->getString(); } nextTok = tokenList->isEmpty() ? NULL : tokenList->first(); if(nextTok == NULL) break; } if(valueStr.isEmpty()) valueStr = defValueStr; thisNode->setData(valueStr); } return rc; }
void SharedWeaponObjectTemplate::readObject(LuaObject* templateData) { SharedTangibleObjectTemplate::readObject(templateData); lua_State* L = templateData->getLuaState(); if (!templateData->isValidTable()) return; int i = 0; lua_pushnil(L); while (lua_next(L, -2) != 0) { // 'key' is at index -2 and 'value' at index -1 //printf("%s - %s\n", // lua_tostring(L, -2), lua_typename(L, lua_type(L, -1))); int type = lua_type(L, -2); if (type == LUA_TSTRING) { size_t len = 0; const char* varName = lua_tolstring(L, -2, &len); parseVariableData(varName, templateData); } else lua_pop(L, 1); ++i; } //here goes server data only xpType = templateData->getStringField("xpType"); damageType = templateData->getIntField("damageType"); LuaObject certifications = templateData->getObjectField("certificationsRequired"); certificationsRequired.removeAll(); for (int i = 1; i <= certifications.getTableSize(); ++i) { certificationsRequired.add(certifications.getStringAt(i)); } certifications.pop(); creatureAccuracyModifiers.removeAll(); LuaObject accMods = templateData->getObjectField("creatureAccuracyModifiers"); for (int i = 1; i <= accMods.getTableSize(); ++i) { creatureAccuracyModifiers.add(accMods.getStringAt(i)); } accMods.pop(); creatureAimModifiers.removeAll(); LuaObject aimMods = templateData->getObjectField("creatureAimModifiers"); for (int i = 1; i <= aimMods.getTableSize(); ++i) { creatureAimModifiers.add(aimMods.getStringAt(i)); } aimMods.pop(); defenderDefenseModifiers.removeAll(); LuaObject defMods = templateData->getObjectField("defenderDefenseModifiers"); for (int i = 1; i <= defMods.getTableSize(); ++i) { defenderDefenseModifiers.add(defMods.getStringAt(i)); } defMods.pop(); damageModifiers.removeAll(); LuaObject dmgMods = templateData->getObjectField("damageModifiers"); for (int i = 1; i <= dmgMods.getTableSize(); ++i) { damageModifiers.add(dmgMods.getStringAt(i)); } dmgMods.pop(); speedModifiers.removeAll(); LuaObject speedMods = templateData->getObjectField("speedModifiers"); for (int i = 1; i <= speedMods.getTableSize(); ++i) { speedModifiers.add(speedMods.getStringAt(i)); } speedMods.pop(); defenderSecondaryDefenseModifiers.removeAll(); LuaObject secMods = templateData->getObjectField("defenderSecondaryDefenseModifiers"); for (int i = 1; i <= secMods.getTableSize(); ++i) defenderSecondaryDefenseModifiers.add(secMods.getStringAt(i)); secMods.pop(); defenderToughnessModifiers.removeAll(); LuaObject toughMods = templateData->getObjectField("defenderToughnessModifiers"); for (int i = 1; i <= toughMods.getTableSize(); ++i) defenderToughnessModifiers.add(toughMods.getStringAt(i)); toughMods.pop(); armorPiercing = templateData->getIntField("armorPiercing"); healthAttackCost = templateData->getIntField("healthAttackCost"); actionAttackCost = templateData->getIntField("actionAttackCost"); mindAttackCost = templateData->getIntField("mindAttackCost"); forceCost = templateData->getIntField("forceCost"); pointBlankAccuracy = templateData->getIntField("pointBlankAccuracy"); pointBlankRange = templateData->getIntField("pointBlankRange"); idealRange = templateData->getIntField("idealRange"); idealAccuracy = templateData->getIntField("idealAccuracy"); maxRange = templateData->getIntField("maxRange"); maxRangeAccuracy = templateData->getIntField("maxRangeAccuracy"); minDamage = templateData->getIntField("minDamage"); maxDamage = templateData->getIntField("maxDamage"); woundsRatio = templateData->getFloatField("woundsRatio"); area = templateData->getIntField("area"); attackSpeed = templateData->getFloatField("attackSpeed"); combatSpam = templateData->getStringField("combatSpam"); animationType = templateData->getStringField("animationType"); }
void SharedTangibleObjectTemplate::readObject(LuaObject* templateData) { SharedObjectTemplate::readObject(templateData); TemplateManager* templateManager = TemplateManager::instance(); lua_State* L = templateData->getLuaState(); if (!templateData->isValidTable()) return; int i = 0; lua_pushnil(L); while (lua_next(L, -2) != 0) { // 'key' is at index -2 and 'value' at index -1 //printf("%s - %s\n", // lua_tostring(L, -2), lua_typename(L, lua_type(L, -1))); int type = lua_type(L, -2); if (type == LUA_TSTRING) { size_t len = 0; const char* varName = lua_tolstring(L, -2, &len); parseVariableData(varName, templateData); } else lua_pop(L, 1); ++i; } /*LuaObject certifications = templateData->getObjectField("certificationsRequired"); for (int i = 1; i <= certifications.getTableSize(); ++i) { certificationsRequired.add(certifications.getStringAt(i)); } certifications.pop(); structureFootprint = templateManager->loadStructureFootprint(templateData->getStringField("structureFootprintFileName")); targetable = templateData->getByteField("targetable"); playerUseMask = templateData->getShortField("playerUseMask"); useCount = templateData->getIntField("useCount"); maxCondition = templateData->getIntField("maxCondition"); level = templateData->getIntField("level"); optionsBitmask = templateData->getIntField("optionsBitmask"); pvpStatusBitmask = templateData->getIntField("pvpStatusBitmask"); sliceable = templateData->getIntField("sliceable"); LuaObject numberExperimentalPropertiesList = templateData->getObjectField("numberExperimentalProperties"); for (int i = 1; i <= numberExperimentalPropertiesList.getTableSize(); ++i) { numberExperimentalProperties->add( numberExperimentalPropertiesList.getIntAt(i)); } numberExperimentalPropertiesList.pop(); LuaObject experimentalPropertiesList = templateData->getObjectField("experimentalProperties"); for (int i = 1; i <= experimentalPropertiesList.getTableSize(); ++i) { experimentalProperties->add(experimentalPropertiesList.getStringAt(i)); } experimentalPropertiesList.pop(); LuaObject experimentalWeightsList = templateData->getObjectField("experimentalWeights"); for (int i = 1; i <= experimentalWeightsList.getTableSize(); ++i) { experimentalWeights->add(experimentalWeightsList.getIntAt(i)); } experimentalWeightsList.pop(); LuaObject experimentalGroupTitlesList = templateData->getObjectField("experimentalGroupTitles"); for (int i = 1; i <= experimentalGroupTitlesList.getTableSize(); ++i) { experimentalGroupTitles->add(experimentalGroupTitlesList.getStringAt(i)); } experimentalGroupTitlesList.pop(); LuaObject experimentalSubGroupTitlesList = templateData->getObjectField("experimentalSubGroupTitles"); for (int i = 1; i <= experimentalSubGroupTitlesList.getTableSize(); ++i) { experimentalSubGroupTitles->add( experimentalSubGroupTitlesList.getStringAt(i)); } experimentalSubGroupTitlesList.pop(); LuaObject experimentalMinList = templateData->getObjectField("experimentalMin"); for (int i = 1; i <= experimentalMinList.getTableSize(); ++i) { experimentalMin->add(experimentalMinList.getIntAt(i)); } experimentalMinList.pop(); LuaObject experimentalMaxList = templateData->getObjectField("experimentalMax"); for (int i = 1; i <= experimentalMaxList.getTableSize(); ++i) { experimentalMax->add(experimentalMaxList.getIntAt(i)); } experimentalMaxList.pop(); LuaObject experimentalPrecisionList = templateData->getObjectField("experimentalPrecision"); for (int i = 1; i <= experimentalPrecisionList.getTableSize(); ++i) { experimentalPrecision->add(experimentalPrecisionList.getIntAt(i)); } experimentalPrecisionList.pop();*/ // Add experimental properties groups to the draft schematic uint32 weightIterator = 0; String subtitle = ""; resourceWeights->removeAll(); for (uint32 i = 0; i < numberExperimentalProperties->size(); i++) { ResourceWeight* newWeight = new ResourceWeight(); newWeight->addProperties(experimentalGroupTitles->get(i), experimentalSubGroupTitles->get(i), experimentalMin->get(i), experimentalMax->get(i), experimentalPrecision->get(i), experimentalCombineType->get(i)); for (uint32 j = 0; j < numberExperimentalProperties->get(i); j++) { newWeight->addWeight(experimentalProperties->get(weightIterator), experimentalWeights->get(weightIterator)); weightIterator++; } resourceWeights->add(newWeight); } }