Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/setcompat.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
setcompat.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* ANSI */
19#include <stdlib.h>
20
21/* utility */
22#include "support.h"
23
24/* server */
25#include "settings.h"
26
27#include "setcompat.h"
28
29 struct set_name_compat {
30 const char *old_name;
31 const char *new_name;
32};
33
34 static struct set_name_compat set_name_compat_S3_1_to_S3_2[] =
35{
36 { "spaceship_travel_time", "spaceship_travel_pct" },
37 { NULL, NULL }
38};
39
40
41/**********************************************************************/
45 static const char *setcompat_name_generic(const char *old_name,
46 struct set_name_compat *compats)
47{
48 int i;
49
50 for (i = 0; compats[i].old_name != NULL; i++) {
51 if (!fc_strcasecmp(old_name, compats[i].old_name)) {
52 return compats[i].new_name;
53 }
54 }
55
56 return old_name;
57}
58
59/**********************************************************************/
62 const char *setcompat_S3_2_name_from_S3_1(const char *old_name)
63{
64 return setcompat_name_generic(old_name, set_name_compat_S3_1_to_S3_2);
65}
66
67/**********************************************************************/
70 const char *setcompat_S3_2_val_from_S3_1(struct setting *pset,
71 const char *val)
72{
73 if (!fc_strcasecmp("compresstype", setting_name(pset))
74 && !fc_strcasecmp("BZIP2", val)) {
75#ifdef FREECIV_HAVE_LIBZSTD
76 return "ZSTD";
77#elif FREECIV_HAVE_LIBLZMA
78 return "XZ";
79#elif FREECIV_HAVE_LIBZ
80 return "LIBZ";
81#else
82 return "PLAIN";
83#endif
84 }
85
86 return NULL;
87}
incite_cost
char * incite_cost
Definition comments.c:74
setcompat_name_generic
static const char * setcompat_name_generic(const char *old_name, struct set_name_compat *compats)
Definition setcompat.c:45
set_name_compat_S3_1_to_S3_2
static struct set_name_compat set_name_compat_S3_1_to_S3_2[]
Definition setcompat.c:34
setcompat_S3_2_val_from_S3_1
const char * setcompat_S3_2_val_from_S3_1(struct setting *pset, const char *val)
Definition setcompat.c:70
setcompat_S3_2_name_from_S3_1
const char * setcompat_S3_2_name_from_S3_1(const char *old_name)
Definition setcompat.c:62
setcompat.h
setting_name
const char * setting_name(const struct setting *pset)
Definition settings.c:3323
settings.h
set_name_compat
Definition setcompat.c:29
set_name_compat::new_name
const char * new_name
Definition setcompat.c:31
set_name_compat::old_name
const char * old_name
Definition setcompat.c:30
setting
Definition settings.c:92
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
support.h