Try Function Error C2712-VBForums
Results 1 to 3 of 3

Thread: Try Function Error C2712

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    7

    Try Function Error C2712

    Code:
    BOOL CMapServerManager::LoadData(char* lpszFileName)
    {
    	if ( (lpszFileName == NULL) || ( strcmp(lpszFileName, "")== 0 ) ) 
    	{
    		MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : File Name Error");
    		return FALSE;
    	}
    
    	EnterCriticalSection(&this->m_critSVRCODE_MAP);
    
    	__try
    	{
    		this->Clear();
    
    		SMDFile = fopen(lpszFileName, "r");
    
    		if ( SMDFile == NULL )
    		{
    			MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : fopen() : %s",
    				lpszFileName);
    
    			return FALSE;
    		}
    
    		int type = -1;
    		SMDToken Token;
    
    		while ( true )
    		{
    			Token = GetToken();
    
    			if ( Token == END )
    				break;
    
    			type = TokenNumber;
    
    			while ( true )
    			{
    				if ( type == 0 )
    				{
    					short sSVR_CODE = -1;
    					short sMAPSVR_GROUP = -1;
    					int iInitSetVal = 1;
    					char szIpAddr[16]={0};
    					WORD wPortNum = 0;
    					
    					Token = GetToken();
    
    					if ( !strcmp("end", TokenString))
    						break;
    
    					sSVR_CODE = TokenNumber;
    
    					Token = GetToken();
    					sMAPSVR_GROUP = TokenNumber;
    
    					Token = GetToken();
    					iInitSetVal = TokenNumber;
    
    					Token = GetToken();
    					memcpy(szIpAddr, &TokenString[1], 16);
    					szIpAddr[15] =0;
    
    					Token = GetToken();
    					wPortNum = TokenNumber;
    
    					if ( sSVR_CODE < 0 )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE < 0 (SVR:%d) - 1",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( iInitSetVal != -1 && iInitSetVal != 0 && iInitSetVal != 1 )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : iInitSetting Value:%d (SVR:%d) - 1",
    							iInitSetVal, sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( !strcmp(szIpAddr, ""))
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : No IpAddress (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( CHECK_LIMIT(sMAPSVR_GROUP, MAX_MAP_GROUPS) == FALSE )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : Map Server Group Index (IDX:%d)",
    							sMAPSVR_GROUP);
    
    						return FALSE;
    					}
    
    					if ( this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP] >= MAX_MAP_SUBGROUPS )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : No Space to Save SvrInfo (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					_MAPSVR_DATA * lpMapSvrData = NULL;
    
    					lpMapSvrData= &this->m_MAPSVR_DATA[sMAPSVR_GROUP][this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]];
    
    					lpMapSvrData->Clear(iInitSetVal);
    					lpMapSvrData->m_bIN_USE = TRUE;
    					lpMapSvrData->m_sSVR_CODE = sSVR_CODE;
    					lpMapSvrData->m_btMAPSVR_GROUP = sMAPSVR_GROUP;
    					lpMapSvrData->m_wPORT = wPortNum;
    					memcpy(lpMapSvrData->m_cIPADDR, szIpAddr, 16);
    					lpMapSvrData->m_cIPADDR[15] = 0;
    					
    					this->m_mapSVRCODE_MAP.insert(std::pair<int,_MAPSVR_DATA *>(sSVR_CODE, lpMapSvrData));
    					this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]++;
    				}
    				else if ( type == 1 )
    				{
    					short sSVR_CODE = -1;
    					BYTE btNotMoveOption = 0;
    					WORD wMapNum = 0;
    					short sDEST_SVR_CODE = -1;
    					_MAPSVR_DATA * lpMapSvrData = NULL;
    
    					Token = GetToken();
    
    					if ( !strcmp("end", TokenString))
    						break;
    
    					sSVR_CODE = TokenNumber;
    
    					Token = GetToken();
    					btNotMoveOption = TokenNumber;
    
    					Token = GetToken();
    					wMapNum = TokenNumber;
    
    					Token = GetToken();
    					sDEST_SVR_CODE = TokenNumber;
    
    					if ( sSVR_CODE < 0 )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE < 0 (SVR:%d) - 2",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( sDEST_SVR_CODE < -2 )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : sDEST_SVR_CODE < -1 (SVR:%d, DEST_SVR:%d) - 2",
    							sSVR_CODE, sDEST_SVR_CODE);
    
    						return FALSE;
    					}
    
    					std::map<int  ,_MAPSVR_DATA *>::iterator it = this->m_mapSVRCODE_MAP.find(sSVR_CODE);
    
    					if ( it == this->m_mapSVRCODE_MAP.end() )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE wasn't registered (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					lpMapSvrData = it->second;
    
    					if ( lpMapSvrData == NULL )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData == NULL (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( lpMapSvrData->m_bIN_USE == FALSE )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_bIN_USE == FALSE (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( lpMapSvrData->m_sSVR_CODE != sSVR_CODE )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d)",
    							sSVR_CODE);
    
    						return FALSE;
    					}
    
    					if ( btNotMoveOption != 0 && btNotMoveOption != 1 )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
    							sSVR_CODE, btNotMoveOption);
    
    						return FALSE;
    					}
    
    					if ( CHECK_LIMIT(wMapNum, MAX_NUMBER_MAP) == FALSE )
    					{
    						MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : Map Number is out of bound (SVR:%d, MAP:%d)",
    							sSVR_CODE, wMapNum);
    
    						return FALSE;
    					}
    
    					switch ( btNotMoveOption )
    					{
    						case 0:
    							lpMapSvrData->m_sMAP_MOVE[wMapNum] = sDEST_SVR_CODE;
    							break;
    						case 1:
    							lpMapSvrData->m_sMAP_MOVE[wMapNum] = -3;
    							break;
    						default:
    							MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
    								sSVR_CODE, btNotMoveOption);
    							break;
    					}
    				}	// if type
    			}	// while ( true )
    		}	// while ( true )
    
    		fclose(SMDFile);
    
    		std::map<int  ,_MAPSVR_DATA *>::iterator it = this->m_mapSVRCODE_MAP.find(gGameServerCode);
    
    		if ( it != this->m_mapSVRCODE_MAP.end() )
    		{
    			this->m_lpThisMapSvrData = it->second;
    		}
    		else
    		{
    			this->m_lpThisMapSvrData = NULL;
    		}
    
    		if ( this->m_lpThisMapSvrData == NULL )
    		{
    			MsgBox("[MapServerMng] CMapServerManager::LoadData() - file load error : This GameServerCode (%d) doesn't Exist at file '%s' != sSVR_CODE",
    				gGameServerCode, lpszFileName);
    
    			return FALSE;
    		}
    
    		this->m_bMapDataLoadOk = TRUE;
    	}
    	__finally
    	{
    		LeaveCriticalSection(&this->m_critSVRCODE_MAP);
    	}
    
    	return TRUE;
    }
    Got Error: Error C2712: Cannot use __try in functions that require object unwinding
    I Use: Yes (/EHsc)

  2. #2
    Hyperactive Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    379

    Re: Try Function Error C2712

    You can't use __try(...) with the /EHSc option together with objects that require unwinding. See https://msdn.microsoft.com/en-us/library/xwtb73ad.aspx for further info and possible work-arounds.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 15.3.4

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2017
    Posts
    7

    Re: Try Function Error C2712

    yes i had already found and fix this issue from project propertise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.