X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ac8bd7b5347c31a0f4ff53aa0a3fcaa54ecb5ca..2a45803fc3877afd0ae3ce356dfe216505165882:/demos/life/game.cpp?ds=sidebyside diff --git a/demos/life/game.cpp b/demos/life/game.cpp index 52c5111584..eefae2c2de 100644 --- a/demos/life/game.cpp +++ b/demos/life/game.cpp @@ -13,10 +13,6 @@ // headers, declarations, constants // ========================================================================== -#ifdef __GNUG__ - #pragma implementation "game.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -35,7 +31,7 @@ #include // for memset -#define ARRAYSIZE 1024 // static array for BeginFind & co. +#define CELLSARRAYSIZE 1024 // static array for BeginFind & co. #define ALLOCBOXES 16 // number of cellboxes to alloc at once #define MAXDEAD 8 // tics before removing cellbox from list @@ -75,9 +71,9 @@ public: bool LifeCellBox::IsAlive(int dx, int dy) const { if (dy > 3) - return (bool)(m_live2 & 1 << ((dy - 4) * 8 + dx)); + return (m_live2 & 1 << ((dy - 4) * 8 + dx)) ? true : false ; else - return (bool)(m_live1 & 1 << ((dy) * 8 + dx)); + return (m_live1 & 1 << ((dy) * 8 + dx)) ? true : false ; } // SetCell: @@ -114,9 +110,9 @@ bool LifeCellBox::SetCell(int dx, int dy, bool alive) Life::Life() { // pattern description - m_name = _(""); - m_rules = _(""); - m_description = _(""); + m_name = wxEmptyString; + m_rules = wxEmptyString; + m_description = wxEmptyString; // pattern data m_numcells = 0; @@ -127,7 +123,7 @@ Life::Life() m_boxes[i] = NULL; // state vars for BeginFind & FindMore - m_cells = new LifeCell[ARRAYSIZE]; + m_cells = new LifeCell[CELLSARRAYSIZE]; m_ncells = 0; m_findmore = false; m_changed = false; @@ -173,9 +169,9 @@ void Life::Clear() m_available = NULL; // reset state - m_name = _(""); - m_rules = _(""); - m_description = _(""); + m_name = wxEmptyString; + m_rules = wxEmptyString; + m_description = wxEmptyString; m_numcells = 0; } @@ -403,7 +399,7 @@ LifeCell Life::FindNorth() y = c->m_y; first = false; } - + LifeCell cell; cell.i = first? 0 : x + CELLBOX / 2; cell.j = first? 0 : y + CELLBOX / 2; @@ -423,7 +419,7 @@ LifeCell Life::FindSouth() y = c->m_y; first = false; } - + LifeCell cell; cell.i = first? 0 : x + CELLBOX / 2; cell.j = first? 0 : y + CELLBOX / 2; @@ -443,7 +439,7 @@ LifeCell Life::FindWest() y = c->m_y; first = false; } - + LifeCell cell; cell.i = first? 0 : x + CELLBOX / 2; cell.j = first? 0 : y + CELLBOX / 2; @@ -463,7 +459,7 @@ LifeCell Life::FindEast() y = c->m_y; first = false; } - + LifeCell cell; cell.i = first? 0 : x + CELLBOX / 2; cell.j = first? 0 : y + CELLBOX / 2; @@ -528,7 +524,7 @@ bool Life::FindMore(LifeCell *cells[], size_t *ncells) continue; // check whether there is enough space left in the array - if (m_ncells > (ARRAYSIZE - 64)) + if (m_ncells > (CELLSARRAYSIZE - 64)) { *ncells = m_ncells; return false; @@ -553,7 +549,7 @@ bool Life::FindMore(LifeCell *cells[], size_t *ncells) continue; // check whether there is enough space left in the array - if (m_ncells > (ARRAYSIZE - 64)) + if (m_ncells > (CELLSARRAYSIZE - 64)) { *ncells = m_ncells; return false; @@ -870,7 +866,7 @@ bool Life::NextTic() t2 |= g_tab[ ((t4 & 0x0000ffff) << 4 ) + ((t3 >> 24) & 0xf) ] << 24; t2 |= g_tab[ ((t4 & 0xffff0000) >> 12) + ((t3 >> 28) & 0xf) ] << 28; - c->m_on[0] = c->m_on[1] = c->m_on[2] = c->m_on[3] = + c->m_on[0] = c->m_on[1] = c->m_on[2] = c->m_on[3] = c->m_on[4] = c->m_on[5] = c->m_on[6] = c->m_on[7] = 0; c->m_live1 = t1; c->m_live2 = t2; @@ -1136,7 +1132,7 @@ int g_tab1[]= 0x11112110, 0x11112121, 0x11112221, - 0x11112232, + 0x11112232, 0x11122100, 0x11122111, 0x11122211,