本文整理汇总了C++中FileReader::CloseCurrent方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::CloseCurrent方法的具体用法?C++ FileReader::CloseCurrent怎么用?C++ FileReader::CloseCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::CloseCurrent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadScripts
int AIScriptManager :: LoadScripts(void)
{
std::string FileName = Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "AIScript"), "script_list.txt");
FileReader lfr;
if(lfr.OpenText(FileName.c_str()) != Err_OK)
{
g_Logs.data->error("Error opening master script list [%v]", FileName);
return -1;
}
AIScriptDef newItem;
lfr.CommentStyle = Comment_Semi;
string LoadName;
while(lfr.FileOpen() == true)
{
int r = lfr.ReadLine();
if(r > 0)
{
aiDef.push_back(newItem);
aiDef.back().CompileFromSource(Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "AIScript"), lfr.DataBuffer));
}
}
lfr.CloseCurrent();
g_Logs.data->info("Loaded %v AI Scripts", aiDef.size());
return 0;
}
示例2: if
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();
}
示例3: LoadNetworkData
void FriendListManager :: LoadNetworkData(void)
{
if(networkDataFile.size() == 0)
{
g_Log.AddMessageFormat("Network Cache filename not set.");
return;
}
FileReader lfr;
if(lfr.OpenText(networkDataFile.c_str()) != Err_OK)
{
g_Log.AddMessageFormat("Error opening Network Cache file for reading: %s", networkDataFile.c_str());
return;
}
lfr.CommentStyle = Comment_Semi;
while(lfr.FileOpen() == true)
{
lfr.ReadLine();
int r = lfr.MultiBreak("=,");
if(r >= 2)
{
int sourceDefID = lfr.BlockToIntC(0);
std::vector<int> &ref = networkData[sourceDefID];
for(int i = 1; i < r; i++)
ref.push_back(lfr.BlockToIntC(i));
}
}
lfr.CloseCurrent();
}
示例4: LoadClan
bool ClanManager::LoadClan(int id, Clan &clan) {
std::string path = GetPath(id);
if (!Platform::FileExists(path)) {
g_Logs.data->info("No file for CS item [%v]", path.c_str());
return NULL;
}
FileReader lfr;
if (lfr.OpenText(path.c_str()) != Err_OK) {
g_Logs.data->error("Could not open file [%v]", path.c_str());
return false;
}
lfr.CommentStyle = Comment_Semi;
int r = 0;
long amt = -1;
while (lfr.FileOpen() == true) {
r = lfr.ReadLine();
lfr.SingleBreak("=");
lfr.BlockToStringC(0, Case_Upper);
if (r > 0) {
if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
if (clan.mId != 0) {
g_Logs.data->warn(
"%v contains multiple entries. CS items have one entry per file",
path.c_str());
break;
}
clan.mId = id;
} else if (strcmp(lfr.SecBuffer, "NAME") == 0)
clan.mName = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "MOTD") == 0)
clan.mMOTD = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "MEMBER") == 0) {
std::vector<std::string> l;
Util::Split(lfr.BlockToStringC(1, 0), ",", l);
ClanMember mem;
if (l.size() > 1) {
mem.mID = atoi(l[0].c_str());
mem.mRank = atoi(l[1].c_str());
clan.mMembers.push_back(mem);
} else {
g_Logs.data->info(
"Incomplete clan member information [%v] in file [%v]",
lfr.SecBuffer, path.c_str());
}
} else
g_Logs.data->info("Unknown identifier [%v] in file [%v]",
lfr.SecBuffer, path.c_str());
}
}
lfr.CloseCurrent();
return true;
}
示例5: to
void ItemManager :: LoadItemList(char *filename, bool itemOverride)
{
TimeObject to("ItemManager::LoadItemList");
FileReader lfr;
if(lfr.OpenText(filename) != Err_OK)
{
g_Logs.data->error("Could not open file [%v].", filename);
return;
}
//Set the prebuilt overrides. Should be helpful since there could potentially
//be thousands of items in the list, and it will save from having convert these values
//for each item that applies.
sprintf(BindingTypeOverride, "%d", g_ItemBindingTypeOverride);
sprintf(ArmorTypeOverride, "%d", g_ItemArmorTypeOverride);
sprintf(WeaponTypeOverride, "%d", g_ItemWeaponTypeOverride);
char Delimiters[] = {'=', 13, 10, 0 };
lfr.Delimiter = Delimiters;
lfr.CommentStyle = Comment_Semi;
ItemDef newItem;
int count = 0;
while(lfr.FileOpen())
{
newItem.Reset();
LoadItemFromStream(lfr, &newItem, filename);
newItem.ProcessParams();
if(itemOverride == true)
{
ItemDef *ptr = GetPointerByID(newItem.mID);
if(ptr != NULL)
ptr->CopyFrom(&newItem);
else
g_Logs.data->warn("Item override specified for ID:%v was not found [%v]", newItem.mID, filename);
}
else
{
ItemDef *ptr = &ItemList[newItem.mID];
if(ptr->mID == 0)
ptr->CopyFrom(&newItem);
else
g_Logs.data->warn("Not allowed to override item %v [%v] in file [%v]", ptr->mID, ptr->mDisplayName.c_str(), filename);
//TODO: Obsolete
//ItemList.push_back(newItem);
}
count++;
}
lfr.CloseCurrent();
}
示例6: LoadStringsFile
int LoadStringsFile(std::string filename, vector<string> &list) {
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
g_Logs.data->error("Error opening file: %v", filename);
return -1;
}
lfr.CommentStyle = Comment_Semi;
while (lfr.FileOpen() == true) {
int r = lfr.ReadLine();
if (r > 0) {
list.push_back(lfr.DataBuffer);
}
}
lfr.CloseCurrent();
return list.size();
}
示例7: LoadSocialData
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();
}
示例8: LoadStringKeyValFile
int LoadStringKeyValFile(std::string filename, vector<StringKeyVal> &list) {
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
g_Logs.data->error("Error opening file: %v", filename);
return -1;
}
lfr.CommentStyle = Comment_Semi;
StringKeyVal newItem;
while (lfr.FileOpen() == true) {
int r = lfr.ReadLine();
lfr.SingleBreak("=");
if (r > 0) {
newItem.key = lfr.BlockToStringC(0, 0);
newItem.value = lfr.BlockToStringC(1, 0);
list.push_back(newItem);
}
}
lfr.CloseCurrent();
return list.size();
}
示例9: LoadItemPackages
void ItemManager :: LoadItemPackages(char *listFile, bool itemOverride)
{
FileReader lfr;
if(lfr.OpenText(listFile) != Err_OK)
{
g_Logs.data->error("Could not open Item list file [%v]", listFile);
Finalize();
return;
}
lfr.CommentStyle = Comment_Semi;
while(lfr.FileOpen() == true)
{
int r = lfr.ReadLine();
if(r > 0)
{
Platform::FixPaths(lfr.DataBuffer);
LoadItemList(lfr.DataBuffer, itemOverride);
}
}
lfr.CloseCurrent();
//Run any post-processing, like sorting.
Finalize();
}
示例10: LoadConfig
//.........这里部分代码省略.........
else if (strcmp(NameBlock, "SquirrelQueueSpeed") == 0)
g_Config.SquirrelQueueSpeed = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "PersistentBuffs") == 0)
g_Config.PersistentBuffs = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "FallDamage") == 0)
g_Config.FallDamage = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "PartyLoot") == 0)
g_Config.PartyLoot = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "AccountCredits") == 0)
g_Config.AccountCredits = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "MinPVPPlayerLootItems") == 0)
g_Config.MinPVPPlayerLootItems = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "MaxPVPPlayerLootItems") == 0)
g_Config.MaxPVPPlayerLootItems = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "NameChangeCost") == 0)
g_Config.NameChangeCost = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "SSLVerifyPeer") == 0)
g_Config.SSLVerifyPeer = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "SSLVerifyHostname") == 0)
g_Config.SSLVerifyHostname = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "SMTPHost") == 0)
g_Config.SMTPHost = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "SMTPUsername") == 0)
g_Config.SMTPUsername = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "SMTPPassword") == 0)
g_Config.SMTPPassword = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "SMTPPort") == 0)
g_Config.SMTPPort = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "SMTPSSL") == 0)
g_Config.SMTPSSL = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "SMTPSender") == 0)
g_Config.SMTPSender = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "LegacyAccounts") == 0)
g_Config.LegacyAccounts = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "PublicAPI") == 0)
g_Config.PublicAPI = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "DirectoryListing") == 0)
g_Config.DirectoryListing = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "HTTPKeepAlive") == 0)
g_Config.HTTPKeepAlive = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "HTTPServeAssets") == 0)
g_Config.HTTPServeAssets = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "LegacyServer") == 0)
g_Config.LegacyServer = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "SiteServiceUsername") == 0)
g_Config.SiteServiceUsername = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "SiteServicePassword") == 0)
g_Config.SiteServicePassword = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "APIAuthentication") == 0)
g_Config.APIAuthentication = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "OAuth2Client") == 0) {
if(!oauthSet) {
oauthSet = true;
g_Config.OAuth2Clients.clear();
}
STRINGLIST output;
Util::Split(lfr.BlockToString(1), "|", output);
if (output.size() == 3) {
OAuth2Client *c = new OAuth2Client();
c->ClientId = output[0];
c->ClientSecret = output[1];
c->RedirectURL = output[2];
g_Config.OAuth2Clients.push_back(c);
} else {
g_Logs.data->error("Invalid OAuth2Client string [%v] in config file [%v]",
lfr.BlockToString(0), filename);
}
} else if (strcmp(NameBlock, "Clans") == 0)
g_Config.Clans = lfr.BlockToBool(1);
else if (strcmp(NameBlock, "ClanCost") == 0)
g_Config.ClanCost = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "MaxAuctionHours") == 0)
g_Config.MaxAuctionHours = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "MinAuctionHours") == 0)
g_Config.MinAuctionHours = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "MinAuctionHours") == 0)
g_Config.PercentageCommisionPerHour = lfr.BlockToFloatC(1);
else if (strcmp(NameBlock, "MaxAuctionExpiredHours") == 0)
g_Config.MaxAuctionExpiredHours = lfr.BlockToInt(1);
else if (strcmp(NameBlock, "ShutdownHandlerScript") == 0)
g_Config.ShutdownHandlerScript = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "MaxNewCreditShopItemDays") == 0)
g_Config.MaxNewCreditShopItemDays = lfr.BlockToFloatC(1);
else if (strcmp(NameBlock, "StaticDataPath") == 0)
g_Config.StaticDataPath = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "VariableDataPath") == 0)
g_Config.VariableDataPath = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "TmpDataPath") == 0)
g_Config.TmpDataPath = lfr.BlockToStringC(1, 0);
else if (strcmp(NameBlock, "LogPath") == 0)
g_Config.LogPath = lfr.BlockToStringC(1, 0);
else {
g_Logs.data->error("Unknown identifier [%v] in config file [%v]",
lfr.BlockToString(0), filename);
}
}
}
lfr.CloseCurrent();
return true;
}
示例11: if
CreditShopItem * CreditShopManager::LoadItem(int id) {
std::string buf = GetPath(id);
if (!Platform::FileExists(buf.c_str())) {
g_Logs.data->error("No file for CS item [%v]", buf.c_str());
return NULL;
}
CreditShopItem *item = new CreditShopItem();
FileReader lfr;
if (lfr.OpenText(buf.c_str()) != Err_OK) {
g_Logs.data->error("Could not open file [%v]", buf.c_str());
return NULL;
}
// unsigned long mStartDate;
// unsigned long mEndDate;
lfr.CommentStyle = Comment_Semi;
int r = 0;
long amt = -1;
while (lfr.FileOpen() == true) {
r = lfr.ReadLine();
lfr.SingleBreak("=");
lfr.BlockToStringC(0, Case_Upper);
if (r > 0) {
if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
if (item->mId != 0) {
g_Logs.data->warn(
"%v contains multiple entries. CS items have one entry per file",
buf.c_str());
break;
}
item->mId = id;
} else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
item->mTitle = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0)
item->mDescription = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "BEGINDATE") == 0)
Util::ParseDate(lfr.BlockToStringC(1, 0), item->mStartDate);
else if (strcmp(lfr.SecBuffer, "ENDDATE") == 0)
Util::ParseDate(lfr.BlockToStringC(1, 0), item->mEndDate);
else if (strcmp(lfr.SecBuffer, "CREATEDDATE") == 0)
Util::ParseDate(lfr.BlockToStringC(1, 0), item->mCreatedDate);
else if (strcmp(lfr.SecBuffer, "PRICECURRENCY") == 0)
item->mPriceCurrency = Currency::GetIDByName(
lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "PRICEAMOUNT") == 0)
amt = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "PRICECOPPER") == 0)
item->mPriceCopper = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "PRICECREDITS") == 0)
item->mPriceCredits = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "ITEMID") == 0)
item->mItemId = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "ITEMAMOUNT") == 0
|| strcmp(lfr.SecBuffer, "IV1") == 0)
item->mIv1 = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "IV2") == 0)
item->mIv2 = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "LOOKID") == 0)
item->mLookId = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0)
item->mCategory = Category::GetIDByName(
lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "STATUS") == 0)
item->mStatus = Status::GetIDByName(lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "QUANTITYLIMIT") == 0)
item->mQuantityLimit = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "QUANTITYSOLD") == 0)
item->mQuantitySold = lfr.BlockToIntC(1);
else
g_Logs.data->error("Unknown identifier [%v] in file [%v]",
lfr.SecBuffer, buf.c_str());
}
}
lfr.CloseCurrent();
// For backwards compatibility - will be able to remove once all items resaved or removed
if (amt > 0) {
if (item->mPriceCurrency == Currency::COPPER)
item->mPriceCopper = amt;
else if (item->mPriceCurrency == Currency::CREDITS)
item->mPriceCredits = amt;
}
cs.Enter("CreditShopManager::LoadItem");
mItems[id] = item;
cs.Leave();
return item;
}
示例12: LoadItemFromStream
int LoadItemFromStream(FileReader &fr, ItemDef *itemDef, char *debugFilename)
{
//Return codes:
// 1 Section end marker reached.
// 0 End of file reached.
// -1 Another entry was encountered
bool curEntry = false;
int r;
while(fr.FileOpen())
{
long CurPos = ftell(fr.FileHandle[0]);
r = fr.ReadLine();
if(r > 0)
r = fr.SingleBreak(NULL);
if(r > 0)
{
fr.BlockToStringC(0, Case_Upper);
if(strcmp(fr.SecBuffer, "[ENTRY]") == 0)
{
if(curEntry == true)
{
//Reset the position so it doesn't interfere with reading the next
//entry
fr.FilePos = CurPos;
fseek(fr.FileHandle[0], CurPos, SEEK_SET);
return -1;
}
else
curEntry = true;
}
else if(strcmp(fr.SecBuffer, "[END]") == 0)
{
return 1;
}
else
{
char *ValueBuf = fr.BlockToString(1);
char *NameBuf = fr.BlockToString(0);
if(strcmp(NameBuf, "mBindingType") == 0)
{
if(g_ItemBindingTypeOverride > 0)
{
if(ValueBuf[0] == '0' + g_ItemBindingTypeOverride)
ValueBuf[0] = 0;
}
else if(g_ItemBindingTypeOverride == 0)
ValueBuf = BindingTypeOverride;
}
else if(strcmp(NameBuf, "mArmorType") == 0)
{
if(g_ItemArmorTypeOverride >= 0)
ValueBuf = ArmorTypeOverride;
}
else if(strcmp(NameBuf, "mWeaponType") == 0)
{
if(g_ItemWeaponTypeOverride >= 0)
ValueBuf = WeaponTypeOverride;
}
/*
if(strcmp(NameBuf, "craftItemDefId") == 0)
{
itemDef->craftItemDefId.push_back(fr.BlockToInt(1));
}*/
//int r = SetItemProperty(itemDef, fr.BlockToString(0), fr.BlockToString(1));
int r = SetItemProperty(itemDef, NameBuf, ValueBuf);
if(r == -1)
g_Logs.data->warn("Unknown property [%v] in item file [%v] on line [%v]", fr.BlockToString(0), debugFilename, fr.LineNumber);
}
}
}
fr.CloseCurrent();
return 1;
}
示例13: if
CreditShopItem * CreditShopManager::LoadItem(int id) {
const char * buf = GetPath(id).c_str();
if (!Platform::FileExists(buf)) {
g_Log.AddMessageFormat("No file for CS item [%s]", buf);
return NULL;
}
CreditShopItem *item = new CreditShopItem();
item->mId = id;
FileReader lfr;
if (lfr.OpenText(buf) != Err_OK) {
g_Log.AddMessageFormat("Could not open file [%s]", buf);
return NULL;
}
// unsigned long mStartDate;
// unsigned long mEndDate;
lfr.CommentStyle = Comment_Semi;
int r = 0;
while (lfr.FileOpen() == true) {
r = lfr.ReadLine();
lfr.SingleBreak("=");
lfr.BlockToStringC(0, Case_Upper);
if (r > 0) {
if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) {
if (item->mId != 0)
g_Log.AddMessageFormat(
"[WARNING] %s contains multiple entries. CS items have one entry per file",
buf);
}
else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
item->mTitle = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0)
item->mDescription = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "BEGINDATE") == 0)
Util::ParseDate(lfr.BlockToStringC(1, 0), item->mStartDate);
else if (strcmp(lfr.SecBuffer, "ENDDATE") == 0)
Util::ParseDate(lfr.BlockToStringC(1, 0), item->mEndDate);
else if (strcmp(lfr.SecBuffer, "PRICECURRENCY") == 0)
item->mPriceCurrency =Currency::GetIDByName(lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "PRICEAMOUNT") == 0)
item->mPriceAmount = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "ITEMID") == 0)
item->mItemId = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "ITEMAMOUNT") == 0 || strcmp(lfr.SecBuffer, "IV1") == 0)
item->mIv1 = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "IV2") == 0)
item->mIv2 = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "LOOKID") == 0)
item->mLookId = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0)
item->mCategory =Category::GetIDByName(lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "STATUS") == 0)
item->mStatus = Status::GetIDByName(lfr.BlockToStringC(1, 0));
else if (strcmp(lfr.SecBuffer, "QUANTITYLIMIT") == 0)
item->mQuantityLimit = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "QUANTITYSOLD") == 0)
item->mQuantitySold = lfr.BlockToIntC(1);
else
g_Log.AddMessageFormat("Unknown identifier [%s] in file [%s]",
lfr.SecBuffer, buf);
}
}
lfr.CloseCurrent();
mItems[id] = item;
return item;
}
示例14: LoadFile
void BookManager::LoadFile(std::string filename) {
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
g_Logs.data->error("Could not open file [%v]", filename);
return;
}
int bookID = atoi(Platform::Basename(filename).c_str());
BookDefinition newItem;
newItem.bookID = bookID;
int r = 0;
std::string page;
bool inPageText = false;
while (lfr.FileOpen() == true) {
r = lfr.ReadLine();
std::string wholeLine = std::string(lfr.DataBuffer);
bool escapedLine = Util::HasBeginning(wholeLine, "\\");
if (r > 0 && !escapedLine) {
lfr.SingleBreak("=");
lfr.BlockToStringC(0, Case_Upper);
if (strcmp(lfr.SecBuffer, "[PAGE]") == 0) {
if(page.length() > 0) {
newItem.pages.push_back(page);
page = "";
}
inPageText = false;
} else if (strcmp(lfr.SecBuffer, "TITLE") == 0)
newItem.title = lfr.BlockToStringC(1, 0);
else if (strcmp(lfr.SecBuffer, "TEXT") == 0) {
page.clear();
page.append(lfr.BlockToStringC(1, 0));
inPageText = true;
}
else {
if(inPageText) {
if(page.length() > 0) {
if(Util::HasEnding(page, "\\")) {
page = page.substr(0, page.length() - 1);
}
else
page.append("<br>");
}
page.append(wholeLine);
}
}
}
else if(inPageText) {
if(escapedLine) {
wholeLine = wholeLine.substr(1);
}
if(page.length() > 0) {
if(Util::HasEnding(page, "\\")) {
page = page.substr(0, page.length() - 1);
}
else
page.append("<br>");
}
if(r != 0) {
page.append(wholeLine);
}
}
}
if(page.length() > 0) {
newItem.pages.push_back(page);
}
books[newItem.bookID] = newItem;
lfr.CloseCurrent();
}
示例15: Init
bool InfoManager::Init() {
TextFileEntityReader ter(Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "Data"), "Tips.txt" ), Case_None, Comment_Semi);
ter.Start();
if (!ter.Exists())
return false;
ter.Key("", "", true);
ter.Index("ENTRY");
STRINGLIST sections = ter.Sections();
int i = 0;
for (auto a = sections.begin(); a != sections.end(); ++a) {
ter.PushSection(*a);
Tip t;
t.mID = ++i;
if (!t.EntityKeys(&ter) || !t.ReadEntity(&ter))
return false;
mTips.push_back(t);
ter.PopSection();
}
ter.End();
std::string filename = Platform::JoinPath(Platform::JoinPath(g_Config.ResolveStaticDataPath(), "Data"), "Game.txt" );
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
g_Logs.data->error("Could not open configuration file: %v", filename);
return false;
}
else {
static char Delimiter[] = { '=', 13, 10 };
lfr.Delimiter = Delimiter;
lfr.CommentStyle = Comment_Semi;
while (lfr.FileOpen() == true) {
int r = lfr.ReadLine();
if (r > 0) {
lfr.SingleBreak("=");
char *NameBlock = lfr.BlockToString(0);
if (strcmp(NameBlock, "GameName") == 0) {
mGameName = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "Edition") == 0) {
mEdition = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "StartZone") == 0) {
mStartZone = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "StartX") == 0) {
mStartX = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "StartY") == 0) {
mStartY = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "StartZ") == 0) {
mStartZ = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "StartRotation") == 0) {
mStartRotation = lfr.BlockToInt(1);
}
else {
g_Logs.data->error("Unknown identifier [%v] in config file [%v]",
lfr.BlockToString(0), filename);
}
}
}
lfr.CloseCurrent();
}
return true;
}