Cambiados los accesos a vector de .at a []

This commit is contained in:
2022-12-07 09:29:06 +01:00
parent 7adb049b37
commit c87e1e68a9
8 changed files with 208 additions and 208 deletions

View File

@@ -125,9 +125,9 @@ void Title::init()
// Si ha encontrado un mando se lo asigna al segundo jugador
if (input->gameControllerFound())
{
options->input.at(1).id = availableInputDevices.at(deviceIndex.at(1)).id;
options->input.at(1).name = availableInputDevices.at(deviceIndex.at(1)).name;
options->input.at(1).deviceType = availableInputDevices.at(deviceIndex.at(1)).deviceType;
options->input[1].id = availableInputDevices[deviceIndex[1]].id;
options->input[1].name = availableInputDevices[deviceIndex[1]].name;
options->input[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
}
// Inicializa el bitmap de Coffee
@@ -1010,49 +1010,49 @@ bool Title::updatePlayerInputs(int numPlayer)
if (!input->gameControllerFound())
{ // Si no hay mandos se deja todo de manera prefijada
deviceIndex.at(0) = 0;
deviceIndex.at(1) = 0;
deviceIndex[0] = 0;
deviceIndex[1] = 0;
options->input.at(0).id = -1;
options->input.at(0).name = "KEYBOARD";
options->input.at(0).deviceType = INPUT_USE_KEYBOARD;
options->input[0].id = -1;
options->input[0].name = "KEYBOARD";
options->input[0].deviceType = INPUT_USE_KEYBOARD;
options->input.at(1).id = 0;
options->input.at(1).name = "GAME CONTROLLER";
options->input.at(1).deviceType = INPUT_USE_GAMECONTROLLER;
options->input[1].id = 0;
options->input[1].name = "GAME CONTROLLER";
options->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
return true;
}
else
{ // Si hay mas de un dispositivo, se recorre el vector
std::cout << "numplayer:" << numPlayer << std::endl;
std::cout << "deviceindex:" << deviceIndex.at(numPlayer) << std::endl;
std::cout << "deviceindex:" << deviceIndex[numPlayer] << std::endl;
// Incrementa el indice
if (deviceIndex.at(numPlayer) < numDevices - 1)
if (deviceIndex[numPlayer] < numDevices - 1)
{
deviceIndex.at(numPlayer)++;
deviceIndex[numPlayer]++;
}
else
{
deviceIndex.at(numPlayer) = 0;
deviceIndex[numPlayer] = 0;
}
std::cout << "deviceindex:" << deviceIndex.at(numPlayer) << std::endl;
std::cout << "deviceindex:" << deviceIndex[numPlayer] << std::endl;
// Si coincide con el del otro jugador, se lo intercambian
if (deviceIndex.at(0) == deviceIndex.at(1))
if (deviceIndex[0] == deviceIndex[1])
{
const int theOtherPlayer = (numPlayer + 1) % 2;
deviceIndex.at(theOtherPlayer)--;
if (deviceIndex.at(theOtherPlayer) < 0)
deviceIndex[theOtherPlayer]--;
if (deviceIndex[theOtherPlayer] < 0)
{
deviceIndex.at(theOtherPlayer) = numDevices - 1;
deviceIndex[theOtherPlayer] = numDevices - 1;
}
}
// Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador
options->input[0] = availableInputDevices.at(deviceIndex.at(0));
options->input[1] = availableInputDevices.at(deviceIndex.at(1));
options->input[0] = availableInputDevices[deviceIndex[0]];
options->input[1] = availableInputDevices[deviceIndex[1]];
return true;
}