Window.List fix

Moderator: MacroQuest Developers

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Window.List fix

Post by echoism » Mon Mar 27, 2006 2:06 pm

This fixes listboxs in the window datatype.
With GetItemText(nIndex,n), n should be 1-based, not 0-based.
Also, fixed ISXEQ-specific code to set n properly.

MQ2DataTypes.cpp

Code: Select all

@@ -3636,7 +3636,7 @@
                return true;
        case List:
             {
[color=red]-                int n = 0;
+                int n = 1;[/color]
                if (((CXWnd*)pWnd)->GetType()==UI_Combobox)
                        VarPtr.Ptr=pWnd->SidlText;
                else if (((CXWnd*)pWnd)->GetType()!=UI_Listbox)
@@ -3645,16 +3645,16 @@
 #ifndef ISXEQ
                if (PCHAR pComma=strchr(Index,',')) {
                     n = atoi(pComma+1) - 1;
[color=red]-                    if (n < 0) n=0;
+                    if (n < 1) n=1;[/color]
 DebugSpew("List: index is %d\n", n);
                     *pComma = '\0';
                 }
 #else
                if (argc==2)
                {
[color=red]-                       n=atoi(argv[0]);
-                       if (n<0)
-                               n=0;
+                       n=atoi(argv[1]);
+                       if (n<1)
+                               n=1;[/color]
                }
 #endif
                if (ISNUMBER())

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Mon Mar 27, 2006 2:51 pm

Well, here's the thing. I think you created a bug instead of fixing the problem, which is that the ISXEQ version is incorrectly 0-based, and the MQ2 version is correctly 1-based. The "n = atoi(pComma+1) - 1" takes care of that. The same thing should be done for the ISXEQ version on the n=atoi(argv[1]) line. The actual value used as n needs to be 0-based.

So the real fix is to change

Code: Select all

n=atoi(argv[0]); 
to

Code: Select all

n=atoi(argv[1])-1; 
CVSing this.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Mon Mar 27, 2006 5:19 pm

Ah, yes. I see. I suppose it would have helped to actually read the rest of the mq2-specific stuff.

One more thing to fix, in regards to Listboxes.

Just doing a CXWnd->SetCurSel will highlight the option, but it doen't count as a mouse-click without a CXWnd->WndNotification.

Essentially, this means that I hafta use:
EQNotify MerchantWnd ItemList ListSelect 2
EQNotify MerchantWnd ItemList LeftMouseUp 2

Ideally, these should happen together, shouldn't they?

I think that should also be done for the :ListSelect method (from ISXEQDataTypes.cpp) so I can just use:
Window[MerchantWnd].Child[ItemList]:ListSelect[2]

Also, :ListSelect should probably use the same logic as .List, to use number or name. I suppose there's an easy way to do that, but I'm drawing a blank.

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Mon Mar 27, 2006 10:11 pm

That didn't quite work for me, Lax.
n=atoi(argv[1])-1;
If I use that, then when I enter in something for Window[MerchantWnd].Child[ItemList].List[1,2] it gives me the first row, first column.

Wwhen GetItemText is called, the 1st value is zero-indexed, the 2nd is 1-indexed.
CXStr Str=((CListWnd*)pWnd)->GetItemText(nIndex,n);

so... ->GetItemText(0,1) is the first row, first column. backwards? yeah, but thats what its doing.

GetItemText(0,2) is the first row, 2nd column. etc.

I'm assuming, since we decriment nIndex, to make it appear 1-indexed in a script, we want n to be 1-indexed too, yes? To do that, we just need
if(n<1) n=1;
or am I mistaken? Also, need n to default to 1. Since, if n ==0 when we do GetItemText, we get a null return.

Or, am I just missing something basic here? Its been known to happen... heh

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Mon Mar 27, 2006 10:21 pm

replace:

Code: Select all

#else
		if (argc==2)
		{
			n=atoi(argv[1])-1;
			if (n<0) 
				n=0;
		}
#endif
with:

Code: Select all

#else
		if (argc==2) n=atoi(argv[1]);
		if (n<1) n=1;
#endif
That way it works like MQ2's Wnd.List[]

iluvseq
Clueless Mudslinger
Posts: 269
Joined: Mon Apr 14, 2003 10:05 am

Post by iluvseq » Fri Jul 14, 2006 2:03 am

Echoism's fix above actually breaks List[x,y] ... It makes it impossible to retrieve the value of the first column of a list.

The proper code is:

Code: Select all

#else
      if (argc==2)
      {
         n=atoi(argv[1])-1;
         if (n<0)
            n=0;
      }
#endif
(ie: the way it was before).

This allows the first column of row x to be referenced by List[x,1]

iluvseq
Clueless Mudslinger
Posts: 269
Joined: Mon Apr 14, 2003 10:05 am

Post by iluvseq » Mon Dec 11, 2006 10:39 am

This bug is still in the latest zip.

It is currently impossible to fetch the value of the first column in any list, or to use .List[=string,y] to find a row, if you are looking for values in the first column.

iluvseq
Clueless Mudslinger
Posts: 269
Joined: Mon Apr 14, 2003 10:05 am

Post by iluvseq » Mon Oct 08, 2007 5:34 pm

This bug STILL exists.

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Mon Oct 08, 2007 5:39 pm

Does the posted fix take care of it?

If so, paste the code that's working for you (diff or whatever).

iluvseq
Clueless Mudslinger
Posts: 269
Joined: Mon Apr 14, 2003 10:05 am

Post by iluvseq » Mon Oct 08, 2007 7:43 pm

The only change required to fix current MQ2 (20071005) is this:

Code: Select all

MQ2DataTypes.cpp
4417,4419c4417,4419  
<                       n=atoi(argv[1]); 
<               if (n<1) 
<                       n=1; 
---
>                       n=atoi(argv[1])-1; 
>               if (n<0) 
>                       n=0;