Build mode bug: building templates exit build mode

Post here if you want to help developing something for FAF.

Build mode bug: building templates exit build mode

Postby crispweed » 21 May 2017, 13:18

(Just to note, first of all, that yeah I know all the cool kids are using hotbuild. I'm not, currently!)

So there's a bug in the build mode lua with building templates resulting in build mode being exited.
(I consider this is a bug, because it's inconsistent with the behaviour when building other stuff, where you stay in build mode.)

The problem seems to be with the interactions between the following functions:

in /lua/ui/game/buildmode.lua:
Code: Select all
local function HandleBuildTemplate(key, modifiers)
    if not Construction.HandleBuildModeKey(key) then
        PlayErrorSound()
    end
    return true
end


in /lua/ui/game/construction.lua:
Code: Select all
function HandleBuildModeKey(key)
    if capturingKeys then
        ProcessKeybinding(key)
    else
        BuildTemplate(key)
    end
end


So the problem is that HandleBuildModeKey() eats the return value of BuildTemplate(), and then HandleBuildTemplate() thinks that this failed.

This is easy enough to fix, and I've fixed this locally by hooking this code in a mod, but it seems like this is something that should be fixed in the actual base lua code itself.

(Just for info, to build templates from build mode, you need to right click on the template and set up a key for it, if not already set up, and then, when in build mode, press '5' to switch to the templates tab.)
crispweed
Crusader
 
Posts: 21
Joined: 02 Jan 2017, 17:32
Has liked: 1 time
Been liked: 1 time
FAF User Name: crispweed

Re: Build mode bug: building templates exit build mode

Postby KeyBlue » 21 May 2017, 22:46

If you fixed it already, would you mind adding your fix to the game code?
https://github.com/FAForever/fa

Just make a pull request there with the fix, and explain what you fixed and how.
User avatar
KeyBlue
Priest
 
Posts: 403
Joined: 28 Jan 2016, 01:06
Has liked: 140 times
Been liked: 92 times
FAF User Name: KeyBlue

Re: Build mode bug: building templates exit build mode

Postby R_Charger » 22 May 2017, 16:05

Its interesting to know that the assigned keys for templates work in build mode when the templates tab is active - I didn't know that, but then I use hotbuild :D
R_Charger
Avatar-of-War
 
Posts: 61
Joined: 30 Jul 2016, 16:27
Has liked: 6 times
Been liked: 6 times
FAF User Name: Reckless_Charger

Re: Build mode bug: building templates exit build mode

Postby crispweed » 22 May 2017, 18:55

KeyBlue wrote:If you fixed it already, would you mind adding your fix to the game code?
https://github.com/FAForever/fa

Just make a pull request there with the fix, and explain what you fixed and how.


Ok, did this, pull request is here: https://github.com/FAForever/fa/pull/2019
crispweed
Crusader
 
Posts: 21
Joined: 02 Jan 2017, 17:32
Has liked: 1 time
Been liked: 1 time
FAF User Name: crispweed

Re: Build mode bug: building templates exit build mode

Postby crispweed » 22 May 2017, 18:56

R_Charger wrote:Its interesting to know that the assigned keys for templates work in build mode when the templates tab is active - I didn't know that, but then I use hotbuild :D


Yeah, I didn't know this, until actually looking at the lua code..
crispweed
Crusader
 
Posts: 21
Joined: 02 Jan 2017, 17:32
Has liked: 1 time
Been liked: 1 time
FAF User Name: crispweed


Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest