예제 #1
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::pasteFile (QString filename, int atX, int atY)
{
    QFile file(filename);
    if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
    QTextStream in(&file);
    setRules(0x8,0xC);
    while (! in.atEnd()) {
        QString line = in.readLine();
        if (line.isEmpty()) continue; // always ignore completely empty lines
        else if (line.startsWith('#')) {
            if (line.startsWith("#R"))
                continue; // TODO: process rules
            else if (reCellBlock.exactMatch(line))
                pasteStart(atX + reCellBlock.cap(1).toInt(),
                           atY + reCellBlock.cap(2).toInt());
            else if (line.startsWith("#C") || line.startsWith("#C"))
                continue; // TODO: keep comments somewhere
        }
        else if (line.startsWith('!')) { // dblife-style comments
            continue; // TODO: keep comments somewhere
        }
        else if (reRLEstart.exactMatch(line)) {
            if (!reRLEstart.cap(3).isEmpty()) setRules(reRLEstart.cap(3).cStr());
            pasteStart(atX, atY);
            while (!in.atEnd())
                if (pasteRLEX_add(in.readLine())) break;
            break;
        }
        else pasteLIFE_add(line);
    }
    file.close();
}
예제 #2
0
파일: Edge.cpp 프로젝트: Tisseo/synthese
		Edge::Edge(
			Path* parentPath,
			size_t rankInPath,
			Vertex* fromVertex,
			double metricOffset
		):	Registrable(0),
			_fromVertex(fromVertex),
			_parentPath (parentPath),
			_metricOffset(metricOffset),
			_rankInPath (rankInPath),
			_previous(NULL),
			_previousConnectionDeparture(NULL),
			_previousDepartureForFineSteppingOnly(NULL),
			_followingConnectionArrival(NULL),
			_followingArrivalForFineSteppingOnly(NULL),
			_next(NULL),
			_departureIndex(INDICES_NUMBER),
			_arrivalIndex(INDICES_NUMBER),
			_serviceIndexUpdateNeeded (true),
			_RTserviceIndexUpdateNeeded(true)
		{
			// Default accessibility
			RuleUser::Rules rules(RuleUser::GetEmptyRules());
			rules[USER_PEDESTRIAN - USER_CLASS_CODE_OFFSET] = AllowedUseRule::INSTANCE.get();
			rules[USER_BIKE - USER_CLASS_CODE_OFFSET] = AllowedUseRule::INSTANCE.get();
			rules[USER_HANDICAPPED - USER_CLASS_CODE_OFFSET] = AllowedUseRule::INSTANCE.get();
			rules[USER_CAR - USER_CLASS_CODE_OFFSET] = AllowedUseRule::INSTANCE.get();
			setRules(rules);
		}
