Hey guys, I'm working on a program that will randomly generate a mapcycle.txt file for Counter-Strike so that when it's run, it creates a list that has no repeated members. I keep getting an error in my Client file everytime I call the functions in my Class. Anyone have any ideas?
//-------------------------------------------------------//
// NAME: Christopher Jackson //
//-------------------------------------------------------//
//-------------------------------------------------------------------------------// Counter-Strike Map Randomizer
// CLIENT FILE
// DESCRIPTION: Randomizes map names for the multiplayer
// Counter-Strike map cycle list
//-------------------------------------------------------------------------------
#include "List.h"
#include <fstream>
using namespace std;
int main()
{
List cstrike;
ofstream fileout;
fileout.open("mapcycle.txt");
bool tempTruth = cstrike.IsFull();
while(!tempTruth)
{
int random = cstrike.RandomNumber();
switch(random)
{
case 1 : fileout << "cs_747" << endl; break;
case 2 : fileout << "cs_italy" << endl; break;
case 3 : fileout << "cs_backalley" << endl; break;
case 4 : fileout << "cs_office" << endl; break;
case 5 : fileout << "cs_militia" << endl; break;
case 6 : fileout << "cs_assault" << endl; break;
case 7 : fileout << "cs_siege" << endl; break;
case 8 : fileout << "de_dust" << endl; break;
case 9 : fileout << "de_vegas" << endl; break;
case 10 : fileout << "de_inferno" << endl; break;
case 11 : fileout << "de_train" << endl; break;
case 12 : fileout << "de_prodigy" << endl; break;
case 13 : fileout << "de_cbble" << endl; break;
case 14 : fileout << "de_dust2" << endl; break;
case 15 : fileout << "de_aztec" << endl; break;
case 16 : fileout << "de_vertigo" << endl; break;
case 17 : fileout << "de_storm" << endl; break;
case 18 : fileout << "de_torn" << endl; break;
case 19 : fileout << "de_survivor" << endl; break;
default: fileout << "* ERROR IN CODE *"; break;
}
}
fileout.close();
return 0;
}
//------------------------------------------------------------------------------
// Counter-Strike Map Randomizer
// IMPLEMENTATION FILE
// DESCRIPTION: Randomizes map names for the multiplayer
// Counter-Strike map cycle list
//------------------------------------------------------------------------------
#include "List.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
List::List()
{
length = 0;
}
//-----------------------------------------------------------------------------
bool List::IsFull() const
{
return (length == MAX_LENGTH);
}
//-----------------------------------------------------------------------------
void List::Insert(/*in*/ ItemType item)
{
data[length] = item;
length++;
}
//-----------------------------------------------------------------------------
bool List::IsPresent(/*in*/ ItemType item) const
{
int index = 0;
while (index < length && item != data[index])
index++;
return (index < length);
}
//----------------------------------------------------------------------------
int List::RandomNumber()
{
int tempRandom;
srand(time(NULL));
do
{
tempRandom = rand()%19+1;
}
while (IsPresent(tempRandom));
Insert(tempRandom);
return tempRandom;
}
Thanks to all of you who read this far.