<commit_before>
#include "InfoPanel.h"
#include "GameSettings.h"
#include <cstddef>

static const unsigned int TRANSPARENT_COLOR = (255 << 8) + (255 << 0);

int InfoPanel::WIDTH =PANEL_TILE_WIDTH * Map::TILE_WIDTH;
int InfoPanel::HEIGHT=13 * Map::TILE_HEIGHT; //unknown here

bool InfoPanel::DRAW_HEALTH_UNDER_PLAYERS = true;


InfoPanel::InfoPanel(SDL_Surface* backbuf, int numPlayers, std::vector<bool>* malePlayers)
{
  WIDTH = PANEL_TILE_WIDTH * Map::TILE_WIDTH;
  HEIGHT = GameSettings::getInstance()->getMapHeight() * Map::TILE_HEIGHT;

  if(numPlayers > GameSettings::MAX_PLAYERS)
  {
    numPlayers = GameSettings::MAX_PLAYERS;
  }
  if(numPlayers < GameSettings::MIN_PLAYERS)
  {
    numPlayers = GameSettings::MIN_PLAYERS;
  }

  m_playerPointers.resize(numPlayers, nullptr);

  clearSelections();

  m_surface = SDL_CreateRGBSurface(0, WIDTH, HEIGHT, backbuf->format->BitsPerPixel, backbuf->format->Rmask,
      backbuf->format->Gmask, backbuf->format->Bmask, 0);

  // set up face surfaces
  for (int i = 0; i < numPlayers; i++)
  {
    // TODO handle more than 4 players
    stringstream ss;
    ss << "assets/bitmaps/player" << (i + 1);
    if (malePlayers->at(i) == true)
    {
      ss << "male";
    }
    else
    {
      ss << "female";
    }
    ss << "face.bmp";

    m_faceSurfaces[i] = SDL_LoadBMP(ss.str().c_str());
  }

  // change to team colours and apply color key
  for (int i = 0; i < numPlayers; ++i)
  {
    SDL_SetColorKey( m_faceSurfaces[i], SDL_TRUE, SDL_MapRGB(m_faceSurfaces[i]->format, 0, 255, 255) );
  }
}

InfoPanel::~InfoPanel()
{
  if (m_surface)
  {
    SDL_FreeSurface(m_surface);
    m_surface = nullptr;
  }
  for (int i = 0; i < m_playerPointers.size(); i++)
  {
    if (m_faceSurfaces[i])
    {
      SDL_FreeSurface(m_faceSurfaces[i]);
      m_faceSurfaces[i] = nullptr;
    }
  }
}

// TODO vector types
void InfoPanel::setPlayerPointers(vector<shared_ptr<PlayerCharacterEntity>> playerCharacters)
{
  m_playerPointers = playerCharacters;
}

void InfoPanel::clearSelections()
{
  for (int t = 0; t < GameSettings::MAX_PLAYERS; t++)<commit_msg>Fix unsigned/signed comparison warn<commit_after>
#include "InfoPanel.h"
#include "GameSettings.h"
#include <cstddef>

static const unsigned int TRANSPARENT_COLOR = (255 << 8) + (255 << 0);

int InfoPanel::WIDTH =PANEL_TILE_WIDTH * Map::TILE_WIDTH;
int InfoPanel::HEIGHT=13 * Map::TILE_HEIGHT; //unknown here

bool InfoPanel::DRAW_HEALTH_UNDER_PLAYERS = true;


InfoPanel::InfoPanel(SDL_Surface* backbuf, int numPlayers, std::vector<bool>* malePlayers)
{
  WIDTH = PANEL_TILE_WIDTH * Map::TILE_WIDTH;
  HEIGHT = GameSettings::getInstance()->getMapHeight() * Map::TILE_HEIGHT;

  if(numPlayers > GameSettings::MAX_PLAYERS)
  {
    numPlayers = GameSettings::MAX_PLAYERS;
  }
  if(numPlayers < GameSettings::MIN_PLAYERS)
  {
    numPlayers = GameSettings::MIN_PLAYERS;
  }

  m_playerPointers.resize(numPlayers, nullptr);

  clearSelections();

  m_surface = SDL_CreateRGBSurface(0, WIDTH, HEIGHT, backbuf->format->BitsPerPixel, backbuf->format->Rmask,
      backbuf->format->Gmask, backbuf->format->Bmask, 0);

  // set up face surfaces
  for (int i = 0; i < numPlayers; i++)
  {
    // TODO handle more than 4 players
    stringstream ss;
    ss << "assets/bitmaps/player" << (i + 1);
    if (malePlayers->at(i) == true)
    {
      ss << "male";
    }
    else
    {
      ss << "female";
    }
    ss << "face.bmp";

    m_faceSurfaces[i] = SDL_LoadBMP(ss.str().c_str());
  }

  // change to team colours and apply color key
  for (int i = 0; i < numPlayers; ++i)
  {
    SDL_SetColorKey( m_faceSurfaces[i], SDL_TRUE, SDL_MapRGB(m_faceSurfaces[i]->format, 0, 255, 255) );
  }
}

InfoPanel::~InfoPanel()
{
  if (m_surface)
  {
    SDL_FreeSurface(m_surface);
    m_surface = nullptr;
  }
  for (unsigned int i = 0; i < m_playerPointers.size(); i++)
  {
    if (m_faceSurfaces[i])
    {
      SDL_FreeSurface(m_faceSurfaces[i]);
      m_faceSurfaces[i] = nullptr;
    }
  }
}

// TODO vector types
void InfoPanel::setPlayerPointers(vector<shared_ptr<PlayerCharacterEntity>> playerCharacters)
{
  m_playerPointers = playerCharacters;
}

void InfoPanel::clearSelections()
{
  for (int t = 0; t < GameSettings::MAX_PLAYERS; t++)
{'fraction_non_alphanumeric': 0.14339890969424035, 'fraction_numerical': 0.011851149561507466, 'mean_word_length': 3.9764150943396226, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6371582', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1524, 'n_words': 307}