Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » read gamelog from scripts.dll
Re: read gamelog from scripts.dll [message #205917 is a reply to message #205903] Wed, 28 June 2006 16:54 Go to previous messageGo to previous message
theplague is currently offline  theplague
Messages: 261
Registered: May 2004
Karma:
Recruit
well, heres a clue, you gotta do it line, by line. As in, everytime you read it, you gotta load the whole file, then set the position you wanna read from.

long last_line = 0;
ifstream gamelog("example_gamelog_name.txt"); // gamelog names do change, your gonna have to generate the correct names
if (gamelog.is_open()) {
  std::string line;
  gamelog.seekg (last_line, ios::beg); // puts it back to the last read position
  while (!gamelog.eof()) { // reads until the end of file is reached
    getline(gamelog,line); // saves a line into a string 'line' to do with as you wish
  }
  gamelog.seekg(0, ios::end); // sets the pointer to the last point in the file
  last_line = gamelog.tellg(); // saves the last point into the variable 'last_line'
} else {
  printf("Error occured, gamelog unreadable.\n");
}


and all this could be within a function and called every X time period, or whenever checking of new lines is needed.


http://users.tpg.com.au/ling44/av_firefox.gifhttp://users.tpg.com.au/ling44/av_rg.gif

[Updated on: Wed, 28 June 2006 16:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: function on launch
Next Topic: BuggyCross Founded Try it out today !!!!
Goto Forum:
  


Current Time: Tue Jul 16 23:43:51 MST 2024

Total time taken to generate the page: 0.00694 seconds