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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2009, 01:54 AM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default Client::GetAugmentID

So on PEQ at least, some keyed doors are handled by perl (no idea if AX does the same) but mainly this applies to VP, I know a few people used their augments on PEQ and were sad they couldn't get back into VP, so I decided to look into it and try to fix check_hasitem.pl to check for the augment, which I realized with our current set of tools we can't do, so I had to do crap etc etc

this is still not a good idea to use it as an augment (what if you die!)

All of these files are from rev478

zone/client.h
line 618 is the define for GetItemIDAt so I just added this below it at line 619

Code:
uint32	GetAugmentIDAt(sint16 slot_id);
zone/inventory.cpp
right below the Client::GetItemIDAt function I added the new function

GetItemIDAt is lines 214-221

below it add

Code:
// Returns an augment's ID that's in an item (returns INVALID_ID if not found)
uint32 Client::GetAugmentIDAt(sint16 slot_id) {
	const ItemInst* inst = m_inv[slot_id];
	sint16 i;
	if (inst)
		for (i = 0; i < 5; i++)
			if (inst->GetAugmentItemID(i))
				return inst->GetAugmentItemID(i);

	// None found
	return INVALID_ID;
}
These will become lines 223-234

Only problem I can see with this is that it checks through all the augslots, but should only return the first, might want to change it to accept slot_id, and augslot_id and then would just have the perl script change each slot

That should take care of the functions, now for the perl crap

zone/perl_client.cpp

on line 2633 it starts the XS(XS_Client_GetItemIDAt) function (lines 2633-2657)

below it I added

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

		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);
		XSprePUSH; PUSHu((UV)RETVAL);
	}
	XSRETURN(1);
}
becoming lines 2659-2684

the following lines are what they should be at after adding the above
on line 3724 is the GetItemIDAt thing
Code:
newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");
below it add

Code:
newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$");
this will be line 3725


now for the check_hasitem.pl

I just defined
Code:
my $augid1;
and above each if statment add
Code:
$augid1=$client->GetAugmentIDAt($slot1);
and change the if to
Code:
if($itemid1==$itmchk || $augid1==$itmchk)
I'll post a the full quest file on PEQ since I believe it's their file or something :P

http://www.projecteq.net/phpBB2/view...?p=32013#32013
Reply With Quote
  #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
  #3  
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
  #4  
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
  #5  
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
  #6  
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
  #7  
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


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 09:30 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3