Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#2857 closed defect (fixed)

[PATCH] Ungarrison all units from an ally building

Reported by: rogue-spectre Owned by: maveric
Priority: Should Have Milestone: Alpha 19
Component: UI & Simulation Keywords:
Cc: Patch:

Description

Currently when one garrisons units in a building of an ally there is no option to ungarrison all units in one shoot like there is for one's building.

Attachments (6)

2857.patch (5.8 KB ) - added by maveric 9 years ago.
2857.1.patch (5.8 KB ) - added by maveric 9 years ago.
2857.2.patch (5.7 KB ) - added by maveric 9 years ago.
2857.3.patch (9.4 KB ) - added by maveric 9 years ago.
2857.4.patch (9.6 KB ) - added by maveric 9 years ago.
2857.5.patch (9.4 KB ) - added by maveric 9 years ago.

Download all attachments as: .zip

Change History (26)

comment:1 by Itms, 9 years ago

Component: Core engineUI & Simulation
Milestone: Alpha 18Backlog

comment:2 by leper, 9 years ago

Keywords: simple added; ungarrision ally removed
Summary: Ungarrison units from an ally buildingUngarrison all units from an ally building

comment:3 by maveric, 9 years ago

Owner: set to maveric
Status: newassigned

by maveric, 9 years ago

Attachment: 2857.patch added

comment:4 by maveric, 9 years ago

Keywords: patch review added
Summary: Ungarrison all units from an ally building[PATCH] Ungarrison all units from an ally building

by maveric, 9 years ago

Attachment: 2857.1.patch added

comment:5 by maveric, 9 years ago

Better version.

comment:6 by sanderd17, 9 years ago

Thanks for working on this. But I have some comments:

Apart from that, I'm unsure if the building owner should be able to ungarrison allied units he doesn't own. EDIT: leper thinks it's fine if a building owner can ungarrison all units, so it's ok to leave it like that.

But overall, it looks like a good patch.

Last edited 9 years ago by sanderd17 (previous) (diff)

in reply to:  6 comment:7 by maveric, 9 years ago

Replying to sanderd17:

  • unit_actions.js::942: The IsOwnedByAlly? function is confusing. cmpPlayer.IsAlly?() also returns true on itself (so a player is always considered an ally of itself). There shouldn't be a difference with the function you create now.

This function will return false, if player is entity owner (we need different behavior for player (ungarrison all units) and allies (ungarrison only those that belong to player)).

Last edited 9 years ago by maveric (previous) (diff)

by maveric, 9 years ago

Attachment: 2857.2.patch added

comment:8 by maveric, 9 years ago

Fixed all except IsOwnedByAlly function. We cant just call to cmpPlayer.isAlly because we need to distinguish only allies(not player).

Last edited 9 years ago by maveric (previous) (diff)

in reply to:  6 ; comment:9 by leper, 9 years ago

Replying to sanderd17:

  • Input.js: Instead of "if (test) return true / false", you can also "return test", which is more concise.

You now do

if (state)
    return state.garrisonHolder;
return false;

while you should just do

return state && state.garrisonHolder;

.

Is the IsOwnedByAlly function just needed because we add the commands panel to the gui for allies? If yes adding some sort of filter to setupUnitPanel, or providing a specific implementation for allies (that might just copy most of the properties from the normal object over and replace a few) might be nicer.

Apart from that the code looks good.

Last edited 9 years ago by leper (previous) (diff)

in reply to:  9 comment:10 by maveric, 9 years ago

Replying to leper:

Is the IsOwnedByAlly function just needed because we add the commands panel to the gui for allies?

It is also used when deciding either we send "unload-all" command or "unload-all-by-owner" to execute ungarrisoning (see 683 line of unit_actions.js).

comment:11 by sanderd17, 9 years ago

If you make a separate panel for allies, you can add a different button with a different function asigned to it. Then you don't need to switch between the two cases internally.

You'd only need that check once: when deciding which panel to show (the owner panel, the allied panel. or none). So you won't have to put it in a function. And that will avoid the naming issue.

comment:12 by maveric, 9 years ago

Well, it sounds like a good idea.

by maveric, 9 years ago

Attachment: 2857.3.patch added

comment:13 by maveric, 9 years ago

Added ally units command panel as new panel.

comment:14 by sanderd17, 9 years ago

Nice work. I guess these should be the final remarks:

  • Can you also add the repair button to the panel? You can probably just reuse the object of the other panel, so
  "repair": g_EntityCommands.repair

I think that's the only thing an ally should be able to do (next to garrisoning).

  • There's an issue with the count display on the ungarrison button. it should only show the units you can ungarrison, so the units you own as allied garrisoner.
  • You should also mind your whitespace (like keeping empty lines consistent, or the space at unit_actions.js::918).
Last edited 9 years ago by sanderd17 (previous) (diff)

in reply to:  14 comment:15 by maveric, 9 years ago

Replying to sanderd17:

  • Can you also add the repair button to the panel? You can probably just reuse the object of the other panel, so
  "repair": g_EntityCommands.repair

I think that's the only thing an ally should be able to do (next to garrisoning).

Maybe this issue is worth creating separate ticket? Because its not going to work this way and I am not sure about how this button should act (does it mean that player will be able to order ally workers to repair somewhat?).

Last edited 9 years ago by maveric (previous) (diff)

by maveric, 9 years ago

Attachment: 2857.4.patch added

comment:16 by maveric, 9 years ago

The rest issues are fixed.

comment:17 by leper, 9 years ago

You still have a space before var g_AllyEntityCommands =, you remove blank lines between functions in input.js, before the g_SelectionPanels.AllyCommand block you should add a blank line. And you reuse state in g_AllyEntityCommands in non-obvious ways.

by maveric, 9 years ago

Attachment: 2857.5.patch added

comment:18 by sanderd17, 9 years ago

Sorry, my bad, I thought the repair button was put on the structure to repair, not on the unit that does the reparation. So that comment was invalid.

comment:19 by sanderd17, 9 years ago

Resolution: fixed
Status: assignedclosed

In 16597:

Allow players to unload all their units when garrisoned in allied buildings. Patch by maveric. Fixes #2857

comment:20 by sanderd17, 9 years ago

Keywords: simple patch review removed
Milestone: BacklogAlpha 19
Note: See TracTickets for help on using tickets.