void add_dynamic_sprite(int gotSlot, Bitmap *redin, bool hasAlpha) { spriteset.set(gotSlot, redin); game.spriteflags[gotSlot] = SPF_DYNAMICALLOC; if (redin->GetColorDepth() > 8) game.spriteflags[gotSlot] |= SPF_HICOLOR; if (redin->GetColorDepth() > 16) game.spriteflags[gotSlot] |= SPF_TRUECOLOR; if (hasAlpha) game.spriteflags[gotSlot] |= SPF_ALPHACHANNEL; spritewidth[gotSlot] = redin->GetWidth(); spriteheight[gotSlot] = redin->GetHeight(); }
void free_dynamic_sprite (int gotSlot) { int tt; if ((gotSlot < 0) || (gotSlot >= spriteset.elements)) quit("!FreeDynamicSprite: invalid slot number"); if ((game.spriteflags[gotSlot] & SPF_DYNAMICALLOC) == 0) quitprintf("!DeleteSprite: Attempted to free static sprite %d that was not loaded by the script", gotSlot); delete spriteset[gotSlot]; spriteset.set(gotSlot, NULL); game.spriteflags[gotSlot] = 0; spritewidth[gotSlot] = 0; spriteheight[gotSlot] = 0; // ensure it isn't still on any GUI buttons for (tt = 0; tt < numguibuts; tt++) { if (guibuts[tt].IsDeleted()) continue; if (guibuts[tt].Image == gotSlot) guibuts[tt].Image = 0; if (guibuts[tt].CurrentImage == gotSlot) guibuts[tt].CurrentImage = 0; if (guibuts[tt].MouseOverImage == gotSlot) guibuts[tt].MouseOverImage = 0; if (guibuts[tt].PushedImage == gotSlot) guibuts[tt].PushedImage = 0; } // force refresh of any object caches using the sprite if (croom != NULL) { for (tt = 0; tt < croom->numobj; tt++) { if (objs[tt].num == gotSlot) { objs[tt].num = 0; objcache[tt].sppic = -1; } else if (objcache[tt].sppic == gotSlot) objcache[tt].sppic = -1; } } }