Project

General

Profile

Feature #2112 ยป 0078-Move-special-functions-to-savegame2.c.patch

Marko Lindqvist, 10/10/2026 07:43 AM

View differences:

server/savegame/savecompat.c
bool sg_success;
static char *special_names[] =
{
"Irrigation", "Mine", "Pollution", "Hut", "Farmland",
"Fallout", nullptr
};
/*
For each savefile format after 2.3.0, compatibility functions are defined
which translate secfile structures from previous version to that version;
......
return pch - num_chars;
}
/************************************************************************//**
Return the special with the given name, or S_LAST.
****************************************************************************/
enum tile_special_type special_by_rule_name(const char *name)
{
int i;
for (i = 0; special_names[i] != nullptr; i++) {
if (!strcmp(name, special_names[i])) {
return i;
}
}
return S_LAST;
}
/************************************************************************//**
Return the untranslated name of the given special.
****************************************************************************/
const char *special_rule_name(enum tile_special_type type)
{
fc_assert(type >= 0 && type < S_LAST);
return special_names[type];
}
/************************************************************************//**
Get extra of the given special
****************************************************************************/
struct extra_type *special_extra_get(int spe)
{
struct extra_type_list *elist = extra_type_list_by_cause(EC_SPECIAL);
if (spe < extra_type_list_size(elist)) {
return extra_type_list_get(elist, spe);
}
return nullptr;
}
/* =======================================================================
* Compatibility functions for loading a game.
server/savegame/savecompat.h
S_FARMLAND,
S_FALLOUT,
/* internal values not saved */
/* Internal values not saved */
S_LAST,
S_OLD_ROAD,
......
int char2num(char ch);
enum tile_special_type special_by_rule_name(const char *name);
const char *special_rule_name(enum tile_special_type type);
struct extra_type *special_extra_get(int spe);
enum ai_level ai_level_convert(int old_level);
enum barbarian_type barb_type_convert(int old_type);
server/savegame/savegame2.c
#define ACTIVITY_OLD_FALLOUT_SG2 (ACTIVITY_OLD_POLLUTION_SG2 + 1)
#define ACTIVITY_LAST_SAVEGAME2 (ACTIVITY_OLD_FALLOUT_SG2 + 1)
static char *special_names[] =
{
"Irrigation", "Mine", "Pollution", "Hut", "Farmland",
"Fallout", nullptr
};
/*
* This loops over the entire map to save data. It collects all the data of
* a line using GET_XY_CHAR and then executes the macro SECFILE_INSERT_LINE.
......
} whole_map_iterate_end;
}
/************************************************************************//**
Return the special with the given name, or S_LAST.
****************************************************************************/
static enum tile_special_type special_by_rule_name(const char *name)
{
int i;
for (i = 0; special_names[i] != nullptr; i++) {
if (!strcmp(name, special_names[i])) {
return i;
}
}
return S_LAST;
}
/************************************************************************//**
Return the untranslated name of the given special.
****************************************************************************/
static const char *special_rule_name(enum tile_special_type type)
{
fc_assert(type >= 0 && type < S_LAST);
fc__unreachable(type >= S_LAST);
return special_names[type];
}
/************************************************************************//**
Get extra of the given special
****************************************************************************/
static struct extra_type *special_extra_get(int spe)
{
struct extra_type_list *elist = extra_type_list_by_cause(EC_SPECIAL);
if (spe < extra_type_list_size(elist)) {
return extra_type_list_get(elist, spe);
}
return nullptr;
}
/************************************************************************//**
Helper function for loading extras from a savegame.
    (1-1/1)