Okay. I am going to teach all of you how to increase the MAX_ITEM_INDEX to a number greater than 65535.
If you have IDA Pro, this is very easy to do -- even if you do not have a working knowledge of ASM.
Place the 'gs' into x86 Ida and let it disassemble, this may take some time.
We are looking for two functions:
Code:
static inline void SetCashItem(size_t citem_id)
{
ASSERT(citem_id < MAX_ITEM_INDEX);
_cash_item_flag[citem_id] = 1;
}
static inline bool IsCashItem(size_t item_id)
{
if(item_id >= MAX_ITEM_INDEX) return false;
return _cash_item_flag[item_id];
}
and lastly the constructor for the item_manager class, which will not be returned in our imm search.
These functions are right on top of one another in the game server.
So... to do this really easily, do as follows:
In the IDA View-A window. Press ALT I ..
Enter 0xFFFE and check the "Final all occurrences" option.
The result will look like:
Click on:
Code:
.text:0820C4E8 _ZN12item_manager11SetCashItemEj cmp dword ptr [ebp+8], 0FFFEh
look at the asm code. where you see:
Code:
cmp dword ptr [ebp+8], 0FFFEh
we need to change this 0xfffeh (655535) to another value. Let's just go as high as we can...
to 99999
place your cursor besides the instruction:
Code:
cmp dword ptr [ebp+8], 0FFFEh
from the Edit menu, select Patch Program -> Change Bytes...
you should see:
Code:
81 7D 08 FE FF 00 00 76 1D 83 EC 04 6A 1E 68 86
we will change this to:
Code:
81 7D 08 9F 86 01 00 76 1D 83 EC 04 6A 1E 68 86
99999 in hex is: 0x1869F[/CODE]
Next we modify....
Code:
.text:0820C522 _ZN12item_manager10IsCashItemEj cmp dword ptr [ebp+8], 0FFFEh
Again you will see:
Code:
81 7D 08 FE FF 00 00 76 09 C7 45 FC 00 00 00 00
and change it to:
81 7D 08 9F 86 01 00 76 09 C7 45 FC 00 00 00 00
After you have made the changes, return to the edit menu -> Patch Program -> Apply Patches to input file. Click "Create backup" just in case.
Now copy the patched 'gs' to your Linux system.
Congratulations .. you can now have items in the server side elements.data that are greater than the default of 65535... as in it will not segfault when loading.
Now, as for why other players cannot see equipment or fashion with an Id above 65535, is exactly the reason stated above.
The value of ItemId in the two packets that need modification are unsigned shorts, which have their limit at 65535... changing to unsigned int is a much bigger job. It is not as simple as changing the two structures in the change to unsigned int .. there are more functions in the 'gs' that require modification.