本文整理汇总了C++中FileReader::BlockToStringC方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::BlockToStringC方法的具体用法?C++ FileReader::BlockToStringC怎么用?C++ FileReader::BlockToStringC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::BlockToStringC方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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();
}
示例2: 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;
}
示例3: 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();
}
示例4: 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();
}
示例5: LoadFromStream
bool PlayerStatSet::LoadFromStream(FileReader &fr) {
char *NameBlock = fr.BlockToStringC(0, Case_Upper);
if(strcmp(NameBlock, "TOTALKILLS") == 0)
TotalKills = fr.BlockToIntC(1);
else if(strcmp(NameBlock, "TOTALDEATHS") == 0)
TotalDeaths = fr.BlockToIntC(1);
else if(strcmp(NameBlock, "TOTALPVPKILLS") == 0)
TotalPVPKills = fr.BlockToIntC(1);
else if(strcmp(NameBlock, "TOTALPVPDEATHS") == 0)
TotalPVPDeaths = fr.BlockToIntC(1);
else
return false;
return true;
}
示例6: 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();
}
示例7: LoadConfig
bool LoadConfig(std::string filename) {
bool oauthSet = false;
//Loads the configuration options from the target file. These are core options
//required for the server to operate.
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
return false;
}
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, "ProtocolVersion") == 0) {
g_ProtocolVersion = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "AuthMode") == 0) {
g_AuthMode = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "AuthKey") == 0) {
strncpy(g_AuthKey, lfr.BlockToString(1), sizeof(g_AuthKey) - 1);
} else if (strcmp(NameBlock, "RouterPort") == 0) {
g_RouterPort = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "SimulatorAddress") == 0) {
strncpy(g_SimulatorAddress, lfr.BlockToString(1),
sizeof(g_SimulatorAddress) - 1);
} else if (strcmp(NameBlock, "BindAddress") == 0) {
strncpy(g_BindAddress, lfr.BlockToString(1),
sizeof(g_BindAddress) - 1);
} else if (strcmp(NameBlock, "SimulatorPort") == 0) {
g_SimulatorPort = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ThreadSleep") == 0) {
g_ThreadSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ErrorSleep") == 0) {
g_ErrorSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "MainSleep") == 0) {
g_MainSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefX") == 0) {
g_Config.DefX = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefY") == 0) {
g_Config.DefY = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefZ") == 0) {
g_Config.DefZ = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefZone") == 0) {
g_Config.DefZone = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefRotation") == 0) {
g_Config.DefRotation = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "HTTPBaseFolder") == 0) {
g_Config.HTTPBaseFolder = lfr.BlockToString(1);
} else if (strcmp(NameBlock, "HTTPCARFolder") == 0) {
g_Config.HTTPCARFolder = lfr.BlockToString(1);
} else if (strcmp(NameBlock, "HTTPListenPort") == 0) {
g_HTTPListenPort = lfr.BlockToInt(1);
}
#ifndef NO_SSL
else if(strcmp(NameBlock, "HTTPSListenPort") == 0)
{
g_HTTPSListenPort = lfr.BlockToInt(1);
}
else if(strcmp(NameBlock, "SSLCertificate") == 0)
{
AppendString(g_SSLCertificate, lfr.BlockToStringC(1, 0));
}
#endif
else if (strcmp(NameBlock, "RebroadcastDelay") == 0) {
g_RebroadcastDelay = lfr.BlockToULongC(1);
} else if (strcmp(NameBlock, "SceneryAutosaveTime") == 0) {
g_SceneryAutosaveTime = lfr.BlockToULongC(1);
} else if (strcmp(NameBlock, "ForceUpdateTime") == 0) {
g_ForceUpdateTime = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemBindingTypeOverride") == 0) {
g_ItemBindingTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemArmorTypeOverride") == 0) {
g_ItemArmorTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemWeaponTypeOverride") == 0) {
g_ItemWeaponTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "MOTD_Name") == 0) {
g_MOTD_Name = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "MOTD_Channel") == 0) {
g_MOTD_Channel = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "RemoteAuthenticationPassword") == 0) {
g_Config.RemoteAuthenticationPassword = lfr.BlockToStringC(1,
0);
} else if (strcmp(NameBlock, "ProperSceneryList") == 0) {
g_Config.ProperSceneryList = lfr.BlockToIntC(1);
} else if (strcmp(NameBlock, "BuybackLimit") == 0) {
g_Config.BuybackLimit = lfr.BlockToIntC(1);
} else if (strcmp(NameBlock, "Upgrade") == 0)
g_Config.Upgrade = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "HeartbeatIntervalMS") == 0)
g_Config.HeartbeatIntervalMS = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "HeartbeatAbortCount") == 0)
g_Config.HeartbeatAbortCount = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "WarpMovementBlockTime") == 0)
g_Config.WarpMovementBlockTime = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "IdleCheckVerification") == 0)
//.........这里部分代码省略.........
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: Load
Petition PetitionManager::Load(const char *path, int id) {
char buffer[256];
Util::SafeFormat(buffer, sizeof(buffer), "%s\\%d.txt", path, id);
Platform::FixPaths(buffer);
FileReader lfr;
Petition newItem;
if (lfr.OpenText(buffer) != Err_OK) {
g_Log.AddMessageFormat("Could not open file [%s]", buffer);
} else {
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 (newItem.petitionId != 0) {
g_Log.AddMessageFormat(
"[WARNING] Petition file %s has more than one ENTRY",
buffer);
newItem.RunLoadDefaults();
break;
}
}
else if (strcmp(lfr.SecBuffer, "ID") == 0)
newItem.petitionId = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "SAGE") == 0)
newItem.sageCDefID = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "PETITIONER") == 0)
newItem.petitionerCDefID = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "TIMESTAMP") == 0)
newItem.timestamp = lfr.BlockToULongC(1);
else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0)
newItem.category = lfr.BlockToIntC(1);
else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0) {
string r = lfr.BlockToStringC(1, 0);
Util::ReplaceAll(r, "\\r\\n", "\r\n");
Util::ReplaceAll(r, "\\n", "\n");
Util::SafeCopy(newItem.description, r.c_str(),
sizeof(newItem.description));
} else if (strcmp(lfr.SecBuffer, "RESOLUTION") == 0) {
string r = lfr.BlockToStringC(1, 0);
Util::ReplaceAll(r, "\\r\\n", "\r\n");
Util::ReplaceAll(r, "\\n", "\n");
Util::SafeCopy(newItem.resolution, r.c_str(),
sizeof(newItem.resolution));
} else {
g_Log.AddMessageFormat(
"[WARNING] Petition file %s has unknown pair %s",
buffer, lfr.SecBuffer);
}
}
}
}
if (newItem.petitionId != 0) {
newItem.RunLoadDefaults();
}
return newItem;
}