Server Help

Bot Questions - Retard Quetion

50% Packetloss - Mon Mar 01, 2004 1:37 am
Post subject: Retard Quetion
Code: Show/Hide

Uint16 botInfo::FindFile(char *name)
{
   Uint16 Rank=0;
   Uint16 Lines=0;
   char FromFile[40];
   bool Success=false;

   ifstream infile("Ranks.bank",ios::in);
   while(infile.good())
   {
      infile.getline(FromFile,20,':');
      Lines++;
      if(CMPSTR(FromFile,name))
      {
          ofstream outfile("temp2.txt",ios::app);
         if(outfile.good())
         {
            Success=true;
            infile.getline(FromFile,10);
            Rank=getInteger(FromFile,10);
            
            infile.seekg(0,ios::beg);
            if(infile.eof())
            {infile.clear();}

            while(infile.good())
            {
               infile.getline(FromFile,40);
               Lines--;
               if(Lines!=0)
               {
                  if(FromFile[0]!='\0')
                  {outfile << FromFile << endl;}
               }
            }
         }
         outfile.close();
         break;
      }
      else
      {infile.ignore(256,'\n');}
   }
   infile.close();

   if(Success)
   {
      _unlink("Ranks.bank");
      rename("temp2.txt","Ranks.bank");
   }

   return Rank;
}


Ok I made a rank bot for a ctf game for DS and this is one of the functions. The idea was to not have to load the entire file into a linkedlist or keep a linklist full of people that arnt online at the time. oh, shit, my cat just farted on me...ok anyway. The job of the function is to just read a file, and once it finds the player's name in the file, it will delete that player's name out of the file and the return the player's rank #. The problem is that I dont know of any ways to delete lines out of a file. So i copy the file over to another file and skip over the part i dont want. Then rename the file/delete the old one.
I dont know if this is the best way to go about this, Im just looking for the best way to do it.
After the player leaves the arena, the player's name is added back into the file along with thier rank and then deleted from linklist.

Edit: removed comments from code. they were making it unreadable
Dr Brain - Mon Mar 01, 2004 9:24 am
Post subject:
*cough*MySQL*cough*
Cyan~Fire - Mon Mar 01, 2004 6:45 pm
Post subject:
Yep, methinks Brain's got it pinned.

What you're trying to do is a bit too ungainly doing it with just text.
50% Packetloss - Mon Mar 01, 2004 6:54 pm
Post subject:
<3
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group