[Patch] admin_level in /who query

EQ2Emulator Development forum.

Moderator: Team Members

paulgh
Retired
Posts: 51
Joined: Sun Jul 27, 2008 8:48 pm

Re: [Patch] admin_level in /who query

Post by paulgh » Sun Jun 07, 2009 6:57 am

Here is my latest patch, which is complete, barring implementation of flags.

Code: Select all

diff -Bruw EQ2Emu/Config Files/World Structs/WorldStructs.xml EQ2EmuPGH/Config Files/World Structs/WorldStructs.xml
--- EQ2Emu/Config Files/World Structs/WorldStructs.xml	Tue Jun  2 09:46:35 2009
+++ EQ2EmuPGH/Config Files/World Structs/WorldStructs.xml	Wed Jun  3 20:36:12 2009
@@ -2369,7 +2369,8 @@
 <Data ElementName="characters_array" Type="Array" ArraySizeVariable="num_characters">
 	<Data ElementName="char_name" Type="char" Size="40" />
 	<Data ElementName="unknown3" Type="int8" Size="1" />
-	<Data ElementName="level" Type="int16" Size="1" />
+	<Data ElementName="level" Type="int8" Size="1" />
+	<Data ElementName="admin_level" Type="int8" Size="1" />
 	<Data ElementName="class" Type="int16" Size="1" />
 	<Data ElementName="unknown4" Type="int8" />
 	<Data ElementName="race" Type="int8" Size="1" />
diff -Bruw EQ2Emu/Source/World/World.cpp EQ2EmuPGH/Source/World/World.cpp
--- EQ2Emu/Source/World/World.cpp	Tue Jun  2 09:46:35 2009
+++ EQ2EmuPGH/Source/World/World.cpp	Sat Jun  6 14:42:38 2009
@@ -630,6 +630,9 @@
 				found_match = false;
 				if(queries->at(i) == "ALL")
 					continue;
+/*				if(player->GetFlags() & FLAG_INVISIBLE)
+ *					continue;
+ */
 				if(queries->at(i).length() > 3 && classes.GetClassID((char*)queries->at(i).c_str()) > 0){
 					if(player->GetAdventureClass() != classes.GetClassID((char*)queries->at(i).c_str()))
 						add_player = false;
@@ -650,11 +653,15 @@
 						add_player = false;
 					found_match = true;
 				}
-				if(queries->at(i) == "LFG")
+				if((queries->at(i) == "GUIDE") && (GetAdminLevel(player->GetName()) > 0) && (GetAdminLevel(player->GetName()) < 5))
 					found_match = true;
-				else if(queries->at(i) == "LFW")
+				if((queries->at(i) == "GM") && (GetAdminLevel(player->GetName()) > 4))
 					found_match = true;
-				else if(queries->at(i) == "ROLEPLAYING")
+				if((queries->at(i) == "LFG") /* && (player->GetFlags() & FLAG_LFG) */ )
+					found_match = true;
+				else if((queries->at(i) == "LFW") /* && (player->GetFlags() & FLAG_LFW) */ )
+					found_match = true;
+				else if((queries->at(i) == "ROLEPLAYING") /* && (player->GetFlags() & FLAG_ROLEPLAYING) */ )
 					found_match = true;
 				else if(strspn(queries->at(i).c_str(),"0123456789") == queries->at(i).length()){
 					try{
@@ -752,8 +759,10 @@
 			player = *spawn_iter;
 			packet->setArrayDataByName("char_name", player->GetName(), i);
 			packet->setArrayDataByName("level", player->GetLevel(), i);
+			packet->setArrayDataByName("admin_level", /*(player->GetFlags() & FLAG_INVISIBLE)?0:*/GetAdminLevel(player->GetName()), i);
 			packet->setArrayDataByName("class", player->GetAdventureClass(), i);
 			packet->setArrayDataByName("unknown4", 0xFF, i); //probably tradeskill class
+			packet->setArrayDataByName("flags", /*player->GetFlags()*/0, i);
 			packet->setArrayDataByName("race", player->GetRace(), i);
 			if(player->GetZone() && player->GetZone()->GetZoneDescription())
 				packet->setArrayDataByName("zone", player->GetZone()->GetZoneDescription(), i);
@@ -1597,3 +1606,22 @@
 	}
 	return ret;
 }
\ No newline at end of file
+
+int32 GetAdminLevel(char *name){
+	Query query;
+	MYSQL_ROW row;
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT admin_status from characters where name = '%s'", name);
+	int32 admin_level = 0;
+	if(result){
+		row = mysql_fetch_row(result);
+		admin_level = strtoul(row[0], NULL, 0);
+	}
+
+/* Temporary fix to adjust admin_status to admin_level.
+ * admin_level must be [0 .. 15] or -1
+ */
+	admin_level = (admin_level >> 4);
+
+	return admin_level;
+}
+
diff -Bruw EQ2Emu/Source/World/World.h EQ2EmuPGH/Source/World/World.h
--- EQ2Emu/Source/World/World.h	Tue Jun  2 09:46:35 2009
+++ EQ2EmuPGH/Source/World/World.h	Sat Jun  6 14:21:22 2009
@@ -33,6 +33,8 @@
 #include "Sign.h"
 #include "Variables.h"
 
+int32 GetAdminLevel(char *name);
+
 using namespace std;
 struct MerchantInfo{
 	vector<int32> inventory_ids;
/who [ALL] GUIDE will show anyone with admin_status 16 - 79.
/who [ALL} GM will show anyone with admin_status 80 -255.
Higher admin_status will sow nothing, but the *client* will probably log a warning in the logfile.

Paul

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Re: [Patch] admin_level in /who query

Post by LethalEncounter » Sun Jun 07, 2009 7:45 am

Good work, I'll get it merge into the source. Thanks for taking the time! :)

Image
Retired
Posts: 251
Joined: Sun Oct 26, 2008 10:07 am

Re: [Patch] admin_level in /who query

Post by Image » Sun Jun 07, 2009 9:49 am

We are going to need to do a different coding of the hide command, I have never been a fan of how they 'hide' the GM's in EQ/EQ2. They are still viewable to the extent at least in EQ that they sent packets out of the GM's location and it would be viewable on ShowEQ/MacroQuest. I feel that it is likely the same deal goes with EQ2 and ISXEQ2.

We need to hardcode out sending position updates/spawn information for GM's who are in hide mode and it needs to work cross zone such as in EQEmu with #hideme.

That is, if John wants real sneakiness :)

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: [Patch] admin_level in /who query

Post by John Adams » Sun Jun 07, 2009 10:22 am

Eventually I would like true sneakiness - invisibility and un-detectediness ;)

But all I was asking for in this is just not display the text (GM-whatever) in the /who list if the individual GM doesn't want to be seen as such. I don't care if their name has GM-Image in front of it or whatever. I was only talkin /who to start. The rest we can enhance as we go.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests