Browse Source

Crash fix for housing packet and checking quest flag on dead quest, finally fixed character_history needs to escape location before going in db

Emagi 8 months ago
parent
commit
7f809a5b79

+ 3 - 0
EQ2/source/WorldServer/Housing/HousingPackets.cpp

@@ -73,6 +73,9 @@ void ClientPacketFunctions::SendHousingList(Client* client) {
 	std::vector<PlayerHouse*> houses = world.GetAllPlayerHouses(client->GetCharacterID());
 	// this packet must be sent first otherwise it blocks out the enter house option after paying upkeep
 	PacketStruct* packet = configReader.getStruct("WS_CharacterHousingList", client->GetVersion());
+	if(!packet) {
+		return;
+	}
 	packet->setArrayLengthByName("num_houses", houses.size());
 	for (int i = 0; i < houses.size(); i++)
 	{

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

@@ -4866,7 +4866,7 @@ int8 Player::CheckQuestFlag(Spawn* spawn){
 		for(int32 i=0;i<quests->size();i++){
 			MPlayerQuests.readlock(__FUNCTION__, __LINE__);
 			if(player_quests.count(quests->at(i)) > 0){
-				if(player_quests[quests->at(i)]->GetCompleted() && player_quests[quests->at(i)]->GetQuestReturnNPC() == spawn->GetDatabaseID()){
+				if(player_quests[quests->at(i)] && player_quests[quests->at(i)]->GetCompleted() && player_quests[quests->at(i)]->GetQuestReturnNPC() == spawn->GetDatabaseID()){
 					ret = 2;
 					MPlayerQuests.releasereadlock(__FUNCTION__, __LINE__);
 					break;

+ 3 - 3
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -6353,8 +6353,8 @@ void WorldDatabase::LoadSpellErrors() {
 }
 
 void WorldDatabase::SaveCharacterHistory(Player* player, int8 type, int8 subtype, int32 value, int32 value2, char* location, int32 event_date) {
-	string str_type;
-	string str_subtype;
+	string str_type("");
+	string str_subtype("");
 	switch (type) {
 	case HISTORY_TYPE_NONE:
 		str_type = "None";
@@ -6403,7 +6403,7 @@ void WorldDatabase::SaveCharacterHistory(Player* player, int8 type, int8 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)", 
-		player->GetCharacterID(), str_type.c_str(), str_subtype.c_str(), value, value2, location, event_date);
+		player->GetCharacterID(), str_type.c_str(), str_subtype.c_str(), value, value2, getSafeEscapeString(location).c_str(), event_date);
 }
 
 void WorldDatabase::LoadTransportMaps(ZoneServer* zone) {