8000 update loading topic · ChatScript/ChatScript@3034ff1 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 3034ff1

Browse files
committed
update loading topic
1 parent 9adaa24 commit 3034ff1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

SRC/factSystem.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,16 +1249,20 @@ FACT* CreateFastFact(FACTOID_OR_MEANING subject, FACTOID_OR_MEANING verb, FACTOI
12491249
bool ReadBinaryFacts(FILE* in,bool dictionary) // read binary facts
12501250
{
12511251
if (!in) return false;
1252+
fseek(in, 0, SEEK_END);
1253+
unsigned long size = ftell(in);
1254+
fseek(in, 0, SEEK_SET);
12521255
FACT* base = lastFactUsed;
1253-
size_t elementCount = fread((void*)(lastFactUsed + 1), 1, 10000000 , in);
1256+
size_t elementCount = fread((void*)(lastFactUsed + 1), 1, size , in);
12541257
FClose(in);
12551258
if (elementCount != 0)
12561259
{
12571260
int count = elementCount / sizeof(FACT); // is +1 with extra verify node
12581261

12591262
// verify collection
12601263
FACT* verify = (FACT*)(lastFactUsed + count);
1261-
if (verify->subjectHead != CHECKSTAMP) return false; // old format
1264+
if (verify->subjectHead != CHECKSTAMP)
1265+
return false; // old format
12621266
if (verify->subject != Word2Index(dictionaryFree)) return false; // dictionary size wrong
12631267
if (verify->verb != (dictionaryFree - 1)->length) return false; // last entry differs in length of name
12641268
if (verify->object != Fact2Index(base)) return false; // start of fact append is wrong

0 commit comments

Comments
 (0)
0