project_files/frontlib/model/weapon.h
changeset 7230 240620f46dd7
parent 7224 5143861c83bd
child 7271 5608ac657362
equal deleted inserted replaced
7227:1c859f572d72 7230:240620f46dd7
     8  *
     8  *
     9  * For loadout, 9 means inifinite ammo.
     9  * For loadout, 9 means inifinite ammo.
    10  * For the other setting, 9 is invalid.
    10  * For the other setting, 9 is invalid.
    11  */
    11  */
    12 typedef struct {
    12 typedef struct {
       
    13 	int _referenceCount;
    13 	char loadout[WEAPONS_COUNT+1];
    14 	char loadout[WEAPONS_COUNT+1];
    14 	char crateprob[WEAPONS_COUNT+1];
    15 	char crateprob[WEAPONS_COUNT+1];
    15 	char crateammo[WEAPONS_COUNT+1];
    16 	char crateammo[WEAPONS_COUNT+1];
    16 	char delay[WEAPONS_COUNT+1];
    17 	char delay[WEAPONS_COUNT+1];
    17 	char *name;
    18 	char *name;
    18 } flib_weaponset;
    19 } flib_weaponset;
       
    20 
       
    21 typedef struct {
       
    22 	int _referenceCount;
       
    23 	int weaponsetCount;
       
    24 	flib_weaponset **weaponsets;
       
    25 } flib_weaponsetlist;
    19 
    26 
    20 /**
    27 /**
    21  * Returns a new weapon set, or NULL on error.
    28  * Returns a new weapon set, or NULL on error.
    22  * name must not be NULL.
    29  * name must not be NULL.
    23  *
    30  *
    25  * settings (see hwconsts.h)
    32  * settings (see hwconsts.h)
    26  */
    33  */
    27 flib_weaponset *flib_weaponset_create(const char *name);
    34 flib_weaponset *flib_weaponset_create(const char *name);
    28 
    35 
    29 /**
    36 /**
    30  * Loads a weapon set, returns NULL on error.
    37  * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
       
    38  * Returns the parameter.
    31  */
    39  */
    32 flib_weaponset *flib_weaponset_from_ini(const char *filename);
    40 flib_weaponset *flib_weaponset_retain(flib_weaponset *weaponset);
    33 
    41 
    34 /**
    42 /**
    35  * Write the weapon set to an ini file. Attempts to
    43  * Decrease the reference count of the object and free it if this was the last reference.
    36  * retain extra ini settings that were already present.
       
    37  */
    44  */
    38 int flib_weaponset_to_ini(const char *filename, const flib_weaponset *set);
    45 void flib_weaponset_release(flib_weaponset *weaponset);
    39 void flib_weaponset_destroy(flib_weaponset *set);
    46 
       
    47 /**
       
    48  * Load a list of weaponsets from the ini file.
       
    49  * Returns NULL on error.
       
    50  */
       
    51 flib_weaponsetlist *flib_weaponsetlist_from_ini(const char *filename);
       
    52 
       
    53 /**
       
    54  * Store the list of weaponsets to an ini file.
       
    55  * Returns NULL on error.
       
    56  */
       
    57 int flib_weaponsetlist_to_ini(const char *filename, const flib_weaponsetlist *weaponsets);
       
    58 
       
    59 /**
       
    60  * Create an empty weaponset list. Returns NULL on error.
       
    61  */
       
    62 flib_weaponsetlist *flib_weaponsetlist_create();
       
    63 
       
    64 /**
       
    65  * Insert a new weaponset into the list at position pos, moving all higher weaponsets to make place.
       
    66  * pos must be at least 0 (insert at the start) and at most list->weaponsetCount (insert at the end).
       
    67  * The weaponset is retained automatically.
       
    68  * Returns 0 on success.
       
    69  */
       
    70 int flib_weaponsetlist_insert(flib_weaponsetlist *list, flib_weaponset *weaponset, int pos);
       
    71 
       
    72 /**
       
    73  * Delete a weaponset from the list at position pos, moving down all higher weaponsets.
       
    74  * The weaponset is released automatically.
       
    75  * Returns 0 on success.
       
    76  */
       
    77 int flib_weaponsetlist_delete(flib_weaponsetlist *list, int pos);
       
    78 
       
    79 /**
       
    80  * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
       
    81  * Returns the parameter.
       
    82  */
       
    83 flib_weaponsetlist *flib_weaponsetlist_retain(flib_weaponsetlist *list);
       
    84 
       
    85 /**
       
    86  * Decrease the reference count of the object and free it if this was the last reference.
       
    87  */
       
    88 void flib_weaponsetlist_release(flib_weaponsetlist *list);
    40 
    89 
    41 #endif
    90 #endif