View Single Post
  #2  
Old 05-08-2009, 01:59 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

so I decided to change this up a little to make it work less stupidly
the line numbers are still based on what I previously said

zone/client.h

line 619
Code:
uint32	GetAugmentIDAt(sint16 slot_id, uint8 augslot);
zone/inventory.cpp

lines 232-233

Code:
// Returns an augment's ID that's in an item (returns INVALID_ID if not found)
// Pass in the slot ID of the item and which augslot you want to check (0-4)
uint32 Client::GetAugmentIDAt(sint16 slot_id, uint8 augslot) {
	const ItemInst* inst = m_inv[slot_id];
	if (inst)
		if (inst->GetAugmentItemID(augslot))
			return inst->GetAugmentItemID(augslot);

	// None found
	return INVALID_ID;
}
zone/perl_client.cpp

lines 2659-2685

Code:
XS(XS_Client_GetAugmentIDAt); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetAugmentIDAt)
{
	dXSARGS;
	if (items != 3)
		Perl_croak(aTHX_ "Usage: Client::GetAugmentIDAt(THIS, slot_id, augslot)");
	{
		Client *		THIS;
		uint32		RETVAL;
		dXSTARG;
		sint16		slot_id = (sint16)SvIV(ST(1));
		sint16		augslot = (uint8)SvIV(ST(2));

		if (sv_derived_from(ST(0), "Client")) {
			IV tmp = SvIV((SV*)SvRV(ST(0)));
			THIS = INT2PTR(Client *,tmp);
		}
		else
			Perl_croak(aTHX_ "THIS is not of type Client");
		if(THIS == NULL)
			Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");

		RETVAL = THIS->GetAugmentIDAt(slot_id, augslot);
		XSprePUSH; PUSHu((UV)RETVAL);
	}
	XSRETURN(1);
}
lines 3726
Code:
newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$$");
now I'm not 100% sure if the stuff in perl_client.cpp are correct, but it seems to work

in a quest file if you wanted to check every augslot for an item you'd just run something like this
Code:
		for($i=0; $i<5; $i++) {
			$augid1=$client->GetAugmentIDAt($slot1, $i);
			if($augid1==$itmchk) {
				return 1;
			}
		}
Reply With Quote