#include "stdafx.h" #include #include "SBotManager.h" #include "SGame.h" #include "SGameVM.h" #include "SGameInterface.h" #include #include "KDeviceManager.h" #include "KUIWnd.h" #include "SGameViewPort.h" #include "SShadowViewPort.h" #include "SWaterViewPort.h" #include "KRenderDeviceDX.h" #include #include #include "KUITextureManager.h" #include "KTextCacheManager.h" #include "SGameSound.h" #include "SCobManager.h" #include "SSpeedTreeManager.h" #include "KPrimitiveSpriteMng.h" #include "resource.h" #include #include "KUIWndManager.h" #include "SUITopConsoleWnd.h" #include "SLog.h" //#include "Util.h" #include //Game Data #include "SBasicStat.h" #include "SStringDB.h" #include "SSkillDB.h" #include "SItemDB.h" #include "SBanWordDB.h" #include "SCombineDB.h" #include "SDecomposeDB.h" #include "SGameOption.h" #include "SItemEffectResourceDB.h" #include "SDefaultTextureResourceDB.h" #include "SDefaultTextureIconResourceDB.h" #include "SMonsterSpeciesDB.h" #include "SMonsterAffiliationDB.h" #include "SMonsterAffiliationDetailDB.h" #include "SMixCategoryDB.h" //Speed Tree #include "SSpeedTreeConfig.h" #include "KSeqSpeedTree.h" #include "KSeqModel.h" // SpeedGrass #include "KSeqSpeedGrass.h" #include "TerrainSpeedGrass.h" #include #include "SGameCursor.h" #include "SGameManager.h" #include #include "KCommandBuilder.h" #include "SRenderFlag.h" #include "SUIDefine.h" #include "SDebug_Util.h" #include "SGameMilesSoundMgr.h" #include "SGameCircleShadowFX.h" #ifdef _COUNTRY_ME_ #include "Localization/MiddleEast.h" #include "Localization/MiddleEast/KPangoCairo.h" // TEST bintitle. 2010.07.20 #endif /// 2010.11.10 - prodongi #include "SGameLobbyDefine.h" #ifdef CLOUD_LUA #include "SGameCloud.h" #endif //JPG 라이브러리 //#include //#include extern HWND g_hWnd; extern int g_DP_Count[3]; extern int g_UsedMeshEXPoolCount[3]; extern int g_Poly_Count; extern int g_TexMem; extern bool g_bActiveRender; extern void MsgSplit( const char* szMsg, std::vector& vecText, const wchar_t* lpDelimiter, bool bProcSpecialCharacter=false ); extern int GetCodePageFromLang( LANGID langid ); bool g_bCursorRender; ////////////////////////////////////////////////////////////////////////// SBot::SBot( const char * pName, K3DRenderDeviceDX *pRenderDevice, SSoundManager * pSoundMng, KTextureManager * pTextureMng, KNX3Manager * pNX3Mng, KViewportObject ** ppViewportList, int nViewportCount, SGameMilesSoundMgr* pMSoundMgr ) { m_pGameVM = new SGameVM; m_pGameInterface = new SGameInterface; m_pGameMng = new SGameManager( m_pGameVM, m_pGameInterface, pRenderDevice, pSoundMng, pTextureMng, pNX3Mng, ppViewportList, nViewportCount, pMSoundMgr ); m_pGameVM->SetGameManager( m_pGameMng ); m_pGameInterface->Initialize( m_pGameMng ); memset( szName, 0, sizeof(szName) ); strcpy( szName, pName ); m_pGameMng->Init(); m_pGameMng->GameSet(); m_nStep = BOT_SELECT; m_bActiveSkip = FALSE; m_bActiveRender = TRUE; g_bActiveRender = true; } SBot::~SBot() { SAFE_DELETE( m_pGameMng ); SAFE_DELETE( m_pGameInterface ); SAFE_DELETE( m_pGameVM ); } void SBot::onDeviceLost() { if( m_pGameInterface ) m_pGameInterface->onDeviceLost(); } void SBot::ProcConsole( SGameMessage * pGameMsg ) { //치트 처리 m_pGameMng->ProcConsole( pGameMsg ); } LRESULT CALLBACK SBot::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //포커스 잃어 버리면, Render 안되게... switch( message ) { case WM_ACTIVATE : if( g_hWnd == hWnd && wParam != WA_INACTIVE ) { g_bCursorRender = true; } else { g_bCursorRender = false; } break; } _CID( WINDOWMSG ); if( m_pGameInterface->PerformV( id_WINDOWMSG, message, (unsigned long)wParam, (unsigned long)lParam ) ) { return 1; } return m_pGameMng->WndProc(hWnd, message, wParam, lParam); } void *SBot::Perform( KID id, KArg& msg ) { return (void*)0; } //Build System //테스트 시작 void SBot::DoTest() { } //보고서 작성 void SBot::DoReport() { } bool SBot::IsLoadGameActivated() { return m_pGameMng->IsLoadGameActivated(); } void SBot::onHotkey( GameHotKeystrcut & HotKey ) { if( m_pGameMng ) m_pGameMng->onHotkey( HotKey ); } void SBot::Process( unsigned long uProcessBitVector ) { if( GetKeyState( VK_NUMLOCK ) > 0 ) m_bActiveSkip = TRUE; else m_bActiveSkip = FALSE; m_pGameMng->Process( uProcessBitVector ); } SGame * SBot::GetActiveGame() { return m_pGameMng->GetActiveGame(); } void SBot::Render( unsigned long uRenderBitVector ) { if( m_bActiveSkip ) { m_pGameMng->Render( uRenderBitVector ); } else { if( m_bActiveRender == TRUE ) m_pGameMng->Render( uRenderBitVector ); } } void SBot::AfterRender( unsigned long uRenderBitVector ) { m_pGameMng->AfterRender( uRenderBitVector ); } void SBot::ProcSecurityMsg( GameSecurityMsg* pSecurityMsg ) { m_pGameMng->ProcSecurityMsg( pSecurityMsg ); } void SBot::InitializeScriptForGameUI() { if( m_pGameInterface ) m_pGameInterface->InitializeAddonScript(); } bool SBot::GameGuardSendToServer( const GG_AUTH_DATA* pAuthdata ) { return m_pGameMng->GameGuardSendToServer( pAuthdata ); } bool SBot::GameGuardSendToServer( const PCSAuth3Data pAuthdata ) { return m_pGameMng->GameGuardSendToServer( pAuthdata ); } ////////////////////////////////////////////////////////////////////////// // static SGameVM* m_pGameVM; SBotManager* SBotManager::m_pBotThis = NULL; SBotManager::SBotManager( HWND hWnd, HINSTANCE hInstance ) { m_nSelectBot = -1; for(int i = 0; i < 10; ++i) m_pViewportList[i] = NULL; m_nViewportCount = 0; m_pUIWndManager = NULL; m_pConsoleWnd = NULL; m_pSystemInfoWnd = NULL; m_bActConsole = false; m_bActSystemInfo = false; m_ulProcessBitVector = Game_ProcessAll; m_ulRenderBitVector = Bot_RenderAll; m_bUseHqWater = false; m_pCursorMng = NULL; m_pSoundMng = NULL; m_pMSoundMgr = NULL; m_bActiveRender = TRUE; g_bActiveRender = true; m_bCheckRender = true; m_dwCheckTime = 0; Init( hWnd, hInstance ); } SBotManager::~SBotManager() { Destroy(); } void SBotManager::BotTest() { char szName[32]; memset( szName, 0, sizeof(szName) ); //for( int i=0; 1>i; i++ ) //{ // XStringUtil::Format( szName, "bot%02d", i+1 ); // Bot_Add( szName ); //} Bot_Add( "bot03" ); m_nSelectBot = 0; } void SBotManager::SetShowWater( bool bShowWater ) { if( m_nViewportCount < 1 ) return; m_pViewportList[0]->SetUseWater( bShowWater ); if( m_nViewportCount != 3 ) return; m_pViewportList[2]->SetUseViewPort( bShowWater ); } void SBotManager::Init( HWND hWnd, HINSTANCE hInstance ) { ////////////////////////////////////////////////////////////////////////// //Speed Tree float afLight1[] = { //c_afLightPosition[0], c_afLightPosition[1], c_afLightPosition[2], // pos 5000000*0.33f, 5000000*0.66f, 5000000*0.66f, c_afLightDiffuse[0], c_afLightDiffuse[1], c_afLightDiffuse[2], // diffuse c_afLightAmbient[0], c_afLightAmbient[1], c_afLightAmbient[2], // ambient c_afLightSpecular[0], c_afLightSpecular[1], c_afLightSpecular[2], // specular 0.f, // directional flag 0.0f, 0.0f, 0.0f // attenuation (constant, linear, quadratic) }; m_fLastElapsedTime = 0.0f; m_fElapsedTime = 0.0f; m_fAccumTime = 0.0f; m_fOldStrength = 0.2f; //나무 흔들림 설정 m_fWindStrength = 0.2f; //나무 흔들림 설정 // set light attributes and enable static light 0 CSpeedTreeRT::SetLightAttributes(0, afLight1); CSpeedTreeRT::SetLightState(0, true); CSpeedTreeRT::SetNumWindMatrices(c_nNumWindMatrices); KSeqSpeedGrass::SetFadeDist( 400.0f ); KSeqSpeedGrass::SetFadeLength( 200.0f ); // Render Device 초기화 K3DRenderDeviceDX::CS cs; if( ENV().IsExist( "16bit" ) ) cs.nBPP = 16; else cs.nBPP = 32; //if(ENV().IsExist("perf_hud") ) // cs.bNVidiaPerfHud = true; m_nScreenCount = 0; //실행 옵션 관련 std::string strRes; std::string strRenderMode; //하드웨어,소프트웨어 if( ENV().IsExist( "render" ) ) { strRenderMode = ENV().GetString( "render" ); if( strstr( strRenderMode.c_str(), "hw_mode" ) ) cs.dwOption = 1; else cs.dwOption = 0; } else { //없으면, 기본으로 하드웨어 모드 strRenderMode = "hw_mode"; cs.dwOption = 1; } //기본 경로 if( ENV().IsExist( "res" ) ) { strRes = ENV().GetString( "res" ); XStringUtil::Replace( strRes, "\\", "/" ); } else { char szDir[_MAX_PATH]; memset( szDir, 0, sizeof(szDir) ); GetCurrentDirectory( _MAX_PATH, szDir ); strRes = szDir; strRes += "\\"; } //#define _WEB_DISP_MODE #ifdef _WEB_DISP_MODE cs.bFullScreen = false; #else //설정이 안되어 있으면 if( GetGameOption().GetWinMode() == -1 ) { cs.bFullScreen = ENV().IsExist( "full" ); } else { if( ENV().IsExist( "win" ) ) { cs.bFullScreen = false; } else { //게임 옵션 cs.bFullScreen = GetGameOption().GetWinMode() == 0 ? true : false; } } #endif KUIWnd::SetEnterChatMode ( GetGameOption().IsEnterChat() ); KUIWndManager::SetEnterChatMode( GetGameOption().IsEnterChat() ); cs.hWnd = hWnd; cs.hFocusWnd = hWnd; //지원 해상도 알아 내기/////////////////////////////////////////////////// K3DRenderDeviceDX * pDevice = new K3DRenderDeviceDX; pDevice->SetSupportDispMode(); const D3DDISPLAYMODE & cur_disp_mode = pDevice->GetCurrentDispMode(); GetGameOption().SetCurrentRefreshRate( cur_disp_mode.RefreshRate ); const std::vector< D3DDISPLAYMODE > & cur_disp_list = pDevice->GetDispMode(); for( unsigned int i(0); cur_disp_list.size()>i; i++ ) { UINT width = cur_disp_list[i].Width; UINT height = cur_disp_list[i].Height; UINT refreshrate = cur_disp_list[i].RefreshRate; GetGameOption().AddDispMode( width, height, refreshrate ); } SAFE_DELETE( pDevice ); ////////////////////////////////////////////////////////////////////////// KSize sizResolution; int nWidth = GetGameOption().GetResolution_Width(); int nHeight = GetGameOption().GetResolution_Height(); sizResolution = KSize(nWidth, nHeight); KUIWndManager::SetResolution( sizResolution ); RECT rect; GetClientRect(hWnd, &rect); ::ShowCursor( FALSE ); int cx = GetSystemMetrics(SM_CXSCREEN); int cy = GetSystemMetrics(SM_CYSCREEN); if ( cs.bFullScreen ) { cx = 1024, cy = 768; // cx = RES_1280, cy = RES_1024; } float va = (float)cy / cx; if ( va < .5f ) { cx /= 2; } //cs.sizeScreen.width = cx; //cs.sizeScreen.height = cy; cs.sizeScreen.width = sizResolution.cx; cs.sizeScreen.height = sizResolution.cy; KDeviceManagerDX::Initialize( hWnd, hInstance, cs ); m_pGraphics = (K3DRenderDeviceDX *)KDeviceManagerDX::GetDeviceManager()->GetRenderDevice(); KSeqSpeedTree::SetRenderingDevice( m_pGraphics ); KSeqSpeedGrass::SetRenderDevice( m_pGraphics ); KUITextureManager::SetRenderDevice( m_pGraphics ); #ifdef _KUI_INVALIDATION // { [sonador] KUICachedTextureManager::SetRenderDevice( m_pGraphics ); // } #endif // Sound Device 초기화 //리소스 관련... // Texture Manager 설정 m_pTextureManager = KTextureManager::GetManager(); m_pTextureManager->SetTextureSearchPolicy( KTextureManager::ORG_THEN_DDS ); // 게임에서는 무조건 확장자를 DDS로 바꿔 그것만 읽는다. - Tyburn SGameOption& game_option = GetGameOption(); if( ENV().IsExist( "minimum_system" ) ) { KNX3Manager::GetManager()->SetSystemRequirements( KNX3Manager::MINIMUM_SYSTEM ); game_option.SettingForMinimumSystem(); } else if( ENV().IsExist( "maximum_system" ) ) { KNX3Manager::GetManager()->SetSystemRequirements( KNX3Manager::MAXIMUM_SYSTEM ); game_option.SettingForMaximumSystem(); } else { if( game_option.GetPresetOption() == 1 ) KNX3Manager::GetManager()->SetSystemRequirements( KNX3Manager::MINIMUM_SYSTEM_BY_USER_SELECT ); else KNX3Manager::GetManager()->SetSystemRequirements( KNX3Manager::MIXED_SYSTEM ); } //텍스쳐 품질 0 저품질, 1 기본 NX3LoadPack::SetTextureLevel( !game_option.GetResourceQuality() ); // NX3 Manager 관련 m_pNX3Mgr = KNX3Manager::GetManager(); // NX3 File Template 등록 { KStream * pStream = KFileManager::Instance().CreateStreamFromResource( "NX3.tml" ); KFiler::RegisterTemplates( *pStream ); pStream->Seek( 0, KStream::seekSet ); KNX3Manager::GetManager()->GetMetaData().importTML( *pStream ); KFileManager::Instance().DeleteStream( pStream ); } // NOB File Template 등록 { KStream * pStream = KFileManager::Instance().CreateStreamFromResource( "NObj.tml" ); KFiler::RegisterTemplates( *pStream ); pStream->Seek( 0, KStream::seekSet ); COBManager::GetManager()->GetMetaData().importTML( *pStream ); KFileManager::Instance().DeleteStream( pStream ); } //KSeqModel * pTest = new KSeqModel; //pTest->Initialize( GetSafeTickCount() ); //pTest->AddAnimation( "card_start", "rcfx_login_asuracard01_start.nx3" ); //SAFE_DELETE( pTest ); //KNX3Manager::GetManager()->PrintList( "릴리즈_테스트.txt" ); m_pMSoundMgr = new SGameMilesSoundMgr; if( m_pMSoundMgr->Initialize( hWnd ) ) { m_pMSoundMgr->SetSfxVolume( (game_option.GetSFX_Volume()+1)*10 ); m_pMSoundMgr->SetBgmVolume( (game_option.GetBGM_Volume()+1)*10 ); m_pMSoundMgr->SetEnvVolume( (game_option.GetENVS_Volume()+1)*10 ); m_pMSoundMgr->SetMasterVolume( (game_option.GetMASTER_Volume()+1)*10 ); } KViewportStruct vp; // vp.Width = RES_1280;//1024; // vp.Height = RES_1024;//768; vp.Width = sizResolution.cx; vp.Height = sizResolution.cy; vp.X = vp.Y = 0; vp.MinZ = 0; vp.MaxZ = 1.0f; SGameViewPort * pGameViewPort = new SGameViewPort(); pGameViewPort->Initilaize( m_pGraphics, vp, 5.f, 6000.f ); pGameViewPort->SetFillColor( KColor( 255, 255, 255, 0 ) ); // pGameViewPort->SetFillColor( KColor( 204, 222, 248, 255 ) ); pGameViewPort->SetSceneAmbient( KColor(0,0,0,255) ); // { //pGameViewPort->SetUseHDR( true ); pGameViewPort->InitHdr(); } m_pViewportList[0] = pGameViewPort; m_nViewportCount = 1; //텍스쳐 스테이지 4개보다 작으면, 스페큘러 안됨 const D3DCAPS9 & rCaps = m_pGraphics->GetCaps(); if( rCaps.MaxSimultaneousTextures >= 4 ) { //Lobby 가 끝나면 자동으로 불러짐. InitViewportEx(); if( rCaps.PixelShaderVersion >= D3DPS_VERSION( 2, 0 ) ) { } else { ((SViewPort*) m_pViewportList[0])->SetRenderBumpMapMode(false); // 나중에 옵션으로 빼서 정리하자 by blackfish } } else { //저 사양 그래픽 임. m_pViewportList[0]->SetUseSpecular( false ); //Game ((SViewPort*) m_pViewportList[0])->SetRenderBumpMapMode(false); // 나중에 옵션으로 빼서 정리하자 by blackfish } //게임 컨텐츠 DB 미리 Load GetStringDB(); GetItemReferenceDB(); GetItemDB(); GetDefaultItemDB(); GetCombineDB(); GetSkinColorTable(); GetItemEffectResourceDB(); GetDefaultTextureResourceDB(); GetDefaultTextureIconResourceDB(); GetMixCategoryDB(); GetDecomposeDB(); GetMonsterSpeciesDB(); GetMonsterAffiliationDB(); GetMonsterAffiliationDetailDB(); GetSummonRandomSkillDB(); GetGameOption().InitChattinSet(); /*// 국가별 정보파일 sfreer 2009.07.07 if(GetLocaleOption().LoadOptionFile("localeinfo.ini") == false) { MessageBox(NULL, "'localeinfo' File Not Found","error", MB_OK); }*/ if( GetLocaleOption().GetValueInt("CODEPAGE", -1) >=0 ) { KTextRender::SetDefaultCodePage( GetLocaleOption().GetValueInt("CODEPAGE", -1) ); #ifdef _COUNTRY_ME_ g_pGameOperationManager->SetDefaultCodePage( GetLocaleOption().GetValueInt("CODEPAGE", -1) ); #endif } else { //코드페이지가 설정되어 있지 않을경우 윈도우 시스템 코드페이지를 //KTextRender의 기본 코드페이지로 설정 한다. //2009-10-05 : hunee LANGID langId = GetSystemDefaultLangID(); int codePage = GetCodePageFromLang(langId); KTextRender::SetDefaultCodePage(codePage); } // GetBanWordDB(); // GetFieldTypeMaterialDB(); GetAbuseDB(); // GetAnimationDB(); #ifdef CLOUD_LUA GetCloudLayerSetDB(); GetCloudLayerDB(); GetCloudTypeInfoDB(); GetCloudPathDB(); GetCloudMoveDirDB(); GetCloudLayerGapDB(); GetCloudHeightRadomGapDB(); GetCloudDistributionDB(); GetCloudTxrGroupDB(); GetCloudSizeDB(); GetCloudThicknessGapDB(); GetCloudThicknessDB(); GetCloudKindDB(); #endif // GetLog().OutputFile(); // 로그가 모두 완료 되면, 다시 넣자. //Network Init if( !XNetworkUtil::InitNetwork() ) return; // UI관련 Init #ifdef _COUNTRY_ME_ // UI관련 Init KTextRender::InitTextRender( m_pGraphics, 1256, ENV().GetString( "default_font", "Tahoma" ).c_str() ); //KTextRender::InitTextRender( m_pGraphics, 1256, "Tahoma" ); KTextLayout::InitLayoutEngine(); // TEST bintitle. 2010.07.20 밑줄이 원본. KTextLayout2::InitLayoutEngine( m_pGraphics ); #else KTextRender::InitTextRender( m_pGraphics ); #endif // KTextRender::AddFreeTypeFont( KTextRender::KDEFAULT_FONT_NAME, "font.ttf" ); KTextRender::AddFont( KTextRender::KDEFAULT_FONT_NAME, KTextRender::KDEFAULT_FONT_SIZE ); KTextRender::AddFont( S(6307)/*"돋움"*/, KTextRender::KDEFAULT_FONT_SIZE ); KUIWndManager::SetHandle( hWnd, hInstance ); //콘솔용 윈도우 Manager~ m_pUIWndManager = new KUIWndManager; CreateConsoleWnd(); m_pCursorMng = new SGameCursorMng( m_pGraphics, m_pTextureManager ); //m_nExit = 1; // 옵션 초기화 ((SGameViewPort *)m_pViewportList[0])->SetBloomEffect( GetGameOption().GetGlowQuality() ); //텍스쳐 밉 바이어스 if( ENV().IsExist( "texqual" ) ) m_pTextureManager->SetMipMapBiasLevel( atoi( ENV().GetString( "texqual" ).c_str()) ); else { int nMipBias = 0; switch( GetGameOption().GetTextureMipBias() ) { case 0 : nMipBias = 2; break; case 1 : nMipBias = 1; break; case 2 : nMipBias = 0; break; } m_pTextureManager->SetMipMapBiasLevel( nMipBias ); } m_pTextureManager->init(); BotTest(); } int SBotManager::InitViewportEx() { /// 2012.04.06 안쓰인다 - prodongi //((SGameViewPort *)m_pViewportList[0])->CreateOcclusionBuffers(); const D3DCAPS9 & rCaps = m_pGraphics->GetCaps(); //m_bUseHqWater = rCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP; if( rCaps.MaxSimultaneousTextures < 4 ) { //저 사양 그래픽 임. m_bUseHqWater = false; SetShowWater(m_bUseHqWater); return m_nViewportCount; } if( m_nViewportCount != 1 ) return m_nViewportCount; KViewportStruct vp; //그림자용 ViewPort vp.X = 0; vp.Y = 0; vp.Width = SIZE_RT_1024; vp.Height = SIZE_RT_1024; vp.MinZ = 0.f; vp.MaxZ = 1.0f; SShadowViewPort * pShadowViewport = new SShadowViewPort(true, false); pShadowViewport->Initilaize( m_pGraphics, vp, 100.f, 8000.f ); pShadowViewport->SetFillColor( KColor( 255,255,255,255 ) ); KSize shadowviewsize( RECT_SHADOW_1024, RECT_SHADOW_1024 ); pShadowViewport->SetViewArea( KRect( KPoint(0, 0), shadowviewsize ) ); //pShadowViewport->SetGameViewport((SViewPort*) m_pViewportList[0]); m_pViewportList[1] = pShadowViewport; ((SGameViewPort *)m_pViewportList[0])->SetShadowViewPort( pShadowViewport ); m_nViewportCount = 2; // return m_nViewportCount; m_bUseHqWater = rCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP; //m_bUseHqWater = true; // 이거 키면 와이어 프리미티브가 안나와서 임시로 끔.. by blackfish if(m_bUseHqWater) { //Water용 ViewPort vp.X = 0; vp.Y = 0; vp.Width = SIZE_RT_1024; vp.Height = SIZE_RT_1024; vp.MinZ = 0.f; vp.MaxZ = 1.0f; SWaterViewPort * pWaterViewport = new SWaterViewPort; pWaterViewport->Initilaize( m_pGraphics, vp, 5.f, 6000.f ); pWaterViewport->SetFillColor( KColor( 255,255,255,255 ) ); KSize waterviewsize( RECT_WATER_1024, RECT_WATER_1024 ); pWaterViewport->SetViewArea( KRect( KPoint(0, 0), waterviewsize ) ); //pWaterViewport->SetGameViewport((SViewPort*) m_pViewportList[0]); m_pViewportList[2] = pWaterViewport; ((SGameViewPort *)m_pViewportList[0])->SetWaterViewPort( pWaterViewport ); pWaterViewport->SetUseViewPort( true ); m_nViewportCount = 3; } SetShowWater(m_bUseHqWater); return m_nViewportCount; } void SBotManager::Destroy() { if( m_pMSoundMgr ) { m_pMSoundMgr->StopMusic(); m_pMSoundMgr->StopBgm(); } SCircleShadowCommonInfo::GetInstance().Destroy(); SAFE_DELETE( m_pCursorMng ); SAFE_DELETE( m_pConsoleWnd ); SAFE_DELETE( m_pSystemInfoWnd ); SAFE_DELETE( m_pUIWndManager ); SAFE_DELETE_VECTOR( m_BotList ); for(int i = 0; i < 10; ++i) SAFE_DELETE( m_pViewportList[i] ); m_nViewportCount = 0; KTextRender::DestroyAll(); #ifdef _COUNTRY_ME_ KTextLayout2::DestroyLayoutEngine(); /// 2010.10.20 빠진것 같음 - prodongi KTextLayout::DestroyLayoutEngine(); #endif XNetworkUtil::DeInitNetwork(); _oprint( "Thread Loading Count : %d\n", KNX3Manager::GetManager()->GetThreadLoadingCount() ); while( KNX3Manager::GetManager()->GetThreadLoadingCount() ) { Sleep(1); } // Release 하는 순서 중요 (KTextureManager를 맨 나중에 Release 하자) KNX3Manager::GetManager()->ClearUnreferencedResource(); //여기서 모든 NX3Set 은 삭제 되야 한다. KTextCacheManager::GetInstance()->DestroyAll(); KPrimitiveSpriteMng::GetManager()->Clear(); KPrimitiveSpriteMng::ReleaseManager(); KSpriteManager::ReleaseManager(); COBManager::ReleaseManager(); SpeedTreeManager::ReleaseManager(); KNX3Manager::ReleaseManager(); KUITextureManager::ReleaseManager(); KTextureManager::ReleaseManager(); //Device 삭제. KDeviceManager *pDM = KDeviceManagerDX::GetDeviceManager(); if( pDM ) pDM->Clear(); SAFE_DELETE( m_pSoundMng ); SAFE_DELETE( m_pMSoundMgr ); } void SBotManager::onHotkey( GameHotKeystrcut & HotKey ) { static DWORD dwLastSnapShow; /// 2010.11.10 - prodongi if (g_UserInfo.isMonkeyTail()) { extern bool g_bDebugMode; if( g_bDebugMode && !m_bCheckRender && HotKey.Virtual_Key == VK_ESCAPE ) { m_bCheckRender = true; return; } if( g_bDebugMode && !HotKey.bUp && ( GetKeyState( VK_SCROLL ) & 0x01 ) && HotKey.Virtual_Key == VK_OEM_PLUS ) { m_bActConsole = !m_bActConsole; if(m_bActConsole) { m_pConsoleWnd->SetShow( true ); m_pUIWndManager->AddWnd(m_pConsoleWnd); } else { m_pConsoleWnd->SetShow( false ); m_pUIWndManager->RemoveWnd(m_pConsoleWnd); } return; } if( g_bDebugMode && !HotKey.bUp && ( GetKeyState( VK_SCROLL ) & 0x01 ) && HotKey.Virtual_Key == VK_OEM_2 ) // '/' { m_bActSystemInfo = !m_bActSystemInfo; if(m_bActSystemInfo) { m_pSystemInfoWnd->SetShow( true ); m_pUIWndManager->AddWnd(m_pSystemInfoWnd); } else { m_pSystemInfoWnd->SetShow( false ); m_pUIWndManager->RemoveWnd(m_pSystemInfoWnd); } return; } } ////////////////////////////////////////////////////////////////////////// //스샷 if(!HotKey.bUp && (GetKeyState(VK_SCROLL) ) && HotKey.Virtual_Key == VK_OEM_2) { if( dwLastSnapShow + 3000 < GetSafeTickCount() ) { HWND hWnd=g_hWnd; RECT rcWnd; GetClientRect(hWnd, &rcWnd); ClientToScreen(hWnd, ((LPPOINT)&rcWnd)); ClientToScreen(hWnd, ((LPPOINT)&rcWnd)+1); SaveScreenBMP( rcWnd, false ); dwLastSnapShow = GetSafeTickCount(); } } if (HotKey.Virtual_Key == VK_SNAPSHOT) { if (dwLastSnapShow + 3000 < GetSafeTickCount()) { HWND hWnd = g_hWnd; RECT rcWnd; GetClientRect(hWnd, &rcWnd); ClientToScreen(hWnd, ((LPPOINT)&rcWnd)); ClientToScreen(hWnd, ((LPPOINT)&rcWnd) + 1); SaveScreenBMP(rcWnd, false); dwLastSnapShow = GetSafeTickCount(); } } ////////////////////////////////////////////////////////////////////////// if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->onHotkey( HotKey ); } } bool SBotManager::IsLoadGameActivated() { if( m_nSelectBot >= 0 ) { return m_BotList[m_nSelectBot]->IsLoadGameActivated(); } return false; } void SBotManager::Bot_Add( const char * pName ) { _oprint( "Bot_Add\n" ); SBot * pBot = new SBot( pName, m_pGraphics, m_pSoundMng, m_pTextureManager, m_pNX3Mgr, m_pViewportList, m_nViewportCount, m_pMSoundMgr ); m_BotList.push_back(pBot); } void SBotManager::Bot_Del( const char * pName ) { _oprint( "Bot_Del\n" ); } void SBotManager::Bot_Del_all() { _oprint( "Bot_Del_all\n" ); } void SBotManager::Bot_List() { _oprint( "Bot_List\n" ); } void SBotManager::Bot_Select( const char * pName ) { _oprint( "Bot_Select\n" ); } void SBotManager::LogSave() { } LRESULT CALLBACK SBotManager::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //포커스 잃어 버리면, Render 안되게... switch( message ) { case WM_ACTIVATE : if( g_hWnd == hWnd ) { if( LOWORD(wParam) == WA_INACTIVE ) { // 2010.08.12 - prodongi //#ifndef _DEV // m_bActiveRender = FALSE; //#endif g_bActiveRender = false; if( GetGameOption().GetWinMode() == 0 ) { // 2010.09.24 디버깅 때문에 - prodongi //#ifndef _DEBUG #if !defined(_DEBUG) && !defined(_DEV) ::ShowWindow( g_hWnd, SW_MINIMIZE ); #endif } } else/* if( LOWORD(wParam) == WA_ACTIVE ) || (LOWORD(wParam) == WA_CLICKACTIVE) ) */ { m_bActiveRender = TRUE; g_bActiveRender = true; ::ShowWindow( g_hWnd, SW_SHOW ); ::SetFocus( g_hWnd ); } if( m_pBotThis && m_pBotThis->m_nSelectBot >= 0/* && m_nExit*/ ) m_pBotThis->m_BotList[m_pBotThis->m_nSelectBot]->SetActiveRender( m_bActiveRender ); } break; case WM_SIZE: if( g_hWnd == hWnd ) { if( GetGameOption().GetWinMode() == 1 ) { if( wParam == SIZE_MINIMIZED ) { m_bActiveRender = FALSE; g_bActiveRender = false; if( m_pBotThis && m_pBotThis->m_nSelectBot >= 0/* && m_nExit*/ ) m_pBotThis->m_BotList[m_pBotThis->m_nSelectBot]->SetActiveRender( m_bActiveRender ); } } } break; } if( WM_SYSKEYDOWN == message || WM_SYSKEYUP == message ) // #2.3.1.29 return 1; // 이거 풀면 종료 메시지박스 제대로 안될것임 ... //if( WM_CLOSE == message ) //{ // m_nExit = 0; //이후 처리는 하지 않음. // _oprint( "WM_CLOSE 왔다\n" ); //} //콘솔 우선 처리 if( m_pUIWndManager/* && m_nExit*/ ) { if( m_bActConsole/* && m_nExit*/ ) { _CID( WINDOWMSG ); if( m_pUIWndManager->PerformV( id_WINDOWMSG, message, (unsigned long)wParam, (unsigned long)lParam ) ) return 1; //뭔가 처리가 됐음. } } ////Cursor & IME { //Basic Cusor NULL switch( message ) { case WM_SETCURSOR : { ::SetCursor( NULL ); m_pCursorMng->ShowCursor( TRUE ); } return TRUE; break; case WM_MOUSEMOVE : { if( m_pGraphics->GetCaps().CursorCaps & D3DCURSORCAPS_LOWRES ) { //소프트웨어 커서일 경우에만 써야 되는 듯... POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); ClientToScreen( g_hWnd, &pt ); if( m_pCursorMng ) m_pCursorMng->SetCursorPos( pt.x, pt.y ); } } break; } } if( m_pBotThis && m_pBotThis->m_nSelectBot >= 0/* && m_nExit*/ ) { //선택된 Bot만 컨트롤이 가능하다. return m_pBotThis->m_BotList[m_pBotThis->m_nSelectBot]->WndProc(hWnd, message, wParam, lParam); } return 0; } void *SBotManager::Perform( KID id, KArg& msg ) { if( m_pUIWndManager ) m_pUIWndManager->Perform( id, msg ); return (void*)0; } void SBotManager::Process( DWORD dwSetTime ) { DWORD dwTime = GetSafeTickCount(); if (dwSetTime > 0) { dwTime = dwSetTime; } else { if( m_bActiveRender == FALSE ) { if( m_dwCheckTime == 0 ) m_dwCheckTime = dwTime; if( (dwTime - m_dwCheckTime) < 200 ) { Sleep(100); return; } else { m_dwCheckTime = dwTime; } } } m_fTime = dwTime * 0.001; if( m_fLastElapsedTime == 0.f ) m_fLastElapsedTime = m_fTime; m_fElapsedTime = (double) (m_fTime - m_fLastElapsedTime); m_fLastElapsedTime = m_fTime; m_fAccumTime += m_fElapsedTime; if( GetGameOption().IsTreeRender() ) { CSpeedTreeRT::SetTime( m_fAccumTime ); SetupWindMatrices( m_fAccumTime ); } if( GetGameOption().IsGrassRender() ) { KSeqSpeedGrass::SetAccumTime( m_fAccumTime ); } if( m_pCursorMng ) m_pCursorMng->Process( dwTime ); if( m_pUIWndManager ) m_pUIWndManager->Process( dwTime ); for( unsigned int i(0); m_BotList.size()>i; i++ ) { DWORD dwBotTime = GetSafeTickCount(); m_BotList[i]->Process( m_ulProcessBitVector ); if( GetSafeTickCount() - dwBotTime > 200 ) { _oprint( "CAUTION: Process(%s) : %d\n", m_BotList[i]->GetName(), GetSafeTickCount() - dwTime ); } } } SBot* SBotManager::GetCurBot() { if( m_nSelectBot >= 0 ) return m_BotList[m_nSelectBot]; return NULL; } extern VARIANT_BOOL g_IsShowWebBrowser; extern bool g_IsShowWebBrowserChanged; void SBotManager::Render( unsigned long uRenderBitVector ) { if( m_bActiveRender == FALSE ) return; if( m_bCheckRender == false ) return; //gmpbigsun( 20130329 ) : 웹브라우저가 활성화 상태라면 DialogBoxMode 항상 ON ( 투명처럼 보이는 문제 ) //if ( g_IsShowWebBrowserChanged ) //{ // //소프트웨어 커서 생기면 삭제 해야 함. // if( m_pGraphics->GetCaps().CursorCaps & D3DCURSORCAPS_LOWRES || // m_pGraphics->GetCaps().CursorCaps == 0 ) // { // m_pGraphics->GetD3DDevice()->SetDialogBoxMode( TRUE ); // } // else // { // m_pGraphics->GetD3DDevice()->SetDialogBoxMode( g_IsShowWebBrowser ); // 웹브라우저를 띄우는 경우 페이지 플리핑을 끈다. - by Tyburn // } // g_IsShowWebBrowserChanged = false; //} if( g_IsShowWebBrowser ) m_pGraphics->GetD3DDevice()->SetDialogBoxMode( TRUE ); g_DP_Count[0] = 0; g_DP_Count[1] = 0; g_DP_Count[2] = 0; g_UsedMeshEXPoolCount[0] = 0; g_UsedMeshEXPoolCount[1] = 0; g_UsedMeshEXPoolCount[2] = 0; g_Poly_Count = 0; if( m_pCursorMng ) m_pCursorMng->Render(); if( m_ulRenderBitVector & Bot_RenderActBot ) { if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->Render( m_ulRenderBitVector ); } } if( uRenderBitVector & Bot_RenderConsole ) { //콘솔을 나중에 Render if( m_pUIWndManager ) m_pUIWndManager->Render( m_pViewportList[0] ) ; } { m_pGraphics->BeginScene(); } g_Poly_Count = 0; START_ONE_FRAME(); if( m_ulRenderBitVector & Bot_RenderViewShadow ) { if(m_pViewportList[1]) { g_UsedMeshEXPoolCount[1] = m_pViewportList[1]->GetUsedMeshEXPoolCount(); m_pViewportList[1]->Render(false); g_DP_Count[0] = m_pGraphics->GetDPCount(); g_Poly_Count += m_pGraphics->GetPolyCount(); } } if( m_ulRenderBitVector & Bot_RenderViewWater ) { if( m_pViewportList[2] && m_pViewportList[0]->GetUseWater() && m_pViewportList[0]->IsRenderWater() ) { g_UsedMeshEXPoolCount[2] = m_pViewportList[2]->GetUsedMeshEXPoolCount(); m_pViewportList[2]->Render(false); g_DP_Count[1] = m_pGraphics->GetDPCount(); g_Poly_Count += m_pGraphics->GetPolyCount(); } } if( m_ulRenderBitVector & Bot_RenderViewGame ) { g_UsedMeshEXPoolCount[0] = m_pViewportList[0]->GetUsedMeshEXPoolCount(); m_pViewportList[0]->Render(); if(m_pViewportList[1]) m_pViewportList[1]->ClearRegisteredList(); if(m_pViewportList[2]) m_pViewportList[2]->ClearRegisteredList(); } END_ONE_FRAME(); g_DP_Count[2] = m_pGraphics->GetDPCount(); g_Poly_Count += m_pGraphics->GetPolyCount(); #ifdef DEBUG g_TexMem = m_pGraphics->GetD3DDevice()->GetAvailableTextureMem(); #endif { m_pGraphics->EndScene(); } { if( m_pGraphics ) { HRESULT hr = m_pGraphics->Render(); if( hr == D3DERR_DEVICELOST ) { SGameCursorMng::OnDeviceLost(); KUITextureManager::GetManager()->DeviceLost(); KPrimitiveSpriteMng::GetManager()->DeviceLost(); if( m_nSelectBot >= 0 ) m_BotList[m_nSelectBot]->onDeviceLost(); } } } if( m_ulRenderBitVector & Bot_RenderActBot ) { if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->AfterRender( m_ulRenderBitVector ); } } } bool ilSaveImageBGRA(const DWORD* c_pdwSrc, UINT uPitch, UINT uWidth, UINT uHeight, const char* c_szFileName, bool bJPG = true) { ilInit(); ilEnable(IL_FILE_OVERWRITE); if( bJPG ) ilSetInteger(IL_JPG_QUALITY, 85); ILuint uHandle; ilGenImages(1, &uHandle); ilBindImage(uHandle); bool isSucceeded=false; if (ilTexImage(uWidth, uHeight, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL)) { DWORD* pdwDst=(DWORD*)ilGetData(); if( pdwDst == NULL ) return false; for (UINT i=0; iGetD3DDevice()->GetDisplayMode(0, &mode); if(FAILED(hr)) { _oprint("Unable to get front buffer size\n"); return; } //비디오 메모리 영역 넘어간 윈도우는 스샷 만들지 않음. if( c_rcWnd.left < 0 || c_rcWnd.right > mode.Width || c_rcWnd.top < 0 || c_rcWnd.bottom > mode.Height ) return; //Create an image surface the same size as the window LPDIRECT3DSURFACE9 surface=NULL; hr=m_pGraphics->GetD3DDevice()->CreateOffscreenPlainSurface(mode.Width, mode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, NULL); if(FAILED(hr)) { _oprint("Unable to create surface to hold screenshot"); return; } //Copy the front buffer onto the surface hr=m_pGraphics->GetD3DDevice()->GetFrontBufferData(0, surface); if(FAILED(hr)) { _oprint("Unable to read front buffer"); if(surface) surface->Release(); surface=NULL; return; } bool isSucceeded=false; D3DLOCKED_RECT kD3DLockRect; if (SUCCEEDED(surface->LockRect(&kD3DLockRect, NULL, 0))) { const DWORD* c_pdwBase=(const DWORD*)kD3DLockRect.pBits; UINT uPitch=kD3DLockRect.Pitch/sizeof(DWORD); UINT uWidth=c_rcWnd.right-c_rcWnd.left; UINT uHeight=c_rcWnd.bottom-c_rcWnd.top; if( uWidth > GetGameOption().GetResolution_Width() || uHeight > GetGameOption().GetResolution_Height() ) { if(surface) surface->Release(); surface=NULL; return; } isSucceeded=ilSaveImageBGRA( c_pdwBase+c_rcWnd.top*uPitch+c_rcWnd.left, uPitch, uWidth, uHeight, strOutBMPName.c_str(), !bMovieMode); surface->UnlockRect(); } //Release the surface if(surface) surface->Release(); surface=NULL; } void SBotManager::SetWindStrength(float fWindStrength) { m_fWindStrength = fWindStrength; } void SBotManager::SetupWindMatrices(float fTimeInSecs) { // matrix computational data static float afMatrixTimes[c_nNumWindMatrices] = { 0.0f }; static float afFrequencies[c_nNumWindMatrices][2] = { { 0.15f, 0.17f }, { 0.25f, 0.15f }, { 0.19f, 0.05f }, { 0.15f, 0.22f } }; // compute time since last call static float fTimeOfLastCall = 0.0f; float fTimeSinceLastCall = fTimeInSecs - fTimeOfLastCall; fTimeOfLastCall = fTimeInSecs; // wind strength m_fOldStrength = m_fWindStrength; // increment matrix times int i; for (i = 0; i < c_nNumWindMatrices; ++i) afMatrixTimes[i] += fTimeSinceLastCall; // compute maximum branch throw float fBaseAngle = m_fWindStrength * 35.0f; // build rotation matrices for (i = 0; i < c_nNumWindMatrices; ++i) { // adjust time to prevent "jumping" if (m_fWindStrength != 0.0f) afMatrixTimes[i] = (afMatrixTimes[i] * m_fOldStrength) / m_fWindStrength; // compute percentages for each axis float fBaseFreq = m_fWindStrength * 20.0f; float fXPercent = sinf(fBaseFreq * afFrequencies[i % c_nNumWindMatrices][0] * afMatrixTimes[i]); float fYPercent = cosf(fBaseFreq * afFrequencies[i % c_nNumWindMatrices][1] * afMatrixTimes[i]); // build compound rotation matrix (rotate on 'x' then on 'y') const float c_fDeg2Rad = 57.2957795f; float fSinX = sinf(fBaseAngle * fXPercent / c_fDeg2Rad); float fSinY = sinf(fBaseAngle * fYPercent / c_fDeg2Rad); float fCosX = cosf(fBaseAngle * fXPercent / c_fDeg2Rad); float fCosY = cosf(fBaseAngle * fYPercent / c_fDeg2Rad); float afMatrix[16] = { 0.0f }; afMatrix[0] = fCosY; afMatrix[2] = -fSinY; afMatrix[4] = fSinX * fSinY; afMatrix[5] = fCosX; afMatrix[6] = fSinX * fCosY; afMatrix[8] = fSinY * fCosX; afMatrix[9] = -fSinX; afMatrix[10] = fCosX * fCosY; afMatrix[15] = 1.0f; #ifdef WRAPPER_USE_CPU_WIND CSpeedTreeRT::SetWindMatrix(i, afMatrix); #endif #ifdef WRAPPER_USE_GPU_WIND // graphics API specific //UploadWindMatrix(c_nVertexShader_WindMatrices + i * 4, afMatrix); m_pGraphics->GetD3DDevice()->SetVertexShaderConstantF(c_nVertexShader_WindMatrices + i * 4, afMatrix, 4); #endif } // track wind strength m_fOldStrength = m_fWindStrength; } KUIGenWnd* SBotManager::CreateConsoleWnd() { const KPoint c_ptWnd = KPoint( 0, 0 ); //위치 const KSize c_sizWnd = KSize ( 1024, 268 ); //크기 const KPoint c_ptInfoWnd = KPoint( 0, 268 ); //위치 const KSize c_sizInfoWnd = KSize ( 300, 200 ); //크기 m_pConsoleWnd = new SUITopConsoleWnd(); m_pConsoleWnd->Create( KUIWND_CREATE_ARG( "genwnd", "top_console", "system_console", KRect( c_ptWnd, c_sizWnd ), KSTYLE_NOSTATUSBAR | KSTYLE_NOMINIMIZE | KSTYLE_NOCLOSE, KFLAG_GET_PASS_MESSAGE, 0, "frame", c_szDEF_SPR_NAME, m_pUIWndManager ) ); m_pConsoleWnd->CreateControls( m_pUIWndManager ); #ifdef _KUI_INVALIDATION m_pConsoleWnd->ActivateImageCache( false ); #endif //System Info m_pSystemInfoWnd = new SUITopSystemInfoWnd(); m_pSystemInfoWnd->Create( KUIWND_CREATE_ARG( "genwnd", "system_info", "system_info", KRect( c_ptInfoWnd, c_sizInfoWnd ), KSTYLE_NOSTATUSBAR | KSTYLE_NOMINIMIZE | KSTYLE_NOCLOSE, KFLAG_GET_PASS_MESSAGE, 0, "frame", c_szDEF_SPR_NAME, m_pUIWndManager ) ); m_pSystemInfoWnd->CreateControls( m_pUIWndManager ); return m_pConsoleWnd; } void SBotManager::GetTimeStr( std::string & strName, const char * pPreFileName ) { struct tm *newtime; time_t _time; time( &_time ); /* Get time as long integer. */ newtime = localtime( &_time ); /* Convert to local time. */ XStringUtil::Format( strName, "%s_%.24s.txt", pPreFileName, asctime( newtime ) ); XStringUtil::Replace( strName, ":", "_" ); XStringUtil::Replace( strName, " ", "_" ); } void SBotManager::ProcConsole( SGameMessage* pGameMsg ) { if( pGameMsg->nType != MSG_CONSOLE_BUILDER ) return; SMSG_CONSOLE_BUILDER* pMsg = static_cast(pGameMsg); if( pMsg->m_bOut ) { if( m_pConsoleWnd == NULL ) return; std::string strOutput; strOutput = ">
"; std::vector vecKeyList; MsgSplit( pMsg->m_strKey.c_str(), vecKeyList, L"." ); if( ::_stricmp(vecKeyList[0].c_str(), "history") == 0 || ::_stricmp(vecKeyList[0].c_str(), "list") == 0 || ::_stricmp(vecKeyList[0].c_str(), "help") == 0 ) { if( pMsg->m_nValueCount == 0 ) strOutput += "============ empty list ===============
"; else { strOutput += "============ "; strOutput += pMsg->m_strKey; strOutput += " ===============
"; for( int i = 0; i < pMsg->m_nValueCount; i++ ) { strOutput += pMsg->m_vecValueList[i]; strOutput += "
"; } strOutput += "============ end list ===============
"; } } else { if( pMsg->m_nValueCount == 0 ) strOutput += "invalid command
"; else // get, ? { strOutput += pMsg->m_strKey; for( int i = 0; i < pMsg->m_nValueCount+1; i++ ) { if( i == pMsg->m_nValueCount ) { strOutput += ";
"; break; } if( i == 0 ) strOutput += " "; if( i > 0 ) strOutput += ";"; strOutput += pMsg->m_vecValueList[i]; } } } strOutput += ">
"; m_pConsoleWnd->AddChatText( strOutput.c_str() ); vecKeyList.clear(); return; } bool bResult = false; // option. if( pMsg->m_nCommandType == SMSG_CONSOLE_BUILDER::TYPE_OPTION ) bResult = ProcOptionConsole( pGameMsg ); // lua. else if( pMsg->m_nCommandType == SMSG_CONSOLE_BUILDER::TYPE_LUA ) bResult = ProcLuaConsole( pGameMsg ); // debug. else if( pMsg->m_nCommandType == SMSG_CONSOLE_BUILDER::TYPE_DEBUG ) bResult = ProcDebugConsole( pGameMsg ); // game. else if( pMsg->m_nCommandType == SMSG_CONSOLE_BUILDER::TYPE_GAME ) bResult = ProcGameConsole( pGameMsg ); //게임 치트 if( m_nSelectBot >= 0 && !bResult ) m_BotList[m_nSelectBot]->ProcConsole( pGameMsg ); } bool SBotManager::ProcGameConsole( SGameMessage* pGameMsg ) { SMSG_CONSOLE_BUILDER* pMsg = static_cast(pGameMsg); while( true ) { if( !::_stricmp(pMsg->m_strKey.c_str(), "botmng_render_toggle") ) { m_bCheckRender = !m_bCheckRender; return true; } if( !::_stricmp(pMsg->m_strKey.c_str(), "bot_del_all") ) { Bot_Del_all(); return true; } if( !::_stricmp(pMsg->m_strKey.c_str(), "game_water_toggle") ) { if( m_nViewportCount != 3 ) return true; m_pViewportList[0]->SetUseWater( !m_pViewportList[2]->GetUseViewPort() ); m_pViewportList[2]->SetUseViewPort( !m_pViewportList[2]->GetUseViewPort() ); return true; } //if( !::_stricmp(pMsg->m_strKey.c_str(), "game_usehdr") ) //{ // bool bUse = !((SGameViewPort*)m_pViewportList[0])->GetUseHDR(); // ((SGameViewPort*)m_pViewportList[0])->SetUseHDR( bUse ); //} //if( !::_stricmp(pMsg->m_strKey.c_str(), "game_hdr_none") ) { ((SGameViewPort*)m_pViewportList[0])->SetHDRType( SGameViewPort::HDR_TYPE_NONE ); } //if( !::_stricmp(pMsg->m_strKey.c_str(), "game_hdr_blur") ) { ((SGameViewPort*)m_pViewportList[0])->SetHDRType( SGameViewPort::HDR_TYPE_BLUR ); } //if( !::_stricmp(pMsg->m_strKey.c_str(), "game_hdr_cross") ){ ((SGameViewPort*)m_pViewportList[0])->SetHDRType( SGameViewPort::HDR_TYPE_CROSS ); } //리소스 매니저 if( !::_stricmp(pMsg->m_strKey.c_str(), "all_list") ) { std::string strFile; GetTimeStr( strFile, "debug_nx3_list" ); KNX3Manager::GetManager()->PrintList( strFile.c_str() ); GetTimeStr( strFile, "debug_tex_list" ); KTextureManager::GetManager()->PrintList( strFile.c_str() ); } if( !::_stricmp(pMsg->m_strKey.c_str(), "nx3_list") ) { std::string strFile; GetTimeStr( strFile, "debug_nx3_list" ); KNX3Manager::GetManager()->PrintList( strFile.c_str() ); } if( !::_stricmp(pMsg->m_strKey.c_str(), "tex_list") ) { std::string strFile; GetTimeStr( strFile, "debug_tex_list" ); KTextureManager::GetManager()->PrintList( strFile.c_str() ); } if( !::_stricmp(pMsg->m_strKey.c_str(), "spr_list") ) { std::string strFile; GetTimeStr( strFile, "debug_spr_list" ); KSpriteManager::GetManager()->PrintList( strFile.c_str() ); } // value count > 1 if( pMsg->m_vecValueList.size() < 1 ) break; if( !::_stricmp(pMsg->m_strKey.c_str(), "pf") ) { int nFlag = atoi(pMsg->m_vecValueList[0].c_str()); if( nFlag == 0 ) m_ulProcessBitVector ^= Game_ProcessLoadGame; if( nFlag == 1 ) m_ulProcessBitVector ^= Game_ProcessInterface; if( nFlag == 2 ) m_ulProcessBitVector ^= Game_ProcessNetwork; if( nFlag == 3 ) m_ulProcessBitVector ^= Game_ProcessActGame; if( nFlag == 4 ) m_ulProcessBitVector ^= Game_ProcessArclient; //GameWorld if( nFlag == 5 ) m_ulProcessBitVector ^= World_ProcessCommandSys; if( nFlag == 6 ) m_ulProcessBitVector ^= World_ProcessGameSys; if( nFlag == 7 ) m_ulProcessBitVector ^= World_ProcessSky; if( nFlag == 8 ) m_ulProcessBitVector ^= World_ProcessTargetModel; if( nFlag == 9 ) m_ulProcessBitVector ^= World_ProcessLocal; if( nFlag == 10 ) m_ulProcessBitVector ^= World_ProcessEffect; if( nFlag == 11 ) m_ulProcessBitVector ^= World_ProcessEnhanEffect; if( nFlag == 12 ) m_ulProcessBitVector ^= World_ProcessLensFlare; //[sonador] --> if( nFlag == 13 ) m_ulProcessBitVector ^= World_ProcessWeather; //[sonador] <-- if( nFlag == 14 ) m_ulProcessBitVector ^= World_ProcessSelectTarget; if( nFlag == 15 ) m_ulProcessBitVector ^= World_ProcessTerrain; if( nFlag == 16 ) m_ulProcessBitVector = Game_ProcessAll; } if( !::_stricmp(pMsg->m_strKey.c_str(), "rf") ) { int nFlag = atoi(pMsg->m_vecValueList[0].c_str()); if( nFlag == 0 ) m_ulRenderBitVector ^= Bot_RenderActBot; if( nFlag == 1 ) m_ulRenderBitVector ^= Bot_RenderConsole; if( nFlag == 2 ) m_ulRenderBitVector ^= Bot_RenderViewGame; if( nFlag == 3 ) m_ulRenderBitVector ^= Bot_RenderViewShadow; if( nFlag == 4 ) m_ulRenderBitVector ^= Bot_RenderViewWater; if( nFlag == 5 ) m_ulRenderBitVector ^= Game_RenderAct; if( nFlag == 6 ) m_ulRenderBitVector ^= Game_RenderLoad; if( nFlag == 7 ) m_ulRenderBitVector ^= Game_RenderInterface; if( nFlag == 8 ) m_ulRenderBitVector ^= Game_RenderSky; if( nFlag == 9 ) m_ulRenderBitVector ^= Game_RenderTarget; if( nFlag == 10 ) m_ulRenderBitVector ^= Game_RenderTerrain; if( nFlag == 11 ) m_ulRenderBitVector ^= Game_RenderEffect; if( nFlag == 12 ) m_ulRenderBitVector ^= Game_RenderCommandSys; if( nFlag == 13 ) m_ulRenderBitVector ^= Game_RenderLensFlare; if( nFlag == 14 ) m_ulRenderBitVector ^= Game_RenderWeather; // [sonador] if( nFlag == 15 ) m_ulRenderBitVector ^= Game_RenderWire; if( nFlag == 16 ) m_ulRenderBitVector ^= Game_RenderAvatar; if( nFlag == 17 ) m_ulRenderBitVector ^= Game_RenderAction; if( nFlag == 18 ) m_ulRenderBitVector ^= Game_RenderSegment; if( nFlag == 19 ) m_ulRenderBitVector ^= Game_RenderPropProc; if( nFlag == 20 ) m_ulRenderBitVector ^= Game_RenderProp; if( nFlag == 21 ) m_ulRenderBitVector ^= Game_RenderSegShadow01; if( nFlag == 22 ) m_ulRenderBitVector ^= Game_RenderSegShadow02; if( nFlag == 23 ) m_ulRenderBitVector = Bot_RenderAll; if( nFlag == 24 ) m_ulRenderBitVector = Bot_RenderActBot | Bot_RenderConsole | Bot_RenderViewGame | Game_RenderInterface; } if( !::_stricmp(pMsg->m_strKey.c_str(), "bot_add") ) { Bot_Add(pMsg->m_vecValueList[0].c_str()); return true; } if( !::_stricmp(pMsg->m_strKey.c_str(), "bot_del") ) { Bot_Del(pMsg->m_vecValueList[0].c_str()); return true; } if( !::_stricmp(pMsg->m_strKey.c_str(), "bot_sel") ) { Bot_Select (pMsg->m_vecValueList[0].c_str()); return true; } if( !::_stricmp(pMsg->m_strKey.c_str(), "view_rf") ) { if( pMsg->m_vecValueList[0] == "u" ) m_pViewportList[0]->SetRenderFlag( RENDER_SPRITE ); if( pMsg->m_vecValueList[0] == "a" || pMsg->m_vecValueList[0] == "u" ) { for( int i = 0; i < 32; ++i ) m_pViewportList[0]->SetRenderFlag( i ); } else m_pViewportList[0]->SetRenderFlag( atoi(pMsg->m_vecValueList[0].c_str()) ); } //if( !::_stricmp(pMsg->m_strKey.c_str(), "game_hdr_set") ) //{ // int nVarCross, nVarBlur; // nVarCross = nVarBlur = -1; // if( pMsg->m_nValueCount > 0 ) // { // nVarCross = atoi( pMsg->m_vecValueList[0].c_str() ); // if( nVarCross > 100 ) nVarCross = 100; // nVarCross = (float)nVarCross/100 * 255.f; // } // if( pMsg->m_nValueCount > 1 ) // { // nVarBlur = atoi( pMsg->m_vecValueList[1].c_str() ); // if( nVarBlur > 100 ) nVarBlur = 100; // nVarBlur = 255 - (255.f * (float)nVarBlur/100); // } // if( nVarBlur > 255 ) nVarBlur = 255; // if( nVarCross > 255 ) nVarCross = 255; // ((SGameViewPort*)m_pViewportList[0])->SetHDRFactor( nVarCross, nVarBlur ); //} break; } return false; } bool SBotManager::ProcOptionConsole( SGameMessage* pGameMsg ) { SMSG_CONSOLE_BUILDER* pMsg = static_cast(pGameMsg); std::vector vecStringList; MsgSplit( pMsg->m_strKey.c_str(), vecStringList, L"." ); if( vecStringList.size() < 2 ) { vecStringList.clear(); return false; } if( ENV().IsBinded( pMsg->m_strKey.c_str() ) ) { ; } else { ; } vecStringList.clear(); return false; } bool SBotManager::ProcDebugConsole( SGameMessage* pGameMsg ) { SMSG_CONSOLE_BUILDER* pMsg = static_cast(pGameMsg); // intf.... return false; } bool SBotManager::ProcLuaConsole( SGameMessage* pGameMsg ) { SMSG_CONSOLE_BUILDER* pMsg = static_cast(pGameMsg); return false; } bool SBotManager::DoesUseHqWater() { return m_bUseHqWater; } void SBotManager::SetShadowEnable(bool bEnable) { if(bEnable && !(m_ulRenderBitVector & Bot_RenderViewShadow) ) { m_ulRenderBitVector |= Bot_RenderViewShadow; m_ulRenderBitVector |= Game_RenderSegShadow01; SShadowViewPort* pShadowViewport = static_cast( m_pViewportList[1]); if(NULL == pShadowViewport) return; pShadowViewport->ReCreateAllShadowMap(); (static_cast(m_pViewportList[0]))->SetShadowViewPort(pShadowViewport ); } else if(!bEnable && (m_ulRenderBitVector & Bot_RenderViewShadow) ) { m_ulRenderBitVector &= ~Bot_RenderViewShadow; m_ulRenderBitVector &= ~Game_RenderSegShadow01; SShadowViewPort* pShadowViewport = static_cast( m_pViewportList[1]); if(NULL == pShadowViewport) return; pShadowViewport->ClearAllShadowMap(); (static_cast(m_pViewportList[0]))->SetShadowViewPort( NULL ); } } void SBotManager::ProcSecurityMsg( GameSecurityMsg* pSecurityMsg ) { if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->ProcSecurityMsg( pSecurityMsg ); } } bool SBotManager::GameGuardSendToServer( const GG_AUTH_DATA* pAuthdata ) { if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->GameGuardSendToServer( pAuthdata ); return true; } return false; } bool SBotManager::GameGuardSendToServer( const PCSAuth3Data pAuthdata ) { if( m_nSelectBot >= 0 ) { m_BotList[m_nSelectBot]->GameGuardSendToServer( pAuthdata ); return true; } return false; }