void CSprite::free() { assert(this); CImage *image = this->images.head; while (image) { CImage *nextImage = image->link.next; image->free(); image = nextImage; } const int y = CLAMP(this->position.y / 32, 0, mapTileSize->height - 1); const CListExtern<CSprite, &CSprite::link> spritesOnTileRow(spritesOnTileRow->heads[y], spritesOnTileRow->tails[y]); spritesOnTileRow.unlink(this); unusedSprites->insertAfterHead<&CSprite::link>(this); }
void CImage::free() { assert(this); if (!(screenLayers->game.hasBeenRefreshed)) scbw::refreshScreen(this->screenPosition.x, this->screenPosition.y, this->screenPosition.x + this->grpSize.right, this->screenPosition.y + this->grpSize.bottom ); CSprite* const parent = this->parentSprite; const CListExtern<CImage, &CImage::link> imageList(parent->imageHead, parent->imageTail); imageList.unlink(this); this->grpOffset = NULL; unusedImages.insertAfterHead(this); }
void CSprite::setPosition(u16 x, u16 y) { assert(this); if (this->position.x == x && this->position.y == y) return; const int oldTileY = CLAMP(this->position.y / 32, 0, mapTileSize->height - 1); const int newTileY = CLAMP(y / 32, 0, mapTileSize->height - 1); this->position.x = x; this->position.y = y; if (oldTileY != newTileY) { const CListExtern<CSprite, &CSprite::link> spritesOnOldTileRow(spritesOnTileRow->heads[oldTileY], spritesOnTileRow->tails[oldTileY]), spritesOnNewTileRow(spritesOnTileRow->heads[newTileY], spritesOnTileRow->tails[newTileY]); spritesOnOldTileRow.unlink(this); spritesOnNewTileRow.insertAfterHead(this); } for (CImage *i = this->images.head; i; i = i->link.next) i->flags |= 1; }