浏览代码

Remove unnecessary if statements, address spell cast time stacking, some misc pieces missed from last patch like attack state of npcs

Emagi 5 月之前
父节点
当前提交
8484c78ca2

+ 7 - 17
EQ2/source/WorldServer/Spawn.cpp

@@ -860,13 +860,7 @@ uchar* Spawn::spawn_pos_changes(Player* player, int16 version, int16* pos_packet
 	}
 
 	int16 newSize = size + 1000;
-	uchar* tmp;
-	if (IsPlayer() && version > 283) {
-		tmp = new uchar[newSize];
-	}
-	else {
-		tmp = new uchar[newSize];
-	}
+	uchar* tmp = new uchar[newSize];
 	size = Pack(tmp, xor_pos_packet, size, newSize, version);
 	player->pos_mutex.releasewritelock(__FUNCTION__, __LINE__);
 
@@ -1250,13 +1244,7 @@ uchar* Spawn::spawn_pos_changes_ex(Player* player, int16 version, int16* pos_pac
 	}
 
 	int16 newSize = size + 1000;
-	uchar* tmp;
-	if (IsPlayer() && version > 283) {
-		tmp = new uchar[newSize];
-	}
-	else {
-		tmp = new uchar[newSize];
-	}
+	uchar* tmp = new uchar[newSize];
 	size = Pack(tmp, xor_pos_packet, size, newSize, version);
 	player->pos_mutex.releasewritelock(__FUNCTION__, __LINE__);
 	
@@ -2691,10 +2679,12 @@ void Spawn::InitializeInfoPacketData(Player* spawn, PacketStruct* packet) {
 				packet->setDataByName("camping", 1);
 			if ((appearance.activity_status & ACTIVITY_STATUS_LFG) > 0)
 				packet->setDataByName("lfg", 1);
-			if (EngagedInCombat()) {
-				packet->setDataByName("auto_attack", 1);
-			}
 		}
+		
+		if (EngagedInCombat()) {
+			packet->setDataByName("auto_attack", 1);
+		}
+		
 		if ((appearance.activity_status & ACTIVITY_STATUS_SOLID) > 0)
 			packet->setDataByName("solid_object", 1);
 	}

+ 3 - 1
EQ2/source/WorldServer/SpellProcess.cpp

@@ -1524,8 +1524,10 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 		else
 			LogWrite(SPELL__DEBUG, 1, "Spell", "Unable to do precast check as there was no lua_interface");
 		
-		if (custom_cast_time > 0)
+		if (custom_cast_time > 0) {
+			spell->GetSpellData()->orig_cast_time = custom_cast_time;
 			spell->GetSpellData()->cast_time = custom_cast_time;
+		}
 
 		//Apply casting speed mod
 		spell->ModifyCastTime(caster);

+ 3 - 1
EQ2/source/WorldServer/Spells.cpp

@@ -1900,6 +1900,7 @@ bool Spell::SetSpellData(lua_State* state, std::string field, int8 fieldArg)
 	else if (field == "cast_time")
 	{
 		int16 cast_time = lua_interface->GetInt16Value(state, fieldArg);
+		GetSpellData()->orig_cast_time = cast_time;
 		GetSpellData()->cast_time = cast_time;
 		valSet = true;
 	}
@@ -2218,7 +2219,8 @@ bool Spell::IsCopiedSpell() {
 }
 
 void Spell::ModifyCastTime(Entity* caster){
-	int16 cast_time = spell->cast_time;
+	int16 cast_time = spell->orig_cast_time;
+	spell->cast_time = cast_time;
 	float cast_speed = caster->GetInfoStruct()->get_casting_speed();
 	if (cast_speed > 0.0f){
 		bool modifiedSpeed = false;

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

@@ -265,6 +265,7 @@ struct SpellData{
 	int16	dissonance_upkeep;
 	int8	target_type;
 	int16	cast_time;
+	int16	orig_cast_time;
 	float	recovery;
 	float	recast;
 	int32	linked_timer;

+ 2 - 1
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -4800,6 +4800,7 @@ void WorldDatabase::LoadSpells()
 
 			/* Spell Parameters */
 			data->call_frequency			= result.GetInt32Str("call_frequency");
+			data->orig_cast_time			= result.GetInt16Str("cast_time");
 			data->cast_time					= result.GetInt16Str("cast_time");
 			data->duration1					= result.GetInt32Str("duration1");
 			data->duration2					= result.GetInt32Str("duration2");
@@ -6437,7 +6438,7 @@ void WorldDatabase::SaveCharacterHistory(Player* player, int8 type, int8 subtype
 		return;
 	}
 
-	LogWrite(PLAYER__INFO, 1, "Player", "Saving character history, type = %s (%i) subtype = %s (%i)", (char*)str_type.c_str(), type, (char*)str_subtype.c_str(), subtype);
+	LogWrite(PLAYER__DEBUG, 1, "Player", "Saving character history, type = %s (%i) subtype = %s (%i)", (char*)str_type.c_str(), type, (char*)str_subtype.c_str(), subtype);
 
 	Query query;
 	query.AddQueryAsync(player->GetCharacterID(), this, Q_REPLACE, "replace into character_history (char_id, type, subtype, value, value2, location, event_date) values (%u, '%s', '%s', %i, %i, '%s', %u)",