Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] How to find out why your Game is terminating abruptly

Status
Not open for further replies.
[emoji848]
Legend
Joined
Dec 3, 2011
Messages
2,232
Reaction score
1,518
As recent incidents show, people don't seem to be able to find out why "nothing happens" after they start their game (Aceonline.atm). This is a rather quick tutorial on how to add most simple debugging to find out what's going on.

Before you start doing anything, check the Server logs, located at "Server/log/SystemLog", for any problems during the establishing of the connections.

I put "nothing happens" into quotes here as there could be a lot of things happening actually. You just don't see an UI yet because the game terminates before initializing the HWND without further messages.

To find out what's happening I suggest putting Message Boxes in front of each return of the main entry point that is not showing any output when failing.

WARNING: This tutorial requires basic knowledge about copy & pasting. It is a requirement that your code already compiles successfully!

1. Open ProjectAtum.cpp

Future - [Tutorial] How to find out why your Game is terminating abruptly - RaGEZONE Forums



2. Add debug messages

To be able to easily find out where your game terminated, add simple MessageBoxes in front of every return in the main entry point! Hell, you don't even need to debug for this!

Add:
Code:
MessageBox(NULL, "DebugX blablabla(insert debugging info here)", NULL, MB_OK);
in front of every
Code:
return x;
that you see.

Your main function should look somewhat like this now:

Code:
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	g_cCustomOptimizer.AutoLauncher();

 	// 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤ 
	SetUnhandledExceptionFilter(Exception_Minidump);
	// end 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤ 
 
	if (g_hMutexMonoInstance)
	{
		MessageBox(NULL, "Debug g_hMutexMonoInstance != NULL", NULL, MB_OK);
		return 0;
	}

	g_hMutexMonoInstance = CreateMutex(NULL, TRUE, WINDOWTEXT_NAME_CLIENT);

	if (NULL == g_hMutexMonoInstance)
	{
		MessageBox(NULL, "Debug g_hMutexMonoInstance == NULL", NULL, MB_OK);
		return 0;
	}

#ifdef MULTI_LOADER_HSSON

#else // MULTI_LOADER_HSSON
	if(ERROR_ALREADY_EXISTS == ::GetLastError())
	{
		MessageBox(NULL, "ERROR : \nApplication is running already...", WINDOWTEXT_NAME_CLIENT, MB_OK);
		return 0;
	}
#endif // MULTI_LOADER_HSSON

	// 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
	//if(__argc != 12 && __argc != 16 && __argc != 11 && __argc != 14)
	if(__argc != 12 && __argc != 16 && __argc != 11 && __argc != 15)
	{
		DBGOUT("[Error] Parameter Count Error, Count(%d)(%s)\n", __argc, lpCmdLine);
		MessageBox(NULL, "Debug Parameter Count Error", NULL, MB_OK);
		return FALSE;
	}

	char szTemp[20];
	CAtumApplication pD3dApp;

	if( __argc == 12 )
	{
#ifdef MULTI_LOADER_HSSON
		sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort, pD3dApp.m_strUserID,
				pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree, szTemp);
		
		if (strcmp(szTemp, "DEVELOP") != 0)
		{
			MessageBox(NULL, "Debug wrong parameter call", NULL, MB_OK);
			return 0;
		}
			
#else // MULTI_LOADER_HSSON
		MessageBox(NULL, "Debug Invalid parameter count", NULL, MB_OK);
		return 0;
#endif // MULTI_LOADER_HSSON
	}
	else if(__argc == 11)	// 2005-08-05 by cmkwon, for JPN release
	{
		sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort, pD3dApp.m_strUserID,
				pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree);
	}
#ifdef KOR_YEDANG_WEB_LAUNCHER_HSSON
	// 2006-10-02 by ispark, Çѱ¹ À¥ ·±Ã³
	// 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
	//else if(__argc == 14)
	else if(__argc == 15)
	{
		int nSeed = 0;
		int nType = 0;
		char Reserve1[20] = {0,};
		char Reserve2[20] = {0,};
		char strMutexID[1024] = {0,};

		DbgOut("%s\n", lpCmdLine);
		sscanf(lpCmdLine,"%s %d %s %d %d %d %d %d %s %s %d %d %s %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort,
						&pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree,						
						&pD3dApp.m_IsFullMode,	// 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
						pD3dApp.m_strUserID, pD3dApp.m_strUserPassword, &nSeed, &nType, Reserve1, Reserve2);

		HANDLE hMutex = NULL;
		sprintf(strMutexID, "%s%d", pD3dApp.m_strUserPassword, nSeed);
		hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, TRUE, (LPTSTR)strMutexID);
		if(hMutex == NULL)
		{
			DbgOut("[Error] Mutex Error\n");
			MessageBox(NULL, "Debug Mutex error", NULL, MB_OK);
			return FALSE;
		}	
		// 2006-10-18 by ispark, ReleaseMutex() -> CloseHandle()·Î º¯°æ
		CloseHandle(hMutex);
	}
