📄 battleserver.cpp
字号:
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <IOCPServer.h>
#include "Battleserver.h"
#include "FieldServerSession.h"
#include "MasterServerSession.h"
#include "ServerSessionFactory.h"
#include "ServerSessionManager.h"
#include <ISolarConsole_Define.h>
#include <ISolarConsole.h>
#include <Define.h>
#include "GameZoneManager.h"
#include "GameHuntingRoom.h"
#include "ServerOptionParser.h"
extern ISolarConsole * g_pIConsole;
BattleServer::BattleServer()
{
m_ServerKey.Set( 0, 0, BATTLE_SERVER, 0 );
SetServerGUID( BATTLE_SERVER );
}
BattleServer::~BattleServer()
{
}
BOOL BattleServer::Init()
{
// INI 颇老 颇教
DISPMSG( "Parsing \"SUNServer.ini\"..." );
m_pFileParser = new CFileParser;
if( !m_pFileParser->ParseInitFile("SUNServer.ini") )
{
DISP_FAIL;
return FALSE;
}
DISP_OK;
SERVER_ENV* pServerEnv = m_pFileParser->GetServerEnv();
// 傈捧辑滚 可记阑 肺靛茄促.
ServerOptionParser::Instance()->Load( "ServerOption.ini", pServerEnv->byBattleServerType );
if( !GameServer::Init() ) return FALSE;
//-------------------------------------------------------------------------------------------------
// 肺弊 颇老 沥焊 檬扁拳
//-------------------------------------------------------------------------------------------------
DISPMSG( "Creating GameLog File...\n" );
g_pLOG = new GameLog;
CreateDirectory(pServerEnv->pszLogPath, NULL);
TCHAR szPath[100], szTextPath[100];
strncpy(szPath, pServerEnv->pszLogPath, 100);
strcat(szPath, "\\\\BATTLE");
strncpy(szTextPath, pServerEnv->pszLogPath, 100 );
strcat(szTextPath, "\\\\BATTLE_TEXT");
if( !g_pLOG->Init( _T(szPath), _T("SUN_BATTLE"), _T(szTextPath) ) )
{
//GameLog甫 父甸瘤 臼嚼聪促.
}
DISP_OK;
g_pSunLog = new CSunLog;
if(g_pSunLog->Init(pServerEnv->bySunLogOption, pServerEnv->bySunLogfileLevel, pServerEnv->pszSunLogfilePath, "Battle") == false)
{
//SunLog甫 父甸瘤 臼嚼聪促.
}
// Battle 辑滚 矫累 肺弊
SUNLOG( eFULL_LOG, "Battle Server Start " );
TCHAR szRoomTitle[40]; strcpy( szRoomTitle, "淬傣" );
TCHAR szRoomPassWord[40]; strcpy( szRoomPassWord, "" );
BASE_ROOMINFO baseRoomInfo;
ADDITIONAL_ROOMINFO addRoomInfo;
addRoomInfo.m_Difficulty = 0;
addRoomInfo.m_Bonus = eHUNTING_BONUS_TYPE_EXPERIENCE;
for( int i = 0; i < 500; ++i )
{
// g_GameZoneManager.CreateHuntingRoom( i+1000, 50, szRoomTitle, szRoomPassWord, &baseRoomInfo, &addRoomInfo );
}
// 霸烙肺弊
//_GAMELOGINIT(GameLogBattle)
return TRUE;
}
VOID BattleServer::Release()
{
GameServer::Release();
// 肺弊
SAFE_DELETE(g_pLOG);
SAFE_DELETE(g_pSunLog);
// 霸烙肺弊
//_GAMELOGRELEASE
}
VOID BattleServer::Run()
{
SERVER_ENV * pServerEnv = m_pFileParser->GetServerEnv();
if(pServerEnv->bGetServerInfoFromFile)
{
ConnectTo( GAME_DBPROXY );
ConnectTo( GUILD_SERVER );
}
else
ConnectTo( MASTER_SERVER );
// 辑滚 矫累
while( 1 )
{
Sleep( 1 );
static DWORD lastUpdateTick = GetTickCount();
DWORD curTick = GetTickCount();
DWORD deltaTick = curTick - lastUpdateTick;
//if( deltaTick >= SERVER_UPDATE_TICK )
{
lastUpdateTick = curTick;
if( !g_pGameServer->Update( deltaTick ) ) break;
}
}
}
BOOL BattleServer::Update( DWORD dwDeltaTick )
{
if( IsOnShutdown() )
{
return FALSE;
}
// 能贾 贸府
if( ProcessConsole() == FALSE )
{
return FALSE; // 辑滚 辆丰
}
return GameServer::Update( dwDeltaTick );
}
BOOL BattleServer::ProcessConsole()
{
#ifndef _USING_SIMPLE_CONSOLE
return g_SUNConsole.Update();
#endif
if( kbhit() )
{
char ch = getch();
ch = (char)toupper(ch);
switch(ch)
{
case 0x1b:
return FALSE;
case 'P': DisplayPoolInfo(); break;
case ' ':
DisplayServerInfo();
break;
}
}
return TRUE;
}
eSERVER_TYPE BattleServer::GetServerType()
{
return BATTLE_SERVER;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -