Iccarus

Members
  • Content count

    91
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Iccarus

  • Rank
    Member
  1. Encryption problem

    No I just have no way of currently encrypting or skipping over this.
  2. I'm having a go at creating a basic encryption algorithm. It all works fine except if the script comes across a newline (\n). Is there anyway I can easily encrypt this? The system I'm using matches characters to an alphabet then uses a sorting algorithm to translate the character into its new form. Thanks for the help.
  3. If you want to do it in an array of somekind it might be worth doing: [tilex][tiley][function_number] where the function number is referenced to another file containing a list of all the functions on that map or globablly (with 0 being none)
  4. I am already just including <string>. I'm not using strcpy() (AFAIK - I'm pretty sure I've converted everything to c++ strings.)
  5. I've just got MS VS 2005 standard edition and have converted my project over from MS 2003.NET. When I try and compile it though I get 283 warnings of deprecated functions in the string.h class. Is there anything I can do to stop this?
  6. I don't think he's actually trapping them. Just asking them "Are you sure you want to leave?". That was my understanding at least.
  7. For me it's: Intellisense, Find and replace (through all files), Debugging, Block comment/uncomment. (I use MS VS.NET 2003) Block find and replace is good as well but not essential. (Sadly missing from VS :()
  8. Ok thanks I didn't know that. Anyone got any help with the problem though?
  9. I think I am (I'm using the default mode, I know it's not binary). I could understand it putting a line at the end but a line at the beginning seems wrong. Can anyone else help with this?
  10. After several months of developement I finally got bored of recompiling for every spelling mistake and have disengaged the, written, content into text files (it's a simple text based game). I'm having some trouble because it's adding newlines before every line it reads. The problem is that I wish to indent the text if it is a character speaking however this doesn't work because it indents at the end of the last line before the newline when I use: cout << " " << line; The code to read the files is: void ReadIn(PLAYER* player,string file, int anchor, bool speech) { ifstream in(file.data()); char* newline = new char[MAX_LINE_SIZE]; string name = "<name>"; string shorttitle = "<shorttitle>"; string longtitle = "<longtitle>"; string end = "<endread>"; string nline = "\n"; string blank = ""; string s_anchor = IntToString(anchor); string fullanchor = "<a="+s_anchor+">"; int anchorlocation = FindAnchor(file,anchor); in.seekg(anchorlocation); int i = 0; if (speech) { // Getname in.getline(newline,MAX_LINE_SIZE,'$'); string line = std::string(newline); //turn into type std::string line.append(":"); cout << line; } while(true) { /* Read in speech * If <end> appears break out of while * and return. * Before displaying to screen parse * to see if any special commands were used. * If they were execute them, then return. * Special commands * <name> - insert players name * <shorttitle> - insert players short title and name * <fulltitle> - insert players full title and name */ in.getline(newline,MAX_LINE_SIZE,'$'); string line = std::string(newline); //turn into type std::string for(i = line.find(name, 0); i != string::npos; i = line.find(name, i)) { string n = player->GetName(); line.erase(i,name.size()); line.insert(i,n); i++; // Move past the last discovered instance to avoid finding same } i = 0; for(i = line.find(longtitle, 0); i != string::npos; i = line.find(longtitle, i)) { string temptitle = GetFullTitle(player); line.erase(i,longtitle.size()); line.insert(i,temptitle); i++; // Move past the last discovered instance to avoid finding same } i = 0; i = line.find(end, 0); if (i != string::npos) { line.erase(i,end.size()); line.insert(i,blank); // Move past the last discovered instance to avoid finding same cout << line; break; } if (speech) { cout << " " << line; } else { cout << line; } } delete newline; in.close(); } Is the problem to do with using the "getline" function? Is there anything I can do to fix the problem? EDIT: Solved it with "ignore(INT_MAX,'\n');" [Edited by - Iccarus on April 29, 2006 11:40:46 PM]
  11. c++ File reading

    NVM. Fixed the problem.
  12. c++ File reading

    I'm trying to create a simple way of loading from files at an arbitrary point until a certain word is found. However after the first line it just continually gets blank lines when it should be getting more of the file. #define MAX_LINE_SIZE 91 // 90 for line, 1 for terminator void Exposition(PLAYER* player,string file, int lastline) { ifstream in(file.data());//,ios::binary); char* line = new char[MAX_LINE_SIZE]; string name = "<name>"; string shorttitle = "<shorttitle>"; string longtitle = "<longtitle>"; string end = "<endread>"; char* temp; char* tempname = new char[32]; char* templt = new char[100]; while(true) { /* Read in exposition * If <end> appears break out of while * and return. * Before displaying to screen parse * to see if any special commands were used. * If they were execute them, then return. * Special commands * <name> - insert players name * <shorttitle> - insert players short title and name * <fulltitle> - insert players full title and name */ // for substrings use strstr //seekg - goto position in file //tellg - get current position in file in.seekg(1,ios_base::cur); in.getline(line,MAX_LINE_SIZE,'$'); temp = strstr(line,name.c_str()); if (temp != NULL) { string n = player->GetName(); strcpy(tempname,n.c_str()); strncpy(temp,tempname,sizeof(tempname)); } temp = strstr(line,longtitle.c_str()); if (temp != NULL) { string temptitle = GetFullTitle(player); strcpy(templt,temptitle.c_str()); strncpy(temp,templt,sizeof(templt)); } cout << line << "\n\n"; temp = strstr(line,end.c_str); if (temp != NULL) { break; } } delete line; delete templt; delete tempname; in.close(); } this is the text file it's reading This is a test. I am <name>. jsdjkhjkdfhjk shjdshkjdskjs; this is testing multi line input 1 2 3 testing <endread> [Edited by - Iccarus on April 27, 2006 9:02:26 PM]
  13. Is it possible to start reading a file at a certain point? So instead of having lots of small files having one large one and passing the line number to the reader function.
  14. C++ tutorials with examples

    I highly suggest this: WRATH LANDS