Nksp.exe Source Code =)
#1

Source code Nksp.exe:

 

[hide]

 

 

/* * Last Chaos * Copyright © 1998, CroTeam. All rights reserved. * */#include "StdH.h"#include <io.h>#include <fcntl.h>#include <sys/stat.h>#include <process.h>#include <Engine/CurrentVersion.h>#include <Engine/Templates/Stock_CEntityClass.h>#include <Engine/Templates/Stock_CFontData.h>#include <Engine/Interface/UIManager.h> // yjpark#include <Engine/Interface/UIMouseCursor.h>#include <Engine/GameState.h>#include <Engine/GlobalDefinition.h>#define DECL_DLL#include <EntitiesMP/Global.h>#include "resource.h"//#include "SplashScreen.h"#include "MainWindow.h"#include "GlSettings.h"//#include "LevelInfo.h"//#include "LCDDrawing.h"#include "CmdLine.h"//#include "Credits.h"#include <Engine/Base/Protection.h>#if COPY_PROTECTION #include <Engine/Base/Protection.cpp>#endif#include <Engine/Network/Web.h>#include <TlHelp32.h>#include <float.h>#include <Ext_ipc_event.h> // IPCENGINE_API extern cWeb g_web;extern ENGINE_API char *g_szExitError;#ifdef XTRAP_SECURE_CKBANG_2010_07_20 #include "xTrapWrapper.h"#endif//#undef XTRAP_SECURE_CKBANG_2010_07_20#ifndef NO_GAMEGUARD#include <Nksp/GameGuard.h>#endif#ifndef NO_GAMEGUARDextern ENGINE_API CTString g_szHackMsg;#endif//CTString _fnmForCDCheck = "Bin\\SeriousSam.exe";// application state variables by NSPextern BOOL g_bTcp = TRUE;// end of ..extern CGame *_pGame = NULL;// application state variables//extern BOOL _bRunning = TRUE;//extern BOOL _bQuitScreen = TRUE;//extern BOOL _bMenuActive = FALSE;//extern BOOL _bMenuRendering = FALSE;#pragma comment(lib, "SharedMemoryDll.lib")static PIX _apixRes[][2] = { 640, 480, 800, 500, 800, 600, 1024, 768, 1152, 864, 1280, 800, 1280, 960, 1280, 1024, 1600,1200, };extern void enableFPExceptions(){ int i = _controlfp (0,0); i &= ~ (EM_ZERODIVIDE); _controlfp (i, MCW_EM);}// helper for limiting window size when changing mode out of full screenextern void FindMaxResolution( PIX &pixSizeI, PIX &pixSizeJ){ const INDEX ctResolutions = ARRAYCOUNT(_apixRes); for( INDEX iRes=(ctResolutions-1); iRes>=0; iRes--) { if( pixSizeI>_apixRes[iRes][0] && pixSizeJ>_apixRes[iRes][1]) { pixSizeI = _apixRes[iRes][0]; pixSizeJ = _apixRes[iRes][1]; return; } } // should not end up here ASSERTALWAYS( "Desktop resolution too low!"); pixSizeI = _apixRes[0][0]; pixSizeJ = _apixRes[0][1];}//extern BOOL _bDefiningKey; // ¿øº».extern BOOL _bDefiningKey = FALSE;//static BOOL _bReconsiderInput = FALSE;extern PIX _pixDesktopWidth = 0;extern PIX _pixDesktopHeight = 0;static INDEX sam_iMaxFPSActive = 500;static INDEX sam_iMaxFPSInactive = 10;static INDEX sam_bPauseOnMinimize = TRUE; // auto-pause when window has been minimizedextern ENGINE_API INDEX sam_bWideScreen; // yjparkextern FLOAT sam_fPlayerOffset = 0.0f;// Window handleextern ENGINE_API HWND _hwndMain;// display mode settingsextern ENGINE_API BOOL _bWindowChanging; // yjpark |<--extern ENGINE_API INDEX sam_bFullScreenActive;extern ENGINE_API INDEX sam_iScreenSizeI;extern ENGINE_API INDEX sam_iScreenSizeJ;extern ENGINE_API INDEX sam_iDisplayDepth;extern ENGINE_API INDEX sam_iDisplayAdapter;extern ENGINE_API INDEX sam_iGfxAPI; // 0==OpenGL // yjpark -->|extern INDEX sam_bFirstStarted = FALSE;extern FLOAT sam_tmDisplayModeReport = 5.0f;//extern INDEX sam_bShowAllLevels = FALSE;//extern INDEX sam_bMentalActivated = FALSE;// network settingsextern CTString sam_strNetworkSettings = "";// command lineextern CTString sam_strCommandLine = "";// 0...app started for the first time// 1...all ok// 2...automatic fallbackstatic INDEX _iDisplayModeChangeFlag = 0;static TIME _tmDisplayModeChanged = 100.0f; // when display mode was last changed// rendering preferences for automatic settingsextern INDEX sam_iVideoSetup = 1; // 0==speed, 1==normal, 2==quality, 3==custom// automatic adjustment of audio qualityextern BOOL sam_bAutoAdjustAudio = TRUE;extern INDEX sam_bAutoPlayDemos = TRUE;static INDEX _bInAutoPlayLoop = TRUE;// menu calling/*extern INDEX sam_bMenuSave = FALSE;extern INDEX sam_bMenuLoad = FALSE;extern INDEX sam_bMenuControls = FALSE;extern INDEX sam_bMenuHiScore = FALSE;*/extern INDEX sam_bToggleConsole = FALSE;//extern INDEX sam_iStartCredits = FALSE;// for mod re-loadingextern CTFileName _fnmModToLoad = CTString("");extern CTString _strModServerJoin = CTString("");extern CTString _strURLToVisit = CTString("");// state variables fo addon execution// 0 - nothing// 1 - start (invoke console)// 2 - console invoked, waiting for one redrawextern INDEX _iAddonExecState = 0;extern CTFileName _fnmAddonToExec = CTString("");// logo textures//static CTextureObject _toLogoCT;//static CTextureObject _toLogoODI;//static CTextureObject _toLogoGSpy;//static CTextureObject _toLogoEAX;//extern CTextureObject *_ptoLogoCT = NULL;//extern CTextureObject *_ptoLogoODI = NULL;//extern CTextureObject *_ptoLogoGSpy = NULL;//extern CTextureObject *_ptoLogoEAX = NULL;extern CTString sam_strVersion = "0.5";//extern CTString sam_strModName = TRANS("Prologue");/*#if _SE_DEMOextern CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld";#elseextern CTString sam_strFirstLevel = "Levels\\01_Hatshepsut.wld";#endif*/extern CTString sam_strIntroLevel = "Levels\\Intro.wld";extern CTString sam_strGameName = "serioussam";//extern CTString sam_strTechTestLevel = "Levels\\TechTest.wld";//extern CTString sam_strTrainingLevel = "Levels\\KarnakDemo.wld";ENGINE_API extern INDEX snd_iFormat;// main window canvas/*CDrawPort *pdp;CDrawPort *pdpNormal;CDrawPort *pdpWideScreen;CViewPort *pvpViewPort;HINSTANCE _hInstance;*/ // ypark// main window canvas // yjparkextern ENGINE_API CDrawPort *_pdpMain;extern ENGINE_API CDrawPort *_pdpNormalMain;extern ENGINE_API CDrawPort *_pdpWideScreenMain;extern ENGINE_API CViewPort *_pvpViewPortMain;extern ENGINE_API HINSTANCE _hInstanceMain;/*static void PlayDemo(const CTString &strDemoFilename){ // ¾²ÀÌÃÂö ¾ÊÀ½. _gmMenuGameMode = GM_DEMO; CTFileName fnDemo = "demos\\" + strDemoFilename + ".dem"; extern BOOL LSLoadDemo(const CTFileName &fnm); LSLoadDemo(fnDemo);} */ENGINE_API extern INDEX g_iCountry;// WSS_NPROTECT 070402 -------------------------->>/*#ifndef NO_GAMEGUARD extern ENGINE_API CTString g_szHackMsg;#endif /**/// ----------------------------------------------<<void GetNM(LPSTR lpCmdLine){ // wooss 060209 NetMable_JP extern BOOL g_bAutoLogin; extern CTString g_nmVER; extern CTString g_nmCID; extern CTString g_nmID; extern CTString g_nmPW; // wooss NetMable_JP Auto login 060209 CTString strTemp((CHAR*)lpCmdLine);// MessageBox(NULL, strTemp, "CommandLine", MB_OK); for(INDEX ii = 0; ii < 4; ii++) { INDEX tempPos = strTemp.FindSubstr(" "); CTString strInsert = strTemp; strInsert.TrimRight(tempPos); switch(ii) { case 0 : g_nmVER.PrintF("%s", strInsert); break; case 1 : g_nmCID.PrintF("%s", strInsert); break; case 2 : g_nmID.PrintF("%s", strInsert); break; case 3 : g_nmPW.PrintF("%s", strTemp); break; } if(ii < 3) strTemp.DeleteChars(0, tempPos + 1); }// MessageBox(NULL, g_nmID, "loginID", MB_OK);// MessageBox(NULL, g_nmPW, "loginPW", MB_OK); if(g_nmID.Length()!=0 && g_nmPW.Length()!=0 ) { switch(g_iCountry) { case KOREA : //if(g_nmCID.IsEqualCaseSensitive("em") || g_nmCID.IsEqualCaseSensitive("nt")) //if(g_nmCID.IsEqualCaseSensitive("or")) if(g_nmCID.Length() > 0) g_bAutoLogin = TRUE;// MessageBox(NULL, "g_bAutoLogin is True", "autologin", MB_OK); break; case TAIWAN : break; case CHINA : break; case THAILAND : break; case TAIWAN2: break; case JAPAN : g_bAutoLogin = TRUE; break; case MALAYSIA : break; case USA: break; case BRAZIL: break; case HONGKONG: g_bAutoLogin = TRUE; break; } }}/************************************************************************************************ IsRunning()* ÃÂߺ¹ ½ÇÇà ¹æÃÂö ÇÃâ€Ã‚¼Ã¶* ÇöÀç ½ÇÇà ÃÂßÀÎ ÇÃ·μ¼½º¸¦ °Ë»öÇÿ© Nksp.exe°¡ ½ÇÇàµÇ¾î ÀÖ´Â °ÃÂÀÌ ÀÖ´ÂÃÂö È®ÀÎÇÿ© TRUE, FALSE¸¦* ¸®ÅàÇÑ´Ù.*************************************************************************************************/BOOL IsRunning(void){ PROCESSENTRY32 peNext; // â±Ù ÇÃ·μ¼½º ÇÚµéÀ» »ý¼ºÇÑ´Ù. HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapShot == INVALID_HANDLE_VALUE ) { if( g_iCountry == RUSSIA ) { MessageBox(NULL, "Îøèáêà çàïóñê?ïðîãðàìì?LastChaos!", "LastChaos Run", MB_OK); } else { MessageBox(NULL, "Fail Execute LastChaos!", "LastChaos Run", MB_OK); } return TRUE; } peNext.dwSize = sizeof(PROCESSENTRY32); int nFindNum = 0; int nSize = 0; DWORD dwTemp = GetCurrentProcessId(); BOOL bCurrentProcess = FALSE; Process32First(hSnapShot, &peNext); // ù¹øÂ° ÇÃ·μ¼½º¸¦ °¡Ã®¿Â´Ù. while(Process32Next(hSnapShot, &peNext)) // ¸ðµç ÇÃ·μ¼½º¸¦ °Ë»öÇÑ´Ù. { if (peNext.th32ProcessID == dwTemp) { bCurrentProcess = TRUE; continue; } nSize = strlen(peNext.szExeFile); if ( nSize > 8 ) { nSize -= 8; } else { nSize = 0; } if (stricmp(peNext.szExeFile+(nSize), "Nksp.exe") == 0) { nFindNum++; if (nFindNum > 0) { CloseHandle(hSnapShot); return TRUE; } } } CloseHandle(hSnapShot); if (!bCurrentProcess) { if( g_iCountry == RUSSIA ) { MessageBox(NULL, "Îøèáêà çàïóñê?ïðîãðàìì?LastChaos!", "LastChaos Run", MB_OK); } else { MessageBox(NULL, "Fail Execute LastChaos!", "LastChaos Run", MB_OK); } return TRUE; } return FALSE;}static void ApplyRenderingPreferences(void){ ApplyGLSettings(TRUE);}/*extern void ApplyVideoMode(void){ StartNewMode( (GfxAPIType)sam_iGfxAPI, sam_iDisplayAdapter, sam_iScreenSizeI, sam_iScreenSizeJ, (enum DisplayDepth)sam_iDisplayDepth, IsFullScreen( sam_bFullScreenActive) );}*/static void BenchMark(void){ _pGfx->Benchmark(_pvpViewPortMain, _pdpMain);}static void QuitGame(void){ _pGameState->Running() = FALSE; _pGameState->QuitScreen() = FALSE;}// check if another app is already runningstatic HANDLE _hLock = NULL;static CTFileName _fnmLock;static void DirectoryLockOn(void){ // create lock filename _fnmLock = _fnmApplicationPath+"nksp.loc"; // try to open lock file _hLock = CreateFile( _fnmLock, GENERIC_WRITE, 0/*no sharing*/, NULL, // pointer to security attributes CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, // file attributes NULL); // if failed if (_hLock==NULL || GetLastError()!=0) { // report warning CPrintF(TRANS("WARNING: Last Chaos didnt shut down properly last time!\n")); }}static void DirectoryLockOff(void){ // if lock is open if (_hLock!=NULL) { // close it CloseHandle(_hLock); }}//°*µ¿¹Î ¼öä ½ÃÀÛ ½Ã½ºÅÛ ¸¶¿ì½º ÀÛ¾÷ 09.09// NOTE : ¾Ö´Ã¸ÞÀ̼Ç Ä¿¼*¸¦ ¸®¼Ò½º·ÎºÎÅàÀþî¿È.static HCURSOR LoadAnimationCursor(HINSTANCE hInstance, UINT nID){ HRSRC hRes = FindResource(hInstance, MAKEINTRESOURCE(nID), "CURSORS"); DWORD dwSize = SizeofResource(hInstance, hRes); HGLOBAL hGlob = LoadResource(hInstance, hRes); LPBYTE pBytes = (LPBYTE)LockResource(hGlob); return (HCURSOR)CreateIconFromResource(pBytes, dwSize, FALSE, 0x00030000); }//°*µ¿¹Î ¼öä ³¡ ½Ã½ºÅÛ ¸¶¿ì½º ÀÛ¾÷ 09.09void End(void);// automaticaly manage input enable/disable toggling//static BOOL _bInputEnabled = FALSE;/*void UpdateInputEnabledState(void){ // do nothing if window is invalid if( _hwndMain==NULL) return; // input should be enabled if application is active // and no menu is active and no console is active BOOL bShouldBeEnabled = ( !IsIconic(_hwndMain) && !_pGameState->m_bMenuActive && _pGame->gm_csConsoleState==CS_OFF ) || _bDefiningKey; // if should be turned off if( (!bShouldBeEnabled && _bInputEnabled) || _bReconsiderInput) { // disable it and remember new state _pInput->DisableInput(); _bInputEnabled = FALSE; } // if should be turned on if( bShouldBeEnabled && !_bInputEnabled) { // enable it and remember new state _pInput->EnableInput(_hwndMain); _bInputEnabled = TRUE; } _bReconsiderInput = FALSE;}*/// automaticaly manage pause togglingvoid UpdatePauseState(void){ // ¾²ÀÌÃÂö ¾Ê´Â ºÎºÃÂ. /* BOOL bShouldPause = ( _gmRunningGameMode == GM_SINGLE_PLAYER ) && ( _pGameState->m_bMenuActive || _pGame->gm_csConsoleState == CS_ON || _pGame->gm_csConsoleState == CS_TURNINGON || _pGame->gm_csConsoleState == CS_TURNINGOFF ); _pNetwork->SetLocalPause(bShouldPause); */}// limit current frame rate if neeededvoid LimitFrameRate(void){ // measure passed time for each loop static CTimerValue tvLast(-1.0f); CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); TIME tmCurrentDelta = (tvNow-tvLast).GetSeconds(); // limit maximum frame rate sam_iMaxFPSActive = ClampDn( (INDEX)sam_iMaxFPSActive, 1L); sam_iMaxFPSInactive = ClampDn( (INDEX)sam_iMaxFPSInactive, 1L); INDEX iMaxFPS = sam_iMaxFPSActive; if( IsIconic(_hwndMain)) iMaxFPS = sam_iMaxFPSInactive; /* if(_pGame->gm_CurrentSplitScreenCfg==CGame::SSC_DEDICATED) { iMaxFPS = ClampDn(iMaxFPS, 60L); // never go very slow if dedicated server } */ TIME tmWantedDelta = 1.0f / iMaxFPS; if( tmCurrentDelta<tmWantedDelta) Sleep( (tmWantedDelta-tmCurrentDelta)*1000.0f); // remember new time tvLast = _pTimer->GetHighPrecisionTimer();}/*// load first demovoid StartNextDemo(void){ // ¾µ¸ð¾ø´Â ºÎºÃÂÀ̹ǷÎ ÃÂÖ¼®Ã³¸®µÊ. if (!sam_bAutoPlayDemos || !_bInAutoPlayLoop) { _bInAutoPlayLoop = FALSE; return; } // skip if no demos if(_lhAutoDemos.IsEmpty()) { _bInAutoPlayLoop = FALSE; return; } // get first demo level and cycle the list CLevelInfo *pli = LIST_HEAD(_lhAutoDemos, CLevelInfo, li_lnNode); pli->li_lnNode.Remove(); _lhAutoDemos.AddTail(pli->li_lnNode); // if intro if (pli->li_fnLevel==sam_strIntroLevel) { // start intro _gmRunningGameMode = GM_NONE; _pGame->gm_aiStartLocalPlayers[0] = 0; _pGame->gm_aiStartLocalPlayers[1] = -1; _pGame->gm_aiStartLocalPlayers[2] = -1; _pGame->gm_aiStartLocalPlayers[3] = -1; _pGame->gm_strNetworkProvider = "Local"; _pGame->gm_StartSplitScreenCfg = CGame::SSC_PLAY1; _pShell->SetINDEX("gam_iStartDifficulty", CSessionProperties::GD_NORMAL); _pShell->SetINDEX("gam_iStartMode", CSessionProperties::GM_FLYOVER); CUniversalSessionProperties sp; _pGame->SetSinglePlayerSession(sp); _pGame->gm_bFirstLoading = TRUE; if ( _pGame->PreNewGame() && _pGame->NewGame( sam_strIntroLevel, sam_strIntroLevel, sp)) { _gmRunningGameMode = GM_INTRO; } // if not intro } else { // start the demo _pGame->gm_StartSplitScreenCfg = CGame::SSC_OBSERVER; _pGame->gm_aiStartLocalPlayers[0] = -1; _pGame->gm_aiStartLocalPlayers[1] = -1; _pGame->gm_aiStartLocalPlayers[2] = -1; _pGame->gm_aiStartLocalPlayers[3] = -1; // play the demo _pGame->gm_strNetworkProvider = "Local"; _gmRunningGameMode = GM_NONE; if( _pGame->StartDemoPlay( pli->li_fnLevel)) { _gmRunningGameMode = GM_DEMO; CON_DiscardLastLineTimes(); } } if (_gmRunningGameMode==GM_NONE) { _bInAutoPlayLoop = FALSE; }}// set registry key for GameSpyvoid RegisterGameSpy(void){ char strExePath[MAX_PATH+1] = ""; // get full path to the exe GetModuleFileName( NULL, strExePath, sizeof(strExePath)-1); // create the registry key HKEY hkey; DWORD dwDisposition; LONG lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\GameSpy\\games",0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition); if (lRes!=ERROR_SUCCESS) { return; } // set the value to current application#if !TECHTESTONLY#if _SE_DEMO RegSetValueEx(hkey, "serioussamdemo", 0, REG_SZ, (UBYTE*)strExePath, strlen(strExePath));#else RegSetValueEx(hkey, sam_strGameName, 0, REG_SZ, (UBYTE*)strExePath, strlen(strExePath));#endif#endif // close the key RegCloseKey(hkey);}*/BOOL _bCDPathFound = FALSE;BOOL FileExistsOnHD(const CTString &strFile){ FILE *f = fopen(_fnmApplicationPath+strFile, "rb"); if (f!=NULL) { fclose(f); return TRUE; } else { return FALSE; }} /*// find possible cd pathBOOL FindCDPath(void){ // if no specified cdpath if (_fnmCDPath=="") { // use default one _fnmCDPath = CTString("C:\\Install\\"); } // for each drive for(INDEX chDrive=C; chDrive<=Z; chDrive++) { char strDrive[4]; strDrive[0] = chDrive; strDrive[1] = :; strDrive[2] = \\; strDrive[3] = 0; // if not cdrom if (GetDriveType(strDrive) != DRIVE_CDROM) { // skip it continue; } // substitute the drive letter ((char*)(const char*)_fnmCDPath)[0] = chDrive; // if the path is valid FILE *f = fopen(_fnmCDPath+_fnmForCDCheck, "rb"); _bCDPathFound = (BOOL)f; if (f!=NULL) { // we have found the cd fclose(f); return TRUE; } } return FALSE;}BOOL IsCDInDrive(void){ CTFileName fnmExpanded; INDEX iType = ExpandFilePath(EFP_READ, CTString("Setup.exe"), fnmExpanded); if (iType!=EFP_FILE || fnmExpanded.HasPrefix(_fnmCDPath)) { return FALSE; } fnmExpanded = fnmExpanded.FileDir()+_fnmForCDCheck; FILE *f = fopen(fnmExpanded, "rb"); if (f==NULL) { return FALSE; } fclose(f); return TRUE;}*/void TrimString(char *str){ int i = strlen(str); if (str[i-1]==\n || str[i-1]==\r) { str[i-1]=0; }}/*BOOL PerformCDCheck(void){ // default message char strTitle[256] = "CD check"; char strMessage[256] = "Please insert the game CD"; // first get the application filename char strTmpPath[MAX_PATH] = ""; GetModuleFileName( NULL, strTmpPath, sizeof(strTmpPath)-1); int iLen = strlen(strTmpPath); // generate insert-cd text filename strTmpPath[iLen-3] = c; strTmpPath[iLen-2] = d; strTmpPath[iLen-1] = 0; // try to load the file FILE *f = fopen(strTmpPath, "rt"); if (f!=NULL) { fgets(strTitle, sizeof(strTitle)-1, f); TrimString(strTitle); fgets(strMessage, sizeof(strMessage)-1, f); TrimString(strMessage); fclose(f); } // repeat FOREVER{ // if cd path found if (FindCDPath()) { // ok return TRUE; }#if !CD_CHECK || _SE_DEMO || TECHTESTONLY return TRUE;#endif // ask user to insert CD int iResult = MessageBox(_hwndMain, strMessage, strTitle, MB_ICONEXCLAMATION|MB_RETRYCANCEL); if (iResult!=IDRETRY) { return FALSE; } Sleep(1000); }}// run web browser and view an urlvoid RunBrowser(const char *strUrl){ int iResult = (int)ShellExecute( _hwndMain, "OPEN", strUrl, NULL, NULL, SW_SHOWMAXIMIZED); if (iResult<32) { // should report error? NOTHING; }}*/void LoadAndForceTexture(CTextureObject &to, CTextureObject *&pto, const CTFileName &fnm){ try { to.SetData_t(fnm); CTextureData *ptd = (CTextureData*)to.GetData(); ptd->Force( TEX_CONSTANT); ptd = ptd->td_ptdBaseTexture; if( ptd!=NULL) ptd->Force( TEX_CONSTANT); pto = &to; } catch( char *pchrError) { (void*)pchrError; pto = NULL; }}//¾ÈÅÂÈÆ ¼öä ½ÃÀÛ //(DevPartner Bug Fix)(2005-01-14)HMODULE g_hGame = NULL;//¾ÈÅÂÈÆ ¼öä ³¡ //(DevPartner Bug Fix)(2005-01-14)void InitializeGame(void){ try {#ifndef NDEBUG #define GAMEDLL ("Bin\\Debug\\Game"+_strModExt+"D.dll")#else#define GAMEDLL ("Bin\\Game"+_strModExt+".dll")#endif CTFileName fnmExpanded; ExpandFilePath(EFP_READ, CTString(GAMEDLL), fnmExpanded); CPrintF(TRANS("Loading game library %s...\n"), (const char *)fnmExpanded);//¾ÈÅÂÈÆ ¼öä ½ÃÀÛ //(DevPartner Bug Fix)(2005-01-14) g_hGame = LoadLibrary(fnmExpanded); if (g_hGame==NULL) { ThrowF_t("%s", GetWindowsError(GetLastError())); } CGame* (*GAME_Create)(void) = (CGame* (*)(void))GetProcAddress(g_hGame, "GAME_Create"); if (GAME_Create==NULL) { ThrowF_t("%s", GetWindowsError(GetLastError())); }//¾ÈÅÂÈÆ ¼öä ³¡ //(DevPartner Bug Fix)(2005-01-14) _pGame = GAME_Create(); } catch (char *strError) { FatalError("%s", strError); } // init game - this will load persistent symbols _pGame->Initialize(CTString("Data\\nksp.gms"));// ENGINE_API extern float g_fGWTimeMul;// ENGINE_API extern float g_fGWTime; // Game world time// g_fGWTimeMul = 0.0f;// g_fGWTime = 100.0f;}static char strExePath[MAX_PATH] = "";static char strDirPath[MAX_PATH] = "";CEntityClass *g_pPlayer, *g_pWorldBase;ENGINE_API void CheckEngineVersion();BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine){ // »õ·Î¿î ¹öÀüÀÇ Launcher°¡ Àִ°¡ È®ÀÎÇðí ÀÖ´Ù¸é, Laucher¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù. // by seo - 40727 // get full path to the exe char strTmpPath[MAX_PATH] = ""; GetModuleFileName( NULL, strExePath, sizeof(strExePath)-1); for (int i=0; i < 2; i++) { for (int j=strlen(strExePath)-1; j > 0; j--) { if (strExePath[j] == \\) { strExePath[j] = \0; break; } } } strcat(strExePath, "\\"); CTFileName fnmLC = strExePath; CTFileName fnmLCNew = strExePath;// CTFileName fnmLW = strExePath;// CTFileName fnmLWNew = strExePath; CTFileName fnmLccnct = strExePath; CTFileName fnmLccnctNew = strExePath; fnmLC = fnmLC + "LC.exe"; fnmLCNew = fnmLCNew + "LCNew.exe"; // õÇôë¶õ¿ë.// fnmLW = fnmLW + "LW.exe";// fnmLWNew = fnmLWNew + "LWNew.exe"; fnmLccnct = fnmLccnct + "lccnct.dta"; fnmLccnctNew = fnmLccnctNew + "lccnctNew.dta"; FILE *fp = fopen (fnmLccnctNew, "rb"); if (fp) { fclose(fp); fclose(fp); Sleep(1000); remove (fnmLccnct); Sleep(1000); int ret = rename(fnmLccnctNew, fnmLccnct); } fp = NULL; fp = fopen (fnmLCNew, "rb"); if (fp) { fclose(fp); Sleep(1000); remove (fnmLC); Sleep(1000); int ret = rename(fnmLCNew, fnmLC); // Date : 2005-05-17(¿ÀÈÄ 4:44:15), By Lee Ki-hwan Ãß°¡ if (!ret) { ShowCursor(TRUE); if( GetSystemDefaultLangID() == 0x0804 ) // ÃÂß±¹ ·ÎÄÃÀÇ °æ¿ì ¼öä { MessageBox(NULL, "Çëµã»÷È·¶¨£¬ÖØÃÂÂÆô¶¯ÃÂú»ê¡£", "ÃÂú»ê", MB_OK); } else { MessageBox(NULL, "Update is completed.\nPlease, restart game.", "Update completed", MB_OK); } return 0; } }/* fp = NULL; fp = fopen (fnmLWNew, "rb"); if (fp) { fclose(fp); Sleep(1000); remove (fnmLW); Sleep(1000); int ret = rename(fnmLWNew, fnmLW); // Date : 2005-05-17(¿ÀÈÄ 4:44:15), By Lee Ki-hwan Ãß°¡ if (!ret) { ShowCursor(TRUE); if( GetSystemDefaultLangID() == 0x0804 ) // ÃÂß±¹ ·ÎÄÃÀÇ °æ¿ì ¼öä { MessageBox(NULL, "Çëµã»÷È·¶¨£¬ÖØÃÂÂÆô¶¯ÃÂú»ê¡£", "ÃÂú»ê", MB_OK); } else { MessageBox(NULL, "Update is completed.\nPlease, restart game.", "Update completed", MB_OK); } return 0; } }*/ // end. _hInstanceMain = hInstance; //0214 ½ºÇ÷¡½Ã ¾È¶ç¿ì±â. // ShowSplashScreen(hInstance); // set registry key for GameSpy // deleted by seo - 40629 //RegisterGameSpy(); // remember desktop dimensions _pixDesktopWidth = ::GetSystemMetrics(SM_CXSCREEN); _pixDesktopHeight = ::GetSystemMetrics(SM_CYSCREEN);#ifdef USE_NEW_LAUNCHER if(strCmdLine.IsEqualCaseSensitive(CTString("4022")))#else if(strCmdLine.IsEqualCaseSensitive(CTString("6574")))#endif { } else { // WSS_NPROTECT 070405 ------------------>><< // È«ÄáÀÇ °æ¿ì nProtect·Î ÃÂߺ¹ °ËÃâ#ifdef NO_GAMEGUARD#ifndef MULTI_CLIENT if (IsRunning()) { if( g_iCountry == RUSSIA ) { MessageBox(NULL, "Êëèåíò LastChaos óæ?çàïóùå?", "LastChaos", MB_OK); } else { MessageBox(NULL, "LastChaos is already running on your system", "LastChaos Run", MB_OK); } return FALSE; } #endif // MULTI_CLIENT#endif#ifndef NKSP_NOT_NICKNAME const CTString CmpStr("dlwltnr"); char* strPos = \0; strPos = strstr(strCmdLine.str_String, CmpStr.str_String); if (!strPos || !CmpStr.IsEqualCaseSensitive(strPos)) { if( g_iCountry == RUSSIA ) { MessageBox(NULL, "Êëèåíò èãðû íå ìîæå?áûòü çàïóùå?ñàìîñò?òåëüíî.", "LastChaos", MB_OK); } else { MessageBox(NULL, "This program could not be run itself", "LastChaos", MB_OK); } return FALSE; }#endif } // prepare main window MainWindow_Init();#ifdef XTRAP_SECURE_CKBANG_2010_07_20 if (XTRAP()) XTRAP()->EngineConfirm();#endif OpenMainWindowInvisible(); // parse command line before initializing engine ParseCommandLine(strCmdLine); /*#if !_SE_DEMO if (!PerformCDCheck()) { return FALSE; }#endif*/ // initialize engine SE_InitEngine(sam_strGameName); extern BOOL g_bNasTrans; g_bNasTrans = FALSE; switch(g_iCountry) { case BRAZIL: SetClassLong( _hwndMain, GCL_HICON, (LONG)LoadIcon( _hInstanceMain, (LPCTSTR)IDI_GUNSOFT ) ); g_bNasTrans = TRUE; break; case HONGKONG: SetClassLong( _hwndMain, GCL_HICON, (LONG)LoadIcon( _hInstanceMain, (LPCTSTR)IDI_FUNMILY ) ); break; } // recheck for proper CD now/* if (FileExistsOnHD("Bin\\EntitiesMP.dll")) { _fnmForCDCheck = "Bin\\EntitiesMP.dll"; } else if (FileExistsOnHD("Bin\\Entities.dll")) { _fnmForCDCheck = "Bin\\Entities.dll"; }*/ /*#if !_SE_DEMO if (!PerformCDCheck()) { return FALSE; }#endif*/#if COPY_PROTECTION // get full path to the exe char strExePath[MAX_PATH] = ""; GetModuleFileName( NULL, strExePath, sizeof(strExePath)-1); char strDrive[] = "C:\\"; strDrive[0] = strExePath[0]; DWORD dwSerial; GetVolumeInformation(strDrive, NULL, 0, &dwSerial, NULL, NULL, NULL, 0); CTFileName fnmKey = CTString("TSE.key"); INDEX iSerial = dwSerial; // init encryption table two times BLOWFISH_CTX ctx1; BLOWFISH_CTX ctx2; CTString strEnKey = _strEngineBuild; strEnKey.TrimLeft(16); char aubKey1[16]; char aubKey2[16]; for(INDEX i=0; i<16; i++) { aubKey1[i] = strEnKey[i]; aubKey2[i] = strEnKey[16-1-i]; } Blowfish_Init (&ctx1, (unsigned char*)aubKey1, 16); Blowfish_Init (&ctx2, (unsigned char*)aubKey2, 16); // if no key if (!FileExists(fnmKey)) { // just bail out FatalError(TRANS("No registration key!\nPlease request registration key for code:\n\n%08X"), iSerial); return FALSE; // if key is here } else { // load it CTString strKey; LoadStringVar(fnmKey, strKey); __int64 llCodeRead = 0; strKey.ScanF("%I64x", &llCodeRead); __int64 llCode1 = llCodeRead; __int64 llCode2 = llCodeRead; // decrypt the code Blowfish_Decrypt(&ctx1, (ULONG*)&llCode1+1, ((ULONG*)&llCode1)); Blowfish_Decrypt(&ctx2, (ULONG*)&llCode2+1, ((ULONG*)&llCode2)); // if not valid if (llCode1!=iSerial && llCode2!=iSerial) { // bail out FatalError(TRANS("Registration key is invalid!")); return FALSE; } }#endif // if cd check didnt pass /* if (!_bCDPathFound) { // check current time SYSTEMTIME st; GetSystemTime(&st); // if after 30.3.2001, fail if (st.wYear>2001) { return FALSE; } else if (st.wYear==2001) { if (st.wMonth>3) { return FALSE; } else if (st.wMonth==3) { if (st.wDay>30) { return FALSE; } } } } */ SE_LoadDefaultFonts(); // now print the output of command line parsing // deleted by seo //CPrintF("%s", cmd_strOutput); // lock the directory DirectoryLockOn(); // load all translation tables InitTranslation(); try { AddTranslationTablesDir_t(CTString("Data\\Translations\\"), CTString("*.txt")); FinishTranslationTable(); } catch (char *strError) { FatalError("%s", strError); } // always disable all warnings when in serious sam _pShell->Execute( "con_bNoWarnings=1;"); // declare shell symbols// _pShell->DeclareSymbol("user void PlayDemo(CTString);", &PlayDemo); _pShell->DeclareSymbol("persistent INDEX sam_bFullScreen;", &sam_bFullScreenActive); // ±âº»ÀÇ ¿øµµ¿ì ¸ðµå ½Ã¿¡ Àüü ¸ðµå·Î º¯°æ /* if( OLD_WINDOW_MODE != WINDOW_MODE ) if ( sam_bFullScreenActive == OLD_WINDOW_MODE ) sam_bFullScreenActive = FULLSCREEN_MODE; */ // Date : 2005-09-13(¿ÀÈÄ 2:58:13), By Lee Ki-hwan // ´ë¸¸¿¡¼* 񃧯 ¿øµµ¿ì ¸ðµå¸¦ ÃÂö¿øÇøé¼* ÇÊ¿ä¾ø¾îÃÂü _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeI;", &sam_iScreenSizeI); _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeJ;", &sam_iScreenSizeJ); _pShell->DeclareSymbol("persistent INDEX sam_iDisplayDepth;", &sam_iDisplayDepth); _pShell->DeclareSymbol("persistent INDEX sam_iDisplayAdapter;", &sam_iDisplayAdapter); _pShell->DeclareSymbol("persistent INDEX sam_iGfxAPI;", &sam_iGfxAPI); //_pShell->DeclareSymbol("persistent INDEX sam_bFirstStarted;", &sam_bFirstStarted); _pShell->DeclareSymbol("persistent INDEX sam_bAutoAdjustAudio;", &sam_bAutoAdjustAudio); _pShell->DeclareSymbol("persistent user INDEX sam_bWideScreen;", &sam_bWideScreen); _pShell->DeclareSymbol("persistent user FLOAT sam_fPlayerOffset;", &sam_fPlayerOffset); _pShell->DeclareSymbol("persistent user INDEX sam_bAutoPlayDemos;", &sam_bAutoPlayDemos); _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSActive;", &sam_iMaxFPSActive); _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSInactive;", &sam_iMaxFPSInactive); _pShell->DeclareSymbol("persistent user INDEX sam_bPauseOnMinimize;", &sam_bPauseOnMinimize); _pShell->DeclareSymbol("persistent user FLOAT sam_tmDisplayModeReport;", &sam_tmDisplayModeReport); _pShell->DeclareSymbol("persistent user CTString sam_strNetworkSettings;", &sam_strNetworkSettings); _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", &sam_strIntroLevel); _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", &sam_strGameName); _pShell->DeclareSymbol("user CTString sam_strVersion;", &sam_strVersion); //_pShell->DeclareSymbol("user CTString sam_strFirstLevel;", &sam_strFirstLevel); //_pShell->DeclareSymbol("user CTString sam_strModName;", &sam_strModName);// _pShell->DeclareSymbol("persistent INDEX sam_bShowAllLevels;", &sam_bShowAllLevels);// _pShell->DeclareSymbol("persistent INDEX sam_bMentalActivated;", &sam_bMentalActivated); //_pShell->DeclareSymbol("user CTString sam_strTechTestLevel;", &sam_strTechTestLevel); //_pShell->DeclareSymbol("user CTString sam_strTrainingLevel;", &sam_strTrainingLevel); _pShell->DeclareSymbol("user void Quit(void);", &QuitGame); _pShell->DeclareSymbol("persistent user INDEX sam_iVideoSetup;", &sam_iVideoSetup); _pShell->DeclareSymbol("user void ApplyRenderingPreferences(void);", &ApplyRenderingPreferences); //_pShell->DeclareSymbol("user void ApplyVideoMode(void);", &ApplyVideoMode); _pShell->DeclareSymbol("user void Benchmark(void);", &BenchMark); /* _pShell->DeclareSymbol("user INDEX sam_bMenuSave;", &sam_bMenuSave); _pShell->DeclareSymbol("user INDEX sam_bMenuLoad;", &sam_bMenuLoad); _pShell->DeclareSymbol("user INDEX sam_bMenuControls;", &sam_bMenuControls); _pShell->DeclareSymbol("user INDEX sam_bMenuHiScore;", &sam_bMenuHiScore); */ _pShell->DeclareSymbol("user INDEX sam_bToggleConsole;",&sam_bToggleConsole);// _pShell->DeclareSymbol("INDEX sam_iStartCredits;", &sam_iStartCredits); // Obtain player and world base class without releasing it (this will never be released from stock) g_pPlayer = _pEntityClassStock->Obtain_t(CTString("Classes\\Player.ecl")); // this must not be a dependency! g_pWorldBase = _pEntityClassStock->Obtain_t(CTString("Classes\\WorldBase.ecl")); // this must not be a dependency! InitializeGame(); _pNetwork->md_strGameID = sam_strGameName; //LCDInit(); /*if( sam_bFirstStarted) { InfoMessage("%s", TRANS( "SeriousSam is starting for the first time.\n" "If you experience any problems, please consult\n" "ReadMe file for troubleshooting information.")); }*/ // initialize sound library snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); _pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat); if (sam_bAutoAdjustAudio) { _pShell->Execute("include \"Scripts\\Addons\\SFX-AutoAdjust.ini\""); } /* // execute script given on command line if (cmd_strScript!="") { CPrintF("Command line script: %s\n", cmd_strScript); CTString strCmd; strCmd.PrintF("include \"%s\"", cmd_strScript); _pShell->Execute(strCmd); } */ // load logo textures //LoadAndForceTexture(_toLogoCT, _ptoLogoCT, CTFILENAME("Textures\\Logo\\LogoCT.tex")); //LoadAndForceTexture(_toLogoODI, _ptoLogoODI, CTFILENAME("Textures\\Logo\\GodGamesLogo.tex")); //LoadAndForceTexture(_toLogoGSpy, _ptoLogoGSpy, CTFILENAME("Textures\\Logo\\LogoGSpy.tex")); //LoadAndForceTexture(_toLogoEAX, _ptoLogoEAX, CTFILENAME("Textures\\Logo\\LogoEAX.tex")); //LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), sam_strVersion); //LoadStringVar(CTString("Data\\Var\\ModName.var"), sam_strModName); CPrintF(TRANS("Nksp version: %s\n"), sam_strVersion); //CPrintF(TRANS("Active mod: %s\n"), sam_strModName); //InitializeMenus(); // ¿øº». // if there is a mod /*if (_fnmMod!="") { // execute the mod startup script _pShell->Execute(CTString("include \"Scripts\\Mod_startup.ini\";")); }*/ // init gl settings module // deleted by seo //InitGLSettings(); // init level-info subsystem // deleted by seo //LoadLevelsList(); //LoadDemosList(); // apply application mode StartNewMode( GAT_D3D, sam_iDisplayAdapter, sam_iScreenSizeI, sam_iScreenSizeJ, (enum DisplayDepth)sam_iDisplayDepth, IsFullScreen( sam_bFullScreenActive) ); _pGameState = new CGameState; _pUIMgr = new CUIManager; // yjpark _pUIMgr->Create(); // yjpark //wooss 050822 add test ui version // TEST UI¸¦ À§ÇØ Ãß°¡ // TEST ȯ°æÀÌ ¾Æ´Ò °æ¿ì À̺κÃÂÀ» FALSE·Î ó¸® // TEST ÇðíÀÚ Çô UI º¯°æ½Ã TYPE ºÎºÃÂÀ» °íÃÄ ÃÂØ´Ù //------------------------------------------------------------------------------>> // _pUIMgr->m_testUI_MODE = TRUE; _pUIMgr->m_testUI_MODE = FALSE; _pUIMgr->m_testUI_TYPE = UI_SELECTLIST; //wooss UI test variable //<<------------------------------------------------------------------------------ if(_pUIMgr->m_testUI_MODE) _pUIMgr->SetUIGameState( UGS_UI_TEST); else _pUIMgr->SetUIGameState( UGS_LOGIN ); // yjpark _pUIMgr->GetOption()->SetDesktopSize( _pixDesktopWidth, _pixDesktopHeight ); _pUIMgr->SetGameHandle(_pGame); _pUIMgr->ResetUIPos( _pdpMain );//°*µ¿¹Î ¼öä ½ÃÀÛ ½Ã½ºÅÛ ¸¶¿ì½º ÀÛ¾÷ 09.09//#define ANIMATION_CURSOR#ifdef ANIMATION_CURSOR _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_NORMAL, LoadAnimationCursor( _hInstanceMain, IDC_NORMAL_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_NORMAL, LoadAnimationCursor( _hInstanceMain, IDC_ATTACK_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_SKILL, LoadAnimationCursor( _hInstanceMain, IDC_SKILL_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_MAGIC, LoadAnimationCursor( _hInstanceMain, IDC_MAGIC_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_BOW, LoadAnimationCursor( _hInstanceMain, IDC_BOW_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_PICK, LoadAnimationCursor( _hInstanceMain, IDC_PICK_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_TALK, LoadAnimationCursor( _hInstanceMain, IDC_TALK_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_PRODUCE, LoadAnimationCursor( _hInstanceMain, IDC_PRODUCE_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_SIZE, LoadAnimationCursor( _hInstanceMain, IDC_SIZE_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ZOOMIN, LoadAnimationCursor( _hInstanceMain, IDC_ZOOMIN_CURSOR) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_SIGNAL, LoadAnimationCursor( _hInstanceMain, IDC_SIGNAL_CURSOR) );#else // FIXME : EngineÀÇ Resource¿¡ *.cur È*ÀÃÂÀ» ³Ö¾îÃÂáÀ»¶§, ÇØ´ç Ä¿¼*¸¦ ¾ò¾î¿ÀÃÂö ¸øÇؼ* ÀÌ·±½ÄÀ¸·Î ó¸®ÇÃâ€. _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_NORMAL, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_NORMAL_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_NORMAL, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_ATTACK_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_SKILL, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_SKILL_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_MAGIC, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_MAGIC_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ATT_BOW, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_BOW_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_PICK, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_PICK_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_TALK, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_TALK_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_PRODUCE, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_PRODUCE_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_SIZE, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_SIZE_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_ZOOMIN, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_ZOOMIN_CURSOR) ) ); _pUIMgr->GetMouseCursor()->SetCursorHandle( UMCT_SIGNAL, LoadCursor( _hInstanceMain, MAKEINTRESOURCE(IDC_SIGNAL_CURSOR) ) ); #endif//°*µ¿¹Î ¼öä ³¡ ½Ã½ºÅÛ ¸¶¿ì½º ÀÛ¾÷ 09.09 // set default mode reporting /*if( sam_bFirstStarted) { _iDisplayModeChangeFlag = 0; sam_bFirstStarted = FALSE; }*/ //0214 ½ºÇ÷¡½Ã ¼û±â±â // HideSplashScreen(); /* if (cmd_strPassword!="") { _pShell->SetString("net_strConnectPassword", cmd_strPassword); } #if TECHTESTONLY cmd_strWorld = CTString("Levels\\TechTestElsa.wld"); #endif if (cmd_strPlayer!="") { int iPlayer = atoi(cmd_strPlayer); _pGame->gm_aiMenuLocalPlayers[0] = Clamp(iPlayer, 0, 7); } */ //0105 42line ÃÂö¿ì±â /* // if connecting to server from command line if (cmd_strServer!="") { CTString strPort = ""; if (cmd_iPort>0) { _pShell->SetINDEX("net_iPort", cmd_iPort); strPort.PrintF(":%d", cmd_iPort); } CPrintF(TRANS("Command line connection: %s%s\n"), cmd_strServer, strPort); // go to join menu _pGame->gam_strJoinAddress = cmd_strServer; if (cmd_bQuickJoin) { extern void JoinNetworkGame(void); JoinNetworkGame(); } else { StartMenus("join"); } // if starting world from command line } else if (cmd_strWorld!="") { CPrintF(TRANS("Command line world: %s\n"), cmd_strWorld); // try to start the game with that level try { if (cmd_iGoToMarker>=0) { CPrintF(TRANS("Command line marker: %d\n"), cmd_iGoToMarker); CTString strCommand; strCommand.PrintF("cht_iGoToMarker = %d;", cmd_iGoToMarker); _pShell->Execute(strCommand); } _pGame->gam_strCustomLevel = cmd_strWorld; if (cmd_bServer) { extern void StartNetworkGame(void); StartNetworkGame(); } else { extern void StartSinglePlayerGame(void); StartSinglePlayerGame(); } } catch (char *strError) { CPrintF(TRANS("Cannot start %s: %s\n"), cmd_strWorld, strError); } // if no relevant starting at command line } else { StartNextDemo(); } */ //0105 //_pGame->gam_strJoinAddress = "211.56.73.22"; //_pGame->gm_strNetworkProvider = "TCP/IP Client"; /* _pGame->gam_strJoinAddress = "211.56.73.12"; // by seo 40225 _pGame->gm_strNetworkProvider = "TCP/IP Mmo"; if (_pGame->JoinGame( CNetworkSession( _pGame->gam_strJoinAddress))) { _gmRunningGameMode = GM_NETWORK; } //.. */ //_pGameState->m_BackGroundWorld.Load_t(LOGIN_WORLD); { /* _pGame->gm_strNetworkProvider = "Local"; _pGame->gm_aiStartLocalPlayers[0] = 0; _pGame->gm_CurrentSplitScreenCfg = CGame::SSC_PLAY1; CSessionProperties sp; _pGame->SetQuickStartSession(sp); CPlayerCharacter &pc = _pGame->gm_apcPlayers[0]; pc.pc_iPlayerIndex = 0; if(!_pGame->PreNewGame() || !_pGame->NewGame( LOGIN_WORLD, LOGIN_WORLD, sp)) { //DisableLoadingHook(); } //_pNetwork->ga_World; //_pGameState->m_BackGroundWorld.Load_t(LOGIN_WORLD); _pUIMgr->SetBackgroundWorld(&_pNetwork->ga_World); */ /* while(TRUE) { GameMainLoop(); pdp->SetAsCurrent(); pdp->Fill(C_BLACK|CT_OPAQUE); pdp->FillZBuffer(ZBUF_BACK); GameRedrawView(pdp, GRV_SHOWEXTRAS); pvp->SwapBuffers(); }; StopGame(); DisableLoadingHook(); */ }//¾ÈÅÂÈÆ ¼öä ½ÃÀÛ //(5th Closed beta)(0.2) WebAddressInit(); g_web.Begin();//¾ÈÅÂÈÆ ¼öä ³¡ //(5th Closed beta)(0.2) // 051121 nksp.exe version check on/off if(strCmdLine.IsEqualCaseSensitive(CTString("6574"))) ; else { CheckEngineVersion(); CheckEntityVersion(); } return TRUE;}void End(void){//¾ÈÅÂÈÆ ¼öä ½ÃÀÛ //(5th Closed beta)(0.2) g_web.End();//¾ÈÅÂÈÆ ¼öä ³¡ //(5th Closed beta)(0.2) _pGame->DisableLoadingHook(); // cleanup level-info subsystem //ClearLevelsList(); // ¿øº». //ClearDemosList(); _pFontStock->Release(_pfdDisplayFont); _pfdDisplayFont = NULL; _pFontStock->Release(_pfdConsoleFont); _pfdConsoleFont = NULL; _pEntityClassStock->Release(g_pPlayer); g_pPlayer = NULL; _pEntityClassStock->Release(g_pWorldBase); g_pWorldBase = NULL; // destroy the main window and its canvas if (_pvpViewPortMain!=NULL) { _pGfx->DestroyWindowCanvas( _pvpViewPortMain); _pvpViewPortMain = NULL; _pdpNormalMain = NULL; } CloseMainWindow(); MainWindow_End(); //DestroyMenus(); // ¿øº». _pGame->End(); //LCDEnd(); // unlock the directory DirectoryLockOff(); SE_EndEngine(); void (*GAME_Destroy)(void) = (void (*)(void))GetProcAddress(g_hGame, "GAME_Destroy"); if (GAME_Destroy==NULL) { ThrowF_t("%s", GetWindowsError(GetLastError())); } GAME_Destroy();//¾ÈÅÂÈÆ ¼öä ½ÃÀÛ //(DevPartner Bug Fix)(2005-01-14) if(g_hGame) FreeLibrary(g_hGame);//¾ÈÅÂÈÆ ¼öä ³¡ //(DevPartner Bug Fix)(2005-01-14)}// print display mode info if neededvoid PrintDisplayModeInfo(void){ // skip if timed out if( _pTimer->GetRealTimeTick() > (_tmDisplayModeChanged+sam_tmDisplayModeReport)) return; // cache some general vars SLONG slDPWidth = _pdpMain->GetWidth(); SLONG slDPHeight = _pdpMain->GetHeight(); if( _pdpMain->IsDualHead()) slDPWidth/=2; if( _pdpMain->IsTripleHead()) slDPWidth/=3; CDisplayMode dm; dm.dm_pixSizeI = slDPWidth; dm.dm_pixSizeJ = slDPHeight; // determine proper text scale for statistics display FLOAT fTextScale = (FLOAT)slDPHeight/480.0f/2; // get resolution CTString strRes; extern CTString _strPreferencesDescription; strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, _pGfx->gl_dmCurrentDisplayMode.DepthString()); if( dm.IsDualHead()) strRes += TRANS(" DualMonitor"); if( dm.IsTripleHead()) strRes += TRANS(" TripleMonitor"); if( dm.IsWideScreen()) strRes += TRANS(" WideScreen"); if( _pGfx->gl_eCurrentAPI==GAT_OGL) strRes += " (OpenGL)"; else if( _pGfx->gl_eCurrentAPI==GAT_D3D) strRes += " (Direct3D)"; CTString strDescr; strDescr.PrintF("\n%s (%s)\n", _strPreferencesDescription, RenderingPreferencesDescription(sam_iVideoSetup)); strRes += strDescr; // tell if application is started for the first time, or failed to set mode if( _iDisplayModeChangeFlag==0) { strRes += TRANS("Display mode set by default!"); } else if( _iDisplayModeChangeFlag==2) { strRes += TRANS("Last mode set failed!"); } // print it all _pdpMain->SetFont( _pfdDisplayFont); _pdpMain->SetTextScaling( fTextScale); _pdpMain->SetTextShadow( +2); _pdpMain->SetTextAspect( 1.0f); const FLOAT fPosMul = _pdpMain->IsTripleHead() ? 1.05f : 0.05f; //pdp->PutText( strRes, slDPWidth*fPosMul, slDPHeight*0.85f, LCDGetColor(C_GREEN|255, "display mode")); // ¿øº». _pdpMain->PutText( strRes, slDPWidth*fPosMul, slDPHeight*0.85f);}// do the main game loop and render screenvoid DoGame(void){ // set flag if not in game if( !_pGame->gm_bGameOn) //_gmRunningGameMode = GM_NONE; // ¿øº». _pGameState->GetGameMode() = CGameState::GM_NONE; // °Ãâ€Ãƒâ‚¬Ãƒâ€œ ¸ðµå°¡ µ¥¸ð¸ðµåÀö§... /* if( _gmRunningGameMode==GM_DEMO && _pNetwork->IsDemoPlayFinished() ||_gmRunningGameMode==GM_INTRO && _pNetwork->IsGameFinished()) { _pGame->StopGame(); _gmRunningGameMode = GM_NONE; // load next demo StartNextDemo(); if (!_bInAutoPlayLoop) { // start menu StartMenus(); } } */ /* // do the main game loop if( _gmRunningGameMode == GM_LOGIN){ _pNetwork-> } else*/ // °Ãâ€Ãƒâ‚¬Ãƒâ€œ ½ÇÇàÃÂßÀö§ »óÅÂ! //_pGameState->m_bMenuActive 0 //_pGameState->m_bMenuRendering 1 //_gmMenuGameMode GM_NONE //_gmRunningGameMode GM_NETWORK //_pGame->gm_bGameOn 1 //_pGame->gm_bMenuOn 0 // °Ãâ€Ãƒâ‚¬Ãƒâ€œÃƒâ‚¬ÃƒÅ’ ½ÇÇàÃÂßÀö§¸¸ È£ÃâµÇ´Â ºÎºÃÂ. //if( _gmRunningGameMode != GM_NONE) //if( _gmRunningGameMode != GM_NONE) // ¿øº». if( _pGameState->GetGameMode() != CGameState::GM_NONE) // ¿øº». { _pGame->GameMainLoop(); //0215 // CSoundObject soMusic; // soMusic.Play_t(CTFILENAME("Music\\Credits.mp3"), SOF_NONGAME|SOF_MUSIC|SOF_LOOP); // // if game is not started } else { // just handle broadcast messages _pNetwork->GameInactive(); } // redraw the view if( !IsIconic(_hwndMain) && _pdpMain!=NULL && _pdpMain->Lock()) { // ¸Þ´º°¡ ºñȰ¼ºÈ* µÇ¾ú°í, °Ãâ€Ãƒâ‚¬Ãƒâ€œ ½ÇÇàÃÂßÀö§??? //if( _gmRunningGameMode!=GM_NONE && !_pGameState->m_bMenuActive ) //if( _gmRunningGameMode!=GM_NONE && !_pGameState->m_bMenuActive ) // ¿øº». int iState = _pGameState->GetGameMode(); //BOOL bState = _pGameState->m_bMenuActive; if( _pGameState->GetGameMode() != CGameState::GM_NONE) // ¿øº». { // handle pretouching of textures and shadowmaps _pdpMain->Unlock(); // °á±¹Àº RenderView()¸¦ È£ÃâÇÃâ€. _pGame->GameRedrawView( _pdpMain, (_pGame->gm_csConsoleState!=CS_OFF)?0:GRV_SHOWEXTRAS); _pdpMain->Lock(); } else { //pdp->Fill( LCDGetColor(C_dGREEN|CT_OPAQUE, "bcg fill")); // ¿øº». _pdpMain->Fill(C_dGREEN|CT_OPAQUE); } // do menu /* if( _pGameState->m_bMenuRendering) { // clear z-buffer pdp->FillZBuffer( ZBUF_BACK); // remember if we should render menus next tick _pGameState->m_bMenuRendering = DoMenu(pdp); } */ //_pUIMgr->SetBackgroundWorld(&_pGameState->m_BackGroundWorld); //pdp->FillZBuffer( ZBUF_BACK); /* TIME tmTickNow = _pTimer->GetRealTimeTick(); while( _tmMenuLastTickDone < tmTickNow) { _pTimer->SetCurrentTick(_tmMenuLastTickDone); _tmMenuLastTickDone += _pTimer->TickQuantum; } SetMenuLerping(); */ //if(_pGameState->m_bMenuRendering) // Render User interface //_pUIMgr->Render( _pdpMain ); // yjpark //0609 kwon _pGame->GameRedrawCursor( _pdpMain, (_pGame->gm_csConsoleState!=CS_OFF)?0:GRV_SHOWEXTRAS); // print display mode info if needed //PrintDisplayModeInfo(); // render console // ÄܼÖâ ·»´õ¸µ. _pGame->ConsoleRender(_pdpMain); // done with all _pdpMain->Unlock(); // clear upper and lower parts of screen if in wide screen mode/* if( _pdpMain==_pdpWideScreenMain && _pdpNormalMain->Lock()) { const PIX pixWidth = _pdpWideScreenMain->GetWidth(); const PIX pixHeight = (_pdpNormalMain->GetHeight() - _pdpWideScreenMain->GetHeight()) /2; const PIX pixJOfs = pixHeight + _pdpWideScreenMain->GetHeight()-1; _pdpNormalMain->Fill( 0, 0, pixWidth, pixHeight, C_BLACK|CT_OPAQUE); _pdpNormalMain->Fill( 0, pixJOfs, pixWidth, pixHeight, C_BLACK|CT_OPAQUE); _pdpNormalMain->Unlock(); }*/ // show _pvpViewPortMain->SwapBuffers(); }}/*void TeleportPlayer(int iPosition){CTString strCommand;strCommand.PrintF( "cht_iGoToMarker = %d;", iPosition);_pShell->Execute(strCommand);}*/CTextureObject _toStarField;static FLOAT _fLastVolume = 1.0f;void RenderStarfield(CDrawPort *pdp, FLOAT fStrength){ CTextureData *ptd = (CTextureData *)_toStarField.GetData(); // skip if no texture if(ptd==NULL) return; PIX pixSizeI = pdp->GetWidth(); PIX pixSizeJ = pdp->GetHeight(); FLOAT fStretch = pixSizeJ / 480.0f; fStretch *= FLOAT(ptd->GetPixWidth()) / ptd->GetWidth(); PIXaabbox2D boxScreen(PIX2D(0,0), PIX2D(pixSizeI, pixSizeJ)); MEXaabbox2D boxTexture(MEX2D(0, 0), MEX2D(pixSizeI/fStretch, pixSizeJ/fStretch)); pdp->PutTexture(&_toStarField, boxScreen, boxTexture, LerpColor(C_BLACK, C_WHITE, fStrength)|CT_OPAQUE);}FLOAT RenderQuitScreen(CDrawPort *pdp, CViewPort *pvp){ CDrawPort dpQuit(pdp, 0); CDrawPort dpWide; dpQuit.MakeWideScreen(&dpWide); // redraw the view if (!dpWide.Lock()) { return 0; } dpWide.Fill(C_BLACK|CT_OPAQUE); RenderStarfield(&dpWide, _fLastVolume); // FLOAT fVolume = Credits_Render(&dpWide);// _fLastVolume = fVolume; _fLastVolume = 1.0f; dpWide.Unlock(); pvp->SwapBuffers(); return _fLastVolume;}// þ·á½Ã Credit º¸¿©ÃÂÖ´Â ºÎºÃÂ.void QuitScreenLoop(void){// Credits_On(3); CSoundObject soMusic; try { _toStarField.SetData_t(CTFILENAME("Textures\\Background\\Night01\\Stars01.tex")); //0603 kwon ȏæ. // soMusic.Play_t(CTFILENAME("Music\\Credits.mp3"), SOF_NONGAME|SOF_MUSIC|SOF_LOOP); } catch (char *strError) { CPrintF("%s\n", strError); } // while it is still running FOREVER { FLOAT fVolume = RenderQuitScreen(_pdpMain, _pvpViewPortMain); if (fVolume<=0) { return; } // assure we can listen to non-3d sounds soMusic.SetVolume(fVolume, fVolume); _pSound->UpdateSounds(); // while there are any messages in the message queue MSG msg; while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // if it is not a keyboard or mouse message if(msg.message==WM_LBUTTONDOWN|| msg.message==WM_RBUTTONDOWN|| msg.message==WM_KEYDOWN) { return; } } //Sleep(5); }}// reverses stringvoid StrRev( char *str) { char ctmp; char *pch0 = str; char *pch1 = str+strlen(str)-1; while( pch1>pch0) { ctmp = *pch0; *pch0 = *pch1; *pch1 = ctmp; pch0++; pch1--; }}void GetLCModulePathName(char* Path){ char strTmpPath[MAX_PATH] = ""; GetModuleFileName(NULL, strTmpPath, MAX_PATH); StrRev(strTmpPath); char *pstr = strchr( strTmpPath, \\); if( strnicmp( pstr, "\\gubed", 6)==0) pstr += 6; if( pstr[0] = \\) pstr++; char *pstrFin = strchr( pstr, \\); if( pstrFin==NULL) { strcpy( pstr, "\\"); pstrFin = pstr; } StrRev(pstrFin); strncpy(strTmpPath, pstrFin, MAX_PATH-1); strcpy(Path, strTmpPath);}int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ (void)hPrevInstance;#ifdef USE_NEW_LAUNCHER CTString strparam = CTString(lpCmdLine); IPCEventInfo EventInfo; memset(EventInfo.ulParameter2, 0, sizeof(EventInfo.ulParameter2)); ////////////////////////////////////////////////////////////////////////// // char strPathName[MAX_PATH] = ""; GetLCModulePathName(strPathName); CTFileName fnmBatch(strPathName); fnmBatch = fnmBatch + "LAUNCHER.BAT"; FILE* fp = NULL; BOOL bExistNewLauncher = FALSE; int nLoopCount = 0; // launcher patch process change. [8/27/2010 rumist] if ((fp = fopen(fnmBatch, "rb")) != NULL) { fclose(fp);// MessageBox(NULL, "Update is completed.\nPlease, restart game.", "Update completed", MB_OK);// ShellExecute(NULL, "open", fnmBatch, NULL, strPathName, SW_HIDE);// return TRUE; bExistNewLauncher = TRUE; } if (!strparam.IsEqualCaseSensitive(CTString("4022"))) { // IPC ////////////////////////////////////////////////////////////////////////// XExtIPCManager<IPCEventInfo> IPCMgr; int Ret = IPCMgr.XExtIPCEventCreate(1, FALSE); if (Ret < 0) { MessageBox(NULL, "This program could not be run itself", "LastChaos", MB_OK); IPCMgr.XExtIPCEventRelease(FALSE); return TRUE; } do { EventInfo.EventID = 0; Ret = IPCMgr.XExtIPCEventQueryIPCEvent(&EventInfo, NULL); ++nLoopCount; if (Ret > 0) { IPCEventInfo SendEventInfo; if (bExistNewLauncher) { SendEventInfo.EventID = -1; SendEventInfo.DestProcessID = 0; SendEventInfo.ulParameter1 = 0; memset(SendEventInfo.ulParameter2, 0, sizeof(SendEventInfo.ulParameter2)); IPCMgr.XExtIPCEventPost(&SendEventInfo); IPCMgr.XExtIPCEventRelease(FALSE); MessageBox(NULL, "Update is completed.\nPlease, restart game.", "Update completed", MB_OK); ShellExecute(NULL, "open", fnmBatch, NULL, strPathName, SW_HIDE); return TRUE; } else if (EventInfo.EventID != 100) { SendEventInfo.EventID = -1; SendEventInfo.DestProcessID = 0; SendEventInfo.ulParameter1 = 0; memset(SendEventInfo.ulParameter2, 0, sizeof(SendEventInfo.ulParameter2)); IPCMgr.XExtIPCEventPost(&SendEventInfo); MessageBox(NULL, "This program could not be run itself", "LastChaos", MB_OK); IPCMgr.XExtIPCEventRelease(FALSE); return TRUE; } if (SE_GetEngineDllRefCnt() > 1 || IsRunning() )// ¸ÖƼ Ŭ¶óÀ̾ðÆ® ¸·±â. [2/4/2010 rumist] { SendEventInfo.EventID = -1; SendEventInfo.DestProcessID = 0; SendEventInfo.ulParameter1 = 0; memset(SendEventInfo.ulParameter2, 0, sizeof(SendEventInfo.ulParameter2)); IPCMgr.XExtIPCEventPost(&SendEventInfo); MessageBox(NULL, "Already Executive Game.", "LastChaos", MB_OK); IPCMgr.XExtIPCEventRelease(FALSE); return TRUE; } else { SendEventInfo.EventID = 100; SendEventInfo.DestProcessID = 0; SendEventInfo.ulParameter1 = 0; memset(SendEventInfo.ulParameter2, 0, sizeof(SendEventInfo.ulParameter2)); IPCMgr.XExtIPCEventPost(&SendEventInfo); IPCMgr.XExtIPCEventRelease(FALSE); //MessageBox(NULL, "Send Event message", "LastChaos", MB_OK); } break; } } while( nLoopCount != 1000 ); } GetNM(EventInfo.ulParameter2);#else if (strlen(lpCmdLine) <= 0) { if( g_iCountry == RUSSIA ) { MessageBox(NULL, "Êëèåíò èãðû íå ìîæå?áûòü çàïóùå?ñàìîñò?òåëüíî.", "LastChaos", MB_OK); } else { MessageBox(NULL, "This program could not be run itself", "LastChaos", MB_OK); } return TRUE; } GetNM(lpCmdLine);#endif ShowCursor(FALSE); if( !Init( hInstance, nCmdShow, lpCmdLine )) return FALSE; BOOL bInit = TRUE; // WSS_NPROTECT 070402 ------------------------------->>#ifndef NO_GAMEGUARD// CPrintF("[ ---->> GameGuard Init...Start <<---- ] - %lu\n",timeGetTime()); //bInit = _pNetwork->Init_nProtect(); //_pGameState->Running() = bInit; //WinMain ÃÖ»ó´Ü¿¡ ³Ö¾úÀ¸³ª string ó¸® ºÎºÃÂÀÌ uimanager¿¡ ÀÖ¾î¼* uimanagerÀ» »ý¼º ÈÄ ó¸®Çؾß µÈ´Ù. CREATE_GAMEGUARD_WRAPPER(); bInit = GAME_GUARD()->Init(); // CPrintF("[ ---->> GameGuard Init...End <<---- ] - %lu\n",timeGetTime());#endif // ---------------------------------------------------<< // initialy, application is running and active, console and menu are off //_bRunning = TRUE; //_bQuitScreen = TRUE; if(g_szExitError == NULL && bInit) { _pGameState->Running() = TRUE; _pGameState->QuitScreen() = TRUE; } _pGame->gm_csConsoleState = CS_OFF; //_pGame->gm_csComputerState = CS_OFF; // _pGameState->m_bMenuActive = FALSE; //_pGameState->m_bMenuRendering = FALSE; // while it is still running #if _DEBUG// enableFPExceptions();#endif //_pGame->QuickTest(LOGIN_WORLD, pdp, pvpViewPort);//#define AUTO_LOGIN#ifndef AUTO_LOGIN if(_pGameState->Running()) { _pGame->LoginGame(LOGIN_WORLD); }#else if(_pGameState->Running()) { g_slZone = 0; _pGame->LoginGame(START_WORLD); }#endif ShowCursor(TRUE); // À̱âȯ ¼öä ½ÃÀÛ (11. 15) : IME »óÅ â æ°Å SendMessage ( _hwndMain, WM_IME_NOTIFY, IMN_CLOSESTATUSWINDOW, NULL ); // À̱âȯ ¼öä ³¡ //¾ÈÃ
#2

2 or go here and not have to like him ^^ silly russian

 

#3
This is just 1 file of the Nksp source.

#4
hi

#5
hi thanks

#6
thx

#7
Thanks ;D

#8
Outdated, doesnt belong to EP2 and imcomplete - but thanks for sharing things you dont have a clue about Wink

#9
thx

#10
thanks



Forum Jump:


Users browsing this thread: 2 Guest(s)