PlaneShift

  • Status Closed
  • Percent Complete
    0%
  • Task Type Bug Report
  • Category Engine
  • Assigned To
    Ralph Campbell
  • Operating System
  • Severity Medium
  • Priority
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: PlaneShift
Opened by Ralph Campbell - 17.07.2013
Last edited by Ralph Campbell - 20.11.2013

FS#6073 - pawsContainerDescWindow::GetSlot() returns the wrong slot (fix included)

The code to get a pawsSlot from the container based on slotID is wrong since there can be more or less columns than 6.
Here is the fix.

Index: src/client/gui/pawscontainerdescwindow.cpp
===================================================================
--- src/client/gui/pawscontainerdescwindow.cpp	(revision 8702)
+++ src/client/gui/pawscontainerdescwindow.cpp	(working copy)
@@ -341,10 +341,11 @@
 
 pawsSlot* pawsContainerDescWindow::GetSlot(int slotID)
 {
-    int col = slotID%6;
-    int row = (slotID-col)/6;
+    int cols = contents->GetTotalColumns();
+    int col = slotID % cols;
+    int row = slotID / cols;
 
-    if (col > 0 && col < contents->GetTotalColumns())
+    if (col >= 0 && col < cols)
     {
         pawsListBoxRow* listRow = contents->GetRow(row);
         if (listRow)

FIXME

Closed by  Ralph Campbell
20.11.2013 01:33
Reason for closing:  
Joe Lyon commented on 07.08.2013 19:48

will need to read related code and have a test strategy in place before changing this.

Ralph Campbell commented on 13.10.2013 15:42

The reason this code wasn't causing a problem is that the  bug 6072  wasn't calling this code. By removing the unnecessary code for 6072, there are no calls to pawsContainerDescWindow::GetSlot() so it is safer to remove this (now dead code) until it is needed.

Index: src/client/gui/pawscontainerdescwindow.cpp
===================================================================
--- src/client/gui/pawscontainerdescwindow.cpp	(revision 8865)
+++ src/client/gui/pawscontainerdescwindow.cpp	(working copy)
@@ -338,22 +338,3 @@
 
     return true;
 }
-
-pawsSlot* pawsContainerDescWindow::GetSlot(int slotID)
-{
-    int col = slotID%6;
-    int row = (slotID-col)/6;
-
-    if (col > 0 && col < contents->GetTotalColumns())
-    {
-        pawsListBoxRow* listRow = contents->GetRow(row);
-        if (listRow)
-        {
-            return dynamic_cast <pawsSlot*> (listRow->GetColumn(col));
-        }
-    }
-
-    return NULL;
-}
-
-
Index: src/client/gui/pawscontainerdescwindow.h
===================================================================
--- src/client/gui/pawscontainerdescwindow.h	(revision 8865)
+++ src/client/gui/pawscontainerdescwindow.h	(working copy)
@@ -49,11 +49,6 @@
      */
     ContainerID GetContainerID() { return containerID; }
 
-    /**
-     * Return the slot.
-     */
-    pawsSlot* GetSlot(int slotID);
-
 private:
     void HandleUpdateItem( MsgEntry* me );
     void HandleViewContainer( MsgEntry* me );
Index: src/client/gui/pawsmoney.cpp
===================================================================
--- src/client/gui/pawsmoney.cpp	(revision 8865)
+++ src/client/gui/pawsmoney.cpp	(working copy)
@@ -232,19 +232,6 @@
     return false;
 }
 
-pawsSlot * pawsMoney::GetSlot(int coin)
-{
-    switch (coin)
-    {
-        case MONEY_CIRCLES:  return circles;
-        case MONEY_OCTAS:    return octas;
-        case MONEY_HEXAS:    return hexas;
-        case MONEY_TRIAS:    return trias;
-        default: CS_ASSERT(0);
-    }    
-    return 0;
-}
-
 void pawsMoney::RecalculateAmount()
 {
     amount  = this->trias->StackCount();
Index: src/client/gui/pawsmoney.h
===================================================================
--- src/client/gui/pawsmoney.h	(revision 8865)
+++ src/client/gui/pawsmoney.h	(working copy)
@@ -57,9 +57,6 @@
     /** Tells if the amount of money is Zero (null) */
     bool IsNoAmount();
 
-    /** Returns pawsItemSlot that represents given coin */
-    pawsSlot * GetSlot(int coin);
-
     void SetContainer( int containerID );
     void Drag( bool dragOn );
 

FIXME

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing