void AddGlyph(GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { GlyphRefPtr gr; CARD32 signature; CheckDuplicates(&globalGlyphs[glyphSet->fdepth], "AddGlyph top global"); /* Locate existing matching glyph */ signature = *(CARD32 *) glyph->sha1; gr = FindGlyphRef(&globalGlyphs[glyphSet->fdepth], signature, TRUE, glyph->sha1); if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph) { FreeGlyphPicture(glyph); dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH); glyph = gr->glyph; } else if (gr->glyph != glyph) { gr->glyph = glyph; gr->signature = signature; globalGlyphs[glyphSet->fdepth].tableEntries++; } /* Insert/replace glyphset value */ gr = FindGlyphRef(&glyphSet->hash, id, FALSE, 0); ++glyph->refcnt; if (gr->glyph && gr->glyph != DeletedGlyph) FreeGlyph(gr->glyph, glyphSet->fdepth); else glyphSet->hash.tableEntries++; gr->glyph = glyph; gr->signature = id; CheckDuplicates(&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom"); }
void FreeGlyph(GlyphPtr glyph, int format) { CheckDuplicates(&globalGlyphs[format], "FreeGlyph"); if (--glyph->refcnt == 0) { GlyphRefPtr gr; int i; int first; CARD32 signature; first = -1; for (i = 0; i < globalGlyphs[format].hashSet->size; i++) if (globalGlyphs[format].table[i].glyph == glyph) { if (first != -1) DuplicateRef(glyph, "FreeGlyph check"); first = i; } signature = *(CARD32 *) glyph->sha1; gr = FindGlyphRef(&globalGlyphs[format], signature, TRUE, glyph->sha1); if (gr - globalGlyphs[format].table != first) DuplicateRef(glyph, "Found wrong one"); if (gr->glyph && gr->glyph != DeletedGlyph) { gr->glyph = DeletedGlyph; gr->signature = 0; globalGlyphs[format].tableEntries--; } FreeGlyphPicture(glyph); dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH); } }
void Map::AddToWListM(Node n, Node p) { if (CheckDuplicates(n.GetX(), n.GetY())) { n.SetParent(p); nodes[n.GetX()][n.GetY()].SetParent(p); nodes[n.GetX()][n.GetY()].SetGDistance(p.GetGDistance() + 10); nodes[n.GetX()][n.GetY()].SetHDistanceManhatten(eNode.GetX(), eNode.GetY()); workinglist.push(nodes[n.GetX()][n.GetY()]); duplicates[n.GetX()][n.GetY()] = true; } }
void CheckDuplicates(guint js, guidata *gui) { int a; for (a=0;a<9;a++) { if (a==js) break; if (gui->joy[js].id == gui->joy[a].id) { gui->joy[a].id++; CheckDuplicates(a, gui); } } }
Bool ResizeGlyphHash(GlyphHashPtr hash, CARD32 change, Bool global) { CARD32 tableEntries; GlyphHashSetPtr hashSet; GlyphHashRec newHash; GlyphRefPtr gr; GlyphPtr glyph; int i; int oldSize; CARD32 s; tableEntries = hash->tableEntries + change; hashSet = FindGlyphHashSet(tableEntries); if (hashSet == hash->hashSet) return TRUE; if (global) CheckDuplicates(hash, "ResizeGlyphHash top"); if (!AllocateGlyphHash(&newHash, hashSet)) return FALSE; if (hash->table) { oldSize = hash->hashSet->size; for (i = 0; i < oldSize; i++) { glyph = hash->table[i].glyph; if (glyph && glyph != DeletedGlyph) { s = hash->table[i].signature; gr = FindGlyphRef(&newHash, s, global, glyph->sha1); gr->signature = s; gr->glyph = glyph; ++newHash.tableEntries; } } free(hash->table); } *hash = newHash; if (global) CheckDuplicates(hash, "ResizeGlyphHash bottom"); return TRUE; }
void Map::AddToWListD(Node n, Node p) { if (CheckDuplicates(n.GetX(), n.GetY())) { n.SetParent(p); nodes[n.GetX()][n.GetY()].SetParent(p); if (n.GetX() != p.GetX() && n.GetY() != p.GetY()) { nodes[n.GetX()][n.GetY()].SetGDistance(p.GetGDistance() + 14); } else { nodes[n.GetX()][n.GetY()].SetGDistance(p.GetGDistance() + 10); } nodes[n.GetX()][n.GetY()].SetHDistanceDiagonal(eNode.GetX(), eNode.GetY()); workinglist.push(nodes[n.GetX()][n.GetY()]); duplicates[n.GetX()][n.GetY()] = true; } }