Freeciv-3.3: /fast/freeciv/nightly/main/tools/fcmp/modinst.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
modinst.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#include "fc_prehdrs.h"
19
20/* utility */
21#include "fciconv.h"
22#include "fcintl.h"
23#include "log.h"
24#include "mem.h"
25#include "net_types.h"
26#include "rand.h"
27#include "registry.h"
28#include "support.h"
29
30/* common */
31#include "fc_interface.h"
32
33/* modinst */
34#include "mpdb.h"
35
36#include "modinst.h"
37
38 static char main_ii_filename[500];
39 static char scenario_ii_filename[500];
40
41/**********************************************************************/
44 void load_install_info_lists(struct fcmp_params *fcmp)
45{
46 char main_db_filename[500];
47 char scenario_db_filename[500];
48 struct stat buf;
49
50 fc_snprintf(main_db_filename, sizeof(main_db_filename),
51 "%s" DIR_SEPARATOR DATASUBDIR DIR_SEPARATOR FCMP_CONTROLD DIR_SEPARATOR "mp.db",
52 fcmp->inst_prefix);
53 fc_snprintf(scenario_db_filename, sizeof(scenario_db_filename),
54 "%s" DIR_SEPARATOR "scenarios" DIR_SEPARATOR FCMP_CONTROLD DIR_SEPARATOR "mp.db",
55 fcmp->inst_prefix);
56
57 fc_snprintf(main_ii_filename, sizeof(main_ii_filename),
58 "%s" DIR_SEPARATOR DATASUBDIR DIR_SEPARATOR FCMP_CONTROLD DIR_SEPARATOR "modpacks.db",
59 fcmp->inst_prefix);
60 fc_snprintf(scenario_ii_filename, sizeof(scenario_ii_filename),
61 "%s" DIR_SEPARATOR "scenarios" DIR_SEPARATOR FCMP_CONTROLD DIR_SEPARATOR "modpacks.db",
62 fcmp->inst_prefix);
63
64 if (fc_stat(main_db_filename, &buf)) {
65 create_mpdb(main_db_filename, FALSE);
66 load_install_info_list(main_ii_filename);
67 } else {
68 open_mpdb(main_db_filename, FALSE);
69 }
70
71 if (fc_stat(scenario_db_filename, &buf)) {
72 create_mpdb(scenario_db_filename, TRUE);
73 load_install_info_list(scenario_ii_filename);
74 } else {
75 open_mpdb(scenario_db_filename, TRUE);
76 }
77}
78
79/**********************************************************************/
82 void fcmp_init(void)
83{
84 libfreeciv_init(FALSE);
85
86 init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
87 registry_module_init();
88
89 fc_init_network();
90
91 /* Needed at least for Windows version of netfile_get_section_file() */
92 fc_srand(time(NULL));
93}
94
95/**********************************************************************/
98 void fcmp_deinit(void)
99{
100 registry_module_close();
101 fc_shutdown_network();
102 /* log_init() was not done by fcmp_init(); we assume the caller called
103 * fcmp_parse_cmdline() (which sets up logging) in between */
104 log_close();
105 libfreeciv_free();
106}
incite_cost
char * incite_cost
Definition comments.c:74
FCMP_CONTROLD
#define FCMP_CONTROLD
Definition download.h:28
libfreeciv_init
void libfreeciv_init(bool check_fc_interface)
Definition fc_interface.c:75
libfreeciv_free
void libfreeciv_free(void)
Definition fc_interface.c:102
fc_interface.h
fc_prehdrs.h
init_character_encodings
static char void init_character_encodings(const char *my_internal_encoding, bool my_use_transliteration)
Definition fciconv.c:70
fciconv.h
FC_DEFAULT_DATA_ENCODING
#define FC_DEFAULT_DATA_ENCODING
Definition fciconv.h:89
fcintl.h
log_close
void log_close(void)
Definition log.c:270
log.h
mem.h
load_install_info_lists
void load_install_info_lists(struct fcmp_params *fcmp)
Definition modinst.c:44
main_ii_filename
static char main_ii_filename[500]
Definition modinst.c:38
fcmp_deinit
void fcmp_deinit(void)
Definition modinst.c:98
fcmp_init
void fcmp_init(void)
Definition modinst.c:82
scenario_ii_filename
static char scenario_ii_filename[500]
Definition modinst.c:39
modinst.h
fcmp
struct fcmp_params fcmp
Definition mpcli.c:37
load_install_info_list
void load_install_info_list(const char *filename)
Definition mpdb.c:43
create_mpdb
void create_mpdb(const char *filename, bool scenario_db)
Definition mpdb.c:134
open_mpdb
void open_mpdb(const char *filename, bool scenario_db)
Definition mpdb.c:181
mpdb.h
net_types.h
fc_shutdown_network
void fc_shutdown_network(void)
Definition netintf.c:217
fc_init_network
void fc_init_network(void)
Definition netintf.c:198
fc_srand
void fc_srand(RANDOM_TYPE seed)
Definition rand.c:161
rand.h
registry_module_init
void registry_module_init(void)
Definition registry.c:31
registry_module_close
void registry_module_close(void)
Definition registry.c:41
registry.h
DIR_SEPARATOR
#define DIR_SEPARATOR
Definition shared.h:127
fcmp_params
Definition modinst.h:17
fcmp_params::inst_prefix
const char * inst_prefix
Definition modinst.h:19
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
fc_stat
int fc_stat(const char *filename, struct stat *buf)
Definition support.c:574
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47