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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #16  
Old 06-25-2012, 05:02 AM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

(Submission write-up in the previous post)

This patch was diff'd against rev. 2153 and affects the following files in ..\trunk\EQEmuServer\zone\:
doors.h
doors.cpp
perlparser.cpp
questmgr.h
questmgr.cpp



<doorsupdate.patch>
Code:
Index: doors.cpp
===================================================================
--- doors.cpp	(revision 2153)
+++ doors.cpp	(working copy)
@@ -31,6 +31,8 @@
 
 #define OPEN_DOOR 0x02
 #define CLOSE_DOOR 0x03
+#define OPEN_INVDOOR 0x03
+#define CLOSE_INVDOOR 0x02
 
 extern EntityList entity_list;
 extern WorldServer worldserver;
@@ -120,9 +122,19 @@
 {
     if(close_timer.Enabled() && close_timer.Check() && IsDoorOpen())
     {
-	triggered=false;
-        close_timer.Disable();
-        SetOpenState(false);
+		if (opentype == 40 || GetTriggerType() == 1)
+		{
+			EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
+			MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
+			md->doorid = door_id;
+			md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
+			entity_list.QueueClients(0, outapp);
+			safe_delete(outapp);
+		}
+
+		triggered=false;
+		close_timer.Disable();
+		SetOpenState(false);
     }
 	return true;
 }
@@ -200,11 +212,11 @@
 		{ // this door is only triggered by an object
 			if(!IsDoorOpen() || (opentype == 58))
 			{
-				md->action = OPEN_DOOR;
+				md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 			}
 			else
 			{
-				md->action = CLOSE_DOOR;
+				md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 			}
 		}
 		else
@@ -221,11 +233,11 @@
 	{	//door not locked
 		if(!IsDoorOpen() || (opentype == 58))
 		{
-			md->action = OPEN_DOOR;
+			md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 		}
 		else
 		{
-			md->action = CLOSE_DOOR;
+			md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 		}
 	}
 	else
@@ -243,6 +255,8 @@
 				strcpy(tmpmsg, "Door is locked by an unknown guild");
 			}
 			sender->Message(4, tmpmsg);
+			// safe_delete(outapp);
+			// /\ possible missing line..all other 'fail' returns seem to have it
 			return;
 		}
 		// a key is required or the door is locked but can be picked or both
@@ -252,11 +266,11 @@
 			sender->Message_StringID(4,DOORS_GM);
 			if(!IsDoorOpen() || (opentype == 58))
 			{
-				md->action = OPEN_DOOR;
+				md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 			}
 			else
 			{
-				md->action = CLOSE_DOOR;
+				md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 			}
 		}
 		else if(playerkey)
@@ -270,11 +284,11 @@
 				sender->Message(4, "You got it open!");
 				if(!IsDoorOpen() || (opentype == 58))
 				{
-					md->action = OPEN_DOOR;
+					md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 				}
 				else
 				{
-					md->action = CLOSE_DOOR;
+					md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 				}
 			}
 		}
@@ -295,11 +309,11 @@
 					{
 						if(!IsDoorOpen())
 						{
-							md->action = OPEN_DOOR;
+							md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 						}
 						else
 						{
-							md->action = CLOSE_DOOR;
+							md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 						}
 						sender->Message_StringID(4, DOORS_SUCCESSFUL_PICK);
 					}
@@ -333,11 +347,11 @@
 				sender->Message(4, "You got it open!"); // more debug spam
 				if(!IsDoorOpen() || (opentype == 58))
 				{ 
-					md->action = OPEN_DOOR; 
+					md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 				} 
 				else
 				{ 
-					md->action = CLOSE_DOOR; 
+					md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
 				} 
 			}
 			else 
@@ -365,7 +379,7 @@
 	//and met all the reqs for opening
 	//everything to do with closed doors has already been taken care of
 	//we return because we don't want people using teleports on an unlocked door (exploit!)
-	if(md->action == CLOSE_DOOR)
+	if((md->action == CLOSE_DOOR && invert_state == 0) || (md->action == CLOSE_INVDOOR && invert_state == 1))
 	{
 		safe_delete(outapp);
 		return;
@@ -439,7 +453,7 @@
 	}
 }
 
