示例#1
0
int	main()
{
	Database*	database;
	Player*		player1;

	database = Database::GetInstance();
	database->Init();
//	player1 = new Player("test",0);
//	printf("dans player = %d\n", player1->__list_charger[1]);
/*	while (player1->Get_Weapon()->Get_Charger1() >= 0)
	{
//		printf("avant fire(chargeur) = %d\n", player1->Get_Weapon()->Get_Nb_Charger1());
		printf("avant fire(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
		printf("avant fire(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
		player1->Fire(0);
		player1->Fire(1);
		printf("apres fire(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
		printf("apres fire(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
		if (player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo() == 0)
			player1->Reload(0);
		if (player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo() == 0)
			player1->Reload(1);
//		printf("dans player = %d\n", player1->__list_charger[1]);
		printf("apres reload(ammo2) = %d\n", player1->Get_Weapon()->Get_Charger1()->Get_Nb_Ammo());
		printf("apres reload(chargeur2) = %d\n", player1->Get_Weapon()->Get_Charger2()->Get_Nb_Ammo());
		sleep(1);
	}*/
}
示例#2
0
文件: db.cpp 项目: LngMH/phxpaxos
int MultiDatabase :: Init(const std::string & sDBPath, const int iGroupCount)
{
    if (access(sDBPath.c_str(), F_OK) == -1)
    {
        PLErr("DBPath not exist or no limit to open, %s", sDBPath.c_str());
        return -1;
    }

    if (iGroupCount < 1 || iGroupCount > 100000)
    {
        PLErr("Groupcount wrong %d", iGroupCount);
        return -2;
    }

    std::string sNewDBPath = sDBPath;

    if (sDBPath[sDBPath.size() - 1] != '/')
    {
        sNewDBPath += '/';
    }

    for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++)
    {
        char sGroupDBPath[512] = {0};
        snprintf(sGroupDBPath, sizeof(sGroupDBPath), "%sg%d", sNewDBPath.c_str(), iGroupIdx);

        Database * poDB = new Database();
        assert(poDB != nullptr);
        m_vecDBList.push_back(poDB);

        if (poDB->Init(sGroupDBPath, iGroupIdx) != 0)
        {
            return -1;
        }
    }

    PLImp("OK, DBPath %s groupcount %d", sDBPath.c_str(), iGroupCount);

    return 0;
}