999 |
} |
} |
1000 |
|
|
1001 |
void world::NameObject(Object *obj, const std::string &name) { |
void world::NameObject(Object *obj, const std::string &name) { |
1002 |
|
string old_name; |
1003 |
|
if (obj->string_attrib("name", &old_name)) { |
1004 |
|
obj->warning("name '%s' overwritten by '%s'", |
1005 |
|
old_name.c_str(), name.c_str()); |
1006 |
|
UnnameObject(obj); |
1007 |
|
} |
1008 |
level->name_object (obj, name); |
level->name_object (obj, name); |
1009 |
} |
} |
1010 |
|
|
1017 |
string name; |
string name; |
1018 |
if (source->string_attrib("name", &name)) { |
if (source->string_attrib("name", &name)) { |
1019 |
UnnameObject(source); |
UnnameObject(source); |
1020 |
|
string targetName; |
1021 |
|
if (target->string_attrib("name", &targetName)) { |
1022 |
|
target->warning("name '%s' overwritten by '%s'", |
1023 |
|
targetName.c_str(), name.c_str()); |
1024 |
|
UnnameObject(target); |
1025 |
|
} |
1026 |
NameObject(target, name); |
NameObject(target, name); |
1027 |
} |
} |
1028 |
} |
} |
1032 |
} |
} |
1033 |
|
|
1034 |
bool world::IsLevelBorder(GridPos p) { |
bool world::IsLevelBorder(GridPos p) { |
1035 |
return level->is_border( p); |
return level->is_border(p); |
1036 |
} |
} |
1037 |
|
|
1038 |
//---------------------------------------- |
//---------------------------------------- |
1406 |
} |
} |
1407 |
|
|
1408 |
void |
void |
1409 |
world::SwapStones(GridPos p, GridPos newp) |
world::ReplaceStone(GridPos p, Stone* st) |
1410 |
{ |
{ |
1411 |
Stone *tmp = st_layer.yield(newp); |
Stone *old = st_layer.get(p); |
1412 |
if (!tmp->is_kind("borderstone")) { |
if (old) { |
1413 |
tmp->play_sound ("st-move"); |
TransferObjectName(old, st); |
1414 |
|
st_layer.kill(p); |
1415 |
|
} |
1416 |
|
SetStone(p, st); |
1417 |
|
} |
1418 |
|
|
1419 |
|
void |
1420 |
|
world::SwapStones(GridPos p, GridPos newp) |
1421 |
|
{ |
1422 |
|
if (!IsLevelBorder(newp) && !IsLevelBorder(p)) { |
1423 |
|
Stone *tmp = st_layer.yield(newp); |
1424 |
Stone *tmp2 = st_layer.yield(p); |
Stone *tmp2 = st_layer.yield(p); |
1425 |
|
|
1426 |
|
tmp->play_sound ("st-move"); |
1427 |
|
|
1428 |
SetStone(newp, tmp2); |
SetStone(newp, tmp2); |
1429 |
SetStone(p, tmp); |
SetStone(p, tmp); |
1430 |
tmp->on_move(); |
tmp->on_move(); |