The Dink Network

Updated File: Windinkedit Plus 2.5 (source code included)

December 7th 2022, 06:01 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
RW has miraculously re-emerged out of the void, proving that no one can escape the DN. He brings offerings in the form of an updated version of Windinkedit Plus 2.

The source has also been graciously provided, uploaded as a separate file.

See the list of changes/updates below.

- Automatically detect FreeDink, Dink HD, and classic Dink
- The Dink installation to use is more granularly configurable
- Run successfully without administrator mode
- Screenmatch duplicate sprites are now marked with a red outline, and are picked up together (Shift+M)
- Stuff is now drawn with SDL instead of DirectDraw, resulting in better performance
- A couple settings used to not be saved properly, this is now fixed
- Some small UI improvements
- Fixed a few bugs, added new ones... you know, the usual.

December 7th 2022, 06:56 AM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 


Improvements too?! This was completely unexpected!
December 7th 2022, 08:58 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
Oh hi.

Let me spoil the miracle: y'all can thank drone1400 for this one. He contacted me over email in August, asking if I still had the sources for WDE+2. So I patched them up a bit, and now here they are!

Although it is mentioned in the description too, I think it's worth repeating the fact that I've also put the entire history of the WDE+2 source code into a git repo at https://gitlab.com/rudolfwg/wdep2 in case anyone is interested in that for some reason.

If you do end up messing with the code, here's a small historical note for you. I worked on this at 3 distinct points in my life. In 2011/2012 I was a complete C++ noob, and because I came from a C and C# background, lots of stuff I did might make you question my sanity. In 2016 I was a complete C++ addict, and in the code I wrote in that period you'll find some advanced C++ trickery that might make the "modern C++" fanboys wet their panties, but will definitely induce nausea in anyone else. Finally, in 2022 (aka just now), I concentrated on fixing the biggest problems I could think of, but had no time or desire to make structural improvements to the code.

Fair warning! This is still the same old clunky WDE we all love/hate. It will probably still crash and corrupt your files, so do keep backups while working on a dmod. If you find things that don't work, or notice that some action causes a crash, feel free to post about it here (or post an issue on the gitlab, if you really want to). I can't promise I'll fix any of it, but in case I don't, someone else should now be able to.

Happy dmodding!

PS
Robj, could you edit the release notes of the executable so the bullet points don't all wash together onto one line? Take a look at the older versions and you'll see what I mean.
December 7th 2022, 07:57 PM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
No worries, I will fix the bullet point issue tonight when get I get home from work.

EDIT: done.
December 8th 2022, 12:17 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
Very cool! Is anyone else have intermittent crashes when either rendering the map or picking sprites on D-mods that use fastfiles, or is it just me?
December 8th 2022, 01:40 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
Yeoldetoast, if you can tell me which dmod(s) you are experiencing this with, I can try seeing if it happens to me too. Also, which version of Dink?

I've done most of my testing with island (on Dink 1.08), so I can totally imagine that there might be edge cases I missed.
December 8th 2022, 04:03 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
Thanks RW, but unless someone else comes forward I have to assume whatever issues I am having are solely relegated to my crappy old PC. For whatever reason, upon loading "The Spy Number 13" or "Milderr", I am greeted by this in the logs before it can display anything despite Jesus Island and Charlie's Legacy being fine:

ERROR: SDL failed to get a vertex buffer for this Direct3D 9 rendering batch!
ERROR: Dropping back to a slower method.
ERROR: This might be a brief hiccup, but if performance is bad, this is probably why.
ERROR: This error will not be logged again for this renderer.
'WinDinkEditPlus2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\comdlg32.dll'.
Exception thrown at 0x7551C5AF in WinDinkEditPlus2.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x002BBE68.

With a backtrace of:
>	WinDinkEditPlus2.exe!Minimap::updateHoverPosition(int x, int y) Line 259	C++
 	WinDinkEditPlus2.exe!mouseMove(int x, int y) Line 880	C++
 	WinDinkEditPlus2.exe!CWinDinkeditView:  nMouseMove(unsigned int nFlags, CPoint point) Line 201	C++
 	SDL2d.dll!WIN_WindowProc(HWND__ * hwnd, unsigned int msg, unsigned int wParam, long lParam) Line 1636	C
 	WinDinkEditPlus2.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 26	C++



I also tried with a few different Dink datasets including one comprised entirely of BMPs and it still crashed, so it's unlikely to be fastfile-specific after all. In this case, I used the Dink "HD" 1.99 dataset.
December 8th 2022, 07:01 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
Anything edited with freedinkedit (even if you open a dmod and quit+save in freedinkedit), crashes when you try to then open it with windinkeditplus 2.5.

But then again I always thought freedinkedit might be bugged or something. Because the previous version of windinkedit has it's own issues with dmods saved in freedinkedit. It opens them, but most of the tile hardness is gone. Does freedinkedit save hardness in a weird way that makes windinkedit plus not be able to read it (and maybe this is causing windinkedit plus 2.5 to just reject it and crash)? If you save the dmod in windinkedit plus with the tile hardness gone, it saves the dmod in that state and then it's even gone in freedinkedit. So a problem with freedinkedit or a problem with windinkedit. I don't know.
December 8th 2022, 07:31 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
Ok, I was able to find and fix the stuff you brought up so far.

The four "ERROR:" lines are not actually an error. I see them too, they come from SDL's internals, everything seems to be working anyway, so I don't care.

Loading spy13 was crashing because it was failing, and failure to load the dmod was crashing because of the accursed Windows message loop and all the devils who made me shove MFC and SDL together!!
Ahem. I fixed it, I think. Maybe.

Loading spy13 was failing because it has a hard.dat that doesn't include the last 128 garbage bytes at the end. Based on what Robj is saying, I presume this is FreeDinkedit's work? I made WDE+2 not look for those unused bytes, but I'll let you folks try out other FreeDinkedited dmods to see if this fixed all of them or not.

I had no problem loading Milderr, but I did find a crash in it when picking up a specific kind of sprite. I made a fix.

I also found and fixed the crash that happened when rendering the minimap of some dmods.

Pls take the updated beta version from here and lmk what new issues you find in it.
December 8th 2022, 09:15 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
Thanks! It works now.

> So a problem with freedinkedit or a problem with windinkedit

Freedinkedit writes strange bytes in some cases, but I believe the discrepancy is in Beuc's (bad) calculation of how many tiles in total there are across all tilescreens. I'm guessing that WDE assumes there are 5248 slots in Hard.dat's screen tile association index, whereas Freedink only bothers going up to 5216 which accounts for the "128 bytes of junk data", which are in fact the difference in total slots ((5248 - 5216) * 4). WDE and its ilk most likely just give up reading the file if not all 5248 are present and decide to delete everything as a result. Nominally, there are 8000 slots in hard.dat's tile index, but neither editor appears to pad it out to the full size. In conclusion, it's both!
December 8th 2022, 02:01 PM
pq_cthunik.gif
GOKUSSJ6
Peasant He/Him Poland
Everyone should get a pizza for free in each week. 
Ran the software in Wine and turns out it will crash during map rendering or when i select a screen to edit.
December 8th 2022, 03:44 PM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 
By the way, RW, since you're here and willing to make slight changes, I wanted to mentions something. I was talking with Robj on discord the other day, and he brought up two issues, dunno if you two talked about them or not, but I figured I'd mention them here too. I quote exactly as he phrased it:

>One of the things I don't like about windinkedit plus 2 is you can't set a fake brain number. You can't manually input your own brain value cause it's a drop down menu forcing you to choose a valid brain number from 1 - 17.
Fake brains are incredibly useful. I used them heaps in Charlie. They can be set via scripting, but sometimes you want the fake brain to be able to be detected instantly on screen entry before anything visual takes place. So for this I had to use FreeDinkEdit since that allows you to input any number for the brain.


>Also windinkeditplus calculates sprite sizes incorrectly or something, or rather the location they should be when the size is different. If you shrink a sprite down and place it in the editor, and then look at it in the game, it's in a different position than the location represented in the editor. I'm not sure how it's supposed to be handled, but windinkeditplus definitely has it wrong.

Also, I have a slight suggestion of my own.

You might know how in DMODs that feature "lanterns", a HUGE pitch black sprite is used with some transparent area in the middle, and that just follows Dink around when he walks.

