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

📄 main.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
	// 011130 YGI
	extern void LoadDRAGON_MAX_CONNECTIONS();
	LoadDRAGON_MAX_CONNECTIONS();
	if( !DRAGON_MAX_CONNECTIONS ) DRAGON_MAX_CONNECTIONS = DRAGON_MAX_CONNECTIONS_; 
	
	
	
	//< CSD-011126
	if (InitEffectTbl() < 0) 	
	{	
		Error("  Effect loading Fail ! ... new! \n");	
		return(0);	
	}
	else 
	{
		MyLog(LOG_NORMAL, "'Effect' Table initializing     ...............   OK !");
	}
	
	if (InitMagicTbl() < 0) 	
	{	
		Error ("  Magic loading Fail ! ... new! \n");	
		return(0);	
	}
	else 
	{
		MyLog(LOG_NORMAL, "'Magic' Table initializing	     ...............   OK !");
	}
	//> CSD-011126
	if( InitSkillMapTable() < 0) 	{	Error ("  SkillMapTable loading Fail !");	return(0);	}
	else MyLog( LOG_NORMAL, "'SkillMapTable' initializing   ................   OK !");
	
	if( InitialScript() <= 0  ) {	Error (" Script Loading Error ! ");	return(0);	}
	
	// 何荐搁 唱坷绰 Item俊 包茄 Table..
	if( LoadItemsInBoxTableSQL() < 0  ){	Error ("  'ItemsBox_new' Table loading Fail !");	return(0);	}
	else MyLog( LOG_NORMAL, " 'ItemsBox_new' Loading  ......................   OK !" );
	
	
	
	MapBuild( &g_Map, MapName );
	MyLog( LOG_NORMAL, "<%11s.map>  loading                        OK !", MapName );
	
	LoadTOI( MapName );
	MyLog( LOG_NORMAL, "<%11s.toi2> loading                        OK !", MapName );
	
	LoadSkillMapTable();
	MyLog( LOG_NORMAL, "<%11s.skb>  loading                        OK !", MapName );
	
	if (!LoadGeneration()) MyLog( LOG_NORMAL, "****** FAILED :: Event_Monster Table loading, Not Terminate......");		// LTS AI2
	else MyLog( LOG_NORMAL,"Event_Monster Table load Complete.........    OK !");
	
	
	if( LoadItemJoinTable()	) MyLog( LOG_NORMAL, "'ItemJoin' Table initializing  ................   OK !");
	else { Error ("******* FAILED !! :: Item Join Table initializing"); return 0; }
	
	if( !LoadWeatherTable() ) MyLog( LOG_NORMAL, "WeatherTable(data/rain.tbl) initializing   ....   OK !");
	else { Error ("***** FAILED :: Weather Table  initializing"); return 0; }
	
	//this2 lsw soksung 
	//011025 lsw >
	if( LoadItemTable()	) 
	{
		MyLog( LOG_NORMAL, "Item Attr. initializing  ");
		MyLog( LOG_NORMAL, 
			"     (Item_mutant/ Item_grade/ Item_mutant_kind ) OK !");
	}
	else { Error ("******* FAILED !! :: Item mutant, rare Table  initializing"); return 0; }
	//011025 lsw <
	
	int t = LoadSkillLevelTable();
	if(	t > 0  ) MyLog( LOG_NORMAL, " skill_lvexp/ skill_exp/ mon_bag Table Loading    OK !");
	else{ Error ("******* FAILED !! :: skill_lvexp/ skill_exp / mon_bag ( %d )", t ); return 0; }
	
	if(LoadGenerateSpecialItem() < 0) {	Error ("  Special_Item initializing Fail !\n");	return(0);	}
	else MyLog( LOG_NORMAL, "'Special_Item' Table initializing .............   OK !" );
	
	if (LoadAbilityLimit())
	{
		MyLog(LOG_NORMAL, "'ability_limit' Table initializing .............   OK !");
	}
	else
	{
		Error("  ability_max initializing Fail!\n");	
		return 0;
	}
	
	if (LoadAbilityDivide())
	{
		MyLog(LOG_NORMAL, "'ability_divide' Table initializing ............   OK !");
	}
	else
	{
		Error("  ability_divide initializing Fail!\n");
		return 0;
	}
	
	if (LoadDualInfo())
	{
		MyLog(LOG_NORMAL, "'dual_info' Table initializing .................   OK !");
	}
	else
	{
		Error("  dual_info initializing Fail!\n");
		return 0;
	}
	
	if( InitGameItem() == 1 )
		MyLog(LOG_NORMAL, "'gamble_item' Table initializing ...............   OK !");
	else
	{
		Error("  gamble_item initializing Fail!\n");
		return 0;
	}
	
	LoadNationItem( g_wday );
	
	SaveMoveDelayTable();// 1鸥老 捞悼窍绰单 吧府绰矫埃阑 Text拳老肺 免仿茄促. ( 扁裙夸备 )
	LoadConditionTable();
	
	if (!InitMapServerConfigINI())	// LTS NEW LOCALWAR
	{
		Error("******* FAILED !! :: Load MapServerConfig.ini\n");
		return 0;
	}	// LTS LOCALWAR
	
	if (!InitNationSystem()) // 010904 LTS
	{
		Error("******* FAILED !! :: Nation System Initializing Fault!\n");
		return 0;
	}
	
	if (!InitLocalWarSystem())		// LTS LOCALWAR
	{
		Error("******* FAILED !! :: LocalWar System Initializing Fault!\n");
		return 0;
	}
	
	if (!InitEventLocalWarSystem())		// 020115 LTS
	{
		Error("******* FAILED !! :: Event LocalWar System Initializing Fault!\n");
		return 0;
	}
	
	if (!InitAIData())		// LTS AI2
	{
		Error("******* FAILED !! :: AI Data Initializing Fault!\n");
		return 0;
	}

	if (LoadWarStartInfo())
	{	//< CSD-030723
		MyLog(LOG_NORMAL, "'WarStartTBL' Table initializing ...............   OK !");
	}	//> CSD-030723
	
	InitRefreshMenu();		// 020620 YGI
	InitNationRelation();	// 001209 KHS 惫啊包拌俊 措茄 檬扁拳.
	LoadGetGodTable();		// 0605 YGI	脚傈 抛捞喉 啊廉坷扁
	LoadGameServerStatus();	
	CheckingChrLogAvailable();	// 010301 KHS
	
	InitOnlyStart_kein();		// 020818 YGI
	
	
	int tflag = InitLoadQuestTable(); // 021106 kyo
	if( tflag == 1 )
	{
		MyLog(LOG_NORMAL, "'quest_in_map'	Table initializing ..............   OK ! ");
		MyLog(LOG_NORMAL, "'quest_info_map' Table initializing ..............   OK ! ");
		MyLog(LOG_NORMAL, "'requital_list'  Table initializing ..............   OK ! ");
		MyLog(LOG_NORMAL, "'requital_item'  Table initializing ..............   OK ! ");	// BBD 040329
	}
	else
	{
		if( tflag == -1 )
			Error("******* FAILED !! 'quest_in_map' QuestTable!\n");
		else if( tflag == -2 )
			Error("******* FAILED !! 'quest_info_map' QuestTable!\n");
		else if( tflag == -3 )
			Error("******* FAILED !! 'requital_list' QuestTable!\n");
		//<! BBD 040329		
		else if( tflag == -4 )
			Error("******* FAILED !! 'requital_item' QuestTable!\n");
		//> BBD 040329		
		
		return 0;
	}
	
	//< soto-030331 瘤糯捞 抛捞喉 肺靛.
	int nRet = 0;
	if(nRet = LoadGuardianGuildList())
	{
		MyLog(LOG_NORMAL,"GuardianGuildList Table initializing ..............   OK ! ");
	}
	else
	{
		Error("******* FAILED !!  GuardianGuildList Table initializing!");
	}
	//> soto-030331
	if (LoadHuntInfo())
	{	//< CSD-030509
		if (LoadHuntGroupInfo())
		{	
			LoadHuntMonsterInfo();
			LoadHuntPlaceInfo();
		}	
	}	//> CSD-030509
	
	if( LocalMgr.IsAbleNation(THAI) )// 030929 kyo
	{
		::InitLimitedTimeAndAge();
	}

	tflag  = GetPrivateProfileInt( "Option", "DisconnectAccelatorUser",	0, MAP_SERVER_INI_ );
	if( tflag )
	{
		g_accelator_user_closeconnection = true;
		MyLog( LOG_NORMAL, "  ** Accelator Users will be disconnected and logged in!");
	}
	else 
	{
		MyLog( LOG_NORMAL, "  ** Accelator Users will be ** NOT ** disconnected and logged in!");
	}
	
	g_alive_time = timeGetTime();
	MyLog( LOG_NORMAL, "All of 'GameServerData' Loaded, successfuly ............^ ^\n\n");
	
	MyLog( LOG_NORMAL, " F1 : Server Status");
	MyLog( LOG_NORMAL, " F5 : Re-Load a part of 'GameServerData'" );
	MyLog( LOG_NORMAL, "ESC : Exit" );
	
	return(1);
}



