Fix crash in demos due to PU not being recorded (#1032)
Added some guards due to bad demo files being shared by now
This commit is contained in:
		
							parent
							
								
									ac673099e0
								
							
						
					
					
						commit
						6a44e09f05
					
				@ -689,6 +689,11 @@ void AOApplication::server_packet_received(AOPacket packet)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    PlayerRegister update{content.at(0).toInt(), PlayerRegister::REGISTER_TYPE(content.at(1).toInt())};
 | 
					    PlayerRegister update{content.at(0).toInt(), PlayerRegister::REGISTER_TYPE(content.at(1).toInt())};
 | 
				
			||||||
    w_courtroom->playerList()->registerPlayer(update);
 | 
					    w_courtroom->playerList()->registerPlayer(update);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (log_to_demo)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      append_to_demofile(packet.toString(true));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (header == "PU")
 | 
					  else if (header == "PU")
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
				
			|||||||
@ -139,6 +139,11 @@ void PlayerListWidget::filterPlayerList()
 | 
				
			|||||||
  int area_id = m_player_map.value(ao_app->client_id).area_id;
 | 
					  int area_id = m_player_map.value(ao_app->client_id).area_id;
 | 
				
			||||||
  for (QListWidgetItem *item : qAsConst(m_item_map))
 | 
					  for (QListWidgetItem *item : qAsConst(m_item_map))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    if (!item)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      qWarning() << "Trying to filter item that does not exist. This indicates either a broken server-implementation or a bad demo file.";
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    item->setHidden(m_player_map[item->data(Qt::UserRole).toInt()].area_id != area_id);
 | 
					    item->setHidden(m_player_map[item->data(Qt::UserRole).toInt()].area_id != area_id);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -147,6 +152,13 @@ void PlayerListWidget::updatePlayer(int playerId, bool updateIcon)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  PlayerData &data = m_player_map[playerId];
 | 
					  PlayerData &data = m_player_map[playerId];
 | 
				
			||||||
  QListWidgetItem *item = m_item_map[playerId];
 | 
					  QListWidgetItem *item = m_item_map[playerId];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!item)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    qWarning() << "No player at ID" << playerId << ". This might indicate a broker server implementation or a bad demo file.";
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  item->setText(data.name.isEmpty() ? QObject::tr("Unnamed Player") : data.name);
 | 
					  item->setText(data.name.isEmpty() ? QObject::tr("Unnamed Player") : data.name);
 | 
				
			||||||
  if (data.character.isEmpty())
 | 
					  if (data.character.isEmpty())
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user