Opened 9 years ago

Last modified 8 years ago

#3424 closed enhancement

[PATCH] Clean up Looter.js — at Version 1

Reported by: Stan Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by elexis)

cmpStatisticsTracker.IncreaseLootCollectedCounter(resourcesToAdd); is called identically twice, and there are some other things that can be cleaned.

Change History (5)

by Stan, 9 years ago

Attachment: 3424.diff added

Initial Elexis's patch

by elexis, 9 years ago

comment:1 by elexis, 9 years ago

Description: modified (diff)
Keywords: patch review added
Type: defectenhancement

fcxSanya implemented Looter.js in r9391 and r11279.

We should clean this code before adding more code, like #2732.

  • added comments
  • removed reundancy by summing up the looted resources and then transfering them and updating the statistics only once)
  • not 100% sure about the call to ApplyValueModificationsToEntity. In my testing it gave the same results, so we might not need to update resources with the return value. In doubt, revert that line.
  • conditional operator to improve readability
  • let instead of var

by elexis, 9 years ago

Attachment: commands.txt added

Visually replaying this file proves that my patch doesn't work as sometimes ApplyValueModificationsToEntity can return something different from what values it received. (Non-visual replay only checks every 20th turn, while visual-replay checks every turn).

by elexis, 9 years ago

Reverts that ApplyValueModificationsToEntity line and further simplifies those resources[carriedGoods.type] += carriedGoods.amount.traderGain || 0 lines.

Note: See TracTickets for help on using tickets.