devolution

Author Topic: Strange code  (Read 2648 times)

0 Members and 1 Guest are viewing this topic.

Offline Anon21

  • Full Member
  • ***
  • Posts: 244
Strange code
« 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;
    }
« Last Edit: August 16, 2011, 04:10:45 PM by Anon21 »

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: Strange code
« Reply #1 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 :)

Offline Anon21

  • Full Member
  • ***
  • Posts: 244
Re: Strange code
« Reply #2 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.