forked from jaildesigner-jailgames/jaildoctors_dilemma
Revert "Eliminados todos los std:: del código"
This reverts commit 4a2d27dc59.
This commit is contained in:
116
source/room.cpp
116
source/room.cpp
@@ -4,34 +4,34 @@
|
||||
#include <sstream>
|
||||
|
||||
// Carga las variables y texturas desde un fichero de mapa de tiles
|
||||
vector<int> loadRoomTileFile(string file_path, bool verbose)
|
||||
std::vector<int> loadRoomTileFile(std::string file_path, bool verbose)
|
||||
{
|
||||
vector<int> tileMapFile;
|
||||
const string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
string line;
|
||||
ifstream file(file_path);
|
||||
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);
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
while (getline(file, line))
|
||||
while (std::getline(file, line))
|
||||
{ // Lee el fichero linea a linea
|
||||
if (line.find("data encoding") != string::npos)
|
||||
if (line.find("data encoding") != std::string::npos)
|
||||
{
|
||||
// Lee la primera linea
|
||||
getline(file, line);
|
||||
std::getline(file, line);
|
||||
while (line != "</data>")
|
||||
{ // Procesa lineas mientras haya
|
||||
stringstream ss(line);
|
||||
string tmp;
|
||||
std::stringstream ss(line);
|
||||
std::string tmp;
|
||||
while (getline(ss, tmp, ','))
|
||||
{
|
||||
tileMapFile.push_back(stoi(tmp) - 1);
|
||||
tileMapFile.push_back(std::stoi(tmp) - 1);
|
||||
}
|
||||
|
||||
// Lee la siguiente linea
|
||||
getline(file, line);
|
||||
std::getline(file, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ vector<int> loadRoomTileFile(string file_path, bool verbose)
|
||||
// Cierra el fichero
|
||||
if (verbose)
|
||||
{
|
||||
cout << "TileMap loaded: " << filename.c_str() << endl;
|
||||
std::cout << "TileMap loaded: " << filename.c_str() << std::endl;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ vector<int> loadRoomTileFile(string file_path, bool verbose)
|
||||
{ // El fichero no se puede abrir
|
||||
if (verbose)
|
||||
{
|
||||
cout << "Warning: Unable to open " << filename.c_str() << " file" << endl;
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,24 +56,24 @@ vector<int> loadRoomTileFile(string file_path, bool verbose)
|
||||
}
|
||||
|
||||
// Carga las variables desde un fichero de mapa
|
||||
room_t loadRoomFile(string file_path, bool verbose)
|
||||
room_t loadRoomFile(std::string file_path, bool verbose)
|
||||
{
|
||||
room_t room;
|
||||
room.itemColor1 = "yellow";
|
||||
room.itemColor2 = "magenta";
|
||||
room.autoSurfaceDirection = 1;
|
||||
|
||||
const string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
room.number = fileName.substr(0, fileName.find_last_of("."));
|
||||
|
||||
string line;
|
||||
ifstream file(file_path);
|
||||
std::string line;
|
||||
std::ifstream file(file_path);
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
while (getline(file, line))
|
||||
while (std::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(string file_path, bool verbose)
|
||||
|
||||
do
|
||||
{
|
||||
getline(file, line);
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
@@ -96,7 +96,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
|
||||
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
} while (line != "[/enemy]");
|
||||
@@ -115,7 +115,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
|
||||
do
|
||||
{
|
||||
getline(file, line);
|
||||
std::getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
@@ -125,7 +125,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
|
||||
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
|
||||
std::cout << "Warning: file " << fileName.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
// Cierra el fichero
|
||||
if (verbose)
|
||||
{
|
||||
cout << "Room loaded: " << fileName.c_str() << endl;
|
||||
std::cout << "Room loaded: " << fileName.c_str() << std::endl;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@@ -162,7 +162,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
else
|
||||
{
|
||||
{
|
||||
cout << "Warning: Unable to open " << fileName.c_str() << " file" << endl;
|
||||
std::cout << "Warning: Unable to open " << fileName.c_str() << " file" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ room_t loadRoomFile(string file_path, bool verbose)
|
||||
}
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
bool setVars(room_t *room, string var, string value)
|
||||
bool setVars(room_t *room, std::string var, std::string value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
@@ -255,7 +255,7 @@ bool setVars(room_t *room, string var, string value)
|
||||
}
|
||||
|
||||
// Asigna variables a una estructura enemy_t
|
||||
bool setEnemy(enemy_t *enemy, string var, string value)
|
||||
bool setEnemy(enemy_t *enemy, std::string var, std::string value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
@@ -267,52 +267,52 @@ bool setEnemy(enemy_t *enemy, string var, string value)
|
||||
|
||||
else if (var == "width")
|
||||
{
|
||||
enemy->w = stof(value);
|
||||
enemy->w = std::stof(value);
|
||||
}
|
||||
|
||||
else if (var == "height")
|
||||
{
|
||||
enemy->h = stof(value);
|
||||
enemy->h = std::stof(value);
|
||||
}
|
||||
|
||||
else if (var == "x")
|
||||
{
|
||||
enemy->x = stof(value) * BLOCK;
|
||||
enemy->x = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "y")
|
||||
{
|
||||
enemy->y = stof(value) * BLOCK;
|
||||
enemy->y = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "vx")
|
||||
{
|
||||
enemy->vx = stof(value);
|
||||
enemy->vx = std::stof(value);
|
||||
}
|
||||
|
||||
else if (var == "vy")
|
||||
{
|
||||
enemy->vy = stof(value);
|
||||
enemy->vy = std::stof(value);
|
||||
}
|
||||
|
||||
else if (var == "x1")
|
||||
{
|
||||
enemy->x1 = stoi(value) * BLOCK;
|
||||
enemy->x1 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "x2")
|
||||
{
|
||||
enemy->x2 = stoi(value) * BLOCK;
|
||||
enemy->x2 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "y1")
|
||||
{
|
||||
enemy->y1 = stoi(value) * BLOCK;
|
||||
enemy->y1 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "y2")
|
||||
{
|
||||
enemy->y2 = stoi(value) * BLOCK;
|
||||
enemy->y2 = std::stoi(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "flip")
|
||||
@@ -332,7 +332,7 @@ bool setEnemy(enemy_t *enemy, string var, string value)
|
||||
|
||||
else if (var == "frame")
|
||||
{
|
||||
enemy->frame = stoi(value);
|
||||
enemy->frame = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "[/enemy]" || var == "tileSetFile" || var.substr(0, 1) == "#")
|
||||
@@ -348,7 +348,7 @@ bool setEnemy(enemy_t *enemy, string var, string value)
|
||||
}
|
||||
|
||||
// Asigna variables a una estructura item_t
|
||||
bool setItem(item_t *item, string var, string value)
|
||||
bool setItem(item_t *item, std::string var, std::string value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
@@ -360,22 +360,22 @@ bool setItem(item_t *item, string var, string value)
|
||||
|
||||
else if (var == "counter")
|
||||
{
|
||||
item->counter = stoi(value);
|
||||
item->counter = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "x")
|
||||
{
|
||||
item->x = stof(value) * BLOCK;
|
||||
item->x = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "y")
|
||||
{
|
||||
item->y = stof(value) * BLOCK;
|
||||
item->y = std::stof(value) * BLOCK;
|
||||
}
|
||||
|
||||
else if (var == "tile")
|
||||
{
|
||||
item->tile = stof(value);
|
||||
item->tile = std::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)
|
||||
{
|
||||
cout << "Error: mapTexture could not be created!\nSDL Error: " << SDL_GetError() << endl;
|
||||
std::cout << "Error: mapTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
SDL_SetTextureBlendMode(mapTexture, SDL_BLENDMODE_BLEND);
|
||||
@@ -514,7 +514,7 @@ Room::~Room()
|
||||
}
|
||||
|
||||
// Devuelve el nombre de la habitación
|
||||
string Room::getName()
|
||||
std::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
|
||||
string Room::getRoom(int border)
|
||||
std::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 = " + to_string(base));
|
||||
debug->add("BASE = " + std::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 = " + to_string(pos));
|
||||
debug->add("POS = " + std::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 = " + to_string(base));
|
||||
debug->add("BASE_R = " + std::to_string(base));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
base -= (tileSize - pos);
|
||||
#ifdef DEBUG
|
||||
debug->add("BASE_L = " + to_string(base));
|
||||
debug->add("BASE_L = " + std::to_string(base));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -928,7 +928,7 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
|
||||
// Calcula las superficies inferiores
|
||||
void Room::setBottomSurfaces()
|
||||
{
|
||||
vector<int> tile;
|
||||
std::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()
|
||||
{
|
||||
vector<int> tile;
|
||||
std::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()
|
||||
{
|
||||
vector<int> tile;
|
||||
std::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()
|
||||
{
|
||||
vector<int> tile;
|
||||
std::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
|
||||
vector<int> found;
|
||||
std::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
|
||||
vector<int> found;
|
||||
std::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()
|
||||
{
|
||||
vector<int> tile;
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo animado
|
||||
// Hay que recorrer la habitación por filas (excepto los de la primera fila)
|
||||
|
||||
Reference in New Issue
Block a user