PDA

View Full Version : Client::GetAugmentID


demonstar55
05-07-2009, 01:54 AM
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

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

// 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


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
newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");

below it add

newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$");

this will be line 3725


now for the check_hasitem.pl

I just defined
my $augid1;

and above each if statment add
$augid1=$client->GetAugmentIDAt($slot1);

and change the if to
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/viewtopic.php?p=32013#32013

demonstar55
05-08-2009, 01:59 PM
so I decided to change this up a little to make it work less stupidly :D
the line numbers are still based on what I previously said

zone/client.h

line 619
uint32 GetAugmentIDAt(sint16 slot_id, uint8 augslot);

zone/inventory.cpp

lines 232-233

// 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

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
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
for($i=0; $i<5; $i++) {
$augid1=$client->GetAugmentIDAt($slot1, $i);
if($augid1==$itmchk) {
return 1;
}
}

cavedude
05-09-2009, 05:50 PM
Would you mind creating a unified diff of the current version of your code?

demonstar55
05-09-2009, 07:00 PM
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, "$$$");


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)


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);

cavedude
05-10-2009, 10:18 PM
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.

demonstar55
05-10-2009, 10:37 PM
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

cavedude
05-11-2009, 09:26 PM
This was committed in Rev 499.

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