Screenshotting and mapmaking
Screenshotting and mapmaking
I started working on a screenshotting feature.
Currently on a separate branch: https://github.com/NagyD/SDLPoP/commits/screenshot
Inspired by the planned preview feature of Total Pack and the recent update of drawmap
You can use these keys:
* F12: Save a screenshot to screenshot.png.
* Shift+F12: Save a screenshot of the whole level to screenshot.png. (cheat mode only)
Or the command line:
* --screenshot -- Must be used with megahit and a level number. When the level starts, a screenshot is saved to screenshot.png and the game quits.
* --screenshot-level -- Similar to the above, except the whole level is screenshotted.
There are also a few TODOs in the source: https://github.com/NagyD/SDLPoP/blob/sc ... reenshot.c
Opinions? Ideas?
Currently on a separate branch: https://github.com/NagyD/SDLPoP/commits/screenshot
Inspired by the planned preview feature of Total Pack and the recent update of drawmap
You can use these keys:
* F12: Save a screenshot to screenshot.png.
* Shift+F12: Save a screenshot of the whole level to screenshot.png. (cheat mode only)
Or the command line:
* --screenshot -- Must be used with megahit and a level number. When the level starts, a screenshot is saved to screenshot.png and the game quits.
* --screenshot-level -- Similar to the above, except the whole level is screenshotted.
There are also a few TODOs in the source: https://github.com/NagyD/SDLPoP/blob/sc ... reenshot.c
Opinions? Ideas?
Re: Screenshotting and mapmaking
Shift+F12 doesn't seem to work for me, but maybe that's the window manager's fault.
Maybe allow 0 or 15 to screenshot the potions level from the command line?
All in all, a big improvement over drawmap.
It's interesting to see full levels of certain mods.
Maybe allow 0 or 15 to screenshot the potions level from the command line?
All in all, a big improvement over drawmap.
It's interesting to see full levels of certain mods.
Re: Screenshotting and mapmaking
Did you enable cheats?Norbert wrote:Shift+F12 doesn't seem to work for me, but maybe that's the window manager's fault.
I restricted whole-level screenshots to cheat mode: https://github.com/NagyD/SDLPoP/blob/sc ... shot.c#L56
If it's really the window manager's fault, you can change the key here: https://github.com/NagyD/SDLPoP/blob/sc ... 09.c#L2574
I usually use PV3.7 for that, but it displays some unknown tile+modifier combinations incorrectly.Norbert wrote:It's interesting to see full levels of certain mods.
The most annoying example is that closed gates placed by level editors (modifier=0) appear as walls.
(The original levels use modifier=2, and PV3 is prepared only for that.)
Re: Screenshotting and mapmaking
Great feature! I think that options of room numbering and grid on/off are needed.David wrote:I started working on a screenshotting feature
...
Opinions? Ideas?
Please check out this link. viewtopic.php?f=73&t=4027&p=21352#p21352
Re: Screenshotting and mapmaking
Since my last post I added that and much more: https://github.com/NagyD/SDLPoP/commits/screenshotstarwindz wrote: Great feature! I think that options of room numbering and grid on/off are needed.
Re: Screenshotting and mapmaking
Nice.David wrote:Since my last post I added that and much more: https://github.com/NagyD/SDLPoP/commits/screenshot
With level_extras, then level 1 of Prince of Wateria, I had to add "if (events_pos > 256) { events_pos = 256; }" under the first line with events+events_pos to prevent the program from crashing. I haven't really looked into it, but just by looking at the resulting screenshot very high event numbers show up in places without buttons or gates.
Re: Screenshotting and mapmaking
Thank you!Norbert wrote:Nice.
I fixed that now: https://github.com/NagyD/SDLPoP/commit/ ... b6bf165ba7Norbert wrote: With level_extras, then level 1 of Prince of Wateria, I had to add "if (events_pos > 256) { events_pos = 256; }" under the first line with events+events_pos to prevent the program from crashing. I haven't really looked into it, but just by looking at the resulting screenshot very high event numbers show up in places without buttons or gates.
This is quite interesting.
My intention with the now-disabled code was to show event numbers for non-button tiles triggered by certain special events.
(level 1 start, Jaffar death, blue potion)
I wanted that because this was used in the Potions of Delusion mod by Tacosalad.
I re-enabled this for blue potions only: https://github.com/NagyD/SDLPoP/commit/ ... 918ffd852f
What happens is documented by Tacosalad at viewtopic.php?p=12690#p12690 and viewtopic.php?p=12704#p12704
And here is SDLPoP's implementation: https://github.com/NagyD/SDLPoP/blob/ma ... 007.c#L748
(I guess trigger() should be called trigger_button() instead.)
Now, on level 1 of Prince of Wateria, the level 1 start event triggers a gate.
Your intention was to change the state of that gate from permanently-open to temporarily-open.
However, as Tacosalad wrote, this event will also trigger the event specified by the modifier of that tile.
The gate is fully open, which means that its modifier is 188.
Now, event 188 will trigger the next events, up to event 255. These are the event numbers that appeared on the map.
If you watch carefully, some of those events point to a loose floor in room 12.
If you start level 1 of Prince of Wateria with "triggering of any tile" enabled, you'll see that the aforementioned loose floor will fall.
Another triggered tile is a spike in room 16.
As for the crash, it didn't happen to me on either Windows or Linux.
I guess snprintf does not like when its second argument is negative.
Its type is size_t, which means it can't even be negative, so negative numbers will be interpreted as a number around 2^32 or 2^64.
Interestingly, on Windows, snprintf returns -1 if the buffer is too small, which means that events_pos can't possibly grow above sizeof(events).
Re: Screenshotting and mapmaking
So, what happens with blue potions also happens with that level 1 special event?David wrote:What happens is documented by Tacosalad at [...]
I don't remember tacosalad explicitly mentioning this, and, if I understand correctly, you seem to imply it.
I guess it's another thing that could be mentioned in the special events document.
I use a 64-bit distro, maybe that's the difference there.David wrote:As for the crash, it didn't happen to me on either Windows or Linux.
I don't think snprintf was the problem. It was probably one of the char var[~256] things in the code. If "events[256*4]" is something you changed, maybe that's the one that had [~256] and received values beyond 255/256. It's the most common cause of the segfaults that I've seen in my life.
Re: Screenshotting and mapmaking
Exactly.Norbert wrote: So, what happens with blue potions also happens with that level 1 special event?
I don't remember tacosalad explicitly mentioning this, and, if I understand correctly, you seem to imply it.
And the level 13 special event (that triggers the top left tile of room 24) also behaves like that.
I mentioned this briefly here, at level 13, but maybe I wasn't clear enough.
But I *do* think snprintf was the problem, or rather the way I was using it, without overflow checking.Norbert wrote: I don't think snprintf was the problem. It was probably one of the char var[~256] things in the code.
If "events[256*4]" is something you changed, maybe that's the one that had [~256] and received values beyond 255/256.
It's the most common cause of the segfaults that I've seen in my life.
The events[] variable that you mention was 256 bytes long, and that's exactly where snprintf is writing.
What I was trying to say in my last post is about this snprintf call:
events_pos += snprintf(events+events_pos, sizeof(events)-events_pos, .......);
If the remaining space (sizeof(events)-events_pos) is not enough, then snprintf returns how many bytes would be enough, so events_pos will be increased above sizeof(events).
In the next call, events_pos > sizeof(events) which means sizeof(events)-events_pos < 0, so the buffer-size parameter of snprintf will be negative.
But that parameter is an unsigned size_t, so the negative number will be interpreted as a number near 2^32 or 2^64 (because it's stored in two's complement), i.e. there will be practically no limit on the number of bytes that snprintf can write, which in turn will lead to the segfault.
Sorry if my previous post was hard to understand, I hope it's clear now.
Re: Screenshotting and mapmaking
I merged this into the master branch, along with "desktop" and "lighting".
https://github.com/NagyD/SDLPoP/commit/ ... 6d80320439
So now you can even make level maps with lighting, if you want that.
https://github.com/NagyD/SDLPoP/commit/ ... 6d80320439
So now you can even make level maps with lighting, if you want that.
Re: Screenshotting and mapmaking
Done: https://github.com/NagyD/SDLPoP/commit/ ... 5b08089f89Norbert wrote:Maybe allow 0 or 15 to screenshot the potions level from the command line?
It's not limited to screenshotting, however.
Hmm, maybe there should also be an option to start level 0 (demo) without the automatic moves?
Re: Screenshotting and mapmaking
It seems I forgot to show what an annotated level map looks like.
So here is one: You can make such maps in cheat mode with Ctrl+Shift+F12 or the command line parameter "--screenshot-level-extras".
This feature is not yet in the latest official SDLPoP binary (v1.17). I guess it's time to make a new release...
So here is one: You can make such maps in cheat mode with Ctrl+Shift+F12 or the command line parameter "--screenshot-level-extras".
This feature is not yet in the latest official SDLPoP binary (v1.17). I guess it's time to make a new release...
Re: Screenshotting and mapmaking
Still a big request, help with the schematic map of MOD-180 the last level-12 and 13, and than them not to see that.
Last edited by YURA on February 8th, 2018, 3:09 am, edited 2 times in total.
Re: Screenshotting and mapmaking
Re: Screenshotting and mapmaking
Many thanks!
And that I cannot pass the 12th level to save - the princess, I cannot find Jafar. Passed all levels.
I cannot understand where a mistake, but now I will understand. THANKS for the help.
https://youtu.be/oTf8mDJZ5og
And that I cannot pass the 12th level to save - the princess, I cannot find Jafar. Passed all levels.
I cannot understand where a mistake, but now I will understand. THANKS for the help.
https://youtu.be/oTf8mDJZ5og