Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

Unhandled exception error on function loadmonstercard


Kafa

Question

Hey guys, im currently trying to code some parts of monster card (just the loading part of .txt and some functions, later i will pay a developer to do the rest)

but i'm getting a unhandled exception error i attached the proces to visual studio after the login it crashs and the error is "unhandled exception ..."

 

here is the function

 

bool CPythonPlayer::LoadMonsterCard(const char* c_szFileName)
{
	const VOID* pvData;
	CMappedFile kFile;
	if (!CEterPackManager::Instance().Get(kFile, c_szFileName, &pvData))
		return false;

	CMemoryTextFileLoader kTextFileLoader;
	kTextFileLoader.Bind(kFile.Size(), pvData);

	CTokenVector kTokenVector;
	for (DWORD i = 0; i < kTextFileLoader.GetLineCount(); ++i)
	{
		if (!kTextFileLoader.SplitLineByTab(i, &kTokenVector))
			continue;

		int pkMap2, pkMap3 = 0;

		int pkGroup = std::stoi(kTokenVector[MONSTER_CARD_GROUP]);
		int pkIndex = std::stoi(kTokenVector[MONSTER_CARD_INDEX]);
		int pkVnum = std::stoi(kTokenVector[MONSTER_CARD_VNUM]);
		int pkType = std::stoi(kTokenVector[MONSTER_CARD_TYPE]);
		int pkMap1 = std::stoi(kTokenVector[MONSTER_CARD_MAP1]);
		pkMap2 = std::stoi(kTokenVector[MONSTER_CARD_MAP2]);
		pkMap3 = std::stoi(kTokenVector[MONSTER_CARD_MAP3]);

		TMonsterCardTable * pTable = new TMonsterCardTable;
		pTable->pkGroup = pkGroup;
		pTable->pkIndex = pkIndex;
		pTable->pkVnum = pkVnum;
		pTable->pkType = pkType;
		pTable->pkMap1 = pkMap1;
		pTable->pkMap2 = pkMap2;
		pTable->pkMap3 = pkMap3;
		m_MonsterCardDataMap.insert(TMonsterCardTableDataMap::value_type(pkIndex, pTable));
		if (pTable->pkType == 0) m_iMonsterCardDataSoloMax++;
		if (pTable->pkType == 1) m_iMonsterCardDataPartyMax++;
	}

	if (m_MonsterCardDataMap.size() > 0)
		SetLoadMonsterCard(true);
	else
		SetLoadMonsterCard(false);
}

 

the result of attaching the process is this line: int pkGroup = std::stoi(kTokenVector[MONSTER_CARD_GROUP]);

 

Can someone help me? unfortunatly i do not understand anything about coding i just copy & paste & use my brain :(

@WeedHex @VegaS™ @Nirray

 

 

€dit: problem solved with the solution of vegas, thank you!! 

Edited by Kafa (see edit history)
Link to post

1 answer to this question

Recommended Posts

  • 0

Search for:

		if (!kTextFileLoader.SplitLineByTab(i, &kTokenVector))
			continue;

Add after:

		if (kTokenVector.size() != MONSTER_CARD_MAX_NUM)
		{
			Tracef("CPythonPlayer::LoadMonsterCard(%s) - Strange Token Count [Line:%d / TokenCount:%d]\n", c_szFileName, i, kTokenVector.size());
			continue;
		}
		
		for (auto & token : kTokenVector)
			token.erase(std::remove_if(token.begin(), token.end(), isspace), token.end());

 

Search for:

		int pkGroup = std::stoi(kTokenVector[MONSTER_CARD_GROUP]);
		int pkIndex = std::stoi(kTokenVector[MONSTER_CARD_INDEX]);
		int pkVnum = std::stoi(kTokenVector[MONSTER_CARD_VNUM]);
		int pkType = std::stoi(kTokenVector[MONSTER_CARD_TYPE]);
		int pkMap1 = std::stoi(kTokenVector[MONSTER_CARD_MAP1]);
		pkMap2 = std::stoi(kTokenVector[MONSTER_CARD_MAP2]);
		pkMap3 = std::stoi(kTokenVector[MONSTER_CARD_MAP3]);

Replace with:

Hidden Content

    		int pkGroup = std::stoi(kTokenVector[MONSTER_CARD_GROUP].c_str());
    		int pkIndex = std::stoi(kTokenVector[MONSTER_CARD_INDEX].c_str());
    		int pkVnum = std::stoi(kTokenVector[MONSTER_CARD_VNUM].c_str());
    		int pkType = std::stoi(kTokenVector[MONSTER_CARD_TYPE].c_str());
    		int pkMap1 = std::stoi(kTokenVector[MONSTER_CARD_MAP1].c_str());
    		int pkMap2 = std::stoi(kTokenVector[MONSTER_CARD_MAP2].c_str());
    		int pkMap3 = std::stoi(kTokenVector[MONSTER_CARD_MAP3].c_str());

And change # to ## from .txt file or delete them.

Edited by VegaS™ (see edit history)
  • Love 2
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.