#endif //YEDANG_WEB_LAUNCHER
	else
	{
		int nSeed = 0;
		char szAccount[SIZE_MAX_ACCOUNT_NAME];
		char szEncAccount[MGAME_MAX_PARAM_STRING_SIZE];
		char szEncPassword[MGAME_MAX_PARAM_STRING_SIZE];

		sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d %s %d %s %s %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort,
						pD3dApp.m_strUserID, pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree,
						szTemp, &nSeed, szAccount, szEncAccount, szEncPassword);

		// Mutex Check
		HANDLE hMutex = NULL;	
		hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, TRUE, (LPTSTR)szEncPassword);  // ¾ÏȣȭµÈÆнº¿öµå°ªÀ» ³Ö´Â´Ù
		if(hMutex == NULL)
		{
			DBGOUT("[Error] Mutex Error\n");
			MessageBox(NULL, "Debug Mutex error", NULL, MB_OK);
			return FALSE;
		}	
		// 2006-10-18 by ispark, ReleaseMutex() -> CloseHandle()·Î º¯°æ
		CloseHandle(hMutex);
		
		// ExcuteType Check
		if(strcmp(szTemp, "INET"))
		{
			DBGOUT("[Error] Excute Type Error, Type(%s)\n", szTemp);
			MessageBox(NULL, "Execute type error", NULL, MB_OK);
			return FALSE;
		}

		char szDecryptedID[MGAME_MAX_PARAM_STRING_SIZE];	
		strncpy(szDecryptedID, (char *)decrypt((unsigned char*)szEncAccount, nSeed), MGAME_MAX_PARAM_STRING_SIZE);
		
		// ID Check
		if(strcmp(szAccount, szDecryptedID))
		{
			DBGOUT("[Error] Decryption ID Error, DecryptedID(%s)\n", szDecryptedID);
			MessageBox(NULL, "Debug Decryption ID Error", NULL, MB_OK);
			return FALSE;
		}

	}

#ifdef ONLY_FULL_WINDOW_HSSON
		pD3dApp.m_IsFullMode = TRUE;
#endif // ONLY_FULL_WINDOW_HSSON

	// 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
	if(!pD3dApp.StartGameGuard())
	{
		pD3dApp.CloseGameGuard();
		MessageBox(NULL, "Debug Failed to start game guard", NULL, MB_OK);
		return FALSE;
	}		
	// end 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡

	// 2007-12-21 by dgwoo â¸ðµå Áö¿ø
	DbgOut("FullMode = %d\n",pD3dApp.m_IsFullMode);
	if (FAILED(pD3dApp.Create(hInstance)))
	{
		MessageBox(NULL, "Debug Failed to initialize the game", NULL, MB_OK);
		return 0;
	}
		
// 2008-11-28 by bhsohn XignCodeÃß°¡
	///////// °ÔÀÓ °¡µå ¼³Á¤///////// 
//#if defined(_DEBUG) || defined(GAMEFORGE_RELEASE) || defined(WORLD_RELEASE) || defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#if defined(_DEBUG) || defined(LANGUAGE_RUSSIA)
//#else
//	// 2006-06-05 by ispark
//	if(!pD3dApp.HS_Start())
//	{
//		DBGOUT("HShield Error\n");
//		pD3dApp.HS_Close();
//		return FALSE;
//	}
//#endif
	// 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
// 	if(!pD3dApp.StartGameGuard())
// 	{
// 		pD3dApp.CloseGameGuard();
// 		return FALSE;
// 	}	
	// end 2008-11-28 by bhsohn XignCodeÃß°¡
	// end 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡

	// 2009-01-28 by bhsohn nProtector °ÔÀÓ °¡µå Ãß°¡
	if(!pD3dApp.SetGameGuardHWND())
	{
		pD3dApp.CloseGameGuard();
		MessageBox(NULL, "Debug Failed to initialize Game Guard", NULL, MB_OK);
		return FALSE;
	}	
	// end 2009-01-28 by bhsohn nProtector °ÔÀÓ °¡µå Ãß°¡

	g_input.InitInput();

	INT nResult;

