I'm trying to load from a temporary hand made data file that I'm using for testing. I recently reworked this code and suddenly it doesn't work. I marked a position in the code which I've found through extensive testing. When the for loop has looped five times, the program suddenly STOPS. No error message, no crash, it simply STOPS. I have no idea why and I'm yanking my hair out trying to get this to work.
charID and roomID are arrays I'm using to store pointers to objects of the Character and Room classes. Both classes are stripped down to accessors and mutators due to problems I've had, so they can't be the source of the problem. Can anyone see what's causing my very odd problem?
Here's the piece of code. I bolded the line that it dies on.
Code:
int id, intInput, numRooms, numItems;
string input;
cout << "Loading realm... ";
ifstream io(WORLD_FILE);
charID[0] = new Character;
io >> numRooms; //Number of Rooms
io >> ROOM_ITEM_LIMIT; //Max items per room
io >> intInput; //Starting Location
charID[0]->setLocation(intInput); //Set player position
io.ignore();
//Load Rooms
Room* newRoom;
for(int i = 0; i < numRooms; i++){
io >> id; //Room's ID
roomID[id] = new Room; //!!!*IT DIES HERE*!!!
io.ignore();
getline(io, input); //Room's Name
roomID[id]->setName(input);
getline(io, input); //Room's Description
roomID[id]->setDesc(input);
for(int dir = 0; dir < 12; dir++){ //Room's Exits
io >> input;
roomID[id]->setDirExit(dir, parseInt(input));
}
for(int i = 0; i < ROOM_ITEM_LIMIT; i++){ //Room's Items
io >> input;
roomID[id]->setItem(i, parseInt(input));
}
int count;
io >> count;
io.ignore();
roomID[id]->setItemCount(count);
}
Here's part of the data file I'm using. I've only included the data up to the point that it dies. I bolded the last piece of data the program loads before dieing.
12 5 3
0
Outpost
You are in the armory corner of the outpost. Scattered weapons and armor line the wall. The supply has obviously run short.
-1 -1 1 -1 3 -1 -1 -1 -1 -1 -1 -1
1 2 -1 -1 -1
2
1
Outpost
The tall watch tower stands in this otherwise empty corner. A barely stable ladder leads to the tower's observation post.
-1 -1 -1 -1 2 -1 0 -1 4 -1 -1 -1
-1 -1 -1 -1 -1
0
2
Outpost
The commander's office is settled in an out of the way section of the outpost. Directly across is a small barracks, which also serves as the dining hall.
1 -1 -1 -1 -1 -1 3 -1 -1 -1 5 -1
-1 -1 -1 -1 -1
0
3
Outpost
The gate of the outpost is guarded by a sentry in tattered leather armor leans against his spear, half asleep.
0 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1
3 -1 -1 -1 -1
1
4
Watch Tower
You can see far into the wilderness from here. The bored watchman is sharpening an arrowhead while leaning against a support beam.
-1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1
-1 -1 -1 -1 -1
0