Related characters feature work continues...
This commit is contained in:
parent
d70b72b0c1
commit
a7b5e1a573
@ -26,6 +26,7 @@
|
|||||||
#include <adoint.h>
|
#include <adoint.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -159,6 +160,19 @@ namespace ZRCola {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Character bank
|
||||||
|
///
|
||||||
|
class character_bank : public std::vector<std::unique_ptr<character> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
character_bank() : std::vector<std::unique_ptr<character> >()
|
||||||
|
{
|
||||||
|
resize(0x10000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Character description index key comparator
|
/// Character description index key comparator
|
||||||
///
|
///
|
||||||
|
@ -395,8 +395,7 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
|
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
|
||||||
ZRCola::DBSource::character_desc_idx idxChrDsc, idxChrDscSub;
|
ZRCola::DBSource::character_desc_idx idxChrDsc, idxChrDscSub;
|
||||||
|
|
||||||
vector<unique_ptr<ZRCola::DBSource::character> > chrs;
|
ZRCola::DBSource::character_bank chrs;
|
||||||
chrs.resize(0x10000);
|
|
||||||
|
|
||||||
// Phase 1: Parse characters and build indexes.
|
// Phase 1: Parse characters and build indexes.
|
||||||
while (!ZRCola::DBSource::IsEOF(rs)) {
|
while (!ZRCola::DBSource::IsEOF(rs)) {
|
||||||
@ -405,10 +404,6 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
if (src.GetCharacter(rs, *c)) {
|
if (src.GetCharacter(rs, *c)) {
|
||||||
const ZRCola::DBSource::character &chr = *c.get();
|
const ZRCola::DBSource::character &chr = *c.get();
|
||||||
chrs[chr.chr].swap(c);
|
chrs[chr.chr].swap(c);
|
||||||
|
|
||||||
// Add description (and keywords) to index.
|
|
||||||
idxChrDsc .add_keywords(chr.terms, chr.chr, 0);
|
|
||||||
idxChrDscSub.add_keywords(chr.terms, chr.chr, 3);
|
|
||||||
} else
|
} else
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
|
|
||||||
@ -420,11 +415,17 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
ZRCola::DBSource::character &chr = *(chrs[i].get());
|
ZRCola::DBSource::character &chr = *(chrs[i].get());
|
||||||
if (&chr == NULL) continue;
|
if (&chr == NULL) continue;
|
||||||
|
|
||||||
// Remove all unexisting or inactive related characters.
|
// Remove all unexisting, inactive, or self related characters.
|
||||||
for (wstring::size_type i = chr.rel.length(); i--;) {
|
for (wstring::size_type i = chr.rel.length(); i--;) {
|
||||||
if (!chrs[chr.rel[i]])
|
if (!chrs[chr.rel[i]] || (wchar_t)i == chr.rel[i])
|
||||||
chr.rel.erase(i, 1);
|
chr.rel.erase(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for (size_t j = 0, j_end = chrs.size(); j < j_end; j++) {
|
||||||
|
// if (i == j) continue;
|
||||||
|
// ZRCola::DBSource::character &chr = *(chrs[i].get());
|
||||||
|
// if (&chr == NULL) continue;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZRCola::character_db db;
|
ZRCola::character_db db;
|
||||||
@ -455,6 +456,10 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
db.data.push_back(chr.rel[i]);
|
db.data.push_back(chr.rel[i]);
|
||||||
db.idxChr.push_back(idx);
|
db.idxChr.push_back(idx);
|
||||||
|
|
||||||
|
// Add description (and keywords) to index.
|
||||||
|
idxChrDsc .add_keywords(chr.terms, chr.chr, 0);
|
||||||
|
idxChrDscSub.add_keywords(chr.terms, chr.chr, 3);
|
||||||
|
|
||||||
// Mark category used.
|
// Mark category used.
|
||||||
categories_used.insert(chr.cat);
|
categories_used.insert(chr.cat);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user