// 020430 acer 2
/////////////////////////////////////////////////////////////////////////////
extern void InitItemLog( int port );
int InitChrLogDB( int port )
{
	if( GetOwnPort() == port )		// 淬寸 辑滚 牢啊?
	{
		if(!Init_ChrLogDB_SQL( "ChrLogDB", 
			LocalMgr.GetDBAccount(CHRLOG_DB,ID), 
			LocalMgr.GetDBAccount(CHRLOG_DB,PASS)))
		{
			MyLog( LOG_FATAL, "'ChrLogDB' Table Initializing Fail !" );
			JustMsg("'ChrLogDB' Table Initializing Fail !"  );
			return(-1);
			
		}
		MyLog( LOG_NORMAL, "SQL server( ChrLogDB ) connect OK!");
	}
	// item_log 甫 困茄 chrlogdb odbc 汲沥
	InitItemLog( port );
	//MyLog( LOG_FATAL, "Error! init ChrLogDB : This Surver port = [%d], ManagementServer port = [%d]", GetOwnPort(), port );
	return(1);
}
/////////////////////////////////////////////////////////////////////////////



// Rewrote by chan78 at 2000/11/27
// 020620 YGI 
void SaveAllUserDatas(void)
{
	static ct = 0;
	DWORD counter = 0;
	
	MyLog( LOG_IMPORTANT, "Saving Player Datas on DATABASE");
	for( int i = DRAGON_CONNECTIONS_START ; i < DRAGON_MAX_CONNECTIONS ; i ++)
	{
		if( i && !(i % ((DRAGON_MAX_CONNECTIONS/5)?(DRAGON_MAX_CONNECTIONS/5):1)) ) 
		{
			MyLog( 0, "-- Now %d connections are saved (%d/%d)", counter, i, DRAGON_MAX_CONNECTIONS );
		}
		if( connections[i].dwAgentConnectionIndex && connections[i].state >= CONNECT_JOIN )
		{
			int ret1 = updateCharacterStatus(connections, i);
			int ret2 = UpdateCharStatusByKein( connections, i);		// 0410 YGI	// 眠啊 某腐磐 沥焊 历厘
			if( ret1 != 1 || ret2 != 1 )
			{
				ct++;
				CHARLIST *ch = &connections[i].chrlst;
				MyLog( 0, "%03d - Name(%-20s): ERROR_CODE[%d/%d], ID(%d), ServerId(%d), EXP(%u)\n", ct, ch->Name, ret1, ret2, i, ch->GetServerID(), ch->Exp );
			}
			else counter++;
		}
	}
	MyLog( 0, "-- Total %d connections are saved (%d:%d)", counter, i, DRAGON_MAX_CONNECTIONS );
	//SaveGameServerStatus();
};	


