Ignore:
Timestamp:
Jan 23, 2011, 2:21:26 PM (10 years ago)
Author:
sam
Message:

Start implementing mash lifetime.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r263 r264  
    107107    }
    108108
    109     /* Should we start dragging something? */
     109    /* Get rid of finished mashes */
     110    for (Mash **it = &data->mashes; *it; )
     111    {
     112        if ((*it)->IsFinished())
     113        {
     114            Ticker::Unref(*it);
     115            *it = (*it)->nextmash;
     116        }
     117        else
     118            it = &(*it)->nextmash;
     119    }
     120
    110121    switch (data->state)
    111122    {
    112123    case BoardData::IDLE:
     124        /* Should we start dragging something? */
    113125        if (buttons[0] && !data->buttons[0])
    114126        {
     
    133145        break;
    134146    case BoardData::GRAB:
     147        /* Should we stop dragging? */
    135148        if (mouse.x >= 0 && mouse.y >= 0)
    136149        {
     
    220233    do
    221234    {
    222 //        Mash *mash = new Mash(data->game);
    223 //        Ticker::Ref(mash);
     235        Mash *mash = new Mash(data->game);
     236        Ticker::Ref(mash);
    224237
    225238        for (int j = 8; j--;) for (int i = 0; i < 8; i++)
     
    229242
    230243            /* The mash becomes the new owner of the disappearing piece */
    231 //            mash->AddPiece(data->pieces[i][j], Int2(i, j));
    232             Ticker::Unref(data->pieces[i][j]);
     244            mash->AddPiece(data->pieces[i][j]);
    233245
    234246            Int2 newpos = data->pieces[i][7]->GetPos() + Int2(0, 48);
     
    247259            list[i][7] = 0;
    248260        }
     261
     262        mash->nextmash = data->mashes;
     263        data->mashes = mash;
    249264    }
    250265    while(ListMashes(list));
Note: See TracChangeset for help on using the changeset viewer.