Loading

Paste #pvlboqrzq

  1. Index: src/script/api/script_list.cpp
  2. ===================================================================
  3. --- src/script/api/script_list.cpp  (revision 27256)
  4. +++ src/script/api/script_list.cpp  (working copy)
  5. @@ -556,6 +556,8 @@
  6.  
  7.  void ScriptList::AddList(ScriptList *list)
  8.  {
  9. +   if (list == this) return;
  10. +
  11.     ScriptListMap *list_items = &list->items;
  12.     for (ScriptListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
  13.         this->AddItem((*iter).first);
  14. @@ -565,6 +567,8 @@
  15.  
  16.  void ScriptList::SwapList(ScriptList *list)
  17.  {
  18. +   if (list == this) return;
  19. +
  20.     this->items.swap(list->items);
  21.     this->buckets.swap(list->buckets);
  22.     Swap(this->sorter, list->sorter);
  23. @@ -694,9 +698,13 @@
  24.  {
  25.     this->modifications++;
  26.  
  27. -   ScriptListMap *list_items = &list->items;
  28. -   for (ScriptListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
  29. -       this->RemoveItem((*iter).first);
  30. +   if (list == this) {
  31. +       Clear();
  32. +   } else {
  33. +       ScriptListMap *list_items = &list->items;
  34. +       for (ScriptListMap::iterator iter = list_items->begin(); iter != list_items->end(); iter++) {
  35. +           this->RemoveItem((*iter).first);
  36. +       }
  37.     }
  38.  }
  39.  
  40. @@ -756,14 +764,12 @@
  41.  
  42.  void ScriptList::KeepList(ScriptList *list)
  43.  {
  44. +   if (list == this) return;
  45. +
  46.     this->modifications++;
  47.  
  48.     ScriptList tmp;
  49. -   for (ScriptListMap::iterator iter = this->items.begin(); iter != this->items.end(); iter++) {
  50. -       tmp.AddItem((*iter).first);
  51. -       tmp.SetValue((*iter).first, (*iter).second);
  52. -   }
  53. -
  54. +   tmp.AddList(this);
  55.     tmp.RemoveList(list);
  56.     this->RemoveList(&tmp);
  57.  }
  58.  

Comments