?? inifile.cpp
字號:
/* Tao's 45 Engine
說句實話:
程序的算法是從Jim Adams 1996 年的 Isometric Views 一
文中來的,我自己的東西并不多,我當時得到這個比較實用的算法是非
常高興的,覺得自己終于可以編個小游戲了,特別因為我喜歡Dialbo這
樣的游戲,不過沒有美工也卻實是件可怕的事......
這個程序有Alpha的代碼,不過太慢了,我一直無法使他支持M
MX,唉!我的p54c(你不知道p54c p55c的區別?)...
如果您改進了他或完善了,請給我一份好嗎?讓我們共同進步!
TAO
http://fireice.yeah.net
Antao@telekbird.com.cn
1999.10. */
// IniFile.cpp: implementation of the IniFile class.
//
//////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include "IniFile.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IniFile::IniFile()
{
m_lpDataBuffer=NULL;
}
IniFile::~IniFile()
{
if (m_lpDataBuffer!=NULL) free(m_lpDataBuffer);
}
bool IniFile::Load(char * lpszFilename)
{
FILE *fp=fopen(lpszFilename,"rb");
if (fp==NULL) return false;
fseek(fp,0,SEEK_END);
int size=ftell(fp);
m_lpDataBuffer=(char *)malloc(size*sizeof(char));
fseek(fp,0,SEEK_SET);
fread(m_lpDataBuffer,size,1,fp);
fclose(fp);
return true;
}
int IniFile::GetValue(char *section, char *keywords)
{
assert(section);
assert(keywords);
char *lpdest=strstr(m_lpDataBuffer,section);
if (lpdest==NULL) return -1;
char *found=strstr(lpdest,keywords);
if (found==NULL) return -1;
found=strstr(found,"=");
found++;
int value=atoi(found);
return value;
}
int IniFile::GetString(char * section , char * keywords, char * buffer, int len)
{
assert(section);
assert(keywords);
char *lpdest=strstr(m_lpDataBuffer,section);
if (lpdest==NULL) return -1;
char *found=strstr(lpdest,keywords);
if (found==NULL) return -1;
found=strstr(found,"=");
found++;
int count=0;
while(count<len)
{
if (*found==0xd) { *buffer=0;break; }
*buffer++=*found++;
count++;
}
return count;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -