TTimo / GtkRadiant

The open source, cross platform level editor for idtech games
http://icculus.org/gtkradiant/
Other
581 stars 152 forks source link

`ERROR: patch has too many plane points` with Unvanquished `parpax.map` #682

Closed illwieckz closed 1 year ago

illwieckz commented 1 year ago

I remembered the Unvanquished parpax map wasn't openable with GtkRadiant, though NetRadiant opens it properly.

The map has been heavily modified since I noticed this, but the the today's error message is (if I'm right I had another one before):

ERROR: patch has too many plane points, patch height > MAX_PATCH_HEIGHT (19 > 16)
Warning: Line 101224 is incomplete [02]
Warning: Line 101225 is incomplete [02]
Warning: Line 101226 is incomplete [02]
Warning: Line 101227 is incomplete [02]
Warning: Line 101228 is incomplete [02]
Warning: Line 101229 is incomplete [02]
Warning: Line 101230 is incomplete [02]
Warning: Line 101231 is incomplete [02]
Warning: Line 101233 is incomplete [02]
No worldspawn in map.

The map is there: https://github.com/UnvanquishedAssets/map-parpax_src.dpkdir/blob/master/maps/parpax.map

The patch starts this way:

{
patchDef2
{
parpax_exm/base1_nonsolid
( 9 19 0 0 0 )
(
( ( 644 -474 472 0 0 ) ( 644 -474 468 0 -0.03125 ) ( 644 -474 464 0 -0.0625 ) ( 644 -474 454 0 -0.140625 ) ( 644 -464 454 0 -0.21875 ) ( 644 -434 454 0 -0.453125 ) ( 644 -398 454 0 -0.734375 ) ( 644 -388 454 0 -0.8125 ) ( 654 -388 454 0 -0.890625 ) ( 748 -388 454 0 -1.625 ) ( 832 -388 454 0 -2.28125 ) ( 844 -388 454 0 -2.375 ) ( 844 -388 442 0 -2.46875 ) ( 844 -388 439 0 -2.4921875 ) ( 844 -388 436 0 -2.515625 ) ( 844 -388 428 0 -2.578125 ) ( 844 -380 428 0 -2.640625 ) ( 844 -378 428 0 -2.65625 ) ( 844 -376 428 0 -2.671875 ) )
[…]

The ( 9 19 0 0 0 ) snippet is on line 101222.

illwieckz commented 1 year ago

In GtkRadiant include/qertypes.h:

#define MAX_PATCH_WIDTH     16
#define MAX_PATCH_HEIGHT    16

In NetRadiant radiant/patchmodule.cpp:

    if ( type == ePatchTypeDoom3 ) {
        MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 99;
    }
    else
    {
        MAX_PATCH_WIDTH = MAX_PATCH_HEIGHT = 31; // matching q3map2
    }

In NetRadiant contrib/bobtoolz/DPatch.h:

const int MAX_PATCH_WIDTH = 32;
const int MAX_PATCH_HEIGHT = 32;
illwieckz commented 1 year ago

The value is probably MAX_PATCH_SIZE on q3map2's side:

In GtkRadiant tools/quake3/q3map2/patch.c:

#define MAX_PATCH_SIZE          32

In GtkRadiant tools/urt/tools/quake3/q3map2/q3map2.h:

#define MAX_PATCH_SIZE          32

In NetRadiant tools/quake3/q3map2/q3map2.h:

#define MAX_PATCH_SIZE          32
illwieckz commented 1 year ago

Those are the way they are checked for:

In GtkRadiant plugins/map/parse.cpp:

    if ( pPatch->height > MAX_PATCH_HEIGHT ) {
        Syn_Printf( "ERROR: patch has too many plane points, patch height > MAX_PATCH_HEIGHT (%i > %i)\n", pPatch->height, MAX_PATCH_HEIGHT );
        pPatch->height = MAX_PATCH_HEIGHT;

In NetRadiant radiant/patch.cpp:

    ASSERT_MESSAGE( h <= MAX_PATCH_HEIGHT, "patch too tall" );
    if ( h > MAX_PATCH_HEIGHT ) {
        h = MAX_PATCH_HEIGHT;
    }

In both GtkRadiant and NetRadiant tools/quake3/q3map2/patch.c:

    if ( m.width < 0 || m.width > MAX_PATCH_SIZE || m.height < 0 || m.height > MAX_PATCH_SIZE ) {
        Error( "ParsePatch: bad size" );

So I assume we can raise the limit to 32 in both GtkRadiant (instead of 16) and NetRadiant (instead of 31).

Garux commented 1 year ago

I think patch size must be odd number