[Add] Check and report failed hunks.

This commit is contained in:
Allanis 2013-12-12 00:30:51 +00:00
parent 27292f1770
commit e4b5f54119

View File

@ -193,10 +193,11 @@ int diff_apply(char* name) {
* @return 0 on success. * @return 0 on success.
*/ */
static int diff_patch(xmlNodePtr parent) { static int diff_patch(xmlNodePtr parent) {
int i;
UniDiff_t* diff; UniDiff_t* diff;
UniHunk_t base, hunk; UniHunk_t base, hunk, *fail;
xmlNodePtr node, cur; xmlNodePtr node, cur;
char* buf; char* buf, *target;
/* Prepare it. */ /* Prepare it. */
diff = diff_newDiff(); diff = diff_newDiff();
@ -271,6 +272,34 @@ static int diff_patch(xmlNodePtr parent) {
} }
} while(xml_nextNode(node)); } while(xml_nextNode(node));
if(diff->nfailed > 0) {
DEBUG("Unidiff '%s' failed %d hunks.", diff->name, diff->nfailed);
for(i = 0; i < diff->nfailed; i++) {
fail = &diff->failed[i];
target = fail->target.u.name;
switch(fail->type) {
case HUNK_TYPE_PLANET_ADD:
DEBUG(" [%s] planet add: '%s'", target, fail->u.name);
break;
case HUNK_TYPE_PLANET_REMOVE:
DEBUG(" [%s] planet remove: '%s'", target, fail->u.name);
break;
case HUNK_TYPE_FLEET_ADD:
DEBUG(" [%s] fleet add: '%s' (%d%% chance)", target,
fail->u.fleet.fleet->name, fail->u.fleet.chance);
break;
case HUNK_TYPE_FLEET_REMOVE:
DEBUG(" [%s] fleet remove: '%s' (%d%% chance)", target,
fail->u.fleet.fleet->name, fail->u.fleet.chance);
break;
default:
DEBUG(" Unkown hunk '%d'", fail->type);
break;
}
}
}
return 0; return 0;
} }