| Akkadius | 
			06-24-2011 02:13 AM | 
		 
		 
		 
		
			COMMITTED: Task Objects to Client   
		
		
		The whole reason why I wanted to export these objects is so that they can be manipulated under the entity_list perl objects. The reason for this is so that you can 'imitate' shared task updates by sending out updates to Group, Guild, Raid, or whatever criteria you want to sort out through the entity list.  
Here is the .diff as well as the simple Perl script I used to test these objects with (Verified and working):
 
$client->UpdateTaskActivity(TaskID, Activity, Count); 
$client->AssignTask(TaskID, NPCID); 
$client->FailTask(TaskID); 
$client->IsTaskCompleted(TaskID); 
$client->IsTaskActive(TaskID); 
$client->IsTaskActivityActive(TaskID, ActivityID); 
$client->IsTaskActivityCompleted(TaskID, ActivityID);
 
	Code: 
	
 Index: EQEmuServer/zone/perl_client.cpp 
=================================================================== 
--- EQEmuServer/zone/perl_client.cpp        (revision 1949) 
+++ EQEmuServer/zone/perl_client.cpp        (working copy) 
@@ -4870,6 +4870,191 @@ 
         XSRETURN(1); 
 } 
  
+XS(XS_Client_UpdateTaskActivity); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_UpdateTaskActivity) 
+{ 
+        dXSARGS; 
+        if (items != 4) 
+                Perl_croak(aTHX_ "Usage: Client::UpdateTaskActivity(THIS, task, activity, count)"); 
+        { 
+                Client *        THIS; 
+                int                task = (sint32)SvIV(ST(1)); 
+                int                activity = (sint32)SvIV(ST(2)); 
+                int                count = (int32)SvUV(ST(3)); 
+ 
+                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."); 
+ 
+                THIS->UpdateTaskActivity(task, activity, count); 
+        } 
+        XSRETURN_EMPTY; 
+} 
+ 
+XS(XS_Client_AssignTask); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_AssignTask) 
+{ 
+        dXSARGS; 
+        if (items != 3) 
+                Perl_croak(aTHX_ "Usage: Client::AssignTask(THIS, TaskID, NPCID)"); 
+        { 
+                Client *        THIS; 
+                int                TaskID = (sint32)SvIV(ST(1)); 
+                int                NPCID = (sint32)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."); 
+ 
+                THIS->AssignTask(TaskID, NPCID); 
+        } 
+        XSRETURN_EMPTY; 
+} 
+ 
+XS(XS_Client_FailTask); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_FailTask) 
+{ 
+        dXSARGS; 
+        if (items != 2) 
+                Perl_croak(aTHX_ "Usage: Client::FailTask(THIS, TaskID)"); 
+        { 
+                Client *        THIS; 
+                int                TaskID = (sint32)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."); 
+ 
+                THIS->FailTask(TaskID); 
+        } 
+        XSRETURN_EMPTY; 
+} 
+ 
+XS(XS_Client_IsTaskCompleted); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_IsTaskCompleted) 
+{ 
+        dXSARGS; 
+        if (items != 2) 
+                Perl_croak(aTHX_ "Usage: Client::IsTaskCompleted(THIS, TaskID)"); 
+        { 
+                Client *                THIS; 
+                bool                RETVAL; 
+                int                TaskID = (sint32)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->IsTaskCompleted(TaskID); 
+                ST(0) = boolSV(RETVAL); 
+                sv_2mortal(ST(0)); 
+        } 
+        XSRETURN(1); 
+} 
+ 
+XS(XS_Client_IsTaskActive); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_IsTaskActive) 
+{ 
+        dXSARGS; 
+        if (items != 2) 
+                Perl_croak(aTHX_ "Usage: Client::IsTaskActive(THIS, TaskID)"); 
+        { 
+                Client *                THIS; 
+                bool                RETVAL; 
+                int                TaskID = (sint32)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->IsTaskActive(TaskID); 
+                ST(0) = boolSV(RETVAL); 
+                sv_2mortal(ST(0)); 
+        } 
+        XSRETURN(1); 
+} 
+ 
+XS(XS_Client_IsTaskActivityActive); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_IsTaskActivityActive) 
+{ 
+        dXSARGS; 
+        if (items != 3) 
+                Perl_croak(aTHX_ "Usage: Client::IsTaskActivityActive(THIS, TaskID, ActivityID)"); 
+        { 
+                Client *                THIS; 
+                bool                RETVAL; 
+                int                TaskID = (sint32)SvIV(ST(1)); 
+                int                ActivityID = (sint32)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->IsTaskActivityActive(TaskID, ActivityID); 
+                ST(0) = boolSV(RETVAL); 
+                sv_2mortal(ST(0)); 
+        } 
+        XSRETURN(1); 
+} 
+ 
+XS(XS_Client_IsTaskActivityCompleted); /* prototype to pass -Wmissing-prototypes */ 
+XS(XS_Client_IsTaskActivityCompleted) 
+{ 
+        dXSARGS; 
+        if (items != 3) 
+                Perl_croak(aTHX_ "Usage: Client::IsTaskActivityCompleted(THIS, TaskID, ActivityID)"); 
+        { 
+                Client *                THIS; 
+                bool                RETVAL; 
+                int                TaskID = (sint32)SvIV(ST(1)); 
+                int                ActivityID = (sint32)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->IsTaskActivityCompleted(TaskID, ActivityID); 
+                ST(0) = boolSV(RETVAL); 
+                sv_2mortal(ST(0)); 
+        } 
+        XSRETURN(1); 
+} 
+ 
 #ifdef __cplusplus 
 extern "C" 
 #endif 
