project_files/frontlib/model/scheme.h
author Wuzzy <Wuzzy2@mail.ru>
Mon, 12 Feb 2018 17:47:40 +0100
changeset 12983 7c3454083489
parent 10017 de822cd3df3a
permissions -rw-r--r--
Battalion: Move crate pickup animation to crate
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     1
/*
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     2
 * Hedgewars, a free turn based strategy game
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     4
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     5
 * This program is free software; you can redistribute it and/or
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     6
 * modify it under the terms of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     8
 * of the License, or (at your option) any later version.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
     9
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    13
 * GNU General Public License for more details.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    14
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    15
 * You should have received a copy of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    16
 * along with this program; if not, write to the Free Software
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    18
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    19
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    20
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    21
 * Data structures for game scheme information.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    22
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    23
 * The scheme consists of settings (integers) and mods (booleans). These are not fixed, but
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    24
 * described in a "metascheme", which describes how each setting and mod is sent to the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    25
 * engine, and in which order they appear in the network protocol. The metascheme is defined
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    26
 * in hwconsts.h
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    27
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    28
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    29
#ifndef SCHEME_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    30
#define SCHEME_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    31
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    32
#include <stdbool.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    33
#include <stddef.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    34
#include "../hwconsts.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    35
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    36
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    37
 * The settings and mods arrays have the same number and order of elements
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    38
 * as the corresponding arrays in the metascheme.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    39
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    40
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    41
    char *name;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    42
    int *settings;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    43
    bool *mods;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    44
} flib_scheme;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    45
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    46
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    47
 * Create a new configuration with everything set to default or false
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    48
 * Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    49
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    50
flib_scheme *flib_scheme_create(const char *schemeName);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    51
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    52
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    53
 * Create a copy of the scheme. Returns NULL on error or if NULL was passed.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    54
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    55
flib_scheme *flib_scheme_copy(const flib_scheme *scheme);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    56
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    57
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    58
 * Decrease the reference count of the object and free it if this was the last reference.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    59
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    60
void flib_scheme_destroy(flib_scheme* scheme);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    61
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    62
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    63
 * Retrieve a mod setting by its name. If the mod is not found, logs an error and returns false.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    64
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    65
bool flib_scheme_get_mod(const flib_scheme *scheme, const char *name);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    66
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    67
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    68
 * Retrieve a game setting by its name. If the setting is not found, logs an error and returns def.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    69
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    70
int flib_scheme_get_setting(const flib_scheme *scheme, const char *name, int def);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    71
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    72
#endif /* SCHEME_H_ */