facetoname[ ], and why it is empty?

Technical and coding related questions.

Moderator: Board moderators

Post Reply
Basilisk
Luser
Posts: 30
Joined: Mon Feb 06, 2006 6:20 am

facetoname[ ], and why it is empty?

Post by Basilisk »

I have been trying to re-do the fog-of-war effect by replacing "XCopyPlane" with a properly
drawn "XCopyArea" so it is not a rectangle.
I would like to use a bitmap from the server instead of the locally-generated square pattern
(although if I can display graphics from the client directory that is an option)

As the fog-of-war is calculated from the client, drawing the fog normally uses "XCopyPlane" from a bitmap that is actually made during x11.c (checkerboard pattern).
Other pixmaps are determined from the bitmap index numbers (pnum) sent from the server.
Pixmaps are selected from "pixmaps[ ]" based on this.

"char *facetoname[ ]" is supposed to store names of each bitmap.
It is an array of text strings, and returns the pixmap name when accessed.
Originally it is local to /common/image.c, and used ONLY for caching images.

I would like to re-use "facetoname[ ]" to retrieve the "pnum" for a bitmap given the face.
Surprisingly, the reverse function does not exist (given name, provide pnum),
so a loop and strcmp seems to be needed.
Furthermore, facetoname[ ] is defined in the scope of image.c

Just now I moved it to "external.h", and I was pleased when it seems the caching still works (or I have not been able to test thoroughly).
But when I accessed facetoname[ ] from x11.c, with the pnum known and the face name unknown, the name was printed empty!

The pixmap numbers related to gen_draw calls (that I added for debug) printed without trouble, so I am using legitimate input data.

Needless to say, a search and compare function using facetoname[ ] to do the reverse, cannot work if facetoname[ ] produces empty strings...

Why would the array be empty?
Basilisk
Luser
Posts: 30
Joined: Mon Feb 06, 2006 6:20 am

Post by Basilisk »

... I found out how to enable the CACHE, and a folder I never knew existed contains the bitmaps, unfortunately they are using a huge hash#.
Plus I am going to have the client request the server to send "dark2.base.111.png" because it is not being sent normally.
Basilisk
Luser
Posts: 30
Joined: Mon Feb 06, 2006 6:20 am

Post by Basilisk »

... I found out how to enable the cache and get the names.

I still get a crash if I try to "requestface" to the server.
Basilisk
Luser
Posts: 30
Joined: Mon Feb 06, 2006 6:20 am

Post by Basilisk »

Disregard this post. It turns out that I do not need to reference the data this way.
I was able to push the images from the server and reference them by their 4-digit number.
Unfortunately, a "real" client would not know the right 4-digit number from the "real" server,
which is why it is sort of unfortunate that there is no easy way to retrieve bitmaps knowing _only_ the name (and not also the checksum, or 4-digit index, or etc).

The legacy means of generating the shadow maps was causing me problems when I tried to "CopyArea" them instead of using "CopyPlane". Nor could I use local pixmaps without some crash regarding image format. So I had the server push the new shadow pixmaps,
then retrieved them from pixmaps[ ] for the modified functions...
Post Reply