CubeSimulationWidget::CubeSimulationWidget(QString mapFile, AgentManagerFactory **facts,
                                           int amCount, AgentFactory **afacts,
                                           int aCount, QWidget *parent)
{
  QFile fileMap(mapFile);
  bool flag = false;


  if(fileMap.open(QFile::ReadOnly)) {
    QStringList line;

    line = QString("").append(fileMap.readLine()).split(" ");

    if(line.length() < 3)
      flag = true;
    else {
      int l, w, h;

      l = line.at(0).toInt();
      w = line.at(1).toInt();
      h = line.at(2).toInt();

      map = new Map(l,w,h);

      bool **level;
      level = new bool*[h];
      for( int i = 0; i < h; i++ )
        level[i] = new bool[w];

      QString oneLine;
      for( int i = 0; i < l; i++ ) {
        for( int j = 0; j < h; j++ ) {
          oneLine = fileMap.readLine();
          for( int k = 0; k < w; k++ )
            level[j][k] = (oneLine.at(k).toAscii() - '0');
        }
        map->loadLevelMask(i, level);
      }

      env = new Environment(map, facts, amCount, afacts, aCount);
    }
  }
  else
    flag = true;


  if(flag) {
    initEnvironment(5,5,5);
  }

  init();
}
예제 #2
0
Module Process::map(const File& file)
{
	WinHandle fileMap(CreateFileMappingW(file.handle(), nullptr, PAGE_READONLY, 0, 1, nullptr), CloseHandle);
	if (!fileMap)
	{
		DWORD errcode = GetLastError();
		BOOST_THROW_EXCEPTION(ex_injection() << e_api_function("CreateFileMapping") << e_file(file.path()) << e_last_error(errcode));
	}

	Module module((HMODULE)MapViewOfFile(fileMap.handle(), FILE_MAP_READ, 0, 0, 1), Process::current, UnmapViewOfFile);
	if (!module)
	{
		DWORD errcode = GetLastError();
		BOOST_THROW_EXCEPTION(ex_injection() << e_api_function("MapViewOfFile") << e_file(file.path()) << e_last_error(errcode));
	}
	return module;
}