project_files/frontlib/model/weapon.h
author alfadur
Sun, 26 May 2019 19:12:16 +0300
changeset 15060 9dbbb4bc1dcd
parent 10017 de822cd3df3a
permissions -rw-r--r--
add idle shouryuuken animation
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
#ifndef MODEL_WEAPON_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    21
#define MODEL_WEAPON_H_
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    22
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    23
#include "../hwconsts.h"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    24
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    25
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    26
 * These values are all ASCII characters in the range '0'..'9'
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    27
 * The fields are zero-terminated so they can easily be used as strings.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    28
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    29
 * For loadout, 9 means inifinite ammo.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    30
 * For the other setting, 9 is invalid.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    31
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    32
typedef struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    33
    char loadout[WEAPONS_COUNT+1];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    34
    char crateprob[WEAPONS_COUNT+1];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    35
    char crateammo[WEAPONS_COUNT+1];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    36
    char delay[WEAPONS_COUNT+1];
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    37
    char *name;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    38
} flib_weaponset;
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
    int weaponsetCount;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    42
    flib_weaponset **weaponsets;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    43
} flib_weaponsetlist;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    44
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    45
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    46
 * Returns a new weapon set, or NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    47
 * name must not be NULL.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    48
 *
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    49
 * The new weapon set is pre-filled with default
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    50
 * settings (see hwconsts.h)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    51
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    52
flib_weaponset *flib_weaponset_create(const char *name);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    53
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    54
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    55
 * Free the memory used by this weaponset
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    56
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    57
void flib_weaponset_destroy(flib_weaponset *weaponset);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    58
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    59
flib_weaponset *flib_weaponset_copy(const flib_weaponset *weaponset);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    60
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    61
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    62
 * Create a weaponset from an ammostring. This format is used both in the ini files
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    63
 * and in the net protocol.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    64
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    65
flib_weaponset *flib_weaponset_from_ammostring(const char *name, const char *ammostring);
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
 * Load a list of weaponsets from the ini file.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    69
 * Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    70
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    71
flib_weaponsetlist *flib_weaponsetlist_from_ini(const char *filename);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    72
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    73
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    74
 * Store the list of weaponsets to an ini file.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    75
 * Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    76
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    77
int flib_weaponsetlist_to_ini(const char *filename, const flib_weaponsetlist *weaponsets);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    78
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    79
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    80
 * Create an empty weaponset list. Returns NULL on error.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    81
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    82
flib_weaponsetlist *flib_weaponsetlist_create();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    83
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    84
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    85
 * Release all memory associated with the weaponsetlist and release all contained weaponsets
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    86
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    87
void flib_weaponsetlist_destroy(flib_weaponsetlist *list);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    88
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    89
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    90
 * Insert a new weaponset into the list at position pos, moving all higher weaponsets to make place.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    91
 * pos must be at least 0 (insert at the start) and at most list->weaponsetCount (insert at the end).
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    92
 * Ownership of the weaponset is transferred to the list.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    93
 * Returns 0 on success.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    94
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    95
int flib_weaponsetlist_insert(flib_weaponsetlist *list, flib_weaponset *weaponset, int pos);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    96
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    97
/**
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    98
 * Delete a weaponset from the list at position pos, moving down all higher weaponsets.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
    99
 * The weaponset is destroyed.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
   100
 * Returns 0 on success.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
   101
 */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
   102
int flib_weaponsetlist_delete(flib_weaponsetlist *list, int pos);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
   103
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7497
diff changeset
   104
#endif