本文整理汇总了C++中FileReader::BlockToIntC方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::BlockToIntC方法的具体用法?C++ FileReader::BlockToIntC怎么用?C++ FileReader::BlockToIntC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::BlockToIntC方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例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: 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;
}
示例4: 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();
}
示例5: 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)
//.........这里部分代码省略.........
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}