1109 |
changed_stones.push_back(p); |
changed_stones.push_back(p); |
1110 |
} |
} |
1111 |
|
|
1112 |
#if defined(USE_IMPULSES) |
static Object *theImpulseSender = 0; |
1113 |
|
|
1114 |
|
Object * |
1115 |
|
world::ImpulseSender() { |
1116 |
|
return theImpulseSender; |
1117 |
|
} |
1118 |
|
|
1119 |
void |
void |
1120 |
world::SendImpulse(GridPos p, Direction dir) |
world::SendImpulse(GridPos p, Direction dir, Object *sender) |
1121 |
{ |
{ |
1122 |
if (Stone *st = GetStone(p)) { |
if (Stone *st = GetStone(p)) { |
1123 |
// fprintf(stderr, "Sending impulse to stone at position %i/%i direction=%s\n", p.x, p.y, to_suffix(dir).c_str()); |
Object *oldImpulseSender = theImpulseSender; |
1124 |
st->on_impulse(dir); |
theImpulseSender = sender; |
|
} |
|
|
} |
|
1125 |
|
|
1126 |
#else |
st->on_impulse(dir); |
|
|
|
|
bool |
|
|
world::MaybeMoveStone(GridPos p, Direction dir) |
|
1127 |
|
|
1128 |
{ |
theImpulseSender = oldImpulseSender; |
|
GridPos newp = move(p,dir); |
|
|
if (GetStone(newp) == 0) |
|
|
{ |
|
|
Stone *st = GetStone(p); |
|
|
if (st && st->is_movable()) |
|
|
{ |
|
|
st->play_sound ("st-move"); |
|
|
SetStone(newp, YieldStone(p)); |
|
|
st->on_move(); |
|
|
if (Item *it = GetItem(newp)) |
|
|
it->on_stonehit(st); |
|
|
return true; |
|
|
} |
|
1129 |
} |
} |
|
return false; |
|
1130 |
} |
} |
1131 |
|
|
|
#endif |
|
|
|
|
1132 |
void |
void |
1133 |
world::SwapStones(GridPos p, GridPos newp) |
world::SwapStones(GridPos p, GridPos newp) |
1134 |
{ |
{ |