[Patch] Refactor AutoResolveCombat
Moderator: Committer
[Patch] Refactor AutoResolveCombat
In CombatSystem.cpp, AutoResolveCombat was basically one huge function.
I added a new struct, AutoresolveInfo to package some of the information
floating around and split AutoResolveCombat into smaller functions in other ways.
I tried to stay close to the original code, so it still isn't very pretty,
but it should be considerably better than before.
All the logic should be entirely intact.
Since there is no change in functionality, the benefit of this patch is somewhat subjective,
but I think it would be hard to argue that AutoResolveCombat was nice as it was.
Nonetheless, changes like this benefit especially from discussion,
so comment away.
I added a new struct, AutoresolveInfo to package some of the information
floating around and split AutoResolveCombat into smaller functions in other ways.
I tried to stay close to the original code, so it still isn't very pretty,
but it should be considerably better than before.
All the logic should be entirely intact.
Since there is no change in functionality, the benefit of this patch is somewhat subjective,
but I think it would be hard to argue that AutoResolveCombat was nice as it was.
Nonetheless, changes like this benefit especially from discussion,
so comment away.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: [Patch] Refactor AutoResolveCombat
Looks generally OK, other than minor formatting nitpicks. Am not able to test immediately, though, and haven't look through everything carefully... but breaking the combat processing into smaller functions should be fine in principle.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: [Patch] Refactor AutoResolveCombat
Combat seems to run OK, after a few early game simple tests. More thorough tests and reports would be useful, though.
Re: [Patch] Refactor AutoResolveCombat
Some for loops had their ending braces indented, which threw off my indentation.
Fixed that and a few other possible formatting nitpicks.
Some sort of automated testing sure would make it easier to
do this large refactorings confidently.
Fixed that and a few other possible formatting nitpicks.
Some sort of automated testing sure would make it easier to
do this large refactorings confidently.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Any code by me in this post is released under GPL 2.0 or later.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: [Patch] Refactor AutoResolveCombat
There have been several discussions on the subject, and a few aborted attempts at, automated testing / unit tests. You might want to search the forums...?
Edit: applies and builds OK
Edit: applies and builds OK
Re: [Patch] Refactor AutoResolveCombat
I played a game for a couple hundred turns with this patch
and didn't notice anything off with the results of battle.
I did feel like I got one battle report a turn too early,
but was probably just confused by a similarly named system.
I was even ambushed by stealthy space monsters I couldn't see
(which was cool), and the "you can hit them after they hit you"
logic seemed to work.
I of course don't have a very fine tuned feel of how the battles
are meant to go, so this experience does not weight that much.
and didn't notice anything off with the results of battle.
I did feel like I got one battle report a turn too early,
but was probably just confused by a similarly named system.
I was even ambushed by stealthy space monsters I couldn't see
(which was cool), and the "you can hit them after they hit you"
logic seemed to work.
I of course don't have a very fine tuned feel of how the battles
are meant to go, so this experience does not weight that much.
Any code by me in this post is released under GPL 2.0 or later.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: [Patch] Refactor AutoResolveCombat
I've committed the patch. Can be reverted if more testing reveals problems.