void OnDestroy()
{
	EndMapServer();
}
// ----------------------------------------------------------------------------------------------
// Functions End
// ----------------------------------------------------------------------------------------------
#include "GameFactory.h"
// ----------------------------------------------------------------------------------------------
// Main()
// ----------------------------------------------------------------------------------------------
int main()
{	//< CSD-HK-030829
	CGameFactory gameFactory;
	CGameSystem gameSystem;
	gameSystem.SetFactory(&gameFactory);
	//> CSD-HK-030829
	DWORD dwResult;
	bool bServerRunning = false;
	
	INPUT_RECORD	irBuffer;
	memset(&irBuffer,0,sizeof(INPUT_RECORD));
	
	AllocConsole();
	hIn = GetStdHandle(STD_INPUT_HANDLE);
	g_hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	
	SetMonitorSize( SCREEN_TEXT_SIZE_X, SCREEN_TEXT_SIZE_Y );
	
	// Initialize LogManager
	InitMyLog();
	
	// 020620 YGI 
	extern void SetMenuFunctionsAll();
	SetMenuFunctionsAll();
	
	// Init Game Timers
	SettingGameTimers();
	
	// Init Lower Layer.
	if( !InitMapServer() )
		goto FinishMapServer;
	
	// MAP Server Datas loading
	if( !InitDRMapServerDatas() )
		goto FinishMapServer;
	
	// Clear Connection List
	CleanUpConnectionList();

	CLottoSystem::Create();//soto-030505
	
	g_CSymbolMgr.Init(hDBC,hDBC_ChrLogDB);//soto-030512
	g_CSymbolMgr.LoadTable();//soto-030512

	CLottoSystem::Create();//soto-030505
	if(LottoSystem())
	LottoSystem()->LoadTable(hDBC);
	//<soto-030711
	CEventTreasureBoxMgr::Create();
	if(TreasureBoxMgr())
	{
		::TreasureBoxMgr()->LoadTable(hDBC);
	}
	//>soto-030711	
	// Try to connect with PROXY
	g_pINet->ResumeTimer(0);
	// Now Start GameTimers
	g_pINet->ResumeTimer(1);
	// Now Start GhostChecker
	g_pINet->ResumeTimer(2);
	
	while ( g_pServerTable->IsServerRunning() )
	{
		ReadConsoleInput(hIn,&irBuffer,1,&dwResult);
		
		if (irBuffer.EventType == KEY_EVENT)
		{
			if (irBuffer.Event.KeyEvent.bKeyDown)
			{
				switch ( irBuffer.Event.KeyEvent.wVirtualKeyCode )
				{
				case VK_ESCAPE:
					{
						SERVER_DATA *pData;
						int			port = 0;
						if( g_pServerTable )
						{
							pData = g_pServerTable->GetOwnServerData();
							port = pData->wPort;
						}
						
						char temp[ FILENAME_MAX];
						sprintf( temp, "Are you sure to DESTROY this map server( '%s': %d )?", MapName, port );
						if( MessageBox( NULL, temp, "IMPORTANT", MB_YESNO ) == IDYES )
						{
							MyLog( LOG_IMPORTANT, "************ MapServer is closing (%d) **********", port );
							g_pServerTable->DestroyServer( FINISH_TYPE_NORMAL );
							bServerRunning = false;
						}
					}break;
				case VK_F1:
					{
						SetEvent(hKeyEvent[0]);
					}break;
				case VK_F5 :
					{
						
						if( ::MessageBox( NULL,	"Re-Load 'GameServerData' (It will take several seconds) \n "
							"This is Call 'ReLoadGameServerDataByKeyInput()' Fuction "
							, "Re-Load GameServerData", MB_YESNO ) == IDYES )
						{
							SetEvent(hKeyEvent[1]);
						}
					}break;
				case VK_F6:
					{
						SetEvent(hKeyEvent[2]);
					}break;
				case VK_F7: 
					{
						SetEvent( hKeyEvent[3] );
					}break;
				default:
					break;
				}
			}
		}
	}
	
FinishMapServer:
	EndTextScript();//020314 lsw
	MyLog( LOG_NORMAL, "-- MapServer ShutDown :: Now Release SQL" );
	Release_SQL();
	
	MyLog( LOG_NORMAL, "-- MapServer ShutDown :: Now Release INetwork Module, ServerTable" );
	OnDestroy();
	
	MyLog( LOG_NORMAL, "-- MapServer Shutdown :: Now Release Console and Log Resources" );
	FreeConsole();
	FreeMyLog();

	CLottoSystem::Destroy();//soto-030505
	CEventTreasureBoxMgr::Destory();//soto-030711
	return 0;
}

⌨️ 快捷键说明

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