From 4780ab9223293243fdeadbda490eeea25aba2072 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 29 Jan 2006 02:27:10 +0000 Subject: Patch #1417631: "gobliiins cleanup". Thanks, wjp. svn-id: r20283 --- gob/cdrom.cpp | 4 ++-- gob/dataio.cpp | 20 +++++++++--------- gob/draw.cpp | 2 +- gob/draw.h | 4 ++-- gob/game.cpp | 41 ++++++++++++++++++++---------------- gob/game.h | 34 +++++++++++++++--------------- gob/global.cpp | 4 ---- gob/global.h | 6 +----- gob/gob.h | 4 ++-- gob/goblin.cpp | 6 +++--- gob/goblin.h | 12 +++++------ gob/init.cpp | 25 +++++++++------------- gob/map.cpp | 9 ++++---- gob/map.h | 8 +++---- gob/mult.cpp | 65 ++++++++++++++++++++++++++++----------------------------- gob/mult.h | 33 ++++++++++++++--------------- gob/pack.cpp | 6 +++--- gob/palanim.cpp | 6 +----- gob/scenery.cpp | 36 ++++++++++++++------------------ gob/scenery.h | 24 ++++++++++----------- gob/sound.cpp | 10 ++++----- gob/sound.h | 4 ++-- gob/util.cpp | 19 ++++++++--------- gob/util.h | 8 +++---- gob/video.cpp | 51 ++++++++++++++++++++------------------------ gob/video.h | 20 +++++++++--------- 26 files changed, 217 insertions(+), 244 deletions(-) diff --git a/gob/cdrom.cpp b/gob/cdrom.cpp index e33ec130e6..69c92f7038 100644 --- a/gob/cdrom.cpp +++ b/gob/cdrom.cpp @@ -86,14 +86,14 @@ void CDROM::readLIC(const char *fname) { _vm->_dataio->seekData(handle, pos, SEEK_CUR); } - _LICbuffer = (byte *)malloc(_numTracks * 22); + _LICbuffer = new byte[_numTracks * 22]; _vm->_dataio->readData(handle, (char *)_LICbuffer, _numTracks * 22); _vm->_dataio->closeData(handle); } void CDROM::freeLICbuffer(void) { - free(_LICbuffer); + delete[] _LICbuffer; _LICbuffer = 0; } diff --git a/gob/dataio.cpp b/gob/dataio.cpp index 71be0e83e4..222e7cd84b 100644 --- a/gob/dataio.cpp +++ b/gob/dataio.cpp @@ -185,7 +185,7 @@ void DataIO::openDataFile(const char *src) { char path[128]; int16 i; int16 file; - struct ChunkDesc *dataDesc; + ChunkDesc *dataDesc; strcpy(path, src); for (i = 0; path[i] != '.' && path[i] != 0; i++); @@ -207,9 +207,8 @@ void DataIO::openDataFile(const char *src) { debug(7, "DataChunks: %d [for %s]", _vm->_global->_numDataChunks[file], path); - _vm->_global->_dataFiles[file] = dataDesc = - (struct ChunkDesc *)malloc(sizeof(struct ChunkDesc) * - _vm->_global->_numDataChunks[file]); + dataDesc = new ChunkDesc[_vm->_global->_numDataChunks[file]]; + _vm->_global->_dataFiles[file] = dataDesc; for (i = 0; i < _vm->_global->_numDataChunks[file]; i++) { file_getHandle(_vm->_global->_dataFileHandles[file])->read(dataDesc[i].chunkName, 13); @@ -230,7 +229,7 @@ void DataIO::closeDataFile() { int16 file; for (file = MAX_DATA_FILES - 1; file >= 0; file--) { if (_vm->_global->_dataFiles[file] != 0) { - free(_vm->_global->_dataFiles[file]); + delete[] _vm->_global->_dataFiles[file]; _vm->_global->_dataFiles[file] = 0; file_getHandle(_vm->_global->_dataFileHandles[file])->close(); return; @@ -254,13 +253,13 @@ char *DataIO::getUnpackedData(const char *name) { if (chunk == -1) return 0; - unpackBuf = (char *)malloc(realSize); + unpackBuf = new char[realSize]; if (unpackBuf == 0) return 0; - packBuf = (char *)malloc(_vm->_global->_packedSize); + packBuf = new char[_vm->_global->_packedSize]; if (packBuf == 0) { - free(unpackBuf); + delete[] unpackBuf; return 0; } @@ -274,7 +273,8 @@ char *DataIO::getUnpackedData(const char *name) { readChunk(chunk, ptr, sizeLeft); freeChunk(chunk); _vm->_pack->unpackData(packBuf, unpackBuf); - free(packBuf); + + delete[] packBuf; return unpackBuf; } @@ -346,7 +346,7 @@ char *DataIO::getData(const char *path) { return data; size = getDataSize(path); - data = (char *)malloc(size); + data = new char[size]; if (data == 0) return 0; diff --git a/gob/draw.cpp b/gob/draw.cpp index e0d3178ebc..3cfc999f3c 100644 --- a/gob/draw.cpp +++ b/gob/draw.cpp @@ -417,7 +417,7 @@ void Draw::spriteOperation(int16 operation) { _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1); } - free(dataBuf); + delete[] dataBuf; break; } // Load from .TOT resources diff --git a/gob/draw.h b/gob/draw.h index 06a9fb44b3..de8ca65df4 100644 --- a/gob/draw.h +++ b/gob/draw.h @@ -33,13 +33,13 @@ namespace Gob { class Draw { public: - typedef struct FontToSprite { + struct FontToSprite { int8 sprite; int8 base; int8 width; int8 height; FontToSprite() : sprite(0), base(0), width(0), height() {} - } FontToSprite; + }; int16 _fontIndex; int16 _spriteLeft; diff --git a/gob/game.cpp b/gob/game.cpp index 8f5afe43c5..05c13b8429 100644 --- a/gob/game.cpp +++ b/gob/game.cpp @@ -141,10 +141,11 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { debug(7, "off: %ld size: %ld", offset, tableSize); _vm->_dataio->seekData(handle, offset + tableSize, SEEK_SET); + // CHECKME: is the below correct? if (isPacked) - dataBuf = (char *)malloc(size); + dataBuf = new char[size]; else - dataBuf = (char *)malloc(size); + dataBuf = new char[size]; dataPtr = dataBuf; while (size > 32000) { @@ -161,9 +162,9 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { if (isPacked != 0) { packedBuf = dataBuf; - dataBuf = (char *)malloc(READ_LE_UINT32(packedBuf)); + dataBuf = new char[READ_LE_UINT32(packedBuf)]; _vm->_pack->unpackData(packedBuf, dataBuf); - free(packedBuf); + delete[] packedBuf; } return dataBuf; @@ -229,7 +230,7 @@ void Game::pushCollisions(char all) { size++; } - destPtr = (Collision *)malloc(size * sizeof(Collision)); + destPtr = new Collision[size]; _collStack[_collStackSize] = destPtr; _collStackElemSizes[_collStackSize] = size; _collStackSize++; @@ -392,7 +393,7 @@ char *Game::loadTotResource(int16 id) { void Game::loadSound(int16 slot, char *dataPtr) { Snd::SoundDesc *soundDesc; - soundDesc = (Snd::SoundDesc *)malloc(sizeof(Snd::SoundDesc)); + soundDesc = new Snd::SoundDesc; _soundSamples[slot] = soundDesc; @@ -437,11 +438,11 @@ void Game::freeSoundSlot(int16 slot) { return; if (_soundFromExt[slot] == 1) { - free(_soundSamples[slot]->data - 6); + delete[] (_soundSamples[slot]->data - 6); _soundFromExt[slot] = 0; } - free(_soundSamples[slot]); + delete _soundSamples[slot]; _soundSamples[slot] = 0; } @@ -1687,8 +1688,10 @@ void Game::loadExtTable(void) { count = FROM_LE_16(count); _vm->_dataio->seekData(_extHandle, 0, 0); - _extTable = (ExtTable *)malloc(sizeof(ExtTable) - + sizeof(ExtItem) * count); + _extTable = new ExtTable; + _extTable->items = 0; + if (count) + _extTable->items = new ExtItem[count]; _vm->_dataio->readData(_extHandle, (char *)&_extTable->itemsCount, 2); _extTable->itemsCount = FROM_LE_16(_extTable->itemsCount); @@ -1855,7 +1858,7 @@ void Game::playTot(int16 skipPlay) { _vm->_global->_inter_animDataSize = READ_LE_UINT16((char *)_totFileData + 0x38); if (_vm->_global->_inter_variables == 0) { variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c); - _vm->_global->_inter_variables = (char *)malloc(variablesCount * 4); + _vm->_global->_inter_variables = new char[variablesCount * 4]; for (i = 0; i < variablesCount; i++) WRITE_VAR(i, 0); } @@ -1877,21 +1880,23 @@ void Game::playTot(int16 skipPlay) { variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c); _vm->_draw->blitInvalidated(); - free(_totFileData); + delete[] _totFileData; _totFileData = 0; if (needTextFree) - free(_totTextData); + delete[] _totTextData; _totTextData = 0; if (needFreeResTable) - free(_totResourceTable); + delete[] _totResourceTable; _totResourceTable = 0; - free(_imFileData); + delete[] _imFileData; _imFileData = 0; - free(_extTable); + if (_extTable) + delete[] _extTable->items; + delete _extTable; _extTable = 0; if (_extHandle >= 0) @@ -1931,11 +1936,11 @@ void Game::playTot(int16 skipPlay) { } void Game::start(void) { - _collisionAreas = (Collision *)malloc(250 * sizeof(Collision)); + _collisionAreas = new Collision[250]; prepareStart(); playTot(0); - free(_collisionAreas); + delete[] _collisionAreas; _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack); diff --git a/gob/game.h b/gob/game.h index f97c5ef73f..4186b82983 100644 --- a/gob/game.h +++ b/gob/game.h @@ -31,7 +31,7 @@ public: #pragma START_PACK_STRUCTS #define szGame_TotResItem (4 + 2 + 2 + 2) - typedef struct Collision { + struct Collision { int16 id; int16 left; int16 top; @@ -41,56 +41,56 @@ public: int16 key; int16 funcEnter; int16 funcLeave; - } GCC_PACK Collision; + } GCC_PACK; - typedef struct TotResItem { + struct TotResItem { int32 offset; // if > 0, then offset from end of resource table. // If < 0, then -offset-1 is index in .IM file table int16 size; int16 width; int16 height; - } GCC_PACK TotResItem; + } GCC_PACK; #define szGame_TotResTable (2 + 1) - typedef struct TotResTable { + struct TotResTable { int16 itemsCount; byte unknown; TotResItem items[1]; - } GCC_PACK TotResTable; + } GCC_PACK; #define szGame_ExtItem (4 + 2 + 2 + 2) - typedef struct ExtItem { + struct ExtItem { int32 offset; // offset from the table end uint16 size; int16 width; // width&0x7fff - width, width&0x8000 - pack flag int16 height; // not zero - } GCC_PACK ExtItem; + } GCC_PACK; #define szGame_ExtTable (2 + 1) - typedef struct ExtTable { + struct ExtTable { int16 itemsCount; byte unknown; - ExtItem items[1]; - } GCC_PACK ExtTable; + ExtItem* items; + } GCC_PACK; #define szGame_TotTextItem (2 + 2) - typedef struct TotTextItem { + struct TotTextItem { int16 offset; int16 size; - } GCC_PACK TotTextItem; + } GCC_PACK; #define szGame_TotTextTable (2) - typedef struct TotTextTable { + struct TotTextTable { int16 itemsCount; TotTextItem items[1]; - } GCC_PACK TotTextTable; + } GCC_PACK; - typedef struct InputDesc { + struct InputDesc { int16 fontIndex; int16 backColor; int16 frontColor; char *ptr; - } GCC_PACK InputDesc; + } GCC_PACK; #pragma END_PACK_STRUCTS TotResTable *_totResourceTable; diff --git a/gob/global.cpp b/gob/global.cpp index 220f417cb1..084400d535 100644 --- a/gob/global.cpp +++ b/gob/global.cpp @@ -88,8 +88,6 @@ Global::Global(GobEngine *vm) : _vm(vm) { _oldMode = 3; _dontSetPalette = 0; - _curPrimaryDesc = 0; - _allocatedPrimary = 0; _pPrimarySurfDesc = 0; _pPaletteDesc = 0; @@ -146,8 +144,6 @@ Global::Global(GobEngine *vm) : _vm(vm) { _inter_mouseX = 0; _inter_mouseY = 0; - - _tmpPalBuffer = 0; } } // End of namespace Gob diff --git a/gob/global.h b/gob/global.h index 995850e234..65535be982 100644 --- a/gob/global.h +++ b/gob/global.h @@ -134,9 +134,7 @@ public: int16 _setAllPalette; - Video::SurfaceDesc *_curPrimaryDesc; - Video::SurfaceDesc *_allocatedPrimary; - Video::SurfaceDesc_t _primarySurfDesc; + Video::SurfaceDesc _primarySurfDesc; Video::SurfaceDesc *_pPrimarySurfDesc; int16 _oldMode; @@ -163,8 +161,6 @@ public: int16 _inter_mouseX; int16 _inter_mouseY; - char *_tmpPalBuffer; - Global(GobEngine *vm); protected: diff --git a/gob/gob.h b/gob/gob.h index 6a9de445f8..8691e68f5f 100644 --- a/gob/gob.h +++ b/gob/gob.h @@ -73,7 +73,7 @@ enum { GF_MAC = 1 << 5 }; -typedef struct GobGameSettings { +struct GobGameSettings { const char *gameid; const char *description; uint32 features; @@ -82,7 +82,7 @@ typedef struct GobGameSettings { GameSettings dummy = { gameid, description, features }; return dummy; } -} GobGameSettings; +}; class GobEngine : public Engine { void errorString(const char *buf_input, char *buf_output); diff --git a/gob/goblin.cpp b/gob/goblin.cpp index b41147fe25..3b5d1e49e3 100644 --- a/gob/goblin.cpp +++ b/gob/goblin.cpp @@ -177,7 +177,7 @@ int16 Goblin::peekGoblin(Gob_Object *_curGob) { } void Goblin::initList(void) { - _objList = (Util::List *) malloc(sizeof(Util::List)); + _objList = new Util::List; _objList->pHead = 0; _objList->pTail = 0; } @@ -1848,7 +1848,7 @@ void Goblin::freeObjects(void) { } delete[] _goblins[i]->stateMach; - free(_goblins[i]); + delete _goblins[i]; _goblins[i] = 0; } @@ -1866,7 +1866,7 @@ void Goblin::freeObjects(void) { } delete[] _objects[i]->stateMach; - free(_objects[i]); + delete _objects[i]; _objects[i] = 0; } } diff --git a/gob/goblin.h b/gob/goblin.h index 1093cfccfe..a482b8c2bb 100644 --- a/gob/goblin.h +++ b/gob/goblin.h @@ -34,7 +34,7 @@ namespace Gob { class Goblin { public: #pragma START_PACK_STRUCTS - typedef struct Gob_State { + struct Gob_State { int16 animation;// +0h int16 layer; // +2h int16 unk0; // +4h @@ -43,13 +43,13 @@ public: int16 freq; // +Ah, high/low byte * 100 - frequency int16 repCount; // +Ch high/low byte - repeat count int16 sndFrame; // +Eh - } GCC_PACK Gob_State; + } GCC_PACK; typedef Gob_State *Gob_PState; typedef Gob_PState Gob_StateLine[6]; - typedef struct Gob_Object { + struct Gob_Object { int16 animation; // +0h int16 state; // +2h int16 stateColumn; // +4h @@ -82,12 +82,12 @@ public: char multObjIndex; // +37h, from which play mult animations char unk14; // +38h char visible; // +39h - } GCC_PACK Gob_Object; + } GCC_PACK; - typedef struct Gob_Pos { + struct Gob_Pos { char x; char y; - } GCC_PACK Gob_Pos; + } GCC_PACK; #pragma END_PACK_STRUCTS Util::List *_objList; diff --git a/gob/init.cpp b/gob/init.cpp index ff96bc8430..c95f92d193 100644 --- a/gob/init.cpp +++ b/gob/init.cpp @@ -104,13 +104,9 @@ void Init::cleanup(void) { _vm->_gtimer->disableTimer(); _vm->_video->freeDriver(); - if (_vm->_global->_curPrimaryDesc != 0) { - _vm->_video->freeSurfDesc(_vm->_global->_curPrimaryDesc); - _vm->_video->freeSurfDesc(_vm->_global->_allocatedPrimary); - _vm->_global->_allocatedPrimary = 0; - _vm->_global->_curPrimaryDesc = 0; - } + _vm->_video->freeSurfDesc(_vm->_global->_pPrimarySurfDesc); _vm->_global->_pPrimarySurfDesc = 0; + if (_vm->_snd->_cleanupFunc != 0 && _vm->_snd->_playingSound != 0) { (*_vm->_snd->_cleanupFunc) (0); _vm->_snd->_cleanupFunc = 0; @@ -172,7 +168,7 @@ memBlocks = word ptr -2*/ _vm->_game->_totFileData = 0; _vm->_game->_totResourceTable = 0; _vm->_global->_inter_variables = 0; - _palDesc = (Video::PalDesc *)malloc(12); + _palDesc = new Video::PalDesc; if (_vm->_global->_videoMode != 0x13) error("initGame: Only 0x13 video mode is supported!"); @@ -224,8 +220,7 @@ memBlocks = word ptr -2*/ if (infPtr == infEnd) break; } - - free(infBuf); + delete[] infBuf; } if (totName != 0) { @@ -244,7 +239,7 @@ memBlocks = word ptr -2*/ varsCount = FROM_LE_32(varsCount); _vm->_dataio->closeData(handle); - _vm->_global->_inter_variables = (char *)malloc(varsCount * 4); + _vm->_global->_inter_variables = new char[varsCount * 4]; memset(_vm->_global->_inter_variables, 0, varsCount * 4); strcpy(_vm->_game->_curTotFile, buffer); @@ -256,10 +251,10 @@ memBlocks = word ptr -2*/ _vm->_cdrom->stopPlaying(); _vm->_cdrom->freeLICbuffer(); - free(_vm->_global->_inter_variables); - free(_vm->_game->_totFileData); - free(_vm->_game->_totTextData); - free(_vm->_game->_totResourceTable); + delete[] _vm->_global->_inter_variables; + delete[] _vm->_game->_totFileData; + delete[] _vm->_game->_totTextData; + delete[] _vm->_game->_totResourceTable; } for (i = 0; i < 4; i++) { @@ -267,7 +262,7 @@ memBlocks = word ptr -2*/ _vm->_util->freeFont(_vm->_draw->_fonts[i]); } - free(_palDesc); + delete _palDesc; _vm->_dataio->closeDataFile(); _vm->_video->initPrimary(-1); cleanup(); diff --git a/gob/map.cpp b/gob/map.cpp index d564c0fab9..9c6668ad9d 100644 --- a/gob/map.cpp +++ b/gob/map.cpp @@ -512,7 +512,7 @@ void Map::loadMapObjects(char *avjFile) { _vm->_goblin->_gobsCount = loadFromAvo_LE_UINT16(); for (i = 0; i < _vm->_goblin->_gobsCount; i++) { - _vm->_goblin->_goblins[i] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); + _vm->_goblin->_goblins[i] = new Goblin::Gob_Object; _vm->_goblin->_goblins[i]->xPos = READ_LE_UINT16(savedPtr2); savedPtr2 += 2; @@ -620,8 +620,7 @@ void Map::loadMapObjects(char *avjFile) { _vm->_goblin->_objCount = loadFromAvo_LE_UINT16(); for (i = 0; i < _vm->_goblin->_objCount; i++) { - _vm->_goblin->_objects[i] = - (Goblin::Gob_Object *) malloc(sizeof(Goblin::Gob_Object)); + _vm->_goblin->_objects[i] = new Goblin::Gob_Object; _vm->_goblin->_objects[i]->xPos = READ_LE_UINT16(savedPtr3); savedPtr3 += 2; @@ -681,7 +680,7 @@ void Map::loadMapObjects(char *avjFile) { delete[] tempstatedata; } - _vm->_goblin->_objects[10] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); + _vm->_goblin->_objects[10] = new Goblin::Gob_Object; memset(_vm->_goblin->_objects[10], 0, sizeof(Goblin::Gob_Object)); _vm->_goblin->_objects[10]->stateMach = new Goblin::Gob_StateLine[40]; @@ -728,7 +727,7 @@ void Map::loadMapObjects(char *avjFile) { strcpy(sndNames[i], buf); } - free(dataBuf); + delete[] dataBuf; _vm->_goblin->_soundData[14] = _vm->_snd->loadSoundData("diamant1.snd"); diff --git a/gob/map.h b/gob/map.h index d7666540c5..6f1c5fe09d 100644 --- a/gob/map.h +++ b/gob/map.h @@ -45,18 +45,18 @@ public: #pragma START_PACK_STRUCTS - typedef struct Point { + struct Point { int16 x; int16 y; - } GCC_PACK Point; + } GCC_PACK; #define szMap_ItemPos 3 - typedef struct ItemPos { + struct ItemPos { int8 x; int8 y; int8 orient; // ?? - } GCC_PACK ItemPos; + } GCC_PACK; #pragma END_PACK_STRUCTS diff --git a/gob/mult.cpp b/gob/mult.cpp index 71fa2ef137..8aafcc6c47 100644 --- a/gob/mult.cpp +++ b/gob/mult.cpp @@ -437,8 +437,8 @@ void Mult::interInitMult(void) { animDataVar = _vm->_parse->parseVarIndex(); if (_objects == 0) { - _renderData = (int16 *)malloc(sizeof(int16) * _objCount * 9); - _objects = (Mult_Object *)malloc(sizeof(Mult_Object) * _objCount); + _renderData = new int16[_objCount * 9]; + _objects = new Mult_Object[_objCount]; for (i = 0; i < _objCount; i++) { _objects[i].pPosX = (int32 *)(_vm->_global->_inter_variables + i * 4 + (posXVar / 4) * 4); @@ -487,8 +487,8 @@ void Mult::freeMult(void) { if (_vm->_anim->_animSurf != 0) _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); - free(_objects); - free(_renderData); + delete[] _objects; + delete[] _renderData; _objects = 0; _renderData = 0; @@ -860,13 +860,13 @@ void Mult::playMult(int16 startFrame, int16 endFrame, char checkEscape, _vm->_anim->_areaHeight = 200; _objCount = 4; - _objects = (Mult_Object *)malloc(sizeof(Mult_Object) * _objCount); - _renderData = (int16 *)malloc(sizeof(int16) * 9 * _objCount); + _objects = new Mult_Object[_objCount]; + _renderData = new int16[9 * _objCount]; - _animArrayX = (int32 *)malloc(sizeof(int32) * _objCount); - _animArrayY = (int32 *)malloc(sizeof(int32) * _objCount); + _animArrayX = new int32[_objCount]; + _animArrayY = new int32[_objCount]; - _animArrayData = (Mult_AnimData *)malloc(sizeof(Mult_AnimData) * _objCount); + _animArrayData = new Mult_AnimData[_objCount]; for (_counter = 0; _counter < _objCount; _counter++) { multObj = &_objects[_counter]; @@ -940,19 +940,19 @@ void Mult::playMult(int16 startFrame, int16 endFrame, char checkEscape, if (stopNoClear == 0) { if (_animDataAllocated) { - free(_objects); + delete[] _objects; _objects = 0; - free(_renderData); + delete[] _renderData; _renderData = 0; - free(_animArrayX); + delete[] _animArrayX; _animArrayX = 0; - free(_animArrayY); + delete[] _animArrayY; _animArrayY = 0; - free(_animArrayData); + delete[] _animArrayData; _animArrayData = 0; if (_vm->_anim->_animSurf) @@ -1020,8 +1020,7 @@ void Mult::loadMult(int16 resId) { _staticKeysCount = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _staticKeys = (Mult_StaticKey *)malloc(sizeof(Mult_StaticKey) * - _staticKeysCount); + _staticKeys = new Mult_StaticKey[_staticKeysCount]; for (i = 0; i < _staticKeysCount; i++, _dataPtr += 4) { _staticKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr); _staticKeys[i].layer = (int16)READ_LE_UINT16(_dataPtr + 2); @@ -1031,7 +1030,7 @@ void Mult::loadMult(int16 resId) { _animKeysCount[j] = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _animKeys[j] = (Mult_AnimKey *) malloc(sizeof(Mult_AnimKey) * _animKeysCount[j]); + _animKeys[j] = new Mult_AnimKey[_animKeysCount[j]]; for (i = 0; i < _animKeysCount[j]; i++, _dataPtr += 10) { _animKeys[j][i].frame = (int16)READ_LE_UINT16(_dataPtr); _animKeys[j][i].layer = (int16)READ_LE_UINT16(_dataPtr + 2); @@ -1052,7 +1051,7 @@ void Mult::loadMult(int16 resId) { _palFadeKeysCount = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _palFadeKeys = (Mult_PalFadeKey *)malloc(sizeof(Mult_PalFadeKey) * _palFadeKeysCount); + _palFadeKeys = new Mult_PalFadeKey[_palFadeKeysCount]; for (i = 0; i < _palFadeKeysCount; i++, _dataPtr += 7) { _palFadeKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr); @@ -1064,7 +1063,7 @@ void Mult::loadMult(int16 resId) { _palKeysCount = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _palKeys = (Mult_PalKey *)malloc(sizeof(Mult_PalKey) * _palKeysCount); + _palKeys = new Mult_PalKey[_palKeysCount]; for (i = 0; i < _palKeysCount; i++, _dataPtr += 80) { _palKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr); _palKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2); @@ -1079,7 +1078,7 @@ void Mult::loadMult(int16 resId) { _textKeysCount = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _textKeys = (Mult_TextKey *) malloc(sizeof(Mult_TextKey) * _textKeysCount); + _textKeys = new Mult_TextKey[_textKeysCount]; for (i = 0; i < _textKeysCount; i++, _dataPtr += 28) { _textKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr); @@ -1094,7 +1093,7 @@ void Mult::loadMult(int16 resId) { _sndKeysCount = READ_LE_UINT16(_dataPtr); _dataPtr += 2; - _sndKeys = (Mult_SndKey *)malloc(sizeof(Mult_SndKey) * _sndKeysCount); + _sndKeys = new Mult_SndKey[_sndKeysCount]; for (i = 0; i < _sndKeysCount; i++) { _sndKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr); _sndKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2); @@ -1149,7 +1148,7 @@ void Mult::freeMultKeys(void) { staticCount = _dataPtr[0]; animCount = _dataPtr[1]; - free(_dataPtr); + delete[] _dataPtr; staticCount++; animCount++; @@ -1164,37 +1163,37 @@ void Mult::freeMultKeys(void) { _vm->_scenery->freeAnim(_animIndices[i]); } - free(_staticKeys); + delete[] _staticKeys; for (i = 0; i < 4; i++) - free(_animKeys[i]); + delete[] _animKeys[i]; - free(_palFadeKeys); - free(_palKeys); - free(_textKeys); + delete[] _palFadeKeys; + delete[] _palKeys; + delete[] _textKeys; for (i = 0; i < _sndSlotsCount; i++) { _vm->_game->freeSoundSlot(19 - i); } - free(_sndKeys); + delete[] _sndKeys; _multData = 0; if (_animDataAllocated != 0) { - free(_objects); + delete[] _objects; _objects = 0; - free(_renderData); + delete[] _renderData; _renderData = 0; - free(_animArrayX); + delete[] _animArrayX; _animArrayX = 0; - free(_animArrayY); + delete[] _animArrayY; _animArrayY = 0; - free(_animArrayData); + delete[] _animArrayData; _animArrayData = 0; if (_vm->_anim->_animSurf) diff --git a/gob/mult.h b/gob/mult.h index 6cd8e67660..6006e167d1 100644 --- a/gob/mult.h +++ b/gob/mult.h @@ -29,7 +29,7 @@ namespace Gob { class Mult { public: #pragma START_PACK_STRUCTS - typedef struct Mult_AnimData { + struct Mult_AnimData { int8 animation; int8 layer; int8 frame; @@ -43,9 +43,9 @@ public: int8 newAnimation; byte intersected; int8 newCycle; - } GCC_PACK Mult_AnimData; + } GCC_PACK; - typedef struct Mult_Object { + struct Mult_Object { int32 *pPosX; int32 *pPosY; Mult_AnimData *pAnimData; @@ -54,47 +54,46 @@ public: int16 lastRight; int16 lastTop; int16 lastBottom; - } Mult_Object; + }; - // Mult - typedef struct Mult_StaticKey { + struct Mult_StaticKey { int16 frame; int16 layer; - } GCC_PACK Mult_StaticKey; + } GCC_PACK; - typedef struct Mult_AnimKey { + struct Mult_AnimKey { int16 frame; int16 layer; int16 posX; int16 posY; int16 order; - } GCC_PACK Mult_AnimKey; + } GCC_PACK; - typedef struct Mult_TextKey { + struct Mult_TextKey { int16 frame; int16 cmd; int16 unknown0[9]; int16 index; int16 unknown1[2]; - } GCC_PACK Mult_TextKey; + } GCC_PACK; - typedef struct Mult_PalKey { + struct Mult_PalKey { int16 frame; int16 cmd; int16 rates[4]; int16 unknown0; int16 unknown1; int8 subst[16][4]; - } GCC_PACK Mult_PalKey; + } GCC_PACK; - typedef struct Mult_PalFadeKey { + struct Mult_PalFadeKey { int16 frame; int16 fade; int16 palIndex; int8 flag; - } GCC_PACK Mult_PalFadeKey; + } GCC_PACK; - typedef struct Mult_SndKey { + struct Mult_SndKey { int16 frame; int16 cmd; int16 freq; @@ -102,7 +101,7 @@ public: int16 repCount; int16 resId; int16 soundIndex; - } GCC_PACK Mult_SndKey; + } GCC_PACK; #pragma END_PACK_STRUCTS // Globals diff --git a/gob/pack.cpp b/gob/pack.cpp index 546618f08c..4728a599bf 100644 --- a/gob/pack.cpp +++ b/gob/pack.cpp @@ -40,7 +40,7 @@ int32 Pack::unpackData(char *sourceBuf, char *destBuf) { realSize = READ_LE_UINT32(sourceBuf); counter = READ_LE_UINT32(sourceBuf); - tmpBuf = (byte *)malloc(4114); + tmpBuf = new byte[4114]; /* * Can use assembler unpacker for small blocks - for speed. @@ -91,7 +91,7 @@ int32 Pack::unpackData(char *sourceBuf, char *destBuf) { *dest++ = tmpBuf[(off + i) % 4096]; counter--; if (counter == 0) { - free(tmpBuf); + delete[] tmpBuf; return realSize; } tmpBuf[tmpIndex] = tmpBuf[(off + i) % 4096]; @@ -100,7 +100,7 @@ int32 Pack::unpackData(char *sourceBuf, char *destBuf) { } } } - free(tmpBuf); + delete[] tmpBuf; return realSize; } diff --git a/gob/palanim.cpp b/gob/palanim.cpp index 35a888337c..e1ec7f4dad 100644 --- a/gob/palanim.cpp +++ b/gob/palanim.cpp @@ -186,8 +186,7 @@ void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) { if (allColors == 0) { do { - if (_vm->_global->_tmpPalBuffer == 0) - _vm->_video->waitRetrace(_vm->_global->_videoMode); + _vm->_video->waitRetrace(_vm->_global->_videoMode); stop = fadeStep(0); @@ -222,9 +221,6 @@ void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) { else _vm->_util->clearPalette(); } - - free(_vm->_global->_tmpPalBuffer); - _vm->_global->_tmpPalBuffer = 0; } } // End of namespace Gob diff --git a/gob/scenery.cpp b/gob/scenery.cpp index 63037f9fe5..69ad9264d2 100644 --- a/gob/scenery.cpp +++ b/gob/scenery.cpp @@ -116,9 +116,9 @@ int16 Scenery::loadStatic(char search) { ptr->layersCount = (int16)READ_LE_UINT16(dataPtr); dataPtr += 2; - ptr->layers = (StaticLayer **)malloc(sizeof(StaticLayer *) * ptr->layersCount); - ptr->pieces = (PieceDesc **)malloc(sizeof(PieceDesc *) * picsCount); - ptr->piecesFromExt = (int8 *)malloc(picsCount); + ptr->layers = new StaticLayer*[ptr->layersCount]; + ptr->pieces = new PieceDesc*[picsCount]; + ptr->piecesFromExt = new int8[picsCount]; for (i = 0; i < ptr->layersCount; i++) { offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]); @@ -196,7 +196,7 @@ void Scenery::freeStatic(int16 index) { for (i = 0; i < _staticPictCount[index]; i++) { if (_statics[index].piecesFromExt[i] == 1) - free(_statics[index].pieces[i]); + delete[] _statics[index].pieces[i]; spr = _staticPictToSprite[index * 7 + i]; _spriteRefs[spr]--; @@ -207,11 +207,11 @@ void Scenery::freeStatic(int16 index) { } } - free(_statics[index].layers); - free(_statics[index].pieces); - free(_statics[index].piecesFromExt); + delete[] _statics[index].layers; + delete[] _statics[index].pieces; + delete[] _statics[index].piecesFromExt; if (_staticFromExt[index] == 1) - free(_statics[index].dataPtr); + delete[] _statics[index].dataPtr; _staticFromExt[index] = 0; _staticPictCount[index] = -1; @@ -433,13 +433,9 @@ int16 Scenery::loadAnim(char search) { ptr->layersCount = READ_LE_UINT16(dataPtr); dataPtr += 2; - ptr->layers = - (AnimLayer **) malloc(sizeof(AnimLayer *) * - ptr->layersCount); - ptr->pieces = - (PieceDesc **) malloc(sizeof(PieceDesc *) * - picsCount); - ptr->piecesFromExt = (int8 *) malloc(picsCount); + ptr->layers = new AnimLayer*[ptr->layersCount]; + ptr->pieces = new PieceDesc*[picsCount]; + ptr->piecesFromExt = new int8[picsCount]; for (i = 0; i < ptr->layersCount; i++) { offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]); @@ -718,7 +714,7 @@ void Scenery::freeAnim(int16 animation) { for (i = 0; i < _animPictCount[animation]; i++) { if (_animations[animation].piecesFromExt[i] == 1) - free(_animations[animation].pieces[i]); + delete[] _animations[animation].pieces[i]; spr = _animPictToSprite[animation * 7 + i]; _spriteRefs[spr]--; @@ -730,11 +726,11 @@ void Scenery::freeAnim(int16 animation) { } } - free(_animations[animation].layers); - free(_animations[animation].pieces); - free(_animations[animation].piecesFromExt); + delete[] _animations[animation].layers; + delete[] _animations[animation].pieces; + delete[] _animations[animation].piecesFromExt; if (_animFromExt[animation] == 1) - free(_animations[animation].dataPtr); + delete[] _animations[animation].dataPtr; _animFromExt[animation] = 0; _animPictCount[animation] = 0; diff --git a/gob/scenery.h b/gob/scenery.h index 805b46a72c..cf47855a32 100644 --- a/gob/scenery.h +++ b/gob/scenery.h @@ -27,39 +27,39 @@ namespace Gob { class Scenery { public: #pragma START_PACK_STRUCTS - typedef struct PieceDesc { + struct PieceDesc { int16 left; //NOTE: int16 right; //These are stored in Little Endian format int16 top; //And should be converted by client code when accessed int16 bottom; //i.e. use FROM_LE_16() - } GCC_PACK PieceDesc; + } GCC_PACK; - typedef struct StaticPlane { + struct StaticPlane { int8 pictIndex; int8 pieceIndex; int8 drawOrder; int16 destX; int16 destY; int8 transp; - } GCC_PACK StaticPlane; + } GCC_PACK; - typedef struct StaticLayer { + struct StaticLayer { int16 backResId; int16 planeCount; StaticPlane planes[1]; - } GCC_PACK StaticLayer; + } GCC_PACK; // Animations - typedef struct AnimFramePiece { + struct AnimFramePiece { byte pictIndex; byte pieceIndex; int8 destX; int8 destY; int8 notFinal; - } GCC_PACK AnimFramePiece; + } GCC_PACK; - typedef struct AnimLayer { + struct AnimLayer { int16 unknown0; int16 posX; int16 posY; @@ -68,10 +68,10 @@ public: int8 transp; int16 framesCount; AnimFramePiece frames[1]; - } GCC_PACK AnimLayer; + } GCC_PACK; #pragma END_PACK_STRUCTS - typedef struct Static { + struct Static { int16 layersCount; StaticLayer **layers; PieceDesc **pieces; @@ -79,7 +79,7 @@ public: char *dataPtr; Static() : layersCount(0), layers(0), pieces(0), piecesFromExt(0), dataPtr(0) {} - } Static; + }; struct Animation { int16 layersCount; diff --git a/gob/sound.cpp b/gob/sound.cpp index b109fae7fa..0321e08052 100644 --- a/gob/sound.cpp +++ b/gob/sound.cpp @@ -118,11 +118,9 @@ void Snd::writeAdlib(int16 port, int16 data) { Snd::SoundDesc *Snd::loadSoundData(const char *path) { Snd::SoundDesc *sndDesc; - int32 size; - size = _vm->_dataio->getDataSize(path); - sndDesc = (Snd::SoundDesc *)malloc(size); - sndDesc->size = size; + sndDesc = new Snd::SoundDesc; + sndDesc->size = _vm->_dataio->getDataSize(path); sndDesc->data = _vm->_dataio->getData(path); return sndDesc; @@ -136,8 +134,8 @@ void Snd::freeSoundData(Snd::SoundDesc *sndDesc) { _loopingSounds[i] = NULL; } - free(sndDesc->data); - free(sndDesc); + delete[] sndDesc->data; + delete sndDesc; } } // End of namespace Gob diff --git a/gob/sound.h b/gob/sound.h index db0507ca18..088b40ef73 100644 --- a/gob/sound.h +++ b/gob/sound.h @@ -28,7 +28,7 @@ namespace Gob { class Snd { public: - typedef struct SoundDesc { + struct SoundDesc { Audio::SoundHandle handle; char *data; int32 size; @@ -39,7 +39,7 @@ public: int16 flag; SoundDesc() : data(0), size(0), repCount(0), timerTicks(0), inClocks(0), frequency(0), flag(0) {} - } SoundDesc; + }; typedef void (*CleanupFuncPtr) (int16); diff --git a/gob/util.cpp b/gob/util.cpp index 601ffe6c47..139cd24688 100644 --- a/gob/util.cpp +++ b/gob/util.cpp @@ -271,7 +271,7 @@ int16 joy_calibrate() { } Video::FontDesc *Util::loadFont(const char *path) { - Video::FontDesc *fontDesc = (Video::FontDesc *) malloc(sizeof(Video::FontDesc)); + Video::FontDesc *fontDesc = new Video::FontDesc; char *data; if (fontDesc == 0) @@ -279,7 +279,7 @@ Video::FontDesc *Util::loadFont(const char *path) { data = _vm->_dataio->getData(path); if (data == 0) { - free(fontDesc); + delete fontDesc; return 0; } @@ -303,8 +303,8 @@ Video::FontDesc *Util::loadFont(const char *path) { } void Util::freeFont(Video::FontDesc * fontDesc) { - free(fontDesc->dataPtr - 4); - free(fontDesc); + delete[] (fontDesc->dataPtr - 4); + delete fontDesc; } void Util::clearPalette(void) { @@ -390,7 +390,7 @@ int16 Util::strstr(const char *str1, char *str2) { void Util::listInsertFront(List * list, void *data) { ListNode *node; - node = (ListNode *) malloc(sizeof(ListNode)); + node = new ListNode; if (list->pHead != 0) { node->pData = data; node->pNext = list->pHead; @@ -415,8 +415,7 @@ void Util::listInsertBack(List * list, void *data) { warning("listInsertBack: Broken list!"); } - node = - (ListNode *) malloc(sizeof(ListNode)); + node = new ListNode; node->pData = data; node->pPrev = list->pTail; node->pNext = 0; @@ -429,12 +428,12 @@ void Util::listInsertBack(List * list, void *data) { void Util::listDropFront(List * list) { if (list->pHead->pNext == 0) { - free((list->pHead)); + delete list->pHead; list->pHead = 0; list->pTail = 0; } else { list->pHead = list->pHead->pNext; - free((list->pHead->pPrev)); + delete list->pHead->pPrev; list->pHead->pPrev = 0; } } @@ -444,7 +443,7 @@ void Util::deleteList(List * list) { listDropFront(list); } - free(list); + delete list; } const char Util::trStr1[] = diff --git a/gob/util.h b/gob/util.h index 1a970e0f2f..4b859b0c9c 100644 --- a/gob/util.h +++ b/gob/util.h @@ -31,18 +31,18 @@ namespace Gob { class Util { public: struct ListNode; - typedef struct ListNode { + struct ListNode { void *pData; struct ListNode *pNext; struct ListNode *pPrev; ListNode() : pData(0), pNext(0), pPrev(0) {} - } ListNode; + }; - typedef struct List { + struct List { ListNode *pHead; ListNode *pTail; List() : pHead(0), pTail(0) {} - } List; + }; void initInput(void); void processInput(void); diff --git a/gob/video.cpp b/gob/video.cpp index 201f55fa9d..e2f071a9ef 100644 --- a/gob/video.cpp +++ b/gob/video.cpp @@ -85,7 +85,7 @@ int32 Video::getRectSize(int16 width, int16 height, int16 flag, int16 mode) { Video::SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags) { int8 flagsAnd2; - byte *vidMem; + byte *vidMem = 0; int32 sprSize; int16 someFlags = 1; SurfaceDesc *descPtr; @@ -108,27 +108,31 @@ Video::SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height flagsAnd2 = 0; if (flags & PRIMARY_SURFACE) { - vidMem = 0; _vm->_global->_primaryWidth = width; _vm->_global->_mouseMaxCol = width; _vm->_global->_primaryHeight = height; _vm->_global->_mouseMaxRow = height; sprSize = 0; - } else { - vidMem = 0; sprSize = Video::getRectSize(width, height, flagsAnd2, vidMode); if (flagsAnd2) someFlags += 0x80; } if (flags & PRIMARY_SURFACE) { descPtr = _vm->_global->_pPrimarySurfDesc; - vidMem = (byte *)malloc(320 * 200); + delete[] descPtr->vidPtr; + assert(descPtr); + vidMem = new byte[320 * 200]; } else { - if (flags & DISABLE_SPR_ALLOC) - descPtr = (SurfaceDesc *)malloc(sizeof(SurfaceDesc)); - else - descPtr = (SurfaceDesc *)malloc(sizeof(SurfaceDesc) + sprSize); + if (flags & DISABLE_SPR_ALLOC) { + descPtr = new SurfaceDesc; + // this case causes vidPtr to be set to invalid memory + assert(false); + } else { + descPtr = new SurfaceDesc; + descPtr->vidPtr = new byte[sprSize]; + vidMem = descPtr->vidPtr; + } } if (descPtr == 0) return 0; @@ -137,8 +141,6 @@ Video::SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height descPtr->height = height; descPtr->flag = someFlags; descPtr->vidMode = vidMode; - if (vidMem == 0) - vidMem = ((byte *)descPtr) + sizeof(SurfaceDesc); descPtr->vidPtr = vidMem; descPtr->reserved1 = 0; @@ -147,11 +149,11 @@ Video::SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height } void Video::freeSurfDesc(SurfaceDesc * surfDesc) { - _vm->_global->_sprAllocated--; - if (surfDesc != _vm->_global->_pPrimarySurfDesc) - free(surfDesc); - else - free(surfDesc->vidPtr); + delete[] surfDesc->vidPtr; + if (surfDesc != _vm->_global->_pPrimarySurfDesc) { + _vm->_global->_sprAllocated--; + delete surfDesc; + } } int16 Video::clampValue(int16 val, int16 max) { @@ -302,7 +304,7 @@ void Video::drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, i return; if ((dest->vidMode & 0x7f) != 0x13) - error("Video::drawPackedSprite: Vide mode 0x%x is not fully supported!", + error("Video::drawPackedSprite: Video mode 0x%x is not fully supported!", dest->vidMode & 0x7f); _videoDriver->drawPackedSprite(sprBuf, width, height, x, y, transp, dest); @@ -378,13 +380,6 @@ void Video::setFullPalette(PalDesc *palDesc) { void Video::initPrimary(int16 mode) { int16 old; - if (_vm->_global->_curPrimaryDesc) { - Video::freeSurfDesc(_vm->_global->_curPrimaryDesc); - Video::freeSurfDesc(_vm->_global->_allocatedPrimary); - - _vm->_global->_curPrimaryDesc = 0; - _vm->_global->_allocatedPrimary = 0; - } if (mode != 0x13 && mode != 3 && mode != -1) error("Video::initPrimary: Video mode 0x%x is not supported!", mode); @@ -450,7 +445,7 @@ char Video::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, srcHeight - 1, x, y, transp); return 1; } else { - memBuffer = (byte *)malloc(4114); + memBuffer = new byte[4114]; if (memBuffer == 0) return 0; @@ -520,13 +515,13 @@ char Video::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, destPtr = linePtr; curHeight++; if (curHeight >= srcHeight) { - free(memBuffer); + delete[] memBuffer; return 1; } } sourceLeft--; if (sourceLeft == 0) { - free(memBuffer); + delete[] memBuffer; return 1; } memBuffer[bufPos] = temp; @@ -536,7 +531,7 @@ char Video::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, } } } - free(memBuffer); + delete[] memBuffer; return 1; } diff --git a/gob/video.h b/gob/video.h index 92b5c3b585..55a10b3f38 100644 --- a/gob/video.h +++ b/gob/video.h @@ -40,7 +40,7 @@ extern int16 setAllPalette; class Video { public: - typedef struct SurfaceDesc_t { + struct SurfaceDesc { int16 width; int16 height; int8 reserved1; @@ -48,11 +48,11 @@ public: int16 vidMode; byte *vidPtr; int16 reserved2; - SurfaceDesc_t() : width(0), height(0), reserved1(0), flag(0), + SurfaceDesc() : width(0), height(0), reserved1(0), flag(0), vidMode(0), vidPtr(0), reserved2(0) {} - } SurfaceDesc; + }; - typedef struct FontDesc_t { + struct FontDesc { char *dataPtr; int8 itemWidth; int8 itemHeight; @@ -61,9 +61,9 @@ public: int8 itemSize; int8 bitWidth; void *extraData; - FontDesc_t() : dataPtr(0), itemWidth(0), itemHeight(0), startItem(0), + FontDesc() : dataPtr(0), itemWidth(0), itemHeight(0), startItem(0), endItem(0), itemSize(0), bitWidth(0) {} - } FontDesc; + }; #define GDR_VERSION 4 @@ -73,20 +73,20 @@ public: #pragma START_PACK_STRUCTS - typedef struct Color { + struct Color { byte red; byte green; byte blue; - } GCC_PACK Color; + } GCC_PACK; #pragma END_PACK_STRUCTS - typedef struct PalDesc { + struct PalDesc { Color *vgaPal; int16 *unused1; int16 *unused2; PalDesc() : vgaPal(0), unused1(0), unused2(0) {} - } PalDesc; + }; Video(class GobEngine *vm); int32 getRectSize(int16 width, int16 height, int16 flag, int16 mode); -- cgit v1.2.3