-void Doors::NPCOpen(NPC* sender)
+void Doors::NPCOpen(NPC* sender, bool alt_mode)
 {
 	if(sender) {
 		if(GetTriggerType() == 255 || GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || opentype == 59 || opentype == 58 || !sender->IsNPC()) { // this object isnt triggered or door is locked - NPCs should not open locked doors!
@@ -449,10 +463,37 @@
 		EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
 		MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
 		md->doorid = door_id;
-		md->action = OPEN_DOOR;
+		md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
 		entity_list.QueueCloseClients(sender,outapp,false,200);
 		safe_delete(outapp);
 
+		if(!alt_mode) { // original function
+			if(!isopen) {
+				close_timer.Start();
+				isopen=true;
+			}
+			else {
+				close_timer.Disable();
+				isopen=false;
+			}
+		}
+		else { // alternative function
+			close_timer.Start();
+			isopen=true;
+		}
+	}
+}
+
+void Doors::ForceOpen(Mob *sender, bool alt_mode)
+{
+	EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
+	MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
+	md->doorid = door_id;
+	md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
+	entity_list.QueueClients(sender,outapp,false);
+	safe_delete(outapp);
+
+	if(!alt_mode) { // original function
 		if(!isopen) {
 			close_timer.Start();
 			isopen=true;
@@ -462,44 +503,59 @@
 			isopen=false;
 		}
 	}
+	else { // alternative function
+		close_timer.Start();
+		isopen=true;
+	}
 }
 
-void Doors::ForceOpen(Mob *sender)
+void Doors::ForceClose(Mob *sender, bool alt_mode)
 {
-    EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
+	EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
 	MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
 	md->doorid = door_id;
-	md->action = OPEN_DOOR;
+	md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR; // change from original (open to close)
 	entity_list.QueueClients(sender,outapp,false);
 	safe_delete(outapp);
 
-    if(!isopen) {
-        close_timer.Start();
-        isopen=true;
-    }
-    else {
-        close_timer.Disable();
-        isopen=false;
-    }
+	if(!alt_mode) { // original function
+		if(!isopen) {
+			close_timer.Start();
+			isopen=true;
+		}
+		else {
+			close_timer.Disable();
+			isopen=false;
+		}
+	}
+	else { // alternative function
+		if(isopen)
+			close_timer.Trigger();
+	}
 }
 
-void Doors::ForceClose(Mob *sender)
+void Doors::ToggleState(Mob *sender)
 {
-    EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
+	if(GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || opentype == 58 || opentype == 40) { // borrowed some NPCOpen criteria
+		return;
+	}
+
+	EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
 	MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
 	md->doorid = door_id;
-	md->action = OPEN_DOOR;
+
+	if(!isopen) {
+		md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
+		isopen=true;
+	}
+	else
+	{
+		md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
+		isopen=false;
+	}
+
 	entity_list.QueueClients(sender,outapp,false);
 	safe_delete(outapp);
-
-    if(!isopen) {
-        close_timer.Start();
-        isopen=true;
-    }
-    else {
-        close_timer.Disable();
-        isopen=false;
-    }
 }
 
 void Doors::DumpDoor(){
Index: doors.h
===================================================================
--- doors.h	(revision 2153)
+++ doors.h	(working copy)
@@ -58,9 +58,10 @@
 	int8	IsLDoNDoor() { return is_ldon_door; }
 	int32	GetClientVersionMask() { return client_version_mask; }
 	
-	void	NPCOpen(NPC* sender);
-	void	ForceOpen(Mob *sender);
-	void	ForceClose(Mob *sender);
+	void	NPCOpen(NPC* sender, bool alt_mode=false);
+	void	ForceOpen(Mob *sender, bool alt_mode=false);
+	void	ForceClose(Mob *sender, bool alt_mode=false);
+	void	ToggleState(Mob *sender);
 
 	void	SetX(float in);
 	void	SetY(float in);
Index: perlparser.cpp
===================================================================
--- perlparser.cpp	(revision 2153)
+++ perlparser.cpp	(working copy)
@@ -1921,30 +1921,68 @@
 XS(XS__forcedooropen)
 {
 	dXSARGS;
-	if (items != 1)
-		Perl_croak(aTHX_ "Usage: forcedooropen(doorid)");
+	if (items < 1 || items > 2)
+		Perl_croak(aTHX_ "Usage: forcedooropen(doorid [, altmode=0])");
 
+	if (items == 1)
+	{
 	int32	did = (int)SvIV(ST(0));
 
-	quest_manager.forcedooropen(did);
+	quest_manager.forcedooropen(did, false);
 
 	XSRETURN_EMPTY;
+	}
+	else
+	{
+	int32	did = (int)SvIV(ST(0));
+	bool	am = (int)SvIV(ST(1)) == 0?false:true;
+
+	quest_manager.forcedooropen(did, am);
+
+	XSRETURN_EMPTY;
+	}
 }
 
 XS(XS__forcedoorclose);
 XS(XS__forcedoorclose)
 {
 	dXSARGS;
-	if (items != 1)
-		Perl_croak(aTHX_ "Usage: forcedoorclose(doorid)");
+	if (items < 1 || items > 2)
+		Perl_croak(aTHX_ "Usage: forcedoorclose(doorid [, altmode=0])");
 
+	if (items == 1)
+	{
 	int32	did = (int)SvIV(ST(0));
 
-	quest_manager.forcedoorclose(did);
+	quest_manager.forcedoorclose(did, false);
 
 	XSRETURN_EMPTY;
+	}
+	else
+	{
+	int32	did = (int)SvIV(ST(0));
+	bool	am = (int)SvIV(ST(1)) == 0?false:true;
+
+	quest_manager.forcedoorclose(did, am);
+
+	XSRETURN_EMPTY;
+	}
 }
 
+XS(XS__toggledoorstate);
+XS(XS__toggledoorstate)
+{
+	dXSARGS;
+	if (items !=1)
+			Perl_croak(aTHX_ "Usage: toggledoorstate(doorid)");
+
+	int32	did = (int)SvIV(ST(0));
+
+	quest_manager.toggledoorstate(did);
+
+	XSRETURN_EMPTY;
+}
+
 XS(XS__isdooropen);
 XS(XS__isdooropen)
 {
@@ -3421,6 +3459,7 @@
 		newXS(strcpy(buf, "buryplayercorpse"), XS__buryplayercorpse, file);
 		newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file);
 		newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file);
+		newXS(strcpy(buf, "toggledoorstate"), XS__toggledoorstate, file);
 		newXS(strcpy(buf, "isdooropen"), XS__isdooropen, file);
 		newXS(strcpy(buf, "depopall"), XS__depopall, file);
 		newXS(strcpy(buf, "depopzone"), XS__depopzone, file);
Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 2153)
+++ questmgr.cpp	(working copy)
@@ -1623,26 +1623,36 @@
 	return Result;
 }
 
-void QuestManager::forcedooropen(int32 doorid) {
+void QuestManager::forcedooropen(int32 doorid, bool altmode) {
 	Doors* d = entity_list.FindDoor(doorid);
 	if(d){
 		if(GetInitiator())
-			d->ForceOpen(GetInitiator());
+			d->ForceOpen(GetInitiator(), altmode);
 		else if(GetOwner())
-			d->ForceOpen(GetOwner());
+			d->ForceOpen(GetOwner(), altmode);
 	}
 }
 
-void QuestManager::forcedoorclose(int32 doorid) {
+void QuestManager::forcedoorclose(int32 doorid, bool altmode) {
 	Doors* d = entity_list.FindDoor(doorid);
 	if(d){
 		if(GetInitiator())
-			d->ForceClose(GetInitiator());
+			d->ForceClose(GetInitiator(), altmode);
 		else if(GetOwner())
-			d->ForceClose(GetOwner());
+			d->ForceClose(GetOwner(), altmode);
 	}
 }
 
+void QuestManager::toggledoorstate(int32 doorid) {
+	Doors* d = entity_list.FindDoor(doorid);
+	if(d){
+		if(GetInitiator())
+			d->ToggleState(GetInitiator());
+		else if(GetOwner())
+			d->ToggleState(GetOwner());
+	}
+}
+
 bool QuestManager::isdooropen(int32 doorid) {
 	Doors* d = entity_list.FindDoor(doorid);
 	if(d){
Index: questmgr.h
===================================================================
--- questmgr.h	(revision 2153)
+++ questmgr.h	(working copy)
@@ -151,8 +151,9 @@
 	bool summonallplayercorpses(int32 char_id, float dest_x, float dest_y, float dest_z, float dest_heading);
 	int32 getplayerburriedcorpsecount(int32 char_id);
 	bool buryplayercorpse(int32 char_id);
-	void forcedooropen(int32 doorid);
-	void forcedoorclose(int32 doorid);
+	void forcedooropen(int32 doorid, bool altmode);
+	void forcedoorclose(int32 doorid, bool altmode);
+	void toggledoorstate(int32 doorid);
 	bool isdooropen(int32 doorid);
 	void npcrace(int race_id);
 	void npcgender(int gender_id);

Let me know if there are coding problems that I missed. (There still may be quirkness with some doors due to default db settings..I've started changing mine.)


U
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
 


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