Clicks not working in opening screen - double-click in game bug

A place to post suggestions for new features, new bugs, and comments about the existing code.
Spunkmeyer
Posts: 2013
Joined: Fri Jun 27, 2003 7:00 am
Location: Contact me regarding: CC, Slayer and AllegWiki.

Post 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.
Last edited by Spunkmeyer on Sun Feb 10, 2013 3:28 am, edited 1 time in total.


Want bigger games? Log on to play at the official game time: 9pmET/8pmCT/7pmMT/6pmPT every day of the week. Also Saturdays 8pm UTC.

raumvogel
Posts: 5910
Joined: Sun Jul 20, 2003 7:00 am
Location: My lawn
Contact:

Post by raumvogel »

No problem here.
Image
dusanc
Posts: 1302
Joined: Sat May 16, 2009 12:06 pm
Location: СРБИЈА/Serbia

Post by dusanc »

Happened to me a few times but I thought it was because of the mouse (baby smashed it a few times).
- "History repeats itself for a reason" - "It's easy to cry for war when you've never experienced it" - "It's better to negotiate for 10 years then make war for 10 days" - "The strong do as they will, and the weak do as they must"
Image
Hellsyng
Posts: 929
Joined: Sat Jul 18, 2009 7:50 pm

Post by Hellsyng »

It's not a constant problem for me so I assumed it was the mouse too...
MastaMetz wrote:QUOTE (MastaMetz @ Dec 6, 2012, 10:32 PM)@#(!ternet. I'm a genius!
BackTrak
Posts: 2078
Joined: Thu Mar 08, 2007 4:52 am
Location: Chicago, IL
Contact:

Post 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.
ImageImage
ThePhantom032
Posts: 836
Joined: Sat May 09, 2009 11:00 am
Location: Germany

Post 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.
Still ready to teach anyone who asks nicely whatever they want to know about playing alleg. Contrary to popular opinion I do not eat newbies. Voobs taste much better.
MonAG
Posts: 552
Joined: Mon Oct 17, 2011 11:37 am

Post 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...
Last edited by MonAG on Sun Feb 10, 2013 10:07 pm, edited 1 time in total.
TheDevil
Posts: 771
Joined: Mon Dec 22, 2008 8:04 pm
Location: London, UK

Post 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. :)
Image
Arson_Fire
Posts: 98
Joined: Mon Apr 24, 2006 7:00 am
Location: NZ

Post 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 .
Last edited by Arson_Fire on Mon Feb 06, 2017 2:54 am, edited 1 time in total.
Image
KGJV
Posts: 1474
Joined: Tue Jul 01, 2003 7:00 am
Location: Transilvania

Post 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.
Image
Post Reply