Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
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
  #2  
Old 05-09-2009, 05:50 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Would you mind creating a unified diff of the current version of your code?
Reply With Quote
  #3  
Old 05-09-2009, 07:00 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

Code:
Index: EQEmuServer/zone/perl_client.cpp
===================================================================
--- EQEmuServer/zone/perl_client.cpp	(revision 491)
+++ EQEmuServer/zone/perl_client.cpp	(working copy)
@@ -2656,6 +2656,34 @@
 	XSRETURN(1);
 }
 
+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);
+}
+
 XS(XS_Client_DeleteItemInInventory); /* prototype to pass -Wmissing-prototypes */
 XS(XS_Client_DeleteItemInInventory)
 {
@@ -3695,6 +3723,7 @@
 		newXSproto(strcpy(buf, "SetMaterial"), XS_Client_SetMaterial, file, "$$$");
 		newXSproto(strcpy(buf, "Undye"), XS_Client_Undye, file, "$");
 		newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");
+		newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$$");
 		newXSproto(strcpy(buf, "DeleteItemInInventory"), XS_Client_DeleteItemInInventory, file, "$$;$$");
 		newXSproto(strcpy(buf, "SummonItem"), XS_Client_SummonItem, file, "$$;$");
 		newXSproto(strcpy(buf, "SetStats"), XS_Client_SetStats, file, "$$$");
Code:
Index: EQEmuServer/zone/inventory.cpp
===================================================================
--- EQEmuServer/zone/inventory.cpp	(revision 491)
+++ EQEmuServer/zone/inventory.cpp	(working copy)
@@ -218,6 +218,18 @@
 	return INVALID_ID;
 }
 
+// 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;
+}
+
 // Remove item from inventory
 void Client::DeleteItemInInventory(sint16 slot_id, sint8 quantity, bool client_update) {
 	#if (EQDEBUG >= 5)
Code:
Index: EQEmuServer/zone/client.h
===================================================================
--- EQEmuServer/zone/client.h	(revision 491)
+++ EQEmuServer/zone/client.h	(working copy)
@@ -616,6 +616,7 @@
 	void	SetMaterial(sint16 slot_id, uint32 item_id);
 	void	Undye();
 	uint32	GetItemIDAt(sint16 slot_id);
+	uint32	GetAugmentIDAt(sint16 slot_id, uint8 augslot);
 	bool	PutItemInInventory(sint16 slot_id, const ItemInst& inst, bool client_update = false);
 	bool	PushItemOnCursor(const ItemInst& inst, bool client_update = false);
 	void	DeleteItemInInventory(sint16 slot_id, sint8 quantity = 0, bool client_update = false);
Reply With Quote
  #4  
Old 05-10-2009, 10:18 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Excellent, this and your updated plugin will be live on the Grand Creation with the reboot. If testing there goes well, I'll commit to SVN.
Reply With Quote
  #5  
Old 05-10-2009, 10:37 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

my only concern with it would be an increased server load since I did double the complexity for each basically :P

at least the function should stay, gives people more options, whether or not the plugin is used, oh well, thought I'd give it a try at fixing it :P

and note, I would still not recommend using the VP aug as an aug until we get the keyring working correctly for all doors
Reply With Quote
  #6  
Old 05-11-2009, 09:26 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

This was committed in Rev 499.

The server load is negligible since this is only being called by the check_hasitem Perl plugin.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:46 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3