Spherical forums

Sphere Development => Sphere General => Topic started by: Fat Cerberus on March 05, 2015, 11:47:29 pm

Title: I take back what I said about Sphere having nice code
Post by: Fat Cerberus on March 05, 2015, 11:47:29 pm
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
Title: Re: I take back what I said about Sphere having nice code
Post by: FBnil on June 07, 2015, 11:55:51 am
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.