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_NOMISNSPAWN_ADD,
102 HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE,
103 HUNK_TYPE_SPOB_TECH_ADD,
104 HUNK_TYPE_SPOB_TECH_REMOVE,
105 HUNK_TYPE_SPOB_TAG_ADD,
106 HUNK_TYPE_SPOB_TAG_REMOVE,
107 HUNK_TYPE_SPOB_SPACE,
108 HUNK_TYPE_SPOB_SPACE_REVERT,
109 HUNK_TYPE_SPOB_EXTERIOR,
110 HUNK_TYPE_SPOB_EXTERIOR_REVERT,
112 HUNK_TYPE_SPOB_LUA_REVERT,
114 HUNK_TYPE_FACTION_VISIBLE,
115 HUNK_TYPE_FACTION_INVISIBLE,
116 HUNK_TYPE_FACTION_ALLY,
117 HUNK_TYPE_FACTION_ENEMY,
118 HUNK_TYPE_FACTION_NEUTRAL,
119 HUNK_TYPE_FACTION_REALIGN,
127typedef struct UniHunk_ {
147typedef struct UniDiff_ {
186static
int diff_cmp( const
void *p1, const
void *p2 )
191 return strcmp( d1->
name, d2->
name );
201 Uint32 time = SDL_GetTicks();
204 for (
int i=0; i<
array_size(diff_files); i++ ) {
212 free( diff_files[i] );
216 node = doc->xmlChildrenNode;
217 if (!xml_isNode(node,
"unidiff")) {
218 WARN( _(
"Malformed XML header for '%s' UniDiff: missing root element '%s'"), diff_files[i],
"unidiff" );
220 free( diff_files[i] );
226 xmlr_attr_strd(node,
"name", diff->
name);
237 if (strcmp(
d->name, dn->
name )==0)
238 WARN(_(
"Two unidiff have the same name '%s'!"),
d->name );
242 time = SDL_GetTicks() - time;
313 WARN(_(
"UniDiff '%s' not found in %s!"), name, UNIDIFF_DATA_PATH);
319 node = doc->xmlChildrenNode;
320 if (strcmp((
char*)node->name,
"unidiff")) {
321 ERR(_(
"Malformed unidiff file: missing root element 'unidiff'"));
355 WARN(_(
"Unidiff '%s' has a system node without a 'name' tag, not applying."), diff->
name);
360 cur = node->xmlChildrenNode;
363 if (xml_isNode(cur,
"spob")) {
364 buf = xml_get( cur );
366 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
374 xmlr_attr_strd(cur,
"name",hunk.
u.name);
377 if (strcmp(buf,
"add")==0)
378 hunk.
type = HUNK_TYPE_SPOB_ADD;
379 else if (strcmp(buf,
"remove")==0)
380 hunk.
type = HUNK_TYPE_SPOB_REMOVE;
382 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for spob '%s'."), diff->
name, buf, hunk.
u.name);
391 else if (xml_isNode(cur,
"spob_virtual")) {
392 buf = xml_get( cur );
394 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
402 xmlr_attr_strd(cur,
"name",hunk.
u.name);
405 if (strcmp(buf,
"add")==0)
406 hunk.
type = HUNK_TYPE_VSPOB_ADD;
407 else if (strcmp(buf,
"remove")==0)
408 hunk.
type = HUNK_TYPE_VSPOB_REMOVE;
410 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for virtual spob '%s'."), diff->
name, buf, hunk.
u.name);
419 else if (xml_isNode(cur,
"jump")) {
420 buf = xml_get( cur );
422 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
430 xmlr_attr_strd(cur,
"target",hunk.
u.name);
433 if (strcmp(buf,
"add")==0)
434 hunk.
type = HUNK_TYPE_JUMP_ADD;
435 else if (strcmp(buf,
"remove")==0)
436 hunk.
type = HUNK_TYPE_JUMP_REMOVE;
438 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for jump '%s'."), diff->
name, buf, hunk.
u.name);
449 else if (xml_isNode(cur,
"background")) {
452 hunk.
type = HUNK_TYPE_SSYS_BACKGROUND;
453 hunk.
u.name = xml_getStrd(cur);
462 else if (xml_isNode(cur,
"features")) {
465 hunk.
type = HUNK_TYPE_SSYS_FEATURES;
466 hunk.
u.name = xml_getStrd(cur);
475 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
476 }
while (xml_nextNode(cur));
502 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
507 cur = node->xmlChildrenNode;
510 if (xml_isNode(cur,
"add")) {
515 hunk.
type = HUNK_TYPE_TECH_ADD;
518 hunk.
u.name = xml_getStrd(cur);
527 else if (xml_isNode(cur,
"remove")) {
532 hunk.
type = HUNK_TYPE_TECH_REMOVE;
535 hunk.
u.name = xml_getStrd(cur);
544 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
545 }
while (xml_nextNode(cur));
571 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
576 cur = node->xmlChildrenNode;
579 if (xml_isNode(cur,
"faction")) {
582 hunk.
type = HUNK_TYPE_SPOB_FACTION;
583 hunk.
u.name = xml_getStrd(cur);
592 else if (xml_isNode(cur,
"population")) {
595 hunk.
type = HUNK_TYPE_SPOB_POPULATION;
596 hunk.
u.data = xml_getUInt(cur);
605 else if (xml_isNode(cur,
"displayname")) {
608 hunk.
type = HUNK_TYPE_SPOB_DISPLAYNAME;
609 hunk.
u.name = xml_getStrd(cur);
618 else if (xml_isNode(cur,
"description")) {
621 hunk.
type = HUNK_TYPE_SPOB_DESCRIPTION;
622 hunk.
u.name = xml_getStrd(cur);
631 else if (xml_isNode(cur,
"bar")) {
634 hunk.
type = HUNK_TYPE_SPOB_BAR;
635 hunk.
u.name = xml_getStrd(cur);
644 else if (xml_isNode(cur,
"service_add")) {
647 hunk.
type = HUNK_TYPE_SPOB_SERVICE_ADD;
657 else if (xml_isNode(cur,
"service_remove")) {
660 hunk.
type = HUNK_TYPE_SPOB_SERVICE_REMOVE;
670 else if (xml_isNode(cur,
"nomissionspawn_add")) {
673 hunk.
type = HUNK_TYPE_SPOB_NOMISNSPAWN_ADD;
682 else if (xml_isNode(cur,
"nomissionspawn_remove")) {
685 hunk.
type = HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE;
694 else if (xml_isNode(cur,
"tech_add")) {
697 hunk.
type = HUNK_TYPE_SPOB_TECH_ADD;
698 hunk.
u.name = xml_getStrd(cur);
707 else if (xml_isNode(cur,
"tech_remove")) {
710 hunk.
type = HUNK_TYPE_SPOB_TECH_REMOVE;
711 hunk.
u.name = xml_getStrd(cur);
720 else if (xml_isNode(cur,
"tag_add")) {
723 hunk.
type = HUNK_TYPE_SPOB_TAG_ADD;
724 hunk.
u.name = xml_getStrd(cur);
733 else if (xml_isNode(cur,
"tag_remove")) {
736 hunk.
type = HUNK_TYPE_SPOB_TAG_REMOVE;
737 hunk.
u.name = xml_getStrd(cur);
746 else if (xml_isNode(cur,
"gfx_space")) {
750 hunk.
type = HUNK_TYPE_SPOB_SPACE;
751 snprintf( str,
sizeof(str), SPOB_GFX_SPACE_PATH
"%s", xml_get(cur));
752 hunk.
u.name = strdup(str);
761 else if (xml_isNode(cur,
"gfx_exterior")) {
765 hunk.
type = HUNK_TYPE_SPOB_EXTERIOR;
766 snprintf( str,
sizeof(str), SPOB_GFX_EXTERIOR_PATH
"%s", xml_get(cur));
767 hunk.
u.name = strdup(str);
776 else if (xml_isNode(cur,
"lua")) {
780 hunk.
type = HUNK_TYPE_SPOB_LUA;
783 hunk.
u.name = strdup( str );
794 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, cur->name);
795 }
while (xml_nextNode(cur));
822 WARN(_(
"Unidiff '%s' has an target node without a 'name' tag"), diff->
name);
827 cur = node->xmlChildrenNode;
830 if (xml_isNode(cur,
"visible")) {
835 hunk.
type = HUNK_TYPE_FACTION_VISIBLE;
847 else if (xml_isNode(cur,
"invisible")) {
852 hunk.
type = HUNK_TYPE_FACTION_INVISIBLE;
864 else if (xml_isNode(cur,
"faction")) {
865 buf = xml_get( cur );
867 WARN( _(
"Unidiff '%s': Null hunk type." ), diff->
name );
875 xmlr_attr_strd(cur,
"name",hunk.
u.name);
878 if (strcmp(buf,
"ally")==0)
879 hunk.
type = HUNK_TYPE_FACTION_ALLY;
880 else if (strcmp(buf,
"enemy")==0)
881 hunk.
type = HUNK_TYPE_FACTION_ENEMY;
882 else if (strcmp(buf,
"neutral")==0)
883 hunk.
type = HUNK_TYPE_FACTION_NEUTRAL;
885 WARN(_(
"Unidiff '%s': Unknown hunk type '%s' for faction '%s'."), diff->
name, buf, hunk.
u.name);
894 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
895 }
while (xml_nextNode(cur));
919 xmlr_attr_strd(parent,
"name",diff->
name);
921 node = parent->xmlChildrenNode;
924 if (xml_isNode(node,
"system")) {
928 else if (xml_isNode(node,
"tech"))
930 else if (xml_isNode(node,
"spob")) {
934 else if (xml_isNode(node,
"faction")) {
939 WARN(_(
"Unidiff '%s' has unknown node '%s'."), diff->
name, node->name);
940 }
while (xml_nextNode(node));
945 n_(
"Unidiff '%s' failed to apply %d hunk.",
"Unidiff '%s' failed to apply %d hunks.", nfailed ),
946 diff->
name, nfailed );
947 for (
int i=0; i<nfailed; i++) {
950 switch (fail->
type) {
951 case HUNK_TYPE_SPOB_ADD:
952 WARN(_(
" [%s] spob add: '%s'"), target, fail->
u.name);
954 case HUNK_TYPE_SPOB_REMOVE:
955 WARN(_(
" [%s] spob remove: '%s'"), target, fail->
u.name);
957 case HUNK_TYPE_VSPOB_ADD:
958 WARN(_(
" [%s] virtual spob add: '%s'"), target, fail->
u.name);
960 case HUNK_TYPE_VSPOB_REMOVE:
961 WARN(_(
" [%s] virtual spob remove: '%s'"), target, fail->
u.name);
963 case HUNK_TYPE_JUMP_ADD:
964 WARN(_(
" [%s] jump add: '%s'"), target, fail->
u.name);
966 case HUNK_TYPE_JUMP_REMOVE:
967 WARN(_(
" [%s] jump remove: '%s'"), target, fail->
u.name);
969 case HUNK_TYPE_TECH_ADD:
970 WARN(_(
" [%s] tech add: '%s'"), target,
973 case HUNK_TYPE_TECH_REMOVE:
974 WARN(_(
" [%s] tech remove: '%s'"), target,
977 case HUNK_TYPE_SPOB_FACTION:
978 WARN(_(
" [%s] spob faction: '%s'"), target,
981 case HUNK_TYPE_SPOB_FACTION_REMOVE:
982 WARN(_(
" [%s] spob faction removal: '%s'"), target,
985 case HUNK_TYPE_SPOB_POPULATION:
986 WARN(_(
" [%s] spob population: '%s'"), target,
989 case HUNK_TYPE_SPOB_POPULATION_REMOVE:
990 WARN(_(
" [%s] spob population removal: '%s'"), target,
993 case HUNK_TYPE_SPOB_DISPLAYNAME:
994 WARN(_(
" [%s] spob displayname: '%s'"), target,
997 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
998 WARN(_(
" [%s] spob displayname revert: '%s'"), target,
1001 case HUNK_TYPE_SPOB_DESCRIPTION:
1002 WARN(_(
" [%s] spob description: '%s'"), target,
1005 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
1006 WARN(_(
" [%s] spob description revert: '%s'"), target,
1009 case HUNK_TYPE_SPOB_BAR:
1010 WARN(_(
" [%s] spob bar: '%s'"), target,
1013 case HUNK_TYPE_SPOB_BAR_REVERT:
1014 WARN(_(
" [%s] spob bar revert: '%s'"), target,
1017 case HUNK_TYPE_SPOB_SPACE:
1018 WARN(_(
" [%s] spob space: '%s'"), target,
1021 case HUNK_TYPE_SPOB_SPACE_REVERT:
1022 WARN(_(
" [%s] spob space revert: '%s'"), target,
1025 case HUNK_TYPE_SPOB_EXTERIOR:
1026 WARN(_(
" [%s] spob exterior: '%s'"), target,
1029 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1030 WARN(_(
" [%s] spob exterior revert: '%s'"), target,
1033 case HUNK_TYPE_SPOB_LUA:
1034 WARN(_(
" [%s] spob lua: '%s'"), target,
1037 case HUNK_TYPE_SPOB_LUA_REVERT:
1038 WARN(_(
" [%s] spob lua revert: '%s'"), target,
1041 case HUNK_TYPE_SPOB_SERVICE_ADD:
1042 WARN(_(
" [%s] spob service add: '%s'"), target,
1045 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1046 WARN(_(
" [%s] spob service remove: '%s'"), target,
1049 case HUNK_TYPE_SPOB_NOMISNSPAWN_ADD:
1050 WARN(_(
" [%s] spob nomissionspawn add"), target );
1052 case HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE:
1053 WARN(_(
" [%s] spob nomissionspawn remove"), target );
1055 case HUNK_TYPE_SPOB_TECH_ADD:
1056 WARN(_(
" [%s] spob tech add: '%s'"), target,
1059 case HUNK_TYPE_SPOB_TECH_REMOVE:
1060 WARN(_(
" [%s] spob tech remove: '%s'"), target,
1063 case HUNK_TYPE_SPOB_TAG_ADD:
1064 WARN(_(
" [%s] spob tech add: '%s'"), target,
1067 case HUNK_TYPE_SPOB_TAG_REMOVE:
1068 WARN(_(
" [%s] spob tech remove: '%s'"), target,
1071 case HUNK_TYPE_FACTION_VISIBLE:
1072 WARN(_(
" [%s] faction visible: '%s'"), target,
1075 case HUNK_TYPE_FACTION_INVISIBLE:
1076 WARN(_(
" [%s] faction invisible: '%s'"), target,
1079 case HUNK_TYPE_FACTION_ALLY:
1080 WARN(_(
" [%s] faction set ally: '%s'"), target,
1083 case HUNK_TYPE_FACTION_ENEMY:
1084 WARN(_(
" [%s] faction set enemy: '%s'"), target,
1087 case HUNK_TYPE_FACTION_NEUTRAL:
1088 WARN(_(
" [%s] faction set neutral: '%s'"), target,
1091 case HUNK_TYPE_FACTION_REALIGN:
1092 WARN(_(
" [%s] faction alignment reset: '%s'"), target,
1097 WARN(_(
" unknown hunk '%d'"), fail->
type);
1120 switch (hunk->
type) {
1123 case HUNK_TYPE_SPOB_ADD:
1128 case HUNK_TYPE_SPOB_REMOVE:
1133 case HUNK_TYPE_VSPOB_ADD:
1137 case HUNK_TYPE_VSPOB_REMOVE:
1142 case HUNK_TYPE_JUMP_ADD:
1146 case HUNK_TYPE_JUMP_REMOVE:
1151 case HUNK_TYPE_SSYS_BACKGROUND:
1153 hunk->o.name = ssys->background;
1154 ssys->background = hunk->
u.name;
1156 case HUNK_TYPE_SSYS_BACKGROUND_REVERT:
1158 ssys->background = (
char*)hunk->o.name;
1162 case HUNK_TYPE_SSYS_FEATURES:
1164 hunk->o.name = ssys->features;
1165 ssys->features = hunk->
u.name;
1167 case HUNK_TYPE_SSYS_FEATURES_REVERT:
1169 ssys->features = (
char*)hunk->o.name;
1173 case HUNK_TYPE_TECH_ADD:
1176 case HUNK_TYPE_TECH_REMOVE:
1180 case HUNK_TYPE_SPOB_FACTION:
1184 if (p->presence.faction<0)
1185 hunk->o.name = NULL;
1190 case HUNK_TYPE_SPOB_FACTION_REMOVE:
1195 if (hunk->o.name==NULL)
1201 case HUNK_TYPE_SPOB_POPULATION:
1205 hunk->o.data = p->population;
1206 p->population = hunk->
u.data;
1208 case HUNK_TYPE_SPOB_POPULATION_REMOVE:
1212 p->population = hunk->o.data;
1216 case HUNK_TYPE_SPOB_DISPLAYNAME:
1220 hunk->o.name = p->display;
1221 p->display = hunk->
u.name;
1223 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
1227 p->display = (
char*)hunk->o.name;
1231 case HUNK_TYPE_SPOB_DESCRIPTION:
1235 hunk->o.name = p->description;
1236 p->description = hunk->
u.name;
1238 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
1242 p->description = (
char*)hunk->o.name;
1246 case HUNK_TYPE_SPOB_BAR:
1250 hunk->o.name = p->bar_description;
1251 p->bar_description = hunk->
u.name;
1253 case HUNK_TYPE_SPOB_BAR_REVERT:
1257 p->bar_description = (
char*)hunk->o.name;
1261 case HUNK_TYPE_SPOB_SERVICE_ADD:
1265 if (spob_hasService( p, hunk->
u.data ))
1270 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1274 if (!spob_hasService( p, hunk->
u.data ))
1281 case HUNK_TYPE_SPOB_NOMISNSPAWN_ADD:
1285 if (spob_isFlag( p, SPOB_NOMISNSPAWN ))
1287 spob_setFlag( p, SPOB_NOMISNSPAWN );
1289 case HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE:
1293 if (!spob_isFlag( p, SPOB_NOMISNSPAWN ))
1295 spob_rmFlag( p, SPOB_NOMISNSPAWN );
1299 case HUNK_TYPE_SPOB_TECH_ADD:
1303 if (p->tech == NULL)
1307 case HUNK_TYPE_SPOB_TECH_REMOVE:
1315 case HUNK_TYPE_SPOB_TAG_ADD:
1319 if (p->tech == NULL)
1325 case HUNK_TYPE_SPOB_TAG_REMOVE:
1331 if (strcmp(p->tags[i], hunk->
u.name )==0) {
1339 array_erase( &p->tags, &p->tags[a], &p->tags[a+1] );
1343 case HUNK_TYPE_SPOB_SPACE:
1347 hunk->o.name = p->gfx_spaceName;
1348 p->gfx_spaceName = hunk->
u.name;
1351 case HUNK_TYPE_SPOB_SPACE_REVERT:
1355 p->gfx_spaceName = (
char*)hunk->o.name;
1360 case HUNK_TYPE_SPOB_EXTERIOR:
1364 hunk->o.name = p->gfx_exterior;
1365 p->gfx_exterior = hunk->
u.name;
1367 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1371 p->gfx_exterior = (
char*)hunk->o.name;
1375 case HUNK_TYPE_SPOB_LUA:
1379 hunk->o.name = p->lua_file;
1380 p->lua_file = hunk->
u.name;
1384 case HUNK_TYPE_SPOB_LUA_REVERT:
1388 p->lua_file = (
char*)hunk->o.name;
1394 case HUNK_TYPE_FACTION_VISIBLE:
1397 case HUNK_TYPE_FACTION_INVISIBLE:
1400 case HUNK_TYPE_FACTION_ALLY:
1413 case HUNK_TYPE_FACTION_ENEMY:
1426 case HUNK_TYPE_FACTION_NEUTRAL:
1441 case HUNK_TYPE_FACTION_REALIGN:
1444 if (hunk->o.data ==
'A') {
1450 else if (hunk->o.data ==
'E') {
1465 WARN(_(
"Unknown hunk type '%d'."), hunk->
type);
1482 if (diff->
failed == NULL)
1541 free(
d->filename );
1571 switch (hunk.
type) {
1572 case HUNK_TYPE_SPOB_ADD:
1573 hunk.
type = HUNK_TYPE_SPOB_REMOVE;
1575 case HUNK_TYPE_SPOB_REMOVE:
1576 hunk.
type = HUNK_TYPE_SPOB_ADD;
1579 case HUNK_TYPE_VSPOB_ADD:
1580 hunk.
type = HUNK_TYPE_VSPOB_REMOVE;
1582 case HUNK_TYPE_VSPOB_REMOVE:
1583 hunk.
type = HUNK_TYPE_VSPOB_ADD;
1586 case HUNK_TYPE_JUMP_ADD:
1587 hunk.
type = HUNK_TYPE_JUMP_REMOVE;
1589 case HUNK_TYPE_JUMP_REMOVE:
1590 hunk.
type = HUNK_TYPE_JUMP_ADD;
1593 case HUNK_TYPE_SSYS_BACKGROUND:
1594 hunk.
type = HUNK_TYPE_SSYS_BACKGROUND_REVERT;
1596 case HUNK_TYPE_SSYS_FEATURES:
1597 hunk.
type = HUNK_TYPE_SSYS_FEATURES_REVERT;
1600 case HUNK_TYPE_TECH_ADD:
1601 hunk.
type = HUNK_TYPE_TECH_REMOVE;
1603 case HUNK_TYPE_TECH_REMOVE:
1604 hunk.
type = HUNK_TYPE_TECH_ADD;
1607 case HUNK_TYPE_SPOB_FACTION:
1608 hunk.
type = HUNK_TYPE_SPOB_FACTION_REMOVE;
1611 case HUNK_TYPE_SPOB_POPULATION:
1612 hunk.
type = HUNK_TYPE_SPOB_POPULATION_REMOVE;
1615 case HUNK_TYPE_SPOB_DISPLAYNAME:
1616 hunk.
type = HUNK_TYPE_SPOB_DISPLAYNAME_REVERT;
1619 case HUNK_TYPE_SPOB_DESCRIPTION:
1620 hunk.
type = HUNK_TYPE_SPOB_DESCRIPTION_REVERT;
1623 case HUNK_TYPE_SPOB_BAR:
1624 hunk.
type = HUNK_TYPE_SPOB_BAR_REVERT;
1627 case HUNK_TYPE_SPOB_SERVICE_ADD:
1628 hunk.
type = HUNK_TYPE_SPOB_SERVICE_REMOVE;
1630 case HUNK_TYPE_SPOB_SERVICE_REMOVE:
1631 hunk.
type = HUNK_TYPE_SPOB_SERVICE_ADD;
1634 case HUNK_TYPE_SPOB_NOMISNSPAWN_ADD:
1635 hunk.
type = HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE;
1637 case HUNK_TYPE_SPOB_NOMISNSPAWN_REMOVE:
1638 hunk.
type = HUNK_TYPE_SPOB_NOMISNSPAWN_ADD;
1641 case HUNK_TYPE_SPOB_TECH_ADD:
1642 hunk.
type = HUNK_TYPE_SPOB_TECH_REMOVE;
1644 case HUNK_TYPE_SPOB_TECH_REMOVE:
1645 hunk.
type = HUNK_TYPE_SPOB_TECH_ADD;
1648 case HUNK_TYPE_SPOB_TAG_ADD:
1649 hunk.
type = HUNK_TYPE_SPOB_TAG_REMOVE;
1651 case HUNK_TYPE_SPOB_TAG_REMOVE:
1652 hunk.
type = HUNK_TYPE_SPOB_TAG_ADD;
1655 case HUNK_TYPE_SPOB_SPACE:
1656 hunk.
type = HUNK_TYPE_SPOB_SPACE_REVERT;
1659 case HUNK_TYPE_SPOB_EXTERIOR:
1660 hunk.
type = HUNK_TYPE_SPOB_EXTERIOR_REVERT;
1663 case HUNK_TYPE_SPOB_LUA:
1664 hunk.
type = HUNK_TYPE_SPOB_LUA_REVERT;
1667 case HUNK_TYPE_FACTION_VISIBLE:
1668 hunk.
type = HUNK_TYPE_FACTION_INVISIBLE;
1670 case HUNK_TYPE_FACTION_INVISIBLE:
1671 hunk.
type = HUNK_TYPE_FACTION_VISIBLE;
1674 case HUNK_TYPE_FACTION_ALLY:
1675 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1677 case HUNK_TYPE_FACTION_ENEMY:
1678 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1680 case HUNK_TYPE_FACTION_NEUTRAL:
1681 hunk.
type = HUNK_TYPE_FACTION_REALIGN;
1685 WARN(_(
"Unknown Hunk type '%d'."), hunk.
type);
1690 WARN(_(
"Failed to remove hunk type '%d'."), hunk.
type);
1725 switch (hunk->
type) {
1726 case HUNK_TYPE_SPOB_ADD:
1727 case HUNK_TYPE_SPOB_REMOVE:
1728 case HUNK_TYPE_VSPOB_ADD:
1729 case HUNK_TYPE_VSPOB_REMOVE:
1730 case HUNK_TYPE_JUMP_ADD:
1731 case HUNK_TYPE_JUMP_REMOVE:
1732 case HUNK_TYPE_SSYS_BACKGROUND:
1733 case HUNK_TYPE_SSYS_FEATURES:
1734 case HUNK_TYPE_TECH_ADD:
1735 case HUNK_TYPE_TECH_REMOVE:
1736 case HUNK_TYPE_SPOB_FACTION:
1737 case HUNK_TYPE_SPOB_FACTION_REMOVE:
1738 case HUNK_TYPE_SPOB_DISPLAYNAME:
1739 case HUNK_TYPE_SPOB_DISPLAYNAME_REVERT:
1740 case HUNK_TYPE_SPOB_DESCRIPTION:
1741 case HUNK_TYPE_SPOB_DESCRIPTION_REVERT:
1742 case HUNK_TYPE_SPOB_TECH_ADD:
1743 case HUNK_TYPE_SPOB_TECH_REMOVE:
1744 case HUNK_TYPE_SPOB_TAG_ADD:
1745 case HUNK_TYPE_SPOB_TAG_REMOVE:
1746 case HUNK_TYPE_SPOB_BAR:
1747 case HUNK_TYPE_SPOB_BAR_REVERT:
1748 case HUNK_TYPE_SPOB_SPACE:
1749 case HUNK_TYPE_SPOB_SPACE_REVERT:
1750 case HUNK_TYPE_SPOB_EXTERIOR:
1751 case HUNK_TYPE_SPOB_EXTERIOR_REVERT:
1752 case HUNK_TYPE_SPOB_LUA:
1753 case HUNK_TYPE_SPOB_LUA_REVERT:
1754 case HUNK_TYPE_FACTION_VISIBLE:
1755 case HUNK_TYPE_FACTION_INVISIBLE:
1756 case HUNK_TYPE_FACTION_ALLY:
1757 case HUNK_TYPE_FACTION_ENEMY:
1758 case HUNK_TYPE_FACTION_NEUTRAL:
1759 case HUNK_TYPE_FACTION_REALIGN:
1761 hunk->
u.name = NULL;
1778 xmlw_startElem(writer,
"diffs");
1783 xmlw_elem(writer,
"diff",
"%s", diff->
name);
1786 xmlw_endElem(writer);
1808 node = parent->xmlChildrenNode;
1810 if (xml_isNode(node,
"diffs")) {
1811 xmlNodePtr cur = node->xmlChildrenNode;
1813 if ( xml_isNode( cur,
"diff" ) ) {
1814 char *diffName = xml_get( cur );
1815 if ( diffName == NULL ) {
1816 WARN( _(
"Expected node \"diff\" to contain the name of a unidiff. Was empty." ) );
1821 }
while (xml_nextNode(cur));
1823 }
while (xml_nextNode(node));
1836 Pilot *
const* pilots;
1858 Pilot *p = pilots[i];
1860 p->nav_hyperspace = -1;
1865 if (!pilot_isWithPlayer(p) && pilot_isFlag( p, PILOT_HYPERSPACE ))
1868 pilot_rmFlag( p, PILOT_HYPERSPACE );
1871 if (pilot_isFlag( p, PILOT_HYP_BEGIN ) ||
1872 pilot_isFlag( p, PILOT_HYP_BRAKE ) ||
1873 pilot_isFlag( p, PILOT_HYP_PREP ))
1894 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.
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::@16 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.