Esempio n. 1
0
int loadConfig(char *filename) {
	char str[1024];
	FILE *fp;
	bool mallocd = FALSE;

	printlog("Loading config '%s'...\n",filename);
	
	if( strstr(filename,".cfg") == NULL ) {
		char *filename2 = filename;
		filename = (char *) malloc(sizeof(char)*256);
		strcpy(filename,filename2);
		mallocd = TRUE;
		strcat(filename,".cfg");
	}
	
	// open the config file
	if( (fp = fopen(filename,"rb")) == NULL ) {
		printlog("warning: config file '%s' does not exist!\n", filename);
		defaultConfig(); //Set up the game with the default config.
		return 0;
	}
	
	// read commands from it
	while( fgets(str,1024,fp) != NULL ) {
		if( str[0] != '#' && str[0]!='\n' && str[0]!='\r' ) { // if this line is not white space or a comment
			// execute command
			consoleCommand(str);
		}
	}
	fclose(fp);
	if( mallocd )
		free(filename);
	return 0;
}
Esempio n. 2
0
ParameterServer::ParameterServer() {
  pre = ros::this_node::getName();
  pre += "/config/";

  defaultConfig();
  getValues();
}
Esempio n. 3
0
bool Database::init(const QString &name)
{
    bool _default = !QFile::exists(name);

    if ((db = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"))))
    {
        db->setDatabaseName(name);

        if (db->open())
        {
            db->exec("PRAGMA journal_mode = OFF");
            db->exec("PRAGMA synchronous = OFF");

            if (_default)
                defaultConfig();

            return true;
        }
        else
        {
            free();
        }
    }

    stdCout("Error! Data base failed");
    return false;
}
Esempio n. 4
0
int main( int argc, char** argv )
{
    boost::scoped_ptr< comma::Multiplay > multiPlay;
    try
    {
        const boost::array< comma::signal_flag::signals, 2 > signals = { { comma::signal_flag::sigint, comma::signal_flag::sigterm } };
        comma::signal_flag shutdownFlag( signals );
        comma::command_line_options options( argc, argv );
        if( options.exists( "--help,-h" ) ) { usage(); }
        options.assert_mutually_exclusive( "--speed,--slow,--slowdown" );
        double speed = options.value( "--speed", 1.0 / options.value< double >( "--slow,--slowdown", 1.0 ) );
        unsigned int precision = options.value( "--precision", 10u );
        std::string from = options.value< std::string>( "--from", "" );
        std::string to = options.value< std::string>( "--to", "" );
        bool quiet =  options.exists( "--quiet" );
        bool flush =  !options.exists( "--no-flush" );
        std::vector< std::string > configstrings = options.unnamed("--quiet,--no-flush","--slow,--slowdown,--speed,--precision,--binary,--fields,--clients,--from,--to");
        if( configstrings.empty() ) { configstrings.push_back( "-;-" ); }
        comma::csv::options csvoptions( argc, argv );
        comma::name_value::parser nameValue("filename,output", ';', '=', false );
        std::vector< comma::Multiplay::SourceConfig > sourceConfigs( configstrings.size() );
        comma::Multiplay::SourceConfig defaultConfig( "-", options.value( "--clients", 0 ), csvoptions );
        for( unsigned int i = 0U; i < configstrings.size(); ++i )
        {
            sourceConfigs[i] = nameValue.get< comma::Multiplay::SourceConfig >( configstrings[i], defaultConfig );
        }
        boost::posix_time::ptime fromtime;
        if( !from.empty() )
        {
            fromtime = boost::posix_time::from_iso_string( from );
        }
        boost::posix_time::ptime totime;
        if( !to.empty() )
        {
            totime = boost::posix_time::from_iso_string( to );
        }
        multiPlay.reset( new comma::Multiplay( sourceConfigs, 1.0 / speed, quiet, boost::posix_time::milliseconds(precision), fromtime, totime, flush ) );
        while( multiPlay->read() && !shutdownFlag && std::cout.good() && !std::cout.bad() &&!std::cout.eof() )
        {

        }
        multiPlay->close();
        multiPlay.reset();
        if( shutdownFlag ) { std::cerr << "csv-play: interrupted by signal" << std::endl; return -1; }
        return 0;
    }
    catch( std::exception& ex )
    {
        std::cerr << "csv-play: " << ex.what() << std::endl;
    }
    catch( ... )
    {
        std::cerr << "csv-play: unknown exception" << std::endl;
    }
    try { if( multiPlay ) { multiPlay->close(); } } catch ( ... ) {} // windows thing
    std::cerr << "reset multiplay" << std::endl;
    std::cerr << "done" << std::endl;
    return -1;
}
// Returns the wallmark shader and modifies it according to the passed VProjectedWallmark object.
VProjectorShaderPass *VWallmarkManager::GetWallmarkShader(const VProjectedWallmark *pWallmark, VisStaticGeometryType_e eGeomType)
{
  VASSERT(eGeomType==STATIC_GEOMETRY_TYPE_MESHINSTANCE || eGeomType==STATIC_GEOMETRY_TYPE_TERRAIN);
  V_COMPILE_ASSERT(STATIC_GEOMETRY_TYPE_MESHINSTANCE<4 && STATIC_GEOMETRY_TYPE_TERRAIN<4 && STATIC_GEOMETRY_TYPE_FIRSTCUSTOM<4);

  VCompiledTechnique *pTech = pWallmark->m_spCustomTechnique[eGeomType]; // first try with wallmark's own technique
  if (pTech == NULL)
    pTech = m_spWallmarkTechnique[eGeomType][pWallmark->IsLightmapped() ? 1:0];
  if (pTech == NULL)
  {
    if (Vision::Shaders.LoadShaderLibrary("\\Shaders\\Projectors.ShaderLib", SHADERLIBFLAG_HIDDEN) == NULL)
    {
      VASSERT(!"failed to load 'Shaders\\Projectors.ShaderLib'");
      return NULL;
    }

  #if defined( SUPPORTS_BORDERCOLOR )
    VTechniqueConfig defaultConfig( "", NULL );
  #else
    VTechniqueConfig defaultConfig( "NO_BORDERCOLOR", NULL );
  #endif

    m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_MESHINSTANCE][0] = Vision::Shaders.CreateTechnique("ProjectorFullbright", NULL, &defaultConfig);
    m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_MESHINSTANCE][1] = Vision::Shaders.CreateTechnique("ProjectorLightmapped", NULL, &defaultConfig);
    VASSERT_MSG(m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_MESHINSTANCE][0] && m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_MESHINSTANCE][1],"failed to create shaders for projectors");
  #if !defined(_VISION_IOS) 
    #if defined( SUPPORTS_BORDERCOLOR )
      VTechniqueConfig terrainConf("VTerrain",NULL);
    #else // defined( SUPPORTS_BORDERCOLOR )
      VTechniqueConfig terrainConf("NO_BORDERCOLOR;VTerrain",NULL);
    #endif  // defined( SUPPORTS_BORDERCOLOR )
    m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_TERRAIN][0] = Vision::Shaders.CreateTechnique("ProjectorFullbright", NULL, &terrainConf);
    m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_TERRAIN][1] = Vision::Shaders.CreateTechnique("ProjectorLightmapped", NULL, &terrainConf);
    VASSERT_MSG(m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_TERRAIN][0] && m_spWallmarkTechnique[STATIC_GEOMETRY_TYPE_TERRAIN][1],"failed to create shaders for terrain projectors. Please use latest Projectors.ShaderLib");
  #endif  // !defined(_VISION_IOS) 
    pTech = m_spWallmarkTechnique[eGeomType][pWallmark->IsLightmapped() ? 1:0];
  }
  VASSERT(pTech->GetShaderCount()==1 && "Invalid shader pass count for projectors");
  VProjectorShaderPass *pWallmarkShader = (VProjectorShaderPass *)pTech->GetShader(0);
  VASSERT(pWallmarkShader->IsOfType(VProjectorShaderPass::GetClassTypeId()));

  // update the shader registers
  pWallmarkShader->SetProperties(pWallmark);
  return pWallmarkShader;
}
void FilterFileLine::loadConfig (QString const & path)
{
	QString const fname = path + "/" + g_filterTag + "/" + typeName();
	FilterFileLine ffl;
	if (!::loadConfigTemplate(ffl, fname))
		defaultConfig();
	m_enabled = ffl.m_enabled;
	mergeWithConfig(ffl.m_data);
}
void OsmAnd::RoutingConfiguration::loadDefault( RoutingConfiguration& outConfig )
{
    auto rawDefaultConfig = EmbeddedResources::decompressResource("routing.xml");
    QBuffer defaultConfig(&rawDefaultConfig);
    bool ok = false;
    ok = defaultConfig.open(QIODevice::ReadOnly | QIODevice::Text);
    assert(ok);
    ok = parseConfiguration(&defaultConfig, outConfig);
    assert(ok);
    defaultConfig.close();
}
Esempio n. 8
0
// @TODO: to base l8r (tag to virtual fn)
void ColorizerMgr::loadConfig (QString const & path)
{
	QString const fname = path + "/" + g_colorizerTag + "/" + typeName();
	if (!::loadConfigTemplate(*this, fname))
		defaultConfig();

	recreateFilters();

	for (int i = 0, ie = m_filters.size(); i < ie; ++i)
		m_filters[i]->loadConfig(path);
}
Esempio n. 9
0
int main( int argc, char** argv )
{
    boost::scoped_ptr< comma::Multiplay > multiplay;
    try
    {
        const boost::array< comma::signal_flag::signals, 2 > signals = { { comma::signal_flag::sigint, comma::signal_flag::sigterm } };
        comma::signal_flag shutdown_flag( signals );
        comma::command_line_options options( argc, argv );
        if( options.exists( "--help,-h" ) ) { usage(); }
        options.assert_mutually_exclusive( "--speed,--slow,--slowdown" );
        double speed = options.value( "--speed", 1.0 / options.value< double >( "--slow,--slowdown", 1.0 ) );
        double resolution = options.value< double >( "--resolution", 0.01 );
        std::string from = options.value< std::string>( "--from", "" );
        std::string to = options.value< std::string>( "--to", "" );
        bool quiet =  options.exists( "--quiet" );
        bool flush =  !options.exists( "--no-flush" );
        std::vector< std::string > configstrings = options.unnamed("--interactive,-i,--paused,--paused-at-start,--quiet,--flush,--no-flush","--slow,--slowdown,--speed,--resolution,--binary,--fields,--clients,--from,--to");
        if( configstrings.empty() ) { configstrings.push_back( "-;-" ); }
        comma::csv::options csvoptions( argc, argv );
        comma::name_value::parser name_value("filename,output", ';', '=', false );
        std::vector< comma::Multiplay::SourceConfig > sourceConfigs( configstrings.size() );
        comma::Multiplay::SourceConfig defaultConfig( "-", options.value( "--clients", 0 ), csvoptions );
        for( unsigned int i = 0U; i < configstrings.size(); ++i ) { sourceConfigs[i] = name_value.get< comma::Multiplay::SourceConfig >( configstrings[i], defaultConfig ); }
        boost::posix_time::ptime fromtime;
        if( !from.empty() ) { fromtime = boost::posix_time::from_iso_string( from ); }
        boost::posix_time::ptime totime;
        if( !to.empty() ) { totime = boost::posix_time::from_iso_string( to ); }
        multiplay.reset( new comma::Multiplay( sourceConfigs, 1.0 / speed, quiet, boost::posix_time::microseconds( static_cast<unsigned int> (resolution * 1000000) ), fromtime, totime, flush ) );
        key_press_handler_t key_press_handler( options.exists( "--interactive,-i" ), options.exists( "--paused,--paused-at-start" ) );
        while( !shutdown_flag && std::cout.good() && !std::cout.bad() && !std::cout.eof() )
        {
            key_press_handler.update( multiplay->now() );
            if( key_press_handler.state() == key_press_handler_t::paused ) { boost::this_thread::sleep( boost::posix_time::millisec( 200 ) ); continue; }
            if( !multiplay->read() ) { break; }
            key_press_handler.has_read_once();
        }
        multiplay->close();
        multiplay.reset();
        if( shutdown_flag ) { std::cerr << "csv-play: interrupted by signal" << std::endl; return -1; }
        return 0;
    }
    catch( std::exception& ex ) { std::cerr << "csv-play: " << ex.what() << std::endl; }
    catch( ... ) { std::cerr << "csv-play: unknown exception" << std::endl; }
    try { if( multiplay ) { multiplay->close(); } } catch ( ... ) {} // windows thing
    return 1;
}
Esempio n. 10
0
Config readConfig(const char* path) {
	std::ifstream handle(path);
	Config cfg = defaultConfig();

	if(handle.is_open()) {
		std::string line;
		while(getline(handle, line)) {
			if(line[0] == '#')
				continue;
			size_t eqPos = line.find("=");
			if(eqPos == std::string::npos)
				continue;
			std::string tag = strip(line.substr(0, eqPos));
			std::string val = strip(line.substr(eqPos+1));

			// Bwearkh.
			if(tag == "url")
				cfg.challengeUrl = val;
			else if(tag == "http_header")
				cfg.httpHeader = val;
			else if(tag == "post_header")
				cfg.postHeader = val;
			else if(tag == "post_footer")
				cfg.postFooter = val;
			else if(tag == "on_success")
				cfg.onSuccessProgram = val;
			else if(tag == "challenge_length")
				cfg.challengeLength = toNumber(val);
			else if(tag == "cooldown_time")
				cfg.authCooldownTime = toNumber(val);
			else {
				fprintf(stderr, "Invalid configuration tag: %s.\n",
						tag.c_str());
				exit(1);
			}
		}
	}
	else {
		fprintf(stderr, "Can't open configuration file. Aborting.\n");
		exit(1);
	}

	return cfg;
}
Esempio n. 11
0
void Config::init(int argc, char* argv[])
{
    boost::filesystem::path programPath = argv[0];
#if BOOST_VERSION > 104200
    programName = programPath.filename().string();
#else
    programName = programPath.filename();
#endif

    boost::filesystem::path defaultConfig("etc/" + programName + ".conf");
    desc.add_options()
        ("help,h", "show this help and exit.")
        ("config,c", boost::program_options::value<boost::filesystem::path>()->default_value(defaultConfig),
            ("config file, default " + defaultConfig.string() + ".").c_str())
        ("no-config-file", boost::program_options::bool_switch()->default_value(false),
            "force do not load options from config file, default false.");
    initDesc();

    try
    {
        boost::program_options::command_line_parser parser(argc, argv);
        parser.options(desc).allow_unregistered().style(boost::program_options::command_line_style::unix_style);
        boost::program_options::store(parser.run(), options);
    }
    catch (const std::exception& e)
    {
        CS_DIE(e.what() << CS_LINESEP << desc);
    }
    boost::program_options::notify(options);

    if (options.count("help"))
    {
        std::cout << desc << std::endl;
        std::exit(EXIT_SUCCESS);
    }
    else
    {
        bool noConfigFile = options["no-config-file"].as<bool>();
        if (!noConfigFile)
        {
            load(options["config"].as<boost::filesystem::path>());
        }
    }
}
Esempio n. 12
0
int init(int argc, char **argv, char **env) {
#ifdef _ITEM_QUITPARTY
  FILE *f;
  int i;
  char line[256];
#endif
  srand(getpid());
  print("This Program is compiled at %s %s by gcc %s\n",
        __DATE__, __TIME__, __VERSION__);

  defaultConfig(argv[0]);
  signalset();

  GOTORETURNFALSEIFFALSE(parseCommandLine(argc, argv));
  GOTORETURNFALSEIFFALSE(parseEnvironment(env));

  {
    Char aho;
    debug(sizeof(aho), d);
    debug(sizeof(aho.data), d);
    debug(sizeof(aho.string), d);
    debug(sizeof(aho.flg), d);
    debug(sizeof(aho.indexOfExistItems), d);
    debug(sizeof(aho.haveSkill), d);
    debug(sizeof(aho.indexOfHaveTitle), d);
    debug(sizeof(aho.addressBook), d);
    debug(sizeof(aho.workint), d);
    debug(sizeof(aho.workchar), d);
  }

  print("配置文件: %s\n", getConfigfilename());

  GOTORETURNFALSEIFFALSE(readconfigfile(getConfigfilename()));

  nice(getrunlevel());
  {
    int iWork = setAcWBSize();
    if(iWork == 0) {
      printf("----------------------------------------\n");
      printf("-------------[AC缓冲] 无法设置 %s\n", getConfigfilename());
      printf("----------------------------------------\n");
      exit(1);
    } else {
      printf("AC缓冲 = %d\n", iWork);
    }
  }

  if(getDebuglevel() >= 1) {
    print("调试等级: %d\n", getDebuglevel());
    print("运行等级: %d\n", getrunlevel());
    print("接收缓冲: %d\n", getrecvbuffer() * 1024);
    print("发送缓冲: %d\n", getsendbuffer() * 1024);
    print("接收缓冲下限: %d\n", getrecvlowatbuffer());
    print("内存单元大小: %d\n", getMemoryunit());
    print("内存单元数量: %d\n", getMemoryunitnum());

    print("账号服务器地址: %s\n", getAccountservername());
    print("账号服务器端口: %d\n", getAccountserverport());
    print("登陆服务器名称: %s\n", getGameservername());
    print("登陆服务器密码: %s\n", getAccountserverpasswd());

    print("等待连接端口: %d\n", getPortnumber());

    print("服务端序列号: %d\n", getServernumber());

    print("重复地址使用: %d\n", getReuseaddr());


    print("最大在线人数: %d\n", getFdnum());
    print("最大在线宠数: %d\n", getPetcharnum());
    print("最大其他数目: %d\n", getOtherscharnum());
    print("最大对象数目: %d\n", getObjnum());
    print("最大物品数目: %d\n", getItemnum());
    print("最大战斗数目: %d\n", getBattlenum());
    print("顶层文件目录: %s\n", getTopdir());
    print("地图文件目录: %s\n", getMapdir());
    print("地图标识文件: %s\n", getMaptilefile());
    print("物品配置文件: %s\n", getItemfile());
    print("不可战斗文件: %s\n", getInvfile());
    print("显示位置文件: %s\n", getAppearfile());
    print("头衔名称文件: %s\n", getTitleNamefile());
    print("头衔配置文件: %s\n", getTitleConfigfile());
    print("遇敌坐标文件: %s\n", getEncountfile());
    print("遇敌组群文件: %s\n", getGroupfile());
    print("宠物基本文件: %s\n", getEnemyBasefile());
    print("创建宠物文件: %s\n", getEnemyfile());
    print("精灵魔法文件: %s\n", getMagicfile());

#ifdef _ATTACK_MAGIC
    print("攻击魔法文件: %s\n", getAttMagicfileName());
#endif

    print("宠物技能文件: %s\n", getPetskillfile());
    print("物品成份文件: %s\n", getItematomfile());
    print("猜迷问题文件: %s\n", getQuizfile());
#ifdef _GMRELOAD
    print("G M 配置文件: %s\n", getGMSetfile());
#endif
    print("日志记录文件: %s\n", getLsgenlogfilename());
    print("还原资料目录: %s\n", getStoredir());
    print("NPC 配置目录: %s\n", getNpcdir());
    print("日志记载文件: %s\n", getLogdir());
    print("日志配置文件: %s\n", getLogconffile());
    print("GM的指命密码: %s\n", getChatMagicPasswd());
    print("使用GM的权限: %d\n", getChatMagicCDKeyCheck());

    print("NPC 模板数目: %d\n", getNpctemplatenum());
    print("NPC 最大数目: %d\n", getNpccreatenum());

    print("走路时间间隔: %d\n", getWalksendinterval());
    print("清除所有间隔: %d\n", getCAsendinterval_ms());
    print("清除目标间隔: %d\n", getCDsendinterval_ms());
    print("执行一次时间: %d\n", getOnelooptime_ms());
    print("宠物清除时间: %d\n", getPetdeletetime());
    print("道具清除时间: %d\n", getItemdeletetime());
#ifdef _DEL_DROP_GOLD
    print("石器清除时间: %d\n", getGolddeletetime());
#endif
    print("数据保存间隔: %d\n", getCharSavesendinterval());

    print("名片最大数目: %d\n", getAddressbookoffmsgnum());
    print("读取频率协议: %d\n", getProtocolreadfrequency());

    print("连接错误上限: %d\n", getAllowerrornum());
#ifdef _GET_BATTLE_EXP
    print("战斗经验倍数: %d倍\n", getBattleexp() );
#endif
#ifdef _NEW_PLAYER_CF
    print("出生人物转数: %d转\n", getNewplayertrans());
    print("出生人物等级: %d级\n", getNewplayerlv());
    print("出生人物金钱: %d S\n", getNewplayergivegold());
    print("出生宠物等级: %d级\n", getNewplayerpetlv());
#ifdef _VIP_SERVER
    print("出生拥有点数: %d点\n", getNewplayergivevip());
#endif
    print("出生能骑等级: %d\n", getRidePetLevel());
#ifdef _NEW_PLAYER_RIDE
    print("出生配套骑宠: %s\n", getPlayerRide());
#endif
    print("出生拥有宠物: NO1:%d NO2:%d NO3:%d NO4:%d NO5:%d\n", getNewplayergivepet(0),
          getNewplayergivepet(1),
          getNewplayergivepet(2),
          getNewplayergivepet(3),
          getNewplayergivepet(4));
    print("出生拥有物品: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n"
              "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n"
              "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n", getNewplayergiveitem(0), getNewplayergiveitem(1),
          getNewplayergiveitem(2), getNewplayergiveitem(3), getNewplayergiveitem(4), getNewplayergiveitem(5),
          getNewplayergiveitem(6), getNewplayergiveitem(7), getNewplayergiveitem(8), getNewplayergiveitem(9),
          getNewplayergiveitem(10), getNewplayergiveitem(11), getNewplayergiveitem(12), getNewplayergiveitem(13),
          getNewplayergiveitem(14));
#endif
#ifdef _UNREG_NEMA
    print("禁止人物名称: 名字1:%s 名字2:%s 名字3:%s 名字4:%s 名字5:%s\n", getUnregname(0),
          getUnregname(1),
          getUnregname(2),
          getUnregname(3),
          getUnregname(4));
#endif
#ifdef _UNLAW_WARP_FLOOR
    print("禁止传送地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n"
              "              地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n", getUnlawwarpfloor(0),
          getUnlawwarpfloor(1),
          getUnlawwarpfloor(2),
          getUnlawwarpfloor(3),
          getUnlawwarpfloor(4),
          getUnlawwarpfloor(5),
          getUnlawwarpfloor(6),
          getUnlawwarpfloor(7),
          getUnlawwarpfloor(8),
          getUnlawwarpfloor(9));
#endif
#ifdef _WATCH_FLOOR
    print("是否全图观战: %s\n",getWatchFloorCF());
    if(strcmp(getWatchFloorCF(),"是"))
      print("允许观战地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getWatchFloor(1),
                                                                    getWatchFloor(2),
                                                                    getWatchFloor(3),
                                                                    getWatchFloor(4),
                                                                    getWatchFloor(5));
#endif

#ifdef _BATTLE_FLOOR
    print("是否强制战斗: %s\n",getBattleFloorCF());
    if(strcmp(getBattleFloorCF(),"是"))
      print("强制战斗地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getBattleFloor(1),
                                                                    getBattleFloor(2),
                                                                    getBattleFloor(3),
                                                                    getBattleFloor(4),
                                                                    getBattleFloor(5));
#endif

#ifdef _TRANS_LEVEL_CF
    print("人物等级转数: %d级\n", getChartrans());
    print("宠物等级转数: %d级\n", getPettrans());
#endif

#ifdef _POINT
    print("禁止点数上限: %s\n", getPoint());
    if(strcmp(getPoint(), "是"))
      print("每转点数上限: 0转:%d 1转:%d 2转:%d 3转:%d 4转:%d 5转:%d 6转:%d\n", getTransPoint(0),
            getTransPoint(1),
            getTransPoint(2),
            getTransPoint(3),
            getTransPoint(4),
            getTransPoint(5),
            getTransPoint(6));
#endif
#ifdef _PET_UP
    print("宠物能否捡获: %s\n", getPetup());
#endif
#ifdef _LOOP_ANNOUNCE
    print("循环公告路径: %s\n",getLoopAnnouncePath());
    print("循环时间间隔: %d分钟\n",getLoopAnnounceTime());
#endif
#ifdef _SKILLUPPOINT_CF
    print("每级升级点数: %d\n",getSkup());
#endif

#ifdef _RIDELEVEL
    print("骑宠等级相差: %d级\n",getRideLevel());
#endif
#ifdef _REVLEVEL
    print("还原上限等级: %s级\n",getRevLevel());
#endif
#ifdef _TRANS_LEVEL_CF
    print("一般等级上限: %d级\n", getYBLevel());
    print("最高等级上限: %d级\n", getMaxLevel());
#endif
#ifdef _FIX_CHARLOOPS
    print("恶魔时间倍数: %d倍\n", getCharloops());
#endif
#ifdef _PLAYER_ANNOUNCE
    if(getPAnnounce() == -1)
      print("喇叭消耗点数: 关闭使用\n");
    else
      print("喇叭消耗点数: %d点\n", getPAnnounce());
#endif
#ifdef _PLAYER_MOVE
    if(getPMove() == -1)
      print("顺移消耗点数: 关闭使用\n");
    else
      print("顺移消耗点数: %d点\n", getPMove());
#endif
#ifdef _BATTLE_GOLD
    print("战斗获得金钱: %d%\n", getBattleGold());
#endif
#ifdef _ANGEL_TIME
    print("精灵召唤时间: (%d人/在线人数)分\n", getAngelPlayerTime());
    print("精灵召唤人数: %d人\n", getAngelPlayerMun());
#endif
#ifdef _RIDEMODE_20
    print("2.0 骑宠模式: %d\n", getRideMode());
#endif
#ifdef _FM_POINT_PK
    print("庄园互抢模式: %s\n", getFmPointPK());
#endif
  }

  {  //andy_add 2003/05/05 check GameServer Name
    char *GameServerName;
    GameServerName = getGameserverID();
    if(GameServerName == NULL || strlen(GameServerName) <= 0)
      return FALSE;
    print("\n游戏服务器ID: %s\n", GameServerName);
  }
  print("开始初始化\n");

//#define DEBUG1( arg... ) if( getDebuglevel()>1 ){##arg}
  print("建立内存空间...");
  GOTORETURNFALSEIFFALSE(configmem(getMemoryunit(),
                                   getMemoryunitnum()));
  GOTORETURNFALSEIFFALSE(memInit());
  print("完成\n");

  print("始终化连接空间...");
  if(!initConnect(getFdnum()))
    goto MEMEND;
  print("完成\n");
  while(1) {
    print("尝试绑定本地端口 %d... ", getPortnumber());
    bindedfd = bindlocalhost(getPortnumber());
    if(bindedfd == -1)
      sleep(10);
    else
      break;
  }
  print("完成\n");

  print("建立对象...");
  if(!initObjectArray(getObjnum()))
    goto CLOSEBIND;
  print("完成\n");

  print("建立人物...");
  if(!CHAR_initCharArray(getFdnum(), getPetcharnum(), getOtherscharnum()))
    goto CLOSEBIND;
  print("完成\n");
  print("建立物品...");
  if(!ITEM_readItemConfFile(getItemfile()))
    goto CLOSEBIND;
  if(!ITEM_initExistItemsArray(getItemnum()))
    goto CLOSEBIND;
  print("完成\n");

  print("建立战斗...");
  if(!BATTLE_initBattleArray(getBattlenum()))
    goto CLOSEBIND;
  print("完成\n");

  print("建立功能模块...");
  if(!initFunctionTable())
    goto CLOSEBIND;
  print("完成\n");

  print("初始化邮件...");
  if(!PETMAIL_initOffmsgBuffer(getAddressbookoffmsgnum()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取不可战斗文件...");
  if(!CHAR_initInvinciblePlace(getInvfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取显示位置文件...");
  if(!CHAR_initAppearPosition(getAppearfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取头衔名称文件...");
  if(!TITLE_initTitleName(getTitleNamefile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取头衔配置文件...");
  if(!TITLE_initTitleConfig(getTitleConfigfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取遇敌坐标文件...");
  if(!ENCOUNT_initEncount(getEncountfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取宠物基本文件...");
  if(!ENEMYTEMP_initEnemy(getEnemyBasefile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取创建宠物文件...");
  if(!ENEMY_initEnemy(getEnemyfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取遇敌组群文件...");
  if(!GROUP_initGroup(getGroupfile()))
    goto CLOSEBIND;
  print("完成\n");
  print("读取魔法文件...");
  if(!MAGIC_initMagic(getMagicfile()))
    goto CLOSEBIND;
  print("完成\n");

#ifdef _ATTACK_MAGIC

  print("读取魔法攻击文件...");

  if(!ATTMAGIC_initMagic(getAttMagicfileName()))
//		if( !ATTMAGIC_initMagic( getMagicfile() ) )
    goto CLOSEBIND;

  print("魔法攻击文件 -->%s...", getAttMagicfileName());
  print("完成\n");

#endif

  print("读取宠物技能文件...");
  if(!PETSKILL_initPetskill(getPetskillfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("读取物品成份文件...");
  if(!ITEM_initItemAtom(getItematomfile()))
    goto CLOSEBIND;
  print("完成\n");

  print("初始化料理合成物品...");
  if(!ITEM_initItemIngCache())
    goto CLOSEBIND;
  print("完成\n");

  print("初始料理合成随机设定...");
  if(!ITEM_initRandTable())
    goto CLOSEBIND;
  print("完成\n");

  print("读取猜迷问题文件...");
  if(!QUIZ_initQuiz(getQuizfile()))
    goto CLOSEBIND;
  print("完成\n");
#ifdef _GMRELOAD
  print("读取GM配置文件...");
  if(!LoadGMSet(getGMSetfile()))
    goto CLOSEBIND;
  print("完成\n");
#endif

#ifdef _USER_EXP_CF
  print( "读取经验配置文件..." );
  if ( !LoadEXP( getEXPfile() ) )
    goto CLOSEBIND;
  print("最高等级: %d...",getMaxLevel());
  print("一般等级: %d...",getYBLevel());
  print( "完成\n" );
#endif

#ifdef _LOOP_ANNOUNCE
  print("读取循环公告文件...");
  if(!loadLoopAnnounce())
    print("...失败\n");
  else
   print("完成\n");
#endif
#ifdef _RIDE_CF
  print("读取自定义骑宠文件...");
  if(!CHAR_Ride_CF_init())
    print("...失败\n");
  print("完成\n");
#endif
#ifdef _FM_LEADER_RIDE
  print("读取庄园族长专用骑宠文件...");
  if(!CHAR_FmLeaderRide_init())
    print("...失败\n");
  print("完成\n");
#endif
#ifdef _NEED_ITEM_ENEMY
  print("读取融合宠配置文件...");
  if(!need_item_eneny_init())
    print("...失败\n");
  print("完成\n");
#endif

  print("建立地图...");
  if(!MAP_initReadMap(getMaptilefile(), getMapdir()))
    goto CLOSEBIND;
  print("完成\n");
  print("读取NPC文件...");
  if(!NPC_readNPCSettingFiles(getNpcdir(), getNpctemplatenum(),
                              getNpccreatenum()))
    goto CLOSEBIND;
  print("完成\n");
  print("初始化 NPC 服务器... ");
  if(lssproto_InitServer(lsrpcClientWriteFunc, LSGENWORKINGBUFFER) < 0)
    goto CLOSEBIND;
  print("完成\n");
  print("尝试连接账号服务器... ");
  acfd = connectHost(getAccountservername(), getAccountserverport());
  if(acfd == -1)
    goto CLOSEBIND;

  print("完成\n");
  initConnectOne(acfd, NULL, 0);
  if(!CONNECT_acfdInitRB(acfd)) goto CLOSEAC;
  if(!CONNECT_acfdInitWB(acfd)) goto CLOSEAC;
  CONNECT_setCtype(acfd, AC);

  print("初始化 NPC 客户端 ... ");
  if(saacproto_InitClient(lsrpcClientWriteFunc, LSGENWORKINGBUFFER, acfd) < 0)
    goto CLOSEAC;
  print("完成\n");

  print("向账号服务器发送登陆请求... ");
  saacproto_ACServerLogin_send(acfd, getGameservername(), getAccountserverpasswd());

  print("完成\n");

  if(isExistFile(getLsgenlogfilename())) {
    lssproto_SetServerLogFiles(getLsgenlogfilename(), getLsgenlogfilename());
    saacproto_SetClientLogFiles(getLsgenlogfilename(), getLsgenlogfilename());
  }


  print("初始化已完成\n");

  print("开始记始日志\n");
  {
    if(!initLog(getLogconffile()))
      goto CLOSEAC;
  }
#ifdef _ITEM_QUITPARTY
  print("读取队伍解散物品消失文件...");

  //读取档案
  f = fopen(getitemquitparty(), "r");
  if(f != NULL) {
    while(fgets(line, sizeof(line), f)) {
      if(line[0] == '#')continue;
      if(line[0] == '\n')continue;
      chomp(line);
      itemquitparty_num++;
    }
    if(fseek(f, 0, SEEK_SET) == -1) {
      print("物品录找错误\n");
      fclose(f);
      goto CLOSEAC;
    }
    //配记忆体
    Disappear_Item = allocateMemory(sizeof(struct tagDisappearItem) * itemquitparty_num);
    if(Disappear_Item == NULL) {
      print("无法分配内存 %d\n", sizeof(struct tagDisappearItem) * itemquitparty_num);
      fclose(f);
      goto CLOSEAC;
    }

    i = 0;
    //将道具编号存入 Disappear_Item.string
    while(fgets(line, sizeof(line), f)) {
      if(line[0] == '#')continue;
      if(line[0] == '\n')continue;
      chomp(line);
      sprintf(Disappear_Item[i].string, "%s", line);
      print("\n道具编号:%s", Disappear_Item[i].string);
      i++;
    }
    fclose(f);
  }
#endif

  DEBUG_ADJUSTTIME = 0;
  return TRUE;

  CLOSEAC:
  close(acfd);
  CLOSEBIND:
  close(bindedfd);
  endConnect();
  MEMEND:
  memEnd();
  RETURNFALSE:
  return FALSE;
}
Esempio n. 13
0
void ColorizerRow::loadConfig (QString const & path)
{
	QString const fname = path + "/" + g_colorizerTag + "/" + typeName();
	if (!::loadConfigTemplate(*this, fname))
		defaultConfig();
}
Esempio n. 14
0
void FilterLvl::loadConfig (QString const & path)
{
	QString const fname = path + "/" + g_filterTag + "/" + typeName();
	if (!::loadConfigTemplate(*this, fname))
		defaultConfig();
}
Esempio n. 15
0
void nRF905_init()
{
#ifdef ARDUINO
    pinMode(TRX_EN, OUTPUT);
    pinMode(PWR_MODE, OUTPUT);
    pinMode(TX_EN, OUTPUT);

#if NRF905_COLLISION_AVOID
    pinMode(CD, INPUT);
#endif

#if AM_IS_USED_HW
    pinMode(AM, INPUT);
#endif

#if !NRF905_DR_SW
    pinMode(DR, INPUT);
#endif

    digitalWrite(CSN, HIGH);
    pinMode(CSN, OUTPUT);

    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV2);
#else
    TRX_EN_DDR |= _BV(TRX_EN_BIT);
    PWR_MODE_DDR |= _BV(PWR_MODE_BIT);
    TX_EN_DDR |= _BV(TX_EN_BIT);

#if NRF905_COLLISION_AVOID
    CD_DDR &= ~_BV(CD_BIT);
#endif

#if AM_IS_USED_HW
    AM_DDR &= ~_BV(AM_BIT);
#endif

#if !NRF905_DR_SW
    DR_DDR &= ~_BV(DR_BIT);
#endif

    spiDeselect();
    CSN_DDR |= _BV(CSN_BIT);

    spi_init();
#endif

    radio.state = NRF905_RADIO_STATE_IDLE;

    // Startup
    enableStandbyMode();
    receiveMode();
    nRF905_powerDown();
    _delay_ms(3);
    defaultConfig();

#if NRF905_INTERRUPTS
    // Set interrupts
    REG_EXTERNAL_INT_CTL |= BIT_EXTERNAL_INT_CTL;
    nRF905_interrupt_on();
#endif

    nRF905_powerUp();
}
Esempio n. 16
0
	bool Config::Init()
	{

		//Don't do anything if file name is empty!
		if (this->m_fileName.empty())
		{
			return true;
		}

		this->m_configFile.open(this->m_fileName);

		const std::string comment("//");
		if (this->m_configFile.is_open())
		{
			while (!this->m_configFile.eof())
			{
				std::string currentLine;
				std::getline(this->m_configFile, currentLine);

				if (currentLine.find("full_screen") != std::string::npos)
				{
					if (currentLine.find("TRUE") != std::string::npos)
						this->m_fullScreen = true;
					else
						this->m_fullScreen = false;
				}
				else if (currentLine.find("v_sync") != std::string::npos)
				{
					if (currentLine.find("TRUE") != std::string::npos)
						this->m_vSync = true;
					else
						this->m_vSync = false;

				}
				else if (currentLine.find("screen_width") != std::string::npos)
				{
					std::string::size_type foundPos = currentLine.find("screen_width");
					std::string stringToErase("screen_width = ");
					currentLine.erase(currentLine.begin() + foundPos, currentLine.begin() + foundPos + stringToErase.length());

					this->m_screenWidth = atoi(currentLine.c_str());
				}
				else if (currentLine.find("screen_height") != std::string::npos)
				{
					std::string::size_type foundPos = currentLine.find("screen_height");
					std::string stringToErase("screen_height = ");
					currentLine.erase(currentLine.begin() + foundPos, currentLine.begin() + foundPos + stringToErase.length());

					this->m_screenHeight = atoi(currentLine.c_str());
				}
				else if (currentLine.find("4xMSAA") != std::string::npos)
				{
					if (currentLine.find("TRUE") != std::string::npos)
						this->m_4xMsaa = true;
					else
						this->m_4xMsaa = false;
				}
				else if (currentLine.find("show_fps") != std::string::npos)
				{
					if (currentLine.find("TRUE") != std::string::npos)
						this->m_showFPS = true;
					else
						this->m_showFPS = false;
				}
				//Comment found, ignore line
				else if (currentLine.compare(0, comment.size(), comment))
				{
					continue;
				}

				//Otherwise just continue
			}
		}

		else
		{
			//Coudn't open config file, create default!
			std::ofstream defaultConfig("config.txt");

			if (!defaultConfig.is_open())
				return false;

			defaultConfig << "//This is the default config, each line beginning with '//' is ignored" << std::endl;
			defaultConfig << "full_screen = FALSE" << std::endl;
			defaultConfig << "screen_width = 800" << std::endl;
			defaultConfig << "screen_height = 600" << std::endl;
			defaultConfig << "v_sync = FALSE" << std::endl;
			defaultConfig << "4xMSAA = TRUE" << std::endl;

			defaultConfig.close();

			//Set all member variables to default values
			this->m_fullScreen = false;
			this->m_vSync = false;
			this->m_screenWidth = 800;
			this->m_screenHeight = 600;
			this->m_4xMsaa = true;
		}


		//Config file read OK!
		return true;
	}