Anyway, I have no idea how Rob and others handle it, but I find them very annoying in the editor, since they cover the whole screen. So my idea was, if you could add a hotkey / toggle options in tools, that when activated, hides sprites with a user defined sprite sequence ID (defined by a text field in the options window). That way, when editing a screen with a "darkness" sprite, you could just toggle that off to make changes to that screen.
December 9th 2022, 01:17 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
GOKUSSJ6, does that happen with the "official" 2.5 or the little beta version I linked further down in the thread? If it's 2.5 then please try the beta. If the beta also crashes, then please tell me which dmod this happens with (or does it happen with all of them?).

drone1400, I only ever talked to people here. If you think it would help, I can join the discord too.

Re brains: I was aware of this problem, but my laziness was hoping you wouldn't ask... oh well. Should be doable.

Re sprite sizes: I'm not surprised about that... I've seen both the dink engine code and the WDE code related to sizing and trimming in the past. Ugh. It's not impossible to fix, but boy is it going to be annoying. No promises about this one.

Re hiding sprites: a simple version of that sounds doable.
December 9th 2022, 03:20 AM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 
>Re sprite sizes: I'm not surprised about that... I've seen both the dink engine code and the WDE code related to sizing and trimming in the past. Ugh. It's not impossible to fix, but boy is it going to be annoying. No promises about this one.

Don't worry about it, I don't mind looking into that myself, although my knowledge of C++ is rather limited, I like investigating how things work and this seems like something I'd enjoy doing hah.

Btw, the other day I managed to get the project built using Jetbrains Rider and MSVC v142 and it seemed to work fine... But that's all I did, I didn't actually look into if JBR actually has any tools for helping with MFC design?... (I imagine VS does?)
December 9th 2022, 11:02 AM
pq_cthunik.gif
GOKUSSJ6
Peasant He/Him Poland
Everyone should get a pizza for free in each week. 
@RW
Tried both of em, used on 3 DMODs so far such as Charlie's Legacy, Dink's Christmas Adventure and a random one like Baywatch Isle. They all crash during map rendering or i try to edit a screen.
December 9th 2022, 03:10 PM
pq_knight.gif
ExDeathEvn
Peasant He/Him New Zealand rumble
"Skinny Legend" 
Regarding the Lantern Shadow sprite and Charlie's Legacy, we planted them in the editor deliberately. They are easy to move/delete when we want to modify the screen, and we can set the depth dot to ridiculously low values so they stay under all sprites in the editor but get reset to max in-game via script.
It also clearly defines dark areas. Or hides stuff we don't want cheaters to find by map-editor diving.
December 11th 2022, 07:52 AM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 
Ah, alright then, that makes sense nvm then
December 19th 2022, 10:37 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
Howdy again folks; I've been traveling last week, hence the silence.

drone1400, Robj,
I made it possible to set a custom brain number. I uploaded the result as a new beta to the same place. If y'all try it out and don't find issues with it, I'll probably upload this to the DN as well, as version 2.6, later.

GOKUSSJ6,
I tried running the new WDE in Wine. Specifically, I used Wine 6.0.3 on Ubuntu 22.04, with the latest version of DinkHD also installed in Wine. For me, this combination does not crash, but fails to draw anything at all by default (and I have no idea if that can be fixed). However, if I set the SDL_RENDER_DRIVER=software environment variable (to make WDE use software rendering instead of DirectX), then it works. I'm able to render the minimap in both Charlie's Legacy and Dink's Christmas Adventure.
I'm not sure what's different between your setup and mine... Wine version? OS? Different version of Dink? ... but in any case, it's not impossible to get it working.
December 19th 2022, 12:10 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
@RW & GOKUSSJ6:

What version of Windows did you ask Wine to emulate? Although I have tried none of the more recent .exe files generated for Dink stuff in the last few months, I get pretty good results for these versions of the relevant .exe files using wine-6.0.3 emulating a WinMe 32 bit environment on Ubuntu 22.04. I have not had good results with DinkHD in this environment though.

354176 Jun  5  2018 ./.wine32/drive_c/Program\ Files/Dink\ Smallwood/dfarc3.14.exe
103808 Dec 13  2015 ./.wine32/drive_c/Program\ Files/Dink\ Smallwood/WinDinkeditPlus2.exe

315392 Feb 25  2006 ./.wine32/drive_c/Program\ Files/Dink\ Smallwood/dink.exe
139264 Feb 25  2006 ./.wine32/drive_c/Program\ Files/Dink\ Smallwood/dinkedit.exe

