コード例 #1
0
ファイル: BoardWidget.cpp プロジェクト: weidendo/qenolaba
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Network n;
    TestGame g(&n);
    if (argc>1) n.addListener(argv[1]);
    QTimer::singleShot(1000, &g, SLOT(startOnEmpty()));

    return app.exec();
}
コード例 #2
0
ファイル: dazeus.cpp プロジェクト: mrngm/dazeus
/**
 * @brief (Re-)loads configuration from the configuration file.
 *
 * If loading failed, this method returns false.
 * Note: this method is automatically called when setConfigFileName is called,
 * and by the constructor.
 */
bool dazeus::DaZeus::loadConfig()
{
  assert( configFileName_.length() != 0 );

  if( config_ != 0 ) {
    delete config_;
  }

  config_ = new ConfigReader(configFileName_);

  if( !config_ )
    return false;

  config_->read();

  const std::vector<NetworkConfig*> &networks = config_->getNetworks();

  if(!connectDatabase()) {
    delete config_;
    config_ = 0;
    return false;
  }

  if(plugins_)
    delete plugins_;
  plugins_ = new PluginComm( database_, config_, this );

  std::vector<NetworkConfig*>::const_iterator it;
  for(it = networks.begin(); it != networks.end(); ++it)
  {
    Network *net = new Network( *it );
    net->addListener(plugins_);
    if( net == 0 ) {
      delete config_;
      config_ = 0;
      return false;
    }

    networks_.push_back( net );
  }

  // Pretty number of initialisations viewer -- and also an immediate database
  // check.
  std::stringstream numInitsStr;
  numInitsStr << database_->property("dazeus.numinits");
  int numInits;
  numInitsStr >> numInits;
  if(!numInitsStr)
    numInits = 0;
  ++numInits;
  numInitsStr.str(""); numInitsStr.clear();
  numInitsStr << numInits;
  database_->setProperty("dazeus.numinits", numInitsStr.str());
  const char *suffix = "th";
  if(numInits%100 == 11 ) ;
  else if(numInits%100 == 12) ;
  else if(numInits%100 == 13) ;
  else if(numInits%10 == 1) suffix = "st";
  else if(numInits%10 == 2) suffix = "nd";
  else if(numInits%10 == 3) suffix = "rd";
  printf("Initialising DaZeus for the %d%s time!\n", numInits, suffix);
  return true;
}