[v1.7.0+] Virtual Image Reload

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

[v1.7.0+] Virtual Image Reload

#1 Post by Zizzo »

You know how things like the Axe of Fluffy Evil from the Santascape event or the Plumpkin from the Hallowed Fields event sometimes lose their tile images and end up as colored characters like '*' and '/'? Well, I finally got a bug up my proverbial to try to fix that, and I think I've made some progress, which I'm releasing as a new addon, Virtual Image Reload.

So here's the basics of what's happening: the images that these server-push events use are installed as "virtual images", built from data shipped with the event rather than data read from an image file on your computer. It looks like the server events install code that re-installs these virtual images every time you load your character; the problem is that sometimes the game draws the map before those virtual images have been installed, so the Plumpkin image, for instance, isn't there when the map tries to draw the Plumpkin object.

To attempt to fix this, here's what we do when you enter a level (and in theory when you load a game, but that doesn't always seem to work):
  • In core.display.loadImage(), we make a note of any image we try to load that is missing.
  • In core.display.virtualImage(), we check the notes from above to see if we already tried and failed to load this image, and make a note if we did.
  • Then we check every object, actor and terrain on the map to see if it uses any of the virtual images we failed to load, and redraw it if it does.
Now, this is still kind of experimental; in addition to the note above about not always working on game load, we have to flush the entire map tile cache to get it to redraw our virtual images, which might cause some display weirdness. And since this is the sort of addon you might want to add to a character retroactively, I'll include the usual FAQ below about how to do that.

[And for now I'm categorizing this as a bugfix addon, so I'm reluctant to add it to ZOmnibus or ZOmnibus Lite, since we'd have to claw it back out if the bug is fixed later.]

[Implementation notes:

Code: Select all

Hooks:
  ToME:load [to add some hooks into the image-loading code]
  ToME:runDone [to attempt to fix current level when we load game]
Superload:
  mod.class.Player:
    onEnterLevelEnd() [to attempt to fix level on entry]
"Blessed are the yeeks, for they shall inherit Arda..."

Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

Re: [v1.7.0+] Virtual Image Reload

#2 Post by Zizzo »

Frequently Asked Questions:

Looks like I've got this problem. Can your addon fix it?

Probably. If you're in this situation, of course, you presumably didn't have this addon enabled when you created the character, which means you'll need to add it retroactively. Installing and enabling the addon after the character is created generally won't do that; you'll need to a bit of savefile surgery:
  • First, find where your ToME savefiles live:
    • On Linux, this is the directory $HOME/.t-engine/4.0/tome/save/.
    • On Windows, this is the directory %userprofile%\T-Engine\4.0\tome\save. [h/t Moasseman]
    • On Mac, in the Finder, select "Go to" ⇒ Library ⇒ Application Support ⇒ T-engine ⇒ 4.0 ⇒ tome ⇒ save. [h/t Lakeere]
  • In this directory, there should be a folder named for your character, and in that folder there should be a file named "desc.lua". Open that file with your favorite text editor.
  • The file will have a line of the form "addons = { … }", listing the ID tags for all addons that are enabled for this character. You'll want to add this addon's tag, "virtimg", to that line; the necessary syntax should be clear.
  • Save this change and re-run ToME. In the Load Game dialog, check that the "virtimg" tag you just added is present and green in your character's addons list (if it's red, either you misspelled the tag or you haven't actually installed the addon).
  • Load the game. If there were entities without images on the level, they will hopefully have been fixed; if not, you may need to leave and return to the level, or in extremis, leave the level, save/reload and return to the level (We Apologize for the Inconvenience™). If none of that worked, let me know on this thread and I'll try to figure it out.
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply