/[enigma]/enigma/src/world.cc
ViewVC logotype

Diff of /enigma/src/world.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.61 by mhawlisch, Fri Jul 11 14:24:18 2003 UTC revision 1.62 by reallysoft, Sun Jul 13 19:28:23 2003 UTC
# Line 999  void world::SetMouseForce(V2 f) { Line 999  void world::SetMouseForce(V2 f) {
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    
# Line 1011  world::TransferObjectName(Object *source Line 1017  world::TransferObjectName(Object *source
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  }  }
# Line 1020  Object * world::GetNamedObject(const std Line 1032  Object * world::GetNamedObject(const std
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  //----------------------------------------  //----------------------------------------
# Line 1394  world::SetStone(GridPos p, Stone* st) Line 1406  world::SetStone(GridPos p, Stone* st)
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();

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.62

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26