void TestDefinesAndIncludes::loadSimpleProject() { s_currentProject = ProjectsGenerator::GenerateSimpleProject(); QVERIFY( s_currentProject ); auto manager = IDefinesAndIncludesManager::manager(); QVERIFY( manager ); const auto actualIncludes = manager->includes( s_currentProject->projectItem(), IDefinesAndIncludesManager::UserDefined ); const auto actualDefines = manager->defines( s_currentProject->projectItem(), IDefinesAndIncludesManager::UserDefined ); qDebug() << actualDefines << actualIncludes; QCOMPARE( actualIncludes, Path::List() << Path( "/usr/include/mydir") ); Defines defines; defines.insert( "_DEBUG", "" ); defines.insert( "VARIABLE", "VALUE" ); QCOMPARE( actualDefines, defines ); }
spriteDesc newSpriteDialog::getSpriteDesc(QString type) { spriteDesc result; QDir dir; dir.setPath("data/sprites/"); QStringList filters; filters << "*.sprite"; dir.setNameFilters(filters); QStringList files = dir.entryList(); for (int i=0; i<files.count(); i++) { QString str = files.at(i); Defines d; d.Load("data/sprites/"+str); if (type == d.Get("registername")) { result.h = d.Get("h").toInt(); result.w = d.Get("w").toInt(); result.animations = d.GetList("animationlist"); return result; } } return result; }
//--------------------------------------------------------------------------- AIRandomMoveTank::AIRandomMoveTank(GameManager *mgr, FastBitmap *c, String profile) : CustomPlayerTank(mgr,c,profile) { Defines d; d.Load("userdata\\"+profile); int cnt=0; movingValues[0]=StrToInt(d.Get("mv_u")); cnt+=movingValues[0]; movingValues[1]=StrToInt(d.Get("mv_l")); cnt+=movingValues[1]; movingValues[2]=StrToInt(d.Get("mv_r")); cnt+=movingValues[2]; movingValues[3]=StrToInt(d.Get("mv_d")); cnt+=movingValues[3]; movingValuesSum = cnt; lasttimeChangedMove = 0; changeTime = StrToInt(d.Get("mv_t")); ccTime = random(changeTime)+changeTime/2; scoreForKill = StrToInt(d.Get("score")); team = TEAM_AI; type = TYPE_AI_TANK; }
// Pre-Processamento: // Remove os comentarios e linhas em branco // E coloca o codigo numa estrutura do tipo CodeLines // Tambem verifica os labels e equs e ifs void readAndPreProcess (const char* fileName) { ifstream infile(fileName); string line; int textMemAddr = textStartAddress; int dataMemAddr = 0; int BSSMemAddr = 0; stringstream tempSS; CodeSection codeSection = NONE; // Le linha a linha for (int lineCount = 1; getline(infile, line); ++lineCount) { // Troca virgulas por espaco strReplace(line, ",", " "); // Ignora linhas em branco if (line.empty()) continue; // Pega palavra a palavra de acordo com os espacos istringstream iss(line); string tempStr; while (iss >> tempStr) { if ("SECTION" == tempStr) { string tempStr2; iss >> tempStr2; if ("TEXT" == tempStr2) codeSection = TEXT; else if ("DATA" == tempStr2) codeSection = DATA; codeLines[lineCount].push_back(tempStr); codeLines[lineCount].push_back(tempStr2); continue; } // Ignora comentarios if (";" == tempStr.substr(0,1)) break; // Desconsidera o caso (maiusculas/minusculas) transform(tempStr.begin(), tempStr.end(), tempStr.begin(), ::toupper); // Ve se eh um label / define if (":" == tempStr.substr(tempStr.length() - 1, 1)) { // Ve se ainda restam tokens na linha if (iss.rdbuf()->in_avail() != 0) { // Remove o ':' tempStr = tempStr.substr(0, tempStr.length() - 1); string tempStr2; iss >> tempStr2; // Ve se o proximo token eh EQU if ("EQU" == tempStr2) { string tempStr3; iss >> tempStr3; // Se define já existe if (defines.find(tempStr3) != defines.end()){ tempSS << lineCount; errors.push("ERRO NA LINHA " + tempSS.str() + ": EQU ja declarado."); tempSS.str(""); } else { // Coloca o valor do EQU na tabela de defines defines[tempStr] = tempStr3; } // Se nao eh so um label // Com algo a mais na mesma linha } else { if ( (labels.find(tempStr) != labels.end()) || (dataLabels.find(tempStr) != dataLabels.end()) ){ tempSS << lineCount; errors.push("ERRO NA LINHA " + tempSS.str() + ": Label ja declarado."); tempSS.str(""); } else { // Adiciona na tabela de labels if(codeSection == TEXT){ labels[tempStr] = textMemAddr; } else if (codeSection == DATA) { dataLabels[tempStr] = dataMemAddr; dataMemAddr += 4; } } // Adiciona endereco de memoria if (instructions.find(tempStr2) != instructions.end()) textMemAddr += get<3>(instructions[tempStr2]); // Adiciona os tokens ao vetor codeLines[lineCount].push_back(tempStr+":"); codeLines[lineCount].push_back(tempStr2); } // Se nao eh um label "sozinho" // Adiciona no vetor } else {
//--------------------------------------------------------------------------- CustomPlayerTank::CustomPlayerTank(GameManager *mgr, FastBitmap *c, String profileFilename) : PlayerTank(mgr,c) { Defines profile; profile.Load("userdata\\"+profileFilename); delete sprite; SpriteFabric * sf = SpriteFabric::getInstance(); sprite = sf->SFM_CURRENT(profile.Get("sprite"),context); attackCoolDown = StrToInt(profile.Get("as")); speed = StrToInt(profile.Get("speed")); dmgmin = StrToInt(profile.Get("dmgmin")); dmgmax = StrToInt(profile.Get("dmgmax")); bulletSpeed = StrToInt(profile.Get("bulletspeed")); bulletType = StrToInt(profile.Get("bullettype")); maxhp = hp = StrToInt(profile.Get("maxhp")); typeResist = StrToInt(profile.Get("typeresist")); valueResist = StrToInt(profile.Get("valueresist")); pen[0] = StrToInt(profile.Get("concretepen")); pen[1] = StrToInt(profile.Get("brickpen")); pen[2] = StrToInt(profile.Get("tankpen")); }