Author Topic: Use Left/Right Hand + Item Action 1-5 to same key crashes game. (Pls help me)  (Read 314 times)

Offline xenoroyal

  • Sergeant
  • **
  • Posts: 31
    • View Profile
When you have the same key bound to OXC: Use Left/Right Hand Item as you do to OXCE: Item Action 1-5, it causes a crash.

Examples I Encountered:
I bound Q to 1.Pick and pull smoke bomb.  2.  Use Left Hand Item.   3.  Item Action 5 [Throw]
If this was worked, I would be able to hit qqq and throw a smoke.  Pairs well with R to ready a grenade, then QQ to throw.

SEQUENCE:
>Q (pick and pull grenade)
>Q (Use Left Hand Item)
The Throw Option appears.
>Q (Throw)
Crash occurs

I bound E to Use 1. Right Hand Item. and 2. Item action 3 (auto).
This would be very convenient too, since fucking blastin and throwing smoke are so common.

SEQUENCE:
>E (use right hand item) (laser rifle)
The Firing options appear.
>E (item action 3 (auto)
crash

To me, it looks like it's got something to do with Use Left/Right Hand Item being a toggle.  First time you hit it, the actions appear.  If you hit it again, they disappear like a right click on map.  The crash seems to be happening because the final Q is closing actions menu(throw/auto) and trying to throw/auto at the same time.

I come to you hat in hand to please help me make this keybind dream of mine a reality.  It's no fun playing keybind jujitsu and I thought I finally figured out the perfect formula.  If that really is the cause and the sacrifice had to be made that it wasn't "toggle"able anymore, i'd advocate for that loss. Because I think 99.999% of the time you'd just right click the map to make the actions menu go away.

« Last Edit: May 09, 2025, 07:45:18 am by xenoroyal »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9562
    • View Profile
When you have the same key bound to OXC: Use Left/Right Hand Item as you do to OXCE: Item Action 1-5, it causes a crash.

Not a bug.

To me, it looks like it's got something to do with Use Left/Right Hand Item being a toggle.  First time you hit it, the actions appear.  If you hit it again, they disappear like a right click on map.  The crash seems to be happening because the final Q is closing actions menu(throw/auto) and trying to throw/auto at the same time.

This is exactly what is happening.

You can't have the same key bound to two different actions, e.g. "close action menu" and "choose item from action menu".

I come to you hat in hand to please help me make this keybind dream of mine a reality.  It's no fun playing keybind jujitsu and I thought I finally figured out the perfect formula.  If that really is the cause and the sacrifice had to be made that it wasn't "toggle"able anymore, i'd advocate for that loss. Because I think 99.999% of the time you'd just right click the map to make the actions menu go away.

I would destroy another man's dream of having a nice quick toggle a reality.

Offline xenoroyal

  • Sergeant
  • **
  • Posts: 31
    • View Profile
I see.  Thank you for your response, and thank you for what you do.

And thank you, for giving me a new challenge : Learn how to recompile, figure out where "close action menu" is, and destroy it.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9562
    • View Profile
figure out where "close action menu" is

class ActionMenuState, method handle(), lines 249-255

Offline xenoroyal

  • Sergeant
  • **
  • Posts: 31
    • View Profile
Literally spent the entire day on this.  8 hours to find the code you were talking about.  I learned a #$%^ ton along the way.
https://github.com/MeridianOXC/OpenXcom/blob/oxce-plus/src/Battlescape/ActionMenuState.cpp#L249


 * Closes the window on right-click.
 * @param action Pointer to an action.
 */
void ActionMenuState::handle(Action *action)
{
   State::handle(action);
   if (action->getDetails()->type == SDL_MOUSEBUTTONDOWN && _game->isRightClick(action))
   {
      _game->popState();
   }
   else if (action->getDetails()->type == SDL_KEYDOWN &&
      (action->getDetails()->key.keysym.sym == Options::keyCancel ||
      action->getDetails()->key.keysym.sym == Options::keyBattleUseLeftHand ||
      action->getDetails()->key.keysym.sym == Options::keyBattleUseRightHand))
   {
      _game->popState();


Heres what I'm thinking.  When the togglemenu is up, there are only 4 things that will close the toggle menu aka popstate, if i am understanding the term.

1.  right clicking
2. pressing the cancel key
3. pressing use lefthanditem (heres the problem)
4. pressing use righthanditem

If I PROPERLY remove :
action->getDetails()->key.keysym.sym == Options::keyBattleUseLeftHand ||
      action->getDetails()->key.keysym.sym == Options::keyBattleUseRightHand

then right clicking and cancel(escape) will be the only ways to get out of the menu, allowing me to continue smashing q and e to my hearts content.  I dont wanna celebrate because I am still setting up visual studio and cant test, but I feel like I got it.  Thank you either way!
« Last Edit: May 12, 2025, 10:15:25 am by xenoroyal »

Online Yankes

  • Commander
  • Global Moderator
  • Commander
  • *****
  • Posts: 3485
  • Posts: 421
    • View Profile
Better solution would be check if any of `Options::keyBattleActionItem1` was used and skip popup if there is conflict.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9562
    • View Profile
Better solution would be to check if any of `Options::keyBattleActionItemX` was used and skip popState() if there is conflict.

Done.

https://github.com/MeridianOXC/OpenXcom/commit/ec12910f9cb0fbb637474fb9771aa6edc223c112

Offline xenoroyal

  • Sergeant
  • **
  • Posts: 31
    • View Profile
you guys are my heroes