Helpc++ help

Posts 1–9 of 9 · Page 1 of 1
c++ help
hello need some help with fixing this c++ app it parses the values from a txt file that has bytes and parses into database values I need the app to be alterd so it parses the new bytes ,The new bytes have the 00 bytes removed this is the old bytes ive spaced the-----00----- to show which ones need to be ignored or added to the new bytes or some tool that could go through the big txt file and add the 00 the code to the app is at bottom im not sure where it finds the 00 to skip in the c++ code

old bytes
00 07------00-------00 0A 06 50-------00--------00 0B 16 82 01-------00-------14 0C 16-------00--------6A 00--------00 00---------00 15 0C 18 --------00---------00 16 0C 17--------00-------00 19 0C 1A-------00--------- 00 1C 09 B8 00


new bytes which need them 00 adding or skiping in the app code below
00 07 00 0A 06 50 00 0B 16 82 01 14 0C 16 6A 00 00 15 0C 18 00 16 0C 17 00 19 0C 1A 00 1C 09 B8 00

if(!item) return true;

SkipValue(8);

size=0;

for(int i=10;i<30 && !size;i++)
{
for(int z=0;z<2 && !size;z++)
{
char srh[6];
_snprintf(srh, 6, "%02X%04X",z,i);
stringstream ss;
for(int d=0;d<6;d++)
ss << srh[d];

size = GetSize(ss.str());
}
}

if(!size)
return true;

size-=4;

SkipValue(size);

int ItemCount = GetInt(1);

if(!ItemCount)
return true;

//cout << "<Items " << ItemCount << ">";

for(int i=0;i<ItemCount;i++)
{
int effectcount = GetInt(1);

int slot = GetInt(2);
int modelid = GetInt(2);

if(!slot || !modelid)
continue;

if(slot==10 || slot==11)
{
QueryResult * Quer = WorldDatabase.Query("SELECT type FROM items WHERE modelid=%u LIMIT 0,1",modelid);
if(Quer)
{
uint32 type = Quer->Fetch()[0].GetUInt32();

if(type == 15 || type == 9 || type ==7 )
WorldDatabase.WaitExecute("UPDATE creature_proto SET rangedattack='1' WHERE entry=%u",m_entry);
}
delete Quer;
}

int m_effect = 0;

for(int z=0;z<effectcount;z++)
m_effect = GetInt(4);

WorldDatabase.WaitExecute("INSERT INTO creature_items (entry,slot_item,model_item,effect) VALUES ('%u','%u','%u','%u')",m_entry,slot,modelid,m_effe ct);
}

return true;
I can't read what are you saying ?
Indentation is key.

Code:
if(!item) return true;

SkipValue(8);

size = 0;

for(int i=10;i<30 && !size;i++)
{
	for(int z=0;z<2 && !size;z++)
	{
		char srh[6];
		_snprintf(srh, 6, "%02X%04X",z,i);
		stringstream ss;
		for(int d=0;d<6;d++)
		ss << srh[d];

		size = GetSize(ss.str());
	}
}

if(!size)
return true;

size-=4;

SkipValue( size);

int ItemCount = GetInt(1);

if(!ItemCount)
return true;

//cout << "<Items " << ItemCount << ">";

for(int i=0;i<ItemCount;i++)
{
	int effectcount = GetInt(1);

	int slot = GetInt(2);
	int modelid = GetInt(2);

	if(!slot || !modelid)
	continue;

	if(slot==10 || slot==11)
	{
		QueryResult * Quer = WorldDatabase.Query("SELECT type FROM items WHERE modelid=%u LIMIT 0,1",modelid);
		if(Quer)
		{
			uint32 type = Quer->Fetch()[0].GetUInt32();

			if(type == 15 || type == 9 || type ==7 )
			WorldDatabase.WaitExecute("UPDATE creature_proto SET rangedattack='1' WHERE entry=%u",m_entry);
		}
		delete Quer;
	}

	int m_effect = 0;

	for(int z=0;z<effectcount;z++)
	m_effect = GetInt(4);

	WorldDatabase.WaitExecute("INSERT INTO creature_items (entry,slot_item,model_item,effect) VALUES ('%u','%u','%u','%u')",m_entry,slot,modelid,m_effe ct);
}

return true;
eh? why copy and paste the same code ok I see
Code:
if(!item) return true;

 SkipValue(8);

 size=0;

 for(int i=10;i<30 && !size;i++)
 {
 for(int z=0;z<2 && !size;z++)
 {
 char srh[6];
 _snprintf(srh, 6, "%02X%04X",z,i);
 stringstream ss;
 for(int d=0;d<6;d++)
 ss << srh[d];

 size = GetSize(ss.str());
 }
 }

 if(!size) 
 return true;

 size-=4;

 SkipValue(size);

 int ItemCount = GetInt(1);

 if(!ItemCount) 
 return true;

 //cout << "<Items " << ItemCount << ">";

 for(int i=0;i<ItemCount;i++)
 {
 int effectcount = GetInt(1);

 int slot = GetInt(2);
 int modelid = GetInt(2);

 if(!slot || !modelid)
 continue;

 if(slot==10 || slot==11)
 {
 QueryResult * Quer = WorldDatabase.Query("SELECT type FROM items WHERE modelid=%u LIMIT 0,1",modelid);
 if(Quer)
 {
 uint32 type = Quer->Fetch()[0].GetUInt32();

 if(type == 15 || type == 9 || type ==7 )
 WorldDatabase.WaitExecute("UPDATE creature_proto SET rangedattack='1' WHERE entry=%u",m_entry);
 }
 delete Quer;
 }

 int m_effect = 0;

 for(int z=0;z<effectcount;z++)
 m_effect = GetInt(4);

 WorldDatabase.WaitExecute("INSERT INTO creature_items (entry,slot_item,model_item,effect) VALUES ('%u','%u','%u','%u')",m_entry,slot,modelid,m_effe ct);
 }

 return true;
Quote Originally Posted by leo2222 View Post
eh? why copy and paste the same code again and not add the fix ?? please fix the error because I don't know

and what is Indentation is key. ???? I not understand were this is
because you didnt post it in code tags so it was impossible to read. you should know what indentation is dude
ok now you can the code why still no help ?
you are creating an app for what ?
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us