CODE
void saveRoom()
{
/*
13 items
14 monsters
15 <value> door name
16 hasBeenExplored?
17 hasBeenSearched?
18 hasMonsterPresent?
*/
int index;
int x = -1000, y = -1000, z = -1000;
apstring dummy;
fstream ioFile;
apstring fileName = "Data";
ioFile.open(fileName.c_str(), ios: :out | ios::in);
if (ioFile.fail())
{
cout << "ioFile failed." << endl;
ofstream outFile;
outFile.open("Data");
outFile << "****ing well work!" << endl;
outFile.close;
ioFile.open(fileName.c_str(), ios: :out | ios::in);
}
while ((!ioFile.fail()) && (!ioFile.eof()) && ((coordX != x) || (coordY != y) || (coordZ != z)))
{
cout << "enter while loop" << endl;
ioFile >> index;
//cout << "index: " << index << endl;
if (index == 1)
{
ioFile >> x >> y >> z;
getline (ioFile, dummy);
//cout << "X: " << coordX << " Y: " << coordY << " Z: " << coordZ << endl;
//cout << dummy << endl;
}
else
{
getline (ioFile, dummy);
//cout << dummy << "else" << endl;
}
//cin.get();
}
if (!ioFile.eof() && !ioFile.fail())
{
cout << "enter if the file exists and we're not at the end of it" << endl;
// room description
ioFile >> index;
ioFile.get();
ioFile << description;
for (int z = 0; z < 255 - description.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// search description
ioFile >> index;
ioFile.get();
ioFile << searchMsg;
for (int z = 0; z < 255 - searchMsg.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the north
ioFile >> index;
ioFile.get();
ioFile << errorMsg[north];
for (int z = 0; z < 255 - errorMsg[north].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the south
ioFile >> index;
ioFile.get();
ioFile << errorMsg[south];
for (int z = 0; z < 255 - errorMsg[south].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the east
ioFile >> index;
ioFile.get();
ioFile << errorMsg[east];
for (int z = 0; z < 255 - errorMsg[east].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the west
ioFile >> index;
ioFile.get();
ioFile << errorMsg[west];
for (int z = 0; z < 255 - errorMsg[west].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error down
ioFile >> index;
ioFile.get();
ioFile << errorMsg[down];
for (int z = 0; z < 255 - errorMsg[down].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error up
ioFile >> index;
ioFile.get();
ioFile << errorMsg[up];
for (int z = 0; z < 255 - errorMsg[up].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// room graphic title (on enter)
ioFile >> index;
ioFile.get();
ioFile << onEnterRoom;
for (int z = 0; z < 30 - onEnterRoom.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// onMonstersDeath graphic title
ioFile >> index;
ioFile.get();
ioFile << onMonstersDeath;
for (int z = 0; z < 30 - onMonstersDeath.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// search graphic title
ioFile >> index;
ioFile.get();
ioFile << onExamineRoom;
for (int z = 0; z < 30 - onExamineRoom.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// item saving
int counter = 0;
while (counter < MAX_NUM)
{
ioFile >> index;
ioFile.get();
ioFile << itemName[counter];
for (int z = 0; z < 30 - itemName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
}
// monster saving
counter = 0;
while (counter < MAX_NUM)
{
ioFile >> index;
ioFile.get();
ioFile << monsterName[counter];
for (int z = 0; z < 30 - monsterName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
}
// door saving
ioFile >> index;
ioFile.get();
ioFile << doorKey << " " << door;
for (int z = 0; z < 30 - door.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
/*
// hasBeenExplored
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.explored[a][b][c];
ioFile.get();
// has been searched
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.searched[a][b][c];
ioFile.get();
//monstersPresent? <-- dunno why I need to do this, maybe I don't remember the code
// that sets the variable..thought it just checked to see if there was a monster, and
// an if regulated the map output later
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.monsterPresent[a][b][c];
ioFile.get();*/
}// end if !eof
else
{
cout << "entered else statement." << endl;
ioFile << ios::app;
// output room coords
ioFile << 1 << " ";
ioFile << x << " " << y << " " << z << " " << endl;
cout << "end room coords." << endl;
// room description
ioFile << 2;
ioFile << " ";
ioFile << description;
for (int z = 0; z < 255 - description.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end room description" << endl;
// search description
ioFile << 3;
ioFile << " ";
ioFile << searchMsg;
for (int z = 0; z < 255 - searchMsg.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end search description" << endl;
// error to the north
ioFile << 4;
ioFile << " ";
ioFile << errorMsg[north];
for (int z = 0; z < 255 - errorMsg[north].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error north" << endl;
// error to the south
ioFile << 5;
ioFile << " ";
ioFile << errorMsg[south];
for (int z = 0; z < 255 - errorMsg[south].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error south." << endl;
// error to the east
ioFile << 6;
ioFile << " ";
ioFile << errorMsg[east];
for (int z = 0; z < 255 - errorMsg[east].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error east" << endl;
// error to the west
ioFile << 7;
ioFile << " ";
ioFile << errorMsg[west];
for (int z = 0; z < 255 - errorMsg[west].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error west" << endl;
// error down
ioFile << 8;
ioFile << " ";
ioFile << errorMsg[down];
for (int z = 0; z < 255 - errorMsg[down].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error down" << endl;
// error up
ioFile << 9;
ioFile << " ";
ioFile << errorMsg[up];
for (int z = 0; z < 255 - errorMsg[up].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error up" << endl;
// room graphic title (on enter)
ioFile << 10;
ioFile << " ";
ioFile << onEnterRoom;
for (int z = 0; z < 30 - onEnterRoom.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end enter room" << endl;
// onMonstersDeath graphic title
ioFile << 11;
ioFile << " ";
ioFile << onMonstersDeath;
for (int z = 0; z < 30 - onMonstersDeath.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end on monster death" << endl;
// search graphic title
ioFile << 12;
ioFile << " ";
ioFile << onExamineRoom;
for (int z = 0; z < 30 - onExamineRoom.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end examine room" << endl;
// item saving
int counter = 0;
while (counter < MAX_NUM)
{
ioFile << 13;
ioFile << " ";
ioFile << itemName[counter];
for (int z = 0; z < 30 - itemName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
counter++;
}
cout << "end item saving" << endl;
// monster saving
counter = 0;
while (counter < MAX_NUM)
{
ioFile << 14;
ioFile << " ";
ioFile << monsterName[counter];
for (int z = 0; z < 30 - monsterName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
counter++;
}
cout << "end monster saving" << endl;
// door saving
ioFile << 15;
ioFile << " ";
ioFile << doorKey << " " << door;
for (int z = 0; z < 30 - door.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end door" << endl;
/////////////////////////////////////////////////////
////////////////////////////////////////////////////////
} // end else
{
/*
13 items
14 monsters
15 <value> door name
16 hasBeenExplored?
17 hasBeenSearched?
18 hasMonsterPresent?
*/
int index;
int x = -1000, y = -1000, z = -1000;
apstring dummy;
fstream ioFile;
apstring fileName = "Data";
ioFile.open(fileName.c_str(), ios: :out | ios::in);
if (ioFile.fail())
{
cout << "ioFile failed." << endl;
ofstream outFile;
outFile.open("Data");
outFile << "****ing well work!" << endl;
outFile.close;
ioFile.open(fileName.c_str(), ios: :out | ios::in);
}
while ((!ioFile.fail()) && (!ioFile.eof()) && ((coordX != x) || (coordY != y) || (coordZ != z)))
{
cout << "enter while loop" << endl;
ioFile >> index;
//cout << "index: " << index << endl;
if (index == 1)
{
ioFile >> x >> y >> z;
getline (ioFile, dummy);
//cout << "X: " << coordX << " Y: " << coordY << " Z: " << coordZ << endl;
//cout << dummy << endl;
}
else
{
getline (ioFile, dummy);
//cout << dummy << "else" << endl;
}
//cin.get();
}
if (!ioFile.eof() && !ioFile.fail())
{
cout << "enter if the file exists and we're not at the end of it" << endl;
// room description
ioFile >> index;
ioFile.get();
ioFile << description;
for (int z = 0; z < 255 - description.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// search description
ioFile >> index;
ioFile.get();
ioFile << searchMsg;
for (int z = 0; z < 255 - searchMsg.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the north
ioFile >> index;
ioFile.get();
ioFile << errorMsg[north];
for (int z = 0; z < 255 - errorMsg[north].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the south
ioFile >> index;
ioFile.get();
ioFile << errorMsg[south];
for (int z = 0; z < 255 - errorMsg[south].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the east
ioFile >> index;
ioFile.get();
ioFile << errorMsg[east];
for (int z = 0; z < 255 - errorMsg[east].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error to the west
ioFile >> index;
ioFile.get();
ioFile << errorMsg[west];
for (int z = 0; z < 255 - errorMsg[west].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error down
ioFile >> index;
ioFile.get();
ioFile << errorMsg[down];
for (int z = 0; z < 255 - errorMsg[down].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// error up
ioFile >> index;
ioFile.get();
ioFile << errorMsg[up];
for (int z = 0; z < 255 - errorMsg[up].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// room graphic title (on enter)
ioFile >> index;
ioFile.get();
ioFile << onEnterRoom;
for (int z = 0; z < 30 - onEnterRoom.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// onMonstersDeath graphic title
ioFile >> index;
ioFile.get();
ioFile << onMonstersDeath;
for (int z = 0; z < 30 - onMonstersDeath.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// search graphic title
ioFile >> index;
ioFile.get();
ioFile << onExamineRoom;
for (int z = 0; z < 30 - onExamineRoom.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
// item saving
int counter = 0;
while (counter < MAX_NUM)
{
ioFile >> index;
ioFile.get();
ioFile << itemName[counter];
for (int z = 0; z < 30 - itemName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
}
// monster saving
counter = 0;
while (counter < MAX_NUM)
{
ioFile >> index;
ioFile.get();
ioFile << monsterName[counter];
for (int z = 0; z < 30 - monsterName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile.get();
}
// door saving
ioFile >> index;
ioFile.get();
ioFile << doorKey << " " << door;
for (int z = 0; z < 30 - door.length(); z++)
{
ioFile << "ø";
}
ioFile.get();
/*
// hasBeenExplored
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.explored[a][b][c];
ioFile.get();
// has been searched
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.searched[a][b][c];
ioFile.get();
//monstersPresent? <-- dunno why I need to do this, maybe I don't remember the code
// that sets the variable..thought it just checked to see if there was a monster, and
// an if regulated the map output later
ioFile >> index;
ioFile.get();
ioFile << rooms.aRoom.monsterPresent[a][b][c];
ioFile.get();*/
}// end if !eof
else
{
cout << "entered else statement." << endl;
ioFile << ios::app;
// output room coords
ioFile << 1 << " ";
ioFile << x << " " << y << " " << z << " " << endl;
cout << "end room coords." << endl;
// room description
ioFile << 2;
ioFile << " ";
ioFile << description;
for (int z = 0; z < 255 - description.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end room description" << endl;
// search description
ioFile << 3;
ioFile << " ";
ioFile << searchMsg;
for (int z = 0; z < 255 - searchMsg.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end search description" << endl;
// error to the north
ioFile << 4;
ioFile << " ";
ioFile << errorMsg[north];
for (int z = 0; z < 255 - errorMsg[north].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error north" << endl;
// error to the south
ioFile << 5;
ioFile << " ";
ioFile << errorMsg[south];
for (int z = 0; z < 255 - errorMsg[south].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error south." << endl;
// error to the east
ioFile << 6;
ioFile << " ";
ioFile << errorMsg[east];
for (int z = 0; z < 255 - errorMsg[east].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error east" << endl;
// error to the west
ioFile << 7;
ioFile << " ";
ioFile << errorMsg[west];
for (int z = 0; z < 255 - errorMsg[west].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error west" << endl;
// error down
ioFile << 8;
ioFile << " ";
ioFile << errorMsg[down];
for (int z = 0; z < 255 - errorMsg[down].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error down" << endl;
// error up
ioFile << 9;
ioFile << " ";
ioFile << errorMsg[up];
for (int z = 0; z < 255 - errorMsg[up].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end error up" << endl;
// room graphic title (on enter)
ioFile << 10;
ioFile << " ";
ioFile << onEnterRoom;
for (int z = 0; z < 30 - onEnterRoom.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end enter room" << endl;
// onMonstersDeath graphic title
ioFile << 11;
ioFile << " ";
ioFile << onMonstersDeath;
for (int z = 0; z < 30 - onMonstersDeath.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end on monster death" << endl;
// search graphic title
ioFile << 12;
ioFile << " ";
ioFile << onExamineRoom;
for (int z = 0; z < 30 - onExamineRoom.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end examine room" << endl;
// item saving
int counter = 0;
while (counter < MAX_NUM)
{
ioFile << 13;
ioFile << " ";
ioFile << itemName[counter];
for (int z = 0; z < 30 - itemName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
counter++;
}
cout << "end item saving" << endl;
// monster saving
counter = 0;
while (counter < MAX_NUM)
{
ioFile << 14;
ioFile << " ";
ioFile << monsterName[counter];
for (int z = 0; z < 30 - monsterName[counter].length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
counter++;
}
cout << "end monster saving" << endl;
// door saving
ioFile << 15;
ioFile << " ";
ioFile << doorKey << " " << door;
for (int z = 0; z < 30 - door.length(); z++)
{
ioFile << "ø";
}
ioFile << endl;
cout << "end door" << endl;
/////////////////////////////////////////////////////
////////////////////////////////////////////////////////
} // end else
If only that would work...
I've spent the past few hours on that, and related, FoDN (see sig) code. Gods, but I wish my original design would have worked. For some damned reason, ioFile won't output to the file. ****ing A.
------------------
Fortress of Die Nacht: An upcoming game from Aviary Productions.
Go take a look! | FoDN Progress Log
[This message has been edited by theGlueBubble (edited 11-05-2001).]

