Browse Source

Completion of invis / hide support, client is notified of other spawns aggro visually

Fix #43 complete
Image 3 years ago
parent
commit
eb5a27d544

+ 12 - 0
EQ2/source/WorldServer/Entity.cpp

@@ -1762,7 +1762,10 @@ void Entity::AddStealthSpell(LuaSpell* spell) {
 		changed = true;
 		AddChangedZoneSpawn();
 		if (IsPlayer())
+		{
 			((Player*)this)->SetCharSheetChanged(true);
+			GetZone()->SendAllSpawnsForInvisChange(GetZone()->GetClientBySpawn(this));
+		}
 	}
 }
 
@@ -1779,7 +1782,10 @@ void Entity::AddInvisSpell(LuaSpell* spell) {
 		changed = true;
 		AddChangedZoneSpawn();
 		if (IsPlayer())
+		{
 			((Player*)this)->SetCharSheetChanged(true);
+			GetZone()->SendAllSpawnsForInvisChange(GetZone()->GetClientBySpawn(this));
+		}
 	}
 }
 
@@ -1795,7 +1801,10 @@ void Entity::RemoveInvisSpell(LuaSpell* spell) {
 		changed = true;
 		AddChangedZoneSpawn();
 		if (IsPlayer())
+		{
 			((Player*)this)->SetCharSheetChanged(true);
+			GetZone()->SendAllSpawnsForInvisChange(GetZone()->GetClientBySpawn(this));
+		}
 	}
 }
 
@@ -1811,7 +1820,10 @@ void Entity::RemoveStealthSpell(LuaSpell* spell) {
 		changed = true;
 		AddChangedZoneSpawn();
 		if (IsPlayer())
+		{
 			((Player*)this)->SetCharSheetChanged(true);
+			GetZone()->SendAllSpawnsForInvisChange(GetZone()->GetClientBySpawn(this));
+		}
 	}
 }
 

+ 1 - 1
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -9371,7 +9371,7 @@ int EQ2Emu_lua_SetSeeInvis(lua_State* state) {
 		{
 			Client* client = spawn->GetZone()->GetClientBySpawn((Player*)spawn);
 			if (client)
-				((Player*)spawn)->GetZone()->SendAllSpawnsForInvisChange(client);
+				((Player*)spawn)->GetZone()->SendAllSpawnsForSeeInvisChange(client);
 		}
 	}
 

+ 6 - 0
EQ2/source/WorldServer/Spawn.cpp

@@ -204,6 +204,12 @@ void Spawn::InitializeVisPacketData(Player* player, PacketStruct* vis_packet) {
 		if (!IsGroundSpawn()){
 			int8 arrow_color = ARROW_COLOR_WHITE;
 			sint8 npc_con = player->GetFactions()->GetCon(faction_id);
+
+			if (IsPlayer() && !((Player*)this)->CanSeeInvis(player))
+				npc_con = 0;
+			else if (!IsPlayer() && IsEntity() && !((Entity*)this)->CanSeeInvis(player))
+				npc_con = 0;
+
 			if (appearance.attackable == 1)
 				arrow_color = player->GetArrowColor(GetLevel());
 			vis_packet->setDataByName("arrow_color", arrow_color);

+ 7 - 0
EQ2/source/WorldServer/client.cpp

@@ -862,7 +862,14 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
 	//	LogWrite(PACKET__DEBUG, 0, "opcode %s received", app->GetOpcodeName());
 	//}
 
+	if (!connected_to_zone && opcode != OP_LoginByNumRequestMsg)
+	{
+		opcode = _maxEmuOpcode; // skip since this is not a valid packet, sent before we allowed the login
+	}
+
 	switch (opcode) {
+	case _maxEmuOpcode:
+		break;
 	case OP_LoginByNumRequestMsg: {
 		LogWrite(OPCODE__DEBUG, 0, "Opcode", "Opcode 0x%X (%i): OP_LoginByNumRequestMsg", opcode, opcode);
 

+ 15 - 1
EQ2/source/WorldServer/zoneserver.cpp

@@ -3983,7 +3983,7 @@ void ZoneServer::SendAllSpawnsForLevelChange(Client* client) {
 }
 
 
-void ZoneServer::SendAllSpawnsForInvisChange(Client* client) {
+void ZoneServer::SendAllSpawnsForSeeInvisChange(Client* client) {
 	Spawn* spawn = 0;
 	if (spawn_range_map.count(client) > 0) {
 		MutexMap<int32, float >::iterator itr = spawn_range_map.Get(client)->begin();
@@ -3996,6 +3996,20 @@ void ZoneServer::SendAllSpawnsForInvisChange(Client* client) {
 	}
 }
 
+
+void ZoneServer::SendAllSpawnsForInvisChange(Client* client) {
+	Spawn* spawn = 0;
+	if (spawn_range_map.count(client) > 0) {
+		MutexMap<int32, float >::iterator itr = spawn_range_map.Get(client)->begin();
+		while (itr.Next()) {
+			spawn = GetSpawnByID(itr->first);
+			if (spawn && spawn->IsEntity() && client->GetPlayer()->WasSentSpawn(spawn->GetID()) && !client->GetPlayer()->WasSpawnRemoved(spawn)) {
+				SendSpawnChanges(spawn, client, false, true);
+			}
+		}
+	}
+}
+
 void ZoneServer::StartZoneSpawnsForLevelThread(Client* client){
 	if(zoneShuttingDown)
 		return;

+ 1 - 0
EQ2/source/WorldServer/zoneserver.h

@@ -327,6 +327,7 @@ public:
 	
 	void	ReloadClientQuests();
 	void	SendAllSpawnsForLevelChange(Client* client);
+	void	SendAllSpawnsForSeeInvisChange(Client* client);
 	void	SendAllSpawnsForInvisChange(Client* client);
 	
 	void	AddLocationGrid(LocationGrid* grid);