project_files/frontlib/hwconsts.h
author Wuzzy <Wuzzy2@mail.ru>
Wed, 19 Dec 2018 20:27:35 +0100
changeset 14483 35724823b0d3
parent 11046 47a8c19ecb60
child 15520 de08a3ae4f8d
permissions -rw-r--r--
Remove unused vars in uTeams
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     1
/*
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     4
 * Copyright (c) 2012 Simeon Maxein <smaxein@googlemail.com>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     5
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
     9
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    13
 * GNU General Public License for more details.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    14
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    15
 * You should have received a copy of the GNU General Public License
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    16
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10017
diff changeset
    17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    18
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    19
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    20
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    21
 * This file contains important constants which might need to be changed to adapt to
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    22
 * changes in the engine or protocols.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    23
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    24
 * It also contains getter functions for some constants (in particular for constants
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    25
 * that are important for the layout of data structures), so that client code can
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    26
 * query the constants that the library was built with.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    27
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    28
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    29
#ifndef HWCONSTS_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    30
#define HWCONSTS_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    31
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    32
#include <inttypes.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    33
#include <stddef.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    34
#include <stdbool.h>
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    35
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    36
#define HEDGEHOGS_PER_TEAM 8
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    37
#define DEFAULT_HEDGEHOG_COUNT 4
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    38
#define DEFAULT_COLOR_INDEX 0
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    39
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    40
#define NETGAME_DEFAULT_PORT 46631
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    41
#define PROTOCOL_VERSION 42
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    42
#define MIN_SERVER_VERSION 1
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    43
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    44
//! Used for sending scripts to the engine
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    45
#define MULTIPLAYER_SCRIPT_PATH "Scripts/Multiplayer/"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    46
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    47
#define WEAPONS_COUNT 56
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    48
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    49
// TODO allow frontend to override these?
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    50
/*! A merge of mikade/bugq colours w/ a bit of channel feedback */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    51
#define HW_TEAMCOLOR_ARRAY  { UINT32_C(0xffff0204), /*! red    */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    52
                              UINT32_C(0xff4980c1), /*! blue   */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    53
                              UINT32_C(0xff1de6ba), /*! teal   */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    54
                              UINT32_C(0xffb541ef), /*! purple */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    55
                              UINT32_C(0xffe55bb0), /*! pink   */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    56
                              UINT32_C(0xff20bf00), /*! green  */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    57
                              UINT32_C(0xfffe8b0e), /*! orange */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    58
                              UINT32_C(0xff5f3605), /*! brown  */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    59
                              UINT32_C(0xffffff01), /*! yellow */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    60
                              /*! add new colors here */ \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    61
                              0 } /*! Keep this 0 at the end */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    62
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    63
extern const size_t flib_teamcolor_count;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    64
extern const uint32_t flib_teamcolors[];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    65
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    66
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    67
 * Returns the team color (ARGB) corresponding to the color index (0 if index out of bounds)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    68
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    69
uint32_t flib_get_teamcolor(int colorIndex);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    70
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    71
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    72
 * Returns the number of team colors (i.e. the length of the flib_teamcolors array)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    73
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    74
int flib_get_teamcolor_count();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    75
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    76
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    77
 * Returns the HEDGEHOGS_PER_TEAM constant
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    78
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    79
int flib_get_hedgehogs_per_team();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    80
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    81
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    82
 * Returns the WEAPONS_COUNT constant
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    83
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    84
int flib_get_weapons_count();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    85
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    86
/*!
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    87
 * These structs define the meaning of values in the flib_scheme struct, i.e. their correspondence to
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    88
 * ini settings, engine commands and positions in the network protocol (the last is encoded in the
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    89
 * order of settings/mods).
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    90
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    91
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    92
    const char *name;               //!< A name identifying this setting (used as key in the schemes file)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    93
    const char *engineCommand;      //!< The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    94
    const bool maxMeansInfinity;    //!< If true, send a very high number to the engine if the setting is equal to its maximum
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    95
    const bool times1000;           //!< If true (for time-based settings), multiply the setting by 1000 before sending it to the engine.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    96
    const int min;                  //!< The smallest allowed value
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    97
    const int max;                  //!< The highest allowed value
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    98
    const int def;                  //!< The default value
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
    99
} flib_metascheme_setting;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   100
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   101
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   102
    const char *name;               //!< A name identifying this mod (used as key in the schemes file)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   103
    const int bitmaskIndex;         //!< Mods are sent to the engine in a single integer, this field describes which bit of that integer is used
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   104
                                    //! for this particular mod.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   105
} flib_metascheme_mod;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   106
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   107
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   108
    const int settingCount;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   109
    const int modCount;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   110
    const flib_metascheme_setting *settings;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   111
    const flib_metascheme_mod *mods;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   112
} flib_metascheme;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   113
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   114
extern const flib_metascheme flib_meta;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   115
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   116
const flib_metascheme *flib_get_metascheme();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   117
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 10015
diff changeset
   118
#endif