25#include "map_overlay.h"
36typedef struct UniDiffData_ {
47typedef enum UniHunkTargetType_ {
60typedef struct UniHunkTarget_ {
72typedef enum UniHunkType_ {
76 HUNK_TYPE_SPOB_REMOVE,
78 HUNK_TYPE_VSPOB_REMOVE,
80 HUNK_TYPE_JUMP_REMOVE,
81 HUNK_TYPE_SSYS_BACKGROUND,
82 HUNK_TYPE_SSYS_BACKGROUND_REVERT,
83 HUNK_TYPE_SSYS_FEATURES,
84 HUNK_TYPE_SSYS_FEATURES_REVERT,
87 HUNK_TYPE_TECH_REMOVE,
89 HUNK_TYPE_SPOB_FACTION,
90 HUNK_TYPE_SPOB_FACTION_REMOVE,
91 HUNK_TYPE_SPOB_POPULATION,
92 HUNK_TYPE_SPOB_POPULATION_REMOVE,
93 HUNK_TYPE_SPOB_DISPLAYNAME,
94 HUNK_TYPE_SPOB_DISPLAYNAME_REVERT,
95 HUNK_TYPE_SPOB_DESCRIPTION,
96 HUNK_TYPE_SPOB_DESCRIPTION_REVERT,
98 HUNK_TYPE_SPOB_BAR_REVERT,
99 HUNK_TYPE_SPOB_SERVICE_ADD,
100 HUNK_TYPE_SPOB_SERVICE_REMOVE,
101 HUNK_TYPE_SPOB_TECH_ADD,
102 HUNK_TYPE_SPOB_TECH_REMOVE,
103 HUNK_TYPE_SPOB_TAG_ADD,
104 HUNK_TYPE_SPOB_TAG_REMOVE,
105 HUNK_TYPE_SPOB_SPACE,
106 HUNK_TYPE_SPOB_SPACE_REVERT,
107 HUNK_TYPE_SPOB_EXTERIOR,
108 HUNK_TYPE_SPOB_EXTERIOR_REVERT,
110 HUNK_TYPE_SPOB_LUA_REVERT,
112 HUNK_TYPE_FACTION_VISIBLE,
113 HUNK_TYPE_FACTION_INVISIBLE,
114 HUNK_TYPE_FACTION_ALLY,
115 HUNK_TYPE_FACTION_ENEMY,
116 HUNK_TYPE_FACTION_NEUTRAL,
117 HUNK_TYPE_FACTION_REALIGN,
125typedef struct UniHunk_ {
145typedef struct UniDiff_ {
184static
int diff_cmp( const
void *p1, const
void *p2 )
189 return strcmp( d1->
name, d2->
name );
199 Uint32 time = SDL_GetTicks();
202 for (
int i=0; i<
array_size(diff_files); i++ ) {
210 free( diff_files[i] );
214 node = doc->xmlChildrenNode;
215 if (!xml_isNode(node,
"unidiff")) {
216 WARN( _(
"Malformed XML header for '%s' UniDiff: missing root element '%s'"), diff_files[i],
"unidiff" );
218 free( diff_files[i] );
224 xmlr_attr_strd(node,
"name", diff->
name);
235 if (strcmp(
d->name, dn->
name )==0)
236 WARN(_(
"Two unidiff have the same name '%s'!"),
d->name );
240 time = SDL_GetTicks() - time;
311 WARN(_(
"UniDiff '%s' not found in %s!"), name, UNIDIFF_DATA_PATH);
317 node = doc->xmlChildrenNode;
318 if (strcmp((
char*)node->name,
"unidiff")) {
319 ERR(_(
"Malformed unidiff file: missing root element 'unidiff'"));
353 WARN(_(
"Unidiff '%s' has a system node without a 'name' tag, not applying."), diff->
name);
358 cur = node->xmlChildrenNode;
361 if (xml_isNode(cur,
"spob")) {
362 buf = xml_get( cur );
364 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
372 xmlr_attr_strd(cur,
"name",hunk.
u.name);
375 if (strcmp(buf,
"add")==0)
376 hunk.
type = HUNK_TYPE_SPOB_ADD;
377 else if (strcmp(buf,
"remove")==0)
378 hunk.
type = HUNK_TYPE_SPOB_REMOVE;
380 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for spob '%s'."), diff->
name, buf, hunk.
u.name);
389 else if (xml_isNode(cur,
"spob_virtual")) {
390 buf = xml_get( cur );
392 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
400 xmlr_attr_strd(cur,
"name",hunk.
u.name);
403 if (strcmp(buf,
"add")==0)
404 hunk.
type = HUNK_TYPE_VSPOB_ADD;
405 else if (strcmp(buf,
"remove")==0)
406 hunk.
type = HUNK_TYPE_VSPOB_REMOVE;
408 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for virtual spob '%s'."), diff->
name, buf, hunk.
u.name);
417 else if (xml_isNode(cur,
"jump")) {
418 buf = xml_get( cur );
420 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
428 xmlr_attr_strd(cur,
"target",hunk.
u.name);
431 if (strcmp(buf,
"add")==0)
432 hunk.
type = HUNK_TYPE_JUMP_ADD;
433 else if (strcmp(buf,
"remove")==0)
434 hunk.
type = HUNK_TYPE_JUMP_REMOVE;
436 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for jump '%s'."), diff->
name, buf, hunk.
u.name);
447 else if (xml_isNode(cur,
"background")) {
450 hunk.
type = HUNK_TYPE_SSYS_BACKGROUND;
451 hunk.
u.name = xml_getStrd(cur);
460 else if (xml_isNode(cur,
"features")) {
463 hunk.
type = HUNK_TYPE_SSYS_FEATURES;
464 hunk.
u.name = xml_getStrd(cur);
473 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
474 }
while (xml_nextNode(cur));
500 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
505 cur = node->xmlChildrenNode;
508 if (xml_isNode(cur,
"add")) {
513 hunk.
type = HUNK_TYPE_TECH_ADD;
516 hunk.
u.name = xml_getStrd(cur);
525 else if (xml_isNode(cur,
"remove")) {
530 hunk.
type = HUNK_TYPE_TECH_REMOVE;
533 hunk.
u.name = xml_getStrd(cur);
542 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
543 }
while (xml_nextNode(cur));
569 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
574 cur = node->xmlChildrenNode;
577 if (xml_isNode(cur,
"faction")) {
580 hunk.
type = HUNK_TYPE_SPOB_FACTION;
581 hunk.
u.name = xml_getStrd(cur);
590 else if (xml_isNode(cur,
"population")) {
593 hunk.
type = HUNK_TYPE_SPOB_POPULATION;
594 hunk.
u.data = xml_getUInt(cur);
603 else if (xml_isNode(cur,
"displayname")) {
606 hunk.
type = HUNK_TYPE_SPOB_DISPLAYNAME;
607 hunk.
u.name = xml_getStrd(cur);
616 else if (xml_isNode(cur,
"description")) {
619 hunk.
type = HUNK_TYPE_SPOB_DESCRIPTION;
620 hunk.
u.name = xml_getStrd(cur);
629 else if (xml_isNode(cur,
"bar")) {
632 hunk.
type = HUNK_TYPE_SPOB_BAR;
633 hunk.
u.name = xml_getStrd(cur);
642 else if (xml_isNode(cur,
"service_add")) {
645 hunk.
type = HUNK_TYPE_SPOB_SERVICE_ADD;
655 else if (xml_isNode(cur,
"service_remove")) {
658 hunk.
type = HUNK_TYPE_SPOB_SERVICE_REMOVE;
668 else if (xml_isNode(cur,
"tech_add")) {
671 hunk.
type = HUNK_TYPE_SPOB_TECH_ADD;
672 hunk.
u.name = xml_getStrd(cur);
681 else if (xml_isNode(cur,
"tech_remove")) {
684 hunk.
type = HUNK_TYPE_SPOB_TECH_REMOVE;
685 hunk.
u.name = xml_getStrd(cur);
694 else if (xml_isNode(cur,
"tag_add")) {
697 hunk.
type = HUNK_TYPE_SPOB_TAG_ADD;
698 hunk.
u.name = xml_getStrd(cur);
707 else if (xml_isNode(cur,
"tag_remove")) {
710 hunk.
type = HUNK_TYPE_SPOB_TAG_REMOVE;
711 hunk.
u.name = xml_getStrd(cur);
720 else if (xml_isNode(cur,
"gfx_space")) {
724 hunk.
type = HUNK_TYPE_SPOB_SPACE;
725 snprintf( str,
sizeof(str), SPOB_GFX_SPACE_PATH
"%s", xml_get(cur));
726 hunk.
u.name = strdup(str);
735 else if (xml_isNode(cur,
"gfx_exterior")) {
739 hunk.
type = HUNK_TYPE_SPOB_EXTERIOR;
740 snprintf( str,
sizeof(str), SPOB_GFX_EXTERIOR_PATH
"%s", xml_get(cur));
741 hunk.
u.name = strdup(str);
750 else if (xml_isNode(cur,
"lua")) {
754 hunk.
type = HUNK_TYPE_SPOB_LUA;
757 hunk.
u.name = strdup( str );
768 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, cur->name);
769 }
while (xml_nextNode(cur));
796 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
801 cur = node->xmlChildrenNode;
804 if (xml_isNode(cur,
"visible")) {
809 hunk.
type = HUNK_TYPE_FACTION_VISIBLE;
821 else if (xml_isNode(cur,
"invisible")) {
826 hunk.
type = HUNK_TYPE_FACTION_INVISIBLE;
838 else if (xml_isNode(cur,
"faction")) {
839 buf = xml_get( cur );
841 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
849 xmlr_attr_strd(cur,
"name",hunk.
u.name);
852 if (strcmp(buf,
"ally")==0)
853 hunk.
type = HUNK_TYPE_FACTION_ALLY;
854 else if (strcmp(buf,
"enemy")==0)
855 hunk.
type = HUNK_TYPE_FACTION_ENEMY;
856 else if (strcmp(buf,
"neutral")==0)
857 hunk.
type = HUNK_TYPE_FACTION_NEUTRAL;
859 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for faction '%s'."), diff->
name, buf, hunk.
u.name);
868 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
869 }
while (xml_nextNode(cur));
893 xmlr_attr_strd(parent,
"name",diff->
name);
895 node = parent->xmlChildrenNode;
898 if (xml_isNode(node,
"system")) {
902 else if (xml_isNode(node,
"tech"))
904 else if (xml_isNode(node,
"spob")) {
908 else if (xml_isNode(node,
"faction")) {
913 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
914 }
while (xml_nextNode(node));
919 n_(
"Unidiff '%s' failed to apply %d hunk.",
"Unidiff '%s' failed to apply %d hunks.", nfailed ),
920 diff->
name, nfailed );
921 for (
int i=0; i<nfailed; i++) {
924 switch (fail->
type) {
925 case HUNK_TYPE_SPOB_ADD:
926 WARN(_(
" [%s] spob add: '%s'"), target, fail->
u.name);
928 case HUNK_TYPE_SPOB_REMOVE:
929 WARN(_(
" [%s] spob remove: '%s'"), target, fail->
u.name);
931 case HUNK_TYPE_VSPOB_ADD:
932 WARN(_(
" [%s] virtual spob add: '%s'"), target, fail->
u.name);
934 case HUNK_TYPE_VSPOB_REMOVE:
935 WARN(_(
" [%s] virtual spob remove: '%s'"), target, fail->
u.name);
937 case HUNK_TYPE_JUMP_ADD:
938 WARN(_(
" [%s] jump add: '%s'"), target, fail->
u.name);
940 case HUNK_TYPE_JUMP_REMOVE:
941 WARN(_(
" [%s] jump remove: '%s'"), target, fail->
u.name);
943 case HUNK_TYPE_TECH_ADD:
944 WARN(_(
" [%s] tech add: '%s'"), target,
947 case HUNK_TYPE_TECH_REMOVE:
948 WARN(_(
" [%s] tech remove: '%s'"), target,
951 case HUNK_TYPE_SPOB_FACTION:
952 WARN(_(
" [%s] spob faction: '%s'"), target,
955 case HUNK_TYPE_SPOB_FACTION_REMOVE:
956 WARN(_(
" [%s] spob faction removal: '%s'"), target,
959 case HUNK_TYPE_SPOB_POPULATION:
960 WARN(_(
" [%s] spob population: '%s'"), target,
963 case HUNK_TYPE_SPOB_POPULATION_REMOVE:
964 WARN(_(
" [%s] spob population removal: '%s'"), target,
967 case HUNK_TYPE_SPOB_DISPLAYNAME:
968 WARN(_(
" [%s] spob displayname: '%s'"), target,
971 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
972 WARN(_(
" [%s] spob displayname revert: '%s'"), target,
975 case HUNK_TYPE_SPOB_DESCRIPTION:
976 WARN(_(
" [%s] spob description: '%s'"), target,
979 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
980 WARN(_(
" [%s] spob description revert: '%s'"), target,
983 case HUNK_TYPE_SPOB_BAR:
984 WARN(_(
" [%s] spob bar: '%s'"), target,
987 case HUNK_TYPE_SPOB_BAR_REVERT:
988 WARN(_(
" [%s] spob bar revert: '%s'"), target,
991 case HUNK_TYPE_SPOB_SPACE:
992 WARN(_(
" [%s] spob space: '%s'"), target,
995 case HUNK_TYPE_SPOB_SPACE_REVERT:
996 WARN(_(
" [%s] spob space revert: '%s'"), target,
999 case HUNK_TYPE_SPOB_EXTERIOR:
1000 WARN(_(
" [%s] spob exterior: '%s'"), target,
1003 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1004 WARN(_(
" [%s] spob exterior revert: '%s'"), target,
1007 case HUNK_TYPE_SPOB_LUA:
1008 WARN(_(
" [%s] spob lua: '%s'"), target,
1011 case HUNK_TYPE_SPOB_LUA_REVERT:
1012 WARN(_(
" [%s] spob lua revert: '%s'"), target,
1015 case HUNK_TYPE_SPOB_SERVICE_ADD:
1016 WARN(_(
" [%s] spob service add: '%s'"), target,
1019 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1020 WARN(_(
" [%s] spob service remove: '%s'"), target,
1023 case HUNK_TYPE_SPOB_TECH_ADD:
1024 WARN(_(
" [%s] spob tech add: '%s'"), target,
1027 case HUNK_TYPE_SPOB_TECH_REMOVE:
1028 WARN(_(
" [%s] spob tech remove: '%s'"), target,
1031 case HUNK_TYPE_SPOB_TAG_ADD:
1032 WARN(_(
" [%s] spob tech add: '%s'"), target,
1035 case HUNK_TYPE_SPOB_TAG_REMOVE:
1036 WARN(_(
" [%s] spob tech remove: '%s'"), target,
1039 case HUNK_TYPE_FACTION_VISIBLE:
1040 WARN(_(
" [%s] faction visible: '%s'"), target,
1043 case HUNK_TYPE_FACTION_INVISIBLE:
1044 WARN(_(
" [%s] faction invisible: '%s'"), target,
1047 case HUNK_TYPE_FACTION_ALLY:
1048 WARN(_(
" [%s] faction set ally: '%s'"), target,
1051 case HUNK_TYPE_FACTION_ENEMY:
1052 WARN(_(
" [%s] faction set enemy: '%s'"), target,
1055 case HUNK_TYPE_FACTION_NEUTRAL:
1056 WARN(_(
" [%s] faction set neutral: '%s'"), target,
1059 case HUNK_TYPE_FACTION_REALIGN:
1060 WARN(_(
" [%s] faction alignment reset: '%s'"), target,
1065 WARN(_(
" unknown hunk '%d'"), fail->
type);
1088 switch (hunk->
type) {
1091 case HUNK_TYPE_SPOB_ADD:
1096 case HUNK_TYPE_SPOB_REMOVE:
1101 case HUNK_TYPE_VSPOB_ADD:
1105 case HUNK_TYPE_VSPOB_REMOVE:
1110 case HUNK_TYPE_JUMP_ADD:
1114 case HUNK_TYPE_JUMP_REMOVE:
1119 case HUNK_TYPE_SSYS_BACKGROUND:
1121 hunk->o.name = ssys->background;
1122 ssys->background = hunk->
u.name;
1124 case HUNK_TYPE_SSYS_BACKGROUND_REVERT:
1126 ssys->background = (
char*)hunk->o.name;
1130 case HUNK_TYPE_SSYS_FEATURES:
1132 hunk->o.name = ssys->features;
1133 ssys->features = hunk->
u.name;
1135 case HUNK_TYPE_SSYS_FEATURES_REVERT:
1137 ssys->features = (
char*)hunk->o.name;
1141 case HUNK_TYPE_TECH_ADD:
1144 case HUNK_TYPE_TECH_REMOVE:
1148 case HUNK_TYPE_SPOB_FACTION:
1152 if (p->presence.faction<0)
1153 hunk->o.name = NULL;
1158 case HUNK_TYPE_SPOB_FACTION_REMOVE:
1163 if (hunk->o.name==NULL)
1169 case HUNK_TYPE_SPOB_POPULATION:
1173 hunk->o.data = p->population;
1174 p->population = hunk->
u.data;
1176 case HUNK_TYPE_SPOB_POPULATION_REMOVE:
1180 p->population = hunk->o.data;
1184 case HUNK_TYPE_SPOB_DISPLAYNAME:
1188 hunk->o.name = p->display;
1189 p->display = hunk->
u.name;
1191 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
1195 p->display = (
char*)hunk->o.name;
1199 case HUNK_TYPE_SPOB_DESCRIPTION:
1203 hunk->o.name = p->description;
1204 p->description = hunk->
u.name;
1206 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
1210 p->description = (
char*)hunk->o.name;
1214 case HUNK_TYPE_SPOB_BAR:
1218 hunk->o.name = p->bar_description;
1219 p->bar_description = hunk->
u.name;
1221 case HUNK_TYPE_SPOB_BAR_REVERT:
1225 p->bar_description = (
char*)hunk->o.name;
1229 case HUNK_TYPE_SPOB_SERVICE_ADD:
1233 if (spob_hasService( p, hunk->
u.data ))
1238 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1242 if (!spob_hasService( p, hunk->
u.data ))
1249 case HUNK_TYPE_SPOB_TECH_ADD:
1253 if (p->tech == NULL)
1257 case HUNK_TYPE_SPOB_TECH_REMOVE:
1265 case HUNK_TYPE_SPOB_TAG_ADD:
1269 if (p->tech == NULL)
1275 case HUNK_TYPE_SPOB_TAG_REMOVE:
1281 if (strcmp(p->tags[i], hunk->
u.name )==0) {
1289 array_erase( &p->tags, &p->tags[a], &p->tags[a+1] );
1293 case HUNK_TYPE_SPOB_SPACE:
1297 hunk->o.name = p->gfx_spaceName;
1298 p->gfx_spaceName = hunk->
u.name;
1301 case HUNK_TYPE_SPOB_SPACE_REVERT:
1305 p->gfx_spaceName = (
char*)hunk->o.name;
1310 case HUNK_TYPE_SPOB_EXTERIOR:
1314 hunk->o.name = p->gfx_exterior;
1315 p->gfx_exterior = hunk->
u.name;
1317 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1321 p->gfx_exterior = (
char*)hunk->o.name;
1325 case HUNK_TYPE_SPOB_LUA:
1329 hunk->o.name = p->lua_file;
1330 p->lua_file = hunk->
u.name;
1334 case HUNK_TYPE_SPOB_LUA_REVERT:
1338 p->lua_file = (
char*)hunk->o.name;
1344 case HUNK_TYPE_FACTION_VISIBLE:
1347 case HUNK_TYPE_FACTION_INVISIBLE:
1350 case HUNK_TYPE_FACTION_ALLY:
1363 case HUNK_TYPE_FACTION_ENEMY:
1376 case HUNK_TYPE_FACTION_NEUTRAL:
1391 case HUNK_TYPE_FACTION_REALIGN:
1394 if (hunk->o.data ==
'A') {
1400 else if (hunk->o.data ==
'E') {
1415 WARN(_(
"Unknown hunk type '%d'."), hunk->
type);
1432 if (diff->
failed == NULL)
1491 free(
d->filename );
1521 switch (hunk.
type) {
1522 case HUNK_TYPE_SPOB_ADD:
1523 hunk.
type = HUNK_TYPE_SPOB_REMOVE;
1525 case HUNK_TYPE_SPOB_REMOVE:
1526 hunk.
type = HUNK_TYPE_SPOB_ADD;
1529 case HUNK_TYPE_VSPOB_ADD:
1530 hunk.
type = HUNK_TYPE_VSPOB_REMOVE;
1532 case HUNK_TYPE_VSPOB_REMOVE:
1533 hunk.
type = HUNK_TYPE_VSPOB_ADD;
1536 case HUNK_TYPE_JUMP_ADD:
1537 hunk.
type = HUNK_TYPE_JUMP_REMOVE;
1539 case HUNK_TYPE_JUMP_REMOVE:
1540 hunk.
type = HUNK_TYPE_JUMP_ADD;
1543 case HUNK_TYPE_SSYS_BACKGROUND:
1544 hunk.
type = HUNK_TYPE_SSYS_BACKGROUND_REVERT;
1546 case HUNK_TYPE_SSYS_FEATURES:
1547 hunk.
type = HUNK_TYPE_SSYS_FEATURES_REVERT;
1550 case HUNK_TYPE_TECH_ADD:
1551 hunk.
type = HUNK_TYPE_TECH_REMOVE;
1553 case HUNK_TYPE_TECH_REMOVE:
1554 hunk.
type = HUNK_TYPE_TECH_ADD;
1557 case HUNK_TYPE_SPOB_FACTION:
1558 hunk.
type = HUNK_TYPE_SPOB_FACTION_REMOVE;
1561 case HUNK_TYPE_SPOB_POPULATION:
1562 hunk.
type = HUNK_TYPE_SPOB_POPULATION_REMOVE;
1565 case HUNK_TYPE_SPOB_DISPLAYNAME:
1566 hunk.
type = HUNK_TYPE_SPOB_DISPLAYNAME_REVERT;
1569 case HUNK_TYPE_SPOB_DESCRIPTION:
1570 hunk.
type = HUNK_TYPE_SPOB_DESCRIPTION_REVERT;
1573 case HUNK_TYPE_SPOB_BAR:
1574 hunk.
type = HUNK_TYPE_SPOB_BAR_REVERT;
1577 case HUNK_TYPE_SPOB_SERVICE_ADD:
1578 hunk.
type = HUNK_TYPE_SPOB_SERVICE_REMOVE;
1580 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1581 hunk.
type = HUNK_TYPE_SPOB_SERVICE_ADD;
1584 case HUNK_TYPE_SPOB_TECH_ADD:
1585 hunk.
type = HUNK_TYPE_SPOB_TECH_REMOVE;
1587 case HUNK_TYPE_SPOB_TECH_REMOVE:
1588 hunk.
type = HUNK_TYPE_SPOB_TECH_ADD;
1591 case HUNK_TYPE_SPOB_TAG_ADD:
1592 hunk.
type = HUNK_TYPE_SPOB_TAG_REMOVE;
1594 case HUNK_TYPE_SPOB_TAG_REMOVE:
1595 hunk.
type = HUNK_TYPE_SPOB_TAG_ADD;
1598 case HUNK_TYPE_SPOB_SPACE:
1599 hunk.
type = HUNK_TYPE_SPOB_SPACE_REVERT;
1602 case HUNK_TYPE_SPOB_EXTERIOR:
1603 hunk.
type = HUNK_TYPE_SPOB_EXTERIOR_REVERT;
1606 case HUNK_TYPE_SPOB_LUA:
1607 hunk.
type = HUNK_TYPE_SPOB_LUA_REVERT;
1610 case HUNK_TYPE_FACTION_VISIBLE:
1611 hunk.
type = HUNK_TYPE_FACTION_INVISIBLE;
1613 case HUNK_TYPE_FACTION_INVISIBLE:
1614 hunk.
type = HUNK_TYPE_FACTION_VISIBLE;
1617 case HUNK_TYPE_FACTION_ALLY:
1618 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1620 case HUNK_TYPE_FACTION_ENEMY:
1621 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1623 case HUNK_TYPE_FACTION_NEUTRAL:
1624 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1628 WARN(_(
"Unknown Hunk type '%d'."), hunk.
type);
1633 WARN(_(
"Failed to remove hunk type '%d'."), hunk.
type);
1668 switch (hunk->
type) {
1669 case HUNK_TYPE_SPOB_ADD:
1670 case HUNK_TYPE_SPOB_REMOVE:
1671 case HUNK_TYPE_VSPOB_ADD:
1672 case HUNK_TYPE_VSPOB_REMOVE:
1673 case HUNK_TYPE_JUMP_ADD:
1674 case HUNK_TYPE_JUMP_REMOVE:
1675 case HUNK_TYPE_SSYS_BACKGROUND:
1676 case HUNK_TYPE_SSYS_FEATURES:
1677 case HUNK_TYPE_TECH_ADD:
1678 case HUNK_TYPE_TECH_REMOVE:
1679 case HUNK_TYPE_SPOB_FACTION:
1680 case HUNK_TYPE_SPOB_FACTION_REMOVE:
1681 case HUNK_TYPE_SPOB_DISPLAYNAME:
1682 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
1683 case HUNK_TYPE_SPOB_DESCRIPTION:
1684 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
1685 case HUNK_TYPE_SPOB_TECH_ADD:
1686 case HUNK_TYPE_SPOB_TECH_REMOVE:
1687 case HUNK_TYPE_SPOB_TAG_ADD:
1688 case HUNK_TYPE_SPOB_TAG_REMOVE:
1689 case HUNK_TYPE_SPOB_BAR:
1690 case HUNK_TYPE_SPOB_BAR_REVERT:
1691 case HUNK_TYPE_SPOB_SPACE:
1692 case HUNK_TYPE_SPOB_SPACE_REVERT:
1693 case HUNK_TYPE_SPOB_EXTERIOR:
1694 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1695 case HUNK_TYPE_SPOB_LUA:
1696 case HUNK_TYPE_SPOB_LUA_REVERT:
1697 case HUNK_TYPE_FACTION_VISIBLE:
1698 case HUNK_TYPE_FACTION_INVISIBLE:
1699 case HUNK_TYPE_FACTION_ALLY:
1700 case HUNK_TYPE_FACTION_ENEMY:
1701 case HUNK_TYPE_FACTION_NEUTRAL:
1702 case HUNK_TYPE_FACTION_REALIGN:
1704 hunk->
u.name = NULL;
1721 xmlw_startElem(writer,
"diffs");
1726 xmlw_elem(writer,
"diff",
"%s", diff->
name);
1729 xmlw_endElem(writer);
1751 node = parent->xmlChildrenNode;
1753 if (xml_isNode(node,
"diffs")) {
1754 xmlNodePtr cur = node->xmlChildrenNode;
1756 if ( xml_isNode( cur,
"diff" ) ) {
1757 char *diffName = xml_get( cur );
1758 if ( diffName == NULL ) {
1759 WARN( _(
"Expected node \"diff\" to contain the name of a unidiff. Was empty." ) );
1764 }
while (xml_nextNode(cur));
1766 }
while (xml_nextNode(node));
1779 Pilot *
const* pilots;
1800 Pilot *p = pilots[i];
1802 p->nav_hyperspace = -1;
1807 if (!pilot_isWithPlayer(p) && pilot_isFlag( p, PILOT_HYPERSPACE ))
1810 pilot_rmFlag( p, PILOT_HYPERSPACE );
1813 if (pilot_isFlag( p, PILOT_HYP_BEGIN ) ||
1814 pilot_isFlag( p, PILOT_HYP_BRAKE ) ||
1815 pilot_isFlag( p, PILOT_HYP_PREP ))
1836 if (defer && !enable)
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
#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_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_shrink(ptr_array)
Shrinks memory to fit only ‘size’ elements.
#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’.
void economy_initialiseCommodityPrices(void)
Initialises commodity prices for the sinusoidal economy model.
int economy_execQueued(void)
Calls economy_refresh if an economy update is queued.
void faction_rmAlly(int f, int o)
Removes an ally from the faction's allies list.
void faction_rmEnemy(int f, int o)
Removes an enemy from the faction's enemies list.
int areEnemies(int a, int b)
Checks whether two factions are enemies.
const char * faction_name(int f)
Gets a factions "real" (internal) name.
int faction_setInvisible(int id, int state)
Sets the faction's invisible state.
void faction_addAlly(int f, int o)
Adds an ally to the faction's allies list.
void faction_addEnemy(int f, int o)
Adds an enemy to the faction's enemies list.
int faction_get(const char *name)
Gets a faction ID by name.
int areAllies(int a, int b)
Checks whether two factions are allies or not.
Header file with generic functions and naev-specifics.
char ** ndata_listRecursive(const char *path)
Lists all the visible files in a directory, at any depth.
static char buf[NEWS_MAX_LENGTH]
xmlDocPtr xml_parsePhysFS(const char *filename)
Analogous to xmlParseMemory/xmlParseFile.
void pilot_hyperspaceAbort(Pilot *p)
Stops the pilot from hyperspacing.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
void pilot_delete(Pilot *p)
Deletes a pilot.
void player_targetHyperspaceSet(int id, int nomsg)
Sets the player's hyperspace target.
void player_targetSpobSet(int id)
Sets the player's target spob.
void safelanes_recalculate(void)
Update the safe lane locations in response to the universe changing (e.g., diff applied).
void space_reconstructPresences(void)
Reset the presence of all systems.
int system_addJumpDiff(StarSystem *sys, xmlNodePtr node)
Adds a jump point to a star system from a diff.
void space_gfxUnload(StarSystem *sys)
Unloads all the graphics for a star system.
int spob_luaInit(Spob *spob)
Updatse the spob's internal Lua stuff.
int spob_getService(const char *name)
Converts name to spob service flag.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
int system_addVirtualSpob(StarSystem *sys, const char *spobname)
Adds a virtual spob to a system.
int system_rmJump(StarSystem *sys, const char *jumpname)
Removes a jump point from a star system.
int spob_setFaction(Spob *p, int faction)
Changes the spobs faction.
StarSystem * system_get(const char *sysname)
Get the system from its name.
int spob_rmService(Spob *p, int service)
Removes a service from a spob.
int system_addSpob(StarSystem *sys, const char *spobname)
Adds a spob to a star system.
int system_rmVirtualSpob(StarSystem *sys, const char *spobname)
Removes a virtual spob from a system.
int spob_addService(Spob *p, int service)
Removes a service from a spob.
const char * spob_getServiceName(int service)
Gets the (English) name for a service code.
void space_gfxLoad(StarSystem *sys)
Loads all the graphics for a star system.
int system_rmSpob(StarSystem *sys, const char *spobname)
Removes a spob from a star system.
The representation of an in-game pilot.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Universe diff filepath list.
Represents each Universe Diff.
Represents the hunk's target.
union UniHunkTarget_t::@28 u
Represents a single hunk in the diff.
int tech_rmItemTech(tech_group_t *tech, const char *value)
Removes an item from a tech.
tech_group_t * tech_groupCreate(void)
Creates a tech group.
int tech_rmItem(const char *name, const char *value)
Removes a tech item.
int tech_addItemTech(tech_group_t *tech, const char *value)
Adds an item to a tech.
int tech_addItem(const char *name, const char *value)
Adds an item to a tech.
static UniDiffData_t * diff_available
static int diff_checkUpdateUniverse(void)
Checks and updates the universe if necessary.
UniHunkType_t
Represents the different type of hunk actions.
static UniDiff_t * diff_get(const char *name)
Gets a diff by name.
static UniDiff_t * diff_stack
int diff_load(xmlNodePtr parent)
Loads the diffs.
void unidiff_universeDefer(int enable)
Sets whether or not to defer universe change stuff.
static int diff_patchTech(UniDiff_t *diff, xmlNodePtr node)
Patches a tech.
static UniDiff_t * diff_newDiff(void)
Creates a new UniDiff_t for usage.
static int diff_patchHunk(UniHunk_t *hunk)
Applies a hunk and adds it to the diff.
int diff_apply(const char *name)
Applies a diff to the universe.
void diff_remove(const char *name)
Removes a diff from the universe.
static int diff_patch(xmlNodePtr parent)
Actually applies a diff in XML node form.
static void diff_cleanup(UniDiff_t *diff)
Cleans up a diff.
void diff_clear(void)
Removes all active diffs. (Call before economy_destroy().)
static int diff_applyInternal(const char *name, int oneshot)
Applies a diff to the universe.
int diff_loadAvailable(void)
Loads available universe diffs.
static void diff_cleanupHunk(UniHunk_t *hunk)
Cleans up a hunk.
static int diff_patchFaction(UniDiff_t *diff, xmlNodePtr node)
Patches a faction.
static int diff_patchSpob(UniDiff_t *diff, xmlNodePtr node)
Patches a spob.
static int diff_universe_changed
static void diff_hunkSuccess(UniDiff_t *diff, UniHunk_t *hunk)
Adds a hunk to the applied list.
static int diff_patchSystem(UniDiff_t *diff, xmlNodePtr node)
Patches a system.
static int diff_universe_defer
void diff_free(void)
Clean up after diff_loadAvailable().
static int diff_removeDiff(UniDiff_t *diff)
Removes a diff.
int diff_save(xmlTextWriterPtr writer)
Saves the active diffs.
int diff_isApplied(const char *name)
Checks if a diff is currently applied.
UniHunkTargetType_t
Represents the possible hunk targets.
static void diff_hunkFailed(UniDiff_t *diff, UniHunk_t *hunk)
Adds a hunk to the failed list.