Eliminados todos los std:: del código

This commit is contained in:
2023-09-16 12:44:40 +02:00
parent 71be364141
commit 4a2d27dc59
35 changed files with 539 additions and 504 deletions

View File

@@ -4,34 +4,34 @@
#include <sstream>
// Carga las variables y texturas desde un fichero de mapa de tiles
std::vector<int> loadRoomTileFile(std::string file_path, bool verbose)
vector<int> loadRoomTileFile(string file_path, bool verbose)
{
std::vector<int> tileMapFile;
const std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
std::string line;
std::ifstream file(file_path);
vector<int> tileMapFile;
const string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
string line;
ifstream file(file_path);
// El fichero se puede abrir
if (file.good())
{
// Procesa el fichero linea a linea
while (std::getline(file, line))
while (getline(file, line))
{ // Lee el fichero linea a linea
if (line.find("data encoding") != std::string::npos)
if (line.find("data encoding") != string::npos)
{
// Lee la primera linea
std::getline(file, line);
getline(file, line);
while (line != "</data>")
{ // Procesa lineas mientras haya
std::stringstream ss(line);
std::string tmp;
stringstream ss(line);
string tmp;
while (getline(ss, tmp, ','))
{
tileMapFile.push_back(std::stoi(tmp) - 1);
tileMapFile.push_back(stoi(tmp) - 1);
}
// Lee la siguiente linea
std::getline(file, line);
getline(file, line);
}
}
}
@@ -39,7 +39,7 @@ std::vector<int> loadRoomTileFile(std::string file_path, bool verbose)
// Cierra el fichero
if (verbose)
{
std::cout << "TileMap loaded: " << filename.c_str() << std::endl;
cout << "TileMap loaded: " << filename.c_str() << endl;
}
file.close();
}
@@ -48,7 +48,7 @@ std::vector<int> loadRoomTileFile(std::string file_path, bool verbose)
{ // El fichero no se puede abrir
if (verbose)
{
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
cout << "Warning: Unable to open " << filename.c_str() << " file" << endl;
}
}
@@ -56,24 +56,24 @@ std::vector<int> loadRoomTileFile(std::string file_path, bool verbose)
}
// Carga las variables desde un fichero de mapa
room_t loadRoomFile(std::string file_path, bool verbose)
room_t loadRoomFile(string file_path, bool verbose)
{
room_t room;
room.itemColor1 = "yellow";
room.itemColor2 = "magenta";
room.autoSurfaceDirection = 1;
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
const string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
room.number = fileName.substr(0, fileName.find_last_of("."));
std::string line;
std::ifstream file(file_path);
string line;
ifstream file(file_path);
// El fichero se puede abrir
if (file.good())
{
// Procesa el fichero linea a linea
while (std::getline(file, line))
while (getline(file, line))
{
// Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo
if (line == "[enemy]")
@@ -86,7 +86,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
do
{
std::getline(file, line);
getline(file, line);
// Encuentra la posición del caracter '='
int pos = line.find("=");
@@ -96,7 +96,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
{
if (verbose)
{
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
}
}
} while (line != "[/enemy]");
@@ -115,7 +115,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
do
{
std::getline(file, line);
getline(file, line);
// Encuentra la posición del caracter '='
int pos = line.find("=");
@@ -125,7 +125,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
{
if (verbose)
{
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
}
}
@@ -145,7 +145,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
{
if (verbose)
{
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
}
}
}
@@ -154,7 +154,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
// Cierra el fichero
if (verbose)
{
std::cout << "Room loaded: " << fileName.c_str() << std::endl;
cout << "Room loaded: " << fileName.c_str() << endl;
}
file.close();
}
@@ -162,7 +162,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
else
{
{
std::cout << "Warning: Unable to open " << fileName.c_str() << " file" << std::endl;
cout << "Warning: Unable to open " << fileName.c_str() << " file" << endl;
}
}
@@ -170,7 +170,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
}
// Asigna variables a partir de dos cadenas
bool setVars(room_t *room, std::string var, std::string value)
bool setVars(room_t *room, string var, string value)
{
// Indicador de éxito en la asignación
bool success = true;
@@ -255,7 +255,7 @@ bool setVars(room_t *room, std::string var, std::string value)
}
// Asigna variables a una estructura enemy_t
bool setEnemy(enemy_t *enemy, std::string var, std::string value)
bool setEnemy(enemy_t *enemy, string var, string value)
{
// Indicador de éxito en la asignación
bool success = true;
@@ -267,52 +267,52 @@ bool setEnemy(enemy_t *enemy, std::string var, std::string value)
else if (var == "width")
{
enemy->w = std::stof(value);
enemy->w = stof(value);
}
else if (var == "height")
{
enemy->h = std::stof(value);
enemy->h = stof(value);
}
else if (var == "x")
{
enemy->x = std::stof(value) * BLOCK;
enemy->x = stof(value) * BLOCK;
}
else if (var == "y")
{
enemy->y = std::stof(value) * BLOCK;
enemy->y = stof(value) * BLOCK;
}
else if (var == "vx")
{
enemy->vx = std::stof(value);
enemy->vx = stof(value);
}
else if (var == "vy")
{
enemy->vy = std::stof(value);
enemy->vy = stof(value);
}
else if (var == "x1")
{
enemy->x1 = std::stoi(value) * BLOCK;
enemy->x1 = stoi(value) * BLOCK;
}
else if (var == "x2")
{
enemy->x2 = std::stoi(value) * BLOCK;
enemy->x2 = stoi(value) * BLOCK;
}
else if (var == "y1")
{
enemy->y1 = std::stoi(value) * BLOCK;
enemy->y1 = stoi(value) * BLOCK;
}
else if (var == "y2")
{
enemy->y2 = std::stoi(value) * BLOCK;
enemy->y2 = stoi(value) * BLOCK;
}
else if (var == "flip")
@@ -332,7 +332,7 @@ bool setEnemy(enemy_t *enemy, std::string var, std::string value)
else if (var == "frame")
{
enemy->frame = std::stoi(value);
enemy->frame = stoi(value);
}
else if (var == "[/enemy]" || var == "tileSetFile" || var.substr(0, 1) == "#")
@@ -348,7 +348,7 @@ bool setEnemy(enemy_t *enemy, std::string var, std::string value)
}
// Asigna variables a una estructura item_t
bool setItem(item_t *item, std::string var, std::string value)
bool setItem(item_t *item, string var, string value)
{
// Indicador de éxito en la asignación
bool success = true;
@@ -360,22 +360,22 @@ bool setItem(item_t *item, std::string var, std::string value)
else if (var == "counter")
{
item->counter = std::stoi(value);
item->counter = stoi(value);
}
else if (var == "x")
{
item->x = std::stof(value) * BLOCK;
item->x = stof(value) * BLOCK;
}
else if (var == "y")
{
item->y = std::stof(value) * BLOCK;
item->y = stof(value) * BLOCK;
}
else if (var == "tile")
{
item->tile = std::stof(value);
item->tile = stof(value);
}
else if (var == "[/item]")
@@ -478,7 +478,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o
{
if (options->console)
{
std::cout << "Error: mapTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
cout << "Error: mapTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
}
}
SDL_SetTextureBlendMode(mapTexture, SDL_BLENDMODE_BLEND);
@@ -514,7 +514,7 @@ Room::~Room()
}
// Devuelve el nombre de la habitación
std::string Room::getName()
string Room::getName()
{
return name;
}
@@ -723,7 +723,7 @@ void Room::update()
}
// Devuelve la cadena del fichero de la habitación contigua segun el borde
std::string Room::getRoom(int border)
string Room::getRoom(int border)
{
switch (border)
{
@@ -897,13 +897,13 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
// Calcula la base del tile
int base = ((p.y / tileSize) * tileSize) + tileSize;
#ifdef DEBUG
debug->add("BASE = " + std::to_string(base));
debug->add("BASE = " + to_string(base));
#endif
// Calcula cuanto se ha entrado en el tile horizontalmente
const int pos = (p.x % tileSize); // Esto da un valor entre 0 y 7
#ifdef DEBUG
debug->add("POS = " + std::to_string(pos));
debug->add("POS = " + to_string(pos));
#endif
// Se resta a la base la cantidad de pixeles pos en funcion de la rampa
@@ -911,14 +911,14 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
{
base -= pos + 1;
#ifdef DEBUG
debug->add("BASE_R = " + std::to_string(base));
debug->add("BASE_R = " + to_string(base));
#endif
}
else
{
base -= (tileSize - pos);
#ifdef DEBUG
debug->add("BASE_L = " + std::to_string(base));
debug->add("BASE_L = " + to_string(base));
#endif
}
@@ -928,7 +928,7 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
// Calcula las superficies inferiores
void Room::setBottomSurfaces()
{
std::vector<int> tile;
vector<int> tile;
// Busca todos los tiles de tipo muro que no tengan debajo otro muro
// Hay que recorrer la habitación por filas (excepto los de la última fila)
@@ -991,7 +991,7 @@ void Room::setBottomSurfaces()
// Calcula las superficies superiores
void Room::setTopSurfaces()
{
std::vector<int> tile;
vector<int> tile;
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
// Hay que recorrer la habitación por filas (excepto los de la primera fila)
@@ -1054,7 +1054,7 @@ void Room::setTopSurfaces()
// Calcula las superficies laterales izquierdas
void Room::setLeftSurfaces()
{
std::vector<int> tile;
vector<int> tile;
// Busca todos los tiles de tipo muro que no tienen a su izquierda un tile de tipo muro
// Hay que recorrer la habitación por columnas (excepto los de la primera columna)
@@ -1102,7 +1102,7 @@ void Room::setLeftSurfaces()
// Calcula las superficies laterales derechas
void Room::setRightSurfaces()
{
std::vector<int> tile;
vector<int> tile;
// Busca todos los tiles de tipo muro que no tienen a su derecha un tile de tipo muro
// Hay que recorrer la habitación por columnas (excepto los de la última columna)
@@ -1151,7 +1151,7 @@ void Room::setRightSurfaces()
void Room::setLeftSlopes()
{
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
std::vector<int> found;
vector<int> found;
for (int i = 0; i < (int)tileMap.size(); ++i)
{
if (getTile(i) == t_slope_l)
@@ -1192,7 +1192,7 @@ void Room::setLeftSlopes()
void Room::setRightSlopes()
{
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
std::vector<int> found;
vector<int> found;
for (int i = 0; i < (int)tileMap.size(); ++i)
{
if (getTile(i) == t_slope_r)
@@ -1232,7 +1232,7 @@ void Room::setRightSlopes()
// Calcula las superficies automaticas
void Room::setAutoSurfaces()
{
std::vector<int> tile;
vector<int> tile;
// Busca todos los tiles de tipo animado
// Hay que recorrer la habitación por filas (excepto los de la primera fila)