• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WorldDatabaseWorkerPool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WorldDatabaseWorkerPool的典型用法代码示例。如果您正苦于以下问题:C++ WorldDatabaseWorkerPool类的具体用法?C++ WorldDatabaseWorkerPool怎么用?C++ WorldDatabaseWorkerPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WorldDatabaseWorkerPool类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: StartDB

/// Initialize connection to the databases
bool StartDB()
{
    MySQL::Library_Init();

    // Load databases
    DatabaseLoader loader("server.worldserver", DatabaseLoader::DATABASE_NONE);
    loader
        .AddDatabase(WorldDatabase, "World")
        .AddDatabase(CharacterDatabase, "Character")
        .AddDatabase(LoginDatabase, "Login");

    if (!loader.Load())
        return false;

    ///- Get the realm Id from the configuration file
    realmID = sConfigMgr->GetIntDefault("RealmID", 0);
    if (!realmID)
    {
        TC_LOG_ERROR("server.worldserver", "Realm ID not defined in configuration file");
        return false;
    }
    TC_LOG_INFO("server.worldserver", "Realm running as realm ID %d", realmID);

    ///- Clean the database before starting
    ClearOnlineAccounts();

    ///- Insert version info into DB
    WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH);        // One-time query

    sWorld->LoadDBVersion();

    TC_LOG_INFO("server.worldserver", "Using World DB: %s", sWorld->GetDBVersion());
    return true;
}
开发者ID:HevdavDEV,项目名称:DeathCore_3.3.5a,代码行数:35,代码来源:Main.cpp


示例2: StopDB

void StopDB()
{
    CharacterDatabase.Close();
    WorldDatabase.Close();
    LoginDatabase.Close();

    MySQL::Library_End();
}
开发者ID:OniBoov,项目名称:TCOLD,代码行数:8,代码来源:Main.cpp


示例3: showBuyList

bool showBuyList(Player *player, Creature* pCreature, uint32 showFromId = 0)
{
	//show not occupied guildhouses

	QueryResult result;
	result = WorldDatabase.PQuery("SELECT `id`, `comment` FROM `guildhouses` WHERE `guildId` = 0 AND `id` > %u ORDER BY `id` ASC LIMIT %u",
		showFromId, GOSSIP_COUNT_MAX);

	if (result)
	{
		uint32 guildhouseId = 0;
		std::string comment = "";
		do
		{

			Field *fields = result->Fetch();

			guildhouseId = fields[0].GetInt32();
			comment = fields[1].GetString();
			
			//send comment as a gossip item
			//transmit guildhouseId in Action variable
			player->ADD_GOSSIP_ITEM(ICON_GOSSIP_TABARD, comment, GOSSIP_SENDER_MAIN,
				guildhouseId + OFFSET_GH_ID_TO_ACTION);

		} while (result->NextRow());

		if (result->GetRowCount() == GOSSIP_COUNT_MAX)
		{
			//assume that we have additional page
			//add link to next GOSSIP_COUNT_MAX items
			player->ADD_GOSSIP_ITEM(ICON_GOSSIP_BALOONDOTS, MSG_GOSSIP_NEXTPAGE, GOSSIP_SENDER_MAIN, 
				guildhouseId + OFFSET_SHOWBUY_FROM);
		}

		
		player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());

		return true;
	} else
	{
		if (showFromId = 0)
		{
			//all guildhouses are occupied
			pCreature->MonsterWhisper(MSG_NOFREEGH, player->GetGUID());
			player->CLOSE_GOSSIP_MENU();
		} else
		{
			//this condition occurs when COUNT(guildhouses) % GOSSIP_COUNT_MAX == 0
			//just show GHs from beginning
			showBuyList(player, pCreature, 0);
		}
	}

	return false;
}
开发者ID:mynew0,项目名称:TrinityCustom,代码行数:56,代码来源:guildmaster.cpp


示例4: sellGuildhouse

void sellGuildhouse(Player *player, Creature *_creature)
{
 QueryResult result;
 result = WorldDatabase.PQuery("UPDATE `guildhouses` SET `guildId` = 0 WHERE `guildId` = %u", player->GetGuildId());

 if (result)
 player->ModifyMoney(COST_GH_SELL);
 _creature->MonsterSay(MSG_SOLD, LANG_UNIVERSAL, player->GetGUID());
 player->CLOSE_GOSSIP_MENU();
}
开发者ID:CrystalEMU,项目名称:CrystalEMU,代码行数:10,代码来源:guildmaster.cpp


示例5: buyGuildhouse