@@ -5068,6 +5253,13 @@ 
                 newXSproto(strcpy(buf, "ClearCompassMark"), XS_Client_ClearCompassMark, file, "$"); 
                 newXSproto(strcpy(buf, "GetFreeSpellBookSlot"), XS_Client_GetFreeSpellBookSlot, file, "$;$"); 
                 newXSproto(strcpy(buf, "GetSpellBookSlotBySpellID"), XS_Client_GetSpellBookSlotBySpellID, file, "$$"); 
+                newXSproto(strcpy(buf, "UpdateTaskActivity"), XS_Client_UpdateTaskActivity, file, "$$$$"); 
+                newXSproto(strcpy(buf, "AssignTask"), XS_Client_AssignTask, file, "$$$"); 
+                newXSproto(strcpy(buf, "FailTask"), XS_Client_FailTask, file, "$$"); 
+                newXSproto(strcpy(buf, "IsTaskCompleted"), XS_Client_IsTaskCompleted, file, "$$"); 
+                newXSproto(strcpy(buf, "IsTaskActive"), XS_Client_IsTaskActive, file, "$$"); 
+                newXSproto(strcpy(buf, "IsTaskActivityActive"), XS_Client_IsTaskActivityActive, file, "$$$"); 
+                newXSproto(strcpy(buf, "IsTaskActivityCompleted"), XS_Client_IsTaskActivityCompleted, file, "$$$"); 
         XSRETURN_YES; 
 } 
 Perl Script, using Task ID 140
 
	Code: 
	
 sub EVENT_SAY{         
        if($text=~/update/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){  
                        $ent->UpdateTaskActivity(140, 0, 1); 
                } 
        } 
        if($text=~/assign/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        $ent->AssignTask(140, $npc->GetID()); 
                } 
        } 
        if($text=~/failtask/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        $ent->FailTask(140); 
                } 
        } 
        if($text=~/taskcomplete/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        if($ent->IsTaskCompleted(140)){ 
                                $ent->Message(15, "Task Complete"); 
                        } 
                        else{ 
                                $ent->Message(15, "Task not complete"); 
                        } 
                } 
        } 
        if($text=~/taskactive/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        if($ent->IsTaskActive(140)){ 
                                $ent->Message(15, "Task Active"); 
                        } 
                        else{ 
                                $ent->Message(15, "Task not active"); 
                        } 
                } 
        } 
        if($text=~/taskactivityactive/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        if($ent->IsTaskActivityActive(140, 0)){ 
                                $ent->Message(15, "Task activity Active"); 
                        } 
                        else{ 
                                $ent->Message(15, "Task activity not active"); 
                        } 
                } 
        } 
        if($text=~/taskactivitycomplete/i){ 
                my @clients = $entity_list->GetClientList(); 
                foreach $ent (@clients){ 
                        if($ent->IsTaskActive(140, 0)){ 
                                $ent->Message(15, "Task activity complete"); 
                        } 
                        else{ 
                                $ent->Message(15, "Task activity not complete"); 
                        } 
                } 
        } 
} 
  
	 |