diff options
-rw-r--r-- | sword2/anims.cpp | 6 | ||||
-rw-r--r-- | sword2/build_display.cpp | 22 | ||||
-rw-r--r-- | sword2/console.cpp | 16 | ||||
-rw-r--r-- | sword2/controls.cpp | 24 | ||||
-rw-r--r-- | sword2/debug.cpp | 2 | ||||
-rw-r--r-- | sword2/driver/_mouse.cpp | 16 | ||||
-rw-r--r-- | sword2/driver/animation.cpp | 6 | ||||
-rw-r--r-- | sword2/driver/d_sound.cpp | 8 | ||||
-rw-r--r-- | sword2/driver/menu.cpp | 2 | ||||
-rw-r--r-- | sword2/driver/palette.cpp | 2 | ||||
-rw-r--r-- | sword2/driver/render.cpp | 10 | ||||
-rw-r--r-- | sword2/driver/sprite.cpp | 12 | ||||
-rw-r--r-- | sword2/function.cpp | 186 | ||||
-rw-r--r-- | sword2/icons.cpp | 2 | ||||
-rw-r--r-- | sword2/interpreter.cpp | 14 | ||||
-rw-r--r-- | sword2/interpreter.h | 2 | ||||
-rw-r--r-- | sword2/layers.cpp | 2 | ||||
-rw-r--r-- | sword2/logic.cpp | 16 | ||||
-rw-r--r-- | sword2/maketext.cpp | 22 | ||||
-rw-r--r-- | sword2/memory.cpp | 8 | ||||
-rw-r--r-- | sword2/protocol.cpp | 52 | ||||
-rw-r--r-- | sword2/resman.cpp | 50 | ||||
-rw-r--r-- | sword2/router.cpp | 10 | ||||
-rw-r--r-- | sword2/save_rest.cpp | 20 | ||||
-rw-r--r-- | sword2/sound.cpp | 2 | ||||
-rw-r--r-- | sword2/speech.cpp | 6 | ||||
-rw-r--r-- | sword2/startup.cpp | 6 | ||||
-rw-r--r-- | sword2/sword2.cpp | 6 | ||||
-rw-r--r-- | sword2/walker.cpp | 8 |
29 files changed, 269 insertions, 269 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp index c60a5a3e06..f9ca218dcc 100644 --- a/sword2/anims.cpp +++ b/sword2/anims.cpp @@ -64,7 +64,7 @@ int Router::doAnimate(ObjectLogic *ob_logic, ObjectGraphic *ob_graphic, int32 an return IR_STOP; } - head = (StandardHeader *) _vm->_resman->openResource(animRes); + head = (StandardHeader *)_vm->_resman->openResource(animRes); // if it's not an animation file if (head->fileType != ANIMATION_FILE) { @@ -88,7 +88,7 @@ int Router::doAnimate(ObjectLogic *ob_logic, ObjectGraphic *ob_graphic, int32 an // open anim file anim_file = _vm->_resman->openResource(animRes); - head = (StandardHeader *) anim_file; + head = (StandardHeader *)anim_file; assert(head->fileType == ANIMATION_FILE); // point to anim header @@ -251,7 +251,7 @@ void Logic::createSequenceSpeech(MovieTextObject *sequenceText[]) { // now fill out the SpriteInfo structure in the // MovieTextObjectStructure - frame = (FrameHeader *) _sequenceTextList[line].text_mem; + frame = (FrameHeader *)_sequenceTextList[line].text_mem; sequenceText[line]->textSprite = new SpriteInfo; diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp index 397b4e9eda..af8fcf0093 100644 --- a/sword2/build_display.cpp +++ b/sword2/build_display.cpp @@ -52,11 +52,11 @@ Screen::Screen(Sword2Engine *vm, int16 width, int16 height) { if ((width % CELLWIDE) || (height % CELLDEEP)) error("Bad cell size"); - _dirtyGrid = (byte *) calloc(_gridWide, _gridDeep); + _dirtyGrid = (byte *)calloc(_gridWide, _gridDeep); if (!_dirtyGrid) error("Could not initialise dirty grid"); - _buffer = (byte *) malloc(width * height); + _buffer = (byte *)malloc(width * height); if (!_buffer) error("Could not initialise display"); @@ -116,7 +116,7 @@ void Screen::buildDisplay() { startRenderCycle(); byte *file = _vm->_resman->openResource(_thisScreen.background_layer_id); - MultiScreenHeader *screenLayerTable = (MultiScreenHeader *) (file + sizeof(StandardHeader)); + MultiScreenHeader *screenLayerTable = (MultiScreenHeader *)(file + sizeof(StandardHeader)); // Render at least one frame, but if the screen is scrolling, and if // there is time left, we will render extra frames to smooth out the @@ -199,7 +199,7 @@ void Screen::displayMsg(byte *text, int time) { clearScene(); byte *text_spr = _vm->_fontRenderer->makeTextSprite(text, 640, 187, _vm->_speechFontId); - FrameHeader *frame = (FrameHeader *) text_spr; + FrameHeader *frame = (FrameHeader *)text_spr; SpriteInfo spriteInfo; @@ -404,7 +404,7 @@ void Screen::processImage(BuildUnit *build_unit) { spriteType |= RDSPR_RLE16; // points to just after last cdt_entry, ie. // start of colour table - colTablePtr = (byte *) (anim_head + 1) + anim_head->noAnimFrames * sizeof(CdtEntry); + colTablePtr = (byte *)(anim_head + 1) + anim_head->noAnimFrames * sizeof(CdtEntry); break; } } @@ -426,7 +426,7 @@ void Screen::processImage(BuildUnit *build_unit) { spriteInfo.type = spriteType; spriteInfo.blend = anim_head->blend; // points to just after frame header, ie. start of sprite data - spriteInfo.data = (byte *) (frame_head + 1); + spriteInfo.data = (byte *)(frame_head + 1); spriteInfo.colourTable = colTablePtr; // check for largest layer for debug info @@ -719,7 +719,7 @@ void Screen::rollCredits() { palette[i * 4 + 3] = 0; } - logoData = (byte *) malloc(logoWidth * logoHeight); + logoData = (byte *)malloc(logoWidth * logoHeight); f.read(logoData, logoWidth * logoHeight); f.close(); @@ -890,10 +890,10 @@ void Screen::rollCredits() { if (!creditsLines[i].sprite) { debug(2, "Creating sprite '%s'", creditsLines[i].str); - creditsLines[i].sprite = _vm->_fontRenderer->makeTextSprite((byte *) creditsLines[i].str, 600, 14, _vm->_speechFontId, 0); + creditsLines[i].sprite = _vm->_fontRenderer->makeTextSprite((byte *)creditsLines[i].str, 600, 14, _vm->_speechFontId, 0); } - FrameHeader *frame = (FrameHeader *) creditsLines[i].sprite; + FrameHeader *frame = (FrameHeader *)creditsLines[i].sprite; spriteInfo.y = creditsLines[i].top - scrollPos; spriteInfo.w = frame->width; @@ -1020,7 +1020,7 @@ void Screen::splashScreen() { barSprite.type = RDSPR_RLE256FAST | RDSPR_TRANS; barSprite.blend = 0; barSprite.colourTable = 0; - barSprite.data = (byte *) (frame + 1); + barSprite.data = (byte *)(frame + 1); drawSprite(&barSprite); @@ -1029,7 +1029,7 @@ void Screen::splashScreen() { for (int i = 0; i < animHead->noAnimFrames; i++) { frame = _vm->fetchFrameHeader(loadingBar, i); - barSprite.data = (byte *) (frame + 1); + barSprite.data = (byte *)(frame + 1); drawSprite(&barSprite); updateDisplay(); _vm->_system->delayMillis(30); diff --git a/sword2/console.cpp b/sword2/console.cpp index 01329eaf1f..f09d268731 100644 --- a/sword2/console.cpp +++ b/sword2/console.cpp @@ -180,8 +180,8 @@ bool Debugger::Cmd_Help(int argc, const char **argv) { } static int compare_blocks(const void *p1, const void *p2) { - const MemBlock *m1 = *(const MemBlock * const *) p1; - const MemBlock *m2 = *(const MemBlock * const *) p2; + const MemBlock *m1 = *(const MemBlock * const *)p1; + const MemBlock *m2 = *(const MemBlock * const *)p2; if (m1->size < m2->size) return 1; @@ -194,7 +194,7 @@ bool Debugger::Cmd_Mem(int argc, const char **argv) { int16 numBlocks = _vm->_memory->getNumBlocks(); MemBlock *memBlocks = _vm->_memory->getMemBlocks(); - MemBlock **blocks = (MemBlock **) malloc(numBlocks * sizeof(MemBlock)); + MemBlock **blocks = (MemBlock **)malloc(numBlocks * sizeof(MemBlock)); int i, j; @@ -209,7 +209,7 @@ bool Debugger::Cmd_Mem(int argc, const char **argv) { DebugPrintf("---------------------------------------------------------------------------\n"); for (i = 0; i < numBlocks; i++) { - StandardHeader *head = (StandardHeader *) blocks[i]->ptr; + StandardHeader *head = (StandardHeader *)blocks[i]->ptr; const char *type; switch (head->fileType) { @@ -320,7 +320,7 @@ bool Debugger::Cmd_ResList(int argc, const char **argv) { for (uint i = 0; i < numResFiles; i++) { if (resList[i].ptr && resList[i].refCount >= minCount) { - StandardHeader *head = (StandardHeader *) resList[i].ptr; + StandardHeader *head = (StandardHeader *)resList[i].ptr; DebugPrintf("%-4d: %-35s refCount: %-3d\n", i, head->name, resList[i].refCount); } } @@ -445,7 +445,7 @@ bool Debugger::Cmd_ResLook(int argc, const char **argv) { } // Open up the resource and take a look inside! - StandardHeader *file_header = (StandardHeader *) _vm->_resman->openResource(res); + StandardHeader *file_header = (StandardHeader *)_vm->_resman->openResource(res); switch (file_header->fileType) { case ANIMATION_FILE: @@ -512,12 +512,12 @@ bool Debugger::Cmd_RunList(int argc, const char **argv) { uint32 runList = _vm->_logic->getRunList(); if (runList) { - game_object_list = (uint32 *) (_vm->_resman->openResource(runList) + sizeof(StandardHeader)); + game_object_list = (uint32 *)(_vm->_resman->openResource(runList) + sizeof(StandardHeader)); DebugPrintf("Runlist number %d\n", runList); for (int i = 0; game_object_list[i]; i++) { - file_header = (StandardHeader *) _vm->_resman->openResource(game_object_list[i]); + file_header = (StandardHeader *)_vm->_resman->openResource(game_object_list[i]); DebugPrintf("%d %s\n", game_object_list[i], file_header->name); _vm->_resman->closeResource(game_object_list[i]); } diff --git a/sword2/controls.cpp b/sword2/controls.cpp index 39a3bca8a7..ac43e8f87c 100644 --- a/sword2/controls.cpp +++ b/sword2/controls.cpp @@ -145,8 +145,8 @@ FontRendererGui::FontRendererGui(Sword2Engine *vm, int fontId) sprite.type = RDSPR_NOCOMPRESSION | RDSPR_TRANS; for (int i = 0; i < SIZE_OF_CHAR_SET; i++) { - head = (FrameHeader *) _vm->fetchFrameHeader(font, i); - sprite.data = (byte *) (head + 1); + head = (FrameHeader *)_vm->fetchFrameHeader(font, i); + sprite.data = (byte *)(head + 1); sprite.w = head->width; sprite.h = head->height; _vm->_screen->createSurface(&sprite, &_glyph[i]._data); @@ -399,8 +399,8 @@ int Dialog::runModal() { Widget::Widget(Dialog *parent, int states) : _vm(parent->_vm), _parent(parent), _numStates(states), _state(0) { - _sprites = (SpriteInfo *) calloc(states, sizeof(SpriteInfo)); - _surfaces = (WidgetSurface *) calloc(states, sizeof(WidgetSurface)); + _sprites = (SpriteInfo *)calloc(states, sizeof(SpriteInfo)); + _surfaces = (WidgetSurface *)calloc(states, sizeof(WidgetSurface)); _hitRect.left = _hitRect.right = _hitRect.top = _hitRect.bottom = -1; } @@ -447,7 +447,7 @@ void Widget::createSurfaceImage(int state, uint32 res, int x, int y, uint32 pc) spriteType |= RDSPR_RLE256; // Points to just after last cdt_entry, i.e. start of colour // table - colTablePtr = (byte *) (anim_head + 1) + + colTablePtr = (byte *)(anim_head + 1) + anim_head->noAnimFrames * sizeof(CdtEntry); break; } @@ -461,7 +461,7 @@ void Widget::createSurfaceImage(int state, uint32 res, int x, int y, uint32 pc) _sprites[state].blend = anim_head->blend; // Points to just after frame header, ie. start of sprite data - _sprites[state].data = (byte *) (frame_head + 1); + _sprites[state].data = (byte *)(frame_head + 1); _vm->_screen->createSurface(&_sprites[state], &_surfaces[state]._surface); _surfaces[state]._original = true; @@ -1074,9 +1074,9 @@ public: void setText(FontRendererGui *fr, int slot, byte *text) { _fr = fr; if (text) - sprintf((char *) _text, "%d. %s", slot, text); + sprintf((char *)_text, "%d. %s", slot, text); else - sprintf((char *) _text, "%d. ", slot); + sprintf((char *)_text, "%d. ", slot); } byte *getText() { @@ -1285,7 +1285,7 @@ void SaveRestoreDialog::onAction(Widget *widget, int result) { } else if (widget == _cancelButton) { setResult(0); } else { - Slot *slot = (Slot *) widget; + Slot *slot = (Slot *)widget; int textWidth; byte tmp; int i; @@ -1322,8 +1322,8 @@ void SaveRestoreDialog::onAction(Widget *widget, int result) { else _firstPos = 4; - strcpy((char *) _editBuffer, (char *) slot->getText()); - _editPos = strlen((char *) _editBuffer); + strcpy((char *)_editBuffer, (char *)slot->getText()); + _editPos = strlen((char *)_editBuffer); _cursorTick = 0; _editBuffer[_editPos] = '_'; _editBuffer[_editPos + 1] = 0; @@ -1400,7 +1400,7 @@ int SaveRestoreDialog::runModal() { if (result) { switch (_mode) { case kSaveDialog: - if (_vm->saveGame(_selectedSlot, (byte *) &_editBuffer[_firstPos]) != SR_OK) + if (_vm->saveGame(_selectedSlot, (byte *)&_editBuffer[_firstPos]) != SR_OK) result = 0; break; case kRestoreDialog: diff --git a/sword2/debug.cpp b/sword2/debug.cpp index 11090c3960..cc4745bc46 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -53,7 +53,7 @@ void Debugger::makeDebugTextBlock(char *text, int16 x, int16 y) { assert(blockNo < MAX_DEBUG_TEXTS); - _debugTextBlocks[blockNo] = _vm->_fontRenderer->buildNewBloc((byte *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); + _debugTextBlocks[blockNo] = _vm->_fontRenderer->buildNewBloc((byte *)text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); } void Debugger::buildDebugText() { diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp index 3842434942..7e04c20aba 100644 --- a/sword2/driver/_mouse.cpp +++ b/sword2/driver/_mouse.cpp @@ -122,7 +122,7 @@ void Mouse::drawMouse() { memset(mouseData, 0, mouse_width * mouse_height); if (_luggageAnim) - decompressMouse(mouseData, (byte *) _luggageAnim + READ_LE_UINT32(_luggageOffset), _luggageAnim->mousew, + decompressMouse(mouseData, (byte *)_luggageAnim + READ_LE_UINT32(_luggageOffset), _luggageAnim->mousew, _luggageAnim->mouseh, mouse_width, deltaX, deltaY); if (_mouseAnim) @@ -144,7 +144,7 @@ int32 Mouse::animateMouse() { if (++_mouseFrame == _mouseAnim->noAnimFrames) _mouseFrame = MOUSEFLASHFRAME; - _mouseSprite = (byte *) _mouseAnim + READ_LE_UINT32(_mouseOffsets + _mouseFrame); + _mouseSprite = (byte *)_mouseAnim + READ_LE_UINT32(_mouseOffsets + _mouseFrame); if (_mouseFrame != prevMouseFrame) drawMouse(); @@ -172,12 +172,12 @@ int32 Mouse::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) { else _mouseFrame = MOUSEFLASHFRAME; - _mouseAnim = (MouseAnim *) malloc(size); + _mouseAnim = (MouseAnim *)malloc(size); if (!_mouseAnim) return RDERR_OUTOFMEMORY; - memcpy((byte *) _mouseAnim, ma, size); - _mouseOffsets = (int32 *) ((byte *) _mouseAnim + sizeof(MouseAnim)); + memcpy((byte *)_mouseAnim, ma, size); + _mouseOffsets = (int32 *)((byte *)_mouseAnim + sizeof(MouseAnim)); animateMouse(); drawMouse(); @@ -207,12 +207,12 @@ int32 Mouse::setLuggageAnim(byte *ma, int32 size) { } if (ma) { - _luggageAnim = (MouseAnim *) malloc(size); + _luggageAnim = (MouseAnim *)malloc(size); if (!_luggageAnim) return RDERR_OUTOFMEMORY; - memcpy((byte *) _luggageAnim, ma, size); - _luggageOffset = (int32 *) ((byte *) _luggageAnim + sizeof(MouseAnim)); + memcpy((byte *)_luggageAnim, ma, size); + _luggageOffset = (int32 *)((byte *)_luggageAnim + sizeof(MouseAnim)); animateMouse(); drawMouse(); diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp index 8e3e8958b6..65ac6a9583 100644 --- a/sword2/driver/animation.cpp +++ b/sword2/driver/animation.cpp @@ -177,7 +177,7 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea if (leadInRes) { byte *leadIn = _vm->_resman->openResource(leadInRes); uint32 leadInLen = _vm->_resman->fetchLen(leadInRes) - sizeof(StandardHeader); - StandardHeader *header = (StandardHeader *) leadIn; + StandardHeader *header = (StandardHeader *)leadIn; assert(header->fileType == WAV_FILE); @@ -192,7 +192,7 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea if (leadOutRes) { leadOut = _vm->_resman->openResource(leadOutRes); leadOutLen = _vm->_resman->fetchLen(leadOutRes) - sizeof(StandardHeader); - StandardHeader *header = (StandardHeader *) leadOut; + StandardHeader *header = (StandardHeader *)leadOut; assert(header->fileType == WAV_FILE); @@ -420,7 +420,7 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte data = _vm->_fontRenderer->makeTextSprite(msg, RENDERWIDE, 255, _vm->_speechFontId); } - FrameHeader *frame = (FrameHeader *) data; + FrameHeader *frame = (FrameHeader *)data; SpriteInfo msgSprite; byte *msgSurface; diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 33699972ef..d936a43941 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -423,9 +423,9 @@ int Sound::readBuffer(int16 *buffer, const int numSamples) { if (!_mixBuffer || numSamples > _mixBufferLen) { if (_mixBuffer) - _mixBuffer = (int16 *) realloc(_mixBuffer, 2 * numSamples); + _mixBuffer = (int16 *)realloc(_mixBuffer, 2 * numSamples); else - _mixBuffer = (int16 *) malloc(2 * numSamples); + _mixBuffer = (int16 *)malloc(2 * numSamples); _mixBufferLen = numSamples; } @@ -724,14 +724,14 @@ uint32 Sound::preFetchCompSpeech(uint32 speechId, uint16 **buf) { uint32 bufferSize = 2 * numSamples; - *buf = (uint16 *) malloc(bufferSize); + *buf = (uint16 *)malloc(bufferSize); if (!*buf) { delete input; fh->file->close(); return 0; } - uint32 readSamples = input->readBuffer((int16 *) *buf, numSamples); + uint32 readSamples = input->readBuffer((int16 *)*buf, numSamples); fh->file->close(); delete input; diff --git a/sword2/driver/menu.cpp b/sword2/driver/menu.cpp index 698090c517..065b2cf99b 100644 --- a/sword2/driver/menu.cpp +++ b/sword2/driver/menu.cpp @@ -278,7 +278,7 @@ int32 Mouse::setMenuIcon(uint8 menu, uint8 pocket, byte *icon) { // Only put the icon in the pocket if it is not NULL if (icon != NULL) { _iconCount++; - _icons[menu][pocket] = (byte *) malloc(RDMENU_ICONWIDE * RDMENU_ICONDEEP); + _icons[menu][pocket] = (byte *)malloc(RDMENU_ICONWIDE * RDMENU_ICONDEEP); if (_icons[menu][pocket] == NULL) return RDERR_OUTOFMEMORY; memcpy(_icons[menu][pocket], icon, RDMENU_ICONWIDE * RDMENU_ICONDEEP); diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp index 60f99253ad..adea1a8dfb 100644 --- a/sword2/driver/palette.cpp +++ b/sword2/driver/palette.cpp @@ -88,7 +88,7 @@ void Screen::setFullPalette(int32 palRes) { if (palRes) { byte *pal = _vm->_resman->openResource(palRes); - StandardHeader *head = (StandardHeader *) pal; + StandardHeader *head = (StandardHeader *)pal; assert(head->fileType == PALETTE_FILE); pal += sizeof(StandardHeader); diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp index dfee05f6b3..1b41f58f13 100644 --- a/sword2/driver/render.cpp +++ b/sword2/driver/render.cpp @@ -213,7 +213,7 @@ void Screen::plotPoint(int x, int y, uint8 colour) { } static void plot(int x, int y, int colour, void *data) { - Screen *screen = (Screen *) data; + Screen *screen = (Screen *)data; screen->plotPoint(x, y, (uint8) colour); } @@ -427,13 +427,13 @@ int32 Screen::initialiseBackgroundLayer(Parallax *p) { _xBlocks[_layer] = (p->w + BLOCKWIDTH - 1) / BLOCKWIDTH; _yBlocks[_layer] = (p->h + BLOCKHEIGHT - 1) / BLOCKHEIGHT; - _blockSurfaces[_layer] = (BlockSurface **) calloc(_xBlocks[_layer] * _yBlocks[_layer], sizeof(BlockSurface *)); + _blockSurfaces[_layer] = (BlockSurface **)calloc(_xBlocks[_layer] * _yBlocks[_layer], sizeof(BlockSurface *)); if (!_blockSurfaces[_layer]) return RDERR_OUTOFMEMORY; // Decode the parallax layer into a large chunk of memory - byte *memchunk = (byte *) calloc(_xBlocks[_layer] * _yBlocks[_layer], BLOCKWIDTH * BLOCKHEIGHT); + byte *memchunk = (byte *)calloc(_xBlocks[_layer] * _yBlocks[_layer], BLOCKWIDTH * BLOCKHEIGHT); if (!memchunk) return RDERR_OUTOFMEMORY; @@ -441,7 +441,7 @@ int32 Screen::initialiseBackgroundLayer(Parallax *p) { if (!p->offset[i]) continue; - byte *pLine = (byte *) p + FROM_LE_32(p->offset[i]); + byte *pLine = (byte *)p + FROM_LE_32(p->offset[i]); uint16 packets = READ_LE_UINT16(pLine); uint16 offset = READ_LE_UINT16(pLine + 2); @@ -503,7 +503,7 @@ int32 Screen::initialiseBackgroundLayer(Parallax *p) { // Only assign a surface to the block if it contains data. if (block_has_data) { - _blockSurfaces[_layer][i] = (BlockSurface *) malloc(sizeof(BlockSurface)); + _blockSurfaces[_layer][i] = (BlockSurface *)malloc(sizeof(BlockSurface)); // Copy the data into the surfaces. dst = _blockSurfaces[_layer][i]->data; diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp index f12ebb716b..a52faef3b9 100644 --- a/sword2/driver/sprite.cpp +++ b/sword2/driver/sprite.cpp @@ -247,7 +247,7 @@ int32 Screen::decompressRLE16(byte *dst, byte *src, int32 decompSize, byte *colT */ int32 Screen::createSurface(SpriteInfo *s, byte **sprite) { - *sprite = (byte *) malloc(s->w * s->h); + *sprite = (byte *)malloc(s->w * s->h); if (!*sprite) return RDERR_OUTOFMEMORY; @@ -371,7 +371,7 @@ int32 Screen::drawSprite(SpriteInfo *s) { if (s->type & RDSPR_NOCOMPRESSION) sprite = s->data; else { - sprite = (byte *) malloc(s->w * s->h); + sprite = (byte *)malloc(s->w * s->h); freeSprite = true; if (!sprite) return RDERR_OUTOFMEMORY; @@ -389,7 +389,7 @@ int32 Screen::drawSprite(SpriteInfo *s) { } if (s->type & RDSPR_FLIP) { - newSprite = (byte *) malloc(s->w * s->h); + newSprite = (byte *)malloc(s->w * s->h); if (newSprite == NULL) { if (freeSprite) free(sprite); @@ -482,7 +482,7 @@ int32 Screen::drawSprite(SpriteInfo *s) { return RDERR_NOTIMPLEMENTED; } - newSprite = (byte *) malloc(s->scaledWidth * s->scaledHeight); + newSprite = (byte *)malloc(s->scaledWidth * s->scaledHeight); if (newSprite == NULL) { if (freeSprite) free(sprite); @@ -516,7 +516,7 @@ int32 Screen::drawSprite(SpriteInfo *s) { // RDSPR_NOCOMPRESSION case. if (!freeSprite) { - newSprite = (byte *) malloc(s->w * s->h); + newSprite = (byte *)malloc(s->w * s->h); memcpy(newSprite, sprite, s->w * s->h); sprite = newSprite; freeSprite = true; @@ -624,7 +624,7 @@ int32 Screen::openLightMask(SpriteInfo *s) { if (_lightMask) return RDERR_NOTCLOSED; - _lightMask = (byte *) malloc(s->w * s->h); + _lightMask = (byte *)malloc(s->w * s->h); if (!_lightMask) return RDERR_OUTOFMEMORY; diff --git a/sword2/function.cpp b/sword2/function.cpp index eb10e46557..5344ea32e4 100644 --- a/sword2/function.cpp +++ b/sword2/function.cpp @@ -52,7 +52,7 @@ int32 Logic::fnRegisterStartPoint(int32 *params) { // 1 pointer to ascii message int32 key = params[0]; - char *name = (char *) decodePtr(params[1]); + char *name = (char *)decodePtr(params[1]); _vm->registerStartPoint(key, name); return IR_CONT; @@ -81,19 +81,19 @@ int32 Logic::fnSetSession(int32 *params) { int32 Logic::fnBackSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), BACK_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), BACK_SPRITE); return IR_CONT; } int32 Logic::fnSortSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), SORT_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), SORT_SPRITE); return IR_CONT; } int32 Logic::fnForeSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), FORE_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), FORE_SPRITE); return IR_CONT; } @@ -106,7 +106,7 @@ int32 Logic::fnRegisterMouse(int32 *params) { // params: 0 pointer to ObjectMouse or 0 for no write to mouse // list - _vm->_mouse->registerMouse((ObjectMouse *) decodePtr(params[0]), NULL); + _vm->_mouse->registerMouse((ObjectMouse *)decodePtr(params[0]), NULL); return IR_CONT; } @@ -117,8 +117,8 @@ int32 Logic::fnAnim(int32 *params) { // Normal forward animation return _router->doAnimate( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), params[2], false); } @@ -198,10 +198,10 @@ int32 Logic::fnWalk(int32 *params) { // 6 target direction (8 means end walk on ANY direction) return _router->doWalk( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4], params[5], params[6]); } @@ -217,10 +217,10 @@ int32 Logic::fnWalkToAnim(int32 *params) { // 4 anim resource id return _router->walkToAnim( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4]); } @@ -236,10 +236,10 @@ int32 Logic::fnTurn(int32 *params) { // 4 target direction return _router->doFace( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4]); } @@ -257,8 +257,8 @@ int32 Logic::fnStandAt(int32 *params) { // 4 target direction _router->standAt( - (ObjectGraphic *) decodePtr(params[0]), - (ObjectMega *) decodePtr(params[1]), + (ObjectGraphic *)decodePtr(params[0]), + (ObjectMega *)decodePtr(params[1]), params[2], params[3], params[4]); return IR_CONT; } @@ -272,10 +272,10 @@ int32 Logic::fnStand(int32 *params) { // params: 0 pointer to object's graphic structure // 1 pointer to object's mega structure // 2 target direction - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[1]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[1]); _router->standAt( - (ObjectGraphic *) decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[0]), ob_mega, ob_mega->feet_x, ob_mega->feet_y, params[2]); return IR_CONT; } @@ -290,8 +290,8 @@ int32 Logic::fnStandAfterAnim(int32 *params) { // 2 anim resource id _router->standAfterAnim( - (ObjectGraphic *) decodePtr(params[0]), - (ObjectMega *) decodePtr(params[1]), + (ObjectGraphic *)decodePtr(params[0]), + (ObjectMega *)decodePtr(params[1]), params[2]); return IR_CONT; } @@ -303,7 +303,7 @@ int32 Logic::fnPause(int32 *params) { // NB. Pause-value of 0 causes script to continue, 1 causes a 1-cycle // quit, 2 gives 2 cycles, etc. - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[0]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[0]); if (ob_logic->looping == 0) { ob_logic->looping = 1; @@ -327,17 +327,17 @@ int32 Logic::fnMegaTableAnim(int32 *params) { // Normal forward anim return _router->megaTableAnimate( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (uint32 *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (uint32 *)decodePtr(params[3]), false); } int32 Logic::fnAddMenuObject(int32 *params) { // params: 0 pointer to a MenuObject structure to copy down - _vm->_mouse->addMenuObject((MenuObject *) decodePtr(params[0])); + _vm->_mouse->addMenuObject((MenuObject *)decodePtr(params[0])); return IR_CONT; } @@ -379,14 +379,14 @@ int32 Logic::fnSetFrame(int32 *params) { // open the resource (& check it's valid) byte *anim_file = _vm->_resman->openResource(res); - StandardHeader *head = (StandardHeader *) anim_file; + StandardHeader *head = (StandardHeader *)anim_file; assert(head->fileType == ANIMATION_FILE); // set up pointer to the animation header AnimHeader *anim_head = _vm->fetchAnimHeader(anim_file); // set up anim resource in graphic object - ObjectGraphic *ob_graphic = (ObjectGraphic *) decodePtr(params[0]); + ObjectGraphic *ob_graphic = (ObjectGraphic *)decodePtr(params[0]); ob_graphic->anim_resource = res; ob_graphic->anim_pc = params[2] ? anim_head->noAnimFrames - 1 : 0; @@ -401,7 +401,7 @@ int32 Logic::fnRandomPause(int32 *params) { // 1 minimum number of game-cycles to pause // 2 maximum number of game-cycles to pause - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[0]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[0]); int32 pars[2]; if (ob_logic->looping == 0) { @@ -424,9 +424,9 @@ int32 Logic::fnRegisterFrame(int32 *params) { // 1 pointer to graphic structure // 2 pointer to mega structure or NULL if not a mega - ObjectMouse *ob_mouse = (ObjectMouse *) decodePtr(params[0]); - ObjectGraphic *ob_graph = (ObjectGraphic *) decodePtr(params[1]); - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[2]); + ObjectMouse *ob_mouse = (ObjectMouse *)decodePtr(params[0]); + ObjectGraphic *ob_graph = (ObjectGraphic *)decodePtr(params[1]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[2]); _vm->_screen->registerFrame(ob_mouse, ob_graph, ob_mega); return IR_CONT; @@ -434,7 +434,7 @@ int32 Logic::fnRegisterFrame(int32 *params) { int32 Logic::fnNoSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), NO_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), NO_SPRITE); return IR_CONT; } @@ -463,7 +463,7 @@ int32 Logic::fnUpdatePlayerStats(int32 *params) { // params: 0 pointer to mega structure - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[0]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[0]); ScreenInfo *screenInfo = _vm->_screen->getScreenInfo(); screenInfo->player_feet_x = ob_mega->feet_x; @@ -496,7 +496,7 @@ int32 Logic::fnPassGraph(int32 *params) { int32 Logic::fnInitFloorMouse(int32 *params) { // params: 0 pointer to object's mouse structure - ObjectMouse *ob_mouse = (ObjectMouse *) decodePtr(params[0]); + ObjectMouse *ob_mouse = (ObjectMouse *)decodePtr(params[0]); ScreenInfo *screenInfo = _vm->_screen->getScreenInfo(); // floor is always lowest priority @@ -537,10 +537,10 @@ int32 Logic::fnFaceXY(int32 *params) { // 5 target y-coord return _router->faceXY( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4], params[5]); } @@ -582,13 +582,13 @@ int32 Logic::fnAddHuman(int32 *params) { int32 Logic::fnWeWait(int32 *params) { // params: 0 target - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(params[0]); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(params[0]); assert(head->fileType == GAME_OBJECT); // Run the target's get-speech-state script int32 target = params[0]; - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 5; runScript(raw_script_ad, raw_script_ad, &null_pc); @@ -622,20 +622,20 @@ int32 Logic::fnTheyDoWeWait(int32 *params) { // 6 ins4 // 7 ins5 - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(params[1]); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(params[1]); assert(head->fileType == GAME_OBJECT); // Run the target's get-speech-state script int32 target = params[1]; - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 5; runScript(raw_script_ad, raw_script_ad, &null_pc); _vm->_resman->closeResource(target); - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[0]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[0]); if (_scriptVars[RESULT] == 1 && !_scriptVars[INS_COMMAND] && ob_logic->looping == 0) { // The target is waiting, i.e. not busy, and there is no other @@ -694,13 +694,13 @@ int32 Logic::fnTheyDo(int32 *params) { // 5 ins4 // 6 ins5 - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(params[0]); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(params[0]); assert (head->fileType == GAME_OBJECT); // Run the target's get-speech-state script int32 target = params[0]; - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 5; runScript(raw_script_ad, raw_script_ad, &null_pc); @@ -745,10 +745,10 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) { // 5 separation return _router->walkToTalkToMega( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4], params[5]); } @@ -801,8 +801,8 @@ int32 Logic::fnISpeak(int32 *params) { // Set up the pointers which we know we'll always need - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[S_OB_LOGIC]); - ObjectGraphic *ob_graphic = (ObjectGraphic *) decodePtr(params[S_OB_GRAPHIC]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[S_OB_LOGIC]); + ObjectGraphic *ob_graphic = (ObjectGraphic *)decodePtr(params[S_OB_GRAPHIC]); // FIRST TIME ONLY: create the text, load the wav, set up the anim, // etc. @@ -858,7 +858,7 @@ int32 Logic::fnISpeak(int32 *params) { return IR_CONT; } - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(text_res); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(text_res); if (head->fileType != TEXT_FILE) { // Invalid - not a text resource @@ -867,7 +867,7 @@ int32 Logic::fnISpeak(int32 *params) { return IR_CONT; } - if (!_vm->checkTextLine((byte *) head, local_text)) { + if (!_vm->checkTextLine((byte *)head, local_text)) { // Line number out of range _vm->_resman->closeResource(text_res); _scriptVars[RESULT] = 2; @@ -919,8 +919,8 @@ int32 Logic::fnISpeak(int32 *params) { // Use this direction table to derive the anim // NB. ASSUMES WE HAVE A MEGA OBJECT!! - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[S_OB_MEGA]); - int32 *anim_table = (int32 *) decodePtr(params[S_DIR_TABLE]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[S_OB_MEGA]); + int32 *anim_table = (int32 *)decodePtr(params[S_DIR_TABLE]); _animId = anim_table[ob_mega->current_dir]; } else { @@ -1194,7 +1194,7 @@ int32 Logic::fnSpeechProcess(int32 *params) { // 3 pointer to ob_mega // 4 pointer to ob_walkdata - ObjectSpeech *ob_speech = (ObjectSpeech *) decodePtr(params[1]); + ObjectSpeech *ob_speech = (ObjectSpeech *)decodePtr(params[1]); while (1) { int32 pars[9]; @@ -1423,7 +1423,7 @@ int32 Logic::fnSetScaling(int32 *params) { // Where s is system scale, which itself is (256 * actual_scale) ie. // s == 128 is half size - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[0]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[0]); ob_mega->scale_a = params[1]; ob_mega->scale_b = params[2]; @@ -1480,10 +1480,10 @@ int32 Logic::fnTimedWait(int32 *params) { // 1 target // 2 number of cycles before give up - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(params[1]); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(params[1]); assert(head->fileType == GAME_OBJECT); - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[0]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[0]); if (!ob_logic->looping) { // This is the first time, so set up the time-out. @@ -1493,7 +1493,7 @@ int32 Logic::fnTimedWait(int32 *params) { // Run the target's get-speech-state script int32 target = params[1]; - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 5; runScript(raw_script_ad, raw_script_ad, &null_pc); @@ -1605,7 +1605,7 @@ int32 Logic::fnSetValue(int32 *params) { // params: 0 pointer to object's mega structure // 1 value to set it to - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[0]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[0]); ob_mega->megaset_res = params[1]; return IR_CONT; @@ -1671,10 +1671,10 @@ int32 Logic::fnReverseMegaTableAnim(int32 *params) { // Reverse anim return _router->megaTableAnimate( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (uint32 *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (uint32 *)decodePtr(params[3]), true); } @@ -1685,8 +1685,8 @@ int32 Logic::fnReverseAnim(int32 *params) { // Reverse anim return _router->doAnimate( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), params[2], true); } @@ -1745,25 +1745,25 @@ int32 Logic::fnSetStandbyCoords(int32 *params) { int32 Logic::fnBackPar0Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), BGP0_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), BGP0_SPRITE); return IR_CONT; } int32 Logic::fnBackPar1Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), BGP1_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), BGP1_SPRITE); return IR_CONT; } int32 Logic::fnForePar0Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), FGP0_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), FGP0_SPRITE); return IR_CONT; } int32 Logic::fnForePar1Sprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteStatus((ObjectGraphic *) decodePtr(params[0]), FGP1_SPRITE); + _router->setSpriteStatus((ObjectGraphic *)decodePtr(params[0]), FGP1_SPRITE); return IR_CONT; } @@ -1816,8 +1816,8 @@ int32 Logic::fnStandAtAnim(int32 *params) { // 2 anim resource id _router->standAtAnim( - (ObjectGraphic *) decodePtr(params[0]), - (ObjectMega *) decodePtr(params[1]), + (ObjectGraphic *)decodePtr(params[0]), + (ObjectMega *)decodePtr(params[1]), params[2]); return IR_CONT; } @@ -1827,7 +1827,7 @@ int32 Logic::fnStandAtAnim(int32 *params) { int32 Logic::fnSetScrollLeftMouse(int32 *params) { // params: 0 pointer to object's mouse structure - ObjectMouse *ob_mouse = (ObjectMouse *) decodePtr(params[0]); + ObjectMouse *ob_mouse = (ObjectMouse *)decodePtr(params[0]); ScreenInfo *screenInfo = _vm->_screen->getScreenInfo(); // Highest priority @@ -1852,7 +1852,7 @@ int32 Logic::fnSetScrollLeftMouse(int32 *params) { int32 Logic::fnSetScrollRightMouse(int32 *params) { // params: 0 pointer to object's mouse structure - ObjectMouse *ob_mouse = (ObjectMouse *) decodePtr(params[0]); + ObjectMouse *ob_mouse = (ObjectMouse *)decodePtr(params[0]); ScreenInfo *screenInfo = _vm->_screen->getScreenInfo(); // Highest priority @@ -1984,7 +1984,7 @@ int32 Logic::fnGetPlayerSaveData(int32 *params) { // Any walk-data must be cleared - the player will be set to stand if // he was walking when saved. - ObjectMega *ob_mega = (ObjectMega *) mega_ptr; + ObjectMega *ob_mega = (ObjectMega *)mega_ptr; if (ob_mega->currently_walking) { ob_mega->currently_walking = 0; @@ -1998,7 +1998,7 @@ int32 Logic::fnGetPlayerSaveData(int32 *params) { fnStand(pars); // Reset looping flag (which would have been 1 during fnWalk) - ObjectLogic *ob_logic = (ObjectLogic *) logic_ptr; + ObjectLogic *ob_logic = (ObjectLogic *)logic_ptr; ob_logic->looping = 0; } @@ -2095,7 +2095,7 @@ int32 Logic::fnPauseForEvent(int32 *params) { // params: 0 pointer to object's logic structure // 1 number of game-cycles to pause - ObjectLogic *ob_logic = (ObjectLogic *) decodePtr(params[0]); + ObjectLogic *ob_logic = (ObjectLogic *)decodePtr(params[0]); if (checkEventWaiting()) { ob_logic->looping = 0; @@ -2121,10 +2121,10 @@ int32 Logic::fnFaceMega(int32 *params) { // 4 id of target mega to face return _router->faceMega( - (ObjectLogic *) decodePtr(params[0]), - (ObjectGraphic *) decodePtr(params[1]), - (ObjectMega *) decodePtr(params[2]), - (ObjectWalkdata *) decodePtr(params[3]), + (ObjectLogic *)decodePtr(params[0]), + (ObjectGraphic *)decodePtr(params[1]), + (ObjectMega *)decodePtr(params[2]), + (ObjectWalkdata *)decodePtr(params[3]), params[4]); } @@ -2140,11 +2140,11 @@ int32 Logic::fnPlaySequence(int32 *params) { // of computer games" - but at the very least we want to show the // cutscene subtitles, so I removed them. - debug(5, "fnPlaySequence(\"%s\");", (const char *) decodePtr(params[0])); + debug(5, "fnPlaySequence(\"%s\");", (const char *)decodePtr(params[0])); // add the appropriate file extension & play it - strcpy(filename, (const char *) decodePtr(params[0])); + strcpy(filename, (const char *)decodePtr(params[0])); // Write to walkthrough file (zebug0.txt) debug(5, "PLAYING SEQUENCE \"%s\"", filename); @@ -2201,13 +2201,13 @@ int32 Logic::fnPlaySequence(int32 *params) { int32 Logic::fnShadedSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteShading((ObjectGraphic *) decodePtr(params[0]), SHADED_SPRITE); + _router->setSpriteShading((ObjectGraphic *)decodePtr(params[0]), SHADED_SPRITE); return IR_CONT; } int32 Logic::fnUnshadedSprite(int32 *params) { // params: 0 pointer to object's graphic structure - _router->setSpriteShading((ObjectGraphic *) decodePtr(params[0]), UNSHADED_SPRITE); + _router->setSpriteShading((ObjectGraphic *)decodePtr(params[0]), UNSHADED_SPRITE); return IR_CONT; } @@ -2279,7 +2279,7 @@ int32 Logic::fnResetGlobals(int32 *params) { debug(5, "globals size: %d", size); - globals = (uint32 *) ((byte *) _vm->_resman->openResource(1) + sizeof(StandardHeader)); + globals = (uint32 *)((byte *)_vm->_resman->openResource(1) + sizeof(StandardHeader)); // blank each global variable memset(globals, 0, size); diff --git a/sword2/icons.cpp b/sword2/icons.cpp index 399d40c903..f3a445b93f 100644 --- a/sword2/icons.cpp +++ b/sword2/icons.cpp @@ -73,7 +73,7 @@ void Mouse::buildMenu() { // register all carried menu objects. uint32 null_pc = 0; - char *menuScript = (char *) _vm->_resman->openResource(MENU_MASTER_OBJECT); + char *menuScript = (char *)_vm->_resman->openResource(MENU_MASTER_OBJECT); _vm->_logic->runScript(menuScript, menuScript, &null_pc); _vm->_resman->closeResource(MENU_MASTER_OBJECT); diff --git a/sword2/interpreter.cpp b/sword2/interpreter.cpp index 740dee3abd..fb2df78053 100644 --- a/sword2/interpreter.cpp +++ b/sword2/interpreter.cpp @@ -214,7 +214,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { int32 stack[STACK_SIZE]; int32 stackPtr = 0; - StandardHeader *header = (StandardHeader *) scriptData; + StandardHeader *header = (StandardHeader *)scriptData; scriptData += sizeof(StandardHeader) + sizeof(ObjectHub); // The script data format: @@ -230,13 +230,13 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { // Get the start of variables and start of code - uint32 *localVars = (uint32 *) (scriptData + sizeof(int32)); + uint32 *localVars = (uint32 *)(scriptData + sizeof(int32)); char *code = scriptData + READ_LE_UINT32(scriptData) + sizeof(int32); uint32 noScripts = READ_LE_UINT32(code); code += sizeof(int32); - const uint32 *offsetTable = (const uint32 *) code; + const uint32 *offsetTable = (const uint32 *)code; if (*offset < noScripts) { ip = FROM_LE_32(offsetTable[*offset]); @@ -271,7 +271,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { // So if his click hander (action script number 2) finishes, and // variable 913 is 1, we set it back to 0 manually. - bool checkPyramidBug = scriptNumber == 2 && strcmp((char *) header->name, "titipoco_81") == 0; + bool checkPyramidBug = scriptNumber == 2 && strcmp((char *)header->name, "titipoco_81") == 0; code += noScripts * sizeof(int32); @@ -382,7 +382,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { Read16ip(parameter); parameter /= 4; - ptr = (byte *) &localVars[parameter]; + ptr = (byte *)&localVars[parameter]; push_ptr(ptr); debug(9, "CP_PUSH_LOCAL_ADDR: &localVars[%d] => %p", parameter, ptr); break; @@ -392,7 +392,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { Read8ip(parameter); // ip now points to the string - ptr = (byte *) (code + ip); + ptr = (byte *)(code + ip); push_ptr(ptr); debug(9, "CP_PUSH_STRING: \"%s\"", ptr); ip += (parameter + 1); @@ -400,7 +400,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { case CP_PUSH_DEREFERENCED_STRUCTURE: // Push the address of a dereferenced structure Read32ip(parameter); - ptr = (byte *) (objectData + sizeof(int32) + sizeof(StandardHeader) + sizeof(ObjectHub) + parameter); + ptr = (byte *)(objectData + sizeof(int32) + sizeof(StandardHeader) + sizeof(ObjectHub) + parameter); push_ptr(ptr); debug(9, "CP_PUSH_DEREFERENCED_STRUCTURE: %d => %p", parameter, ptr); break; diff --git a/sword2/interpreter.h b/sword2/interpreter.h index 7a31e7f078..e24001c995 100644 --- a/sword2/interpreter.h +++ b/sword2/interpreter.h @@ -36,7 +36,7 @@ enum { // Get parameter fix so that the playstation version can handle words not on // word boundaries -#define Read8ip(var) { var = *((const int8 *) (code + ip)); ip++; } +#define Read8ip(var) { var = *((const int8 *)(code + ip)); ip++; } #define Read16ip(var) { var = (int16) READ_LE_UINT16(code + ip); ip += sizeof(int16); } #define Read32ip(var) { var = (int32) READ_LE_UINT32(code + ip); ip += sizeof(int32); } #define Read32ipLeaveip(var) { var = (int32) READ_LE_UINT32(code + ip); } diff --git a/sword2/layers.cpp b/sword2/layers.cpp index 0fc9734c93..b5b365870a 100644 --- a/sword2/layers.cpp +++ b/sword2/layers.cpp @@ -129,7 +129,7 @@ void Screen::initBackground(int32 res, int32 new_palette) { // shading mask - MultiScreenHeader *screenLayerTable = (MultiScreenHeader *) (file + sizeof(StandardHeader)); + MultiScreenHeader *screenLayerTable = (MultiScreenHeader *)(file + sizeof(StandardHeader)); if (screenLayerTable->maskOffset) { SpriteInfo spriteInfo; diff --git a/sword2/logic.cpp b/sword2/logic.cpp index c286b2f9b7..7699042704 100644 --- a/sword2/logic.cpp +++ b/sword2/logic.cpp @@ -63,10 +63,10 @@ int Logic::processSession() { uint32 ret, script; char *raw_script_ad; - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(run_list); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(run_list); assert(head->fileType == RUN_LIST); - uint32 *game_object_list = (uint32 *) (head + 1); + uint32 *game_object_list = (uint32 *)(head + 1); // read the next id uint id = game_object_list[_pc++]; @@ -79,10 +79,10 @@ int Logic::processSession() { return 0; } - head = (StandardHeader *) _vm->_resman->openResource(_scriptVars[ID]); + head = (StandardHeader *)_vm->_resman->openResource(_scriptVars[ID]); assert(head->fileType == GAME_OBJECT); - _curObjectHub = (ObjectHub *) (head + 1); + _curObjectHub = (ObjectHub *)(head + 1); debug(5, "Level %d id(%d) pc(%d)", LEVEL, @@ -109,18 +109,18 @@ int Logic::processSession() { // This is the script data. Script and data // object are the same. - raw_script_ad = (char *) head; + raw_script_ad = (char *)head; ret = runScript(raw_script_ad, raw_script_ad, &_curObjectHub->script_pc[LEVEL]); } else { // We're running the script of another game // object - get our data object address. - StandardHeader *far_head = (StandardHeader *) _vm->_resman->openResource(script / SIZE); + StandardHeader *far_head = (StandardHeader *)_vm->_resman->openResource(script / SIZE); assert(far_head->fileType == GAME_OBJECT || far_head->fileType == SCREEN_MANAGER); - raw_script_ad = (char *) far_head; - char *raw_data_ad = (char *) head; + raw_script_ad = (char *)far_head; + char *raw_data_ad = (char *)head; ret = runScript(raw_script_ad, raw_data_ad, &_curObjectHub->script_pc[LEVEL]); diff --git a/sword2/maketext.cpp b/sword2/maketext.cpp index 0ca8619687..0b635de5eb 100644 --- a/sword2/maketext.cpp +++ b/sword2/maketext.cpp @@ -93,17 +93,17 @@ byte *FontRenderer::makeTextSprite(byte *sentence, uint16 maxWidth, uint8 pen, u // Allocate memory for array of lineInfo structures - byte *line = (byte *) malloc(MAX_LINES * sizeof(LineInfo)); + byte *line = (byte *)malloc(MAX_LINES * sizeof(LineInfo)); // Get details of sentence breakdown into array of LineInfo structures // and get the number of lines involved - uint16 noOfLines = analyseSentence(sentence, maxWidth, fontRes, (LineInfo *) line); + uint16 noOfLines = analyseSentence(sentence, maxWidth, fontRes, (LineInfo *)line); // Construct the sprite based on the info gathered - returns floating // mem block - byte *textSprite = buildTextSprite(sentence, fontRes, pen, (LineInfo *) line, noOfLines); + byte *textSprite = buildTextSprite(sentence, fontRes, pen, (LineInfo *)line, noOfLines); free(line); return textSprite; @@ -213,12 +213,12 @@ byte *FontRenderer::buildTextSprite(byte *sentence, uint32 fontRes, uint8 pen, L // Allocate memory for the text sprite uint32 sizeOfSprite = spriteWidth * spriteHeight; - byte *textSprite = (byte *) malloc(sizeof(FrameHeader) + sizeOfSprite); + byte *textSprite = (byte *)malloc(sizeof(FrameHeader) + sizeOfSprite); // At this stage, textSprite points to an unmovable memory block. Set // up the frame header. - FrameHeader *frameHeadPtr = (FrameHeader *) textSprite; + FrameHeader *frameHeadPtr = (FrameHeader *)textSprite; frameHeadPtr->compSize = 0; frameHeadPtr->width = spriteWidth; @@ -324,7 +324,7 @@ FrameHeader* FontRenderer::findChar(byte ch, byte *charSet) { */ void FontRenderer::copyChar(FrameHeader *charPtr, byte *spritePtr, uint16 spriteWidth, uint8 pen) { - byte *source = (byte *) charPtr + sizeof(FrameHeader); + byte *source = (byte *)charPtr + sizeof(FrameHeader); byte *rowPtr = spritePtr; for (uint i = 0; i < charPtr->height; i++) { @@ -387,7 +387,7 @@ uint32 FontRenderer::buildNewBloc(byte *ascii, int16 x, int16 y, uint16 width, u // without margin checking - used for debug text if (justification != NO_JUSTIFICATION) { - FrameHeader *frame_head = (FrameHeader *) _blocList[i].text_mem; + FrameHeader *frame_head = (FrameHeader *)_blocList[i].text_mem; switch (justification) { case POSITION_AT_CENTRE_OF_BASE: @@ -460,7 +460,7 @@ uint32 FontRenderer::buildNewBloc(byte *ascii, int16 x, int16 y, uint16 width, u void FontRenderer::printTextBlocs() { for (uint i = 0; i < MAX_text_blocs; i++) { if (_blocList[i].text_mem) { - FrameHeader *frame = (FrameHeader *) _blocList[i].text_mem; + FrameHeader *frame = (FrameHeader *)_blocList[i].text_mem; SpriteInfo spriteInfo; spriteInfo.x = _blocList[i].x; @@ -507,7 +507,7 @@ void Sword2Engine::initialiseFontResourceFlags() { // "zapisz" Polish for "save" // Get the text line (& skip the 2 chars containing the wavId) - char *textLine = (char *) fetchTextLine(textFile, SAVE_LINE_NO) + 2; + char *textLine = (char *)fetchTextLine(textFile, SAVE_LINE_NO) + 2; if (strcmp(textLine, "tallenna") == 0) initialiseFontResourceFlags(FINNISH_TEXT); @@ -529,9 +529,9 @@ void Sword2Engine::initialiseFontResourceFlags() { // But we get it from the text resource instead. if (Logic::_scriptVars[DEMO]) - textLine = (char *) fetchTextLine(textFile, 451) + 2; + textLine = (char *)fetchTextLine(textFile, 451) + 2; else - textLine = (char *) fetchTextLine(textFile, 54) + 2; + textLine = (char *)fetchTextLine(textFile, 54) + 2; _system->setWindowCaption(textLine); _resman->closeResource(TEXT_RES); diff --git a/sword2/memory.cpp b/sword2/memory.cpp index ea06fd8abf..2030ecc0aa 100644 --- a/sword2/memory.cpp +++ b/sword2/memory.cpp @@ -66,9 +66,9 @@ MemoryManager::MemoryManager(Sword2Engine *vm) : _vm(vm) { // encoding or decoding pointers any faster, and these are by far the // most common operations. - _idStack = (int16 *) malloc(MAX_MEMORY_BLOCKS * sizeof(int16)); - _memBlocks = (MemBlock *) malloc(MAX_MEMORY_BLOCKS * sizeof(MemBlock)); - _memBlockIndex = (MemBlock **) malloc(MAX_MEMORY_BLOCKS * sizeof(MemBlock *)); + _idStack = (int16 *)malloc(MAX_MEMORY_BLOCKS * sizeof(int16)); + _memBlocks = (MemBlock *)malloc(MAX_MEMORY_BLOCKS * sizeof(MemBlock)); + _memBlockIndex = (MemBlock **)malloc(MAX_MEMORY_BLOCKS * sizeof(MemBlock *)); _totAlloc = 0; _numBlocks = 0; @@ -192,7 +192,7 @@ byte *MemoryManager::memAlloc(uint32 size, int16 uid) { int16 id = _idStack[--_idStackPtr]; // Allocate the new memory block - byte *ptr = (byte *) malloc(size); + byte *ptr = (byte *)malloc(size); assert(ptr); diff --git a/sword2/protocol.cpp b/sword2/protocol.cpp index ec4bcd9b1c..4941fa87d5 100644 --- a/sword2/protocol.cpp +++ b/sword2/protocol.cpp @@ -30,9 +30,9 @@ namespace Sword2 { */ byte *Sword2Engine::fetchPalette(byte *screenFile) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); - byte *palette = (byte *) mscreenHeader + mscreenHeader->palette; + byte *palette = (byte *)mscreenHeader + mscreenHeader->palette; // Always set colour 0 to black, because while most background screen // palettes have a bright colour 0 it should come out as black in the @@ -52,9 +52,9 @@ byte *Sword2Engine::fetchPalette(byte *screenFile) { */ byte *Sword2Engine::fetchPaletteMatchTable(byte *screenFile) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); - return (byte *) mscreenHeader + mscreenHeader->paletteTable; + return (byte *)mscreenHeader + mscreenHeader->paletteTable; } /** @@ -63,8 +63,8 @@ byte *Sword2Engine::fetchPaletteMatchTable(byte *screenFile) { */ ScreenHeader *Sword2Engine::fetchScreenHeader(byte *screenFile) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); - ScreenHeader *screenHeader = (ScreenHeader *) ((byte *) mscreenHeader + mscreenHeader->screen); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); + ScreenHeader *screenHeader = (ScreenHeader *)((byte *)mscreenHeader + mscreenHeader->screen); return screenHeader; } @@ -83,9 +83,9 @@ LayerHeader *Sword2Engine::fetchLayerHeader(byte *screenFile, uint16 layerNo) { error("fetchLayerHeader(%d) invalid layer number!", layerNo); #endif - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); - LayerHeader *layerHeader = (LayerHeader *) ((byte *) mscreenHeader + mscreenHeader->layers + (layerNo * sizeof(LayerHeader))); + LayerHeader *layerHeader = (LayerHeader *)((byte *)mscreenHeader + mscreenHeader->layers + (layerNo * sizeof(LayerHeader))); return layerHeader; } @@ -96,9 +96,9 @@ LayerHeader *Sword2Engine::fetchLayerHeader(byte *screenFile, uint16 layerNo) { */ byte *Sword2Engine::fetchShadingMask(byte *screenFile) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); - return (byte *) mscreenHeader + mscreenHeader->maskOffset; + return (byte *)mscreenHeader + mscreenHeader->maskOffset; } /** @@ -107,7 +107,7 @@ byte *Sword2Engine::fetchShadingMask(byte *screenFile) { */ AnimHeader *Sword2Engine::fetchAnimHeader(byte *animFile) { - return (AnimHeader *) (animFile + sizeof(StandardHeader)); + return (AnimHeader *)(animFile + sizeof(StandardHeader)); } /** @@ -124,7 +124,7 @@ CdtEntry *Sword2Engine::fetchCdtEntry(byte *animFile, uint16 frameNo) { error("fetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames); #endif - return (CdtEntry *) ((byte *) animHead + sizeof(AnimHeader) + frameNo * sizeof(CdtEntry)); + return (CdtEntry *)((byte *)animHead + sizeof(AnimHeader) + frameNo * sizeof(CdtEntry)); } /** @@ -135,7 +135,7 @@ CdtEntry *Sword2Engine::fetchCdtEntry(byte *animFile, uint16 frameNo) { FrameHeader *Sword2Engine::fetchFrameHeader(byte *animFile, uint16 frameNo) { // required address = (address of the start of the anim header) + frameOffset - return (FrameHeader *) (animFile + sizeof(StandardHeader) + fetchCdtEntry(animFile, frameNo)->frameOffset); + return (FrameHeader *)(animFile + sizeof(StandardHeader) + fetchCdtEntry(animFile, frameNo)->frameOffset); } /** @@ -143,36 +143,36 @@ FrameHeader *Sword2Engine::fetchFrameHeader(byte *animFile, uint16 frameNo) { */ Parallax *Sword2Engine::fetchBackgroundParallaxLayer(byte *screenFile, int layer) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); #ifdef SWORD2_DEBUG if (mscreenHeader->bg_parallax[layer] == 0) error("fetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer); #endif - return (Parallax *) ((byte *) mscreenHeader + mscreenHeader->bg_parallax[layer]); + return (Parallax *)((byte *)mscreenHeader + mscreenHeader->bg_parallax[layer]); } Parallax *Sword2Engine::fetchBackgroundLayer(byte *screenFile) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); #ifdef SWORD2_DEBUG if (mscreenHeader->screen == 0) error("fetchBackgroundLayer (%d) - No background layer exists"); #endif - return (Parallax *) ((byte *) mscreenHeader + mscreenHeader->screen + sizeof(ScreenHeader)); + return (Parallax *)((byte *)mscreenHeader + mscreenHeader->screen + sizeof(ScreenHeader)); } Parallax *Sword2Engine::fetchForegroundParallaxLayer(byte *screenFile, int layer) { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) (screenFile + sizeof(StandardHeader)); + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)(screenFile + sizeof(StandardHeader)); #ifdef SWORD2_DEBUG if (mscreenHeader->fg_parallax[layer] == 0) error("fetchForegroundParallaxLayer(%d) - No parallax layer exists", layer); #endif - return (Parallax *) ((byte *) mscreenHeader + mscreenHeader->fg_parallax[layer]); + return (Parallax *)((byte *)mscreenHeader + mscreenHeader->fg_parallax[layer]); } static byte errorLine[128]; @@ -181,11 +181,11 @@ byte *Sword2Engine::fetchTextLine(byte *file, uint32 text_line) { StandardHeader *fileHeader; uint32 *point; - TextHeader *text_header = (TextHeader *) (file + sizeof(StandardHeader)); + TextHeader *text_header = (TextHeader *)(file + sizeof(StandardHeader)); if (text_line >= text_header->noOfLines) { - fileHeader = (StandardHeader *) file; - sprintf((char *) errorLine, "xxMissing line %d of %s (only 0..%d)", text_line, fileHeader->name, text_header->noOfLines - 1); + fileHeader = (StandardHeader *)file; + sprintf((char *)errorLine, "xxMissing line %d of %s (only 0..%d)", text_line, fileHeader->name, text_header->noOfLines - 1); // first 2 chars are NULL so that actor-number comes out as '0' @@ -195,22 +195,22 @@ byte *Sword2Engine::fetchTextLine(byte *file, uint32 text_line) { } // point to the lookup table - point = (uint32 *) text_header + 1; + point = (uint32 *)text_header + 1; - return (byte *) (file + READ_LE_UINT32(point + text_line)); + return (byte *)(file + READ_LE_UINT32(point + text_line)); } // Used for testing text & speech (see fnISpeak in speech.cpp) bool Sword2Engine::checkTextLine(byte *file, uint32 text_line) { - TextHeader *text_header = (TextHeader *) (file + sizeof(StandardHeader)); + TextHeader *text_header = (TextHeader *)(file + sizeof(StandardHeader)); return text_line < text_header->noOfLines; } byte *Sword2Engine::fetchObjectName(int32 resourceId, byte *buf) { - StandardHeader *header = (StandardHeader *) _resman->openResource(resourceId); + StandardHeader *header = (StandardHeader *)_resman->openResource(resourceId); memcpy(buf, header->name, NAME_LEN); _resman->closeResource(resourceId); diff --git a/sword2/resman.cpp b/sword2/resman.cpp index e11048c625..987ac50577 100644 --- a/sword2/resman.cpp +++ b/sword2/resman.cpp @@ -81,7 +81,7 @@ ResourceManager::ResourceManager(Sword2Engine *vm) { size = file.size(); // Get some space for the incoming resource file - soon to be trashed - temp = (byte *) malloc(size); + temp = (byte *)malloc(size); if (file.read(temp, size) != size) { file.close(); @@ -134,7 +134,7 @@ ResourceManager::ResourceManager(Sword2Engine *vm) { _totalResFiles = size / 4; // Table seems ok so malloc some space - _resConvTable = (uint16 *) malloc(size); + _resConvTable = (uint16 *)malloc(size); for (i = 0; i < size / 2; i++) _resConvTable[i] = file.readUint16LE(); @@ -163,7 +163,7 @@ ResourceManager::ResourceManager(Sword2Engine *vm) { for (i = 0; i < _totalClusters; i++) { for (j = 0; j < _totalClusters; j++) { - if (scumm_stricmp((char *) cdInf[j].clusterName, _resFiles[i].fileName) == 0) + if (scumm_stricmp((char *)cdInf[j].clusterName, _resFiles[i].fileName) == 0) break; } @@ -179,7 +179,7 @@ ResourceManager::ResourceManager(Sword2Engine *vm) { for (i = 0; i < _totalClusters; i++) debug(2, "filename of cluster %d: -%s", i, _resFiles[i].fileName); - _resList = (Resource *) malloc(_totalResFiles * sizeof(Resource)); + _resList = (Resource *)malloc(_totalResFiles * sizeof(Resource)); for (i = 0; i < _totalResFiles; i++) { _resList[i].ptr = NULL; @@ -208,7 +208,7 @@ ResourceManager::~ResourceManager() { void convertEndian(byte *file, uint32 len) { int i; - StandardHeader *hdr = (StandardHeader *) file; + StandardHeader *hdr = (StandardHeader *)file; file += sizeof(StandardHeader); @@ -217,7 +217,7 @@ void convertEndian(byte *file, uint32 len) { switch (hdr->fileType) { case ANIMATION_FILE: { - AnimHeader *animHead = (AnimHeader *) file; + AnimHeader *animHead = (AnimHeader *)file; SWAP16(animHead->noAnimFrames); SWAP16(animHead->feetStartX); @@ -226,13 +226,13 @@ void convertEndian(byte *file, uint32 len) { SWAP16(animHead->feetEndY); SWAP16(animHead->blend); - CdtEntry *cdtEntry = (CdtEntry *) (file + sizeof(AnimHeader)); + CdtEntry *cdtEntry = (CdtEntry *)(file + sizeof(AnimHeader)); for (i = 0; i < animHead->noAnimFrames; i++, cdtEntry++) { SWAP16(cdtEntry->x); SWAP16(cdtEntry->y); SWAP32(cdtEntry->frameOffset); - FrameHeader *frameHeader = (FrameHeader *) (file + cdtEntry->frameOffset); + FrameHeader *frameHeader = (FrameHeader *)(file + cdtEntry->frameOffset); // Quick trick to prevent us from incorrectly applying the endian // fixes multiple times. This assumes that frames are less than 1 MB // and have height/width less than 4096. @@ -247,7 +247,7 @@ void convertEndian(byte *file, uint32 len) { break; } case SCREEN_FILE: { - MultiScreenHeader *mscreenHeader = (MultiScreenHeader *) file; + MultiScreenHeader *mscreenHeader = (MultiScreenHeader *)file; SWAP32(mscreenHeader->palette); SWAP32(mscreenHeader->bg_parallax[0]); @@ -260,14 +260,14 @@ void convertEndian(byte *file, uint32 len) { SWAP32(mscreenHeader->maskOffset); // screenHeader - ScreenHeader *screenHeader = (ScreenHeader *) (file + mscreenHeader->screen); + ScreenHeader *screenHeader = (ScreenHeader *)(file + mscreenHeader->screen); SWAP16(screenHeader->width); SWAP16(screenHeader->height); SWAP16(screenHeader->noLayers); // layerHeader - LayerHeader *layerHeader = (LayerHeader *) (file + mscreenHeader->layers); + LayerHeader *layerHeader = (LayerHeader *)(file + mscreenHeader->layers); for (i = 0; i < screenHeader->noLayers; i++, layerHeader++) { SWAP16(layerHeader->x); SWAP16(layerHeader->y); @@ -282,14 +282,14 @@ void convertEndian(byte *file, uint32 len) { int offset; offset = mscreenHeader->bg_parallax[0]; if (offset > 0) { - parallax = (Parallax *) (file + offset); + parallax = (Parallax *)(file + offset); SWAP16(parallax->w); SWAP16(parallax->h); } offset = mscreenHeader->bg_parallax[1]; if (offset > 0) { - parallax = (Parallax *) (file + offset); + parallax = (Parallax *)(file + offset); SWAP16(parallax->w); SWAP16(parallax->h); } @@ -297,7 +297,7 @@ void convertEndian(byte *file, uint32 len) { // backgroundLayer offset = mscreenHeader->screen + sizeof(ScreenHeader); if (offset > 0) { - parallax = (Parallax *) (file + offset); + parallax = (Parallax *)(file + offset); SWAP16(parallax->w); SWAP16(parallax->h); } @@ -305,21 +305,21 @@ void convertEndian(byte *file, uint32 len) { // foregroundParallaxLayer offset = mscreenHeader->fg_parallax[0]; if (offset > 0) { - parallax = (Parallax *) (file + offset); + parallax = (Parallax *)(file + offset); SWAP16(parallax->w); SWAP16(parallax->h); } offset = mscreenHeader->fg_parallax[1]; if (offset > 0) { - parallax = (Parallax *) (file + offset); + parallax = (Parallax *)(file + offset); SWAP16(parallax->w); SWAP16(parallax->h); } break; } case GAME_OBJECT: { - ObjectHub *objectHub = (ObjectHub *) file; + ObjectHub *objectHub = (ObjectHub *)file; objectHub->type = (int) SWAP_BYTES_32(objectHub->type); SWAP32(objectHub->logic_level); @@ -332,12 +332,12 @@ void convertEndian(byte *file, uint32 len) { break; } case WALK_GRID_FILE: { - WalkGridHeader *walkGridHeader = (WalkGridHeader *) file; + WalkGridHeader *walkGridHeader = (WalkGridHeader *)file; SWAP32(walkGridHeader->numBars); SWAP32(walkGridHeader->numNodes); - BarData *barData = (BarData *) (file + sizeof(WalkGridHeader)); + BarData *barData = (BarData *)(file + sizeof(WalkGridHeader)); for (i = 0; i < walkGridHeader->numBars; i++) { SWAP16(barData->x1); SWAP16(barData->y1); @@ -353,7 +353,7 @@ void convertEndian(byte *file, uint32 len) { barData++; } - uint16 *node = (uint16 *) (file + sizeof(WalkGridHeader) + walkGridHeader->numBars * sizeof(BarData)); + uint16 *node = (uint16 *)(file + sizeof(WalkGridHeader) + walkGridHeader->numBars * sizeof(BarData)); for (i = 0; i < walkGridHeader->numNodes * 2; i++) { SWAP16(*node); node++; @@ -366,7 +366,7 @@ void convertEndian(byte *file, uint32 len) { case PARALLAX_FILE_null: break; case RUN_LIST: { - uint32 *list = (uint32 *) file; + uint32 *list = (uint32 *)file; while (*list) { SWAP32(*list); list++; @@ -374,7 +374,7 @@ void convertEndian(byte *file, uint32 len) { break; } case TEXT_FILE: { - TextHeader *textHeader = (TextHeader *) file; + TextHeader *textHeader = (TextHeader *)file; SWAP32(textHeader->noOfLines); break; } @@ -440,7 +440,7 @@ byte *ResourceManager::openResource(uint32 res, bool dump) { file->read(_resList[res].ptr, len); if (dump) { - StandardHeader *header = (StandardHeader *) _resList[res].ptr; + StandardHeader *header = (StandardHeader *)_resList[res].ptr; char buf[256]; const char *tag; Common::File out; @@ -725,7 +725,7 @@ void ResourceManager::killAll(bool wantInfo) { continue; if (_resList[i].ptr) { - StandardHeader *header = (StandardHeader *) _resList[i].ptr; + StandardHeader *header = (StandardHeader *)_resList[i].ptr; if (wantInfo) Debug_Printf("Nuked %5d: %s\n", i, header->name); @@ -757,7 +757,7 @@ void ResourceManager::killAllObjects(bool wantInfo) { continue; if (_resList[i].ptr) { - StandardHeader *header = (StandardHeader *) _resList[i].ptr; + StandardHeader *header = (StandardHeader *)_resList[i].ptr; if (header->fileType == GAME_OBJECT) { if (wantInfo) diff --git a/sword2/router.cpp b/sword2/router.cpp index de92f28855..894389e391 100644 --- a/sword2/router.cpp +++ b/sword2/router.cpp @@ -109,7 +109,7 @@ void Router::allocateRouteMem() { if (_routeSlots[slotNo]) freeRouteMem(); - _routeSlots[slotNo] = (WalkData *) malloc(sizeof(WalkData) * O_WALKANIM_SIZE); + _routeSlots[slotNo] = (WalkData *)malloc(sizeof(WalkData) * O_WALKANIM_SIZE); // 12000 bytes were used for this in Sword1 mega compacts, based on // 20 bytes per 'WalkData' frame @@ -127,7 +127,7 @@ void Router::allocateRouteMem() { WalkData *Router::getRouteMem() { uint8 slotNo = returnSlotNo(Logic::_scriptVars[ID]); - return (WalkData *) _routeSlots[slotNo]; + return (WalkData *)_routeSlots[slotNo]; } void Router::freeRouteMem() { @@ -2397,7 +2397,7 @@ void Router::loadWalkGrid() { // open walk grid file fPolygrid = _vm->_resman->openResource(_walkGridList[i]); fPolygrid += sizeof(StandardHeader); - memcpy((byte *) &floorHeader, fPolygrid, sizeof(WalkGridHeader)); + memcpy((byte *)&floorHeader, fPolygrid, sizeof(WalkGridHeader)); fPolygrid += sizeof(WalkGridHeader); // how many bars & nodes are we getting from this @@ -2414,7 +2414,7 @@ void Router::loadWalkGrid() { // lines - memcpy((byte *) &_bars[_nBars], fPolygrid, theseBars * sizeof(BarData)); + memcpy((byte *)&_bars[_nBars], fPolygrid, theseBars * sizeof(BarData)); // move pointer to start of node data fPolygrid += theseBars * sizeof(BarData); @@ -2423,7 +2423,7 @@ void Router::loadWalkGrid() { // leave node 0 for start node for (uint j = 0; j < theseNodes; j++) { - memcpy((byte *) &_node[_nNodes + j].x, fPolygrid, 2 * sizeof(int16)); + memcpy((byte *)&_node[_nNodes + j].x, fPolygrid, 2 * sizeof(int16)); fPolygrid += 2 * sizeof(int16); } diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp index 366d519f46..fa7a10eb11 100644 --- a/sword2/save_rest.cpp +++ b/sword2/save_rest.cpp @@ -93,7 +93,7 @@ static void convertHeaderEndian(Sword2Engine::SaveGameHeader &header) { uint32 Sword2Engine::saveGame(uint16 slotNo, byte *desc) { uint32 bufferSize = findBufferSize(); - byte *saveBufferMem = (byte *) malloc(bufferSize); + byte *saveBufferMem = (byte *)malloc(bufferSize); fillSaveBuffer(saveBufferMem, bufferSize, desc); @@ -132,7 +132,7 @@ void Sword2Engine::fillSaveBuffer(byte *buffer, uint32 size, byte *desc) { // Set up the _saveGameHeader. Checksum gets filled in last of all. ScreenInfo *screenInfo = _screen->getScreenInfo(); - strcpy(_saveGameHeader.description, (char *) desc); + strcpy(_saveGameHeader.description, (char *)desc); _saveGameHeader.varLength = _resman->fetchLen(1); _saveGameHeader.screenId = screenInfo->background_layer_id; _saveGameHeader.runListId = _logic->getRunList(); @@ -160,7 +160,7 @@ void Sword2Engine::fillSaveBuffer(byte *buffer, uint32 size, byte *desc) { memcpy(buffer + sizeof(_saveGameHeader), varsRes, FROM_LE_32(_saveGameHeader.varLength)); #ifdef SCUMM_BIG_ENDIAN - uint32 *globalVars = (uint32 *) (buffer + sizeof(_saveGameHeader) + sizeof(StandardHeader)); + uint32 *globalVars = (uint32 *)(buffer + sizeof(_saveGameHeader) + sizeof(StandardHeader)); const uint numVars = (FROM_LE_32(_saveGameHeader.varLength) - sizeof(StandardHeader)) / 4; for (uint i = 0; i < numVars; i++) @@ -205,7 +205,7 @@ uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) { uint32 Sword2Engine::restoreGame(uint16 slotNo) { uint32 bufferSize = findBufferSize(); - byte *saveBufferMem = (byte *) malloc(bufferSize); + byte *saveBufferMem = (byte *)malloc(bufferSize); uint32 errorCode = restoreData(slotNo, saveBufferMem, bufferSize); @@ -332,7 +332,7 @@ uint32 Sword2Engine::restoreFromBuffer(byte *buffer, uint32 size) { memcpy(varsRes, buffer + sizeof(_saveGameHeader), _saveGameHeader.varLength); #ifdef SCUMM_BIG_ENDIAN - uint32 *globalVars = (uint32 *) (varsRes + sizeof(StandardHeader)); + uint32 *globalVars = (uint32 *)(varsRes + sizeof(StandardHeader)); const uint numVars = (_saveGameHeader.varLength - sizeof(StandardHeader)) / 4; for (uint i = 0; i < numVars; i++) @@ -416,7 +416,7 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) { in->read(&dummy, sizeof(dummy)); delete in; - strcpy((char *) description, dummy.description); + strcpy((char *)description, dummy.description); return SR_OK; } @@ -447,11 +447,11 @@ bool Sword2Engine::saveExists(uint16 slotNo) { */ void Sword2Engine::getPlayerStructures() { - StandardHeader *head = (StandardHeader *) _resman->openResource(CUR_PLAYER_ID); + StandardHeader *head = (StandardHeader *)_resman->openResource(CUR_PLAYER_ID); assert(head->fileType == GAME_OBJECT); - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; // Script no. 7 - 'george_savedata_request' calls fnPassPlayerSaveData uint32 null_pc = 7; @@ -467,11 +467,11 @@ void Sword2Engine::getPlayerStructures() { */ void Sword2Engine::putPlayerStructures() { - StandardHeader *head = (StandardHeader *) _resman->openResource(CUR_PLAYER_ID); + StandardHeader *head = (StandardHeader *)_resman->openResource(CUR_PLAYER_ID); assert(head->fileType == GAME_OBJECT); - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; // Script no. 8 - 'george_savedata_return' calls fnGetPlayerSaveData diff --git a/sword2/sound.cpp b/sword2/sound.cpp index 3723784142..c676ea5e7a 100644 --- a/sword2/sound.cpp +++ b/sword2/sound.cpp @@ -205,7 +205,7 @@ void Sound::queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan) for (int i = 0; i < FXQ_LENGTH; i++) { if (!_fxQueue[i].resource) { byte *data = _vm->_resman->openResource(res); - StandardHeader *header = (StandardHeader *) data; + StandardHeader *header = (StandardHeader *)data; assert(header->fileType == WAV_FILE); diff --git a/sword2/speech.cpp b/sword2/speech.cpp index 80927da502..e15cc9c6ff 100644 --- a/sword2/speech.cpp +++ b/sword2/speech.cpp @@ -87,7 +87,7 @@ void Logic::locateTalker(int32 *params) { if (cdt_entry->frameType & FRAME_OFFSET) { // The frame has offsets, i.e. it's a scalable mega frame - ObjectMega *ob_mega = (ObjectMega *) decodePtr(params[S_OB_MEGA]); + ObjectMega *ob_mega = (ObjectMega *)decodePtr(params[S_OB_MEGA]); // Calculate scale at which to print the sprite, based on feet // y-coord and scaling constants (NB. 'scale' is actually @@ -158,7 +158,7 @@ void Logic::formText(int32 *params) { return; } - ObjectSpeech *ob_speech = (ObjectSpeech *) decodePtr(params[S_OB_SPEECH]); + ObjectSpeech *ob_speech = (ObjectSpeech *)decodePtr(params[S_OB_SPEECH]); // Establish the max width allowed for this text sprite. uint32 textWidth = ob_speech->width ? ob_speech->width : 400; @@ -181,7 +181,7 @@ void Logic::formText(int32 *params) { _vm->_resman->closeResource(text_res); // Set speech duration, in case not using a wav. - _speechTime = strlen((char *) text) + 30; + _speechTime = strlen((char *)text) + 30; } /** diff --git a/sword2/startup.cpp b/sword2/startup.cpp index b6aedf81c1..78b7650ffc 100644 --- a/sword2/startup.cpp +++ b/sword2/startup.cpp @@ -117,7 +117,7 @@ bool Sword2Engine::initStartMenu() { // start list if (_resman->checkValid(_startRes)) { - char *raw_script = (char *) _resman->openResource(_startRes); + char *raw_script = (char *)_resman->openResource(_startRes); uint32 null_pc = 0; _logic->runScript(raw_script, raw_script, &null_pc); @@ -167,8 +167,8 @@ void Sword2Engine::runStart(int start) { } // Open George - char *raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID); - char *raw_script = (char *) _resman->openResource(_startList[start].start_res_id); + char *raw_data_ad = (char *)_resman->openResource(CUR_PLAYER_ID); + char *raw_script = (char *)_resman->openResource(_startList[start].start_res_id); // Denotes script to run uint32 null_pc = _startList[start].key & 0xffff; diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 1e2858cd0f..9daced6548 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -221,7 +221,7 @@ void Sword2Engine::writeSettings() { */ void Sword2Engine::setupPersistentResources() { - Logic::_scriptVars = (uint32 *) (_resman->openResource(1) + sizeof(StandardHeader)); + Logic::_scriptVars = (uint32 *)(_resman->openResource(1) + sizeof(StandardHeader)); _resman->openResource(CUR_PLAYER_ID); } @@ -592,8 +592,8 @@ void Sword2Engine::startGame() { uint32 null_pc = 1; - char *raw_data_ad = (char *) _resman->openResource(CUR_PLAYER_ID); - char *raw_script = (char *) _resman->openResource(screen_manager_id); + char *raw_data_ad = (char *)_resman->openResource(CUR_PLAYER_ID); + char *raw_script = (char *)_resman->openResource(screen_manager_id); _logic->runScript(raw_script, raw_data_ad, &null_pc); diff --git a/sword2/walker.cpp b/sword2/walker.cpp index 102cc7950f..fb7d4bb8b6 100644 --- a/sword2/walker.cpp +++ b/sword2/walker.cpp @@ -250,7 +250,7 @@ int Router::walkToTalkToMega(ObjectLogic *ob_logic, ObjectGraphic *ob_graph, Obj // If this is the start of the walk, calculate the route. if (!ob_logic->looping) { - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(megaId); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(megaId); assert(head->fileType == GAME_OBJECT); @@ -258,7 +258,7 @@ int Router::walkToTalkToMega(ObjectLogic *ob_logic, ObjectGraphic *ob_graph, Obj // call, and will set _engineMega to the ObjectMega of mega we // want to route to. - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 3; _vm->_logic->runScript(raw_script_ad, raw_script_ad, &null_pc); @@ -344,7 +344,7 @@ int Router::faceMega(ObjectLogic *ob_logic, ObjectGraphic *ob_graph, ObjectMega // If this is the start of the walk, decide where to walk to. if (!ob_logic->looping) { - StandardHeader *head = (StandardHeader *) _vm->_resman->openResource(megaId); + StandardHeader *head = (StandardHeader *)_vm->_resman->openResource(megaId); assert(head->fileType == GAME_OBJECT); @@ -352,7 +352,7 @@ int Router::faceMega(ObjectLogic *ob_logic, ObjectGraphic *ob_graph, ObjectMega // call, and will set _engineMega to the ObjectMega of mega we // want to turn to face. - char *raw_script_ad = (char *) head; + char *raw_script_ad = (char *)head; uint32 null_pc = 3; _vm->_logic->runScript(raw_script_ad, raw_script_ad, &null_pc); |