void buyGuildhouse(Player *player, Creature* pCreature, uint32 guildhouseId)
{
	if (!player->HasEnoughMoney(GHBUY_COST))//(player->GetMoney() < GHBUY_COST)
	{
		//show how much money player need to buy GH (in gold)
		char msg[100];
		sprintf(msg, MSG_NOTENOUGHMONEY, GHBUY_COST / 10000);
		pCreature->MonsterWhisper(msg, player->GetGUID());
		return;
	}

	if (isPlayerHasGuildhouse(player, pCreature, true))
	{
		//player already have GH
		return;
	}

	QueryResult result;

	//check if somebody already occupied this GH
	result = WorldDatabase.PQuery("SELECT `id` FROM `guildhouses` WHERE `id` = %u AND `guildId` <> 0",
		guildhouseId);

	if (result)
	{
		pCreature->MonsterWhisper(MSG_GHOCCUPIED, player->GetGUID());
		return;
	}

	//update DB
	result = WorldDatabase.PQuery("UPDATE `guildhouses` SET `guildId` = %u WHERE `id` = %u",
		player->GetGuildId(), guildhouseId);

	if (result)
		
	player->ModifyMoney(-int32(GHBUY_COST));
	player->ModifyMoney(-(ConfigMgr::GetFloatDefault("pryds_guildhouseGoldCost",0)));
	pCreature->MonsterSay(MSG_CONGRATULATIONS, LANG_UNIVERSAL, player->GetGUID());
	
}
开发者ID:mynew0,项目名称:TrinityCustom,代码行数:40,代码来源:guildmaster.cpp


示例6: buyGuildhouse

void buyGuildhouse(Player *player, Creature *_creature, uint32 guildhouseId)
{
 if (player->GetMoney() < COST_GH_BUY)
 {
 //show how much money player need to buy GH (in gold)
 char msg[100];
 sprintf(msg, MSG_NOTENOUGHMONEY, COST_GH_BUY / 10000);
 _creature->MonsterWhisper(msg, player->GetGUID());
 return;
 }

 if (isPlayerHasGuildhouse(player, _creature, true))
 {
 //player already have GH
 return;
 }

 QueryResult result;

 //check if somebody already occupied this GH
 result = WorldDatabase.PQuery("SELECT `id` FROM `guildhouses` WHERE `id` = %u AND `guildId` <> 0", guildhouseId);

 if (result)
 {
 _creature->MonsterWhisper(MSG_GHOCCUPIED, player->GetGUID());
 return;
 }

 //update DB
 result = WorldDatabase.PQuery("UPDATE `guildhouses` SET `guildId` = %u WHERE `id` = %u",
 player->GetGuildId(), guildhouseId);

 if (result)
 player->ModifyMoney(-COST_GH_BUY);
 player->DestroyItemCount(30, 1, true, false);
 _creature->MonsterSay(MSG_CONGRATULATIONS, LANG_UNIVERSAL, player->GetGUID());
}
开发者ID:CrystalEMU,项目名称:CrystalEMU,代码行数:37,代码来源:guildmaster.cpp


示例7: StartDB

/// Initialize connection to the databases
bool StartDB()
{
    MySQL::Library_Init();

    // Load databases
    DatabaseLoader loader("server.worldserver", DatabaseLoader::DATABASE_NONE);
    loader
        .AddDatabase(HotfixDatabase, "Hotfix")
        .AddDatabase(WorldDatabase, "World")
        .AddDatabase(CharacterDatabase, "Character")
        .AddDatabase(LoginDatabase, "Login");

    if (!loader.Load())
        return false;

    ///- Get the realm Id from the configuration file
    realmHandle.Index = sConfigMgr->GetIntDefault("RealmID", 0);
    if (!realmHandle.Index)
    {
        TC_LOG_ERROR("server.worldserver", "Realm ID not defined in configuration file");
        return false;
    }

    // Realm Handles
    QueryResult realmIdQuery = LoginDatabase.PQuery("SELECT `Region`,`Battlegroup` FROM `realmlist` WHERE `id`=%u", realmHandle.Index);
    if (!realmIdQuery)
    {
        TC_LOG_ERROR("server.worldserver", "Realm id %u not defined in realmlist table", realmHandle.Index);
        return false;
    }

    realmHandle.Region = (*realmIdQuery)[0].GetUInt8();
    realmHandle.Battlegroup = (*realmIdQuery)[1].GetUInt8();

    TC_LOG_INFO("server.worldserver", "Realm running as realm ID %u region %u battlegroup %u", realmHandle.Index, uint32(realmHandle.Region), uint32(realmHandle.Battlegroup));

    ///- Clean the database before starting
    ClearOnlineAccounts();

    ///- Insert version info into DB
    WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", GitRevision::GetFullVersion(), GitRevision::GetHash());        // One-time query

    sWorld->LoadDBVersion();

    TC_LOG_INFO("server.worldserver", "Using World DB: %s", sWorld->GetDBVersion());
    return true;
}
开发者ID:RafoxSama,项目名称:TrinityCore,代码行数:48,代码来源:Main.cpp


示例8: sellGuildhouse

void sellGuildhouse(Player *player, Creature *_creature)
{
 if (isPlayerHasGuildhouse(player, _creature))
 {
 QueryResult result;
 result = WorldDatabase.PQuery("UPDATE `guildhouses` SET `guildId` = 0 WHERE `guildId` = %u",
 player->GetGuildId());

 if (result)
 player->ModifyMoney(COST_GH_SELL);

 //display message e.g. "here your money etc."
 char msg[100];
 sprintf(msg, MSG_SOLD, COST_GH_SELL / 10000);
 _creature->MonsterWhisper(msg, player->GetGUID());
 }
}
开发者ID:Sharki,项目名称:TC,代码行数:17,代码来源:guildmaster.cpp


