Batch #5122 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_17632 LexiconBoundary::Load: logic confirmed by peer review Peer-reviewed-by: youko, Romain Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
89 lines
3.5 KiB
C++
89 lines
3.5 KiB
C++
#include "Utility/Lexicon/LexiconBoundary.h"
|
|
|
|
#include "Utility/Lexicon/LexiconSerializer.h"
|
|
|
|
#include <cstring>
|
|
|
|
// GLOBAL: gl_24545
|
|
std::uint32_t g_lexiconByteClasses[256] = {
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0x1000000, 0x400, 0x400, 0x400, 0x400, 0x400, 0x400, 0x400,
|
|
0x10, 0x20, 0x400, 0x400, 0x400, 0x400, 0x404, 0x400,
|
|
0x10002, 0x10002, 0x10002, 0x10002, 0x10002, 0x10002, 0x10002, 0x10002,
|
|
0x10002, 0x10002, 0x400, 0x400, 0x10, 0x400, 0x20, 0x40,
|
|
0x400, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002,
|
|
0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002,
|
|
0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002, 0x100002,
|
|
0x100002, 0x100002, 0x100002, 0x10, 0x400, 0x20, 0x400, 0x400,
|
|
0x400, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002,
|
|
0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002,
|
|
0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002, 0x200002,
|
|
0x200002, 0x200002, 0x200002, 0x10, 0x400, 0x20, 0x400, 0,
|
|
0x20001, 0x101, 0x101, 0x101, 0x101, 0x400, 0x8101, 0x8101,
|
|
0x8101, 0x8101, 0x4101, 0x8101, 0x8101, 0x8101, 0x8101, 0x4101,
|
|
0x20001, 0x414, 0x424, 0x414, 0x424, 0x400, 0x400, 0x400,
|
|
0x4101, 0x4101, 0x4101, 0x8101, 0x8101, 0x8101, 0x8101, 0x4101,
|
|
0x1000000, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001,
|
|
0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001,
|
|
0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001,
|
|
0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001,
|
|
0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001,
|
|
0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x20001, 0x201,
|
|
0x2001, 0x4101, 0x2001, 0x2001, 0x101, 0x101, 0x101, 0x101,
|
|
0x101, 0x101, 0x4101, 0x2000000, 0x400, 0, 0, 0x400,
|
|
0x1001, 0x1001, 0x1001, 0x1001, 0x1001, 0x2001, 0x1, 0x4101,
|
|
0x8101, 0x8101, 0x8101, 0x8101, 0x4101, 0x4101, 0x4101, 0x400,
|
|
0x10001, 0x10001, 0x10001, 0x10001, 0x10001, 0x10001, 0x10001, 0x10001,
|
|
0x10001, 0x400, 0x400, 0x101, 0x101, 0x101, 0, 0,
|
|
};
|
|
|
|
// OFFSET: 0x00AC4EA0
|
|
// FUNCTION: fn_17634
|
|
bool LexiconBoundary::Matches(unsigned char previous, unsigned char current, unsigned char options) const {
|
|
if (previous == 0xDD) {
|
|
return true;
|
|
}
|
|
|
|
if ((this->flags[previous] & 1) != 0 && (this->flags[current] & 0x2100) != 0) {
|
|
return true;
|
|
}
|
|
|
|
if (current == 32) {
|
|
return true;
|
|
}
|
|
|
|
if (previous == 32) {
|
|
return false;
|
|
}
|
|
|
|
const std::uint32_t before = this->flags[previous];
|
|
const std::uint32_t after = this->flags[current];
|
|
if ((options & 2) != 0) {
|
|
return ((before & 0x470) != 0) == ((after & 0x470) != 0) &&
|
|
(((before & 0x1000) != 0 && (after & 1) != 0) || ((before & 0x470) != 0 && (after & 0x470) != 0) ||
|
|
((before & 2) != 0 && (after & 2) != 0));
|
|
}
|
|
|
|
if ((after & 0x10) != 0 && (before & 0x10) == 0) {
|
|
return false;
|
|
}
|
|
|
|
if ((after & 0x60) != 0 || (before & 0x10) != 0 || ((before & 0x1000) != 0 && (after & 1) != 0)) {
|
|
return true;
|
|
}
|
|
|
|
return ((before & 0x400) != 0 && (after & 0x10002) != 0) || (after & 0x400) != 0;
|
|
}
|
|
|
|
// OFFSET: 0x00AC4A40
|
|
// FUNCTION: fn_17632
|
|
bool LexiconBoundary::Load() {
|
|
delete this->serializer;
|
|
this->serializer = new LexiconSerializer;
|
|
this->serializer->Load("..\\ftwrk.lex");
|
|
std::memcpy(this->flags, g_lexiconByteClasses, sizeof(this->flags));
|
|
return this->serializer != nullptr;
|
|
}
|