Routine for mounting equipment….?
-
I need some help on this issue.
I just want to track what equipment is mounted and unmounted on a ship. I figured out in the ServerImpl Routines there is this “ReqEquipment” function with this signature:
void __stdcall ReqEquipment (class EquipDescList const &edl, unsigned int iClientID)
I assume the current equipment that is mounted or unmounted is listed in the EquipDescList address space. However i tried to figure out how i could be able to track back what equipment that is. Without success so far.
Looking through the code there is also a few times the EquipDescList from the Players data taken… e. g.:
char *szClassPtr; memcpy(&szClassPtr, &Players, 4); szClassPtr += 0x418 * (iClientID - 1); EquipDescList *edlList = (EquipDescList*)szClassPtr + 0x328;
However the address i get there is quite another one - probably all the equipment that is on the ship and not just only one.
Additional to this i found this here:char *szClassPtr; memcpy(&szClassPtr, &Players, 4); szClassPtr += 0x418 * (iClientID - 1); EQ_ITEM *eqLst; memcpy(&eqLst, szClassPtr + 0x27C, 4);
This lists the equipment also from the Players data. But if i take the address from EquipDescList from the ReqEquipment call and type cast it to EQ_ITEM i don’t get the proper results. So i am asking myself how could i track what item is mounted/unmounted. Or is there another routine that could be used where i have access directly to the ArchID of that item?
Any hints and help would be appreciated. Thanks in advance.
-
EquipDescList is std::list <equipdesc>(stored at +0x278, for VC6); EQ_ITEM is the “raw” equivalent (where the head pointer is at +0x27C). As it seems you’re using FLHook, just use HkEnumCargo as Crazy suggests, which runs through the list at +0x27C and gives it to you as another std::list (for your compiler). To distinguish between equipment and commodity, use arch_is_combinable (true is commodity, false is equipment). So I guess you want something like:
list <cargo_info>lstCargo; int iHold; HkEnumCargo(wscCharname, lstCargo, iHold); foreach(lstCargo, CARGO_INFO, it) { if (it->bMounted) { // Equipment is mounted } else if (!arch_is_combinable(it->bArchID)) { // Equipment is unmounted } // else it's a commodity (or bat/bot) }</cargo_info> ```</equipdesc>
-
Thanks so far. HkEnumCargo could be used indeed.
But i wasn’t that accurate in my first post. When i mount/unmount an item to my ship the routine ReqEquipment is called with that EquipDescList reference. I need exactly that item that is currently mount/unmount. And i thought its somewhere in EquipDescList reference contained.Surely i could run through all items and do what i want to do checking the mount flag in the cargo list. But i thought there is another way. For something this EquipDescList that points me directly to that item i am working on currently
Hence my trials with that typecasting to the EQ_ITEM. I need the archID to compare it with something special tho…
If there are no other ways then HkEnumCargo is the way i need to go then.But just for interest - the EquipDescList is defined as class, with some subroutines but no member variables. How is it possible to track what exactly is in this EquipDescList then? For the subroutines i need an archId to find the equipment - but i need the other way round (where i have a routine as well - but not with that reference from the ReqEquipment call)…
-
Huor wrote:
But just for interest - the EquipDescList is defined as class, with some subroutines but no member variables. How is it possible to track what exactly is in this EquipDescList then? For the subroutines i need an archId to find the equipment - but i need the other way round (where i have a routine as well - but not with that reference from the ReqEquipment call)…
From the SDK:
public: // std::list <equipdesc>equip; // FIXME: std::list is not compatible with VC9 libs EquipDescListItem *pIter; EquipDescListItem *pFirst; UINT iCount;</equipdesc>
Anyways, IIRC the reqequipment includes all the equipment on a ship rather than only the “changed” equipment, so as Crazy and adoxa said, simply use HkEnumCargo for simplicity after the server call.
-
If you’re sure that there isn’t another function called when mounting/unmounting (haven’t checked) you could simply save a list with mounted and unmounted equip when a player is entering a base.
Compare that list with a new one created when ReqEquipment is called and you should be able to find out which one is missing/new. -
At least thats the first function that my breakpoints interrupt the code from its execution - so i thought its well used as first
If the EquipDescList reference from the function call would point to the item/equipment that is currently in use then it could save needless traversing through the cargo. W0dka pointed out to use the iterators of EquipDescListItem - but the question would be if the item that is currently in use can be retrieved by it wiithout running through all objects.
I will see if i can find something out with these iterators. For now i think traversing the cargo hold is a reasonable way to get what i am looking for - although if its a workaround^^
Thanks so far all that left a hint here.