Skip to main content

News

Topic: I take back what I said about Sphere having nice code (Read 1498 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • miniSphere Developer
I take back what I said about Sphere having nice code
So, I use the Sphere source as reference material in order to keep minisphere's compatibility as high as possible, and I found this gem in the map loading logic:

Code: (cpp) [Select]
inline std::string ReadMapString(IFile* file)
{
    std::string s;
    word length = ReadMapWord(file);

    for (int i = 0; i < length; i++)
    {
        char c;
        file->Read(&c, 1);
        s += c;
    }
    return s;
}


It's the function that reads lstrings from an RMP map file.  Note that it reads the string one character at a time. :o

Sorry for the spam, just found this amusing and had to share it!

edit - changed code tag to syntax highlight +neo
  • Last Edit: March 07, 2015, 02:55:48 pm by N E O
miniSphere 5.2.13 - Cell compiler - SSj debugger - thread | on GitHub
For the sake of our continued health I very much hope that Fat Cerberus does not become skilled enough at whatever arcane art it would require to cause computers to spawn enourmous man eating pigs ~Rhuan

  • FBnil
  • [*][*]
Re: I take back what I said about Sphere having nice code
Reply #1
Ah, yes. Legacy code. we didnt touch it because it wasnt broken. However, feel free to change it in the main branch.
For good code, check out standard32.c optimal usage of quaternions, iirc.