December 19th 2022, 03:10 PM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
I used whatever the defaults are. If winecfg can be trusted, then that's Windows 7.

Basically I just installed a fresh Ubuntu 22.04 in a virtual machine, and then:

# install Wine
sudo apt update
sudo apt install wine wine32 win64

# install DinkHD
wine Downloads/dink_smallwood_hd-1_99.exe

# I run DinkHD in windowed mode so it doesn't mess things up
wine 'C:\blah\dink.exe' -window

# I run WDE with software rendering so it works
SDL_RENDER_DRIVER=software wine WinDinkeditPlus2.exe


DinkHD seems to run without issues for me... well, I haven't tried it for long, but I'm able to use it to download dmods, and also to play Dink and dmods from what I can tell.
December 20th 2022, 06:14 PM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 
Hey RW, I'm dropping by to say that I am an absolute dumbass and didn't realize your git had the SDL static library files too. Yesterday, I was messing with building WDEP2 and wanted to static link SDL2. I thought I had to build it myself, and having never done such a thing before, I spent a few hours fumbling about and failing - It would build fine, but when I tried to use the static lib I built in WDEP2, I'd get some weird errors about missing external symbols related to PLATFORM_hid_enumerate and SDL_IsXInputDevice.. In the end I got it to work, but it seems I had to disable SDL_XINPUT, SDL_HIDAPI and SDL_HIDAPI_JOYSTICK to get the static library to work with WDEP2.

But anyway, today I got the code from the git and I see that pretty much just works (tm). I saw that you already took care of the Brain selection thing. Anyway, I want to look into the whole sprite scaling thing RobJ mentioned...

Edit: D'oh! I just now saw your post from a couple of days ago where you literally said you implemented the Brain thing.
December 20th 2022, 11:37 PM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
For an easy time building, to get the above traceback with a debug exe, I installed SDL2 through vcpkg and got rid of the reference to the static library in VS and did it as a shared build instead with a single resultant DLL. RW has also turned off certain things in cmake which are probably causing those errors, but also has a mysterious alt-key patch which you miss out on when building the way I did.
December 21st 2022, 08:43 AM
sob_scorpb.gif
RW
Peasant He/Him Romania
Thankfully, my brain is rewritable. 
>didn't realize your git had the SDL static library files too

Yeah, I excluded the lib files from the zip I uploaded here because I wanted to keep the size down. But now that you mention it, I should have probably included at least the note.txt files, and maybe some additional instructions too.

>having never done such a thing before, I spent a few hours fumbling about and failing

If you want any help with this, or C++, or the WDE source code in general, feel free to ask. We can chat about any of those over discord or something.

>also has a mysterious alt-key patch

Yeah, SDL eats Alt+stuff chords, so eg. you can't open the File menu with Alt+F, which is something I do a lot. The patch fixes that. I also opened a pull request to SDL to make this configurable at runtime... I hope it'll land in SDL 2.28.
December 22nd 2022, 03:53 AM
goblins.gif
drone1400
Peasant He/Him Romania
C# nerd 
>If you want any help with this, or C++, or the WDE source code in general, feel free to ask. We can chat about any of those over discord or something.
Hah, I'll probably take you up on that offer. I basically never really did anything in C++ before.

In uni and at work I worked with C for AVR microcontrollers, and then at work I got mainly into C# and WPF.

I've just started messing around with C++ and MFC. My only issue is, having mainly used JetBrains Rider for the past year, I've kind of started to hate Visual Studio now... It's just so slow compared to JBR and even CLion, when searching for something solution wide, JBR is basically instant even for a massive solution with over 70 projects, while VS keeps you waiting like it's larping as Snake from Metal Gear...

Edit: BTW, before you actually posted the source, the whole saving config files in the windows directory got so annoying for me[*] that I started looking into x86 assembly and tried hexediting function calls to make it store config files in a local folder. Basically my idea was to replace GetWindowsDirectory calls with GetCurrentDirectory calls, since they were quite similar. The function call swap approach turned out to have some other issues. In the end, I ended up hexing away some constant string defintions to achieve the same result, since it was easier.

* - I honestly don't know how DMOD makers have been dealing with that without whining about it all day