forked from jaildesigner-jailgames/jaildoctors_dilemma
Revert "Eliminados todos los std:: del código"
This reverts commit 4a2d27dc59.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <sstream>
|
||||
|
||||
// Constructor
|
||||
Stats::Stats(string file, string buffer, options_t *options)
|
||||
Stats::Stats(std::string file, std::string buffer, options_t *options)
|
||||
{
|
||||
this->options = options;
|
||||
bufferPath = buffer;
|
||||
@@ -51,10 +51,10 @@ void Stats::init()
|
||||
}
|
||||
|
||||
// Añade una muerte a las estadisticas
|
||||
void Stats::addDeath(string name)
|
||||
void Stats::addDeath(std::string name)
|
||||
{
|
||||
// Normaliza el nombre
|
||||
// replace(name.begin(), name.end(), ' ', '_');
|
||||
// std::replace(name.begin(), name.end(), ' ', '_');
|
||||
|
||||
// Primero busca si ya hay una entrada con ese nombre
|
||||
const int index = findByName(name, bufferList);
|
||||
@@ -75,10 +75,10 @@ void Stats::addDeath(string name)
|
||||
}
|
||||
|
||||
// Añade una visita a las estadisticas
|
||||
void Stats::addVisit(string name)
|
||||
void Stats::addVisit(std::string name)
|
||||
{
|
||||
// Normaliza el nombre
|
||||
// replace(name.begin(), name.end(), ' ', '_');
|
||||
// std::replace(name.begin(), name.end(), ' ', '_');
|
||||
|
||||
// Primero busca si ya hay una entrada con ese nombre
|
||||
const int index = findByName(name, bufferList);
|
||||
@@ -99,7 +99,7 @@ void Stats::addVisit(string name)
|
||||
}
|
||||
|
||||
// Busca una entrada en la lista por nombre
|
||||
int Stats::findByName(string name, vector<stats_t> &list)
|
||||
int Stats::findByName(std::string name, std::vector<stats_t> &list)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -116,7 +116,7 @@ int Stats::findByName(string name, vector<stats_t> &list)
|
||||
}
|
||||
|
||||
// Carga las estadisticas desde un fichero
|
||||
bool Stats::loadFromFile(string filePath, vector<stats_t> &list)
|
||||
bool Stats::loadFromFile(std::string filePath, std::vector<stats_t> &list)
|
||||
{
|
||||
list.clear();
|
||||
|
||||
@@ -124,21 +124,21 @@ bool Stats::loadFromFile(string filePath, vector<stats_t> &list)
|
||||
bool success = true;
|
||||
|
||||
// Variables para manejar el fichero
|
||||
string line;
|
||||
ifstream file(filePath);
|
||||
std::string line;
|
||||
std::ifstream file(filePath);
|
||||
|
||||
// Si el fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
while (getline(file, line))
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Comprueba que la linea no sea un comentario
|
||||
if (line.substr(0, 1) != "#")
|
||||
{
|
||||
stats_t stat;
|
||||
stringstream ss(line);
|
||||
string tmp;
|
||||
std::stringstream ss(line);
|
||||
std::string tmp;
|
||||
|
||||
// Obtiene el nombre
|
||||
getline(ss, tmp, ';');
|
||||
@@ -146,11 +146,11 @@ bool Stats::loadFromFile(string filePath, vector<stats_t> &list)
|
||||
|
||||
// Obtiene las visitas
|
||||
getline(ss, tmp, ';');
|
||||
stat.visited = stoi(tmp);
|
||||
stat.visited = std::stoi(tmp);
|
||||
|
||||
// Obtiene las muertes
|
||||
getline(ss, tmp, ';');
|
||||
stat.died = stoi(tmp);
|
||||
stat.died = std::stoi(tmp);
|
||||
|
||||
list.push_back(stat);
|
||||
}
|
||||
@@ -177,14 +177,14 @@ void Stats::loadFromServer()
|
||||
|
||||
list.clear();
|
||||
|
||||
string data;
|
||||
std::string data;
|
||||
if (options->online.enabled)
|
||||
{
|
||||
data = jscore::getUserData(options->online.gameID, options->online.jailerID);
|
||||
}
|
||||
|
||||
stringstream ss(data);
|
||||
string tmp;
|
||||
std::stringstream ss(data);
|
||||
std::string tmp;
|
||||
|
||||
int count = 0;
|
||||
|
||||
@@ -206,11 +206,11 @@ void Stats::loadFromServer()
|
||||
|
||||
// Obtiene las visitas
|
||||
getline(ss, tmp, ';');
|
||||
stat.visited = stoi(tmp);
|
||||
stat.visited = std::stoi(tmp);
|
||||
|
||||
// Obtiene las muertes
|
||||
getline(ss, tmp, ';');
|
||||
stat.died = stoi(tmp);
|
||||
stat.died = std::stoi(tmp);
|
||||
|
||||
list.push_back(stat);
|
||||
count = count - 3;
|
||||
@@ -218,16 +218,16 @@ void Stats::loadFromServer()
|
||||
}
|
||||
|
||||
// Guarda las estadisticas en un fichero
|
||||
void Stats::saveToFile(string filePath, vector<stats_t> &list)
|
||||
void Stats::saveToFile(std::string filePath, std::vector<stats_t> &list)
|
||||
{
|
||||
// Crea y abre el fichero de texto
|
||||
ofstream file(filePath);
|
||||
std::ofstream file(filePath);
|
||||
|
||||
// Escribe en el fichero
|
||||
file << "# ROOM NAME;VISITS;DEATHS" << endl;
|
||||
file << "# ROOM NAME;VISITS;DEATHS" << std::endl;
|
||||
for (auto item : list)
|
||||
{
|
||||
file << item.name << ";" << item.visited << ";" << item.died << endl;
|
||||
file << item.name << ";" << item.visited << ";" << item.died << std::endl;
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
@@ -237,12 +237,12 @@ void Stats::saveToFile(string filePath, vector<stats_t> &list)
|
||||
// Guarda las estadisticas en un servidor
|
||||
void Stats::saveToServer()
|
||||
{
|
||||
string data = "";
|
||||
std::string data = "";
|
||||
if (options->online.enabled)
|
||||
{
|
||||
for (auto item : list)
|
||||
{
|
||||
data = data + nameToNumber(item.name) + ";" + to_string(item.visited) + ";" + to_string(item.died) + ";";
|
||||
data = data + nameToNumber(item.name) + ";" + std::to_string(item.visited) + ";" + std::to_string(item.died) + ";";
|
||||
}
|
||||
jscore::setUserData(options->online.gameID, options->online.jailerID, data);
|
||||
}
|
||||
@@ -263,13 +263,13 @@ void Stats::checkWorstNightmare()
|
||||
}
|
||||
|
||||
// Añade una entrada al diccionario
|
||||
void Stats::addDictionary(string number, string name)
|
||||
void Stats::addDictionary(std::string number, std::string name)
|
||||
{
|
||||
dictionary.push_back({number, name});
|
||||
}
|
||||
|
||||
// Obtiene el nombre de una habitación a partir del número
|
||||
string Stats::numberToName(string number)
|
||||
std::string Stats::numberToName(std::string number)
|
||||
{
|
||||
for (auto l : dictionary)
|
||||
{
|
||||
@@ -282,7 +282,7 @@ string Stats::numberToName(string number)
|
||||
}
|
||||
|
||||
// Obtiene el número de una habitación a partir del nombre
|
||||
string Stats::nameToNumber(string name)
|
||||
std::string Stats::nameToNumber(std::string name)
|
||||
{
|
||||
for (auto l : dictionary)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user