⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zonegroupthread.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////////////// Filename    : ZoneGroupThread.cc// Written by  : reiot@ewestsoft.com// Description : //////////////////////////////////////////////////////////////////////////////#include "ZoneGroupThread.h"#include "ZonePlayerManager.h"#include "LogClient.h"#include "DB.h"#include "VSDateTime.h"#include "Properties.h"#include "Profile.h"#include "Timeval.h"#include "Gpackets/GMServerInfo.h"//////////////////////////////////////////////////////////////////////////////// constructor//////////////////////////////////////////////////////////////////////////////ZoneGroupThread::ZoneGroupThread (ZoneGroup* pZoneGroup) 	throw (): m_pZoneGroup(pZoneGroup){	__BEGIN_TRY	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// destructor//////////////////////////////////////////////////////////////////////////////ZoneGroupThread::~ZoneGroupThread () 	throw (){	__BEGIN_TRY	__END_CATCH}//////////////////////////////////////////////////////////////////////////////// 静饭靛 皋筋靛甸篮 弥惑困肺 荤侩登骨肺 __BEGIN_TRY客 __END_CATCH// 甫 且 鞘夸啊 绝促. 溜 葛电 抗寇甫 棱酒辑 贸府秦具 茄促绰 家府.//////////////////////////////////////////////////////////////////////////////void ZoneGroupThread::run () 	throw (){	__BEGIN_DEBUG	string host     = g_pConfig->getProperty("DB_HOST");	string db       = g_pConfig->getProperty("DB_DB");	string user     = g_pConfig->getProperty("DB_USER");	string password = g_pConfig->getProperty("DB_PASSWORD");	Connection* pConnection = new Connection(host, db, user, password);	g_pDatabaseManager->addConnection((int)Thread::self(), pConnection);	cout << "******************************************************" << endl;	cout << " THREAD CONNECT DB " << endl;	cout << "******************************************************" << endl;	string dist_host     = g_pConfig->getProperty("UI_DB_HOST");	string dist_db       = "DARKEDEN";	string dist_user     = g_pConfig->getProperty("UI_DB_USER");	string dist_password = g_pConfig->getProperty("UI_DB_PASSWORD");	Connection* pDistConnection = new Connection(dist_host, dist_db, dist_user, dist_password);	g_pDatabaseManager->addDistConnection(((int)Thread::self()), pDistConnection);	cout << "******************************************************" << endl;	cout << " THREAD CONNECT UIIRIBUTION DB " << endl;	cout << " TID Number = " << (int)Thread::self()<< endl;	cout << "******************************************************" << endl;	/*	// Login DB 狼 PCRoomDBInfo Table 佬绢辑 Connection 父甸扁	Statement * pStmt = NULL;	pStmt = pDistConnection->createStatement();	Result * pResult = NULL;		pResult = pStmt->executeQuery("SELECT ID, Host, DB, User, Password FROM PCRoomDBInfo");		if (pResult->next())	{		WorldID_t ID = pResult->getInt(1);		string host = pResult->getString(2);		string db = pResult->getString(3);		string user = pResult->getString(4);		string password = pResult->getString(5);		cout << "Connection: "			 << "  ID=" << (int)ID			 << ", HOST=" << host.c_str()			 << ", DB=" << db.c_str()			 << ", User=" << user.c_str() << endl;		Connection * pConnection = new Connection(host, db, user, password);		Assert(pConnection!=NULL);		g_pDatabaseManager->addPCRoomConnection((int)(Thread::self()) , pConnection );	}	*/	Timeval NextTime;	getCurrentTime(NextTime);	Timeval currentTime;	NextTime.tv_sec += 2;	Timeval dummyQueryTime;	getCurrentTime(dummyQueryTime);	try {	while (true) 	{		beginProfileEx("ZGT_MAIN");		usleep(100); // CPU 痢蜡啦阑 临捞扁 困秦辑 碍力肺 0.001 檬悼救 疆促.		__ENTER_CRITICAL_SECTION((*m_pZoneGroup))		beginProfileEx("ZG_PP");		m_pZoneGroup->processPlayers(); // process all players in ZonePlayerManager;		endProfileEx("ZG_PP");		beginProfileEx("ZG_HEARTBEAT");		m_pZoneGroup->heartbeat(); // process all npc, monster, ... in Zones		endProfileEx("ZG_HEARTBEAT");		__LEAVE_CRITICAL_SECTION((*m_pZoneGroup))		getCurrentTime(currentTime);		endProfileEx("ZGT_MAIN");		if (dummyQueryTime < currentTime)		{			g_pDatabaseManager->executeDummyQuery( pConnection );			g_pDatabaseManager->executeDummyQuery( pDistConnection );			// 1矫埃 ~ 1矫埃 30盒 荤捞俊辑 dummy query 矫埃阑 汲沥茄促.		    // timeout捞 登瘤 臼霸 窍扁 困秦辑捞促.		    dummyQueryTime.tv_sec += (60+rand()%30) * 60;		}		if (NextTime < currentTime)		{			GMServerInfo gmServerInfo;			m_pZoneGroup->makeZoneUserInfo(gmServerInfo); 			//outputProfileEx(false, false);			(g_ProfileSampleManager.getProfileSampleSet())->outputProfileToFile("Profile", false, false,																				&gmServerInfo);						NextTime.tv_sec = currentTime.tv_sec + 10;			NextTime.tv_usec = currentTime.tv_usec;			// 概畔付促 橇肺颇老 单捞磐甫 檬扁拳秦霖促.			// 穿利 单捞磐焊促绰 矫埃措俊 蝶弗 矫埃阑 螟沥窍扁 困秦辑...			initProfileEx();		}	}	} catch (Throwable& t){		filelog("zoneGroupThreadError.log", "%s", t.toString().c_str());		throw;	}	__END_DEBUG}//////////////////////////////////////////////////////////////////////////////// get debug string//////////////////////////////////////////////////////////////////////////////string ZoneGroupThread::toString () const 	throw (){	StringStream msg;	msg << "ZoneGroupThread("			<< m_pZoneGroup->toString()			<< ")";	return msg.toString();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -