PDA

View Full Version : Next Generation SHP Viewer


MarkSheppard
October 9th, 2024, 10:15 PM
So; this is something I knocked out over a few hours with ChatGPT + Fred Chlanda's old SHPEd code that he released decade(s) ago.

You might be wondering "Where's the file? Where's everything?"

Everything is contained in that HTML file; you can open it up; it's only 275 lines of code to inspect (of which 40 are used to define the SPCAMO palette).

https://i.imgur.com/V6lAvWk.png

A lot has changed over the last 15 years -- web browsers have become standardized multi-purpose machines with Javascript + HTML5 elements -- there was some early tentative steps this way back with Panzer Command and a scenario generator/editor that used Internet Explorer; but it was the early days of that and it quickly broke with the advance of the internet.

But now that things have standardized, as long as you don't attempt to do anything too crazy; HTML5 code will last a long(er) time (hopefully).

Right now; this is just a "proof of concept" to prove that you can read SHP files and display them graphically in a Chrome-based browser (which is everything nowadays). I've tested it in Chrome + Edge and they both work.

Potential future work:

1.) Integrating the Master Icon Lists so that you know right away what something is without having to cross check.

2.) Figuring out how to dump the SHP icon files with their header data included so that you can easily import them into other SHP files and everything automagically updates.

3.) Integrating other Palettes (and option of loading your own JASC PIC PAL file)

But for now I'm just going to sit back and see what shakes out of this -- the biggest advantage of this primitive v0 is that you now can use a modern Windows dialogue/file path box, allowing cut and pasting of your SPCAMO path instead of having to navigate up down the file tree to it.

DRG
October 10th, 2024, 08:31 AM
As a simple SHP viewer, it is faster than ShpEdit to call up a SHP file but that is all it is for v0.00.

I see the potential is there to be more though

MarkSheppard
October 12th, 2024, 09:51 AM
Version 0.00L

Major Changes:
I've started to separate major things into individual javascript .js files to keep things organized -- this was needed for the 146kb of palette information I added.

Also; there's a third-party javascript library - jszip (NextGenSHP_Viewer_jszip.min.js) included to handle ZIP functionality within the program.

What's new:

There's an option to organize in rows of 2 (to make turreted SHP files look more organized)

https://i.imgur.com/vXBmOUR.png

I hard coded as many palettes as I could in -- including all of the original PALs that shipped with Fred's SHP Edit many moons ago. Default is the current (2021+) SPCAMO full icon palette.

To Swap palettes or organize in rows of 2, select your new palettes or click on the organize in rows of 2 checkbox and then push the RELOAD button.

To save an individual icon; just right click on any of the icons and choose SAVE IMAGE; a PNG version helpfully named:

{filename}+{4 digit leading icon position}.png will be downloaded to your DOWNLOAD directory.

So if you were saving the second icon from a file named icon0090.shp, it would be named: icon0090-0002.png

The Export SHP to ZIP button dumps all the SHPs using that above terminology into a new zip file in your download directory; named after the original SHP file. Thus, if your file was icon0090.shp, the file will be icon0090.zip.

Also, there will be a metadata CSV file inside the zip file -- containing the following information

DRG
October 13th, 2024, 08:15 AM
The default palette for viewing game Icons should be the Icon only palette NOT the full palette

The "Organize in two rows for Turreted Vehicles" is a nice touch

MarkSheppard
October 13th, 2024, 03:10 PM
The default palette for viewing game Icons should be the Icon only palette NOT the full palette

Version 0, Ausf M changes to that as teh default palette.

NOTE: I had to add a password - SPCAMO - to the zip file to upload it; because the forum upload software kept blocking it.

There's a bunch of new features here:

You can now load SHP files contained within ZIP images, or from a folder on your hard drive; with the option to load all, or just the icon SHPs.

https://i.imgur.com/KxI1F2Q.png

This was a direct load of the exact ZIP file contained in this post

https://forum.shrapnelgames.com/showthread.php?t=52719
P-51D, F-51D, Cavalier, Piper Mustang evolution after WW2

Making it easier to evaluate mods that are posted on the forum.

Using the "load entire folder; only for icon files" feature is considerably faster on:

WW2\Game Data\Graphics
than it is on
MBT\Game Data\Graphics

It takes a while (a couple minutes) to load all 11,200 or so icons for MBT :shock: but there is this nice surprise at the end for you at Icon0196.shp:

https://i.imgur.com/OkYvZwV.png

FYI, total memory use for that Chrome tab with every single MBT icon loaded was 392~ MB; something easily afforded today.

There's a revised right click dialog for hovering over individual SHP icons:

https://i.imgur.com/pLgNwKX.png

Copy to Clipboard saves it as a paint shop pro compatible cut and paste image.

Save Image as PNG is slightly obvious -- it saves it in this case as Icon0105-0002.png (2nd icon slot in ICON0105.SHP).

Export SHP to ZIP works, even for an entire MBT icon folder run through -- as before, it works a bit slow; but eventually coughs out the file -- in that specific use case, a 17.3 MB file containing 11,199 individual PNG files :shock:

DRG
October 13th, 2024, 04:17 PM
.............there is this nice surprise at the end for you at Icon0196.shp:

https://i.imgur.com/OkYvZwV.png



I wondered when someone would notice that <G>

DRG
October 13th, 2024, 04:27 PM
be very careful about loading entire folder folders!


YEP


There are a LOT of Icons

What is nice from my POV is if a section needs a closer look a simple "print screen" on my keyboard picks them up which is what I can do with ScenHack now but this picks up in bulk

:up::up:


I've even found things I had forgotten were there!

MarkSheppard
October 14th, 2024, 10:00 PM
Version 0, Ausf P

NOTE: I had to add a password - SPCAMO - to the zip file to upload it; because the forum upload software kept blocking it.

There's a bunch of new features here:

https://i.imgur.com/MwHO9Ut.png

Scaler -- scale the icons by 1x, 2x or 4x; because we're all getting old. I was a teenager when SP2 was released and you can guess my age now. Also, a zoomed in option lets you inspect icons carefully now.

Draw SP Header Cross-- Graphically represent the "centroid" of the icon as put in the SHP header and editable through
SHPEd's "Fix SP Header".

An example of how you can combine the SP Header Cross and 2x Zoom/Scaleup is this one:

https://i.imgur.com/hDkHGoc.png

NOTE This software is a bit non-idiot proof - in that there's no internal checks on saving/exporting when you have higher zoom levels (2x or 4x) or the SP Header Cross selected -- it will happily export the scaled up images or the header cross images -- so always doublecheck to see if you're in 1x mode and that cross checkbox is unchecked....

The right click menu is slightly changed:

https://i.imgur.com/QXdNcSj.png

You can now dump a single image, two images (for turreted icon slots), and "n" amount of images (if you want to dump 3 turreted images, you'd put in 6).

MarkSheppard
October 14th, 2024, 10:12 PM
One of the things I need to do next is to systematically validate the image decompress routines by comparing SHPEd BMP images with the PNG images generated by this; to ensure that pixel values are correct; because if they're off slightly; errors can start compounding if this is used as an alternative for MOBHack + Print Screen + Paint Shop Pro; and somewhere there's a bug making pixel values off slightly.

RecruitMonty
October 15th, 2024, 11:21 AM
What a good idea.

DRG
October 15th, 2024, 03:09 PM
How close do you think you are to allowing Icons to be added?

MarkSheppard
October 15th, 2024, 06:06 PM
Probably a week or two. I tried adding SHP recompression capability; but it wasn't quite there; lots of errors and corrupted data; so I shelved that for the time being to work on usability improvements.

Latest usability improvement I whipped up this morning was to add the option for icon slot #s to be drawn onto icons:

https://i.imgur.com/tPCw4GX.png

MarkSheppard
October 15th, 2024, 09:37 PM
Perhaps longer. I wasted a few hours; and I'm at my wits end here. It's easy to READ something; because you can take hacks and shortcuts; but if you want to write it into a correct compatible format... :cold:

DRG
October 16th, 2024, 01:52 PM
Take a break. Go do something else for awhile. Trust me it can help

DRG
October 16th, 2024, 01:58 PM
This may be what you are trying to do or it might be impossible but for me a great way to add icons into a Shp file would be drag and drop the image into where I want to put it in the SHP file then click on where I want the crosshairs to be to center the two parts ( if there are two parts )

DRG
October 16th, 2024, 02:01 PM
...and as you noticed in post #12..... I don't always use the standard 89x89 image size because with SHPEdit I don't have to but most things are just out of old habits

DRG
October 16th, 2024, 02:04 PM
......and in case you didn't know.... the game and Fred sometimes built code that counted from zero and sometimes counted from one............ this is why SHPEdit reports the image as 88x88 when it is actually 89x89

MarkSheppard
October 17th, 2024, 06:29 PM
This may be what you are trying to do or it might be impossible but for me a great way to add icons into a Shp file would be drag and drop the image into where I want to put it

My first try at adding image replacement capability was to simply right click on the icon slot you wanted to use; select REPLACE and then choose replacement image using the system file dialog.

in the SHP file then click on where I want the crosshairs to be to center the two parts ( if there are two parts )

That was close to my concept as well; I think I can easily make a SHP Header editor; since you can edit header data without having to touch the compressed SHP files.

MarkSheppard
October 17th, 2024, 09:45 PM
I've been working at refactoring the program some more; and I've discovered that it probably does not implement the SHP RLE logic correctly -- it does it well enough to pass with SPCAMO files; but when I throw age of rifles (AOR) or Panzer General (PG) SHPs at it; it starts coughing.

This is probably why when compression is reversed; it's not doing it correctly.

lukerduker123
October 18th, 2024, 01:27 AM
Lol this came out AFTER I finished adding all the icons to my mod. For real though, given this runs in browser I'm incredibly impressed. Here I was thinking my browser was only good for playing youtube and browsing Battletech (And Steel Panthers) forums. Good job, I can't wait to see this thing fully fleshed out!

MarkSheppard
October 18th, 2024, 09:12 PM
I think I may have finally generated correct working SHP decompilation code. It correctly renders a lot of stuff including AOR and PG SHPs which did not render correctly before.

EDIT: It all comes down to the SHP header data.

xStart and yStart in the SHP Icon Headers are irrelevant in Steel Panthers; because everything always begins in the upper left corner of the SHP file, whether it's a screen image, button, or unit icon.

But in Age of Rifles; because of the extensive use of paperdolls with multiple SHP images overlaid over each other; some way of "offsetting" x/y had to be done:

https://i.imgur.com/oyPvUWB.png

AHA!

It's because Steel Panthers uses the xStart and yStart SHP header variables differently than other SSI programs -- in Steel Panthers, this is used to place the turret and hull offsets to place icons centered on the battlefield.

I need to go look deeper into Fred's code; to see if he had any flags that recognized a Steel Panthers SHP image and treated it differently than a "regular" SSI SHP

EDIT: I figured it out.

SHPs that are used in transparent "paper dolls" have POSITIVE numbers for xStart + yStart.

SHPs that use xStart + yStart to store centroid information for turret placement are NEGATIVE numbers; and this is how SSI differentiated between them, while maintaining compatibility

DRG
October 19th, 2024, 07:34 AM
Great news. This all sounds very promising .

MarkSheppard
October 21st, 2024, 07:31 PM
Still haven't cracked the SHP recompression code; but I'm close to cracking the SPHeader fix code.

As requested, you can double click on the location to get into the gross area of where you want your new centroid to be; and then use the +/- buttons to dial in the exact location.

The "write header to all icons" is for when you have a massive collection of 40 x P-51 mustang icons in that SHP and they all have the same basic centroid.

EDIT: Further work will have to wait for later; everything here so far is a proof of concept working on a massively kludged system; I have to go back and refactor more code to make storing/editing the new header data easier and actually doable.

https://i.imgur.com/iHVqYbz.png

DRG
October 21st, 2024, 09:18 PM
; everything here so far is a proof of concept working on a massively kludged system

Funnily enough if it was not for kludges made to work the game would not exist:D

MarkSheppard
October 22nd, 2024, 09:31 PM
Here's version 0.80 -- chosen because it's 80% of the way there; that last 20% will be probably quite difficult.

As before, the password is SPCAMO.

Changes with this version:

1.) More accurate SHP file decoding than previous versions.

2.) You can now edit SP Header files; either by typing in the data yourself, double clicking on the general area you want the centroid to be, and/or using the buttons to fine tune the centroid placement.

BIG NOTE: Currently, the SP Header edit (right click and choose SHOW ICON SP HEADER DATA) has options that are not data friendly.

For example, we have

Write Header to this Icon
Write Header to 'N' Icons
Write Header to This + Alternating Icons

Buttons.

The last two are "extras" to make writing 35 icons of the same exact type (i.e. 35 versions of the same P-51D Mustang) simpler and save you time.

The current implementation when it's used for write header to 'N' icons just copies the "bounding box" -- the last two variables in the SHP header -- xEnd and yEnd -- from the icon in the pop up menu to the next 'N' icons.

It works great if the bounding boxes (i.e. rightmost+bottom-most pixel that is not transparent) are the same. But what happen if the bounding boxes are not the same; i.e. we take the bounding box from a hull icon and paste it over a turret icon?

https://i.imgur.com/PJlquo7.png
(Image from SHPEd)

Yeah, that happens.

I need to revise (in the future) the "paste into N" buttons to include a 'recalculate bounding boxes on the fly' function to eliminate this possible failure mode.

But I wanted to get this out for input and testing.

MarkSheppard
October 22nd, 2024, 09:47 PM
Sharp eyed people may notice a "Replace SHP Image" option in the right click menu that has functionality that lets you select images to replace an existing SHP icon with.

You can then set the replacement SHP image's header with SHOW SHP HEADER DATA.

What's remaining to do is the last major hurdle -- trying to figure out how to get this thing to do correct SHP compression and then reassembly so that the Replace SHP Image is actually useful, and not just a tech demo.

DRG
October 22nd, 2024, 10:05 PM
In the viewer I was able to add a new BMP into a tester SHP file I have in the folder with the viewer.

I was able to adjust the X/Y coordinates to center where I wanted the tester hull in the file

But

When I viewed the full file the number of that Hull was gone as was the crosshair I had centered inside the turret ring

https://forum.shrapnelgames.com/attachment.php?attachmentid=17063&stc=1&d=1729648656

I can see the result of the changed header but I could not find a way to save the file with the new hull

Is that what you see or did I miss something?

As you say not 100% yet but it is very interesting

MarkSheppard
October 22nd, 2024, 10:17 PM
Re: being unable to download file with images in them -- the SHP compression logic necessary to actually download a SHP file with the new images isn't there yet.

I was a little bit ahead of myself here.

To edit headers; this is the procedure:

1.) Right Click on image you want to edit header for and select SHOW ICON SHP HEADER DATA.

3.) Move the Centroid Cross to where you want it through double clicking or using the X/Y buttons.

4.) Push "Write Header to this Icon" button.

5.) Close pop up window.

6. ) Click on Rewrite Headers to SHP to download a SHP file with just the headers edited.

DRG
October 23rd, 2024, 04:49 AM
Re: being unable to download file with images in them -- the SHP compression logic necessary to actually download a SHP file with the new images isn't there yet.

I was a little bit ahead of myself here.

To edit headers; this is the procedure:

1.) Right Click on image you want to edit header for and select SHOW ICON SHP HEADER DATA.

3.) Move the Centroid Cross to where you want it through double clicking or using the X/Y buttons.

4.) Push "Write Header to this Icon" button.

5.) Close pop up window.

6. ) Click on Rewrite Headers to SHP to download a SHP file with just the headers edited.

Yes, that is how I did it as well and the "Centroid Cross" had moved to where I put it on the new image but, of course, the new icon was not actually saved in the file

You have made some real progress with this and it looks very promising

MarkSheppard
October 24th, 2024, 09:13 PM
I'm currently stalled on the SHP compression; I can get it to compress the first row of pixels in an icon; then it just stops compressing pixel rows.

The GOOD: Both SHPed and this show the exact same broken image; so my image decompression code is valid.

Mobhack
October 25th, 2024, 03:20 PM
I'm currently stalled on the VFX SHP compression; I can get it to compress the first row of pixels in an icon; then it just stops compressing pixel rows.

The GOOD: Both SHPed and this show the exact same broken image; so my image decompression code is valid.

Mark - check your PM's as I sent you an email address there which you can reply to for a copy of the design specs for the VFX library SHP format by Miles Design. That includes the compression formulae they used.

You will need to pass me a valid email as there is no way to attach a zipfile to PM's, and I'm not putting it up here in case of copyright issues.

oh - found that he seems to have put it up on github so I'll PM you with the linky

cheers
Andy

DRG
October 28th, 2024, 10:29 AM
Just curious, was there any difficulty setting up the SHPEdit code in HTML5 ?

MarkSheppard
October 28th, 2024, 08:06 PM
I think I've made a semi breakthrough; I was stuck on trying to recompile SPCAMO stock SHP Icon111 from WW2; and I tried some other SHP files and they showed correctly:

https://i.imgur.com/jhk7DJJ.png

Likewise, some old Warhammer 40K SHPs partially show up:

https://i.imgur.com/lvwlqfD.png

With this (helped by the very useful cross overlay) I think what's happening is that I've got the SHP compression code now mostly correct...

BUT somewhere along the way, the SHP header stuff is not being passed along correctly; and the SHP header stuff plays a big important part in the SHP file compression procedure; because it defines a bounding box of pixels that we compress and discard the rest (to save pixel space)

MarkSheppard
October 28th, 2024, 09:43 PM
So, I --THINK-- I may have gotten it to work; but it's late at night and I don't feel like editing game files; but I've validated the files in Fred's SHPEd afterwards; so they load in that at least.

Here's v0.82; once again, SPCAMO is the password to let me upload it.

big glaring warning

this is currently not validated completely; so don't use it for heavy file editing [i.e. replacing 100 icons etc] just yet.

MarkSheppard
October 28th, 2024, 10:05 PM
now that I can actually save SHPs; I'm doing some more case testing -- and I need to make some changes to the icon replacement code -- it works fine if the icon is the same size as the one being replaced; but looks horrible if there's a size disparity between the new/old icons.

To fix this, here's a quick replacement; as once again SPCAMO is password.

DRG
October 28th, 2024, 10:40 PM
Take a break. You are making great progress but walk away for a day or two and clear your head

I made a copy of a SHP file I am putting new icons into and replaced the hull and turret of one I had tinkered with a bit

When I was done I loaded it into SHPedit and the hull looked good but the turret had black Kruf below the turret which I fixed with SHPedit as none of that showed in the new editor. I saved the file and viewed the icon in MOBHack

https://forum.shrapnelgames.com/attachment.php?attachmentid=17078&stc=1&d=1730168113

That is usually caused by the wrong-sized Shp file the icon is in and SHPEdit reports

#7 Problem??
cols 72, lines 27
Last #67
#8 Problem??

Shpedit also reports the main file is 89x89 BUT this new editor is reporting them as 90x90 which may explain above

My other issue is I've been using SHPEdit for over 2 decades. I know I saved the file once that is how the screenshot was produced but this is not intuitive to me and I have attempted to go back and redo this but I cannot find how I saved the first time ( it's late here too.......)

