1188 |
Stone *tmp = st_layer.yield(newp); |
Stone *tmp = st_layer.yield(newp); |
1189 |
if (0 != strcmp(tmp->get_kind(), "borderstone")) { |
if (0 != strcmp(tmp->get_kind(), "borderstone")) { |
1190 |
tmp->play_sound ("st-move"); |
tmp->play_sound ("st-move"); |
1191 |
SetStone(newp, st_layer.yield(p)); |
|
1192 |
|
Stone *tmp2 = st_layer.yield(p); |
1193 |
|
|
1194 |
|
SetStone(newp, tmp2); |
1195 |
SetStone(p, tmp); |
SetStone(p, tmp); |
1196 |
|
tmp->on_move(); |
1197 |
|
tmp2->on_move(); |
1198 |
|
|
1199 |
player::IncMoveCounter(2); |
player::IncMoveCounter(2); |
1200 |
} |
} |
1201 |
} |
} |
1213 |
laser::MaybeRecalcLight(p); |
laser::MaybeRecalcLight(p); |
1214 |
return it_layer.yield(p); |
return it_layer.yield(p); |
1215 |
} |
} |
1216 |
void world::SetItem(GridPos p, Item* st) { |
void world::SetItem(GridPos p, Item* it) { |
1217 |
laser::MaybeRecalcLight(p); |
laser::MaybeRecalcLight(p); |
1218 |
it_layer.set(p,st); |
it_layer.set(p,it); |
1219 |
|
} |
1220 |
|
|
1221 |
|
void world::SetItemAsStone(GridPos p, Item* it) { |
1222 |
|
Stone *st = world::ConvertToStone(it); |
1223 |
|
if (st) |
1224 |
|
SetStone(p, st); |
1225 |
|
else |
1226 |
|
fprintf(stderr, "Could not SetItemAsStone(%s)\n", it->get_kind()); |
1227 |
|
} |
1228 |
|
|
1229 |
|
// ---------------------------------- |
1230 |
|
// Item <-> Stone conversion |
1231 |
|
// ---------------------------------- |
1232 |
|
|
1233 |
|
// These conversions assume that the name of the item starts with |
1234 |
|
// 'it-' and the name of stone starts with 'st-'. The rest of |
1235 |
|
// the name has to be identical. |
1236 |
|
|
1237 |
|
// If the conversion fails, a message is printed to stderr |
1238 |
|
// and the source (item or stone) is not disposed. |
1239 |
|
|
1240 |
|
Stone *world::ConvertToStone(Item *it) { |
1241 |
|
string kind = it->get_kind(); |
1242 |
|
if (kind[0] == 'i') kind[0] = 's'; |
1243 |
|
|
1244 |
|
Stone *st = MakeStone(kind.c_str()); |
1245 |
|
if (st) it->dispose(); |
1246 |
|
return st; |
1247 |
|
} |
1248 |
|
Item *world::ConvertToItem(Stone *st) { |
1249 |
|
string kind = st->get_kind(); |
1250 |
|
if (kind[0] == 's') kind[0] = 'i'; |
1251 |
|
|
1252 |
|
Item *it = MakeItem(kind.c_str()); |
1253 |
|
if (it) st->dispose(); |
1254 |
|
|
1255 |
|
return it; |
1256 |
} |
} |
1257 |
|
|
1258 |
//---------------------------------------- |
//---------------------------------------- |