Jump to content
  • 0

std:string


djmester
Go to solution Solved by Mali61,

Question

Hi!

i try fix one system. so starting debugging :D

so i have one func in cmd_general. client send one word to server. and i try check is correctly.

	char arg1[4096];
	one_argument(argument, arg1, sizeof(arg1));
	
	if (!*arg1)
		return;

	int size_array = sizeof(argument) / sizeof(char);


	
	std::string nume_item(arg1);

	ch->ChatPacket(CHAT_TYPE_INFO, "argumentum: %s , nume_item : %s", argument, nume_item);

spacer.png

so argument or arg1 is correclty but when i pass it on to a string i got wrong characters.. 

What do I do wrong??

gcc8 

Link to post

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

it i use 

ch->ChatPacket(CHAT_TYPE_INFO, "argumentum: %s , nume_item : %s", argument, nume_item.c_str());

server is crash :'D  no crash its my bad xd.. but ye now i see correctly words. but just first 3 character.. 😕

Edited by djmester
Link to post
  • 0

thanks for help its work :) but u have one more question.

i fount why crash my server but i dont know why..

so :

 

itertype(m_map_pkDropItemGroup) it;
	
	for (std::map<DWORD, CDropItemGroup*>::iterator it = m_map_pkDropItemGroup.begin(); it != m_map_pkDropItemGroup.end(); it++)
	{
		
		if (it != m_map_pkDropItemGroup.end())
		{
			
			typeof(it->second->GetVector()) v = it->second->GetVector();
			

			for (DWORD i = 0; i < v.size(); ++i)
			{
				
				TItemTable* Titem = ITEM_MANAGER::instance().GetTable(v[i].dwVnum);
				bool nume = (name_item.length() ? strstr(Titem->szLocaleName, name_item.c_str()) != NULL : true);
				const CMob* pMob = CMobManager::instance().Get(it->first);
				std::string name_monster(pMob->m_table.szLocaleName);
				//ch->ChatPacket(CHAT_TYPE_INFO, "DWORD %d", it->first);
				

when i try get parameters from pMob.m_table i got all time crash . .when i just try wrote out it->first (dword) i got crash.. but if i list all "v[i].dwVnum" i have items .. but i dont know what is problem on pMob and it-first value. .. 😕 

have any ideas? 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • 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.