Skip to content

Commit

Permalink
Server: Backport 0046-Fix-combat-veterancy-chance.patch
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Lindqvist <[email protected]>
  • Loading branch information
cazfi committed Oct 19, 2024
1 parent 1ddf27f commit 1fdf5ea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions freeciv/apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
# 0030-Tex-Initialize-map-topology.patch
# Tex AI map topology fix
# RM #663
# 0046-Fix-combat-veterancy-chance.patch
# Fix veterancy gaining
# RM #983

# Not in the upstream Freeciv server
# ----------------------------------
Expand Down Expand Up @@ -69,6 +72,7 @@ declare -a PATCHLIST=(
"backports/0068-AI-Remove-shared-vision-from-pending-war-target-once"
"backports/0038-map_init_topology-Operate-on-any-map"
"backports/0030-Tex-Initialize-map-topology"
"backports/0046-Fix-combat-veterancy-chance"
"RevertAmplio2ExtraUnits"
"meson_webperimental"
"metachange"
Expand Down
35 changes: 35 additions & 0 deletions freeciv/patches/backports/0046-Fix-combat-veterancy-chance.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From b739562d61054e143e901c16b2e61037f1c44c59 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <[email protected]>
Date: Sat, 19 Oct 2024 02:33:02 +0300
Subject: [PATCH 46/46] Fix combat veterancy chance

It was always zero (integer math for 0.00 - 0.99) when
it was supposed to be scaled to how challenging the combat was.

Reported by Moke

See RM #983

Signed-off-by: Marko Lindqvist <[email protected]>
---
server/unittools.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/unittools.c b/server/unittools.c
index 6ba61bceda..eab53957fe 100644
--- a/server/unittools.c
+++ b/server/unittools.c
@@ -321,8 +321,8 @@ bool unit_versus_unit(struct unit *attacker, struct unit *defender,
/* In a combat between equal strength units the values are 50% / 50%.
* -> scaling that to 100% by doubling, to match scale of chances
* in existing rulesets, and in !combat_odds_scaled_veterancy case. */
- *att_vet = def_strength * 2 / (att_strength + def_strength);
- *def_vet = att_strength * 2 / (att_strength + def_strength);
+ *att_vet = 100 * def_strength * 2 / (att_strength + def_strength);
+ *def_vet = 100 * att_strength * 2 / (att_strength + def_strength);

if (attackpower == 0) {
*att_hp = 0;
--
2.45.2

0 comments on commit 1fdf5ea

Please sign in to comment.