# HG changeset patch # User Matti Hamalainen # Date 1412557367 -10800 # Node ID 4ef9dfbd82b69bc9f1f5fc9377fcf1c466305230 # Parent ad0f12582a39759ac6542bcf50a34436a26e2e9c Cosmetics. diff -r ad0f12582a39 -r 4ef9dfbd82b6 src/pic2img.cc --- a/src/pic2img.cc Mon Oct 06 01:54:21 2014 +0300 +++ b/src/pic2img.cc Mon Oct 06 04:02:47 2014 +0300 @@ -92,7 +92,7 @@ the image buffer where the top of the current column should be pasted. It can be off the image buffer! */ -// Locate the lump where the picture is + // Locate the lump where the picture is if (picloc.wad != 0) { MasterDirectory dirbuf; @@ -111,7 +111,7 @@ } } -// Read the picture header + // Read the picture header dir->wadfile->seek(dir->dir.start); if (dir->wadfile->error()) { @@ -149,7 +149,7 @@ } } -// If no buffer given by caller, allocate one. + // If no buffer given by caller, allocate one. if (img.is_null()) { // Sanity checks @@ -176,7 +176,7 @@ } int img_width = img.width(); -// Centre the picture. + // Centre the picture. if (pic_x_offset == INT_MIN) pic_x_offset = (img_width - pic_width_) / 2; if (pic_y_offset == INT_MIN) @@ -192,7 +192,7 @@ ColumnData = (u8 *) GetMemory(TEX_COLUMNBUFFERSIZE); /* FIXME DOS and pic_width_ > 16000 */ - NeededOffsets = (i32 *) GetMemory((long) pic_width_ * 4); + NeededOffsets = (i32 *) GetMemory((long) pic_width_ * sizeof(i32)); if (long_offsets) dir->wadfile->read_i32(NeededOffsets, pic_width_); @@ -212,7 +212,7 @@ return 1; } -// Read first column data, and subsequent column data + // Read first column data, and subsequent column data if (long_offsets && NeededOffsets[0] != 8 + (long) pic_width_ * 4 || !long_offsets && NeededOffsets[0] != 4 + (long) pic_width_ * 2) { @@ -226,11 +226,11 @@ return 1; } } - ActualBufLen = - dir->wadfile->read_vbytes(ColumnData, TEX_COLUMNBUFFERSIZE); -// FIXME should catch I/O errors -// Clip the picture horizontally and vertically + ActualBufLen = dir->wadfile->read_vbytes(ColumnData, TEX_COLUMNBUFFERSIZE); + // FIXME should catch I/O errors + + // Clip the picture horizontally and vertically pic_x0 = -pic_x_offset; if (pic_x0 < 0) pic_x0 = 0; @@ -247,10 +247,9 @@ if (pic_y1 >= pic_height_) pic_y1 = pic_height_ - 1; -// For each (non clipped) column of the picture... + // For each (non clipped) column of the picture... for (pic_x = pic_x0, - buf = - img.wbuf() + al_amax(pic_x_offset, 0) + img_width * pic_y_offset; + buf = img.wbuf() + al_amax(pic_x_offset, 0) + img_width * pic_y_offset; pic_x <= pic_x1; pic_x++, buf++) { u8 *filedata; @@ -259,6 +258,7 @@ ColumnInMemory = CurrentOffset >= NeededOffsets[0] && CurrentOffset + TEX_COLUMNSIZE <= NeededOffsets[0] + ActualBufLen; + if (ColumnInMemory) Column = ColumnData + CurrentOffset - NeededOffsets[0]; else diff -r ad0f12582a39 -r 4ef9dfbd82b6 src/wadfile.cc --- a/src/wadfile.cc Mon Oct 06 01:54:21 2014 +0300 +++ b/src/wadfile.cc Mon Oct 06 04:02:47 2014 +0300 @@ -67,8 +67,7 @@ const size_t total = name_len_max - strlen(ellipsis); const size_t left = total / 2; const size_t right = total - left; - sprintf(where_, "%*s%s%*s(%lXh)", - left, filename, ellipsis, right, filename + total, offset); + sprintf(where_, "%*s%s%*s(%lXh)", left, filename, ellipsis, right, filename + total, offset); } return where_; diff -r ad0f12582a39 -r 4ef9dfbd82b6 src/wadfile.h --- a/src/wadfile.h Mon Oct 06 01:54:21 2014 +0300 +++ b/src/wadfile.h Mon Oct 06 04:02:47 2014 +0300 @@ -89,6 +89,7 @@ /* Ugly but better than making the data members public. FIXME Many of these are friend just because they use fp for reading. */ + friend char *GetWadFileName(const char *); friend int SaveLevelData(const char *, const char *); friend int OpenMainWad(const char *); @@ -99,7 +100,9 @@ friend void SaveEntryToRawFile(FILE *, const char *); friend void ListFileDirectory(FILE *, const Wad_file *); - public:Wad_file() + public: + + Wad_file() { filename = NULL; fp = NULL; diff -r ad0f12582a39 -r 4ef9dfbd82b6 src/wads2.cc --- a/src/wads2.cc Mon Oct 06 01:54:21 2014 +0300 +++ b/src/wads2.cc Mon Oct 06 04:02:47 2014 +0300 @@ -442,14 +442,13 @@ } } -// Create a new Wad_file - Wad_file *wf = new Wad_file; + // Create a new Wad_file + Wad_file *wf = new Wad_file(); wf->pic_format_ = pic_format; wf->directory = 0; - wf->filename = (char *) GetMemory(strlen(filename) + 1); - strcpy(wf->filename, filename); + wf->filename = strdup(filename); -// Open the wad and read its header. + // Open the wad and read its header. wf->fp = fopen(filename, "rb"); if (wf->fp == 0) { @@ -471,9 +470,8 @@ verbmsg(" Type %.4s, directory has %ld entries at offset %08lXh\n", wf->type, (long) wf->dirsize, (long) wf->dirstart); -// Load the directory of the wad - wf->directory = (DirPtr) GetMemory((long) sizeof(struct Directory) - * wf->dirsize); + // Load the directory of the wad + wf->directory = (DirPtr) GetMemory((long) sizeof(struct Directory) * wf->dirsize); if (fseek(wf->fp, wf->dirstart, SEEK_SET) != 0) { printf("%.128s: can't seek to directory at %08lXh\n", @@ -495,7 +493,7 @@ } } -// Insert the new wad in the list + // Insert the new wad in the list wad_list.insert(wf); byebye: