Author Topic: How does R button work in battlescape?  (Read 4752 times)

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
How does R button work in battlescape?
« on: November 15, 2016, 08:33:46 pm »
I am not idiot, yes, I know it is reload in general (-:

I want to know how exactly it works. For instance, I have 3 different ammos in different body slots. Which one would reload my gun if I press R? And which gun (left of right) will be reloaded?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: How does R button work in battlescape?
« Reply #1 on: November 15, 2016, 08:45:29 pm »
Right hand is reloaded first, left hand second.
Ammo is taken "randomly"... or in no particular order if you wish.

https://github.com/SupSuper/OpenXcom/blob/master/src/Savegame/BattleUnit.cpp#L2042

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
Re: How does R button work in battlescape?
« Reply #2 on: November 15, 2016, 09:34:18 pm »
Thank you for quick and exact answer.

But why guys don't use constants in the code instead of integer literals?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: How does R button work in battlescape?
« Reply #3 on: November 15, 2016, 10:13:55 pm »
There's as many explanations to that question as there are people on Earth.

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
Re: How does R button work in battlescape?
« Reply #4 on: November 15, 2016, 10:42:48 pm »
:)

I've read many books on programming. But nowhere I saw a line saying "there are situations where you should not use literals". Every author positively says "you must you const" and gives a pretty good reason.

Could you give at least a couple of such explanations?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: How does R button work in battlescape?
« Reply #5 on: November 15, 2016, 11:00:14 pm »
I didn't say there are good reasons.
I said there are reasons.

- "It was only a prototype..."
- "Somebody else did it and I didn't fix it yet."
- "We have no guidelines!"
- "15 is a meaning of life..."
- "Because..."
- "Let me just put 15 here, I'll fix it in a minute..."
- "I don't care"
- "Cthulhu made me do it!"
- "What's a constant?"

And another 7.5 billion excuses... what's your favourite? :)

PS: if you've read all those books, why ask the question?

PS2: also, not all forks have 15 hardcoded: https://github.com/MeridianOXC/OpenXcom/blob/oxce3.3-plus-proto/src/Savegame/BattleUnit.cpp#L2310
This one however has number 2 hardcoded... would you put that one in a constant too? :)

PS3: and yes, there are good reasons too... just not for this example
« Last Edit: November 15, 2016, 11:06:28 pm by Meridian »

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
Re: How does R button work in battlescape?
« Reply #6 on: November 16, 2016, 06:16:48 pm »
 ;D :) Suspected that, I understand you.

This one however has number 2 hardcoded... would you put that one in a constant too? :)

Two as amount of human's hands? Yes, I would ))
First of all, I don't know at the point how much bizarre the project would be in the future, or how much mad the mod makers are to construct very much mad mod. And readablity one:

Code: [Select]
for (int i = 0; i < HUMAN_HANDS_NUMBER; ++i)
is more self-explanating than just

Code: [Select]
for (int i = 0; i < 2; ++i)

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: How does R button work in battlescape?
« Reply #7 on: November 16, 2016, 09:28:43 pm »
I've always thought that the clip with lowest TUs to load takes preference... Was I really wrong? I never noticed if it works otherwise.

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
Re: How does R button work in battlescape?
« Reply #8 on: November 16, 2016, 09:31:10 pm »
Every clip from every slot for every weapon takes 15 TUs to reload. Well, mathematically, you were exactly right  ;)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: How does R button work in battlescape?
« Reply #9 on: November 16, 2016, 09:47:09 pm »
I've always thought that the clip with lowest TUs to load takes preference... Was I really wrong? I never noticed if it works otherwise.

May be like that in OXCE (would have to check)... but I was answering question about OXC.

Every clip from every slot for every weapon takes 15 TUs to reload. Well, mathematically, you were exactly right  ;)

Unless you play with OXCE/OXCE+ :)

Offline Constantine

  • Sergeant
  • **
  • Posts: 30
    • View Profile
Re: How does R button work in battlescape?
« Reply #10 on: November 16, 2016, 09:48:58 pm »
Unless you play with OXCE/OXCE+ :)

What do these incantations mean? )

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: How does R button work in battlescape?
« Reply #11 on: November 16, 2016, 09:52:41 pm »
OXC = OpenXcom (by Warboy and SupSuper)
OXCE = OpenXcom Extended (by Yankes)
OXCE+ = OpenXcom Extended Plus (by Meridian)

The latter are different forks of OpenXcom, which extend the functionality of OpenXcom introducing tons of QoL improvements and modding options.

OXCE: https://openxcom.org/forum/index.php/topic,2915.0.html
OXCE+: https://openxcom.org/forum/index.php/topic,4187.0.html

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: How does R button work in battlescape?
« Reply #12 on: November 16, 2016, 09:54:53 pm »
May be like that in OXCE (would have to check)... but I was answering question about OXC.

Sorry... Haven't played vanilla for so long I forgot it worled differently there. :)