void IGFManager :: LoadConfig(void) { char buffer[256]; Platform::GenerateFilePath(buffer, "IGForum", "IGFSession.txt"); FileReader lfr; if(lfr.OpenText(buffer) != Err_OK) { g_Logs.data->error("IGFManager::LoadConfig failed to open file."); return; } lfr.CommentStyle = Comment_Semi; while(lfr.FileOpen() == true) { lfr.ReadLine(); int r = lfr.BreakUntil("=", '='); if(r > 0) { lfr.BlockToStringC(0, 0); if(strcmp(lfr.SecBuffer, "NextCategoryID") == 0) mNextCategoryID = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "NextThreadID") == 0) mNextThreadID = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "NextPostID") == 0) mNextPostID = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "PlatformLaunchMinute") == 0) mPlatformLaunchMinute = lfr.BlockToULongC(1); else g_Logs.data->warn("IGFManager::LoadConfig unknown identifier [%v] in file [%v] on line [%v]", lfr.SecBuffer, buffer, lfr.LineNumber); } } lfr.CloseCurrent(); }
void IGFThreadPage :: LoadFile(const char *filename) { FileReader lfr; if(lfr.OpenText(filename) != Err_OK) { g_Logs.data->error("IGFThreadPage::LoadFile failed to open file."); return; } lfr.CommentStyle = Comment_Semi; IGFThread entry; while(lfr.FileOpen() == true) { lfr.ReadLine(); int r = lfr.BreakUntil("=", '='); if(r > 0) { lfr.BlockToStringC(0, 0); if(strcmp(lfr.SecBuffer, "[ENTRY]") == 0) { if(entry.mID != 0) InsertEntry(entry, false); entry.Clear(); } else if(strcmp(lfr.SecBuffer, "ID") == 0) entry.mID = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "Title") == 0) entry.mTitle = lfr.BlockToStringC(1, 0); else if(strcmp(lfr.SecBuffer, "CreationAccount") == 0) entry.mCreationAccount = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "CreationTime") == 0) entry.mCreationTime = lfr.BlockToStringC(1, 0); else if(strcmp(lfr.SecBuffer, "CreatorName") == 0) entry.mCreatorName = lfr.BlockToStringC(1, 0); else if(strcmp(lfr.SecBuffer, "ParentCategory") == 0) entry.mParentCategory = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "Locked") == 0) entry.mLocked = lfr.BlockToBoolC(1); else if(strcmp(lfr.SecBuffer, "Stickied") == 0) entry.mStickied = lfr.BlockToBoolC(1); else if(strcmp(lfr.SecBuffer, "Flags") == 0) entry.mFlags.setraw(lfr.BlockToIntC(1)); else if(strcmp(lfr.SecBuffer, "LastUpdateTime") == 0) entry.mLastUpdateTime = lfr.BlockToULongC(1); else if(strcmp(lfr.SecBuffer, "PostList") == 0) { r = lfr.MultiBreak("=,"); for(int i = 1; i < r; i++) entry.mPostList.push_back(lfr.BlockToIntC(i)); } else g_Logs.data->warn("IGFThreadPage::LoadFile unknown identifier [%v] in file [%v] on line [%v]", lfr.SecBuffer, filename, lfr.LineNumber); } } if(entry.mID != 0) InsertEntry(entry, false); lfr.CloseCurrent(); }
void IGFPostPage :: LoadFile(const char *filename) { FileReader lfr; if(lfr.OpenText(filename) != Err_OK) { g_Logs.data->error("IGFPostPage::LoadFile failed to open: %v", filename); return; } //lfr.CommentStyle = Comment_Semi; //No comments since they're valid characters for posts. IGFPost entry; while(lfr.FileOpen() == true) { lfr.ReadLine(); int r = lfr.BreakUntil("=", '='); if(r > 0) { lfr.BlockToStringC(0, 0); if(strcmp(lfr.SecBuffer, "[ENTRY]") == 0) { if(entry.mID != 0) InsertEntry(entry, false); entry.Clear(); } else if(strcmp(lfr.SecBuffer, "ID") == 0) entry.mID = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "CreationAccount") == 0) entry.mCreationAccount = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "CreationTime") == 0) entry.mCreationTime = lfr.BlockToStringC(1, 0); else if(strcmp(lfr.SecBuffer, "CreatorName") == 0) entry.mCreatorName = lfr.BlockToStringC(1, 0); else if(strcmp(lfr.SecBuffer, "ParentThread") == 0) entry.mParentThread = lfr.BlockToIntC(1); else if(strcmp(lfr.SecBuffer, "PostedTime") == 0) entry.mPostedTime = lfr.BlockToULongC(1); else if(strcmp(lfr.SecBuffer, "LastUpdateTime") == 0) entry.mLastUpdateTime = lfr.BlockToULongC(1); else if(strcmp(lfr.SecBuffer, "EditCount") == 0) entry.mEditCount = lfr.BlockToULongC(1); else if(strcmp(lfr.SecBuffer, "BodyText") == 0) entry.mBodyText = lfr.BlockToStringC(1, 0); else g_Logs.data->warn("IGFPostPage::LoadFile unknown identifier [%v] in file [%v] on line [%v]", lfr.SecBuffer, filename, lfr.LineNumber); } } if(entry.mID != 0) InsertEntry(entry, false); lfr.CloseCurrent(); }
void FriendListManager :: LoadSocialData(void) { if(socialDataFile.size() == 0) { g_Log.AddMessageFormat("Social Cache filename not set."); return; } FileReader lfr; if(lfr.OpenText(socialDataFile.c_str()) != Err_OK) { g_Log.AddMessageFormat("Error opening Social Cache file for reading: %s", socialDataFile.c_str()); return; } lfr.CommentStyle = Comment_Semi; SocialWindowEntry newItem; while(lfr.FileOpen() == true) { lfr.ReadLine(); int r = lfr.BreakUntil(",|", '|'); if(r >= 6) { newItem.creatureDefID = lfr.BlockToIntC(0); newItem.name = lfr.BlockToStringC(1, 0); newItem.level = lfr.BlockToIntC(2); newItem.profession = lfr.BlockToIntC(3); newItem.online = lfr.BlockToBoolC(4); newItem.shard = lfr.BlockToStringC(5, 0); //HACK: since the friend list is only loaded when the server is launched, //it's safe to assume that everyone is offline. This should auto fix any //players that are stuck offline. If I had been thinking when I designed //this, the online flag wouldn't be saved at all. //TODO: remove onine status from save files newItem.online = false; //Get the status last in case it contains any unusual characters. if(r >= 7) newItem.status = lfr.BlockToStringC(6, 0); else newItem.status.clear(); UpdateSocialEntry(newItem); } } lfr.CloseCurrent(); }