Subject: [Nel] here's the landscape.cpp patch I used

From: [email-masked]
Date: Wed, 7 Mar 2001 01:33:34 -0800 (PST)

Thanks to Leighton's advice I was able to get running.  Here's the
patch I used:

$ cvs diff landscape.cpp
Index: landscape.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/landscape.cpp,v
retrieving revision 1.48
diff -u -r1.48 landscape.cpp
--- landscape.cpp       2001/02/28 14:28:57     1.48
+++ landscape.cpp       2001/03/07 09:35:52
@@ -741,16 +741,21 @@
        // Fill rdrpass.
        CPatchRdrPass   pass;
        // The diffuse part for a tile is inevitable.
-       if(tile)
-               pass.TextureDiffuse= findTileTexture(TileBank.getAbsPath()+tile->getRelativeFileName(CTile::diffuse));
-       else
+       if(tile) {
+               textName= tile->getRelativeFileName (CTile::diffuse);
+               if(textName!="")
+                       pass.TextureDiffuse= findTileTexture(TileBank.getAbsPath()+textName);
+       } else {
                pass.TextureDiffuse= new CTextureCross;
+        }
        if(tile)
        {
                textName= tile->getRelativeFileName (CTile::alpha);
                if(textName!="")
                        pass.TextureAlpha= findTileTexture(TileBank.getAbsPath()+textName);
-       }
+       } else {
+                pass.TextureAlpha= new CTextureCross;
+        }

        // Fill tileInfo.

As he said, this is not an actuall fix, merely a way to cover up the
problem.  This will probably make sense to someone there and in the
mean time I can learn about the rest of this system.

Woo hoo!

-- 
Robert de Forest      " meetings, n.:
System Administrator         A place where minutes are kept 
Got.net                                and hours are lost."
<[email-masked]>                    -- login fortune

---

From: "Lionel Berenguier" <[email-masked]>
Date: Wed, 7 Mar 2001 11:59:21 +0100

----- Original Message -----
From: <[email-masked]>
To: <[email-masked]>
Sent: Wednesday, March 07, 2001 10:33 AM
Subject: [Nel] here's the landscape.cpp patch I used

> -               pass.TextureDiffuse=
findTileTexture(TileBank.getAbsPath()+tile->getRelativeFileName(CTile::diffu
se));
> +                       pass.TextureDiffuse=
findTileTexture(TileBank.getAbsPath()+textName);
>                 pass.TextureDiffuse= new CTextureCross;

Actually, If CTextureFile::generate() do not find the file, it should do the
work of creating a dummy texture for you.

I think, the bug is CTextureFile::generate() try to load a "data/" (a
directory) which may crash on linux ??

>                         pass.TextureAlpha=
findTileTexture(TileBank.getAbsPath()+textName);
> +                pass.TextureAlpha= new CTextureCross;

This patch is wrong, because a NULL TextureAlpha is possible, and should not
crash.

I'll correct this.

Lionel Berenguier.
---
3d programmer / nevrax.com

---

From: "Vianney Lecroart" <[email-masked]>
Date: Wed, 7 Mar 2001 14:25:17 +0100

Hi there!

We, at last, understood the problem of the 'data/' bug on linux.
In fact, in our rawdatafiles, there are some empty file names and in our
program, we try to find where these files are located.
For that, we use a function (CPath::lookup()) that tries to find the file in
all directories provided before by the user.
To know if a file exists, we try to open it and if the opening success, we
return true (CFile::fileExists()).
When the prog tries to find the file "", first it calls fileExists("") that
returns false.
Next step, it tries with the first directory in his list,
fileExists("data/"+""); On windows, the OS can't open the directory
("data/")
so it returns false. On linux, it can, so it returns true and the program
tries to read the directory as if it was
a texture, and of course, it fails (end of file).

We fixed the problem by adding this next line in the top of the function
string CPath::lookup( const string& filename ) in path.cpp:

 if(filename.empty())
  throw EPathNotFound( filename );

Of course, we put it on cvs and it will be synchronized this night (GMT+1).

Vianney Lecroart
---
lead network programmer / nevrax.com
icq#: 6870415
homepage: http://ace.planet-d.net
www.geekcode.com: GCS/E d- s+++: a-- C+++$ UL++ P- L+++>+$ E+>- W++ N+ o? K-
w++$ O- M- V- PS- PE? Y PGP t 5? X+ R- tv++ b- DI D+ G e++ h+ r-- y?