Ok, I think I got the conversion functions written properly, but it might not hurt to have them double-checked:
Code:
// Converts Titanium Slot IDs to SoF Slot IDs for use in Encodes
static inline int32 TitaniumToSoFSlot(int32 TitaniumSlot) {
int32 SoFSlot = 0;
if(TitaniumSlot >= 21 && TitaniumSlot <= 50) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
SoFSlot = TitaniumSlot + 1;
}
else if(TitaniumSlot >= 251 && TitaniumSlot <= 340) // Bag Slots for Normal Inventory and Cursor
{
SoFSlot = TitaniumSlot + 11;
}
else if(TitaniumSlot >= 2031 && TitaniumSlot <= 2270) // Bank Bag Slots
{
SoFSlot = TitaniumSlot + 1;
}
else if(TitaniumSlot >= 2531 && TitaniumSlot <= 2550) // Shared Bank Bag Slots
{
SoFSlot = TitaniumSlot + 1;
}
else if(TitaniumSlot == 9999) //Unused slot ID to give a place to save Power Slot
{
SoFSlot = 21;
}
else
{
SoFSlot = TitaniumSlot;
}
return SoFSlot;
}
// Converts Sof Slot IDs to Titanium Slot IDs for use in Decodes
static inline int32 SoFToTitaniumSlot(int32 SoFSlot) {
int32 TitaniumSlot = 0;
if(SoFSlot >= 22 && SoFSlot <= 51) // Cursor/Ammo/Power Source and Normal Inventory Slots
{
TitaniumSlot = SoFSlot - 1;
}
else if(SoFSlot >= 262 && SoFSlot <= 351) // Bag Slots for Normal Inventory and Cursor
{
TitaniumSlot = SoFSlot - 11;
}
else if(SoFSlot >= 2032 && SoFSlot <= 2271) // Bank Bag Slots
{
TitaniumSlot = SoFSlot - 1;
}
else if(SoFSlot >= 2532 && SoFSlot <= 2551) // Shared Bank Bag Slots
{
TitaniumSlot = SoFSlot - 1;
}
else if(SoFSlot == 21)
{
TitaniumSlot = 9999; //Unused slot ID to give a place to save Power Slot
}
else
{
TitaniumSlot = SoFSlot;
}
return TitaniumSlot;
}
When working on that, I noticed that there were a couple of issues with the current slot move related stuff in the encodes and decodes that could cause items to be lost if stored in certain slots. Right now, I think those would include:
1. The last slot in a 10 slot bag that is on your cursor.
2. The last slot in the last bag of your bank in SoF.
3. The last slot in the last bag in you shared bank.
This conversion should fix all of that once it is working. Hopefully it will also make it easy to for us to add in any more conversions for slots without having to go through each encode/decode and adjusting them 1 by 1. I will try this out later and see how well it works. Seems like it should be ok.
I am not completely sure what uses slot 31 to 50 in Titanium, but maybe that is how stacked items are stored on the cursor when being moved. If so, we might need to increase that from 50 to at least 130, so it could account for stacks up to 100.