// 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤ 
// #ifdef _DEBUG
// 	nResult = pD3dApp.Run();
// #else
// 	try
// 	{
// 		nResult = pD3dApp.Run();
// 	}
// 
// 	catch(...)
// 	{
// 		DBGOUT("Extations Error\n");
// 		// 2008-11-28 by bhsohn XignCodeÃß°¡
// 		//pD3dApp.HS_Close();
// 		pD3dApp.CloseGameGuard();
// 		// end 2008-11-28 by bhsohn XignCodeÃß°¡
// 	}
// #endif
//#ifdef _DEBUG
	nResult = pD3dApp.Run();
//#else
//	try
//	{
//		nResult = pD3dApp.Run();
//	}

//	catch(...)
//	{
		DBGOUT("Extations Error\n");
		// 2008-11-28 by bhsohn XignCodeÃß°¡
		//pD3dApp.HS_Close();
		pD3dApp.CloseGameGuard();
		// end 2008-11-28 by bhsohn XignCodeÃß°¡
//	}
//#endif
// end 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤
	CloseHandle(g_hMutexMonoInstance);

	// 2008-11-28 by bhsohn XignCodeÃß°¡
// 2008-09-19 by bhsohn Canada HackShield
//#if	defined(_DEBUG) || defined(GAMEFORGE_RELEASE) || defined(WORLD_RELEASE)|| defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#if	defined(_DEBUG) || defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#else
//	// 2006-06-05 by ispark
//	pD3dApp.HS_Close();	
//#endif
	pD3dApp.CloseGameGuard();	
	// end 2008-11-28 by bhsohn XignCodeÃß°¡

	// 2006-07-06 by ispark, °­Á¦ Á¾·áÀ̸鼭 ¿¡·¯ ¸Þ¼¼Áö¸¦ °¡Áö°í ÀÖ´Ù¸é
	if(pD3dApp.m_bShutDown && strlen(pD3dApp.m_strMsgLastError))
	{
		MessageBox(NULL, pD3dApp.m_strMsgLastError,STRMSG_WINDOW_TEXT, MB_OK);
	}

	return nResult;
}


3. Compile the client

Please don't forget to compile your client after those changes.
Future - [Tutorial] How to find out why your Game is terminating abruptly - RaGEZONE Forums



4. Replace the client and start it

Future - [Tutorial] How to find out why your Game is terminating abruptly - RaGEZONE Forums


Start the launcher and login to start the ace.atm process.
Now you should get a message box popping up whenever your client is about to abort the start routine. This at least gives you an idea where to search for the problem.

Future - [Tutorial] How to find out why your Game is terminating abruptly - RaGEZONE Forums



A little tip

That being said, the problem most likely occurs here:

Code:
pD3dApp.StartGameGuard()
or here:
Code:
pD3dApp.Create(hInstance)

Possible Hot-Fixes

  • Validate your Hack Shield installation or optionally turn it off
  • Validate your Direct-X installation
  • Start the game as administrator
  • Create a new omi.tex file

Hope it helps you to fix your problems when launching the game.
 
Last edited:
Junior Spellweaver
Joined
Nov 19, 2014
Messages
132
Reaction score
12
Nice to see someone working for forum, youre doing a good job future
 
Joined
Apr 12, 2013
Messages
896
Reaction score
479
Sadly, what Future has done here is outline the very basics of how you start any kind of debugging session, something that should be painfully obvious to anyone who is actually willing to learn a programming language.
Well, sadly it's the only option here, because most people here don't even understand the simple datatypes etc, and how to debug memory (even with Visual Studio)
 
[emoji848]
Legend
Joined
Dec 3, 2011
Messages
2,232
Reaction score
1,518
I agree with all said above. The proper way is to attach a debugger to the process or get some kind of debug outputting system to work.
But as the debugging of the main function is quite a hassle to do as the process starts with variable arguments and you'd have to add some layer in-between that gets those arguments and launches the debugger with them, I decided to keep things simple.

This should be fairly simple to do for everyone without diving into tutorials on how to debug things
 
Status
Not open for further replies.
Back
Top