Pink Petal Games

Game Discussion => General Discussion & Download => Topic started by: Anon21 on August 16, 2011, 03:39:20 PM

Title: Strange code
Post by: Anon21 on August 16, 2011, 03:39:20 PM
By the look of it that 'return' can never be reached.

Code: [Select]
void cFont::RenderText(string text, bool multi)
{
...
    m_Message = 0;

    if((m_Message != 0) && (text == ""))
        return;

[EDIT] Also I think the next bit of code doesn't work unless / is replaced by \\

Code: [Select]
bool CSurface::DrawSurface(int x, int y, SDL_Surface* destination, SDL_Rect* clip, bool resize, bool maintainRatio)
{
    double scaleX = 0;
    double scaleY = 0;

/*
 *    bit of a kludge to stop buttons with a missing
 *    disabled image from spamming the log file
 */
    if(m_Filename == "./Resources/Buttons/") {
        return false;
    }
Title: Re: Strange code
Post by: DocClox on August 18, 2011, 05:51:28 PM
By the look of it that 'return' can never be reached.

Code: [Select]
void cFont::RenderText(string text, bool multi)
{
...
    m_Message = 0;

    if((m_Message != 0) && (text == ""))
        return;


Yep, looks like you're right

[EDIT] Also I think the next bit of code doesn't work unless / is replaced by \\

Code: [Select]
bool CSurface::DrawSurface(int x, int y, SDL_Surface* destination, SDL_Rect* clip, bool resize, bool maintainRatio)
{
    double scaleX = 0;
    double scaleY = 0;

/*
 *    bit of a kludge to stop buttons with a missing
 *    disabled image from spamming the log file
 */
    if(m_Filename == "./Resources/Buttons/") {
        return false;
    }

Strictly, all paths ought to be build using DirPath and friends. That way we get code that can run on Linux and (hopefully) Macs.

And yeah, mea culpa for that one :)
Title: Re: Strange code
Post by: Anon21 on August 18, 2011, 09:05:54 PM
That way we get code that can run on Linux and (hopefully) Macs.

Good point. I've broken that idea a lot so I should go redo some code now.