DRG
October 28th, 2024, 11:01 PM
OK I figured out how to save correctly " write headers+ images to SHP" ( " write headers+ images to SHP to SAVE" might be better

I looked at the recompiled.SHP with Shpedit and it reports
recompiled.shp
99 Icons
90 Max Height
90 Max Width

It should not be reporting they are 90 and EVERY file in that recompiled SHP reports 90x90 when checked with SHPedit SPFix .

I renamed it to the correct SHP file nameand loaded it in MOBhack and the Icons were skewed like the screen shot above

But also

ALL the icons I never touched with the new editor are skewed because they are 90x90

https://forum.shrapnelgames.com/attachment.php?attachmentid=17080&stc=1&d=1730170636

But it gets more interesting

This icon I never touched at all and this is what shows up in the game (EDIT) using the file I created with your viewer.... it does not show up with the grey zone around the turret barrel like that in the game with the SHPEdit created file.

https://forum.shrapnelgames.com/attachment.php?attachmentid=17081&stc=1&d=1730170838

Sorry for the bad news but I suspect whatever it is a simple thing...... it's finding it that might be a problem

DRG
October 29th, 2024, 11:45 AM
I ran an experiment

I built 2 test Icon inside an 88x88 square instead of 89x89
I check the recompiled.shp with SHPEdit and......

recompiled (1).
99 Icons
89 Max Height
89 Max Width

With V83 it reports

https://forum.shrapnelgames.com/attachment.php?attachmentid=17088&stc=1&d=1730215804

89x89 for that Icon but for all the others in the V83 generated SHP it's

https://forum.shrapnelgames.com/attachment.php?attachmentid=17089&stc=1&d=1730215904

90x90

The change I made using the v.83 version shows up OK in MOBHack
https://forum.shrapnelgames.com/attachment.php?attachmentid=17090&stc=1&d=1730216302

BUT in the game it shows up

https://forum.shrapnelgames.com/attachment.php?attachmentid=17091&stc=1&d=1730216477

and the other icons in the file that I did not touch show up in MOBhack show up skewed as before and in the game with the same issue with the turret as above

There is a glimmer of good news their..... v,83 is making the SHP too big which accounts for the skewing in MOBHack but I have NO IDEA why the turret issue is happening

DRG
October 29th, 2024, 11:45 AM
I ran an experiment

I built 2 test Icon inside an 88x88 square instead of 89x89
I check the recompiled.shp with SHPEdit and......

recompiled (1).
99 Icons
89 Max Height
89 Max Width

With V83 it reports

https://forum.shrapnelgames.com/attachment.php?attachmentid=17088&stc=1&d=1730215804

89x89 for that Icon but for all the others in the V83 generated SHP it's

https://forum.shrapnelgames.com/attachment.php?attachmentid=17089&stc=1&d=1730215904

90x90

The change I made using the v.83 version shows up OK in MOBHack
https://forum.shrapnelgames.com/attachment.php?attachmentid=17090&stc=1&d=1730216302

BUT in the game it shows up

https://forum.shrapnelgames.com/attachment.php?attachmentid=17091&stc=1&d=1730216477

and the other icons in the file that I did not touch show up in MOBhack show up skewed as before and in the game with the same issue with the turret as above

There is a glimmer of good news here..... v,83 is making the SHP too big which accounts for the skewing in MOBHack but I have NO IDEA why the turret issue is happening

HOWEVER

There is another issue

https://forum.shrapnelgames.com/attachment.php?attachmentid=17092&stc=1&d=1730217023

That grey around the turrets is FLASHING in the game,
Those colours are NOT in the Icon palette....... those are the cycling greys used for smoke so that is NOT the "SPCamo Icon only palette ( 2021+) that shows being loaded at start.... it cannot be as those entries are blacked out in that file so that is the full palette being used

Icon palette on left, full palette on right. The flashers are all blacked out in the Icon version

https://forum.shrapnelgames.com/attachment.php?attachmentid=17093&stc=1&d=1730218115

MarkSheppard
October 29th, 2024, 07:33 PM
Thanks for the testing; I've been so focused on making sure that everything decompresses/compresses in SHPEd as a "major sanity check"; that I haven't done testing in the actual game(s) yet.

Did a slight detour away from file compression issues (after spending so long bashing my head against it) and went back into designing usability features.

EDIT:

I think I may have fixed the distorted images:

In my SHPView_sHeaders.js file I had this:

function readImageHeader(dataView, offset, imageNumber)
{
// SHP Image Header: 24 bytes long

const height = dataView.getUint16(offset + 0, true) +1;
const width = dataView.getUint16(offset + 2, true) +1;

const var1 = dataView.getInt32(offset + 4, true); // Use getInt32 to allow for negative numbers
const xStart = dataView.getInt32(offset + 8, true); // Use getInt32 to allow for negative numbers
const yStart = dataView.getInt32(offset + 12, true); // Use getInt32 to allow for negative numbers
const xEnd = dataView.getInt32(offset + 16, true); // Use getInt32 to allow for negative numbers
const yEnd = dataView.getInt32(offset + 20, true); // Use getInt32 to allow for negative numbers

// Include the image number in the log message
conditionalLog(`Image ${imageNumber} Header - Height: ${height}, Width: ${width}, Var1: ${var1}, xStart: ${xStart}, yStart: ${yStart}, xEnd: ${xEnd}, yEnd: ${yEnd}`); // only if verbose logging included.

return { height, width, var1, xStart, yStart, xEnd, yEnd };
}

Removing the +1 from height & width in that function made things show up inside the game + MOBHack for me with no skewed icons.

I then rewrote Icon0128.shp for MBT; doing a test with replacing

{12800, 12801}, //4948. SPW-60PB DDR *********NEW

with a Caesar like SPH icon

https://i.imgur.com/2Kaud0n.png

Transparency no good in the "zoom out" icon, but seems to work in the zoom in feature.

I then skipped down to an icon in Icon0128.shp that I did not edit:

{12810, 12811}, //4953. 2S1 Gvozdika Ukraine *********NEW winSPMBT v16

It exhibits the same issue:

https://i.imgur.com/ld0mpHC.png

So I guess I need to look at palette mapping codes....

MarkSheppard
October 29th, 2024, 08:06 PM
Some more investigation...

At one specific zoom level; I get the flashing/cycling gray box where it should be transparent, but at all other zoom levels (I think) I have transparency:

https://i.imgur.com/r0ip4kL.png

Also, if you rotate the unit; the flashing area disappears:

https://i.imgur.com/INsft1v.png

Current code is attached (As always, password is SPCAMO)

DRG
October 29th, 2024, 09:41 PM
Interesting......... I did not check different zoom levels

DRG
October 29th, 2024, 09:53 PM
I have seen many odd things happen with this code in the last quarter century but the flashing zone around the gun barrel that only shows when the icon is 1:1 and facing to the right is probably the strangest one of all

Just totally bizarre


However, it more complicated than that

https://forum.shrapnelgames.com/attachment.php?attachmentid=17096&stc=1&d=1730253634

That was reduced and enlarged in the game...
and its not just when it faces right

https://forum.shrapnelgames.com/attachment.php?attachmentid=17097&stc=1&d=1730253821

DRG
October 29th, 2024, 10:11 PM
......and just to make it more interesting the problem is inconsistent and will manifest in different ways

https://forum.shrapnelgames.com/attachment.php?attachmentid=17103&stc=1&d=1730254580


https://forum.shrapnelgames.com/attachment.php?attachmentid=17102&stc=1&d=1730254280

A trifecta of PITA....

MarkSheppard
October 29th, 2024, 10:12 PM
I've been looking at the "buy menu" encyclopedia icon and the png file:

https://i.imgur.com/92DR6MC.png

I think what's happening is this:

My compression routine starts out correctly enciphering transparent areas of the SHP images (notice how the hull is mostly good?) and then somewhere things break.

I think what's happening is something causes the pixel variable being scanned to hang in memory and refuse to be updated; explaining how the hull on the first image works mostly fine, then the turret is flashing transparent.

Either that; or the true color to indexed color flattening code is bugging out somewhere; reading index 255 as a different index (one that happens to flash)

EDIT:
And I think the reason why other zoom levels work; but not the "Default" is because your zoom and rotate routines use interpolation.

So my program is probably outputting transparent pixels as something like index 254 or something (which is a known flashing color index); so it flashes in "normal" view.

But when you zoom in; the interpolation code moves it into pixel value 255; and it becomes transparent again.

MarkSheppard
October 29th, 2024, 10:57 PM
I think it's programming error on my part.

I never defined a way to pass through a palette to the SHP compression function; so it's somehow picking the first palette I defined (the full SPCAMO palette)

DRG
October 30th, 2024, 11:03 AM
I think it's programming error on my part.

I never defined a way to pass through a palette to the SHP compression function; so it's somehow picking the first palette I defined (the full SPCAMO palette)


That could be why Fred added a " SP no flash" checkbox

DRG
October 30th, 2024, 11:42 AM
I tried an experiment

I took a Recompiled.SHP generated by v.83 and loaded it into SHPedit with the NO flash box checked
I added a new Icon hull and turret into the shp and saved

I then ran it through MOBHack then the game with a special unit made for the hybrid Icon I added as a test

All the icons that were in the Recompiled.SHP that I had added an icon with SHPEdit were normal in MOBHack

The images that were already in the Recompiled.SHP still exhibited the kruf as before when viewed in the game

https://forum.shrapnelgames.com/attachment.php?attachmentid=17104&stc=1&d=1730302416


I changed the grey to fushia to make the areas it is in show more clearly.... it is not just the turret that has the problem. it is every pixel within the boundary of the X and Y of the image that does not have part of the icon in it that shows fushia same as if you drew a box with the max X and Y of the image then dropped the image on top of that..... any area of the background that was left unused by the image shows the grey flashing colour

The hybrid I added with SHPedit with the NO flash box checked was OK in MOBHack and the game

https://forum.shrapnelgames.com/attachment.php?attachmentid=17105&stc=1&d=1730302536


https://forum.shrapnelgames.com/attachment.php?attachmentid=17107&stc=1&d=1730302768


I think you are close to getting this solved and if it helps, Fred had some problems I help him sort out with his first version of SHPedit as well....... not quite as odd as this but there were issues that needed resolving and they were and you will too

The issue is that area within the max X and Y of the image that does not have Icon detail. Get that sorted and you are nearly there

FURTHER

I built this test to show it's the X-Y

https://forum.shrapnelgames.com/attachment.php?attachmentid=17108&stc=1&d=1730305239

That is just four 4 pixel squares at the outer boundary with XXX in between for the hull and the same for the turret except that uses 2 XX
Don

MarkSheppard
October 30th, 2024, 07:39 PM
I ---THINK--- I have it sorted.

I had to reverse the order in which I was compressing the data:

i.e.

Do the loop that handles Transparent (skipped) pixels FIRST, rather than second.

https://i.imgur.com/AWSuubX.png
(Replaced SPW-60Bs in Icon0128.shp, slot 4948)

So now I need to archive this version as a known "ok" version and start refining it more and testing it more before I release another version.

I grabbed the old USA REMOD files from here

https://forum.shrapnelgames.com/showthread.php?t=49329&page=4

went in; loaded the SHP files in one of gooseman's last uploads; selected one of the weird turreted bradley things and chose to export it (see attached zip for exported version)

Chose to replace the SPW-60B icon using that exported zip file; it automagically replaced the files, enlarged the canvas, and set all the SP Header data from the CSV in the zip.

End result:

https://i.imgur.com/RsK7bQB.png

DRG
October 30th, 2024, 09:03 PM
The revised editor you used to get that result would have been nice but carry on until you are happy with it

MarkSheppard
October 30th, 2024, 10:13 PM
The revised editor you used to get that result would have been nice but carry on until you are happy with it

Here it is.

I wanted to let it cook a bit; and double check on everything to make sure it mostly worked before unleashing it here; because it costs you guys time swapping files in and out and starting/restarting the game executable.

As before, the password is SPCAMO

MarkSheppard
October 30th, 2024, 10:19 PM
BTW, I think you may have a bug in

WinMBT Icon0128.shp file;

SHP Slot #42

The SP Header centroid isn't over the turret ring in my copy

https://i.imgur.com/CNUi87a.png

DRG
October 31st, 2024, 04:17 AM
BTW, I think you may have a bug in

WinMBT Icon0128.shp file;

SHP Slot #42

The SP Header centroid isn't over the turret ring in my copy

https://i.imgur.com/CNUi87a.png

You are correct. That is the Ukrainian M113AS4. Apparently, nobody ever bought one or if they did thought it odd that the turret was hanging off the back of the hull

Now corrected in the master files

https://forum.shrapnelgames.com/attachment.php?attachmentid=17111&stc=1&d=1730362724

And it's an ERROR, not a 'BUG'

An error is a mistake using the program by the operator
A bug is a program doing something wrong due to a programming error


Thanks

Don

DRG
October 31st, 2024, 08:05 AM
No Joy

Three steps forward but one step back

Icons entered with this version are skewing the icons again in MOBHack .

They work OK in the game at all zoom levels but they have to work in MOBHack and they did and now they don't again

https://forum.shrapnelgames.com/attachment.php?attachmentid=17112&stc=1&d=1730376284

I added five and they all do the same thing

Mobhack needs to be included in your checking routine as both have to work with this and both have their own "gotcha's'

If that can be fixed you have a winner. Being able to drop the BMP into the file is nice but ..

SUGGESTION

The centering cross only moves when you release it after it is clicked on.

Allow it to be held down so that it scrolls ( not too fast.....) in the direction you want when you click on the appropriate button rather than clicking 30 times to center it where it needs to be

Adding one or two icons it's not an issue..... entering dozens it gets old real fast

DRG
November 4th, 2024, 06:21 PM
If I download an icon from the files with this it turns an 89x89 image into 88x88

DRG
November 7th, 2024, 11:19 AM
Load MBT Icon0100.shp

Error: Pixel position exceeded width while reading different colors at line 21 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 64, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 66, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 68, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 70, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 20 in Image 82, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 20 in Image 82, pixel position: 108

Each message is duplicated

Error: Pixel position exceeded width while reading different colors at line 21 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 21 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 22 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 62, pixel position: 108
Error: Pixel position exceeded width while reading different colors at line 23 in Image 62, pixel position: 108



Both the fuselage of the helo and the rotors are in a 109x109 image which is the max MOBHack will accept and show up perfectly in the game and MOBHack so it's not an error

DRG
November 12th, 2024, 09:29 AM
FURTHER

I tried an experiment a couple days ago entering an icon using the widen by one pixel debug feature and it still showed the icon skewed in MOBhack so I entered it with SHPedit but I checked another icon in that file today in MOBHack and it and EVERY OTHER ICON IN THAT FILE is skewed in MOBHack now as well so the entire SHP file has to be rebuilt