project_files/frontlib/model/weapon.h
changeset 7497 7e1d72fc03c7
parent 7482 d70a5b0d1190
child 10017 de822cd3df3a
equal deleted inserted replaced
7494:e65adfc99f15 7497:7e1d72fc03c7
    26  * These values are all ASCII characters in the range '0'..'9'
    26  * These values are all ASCII characters in the range '0'..'9'
    27  * The fields are zero-terminated so they can easily be used as strings.
    27  * The fields are zero-terminated so they can easily be used as strings.
    28  *
    28  *
    29  * For loadout, 9 means inifinite ammo.
    29  * For loadout, 9 means inifinite ammo.
    30  * For the other setting, 9 is invalid.
    30  * For the other setting, 9 is invalid.
    31  * TODO stop reference counting, it complects everything
       
    32  */
    31  */
    33 typedef struct {
    32 typedef struct {
    34 	int _referenceCount;
       
    35 	char loadout[WEAPONS_COUNT+1];
    33 	char loadout[WEAPONS_COUNT+1];
    36 	char crateprob[WEAPONS_COUNT+1];
    34 	char crateprob[WEAPONS_COUNT+1];
    37 	char crateammo[WEAPONS_COUNT+1];
    35 	char crateammo[WEAPONS_COUNT+1];
    38 	char delay[WEAPONS_COUNT+1];
    36 	char delay[WEAPONS_COUNT+1];
    39 	char *name;
    37 	char *name;
    52  * settings (see hwconsts.h)
    50  * settings (see hwconsts.h)
    53  */
    51  */
    54 flib_weaponset *flib_weaponset_create(const char *name);
    52 flib_weaponset *flib_weaponset_create(const char *name);
    55 
    53 
    56 /**
    54 /**
    57  * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
    55  * Free the memory used by this weaponset
    58  * Returns the parameter.
       
    59  */
    56  */
    60 flib_weaponset *flib_weaponset_retain(flib_weaponset *weaponset);
    57 void flib_weaponset_destroy(flib_weaponset *weaponset);
    61 
       
    62 /**
       
    63  * Decrease the reference count of the object and free it if this was the last reference.
       
    64  */
       
    65 void flib_weaponset_release(flib_weaponset *weaponset);
       
    66 
    58 
    67 flib_weaponset *flib_weaponset_copy(const flib_weaponset *weaponset);
    59 flib_weaponset *flib_weaponset_copy(const flib_weaponset *weaponset);
    68 
    60 
    69 /**
    61 /**
    70  * Create a weaponset from an ammostring. This format is used both in the ini files
    62  * Create a weaponset from an ammostring. This format is used both in the ini files
    95 void flib_weaponsetlist_destroy(flib_weaponsetlist *list);
    87 void flib_weaponsetlist_destroy(flib_weaponsetlist *list);
    96 
    88 
    97 /**
    89 /**
    98  * Insert a new weaponset into the list at position pos, moving all higher weaponsets to make place.
    90  * Insert a new weaponset into the list at position pos, moving all higher weaponsets to make place.
    99  * pos must be at least 0 (insert at the start) and at most list->weaponsetCount (insert at the end).
    91  * pos must be at least 0 (insert at the start) and at most list->weaponsetCount (insert at the end).
   100  * The weaponset is retained automatically.
    92  * Ownership of the weaponset is transferred to the list.
   101  * Returns 0 on success.
    93  * Returns 0 on success.
   102  */
    94  */
   103 int flib_weaponsetlist_insert(flib_weaponsetlist *list, flib_weaponset *weaponset, int pos);
    95 int flib_weaponsetlist_insert(flib_weaponsetlist *list, flib_weaponset *weaponset, int pos);
   104 
    96 
   105 /**
    97 /**
   106  * Delete a weaponset from the list at position pos, moving down all higher weaponsets.
    98  * Delete a weaponset from the list at position pos, moving down all higher weaponsets.
   107  * The weaponset is released automatically.
    99  * The weaponset is destroyed.
   108  * Returns 0 on success.
   100  * Returns 0 on success.
   109  */
   101  */
   110 int flib_weaponsetlist_delete(flib_weaponsetlist *list, int pos);
   102 int flib_weaponsetlist_delete(flib_weaponsetlist *list, int pos);
   111 
   103 
   112 #endif
   104 #endif