예제 #3
0
//parse received data buffer and update values
//1 -> next 2 bytes are rules
//2 -> next byte is number of states
//3 -> next 6 bytes are colors
//4 -> disable mic
//5 -> enable mic
static void parseBuffer(){
	seqNum = comBuf[0];
	int i = 1;
	uint8_t numBytes = bitsRcvd/8;
	while(i<numBytes){
		if(comBuf[i]==1){
			if(i+2<numBytes){
				setRules(comBuf[i+1],comBuf[i+2]); 
			}
			i+=3;
		}else if(comBuf[i]==2){
			if(i+1<numBytes){
				setNumStates(comBuf[i+1]);
			}
			i+=2;
		}else if(comBuf[i]==3){
			if(i+6<numBytes){
				setColors(comBuf+i+1);
			}
			i+=7;
		}else if(comBuf[i]==4){
			soundEn = 0;
			i++;
		}else if(comBuf[i]==5){
			soundEn = 1;
			i++;
		}else{
			i++;
		}
	}
}
예제 #4
0
c_Square::c_Square(const int &x_pos, const int &y_pos, const int &length, const int &width, const int &ID)
{
    visited = false;
    moveUp = false;
    moveDown = false;
    moveLeft = false;
    moveRight = false;
    position.x = x_pos;
    position.y = y_pos;
    id = ID;
    addPositions();
    setRules(length, width);
}
예제 #5
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::setRules (QString ruleString)
{
    QString::const_iterator it;
    int B_bitmask = 0, S_bitmask = 0;
    QString digits;
    if (reBrule.indexIn(ruleString) >= 0) {
        digits = reBrule.cap(1);
        for (it = digits.constBegin(); it != digits.constEnd(); it++)
            B_bitmask |= (1 << it->digitValue());
    }
    if (reSrule.indexIn(ruleString) >= 0) {
        digits = reSrule.cap(1);
        for (it = digits.constBegin(); it != digits.constEnd(); it++)
            S_bitmask |= (1 << it->digitValue());
    }
    fprintf(stderr,"Rules(%s=+%x:%x)\n", ruleString.cStr(), B_bitmask,S_bitmask);
    setRules(B_bitmask, S_bitmask);
}
예제 #6
0
파일: hashcat.cpp 프로젝트: bitland/disthc
int Ngn_Hashcat::run ()
{
	Application& app = Application::instance();
	DJob *job = DJob::Instance();
	string cmd;
	string hashcat(dengine->getBinaryPath("hashcat"));
	int eCode(-1);
	
	// clean results
	_results = string("");
	
	// grab settings from job
	setAttackMode(job->getAttackMode());
	setHashType(job->getHashType());
	setMask(job->getMask());
	setRules(job->getRules());
	setDictionary(job->getDictionary());
	setPot("disthc.pot");
	
	// clean pot before working
	File f(getPot());
	if(f.exists()) {
		f.remove();
	}
	
	// setup command prefix (format command takes 7 args max)
	cmd = format("%s -o %s -s %lu -l %u",
		hashcat,
		getPot(),
		job->getChunk(),
		job->getChunkSize()
	);
	
	// Attack modes:
	// 0 = Straight
	// 1 = Combination
	// 2 = Toggle-Case
	// 3 = Brute-force
	// 4 = Permutation
	// 5 = Table-Lookup
	
	// if mask minimum set, apply it
	if(job->getMaskMin())
	{
		cmd = format("%s --pw-min %d",
			cmd,
			job->getMaskMin()
		);
	}
	
	// if mask maximum set, apply it
	if(job->getMaskMax())
	{
		cmd = format("%s --pw-min %d",
			cmd,
			job->getMaskMax()
		);
	}
	
	// discover attack mode and create command to execute
	switch(getAttackMode())
	{
		case 3:
			cmd = format("%s -a3 -m %d %s %s %s",
				cmd,
				getHashType(),
				getFlags(),
				getHashFile(),
				getMask()
			);
			break;
		default:
			// default command uses attack mode 0
			cmd = format("%s -m %d %s %s %s %s",
				cmd,
				getHashType(),
				getFlags(),
				getHashFile(),
				getDictionary(),
				getRules()
			);
	}
	
	if(DEBUG) app.logger().information(format("%%Running command: %s", cmd));

	// check for ghosts, and run as appropriate
	if(isGhost())
	{
		app.logger().information("~~~ A ghost is loose! ~~~");
		app.logger().information("      .-.");
		app.logger().information("     (o o) boo!");
		app.logger().information("    \\| O \\/");
		app.logger().information("      \\   \\ ");
		app.logger().information("       `~~~' ");
	}
	else
	{
		// run hashcat!  :)
		// TODO change this over to use Poco Processes
		eCode = system(cmd.c_str());
		
		// check for results
		if(f.exists()) {
			FileInputStream fis(getPot());
			//std::ifstream in(pot,std::ios::in);
			string line;
			while(fis >> line) {
				_results.append(line + "\n");
			}
		}
		
		// TODO might take this out?
		// see if it's worth it to just display hashcout output during
		// execution
		// if enabled, print pot to screen
//		if(false) {
//			app.logger().information("\n=== Recovered Hashes ===");
//			if(!_results.empty()) app.logger().information(_results);
//			app.logger().information("========================");
//		}
	}
예제 #7
0
void Game::createGame() {
  setRules();
  createPlayers();
  shuffleDeck();
  dealCards();
}