-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server: Backport 0080-savegame-Save-ACTION_NONE-as-1.patch
Signed-off-by: Marko Lindqvist <[email protected]>
- Loading branch information
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
freeciv/patches/backports/0080-savegame-Save-ACTION_NONE-as-1.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
From c902b55fde30f4d24d7bbd95fce4fbe5f6281e03 Mon Sep 17 00:00:00 2001 | ||
From: Marko Lindqvist <[email protected]> | ||
Date: Sun, 12 May 2024 11:21:28 +0300 | ||
Subject: [PATCH 80/80] savegame: Save ACTION_NONE as -1 | ||
|
||
See RM #598 | ||
|
||
Signed-off-by: Marko Lindqvist <[email protected]> | ||
--- | ||
server/savegame/savecompat.c | 4 ++-- | ||
server/savegame/savegame3.c | 26 +++++++++++++++++++++----- | ||
2 files changed, 23 insertions(+), 7 deletions(-) | ||
|
||
diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c | ||
index 322aae8644..152b756cb3 100644 | ||
--- a/server/savegame/savecompat.c | ||
+++ b/server/savegame/savecompat.c | ||
@@ -2556,7 +2556,7 @@ static void compat_load_030300(struct loaddata *loading, | ||
} | ||
|
||
if (!found) { | ||
- secfile_insert_int(loading->file, ACTION_NONE, "player%d.u%d.action", | ||
+ secfile_insert_int(loading->file, -1, "player%d.u%d.action", | ||
plrno, unro); | ||
} | ||
} | ||
@@ -3439,7 +3439,7 @@ static void compat_load_dev(struct loaddata *loading) | ||
} | ||
|
||
if (!found) { | ||
- secfile_insert_int(loading->file, ACTION_NONE, "player%d.u%d.action", | ||
+ secfile_insert_int(loading->file, -1, "player%d.u%d.action", | ||
plrno, unro); | ||
} | ||
} | ||
diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c | ||
index 137a990700..8c349fc295 100644 | ||
--- a/server/savegame/savegame3.c | ||
+++ b/server/savegame/savegame3.c | ||
@@ -5502,11 +5502,13 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr, | ||
order->dir = char2dir(rally_dirs[i]); | ||
order->activity = char2activity(rally_activities[i]); | ||
|
||
- unconverted = secfile_lookup_int_default(loading->file, ACTION_NONE, | ||
+ unconverted = secfile_lookup_int_default(loading->file, -1, | ||
"%s.rally_point_action_vec,%d", | ||
citystr, i); | ||
|
||
- if (unconverted >= 0 && unconverted < loading->action.size) { | ||
+ if (unconverted == -1) { | ||
+ order->action = ACTION_NONE; | ||
+ } else if (unconverted >= 0 && unconverted < loading->action.size) { | ||
/* Look up what action id the unconverted number represents. */ | ||
order->action = loading->action.order[unconverted]; | ||
} else { | ||
@@ -5910,6 +5912,10 @@ static void sg_save_player_cities(struct savedata *saving, | ||
case ORDER_LAST: | ||
break; | ||
} | ||
+ | ||
+ if (actions[j] == ACTION_NONE) { | ||
+ actions[j] = -1; | ||
+ } | ||
} | ||
orders[len] = dirs[len] = activities[len] = '\0'; | ||
|
||
@@ -6197,7 +6203,7 @@ static bool sg_load_player_unit(struct loaddata *loading, | ||
sg_warn_ret_val(secfile_lookup_int(loading->file, &ei, | ||
"%s.action", unitstr), FALSE, | ||
"%s", secfile_error()); | ||
- if (ei == ACTION_NONE) { | ||
+ if (ei == -1) { | ||
action = ACTION_NONE; | ||
} else { | ||
action = loading->action.order[ei]; | ||
@@ -6454,7 +6460,9 @@ static bool sg_load_player_unit(struct loaddata *loading, | ||
"%s.action_vec,%d", | ||
unitstr, j); | ||
|
||
- if (unconverted >= 0 && unconverted < loading->action.size) { | ||
+ if (unconverted == -1) { | ||
+ order->action = ACTION_NONE; | ||
+ } else if (unconverted >= 0 && unconverted < loading->action.size) { | ||
/* Look up what action id the unconverted number represents. */ | ||
order->action = loading->action.order[unconverted]; | ||
} else { | ||
@@ -6725,7 +6733,11 @@ static void sg_save_player_units(struct savedata *saving, | ||
secfile_insert_int(saving->file, punit->activity, "%s.activity", buf); | ||
secfile_insert_int(saving->file, punit->activity_count, | ||
"%s.activity_count", buf); | ||
- secfile_insert_int(saving->file, punit->action, "%s.action", buf); | ||
+ if (punit->action == ACTION_NONE) { | ||
+ secfile_insert_int(saving->file, -1, "%s.action", buf); | ||
+ } else { | ||
+ secfile_insert_int(saving->file, punit->action, "%s.action", buf); | ||
+ } | ||
if (punit->activity_target == NULL) { | ||
secfile_insert_int(saving->file, -1, "%s.activity_tgt", buf); | ||
} else { | ||
@@ -6857,6 +6869,10 @@ static void sg_save_player_units(struct savedata *saving, | ||
case ORDER_LAST: | ||
break; | ||
} | ||
+ | ||
+ if (action_buf[j] == ACTION_NONE) { | ||
+ action_buf[j] = -1; | ||
+ } | ||
} | ||
orders_buf[len] = dir_buf[len] = act_buf[len] = '\0'; | ||
|
||
-- | ||
2.43.0 | ||
|