示例9: getGuildHouseCoords

bool getGuildHouseCoords(uint32 guildId, float &x, float &y, float &z, uint32 &map)
{
	if (guildId == 0)
	{
		//if player has no guild
		return false;
	}

	QueryResult result;
	result = WorldDatabase.PQuery("SELECT `x`, `y`, `z`, `map` FROM `guildhouses` WHERE `guildId` = %u", guildId);
	if (result)
	{
		Field *fields = result->Fetch();
		x = fields[0].GetFloat();
		y = fields[1].GetFloat();
		z = fields[2].GetFloat();
		map = fields[3].GetUInt32();
		return true;
	}
	return false;
}
开发者ID:mynew0,项目名称:TrinityCustom,代码行数:21,代码来源:guildmaster.cpp


示例10: isPlayerHasGuildhouse

bool isPlayerHasGuildhouse(Player *player, Creature *_creature, bool whisper = false)
{
 QueryResult result;
 result = WorldDatabase.PQuery("SELECT `comment` FROM `guildhouses` WHERE `guildId` = %u",
 player->GetGuildId());

 if (result)
 {
 if (whisper)
 {
 //whisper to player "already have etc..."
 Field *fields = result->Fetch();
 char msg[100];
 sprintf(msg, MSG_ALREADYHAVEGH, fields[0].GetString());
 _creature->MonsterWhisper(msg, player->GetGUID());
 }

 return true;
 }

 return false;
}
开发者ID:CrystalEMU,项目名称:CrystalEMU,代码行数:22,代码来源:guildmaster.cpp


示例11: StartDB

/// Initialize connection to the databases
bool StartDB()
{
    MySQL::Library_Init();

    std::string dbString;
    uint8 asyncThreads, synchThreads;

    dbString = sConfigMgr->GetStringDefault("WorldDatabaseInfo", "");
    if (dbString.empty())
    {
        TC_LOG_ERROR("server.worldserver", "World database not specified in configuration file");
        return false;
    }

    asyncThreads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.WorkerThreads", 1));
    if (asyncThreads < 1 || asyncThreads > 32)
    {
        TC_LOG_ERROR("server.worldserver", "World database: invalid number of worker threads specified. "
            "Please pick a value between 1 and 32.");
        return false;
    }

    synchThreads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.SynchThreads", 1));
    ///- Initialize the world database
    if (!WorldDatabase.Open(dbString, asyncThreads, synchThreads))
    {
        TC_LOG_ERROR("server.worldserver", "Cannot connect to world database %s", dbString.c_str());
        return false;
    }

    ///- Get character database info from configuration file
    dbString = sConfigMgr->GetStringDefault("CharacterDatabaseInfo", "");
    if (dbString.empty())
    {
        TC_LOG_ERROR("server.worldserver", "Character database not specified in configuration file");
        return false;
    }

    asyncThreads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.WorkerThreads", 1));
    if (asyncThreads < 1 || asyncThreads > 32)
    {
        TC_LOG_ERROR("server.worldserver", "Character database: invalid number of worker threads specified. "
            "Please pick a value between 1 and 32.");
        return false;
    }

    synchThreads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.SynchThreads", 2));

    ///- Initialize the Character database
    if (!CharacterDatabase.Open(dbString, asyncThreads, synchThreads))
    {
        TC_LOG_ERROR("server.worldserver", "Cannot connect to Character database %s", dbString.c_str());
        return false;
    }

    ///- Get login database info from configuration file
    dbString = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
    if (dbString.empty())
    {
        TC_LOG_ERROR("server.worldserver", "Login database not specified in configuration file");
        return false;
    }

    asyncThreads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1));
    if (asyncThreads < 1 || asyncThreads > 32)
    {
        TC_LOG_ERROR("server.worldserver", "Login database: invalid number of worker threads specified. "
            "Please pick a value between 1 and 32.");
        return false;
    }

    synchThreads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1));
    ///- Initialise the login database
    if (!LoginDatabase.Open(dbString, asyncThreads, synchThreads))
    {
        TC_LOG_ERROR("server.worldserver", "Cannot connect to login database %s", dbString.c_str());
        return false;
    }

    ///- Get the realm Id from the configuration file
    realmID = sConfigMgr->GetIntDefault("RealmID", 0);
    if (!realmID)
    {
        TC_LOG_ERROR("server.worldserver", "Realm ID not defined in configuration file");
        return false;
    }
    TC_LOG_INFO("server.worldserver", "Realm running as realm ID %d", realmID);

    ///- Clean the database before starting
    ClearOnlineAccounts();

    ///- Insert version info into DB
    WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH);        // One-time query

    sWorld->LoadDBVersion();

    TC_LOG_INFO("server.worldserver", "Using World DB: %s", sWorld->GetDBVersion());
    return true;
}
开发者ID:OniBoov,项目名称:TCOLD,代码行数:100,代码来源:Main.cpp



注:本文中的WorldDatabaseWorkerPool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WorldInterface类代码示例发布时间:2022-05-31
下一篇:
C++ World类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap