Witam! Problem polega na tym, że podczas zapisu "dopisuje się" jedna postać, tzn. mam kod:

EntityManager klasa

void EntityManager::AddComponent(std::string name, EntityType type, SDL_Renderer *renderer)
{
	std::vector<std::vector<std::string>> attributes;
	std::vector<std::vector<std::string>> contents;

	std::vector<float> eX, eY, eMS, eRG, eMD, cRadius;

        //czytanie z pliku w zależności od "name"
	fileManager.LoadFromFile(name, attributes, contents, name);

	for (int i = 0; i < attributes.size(); i++)
	{
		for (int j = 0; j < attributes[i].size(); j++)
		{
			std::string att = attributes[i][j];
			std::string con = contents[i][j];

			float conf = atof(con.c_str());
			int coni = atoi(con.c_str());

			if (att == "x") eX.push_back(conf);
			else if (att == "y") eY.push_back(conf);
			else if (att == "ms") eMS.push_back(conf); // moveSpeed
			else if (att == "range") eRG.push_back(conf);
			else if (att == "moveDirection") eMD.push_back(coni);
			else if (att == "radius") cRadius.push_back(coni);
		}
	}

        // render przeciwników w zależności od ilości contentsów
	for (int i = 0; i < contents.size(); i++)
	{
		switch (type)
		{
			case human: ent[getList(eX[i])].push_back(new Human(eX[i], eY[i], eMS[i], eRG[i], eMD[i], renderer)); break;
			case cleaver: ent[getList(eX[i])].push_back(new Cleaver(eX[i], eY[i], cRadius[i], 0, eMD[i], renderer)); break;
		}
	}

	eX.clear(); eY.clear(), eMS.clear(), eRG.clear();
}

Plik tekstowy z którego czytam

Human:{x, y, ms, range, moveDirection} // <- name + attributes
209, 518, 2, 140, 1 // <- contents
1058, 518, 2, 250, 1
2270, 486, 2, 300, 1
2612, 486, 0, 800, 1
2737, 484, 0, 800, 1
Human; // <- oznacznik końca 

//Wyjaśnienie:
//Human - nazwa przeciwnika
//{różne zmienne} - wektor attributes, zmienne takie jak pozycja, prędkość itp.
//różne zmienne - wektor contents, przechowuje wartości zmiennych

I metoda która zapisuje:

void EntityManager::SaveToFile(std::string name, EntityType type)
{
	std::ofstream openFile("Files/Config/" + name + ".cfg");

	if (openFile.is_open())
	{
		openFile << name + ":";
		switch (type)
		{
			case human: openFile << "{x, y, ms, range, moveDirection}" << std::endl; break;
			case cleaver: openFile << "Cleaver : {x, y, radius, moveDirection}" << std::endl; break;
		}

		for (int j = 0; j < ent.size(); j++)
		{
			for (int k = 0; k < ent[j].size(); k++)
			{
				switch (type)
				{
					case human: 
						openFile << ent[j][k]->getX() << ", " << ent[j][k]->getY() << ", " << ent[j][k]->getVelX() << ", " << ent[j][k]->getRange() << ", " << ent[j][k]->getMoveDirection() << std::endl; 
						break;
					case cleaver:
						openFile << ent[j][k]->getX() << ", " << ent[j][k]->getY() << ", " << "------ Radius -----" << ", " << ent[j][k]->getMoveDirection() << std::endl;
						break;
				}
			}
		}
		openFile << name + ";" << std::endl;
	}
}

Medota w gameplayscreen

void GameplayScreen::LoadMapSDL_Renderer *renderer)
{
	ent.CreateEntity(map);
	ent.ClearEntity();
	
	this->pPosX = 100;
	this->pPosY = 300; 

        //wczytuje Human
	ent.AddComponent("Human", EntityManager::EntityType::human, renderer);
        // wczytuje tasak
	ent.AddComponent("Cleaver", EntityManager::EntityType::cleaver, renderer);
}

Gdy dam w komentarz jedną z tych dwóch linijek

case cleaver: ent[getList(eX[i])].push_back(new Cleaver(eX[i], eY[i], cRadius[i], 0, eMD[i], renderer)); break;
albo
ent.AddComponent("Cleaver", EntityManager::EntityType::cleaver, renderer);

czyli żeby wczytywał jednego przeciwnika, wszystko zapisuje się dobrze. Jednak gdy już chce żeby wczytał 2 przeciwników i zapisał tylko Human, do pliku tekstowego dopisuje się jedna postać, czyli po dopisaniu wygląda to tak:

Human:{x, y, ms, range, moveDirection}
50, 194, 0, -842150451, 1
327, 518, 2, 140, 1
1176, 518, 2, 250, 1
2388, 486, 2, 300, 1
2612, 486, 0, 800, 1
2737, 484, 0, 800, 1
Human;

Co może być tego problemem?
Jestem otwarty też na propozyje jak mógłbym zmienić ten kod.

Edit:
Aha i jeszcze jak wygląda zapis

//W klasie gameplayscreen
void GameplayScreen::SaveEntity(std::string name, EntityManager::EntityType type)
{
	ent.SaveToFile(name, type);
}
//I w klasie pauseMenu
void PauseScreen::Enter()
{
	switch (optionType)
	{
		case 3: 
			if (!saved)
			{
				System::getScreenManager()->GetGame()->SaveEntity("Human", EntityManager::EntityType::human);
				saved = true;
			}
			else
			{
				Config::getSM()->SetGameState(Config::getSM()->gsPauseMenu);
				saved = false;
			}
	}
}