Page 1 of 2

Posted: Sun Feb 10, 2013 3:21 am
by Spunkmeyer
So if you have a similar problem, are the following true?

1-You seem to be unable to click on the buttons when you start the game, but if you keep the pointer on the button, second or third click will actually work.
2-While joining a server and a team, single clicks register as double click (so you are not able to look at teams, for example - you automatically try to join as if you had double clicked)

It seems when this happens the first clicks on any control are registered as double-clicks.

Posted: Sun Feb 10, 2013 5:52 am
by raumvogel
No problem here.

Posted: Sun Feb 10, 2013 9:17 am
by dusanc
Happened to me a few times but I thought it was because of the mouse (baby smashed it a few times).

Posted: Sun Feb 10, 2013 6:35 pm
by Hellsyng
It's not a constant problem for me so I assumed it was the mouse too...

Posted: Sun Feb 10, 2013 7:13 pm
by BackTrak
This happens to me when I run the alleg client from VS 2010 debugger. I thought it was just related to the conditional break points I had at the time. It doesn't seem to happen on a normal basis.

Posted: Sun Feb 10, 2013 8:04 pm
by ThePhantom032
I had this happen a few times and every single time it happened after I played another fullscreen game first. Restarting alleg never fixed it - restarting windows always did.

Posted: Sun Feb 10, 2013 10:03 pm
by MonAG
Happens to me once in a while, but not too often. Learned to live with it. ;)

EDIT: Alleg always reacts slowly in my comp, and I am a bit impatient with clicks, so I always believed it was a full buffer of some sort. But who knows...

Posted: Sun Feb 10, 2013 11:05 pm
by TheDevil
Yeah happens occasionally. I notice it more when I command few game. Like I can't double click to invest sometimes and have to click like a madmen or click on the invest button. But I have learned to live with it like other, not a huge issue imo. :)

Posted: Mon Feb 06, 2017 2:18 am
by Arson_Fire
I booted up Alleg today for the first time in probably a couple of years, and this issue was bugging the hell out of me.
Enough that I downloaded the source code and took a peek.

Bear in mind my experience with C++ and unmanaged languages is somewhere between minimal and non-existent. Although I do know a thing or two about C# and other managed languages.
So please correct me if I'm getting the wrong idea somewhere.



The problem is that in the click handling code, the IsDoubleClick() function is returning True for a single click. Which is preventing a bunch of single click code from running, and breaking buttons.

Whenever you perform a click, it stores the time this most recent click was made.
Whenever you move the mouse it clears this last click time.
If a second click is performed within 0.25 seconds of the previous click time, then it should count as a double click.
Simple enough.




The Time class stores a DWORD (unsigned long, which apparently in c++ is the same as an unsigned int? Odd, but whatever). Which can range from 0 to 4,294,967,295.
We assign the current time using the WINAPI timeGetTime() function, which returns the number of milliseconds since windows was started. Apparently wrapping back around to 0 when it goes past the limit (which takes just under 50 days). In my case it's currently around 2,229,916,287 (it seems that the hybrid shutdown used on modern windows machines doesn't reset it).
Maybe this means something time related breaks once every 50 days, but that's not a huge problem.


Now in the Time class we also have a bunch of overloaded operators for comparing different times together. Here's the one for checking whether your time is greater than another time.

Code: Select all

    inline bool    operator >  (const Time     t) const
    {
        return ((int)(m_dwTime - t.m_dwTime) > 0);
    }
That's subtracting an unsigned int from an unsigned int, then casting it to a signed int.
If the result of the subtraction is greater than 2,147,483,647 then it's going to result in a negative number.

This means that if windows was last started more than 25 days ago, every click is a double click (unless you very carefully do not move the mouse between mouse down and mouse up). Whoops :P .

Posted: Wed Jun 07, 2017 7:34 pm
by KGJV
very nice find. I ran into this problem yesterday while developing some changes and it drove me crazy. Thx for this post it will save me some precious time :)
Indeed my PC just reached the critical number of days yesterday and the 'click' issue happened.

I'll try to find a fix that is not messing with the rest of the game.