44 Claim_t *claim = malloc(
sizeof( Claim_t ) );
48 claim->exclusive = exclusive;
61 assert( !claim->active );
63 if ( claim->strs == NULL )
79 assert( !claim->active );
81 if ( claim->ids == NULL )
120 exc = claim->exclusive;
123 for (
int i = 0; i <
array_size( claim->ids ); i++ ) {
125 int claimed = sys_isFlag( sys, SYSTEM_CLAIMED );
126 if ( claimed || ( exc && ( sys->claims_soft > 0 ) ) )
131 for (
int i = 0; i <
array_size( claim->strs ); i++ ) {
155 for (
int i = 0; i <
array_size( claim->strs ); i++ ) {
156 if ( strcmp( claim->strs[i], str ) == 0 )
177 for (
int i = 0; i <
array_size( claim->ids ); i++ )
178 if ( claim->ids[i] == sys )
191 if ( claim->active ) {
192 for (
int i = 0; i <
array_size( claim->ids ); i++ ) {
194 if ( claim->exclusive )
195 sys_rmFlag( sys, SYSTEM_CLAIMED );
202 for (
int i = 0; i <
array_size( claim->strs ); i++ ) {
203 if ( claim->active ) {
213 free( claim->strs[i] );
226 for (
int i = 0; i <
array_size( sys ); i++ ) {
227 sys_rmFlag( &sys[i], SYSTEM_CLAIMED );
228 sys[i].claims_soft = 0;
255 for (
int i = 0; i <
array_size( claim->ids ); i++ ) {
257 if ( claim->exclusive )
258 sys_setFlag( sys, SYSTEM_CLAIMED );
266 for (
int i = 0; i <
array_size( claim->strs ); i++ )
284 xmlw_attr( writer,
"exclusive",
"%d", claim->exclusive );
286 for (
int i = 0; i <
array_size( claim->ids ); i++ ) {
289 xmlw_elem( writer,
"sys",
"%s", sys->name );
291 WARN( _(
"System Claim has inexistent system" ) );
294 for (
int i = 0; i <
array_size( claim->strs ); i++ )
295 xmlw_elem( writer,
"str",
"%s", claim->strs[i] );
313 xmlr_attr_int_def( parent,
"exclusive", exclusive, 1 );
319 node = parent->xmlChildrenNode;
321 if ( xml_isNode( node,
"sys" ) ) {
322 const StarSystem *sys =
system_get( xml_get( node ) );
326 WARN( _(
"System Claim trying to load system '%s' which doesn't "
329 }
else if ( xml_isNode( node,
"str" ) ) {
330 const char *str = xml_get( node );
333 }
while ( xml_nextNode( node ) );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
int claim_test(const Claim_t *claim)
Tests to see if a system claim would have collisions.
void claim_destroy(Claim_t *claim)
Destroys a system claim.
void claim_clear(void)
Clears the claims on all systems.
int claim_addStr(Claim_t *claim, const char *str)
Adds a string claim to a claim.
int claim_addSys(Claim_t *claim, int ss_id)
Adds a claim to a system claim.
void claim_activate(Claim_t *claim)
Activates a claim on a system.
int claim_testSys(const Claim_t *claim, int sys)
Tests to see if a system is claimed by a system claim.
int claim_isNull(const Claim_t *claim)
See if a claim actually contains data.
Claim_t * claim_xmlLoad(xmlNodePtr parent)
Loads a claim.
static char ** claimed_strs
int claim_xmlSave(xmlTextWriterPtr writer, const Claim_t *claim)
Saves all the systems in a claim in XML.
Claim_t * claim_create(int exclusive)
Creates a system claim.
int claim_testStr(const Claim_t *claim, const char *str)
Tests to see if a system is claimed by a system claim.
void claim_activateAll(void)
Activates all the claims.
void event_activateClaims(void)
Activates all the active event claims.
void missions_activateClaims(void)
Activates mission claims.
Header file with generic functions and naev-specifics.
StarSystem * system_getIndex(int id)
Get the system by its index.
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
StarSystem * system_get(const char *sysname)
Get the system from its name.
int system_index(const StarSystem *sys)
Gets the index of a star system.