1
0
Fork 0

(svn r16503) -Fix: base graphics names must be unique, so don't add duplicates (even if the versions differ).

release/1.0
rubidium 2009-06-02 12:56:38 +00:00
parent 4ea3e511bd
commit be04b7e29c
1 changed files with 25 additions and 6 deletions

View File

@ -444,7 +444,7 @@ public:
bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length) bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
{ {
bool ret = false; bool ret = false;
DEBUG(grf, 1, "Found %s as base graphics set", filename); DEBUG(grf, 1, "Checking %s for base graphics set", filename);
GraphicsSet *graphics = new GraphicsSet();; GraphicsSet *graphics = new GraphicsSet();;
IniFile *ini = new IniFile(); IniFile *ini = new IniFile();
@ -459,12 +459,28 @@ bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
} }
if (FillGraphicsSetDetails(graphics, ini, path)) { if (FillGraphicsSetDetails(graphics, ini, path)) {
bool duplicate = false; const GraphicsSet *duplicate = NULL;
for (const GraphicsSet *c = _available_graphics_sets; !duplicate && c != NULL; c = c->next) { for (const GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) {
duplicate = (strcmp(c->name, graphics->name) == 0 || c->shortname == graphics->shortname) && c->version == graphics->version; if (strcmp(c->name, graphics->name) == 0 || c->shortname == graphics->shortname) {
duplicate = c;
break;
}
} }
if (duplicate) { if (duplicate != NULL) {
delete graphics; if (duplicate->version >= graphics->version) {
DEBUG(grf, 1, "Not adding %s (%i) as base graphics set (duplicate)", graphics->name, graphics->version);
delete graphics;
} else {
GraphicsSet **prev = &_available_graphics_sets;
while (*prev != duplicate) prev = &(*prev)->next;
*prev = graphics;
graphics->next = duplicate->next;
DEBUG(grf, 1, "Removing %s (%i) as base graphics set (duplicate)", duplicate->name, duplicate->version);
delete duplicate;
ret = true;
}
} else { } else {
GraphicsSet **last = &_available_graphics_sets; GraphicsSet **last = &_available_graphics_sets;
while (*last != NULL) last = &(*last)->next; while (*last != NULL) last = &(*last)->next;
@ -472,6 +488,9 @@ bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
*last = graphics; *last = graphics;
ret = true; ret = true;
} }
if (ret) {
DEBUG(grf, 1, "Adding %s (%i) as base graphics set", graphics->name, graphics->version);
}
} else { } else {
delete graphics; delete graphics;
} }