Thread: Pet Focus
View Single Post
  #5  
Old 02-18-2010, 12:34 AM
iRFNA
Fire Beetle
 
Join Date: Dec 2009
Posts: 23
Default

Well, assuming you start with the current code and want to insert more in this area:

Code:
struct ExtendedProfile_Struct {
	// Pet stuff
	int16				pet_id;
	int16				pet_hp;
	int16				pet_mana;
	SpellBuff_Struct	pet_buffs[BUFF_COUNT];
	int32				pet_items[MAX_MATERIALS];

	>>>here<<<

	char				pet_name[64];
	
	uint32				aa_effects;
	uint32				perAA;		//% of exp going to AAs
};
...then you just need to use a little sql to put some padding in the char profiles in that area. Here's a quick query for that:

Code:
update character_ set extprofile = concat(left(extprofile, length(extprofile) - (64 + 4 + 4)), repeat(char(0), ???), right(extprofile, 64 + 4 + 4));
The (64 + 4 + 4) corresponds to the size of the data under the big bold here marker. Just pull apart the current exp profile, fill it with a buffer of 0x00 characters (I assume 0x00 is preferable?), and put it all back together. So, however much larger you make the pet equipment array, you'll just toss that in ???. Each added int32 is 4 bytes.

From what I can see in the code, it'd be safer to add everything under the current data so that if someone's extprofile isn't updated, it won't try to use faulty data for things like AAs or their pet name. However, it'd be pretty odd and annoying to split up the pet equipment array like that.

Another option would be to update the SetExtendedProfile function in extprofile.cpp to do basically this same thing except with memcpy/memmove and SecureZeroMemory. Maybe on a special case if the length is the same as the old one, reformat its data like that or however you need it, and then do the dump into the player's ExtendedProfile_Struct. Again, I'm assuming it's preferable to fill everything new with 0x00, which I think should be the case?
Reply With Quote