That was rather embarrassing. See if you can find the error:
int16 StatBaseAddr = 0x298;
for ( x = 0; x < 3; x++ )
{
SceneFile[x * 2] = (int16)ModelIDs[x] && 0xFF;
SceneFile[x * 2 + 1] = ((int16)ModelIDs[x] && 0xFF00) >> 8;
StatBaseAddr += x * 184;
Array.Copy( NewStats[x], 0, SceneFile, StatBaseAddr, 184 );
}
If you see it, good for you. Don't feel bad if you don't get it though. I don't think there's a C++ equiv for Array.Copy( array, int, array, int, int) so I'll just tell you that it copies a certain number of values from one array into another.
See it yet? Follow StatBaseAddr for each loop:
x = 0: StatBaseAddr = 0x298 //first enemy's data
x = 1: StatBaseAddr = 0x350 //second enemy's data
x = 2: StatBaseAddr = 0x4C0 //beginning of attack data!!
So technically, the third enemy's data was getting saved, but in the wrong place. :( I changed that StatBaseAddr += x * 184; to StatBaseAddr += 184 and moved it to below the Array.Copy line and it saves just like it should now. Problem solved. :D
Thursday, June 9, 2011
Subscribe to:
Post Comments (Atom)
Does that mean that my attempts at saving the third enemy with alpha 3 corrupted my attack data ? Now I'm worried.
ReplyDelete-ArmorVil
It is possible. I hope you have backups. :(
ReplyDeleteActually, no. It's not possible because the last thing PrC does is write the attack data back to the scenefile after everything else is written. So the attack data itself won't be corrupted. All those changes will just be completely lost.
ReplyDeleteAh great, thank you, that's what I thought :)
ReplyDelete-Armorvil
std::copy do the same as Array.Copy( array, int, array, int, int)
ReplyDelete