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)
178 if (claim->ids[i] == sys)
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++) {
212 free( claim->strs[i] );
226 sys_rmFlag( &sys[i], SYSTEM_CLAIMED );
227 sys[i].claims_soft = 0;
254 for (
int i=0; i<
array_size(claim->ids); i++) {
256 if (claim->exclusive)
257 sys_setFlag( sys, SYSTEM_CLAIMED );
283 xmlw_attr( writer,
"exclusive",
"%d", claim->exclusive );
285 for (
int i=0; i<
array_size(claim->ids); i++) {
288 xmlw_elem( writer,
"sys",
"%s", sys->name );
290 WARN(_(
"System Claim has inexistent system"));
294 xmlw_elem( writer,
"str",
"%s", claim->strs[i] );
312 xmlr_attr_int_def( parent,
"exclusive", exclusive, 1 );
318 node = parent->xmlChildrenNode;
320 if (xml_isNode(node,
"sys")) {
321 StarSystem *sys =
system_get( xml_get(node) );
325 WARN(_(
"System Claim trying to load system '%s' which doesn't exist"), xml_get(node));
327 else if (xml_isNode(node,
"str")) {
328 char *str = xml_get(node);
331 }
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.