本文整理汇总了C++中CFileHandler::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileHandler::Read方法的具体用法?C++ CFileHandler::Read怎么用?C++ CFileHandler::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileHandler
的用法示例。
在下文中一共展示了CFileHandler::Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void CTileHandler::ProcessTiles2(void)
{
unsigned char* data=new unsigned char[1024*1024*4];
bigTex=CBitmap(data,1,1); /// /free big tex memory
int tilex=xsize/4;
int tiley=ysize/4;
for(int a=0;a<(tilex*tiley)/1024;++a){
int startTile=a*1024;
char name[100];
DDSURFACEDESC2 ddsheader;
int ddssignature;
CFileHandler file;
if (prog == "nvdxt.exe " || prog == "nvcompress.exe " || prog == "texconv.exe " || prog == "old_nvdxt.exe "){
sprintf(name,"Temp%03i.dds",a);
file.Open(name);
file.Read(&ddssignature, sizeof(int));
file.Read(&ddsheader, sizeof(DDSURFACEDESC2));
}
if (prog == "texcompress.exe "){
sprintf(name, "temp\\Temp%03i.png.raw", a);
file.Open(name);
}
char bigtile[696320]; // /1024x1024 and 4 mipmaps
file.Read(bigtile, 696320);
for(int b=0;b<1024;++b){
int x=b%32;
int y=b/32;
int xb=(startTile+b)%tilex;
int yb=(startTile+b)/tilex;
char* ctile=new char[SMALL_TILE_SIZE];
ReadTile(x*32,y*32,ctile,bigtile);
CBitmap* bm=new CBitmap();
bm->CreateFromDXT1((unsigned char*)ctile,32,32);
int t1=tileUse[max(0,(yb-1)*tilex+xb)];
int t2=tileUse[max(0,yb*tilex+xb-1)];
int ct=FindCloseTile(bm,t1==t2?t1:-1);
if(ct==-1){
tileUse[yb*tilex+xb]=usedTiles;
tiles[usedTiles++]=bm;
newTiles.push_back(ctile);
} else {
tileUse[yb*tilex+xb]=ct;
delete bm;
delete[] ctile;
}
}
printf("Creating tiles %i/%i %i%%\n", usedTiles-numExternalTile,(a+1)*1024,(((a+1)*1024)*100)/(tilex*tiley));
}
delete[] data;
}
示例2: GetLine
static std::string GetLine(CFileHandler& fh)
{
std::string s = "";
char a;
fh.Read(&a, 1);
while (a!='\n' && a!='\r') {
s += a;
fh.Read(&a, 1);
if (fh.Eof())
break;
}
return s;
}
示例3:
string CUnit3DLoader::GetLine(CFileHandler& fh)
{
string s="";
char a;
fh.Read(&a,1);
while(a!='\xd' && a!='\xa'){
s+=a;
fh.Read(&a,1);
if(fh.Eof())
break;
}
return s;
}
示例4: ReadMapTileFileHeader
/// Read TileFileHeader head from file src
void CSMFMapFile::ReadMapTileFileHeader(TileFileHeader& head, CFileHandler& file)
{
file.Read(&head.magic,sizeof(head.magic));
head.version = ReadInt(file);
head.numTiles = ReadInt(file);
head.tileSize = ReadInt(file);
head.compressionType = ReadInt(file);
}
示例5: Init
void CTAPalette::Init(CFileHandler& paletteFile)
{
for (unsigned c = 0; c < NUM_PALETTE_ENTRIES; ++c) {
for (unsigned c2 = 0; c2 < 4; ++c2) {
paletteFile.Read(&p[c][c2], 1);
}
p[c][3] = 255;
}
}
示例6: GetWord
static void GetWord(CFileHandler& fh, std::string &s)
{
char a = fh.Peek();
while (a == ' ' || a == '\n' || a == '\r') {
fh.Read(&a, 1);
a = fh.Peek();
if (fh.Eof())
break;
}
s = "";
fh.Read(&a, 1);
while (a != ',' && a != ' ' && a != '\n' && a != '\r') {
s += a;
fh.Read(&a, 1);
if (fh.Eof())
break;
}
}
示例7: LoadToken
std::string CSpawnScript::LoadToken(CFileHandler& file)
{
std::string s;
char c;
while (!file.Eof()) {
file.Read(&c,1);
if(c>='0' && c<='z')
break;
}
s += c;
while (!file.Eof()) {
file.Read(&c,1);
if(c<'0' || c>'z')
return s;
s+=c;
}
return s;
}
示例8: ReadFile
bool CAICallback::ReadFile (const char *name, void *buffer, int bufferLength)
{
CFileHandler fh (name);
int fs;
if (!fh.FileExists() || bufferLength < (fs = fh.FileSize()))
return false;
fh.Read (buffer, fs);
return true;
}
示例9: GetLine
// returns next line (without newlines)
string SimpleParser::GetLine(CFileHandler& fh)
{
lineNumber++;
char a;
string s = "";
while (!fh.Eof()) {
fh.Read(&a, 1);
if (a == '\n') { break; }
if (a != '\r') { s += a; }
}
return s;
}
示例10: GetLine
// returns next line (without newlines)
static string GetLine(CFileHandler& fh)
{
lineNumber++;
char a;
string s = "";
while (true) {
a = fh.Peek();
if (a == EOF) { break; }
fh.Read(&a, 1);
if (a == '\n') { break; }
if (a != '\r') { s += a; }
}
return s;
}
示例11: ReadMapHeader
/// Read SMFHeader head from file
void CSMFMapFile::ReadMapHeader(SMFHeader& head, CFileHandler& file)
{
file.Read(head.magic,sizeof(head.magic));
head.version = ReadInt(file);
head.mapid = ReadInt(file);
head.mapx = ReadInt(file);
head.mapy = ReadInt(file);
head.squareSize = ReadInt(file);
head.texelPerSquare = ReadInt(file);
head.tilesize = ReadInt(file);
head.minHeight = ReadFloat(file);
head.maxHeight = ReadFloat(file);
head.heightmapPtr = ReadInt(file);
head.typeMapPtr = ReadInt(file);
head.tilesPtr = ReadInt(file);
head.minimapPtr = ReadInt(file);
head.metalmapPtr = ReadInt(file);
head.featurePtr = ReadInt(file);
head.numExtraHeaders = ReadInt(file);
}
示例12: ReadFile
int CArchiveDir::ReadFile(int handle, void* buffer, int numBytes)
{
CFileHandler* f = GetFileHandler(handle);
f->Read(buffer, numBytes);
return 0;
}
示例13: tileFile
CBFGroundTextures::CBFGroundTextures(CSmfReadMap *rm)
{
CFileHandler *ifs = rm->ifs;
map = rm;
numBigTexX=gs->mapx/128;
numBigTexY=gs->mapy/128;
MapHeader* header=&map->header;
ifs->Seek(header->tilesPtr);
tileSize = header->tilesize;
MapTileHeader tileHeader;
READPTR_MAPTILEHEADER(tileHeader,ifs);
tileMap = SAFE_NEW int[(header->mapx*header->mapy)/16];
tiles = SAFE_NEW char[tileHeader.numTiles*SMALL_TILE_SIZE];
int curTile=0;
for(int a=0;a<tileHeader.numTileFiles;++a){
PrintLoadMsg("Loading tile file");
int size;
ifs->Read(&size,4);
size = swabdword(size);
string name;
while(true){
char ch;
ifs->Read(&ch,1);
/* char, no swab */
if(ch==0)
break;
name+=ch;
}
name=string("maps/")+name;
CFileHandler tileFile(name);
if(!tileFile.FileExists()){
logOutput.Print("Couldnt find tile file %s",name.c_str());
memset(&tiles[curTile*SMALL_TILE_SIZE],0xaa,size*SMALL_TILE_SIZE);
curTile+=size;
continue;
}
PrintLoadMsg("Reading tiles");
TileFileHeader tfh;
READ_TILEFILEHEADER(tfh,tileFile);
if(strcmp(tfh.magic,"spring tilefile")!=0 || tfh.version!=1 || tfh.tileSize!=32 || tfh.compressionType!=1){
char t[500];
sprintf(t,"Error couldnt open tile file %s",name.c_str());
handleerror(0,t,"Error when reading tile file",0);
exit(0);
}
for(int b=0;b<size;++b){
tileFile.Read(&tiles[curTile*SMALL_TILE_SIZE],SMALL_TILE_SIZE);
curTile++;
}
}
PrintLoadMsg("Reading tile map");
int count = (header->mapx*header->mapy)/16;
ifs->Read(tileMap, count*sizeof(int));
for (int i = 0; i < count; i++) {
tileMap[i] = swabdword(tileMap[i]);
}
tileMapXSize = header->mapx/4;
tileMapYSize = header->mapy/4;
squares=SAFE_NEW GroundSquare[numBigTexX*numBigTexY];
for(int y=0;y<numBigTexY;++y){
for(int x=0;x<numBigTexX;++x){
GroundSquare* square=&squares[y*numBigTexX+x];
square->texLevel=1;
square->lastUsed=-100;
LoadSquare(x,y,2);
}
}
inRead=false;
}
示例14: runtime_error
CglFont::CglFont(const std::string& fontfile, int size, int _outlinewidth, float _outlineweight):
fontSize(size),
fontPath(fontfile),
outlineWidth(_outlinewidth),
outlineWeight(_outlineweight),
inBeginEnd(false)
{
if (size<=0)
size = 14;
const float invSize = 1.0f / size;
const float normScale = invSize / 64.0f;
FT_Library library;
FT_Face face;
//! initialize Freetype2 library
FT_Error error = FT_Init_FreeType(&library);
if (error) {
string msg = "FT_Init_FreeType failed:";
msg += GetFTError(error);
throw std::runtime_error(msg);
}
//! load font via VFS
CFileHandler* f = new CFileHandler(fontPath);
if (!f->FileExists()) {
//! check in 'fonts/', too
if (fontPath.substr(0, 6) != "fonts/") {
delete f;
fontPath = "fonts/" + fontPath;
f = new CFileHandler(fontPath);
}
if (!f->FileExists()) {
delete f;
FT_Done_FreeType(library);
throw content_error("Couldn't find font '" + fontfile + "'.");
}
}
int filesize = f->FileSize();
FT_Byte* buf = new FT_Byte[filesize];
f->Read(buf,filesize);
delete f;
//! create face
error = FT_New_Memory_Face(library, buf, filesize, 0, &face);
if (error) {
FT_Done_FreeType(library);
delete[] buf;
string msg = fontfile + ": FT_New_Face failed: ";
msg += GetFTError(error);
throw content_error(msg);
}
//! set render size
error = FT_Set_Pixel_Sizes(face, 0, size);
if (error) {
FT_Done_Face(face);
FT_Done_FreeType(library);
delete[] buf;
string msg = fontfile + ": FT_Set_Pixel_Sizes failed: ";
msg += GetFTError(error);
throw content_error(msg);
}
//! setup character range
charstart = 32;
charend = 254; //! char 255 = colorcode
chars = (charend - charstart) + 1;
//! get font information
fontFamily = face->family_name;
fontStyle = face->style_name;
//! font's descender & height (in pixels)
fontDescender = normScale * FT_MulFix(face->descender, face->size->metrics.y_scale);
//lineHeight = invSize * (FT_MulFix(face->height, face->size->metrics.y_scale) / 64.0f);
//lineHeight = invSize * math::ceil(FT_MulFix(face->height, face->size->metrics.y_scale) / 64.0f);
lineHeight = face->height / face->units_per_EM;
//lineHeight = invSize * face->size->metrics.height / 64.0f;
if (lineHeight<=0.0f) {
lineHeight = 1.25 * invSize * (face->bbox.yMax - face->bbox.yMin);
}
//! used to create the glyph textureatlas
CFontTextureRenderer texRenderer(outlineWidth, outlineWeight);
for (unsigned int i = charstart; i <= charend; i++) {
GlyphInfo* g = &glyphs[i];
//! translate WinLatin (codepage-1252) to Unicode (used by freetype)
int unicode = WinLatinToUnicode(i);
//! convert to an anti-aliased bitmap
error = FT_Load_Char(face, unicode, FT_LOAD_RENDER);
if ( error ) {
continue;
}
//.........这里部分代码省略.........
示例15: ReadInt
/// read an int from file (endian aware)
static int ReadInt(CFileHandler& file)
{
unsigned int __tmpdw = 0;
file.Read(&__tmpdw,sizeof(unsigned int));
return (int)swabDWord(__tmpdw);
}