Jump to content

Unintended tribute


mapkoc
 Share

Recommended Posts

Not sure if this is a bug or intended behavior. Tested on a22 and svn.

If you try to pay tributes in diplomacy window and press Shift and click on any res and without releasing Shift click on another res, only 500 of last res is sent after releasing Shift. If you now click on first resource, a 500 tribute will be sent. If you shift click on first resource instead, a 1000 tribute is sent.

I find this counter intuitive if intended.  If tributes are not sent when shift key is not release then they should be reset, not compounded like that.

  • Thanks 1
Link to comment
Share on other sites

Agree to reset the tribute factor when clicking on a different resource, not only when releasing shift.

Does that also happen with tributing? Guess not.

Wanna try a patch? It's in gui/session/ somewhere, likely menu.js

Otherwise you could also write a ticket on trac if you don't want to have it lost on the forums.

Link to comment
Share on other sites

I press Shift and click on food and without releasing Shift click on wood and release shift.

a.png.07116e400a8cae5bb0c421eb93da8c57.png

The result I would expect is to give the tribute as soon as I click without waiting to release shift.

Now amounts[food] is dirty and if I shift click on food once and release

b.png.bfdbd81c8b7700d939dbc879d4e90d6c.png

If you click (no shift) on food, a 500 tribute will be sent, I have no idea why.

The file elexis said is
binaries/data/mods/public/gui/session/menu.js
the function
470 -> function diplomacyFormatTributeButtons(i, hidden)
but I don't know how to fix :(

 

Link to comment
Share on other sites

I found a way to reset previous clicks when masstributing and not releasing shift.

Add multiplier = 1; before closing onPress, say in line 522.

You still can't give several tributes with 1 shift because g_FlushTributing is only called on shift release.

    case INPUT_MASSTRIBUTING:
        if (ev.type == "hotkeyup" && ev.hotkey == "session.masstribute")


Maybe with an event != "hotkeyup" ?

Link to comment
Share on other sites

The previous hack breaks sending more than 500.

This is the only way I could solve "the bug".

Move declaration of multiplier and amounts outside onPress callback, before
for (let resCode of resCodes)
and make multiplier an array and initialize, like this

    let multiplier = {};
    let amounts = {};
    for (let res of resCodes) {
        multiplier[res] = 1;
        amounts[res] = 0;
    }

change updates of multiplier to multiplier[resCode]
but inside g_FlushTributing reset arrays like this

	for (let res of resCodes) {
		multiplier[res] = 1;
		amounts[res] = 0;
	}

Now it works as I expected

a.png.f18e9f5290458b38d424185dcbdb4b71.png

Link to comment
Share on other sites

You wrote a patch and you have an aco@#$% on phabricator. If I get an actual patch instead of an instruction, that would make things easier.

I'm still not sure if it wouldn't be the easiest solution to reset upon onMouseEnter. But we will see.

Also add yourself to gui/credits/programming.json :-)

  • Like 1
Link to comment
Share on other sites

7 hours ago, elexis said:

you have an aco@#$%

Is that an entity or a swear word? :huh:

I was hoping you did all the work. :)
Well, that was hard, first time. (D1191)

I guess one should follow https://trac.wildfiregames.com/wiki/SubmittingPatches

Since the code already mixes two styles and https://trac.wildfiregames.com/wiki/Coding_Conventions#Misc also (the for_each),
i figured I choose the one I like best.:angel:

9 hours ago, elexis said:

add yourself to gui/credits/programming.json :-)

No thanks, I'm good.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...