}
// SetCell:
-// Sets cell dx, dy in this box to 'alive', returns TRUE if
-// the previous value was different, FALSE if it was the same.
+// Sets cell dx, dy in this box to 'alive', returns true if
+// the previous value was different, false if it was the same.
//
bool LifeCellBox::SetCell(int dx, int dy, bool alive)
{
// reset this here to avoid updating problems
m_dead = 0;
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
// state vars for BeginFind & FindMore
m_cells = new LifeCell[ARRAYSIZE];
m_ncells = 0;
- m_findmore = FALSE;
- m_changed = FALSE;
+ m_findmore = false;
+ m_changed = false;
}
Life::~Life()
//
bool Life::IsAlive(wxInt32 x, wxInt32 y)
{
- LifeCellBox *c = LinkBox(x, y, FALSE);
+ LifeCellBox *c = LinkBox(x, y, false);
return (c && c->IsAlive( x - c->m_x, y - c->m_y ));
}
for (c = m_boxes[hv]; c; c = c->m_hnext)
if ((c->m_x == x) && (c->m_y == y)) return c;
- // if not found, and (create == TRUE), create a new one
+ // if not found, and (create == true), create a new one
return create? CreateBox(x, y, hv) : (LifeCellBox*) NULL;
}
LifeCell Life::FindNorth()
{
wxInt32 x = 0, y = 0;
- bool first = TRUE;
+ bool first = true;
LifeCellBox *c;
for (c = m_head; c; c = c->m_next)
{
x = c->m_x;
y = c->m_y;
- first = FALSE;
+ first = false;
}
LifeCell cell;
LifeCell Life::FindSouth()
{
wxInt32 x = 0, y = 0;
- bool first = TRUE;
+ bool first = true;
LifeCellBox *c;
for (c = m_head; c; c = c->m_next)
{
x = c->m_x;
y = c->m_y;
- first = FALSE;
+ first = false;
}
LifeCell cell;
LifeCell Life::FindWest()
{
wxInt32 x = 0, y = 0;
- bool first = TRUE;
+ bool first = true;
LifeCellBox *c;
for (c = m_head; c; c = c->m_next)
{
x = c->m_x;
y = c->m_y;
- first = FALSE;
+ first = false;
}
LifeCell cell;
LifeCell Life::FindEast()
{
wxInt32 x = 0, y = 0;
- bool first = TRUE;
+ bool first = true;
LifeCellBox *c;
for (c = m_head; c; c = c->m_next)
{
x = c->m_x;
y = c->m_y;
- first = FALSE;
+ first = false;
}
LifeCell cell;
m_x1 = (x1 + 7) & 0xfffffff8;
m_y1 = (y1 + 7) & 0xfffffff8;
- m_findmore = TRUE;
+ m_findmore = true;
m_changed = changed;
}
for ( ; m_y <= m_y1; m_y += 8, m_x = m_x0)
for ( ; m_x <= m_x1; m_x += 8)
{
- if ((c = LinkBox(m_x, m_y, FALSE)) == NULL)
+ if ((c = LinkBox(m_x, m_y, false)) == NULL)
continue;
// check whether there is enough space left in the array
if (m_ncells > (ARRAYSIZE - 64))
{
*ncells = m_ncells;
- return FALSE;
+ return false;
}
DoLine(m_x, m_y , c->m_live1, c->m_old1 );
for ( ; m_y <= m_y1; m_y += 8, m_x = m_x0)
for ( ; m_x <= m_x1; m_x += 8)
{
- if ((c = LinkBox(m_x, m_y, FALSE)) == NULL)
+ if ((c = LinkBox(m_x, m_y, false)) == NULL)
continue;
// check whether there is enough space left in the array
if (m_ncells > (ARRAYSIZE - 64))
{
*ncells = m_ncells;
- return FALSE;
+ return false;
}
DoLine(m_x, m_y , c->m_live1 );
}
*ncells = m_ncells;
- m_findmore = FALSE;
- return TRUE;
+ m_findmore = false;
+ return true;
}
// --------------------------------------------------------------------------
{
LifeCellBox *c, *up, *dn, *lf, *rt;
wxUint32 t1, t2, t3, t4;
- bool changed = FALSE;
+ bool changed = false;
m_numcells = 0;
// see below
g_tab = new unsigned char [0xfffff];
- if (!g_tab) return FALSE;
+ if (!g_tab) return false;
for (wxUint32 i = 0; i < 0xfffff; i++)
{
g_tab[i] = (unsigned char) live;
}
- return TRUE;
+ return true;
}
void LifeModule::OnExit()
inline wxString GetRules() const { return m_rules; };
inline wxString GetDescription() const { return m_description; };
bool IsAlive(wxInt32 x, wxInt32 y);
- void SetCell(wxInt32 x, wxInt32 y, bool alive = TRUE);
+ void SetCell(wxInt32 x, wxInt32 y, bool alive = true);
void SetPattern(const LifePattern &pattern);
// game control
// The following functions find cells within a given viewport; either
// all alive cells, or only those cells which have changed since last
// generation. You first call BeginFind() to specify the viewport,
- // then keep calling FindMore() until it returns TRUE.
+ // then keep calling FindMore() until it returns true.
//
// BeginFind:
// Specify the viewport and whether to look for alive cells or for
// Fills an array with cells that match the specification given with
// BeginFind(). The array itself belongs to the Life object and must
// not be modified or freed by the caller. If this function returns
- // FALSE, then the operation is not complete: just process all cells
+ // false, then the operation is not complete: just process all cells
// and call FillMore() again.
//
void BeginFind(wxInt32 x0, wxInt32 y0,
private:
// cellbox-related
LifeCellBox *CreateBox(wxInt32 x, wxInt32 y, wxUint32 hv);
- LifeCellBox *LinkBox(wxInt32 x, wxInt32 y, bool create = TRUE);
+ LifeCellBox *LinkBox(wxInt32 x, wxInt32 y, bool create = true);
void KillBox(LifeCellBox *c);
// helper for BeginFind & FindMore
// some shortcuts
#define ADD_TOOL(id, bmp, tooltip, help) \
- toolBar->AddTool(id, bmp, wxNullBitmap, false, -1, -1, (wxObject *)0, tooltip, help)
+ toolBar->AddTool(id, bmp, wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *)NULL, tooltip, help)
// --------------------------------------------------------------------------
wxSlider *slider = new wxSlider(panel2, ID_SLIDER,
5, 1, 10,
wxDefaultPosition,
- wxSize(200, -1),
+ wxSize(200, wxDefaultSize.y),
wxSL_HORIZONTAL | wxSL_AUTOTICKS);
UpdateInfoText();