.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   TRACE_TEXTURE weirdnesses (http://forums.bots-united.com/showthread.php?t=1598)

two_masks 05-05-2004 03:24

TRACE_TEXTURE weirdnesses
 
Got another one for you all:

I'm using TRACE_TEXTURE to determine the texture a player is standing on (for hearing purposes, as covered in a thread from last week). However, it seems to be doing strange things to the stack: depending on how much code follows it, my return values get all messed up. I'm guessing it's a stack corruption because adding a LOG_CONSOLE to track my return value "fixed" the problem, that is, until I added some more code, at which point it went haywire again. Has anybody every experienced this before?

Here's a snippet of my code where the actual call happens:

Code:


        float rgfl1[3];
        float rgfl2[3];
 
        const char * pTextureName;
                   
        v_source = pPlayer->v.origin;
        v_dest = pPlayer->v.origin;
        v_dest.z = v_dest.z - 1000;
 
        pPlayer->v.origin.CopyToArray(rgfl1);
        v_dest.CopyToArray(rgfl2);
 
        pTextureName = TRACE_TEXTURE( ENT(0), rgfl1, rgfl2 );

Any thoughts?

-JB

botman 05-05-2004 14:56

Re: TRACE_TEXTURE weirdnesses
 
What are you doing with pTextureName in the rest of that function?

You're not trying to return pTextureName back from the function are you? That would cause problems because pTextureName is a local variable on the stack frame of that function.

botman

two_masks 05-05-2004 20:15

Re: TRACE_TEXTURE weirdnesses
 
Nope, not returning any local variables, I'm just comparing the texture name to a few known textures that I want to cause sound when walked upon.

Any other thoughts? Have you all used TRACE_TEXTURE successfully?

-JB

Pierre-Marie Baty 06-05-2004 05:50

Re: TRACE_TEXTURE weirdnesses
 
To check what sort of footstep sound belongs to a texture, call the PM_FindTextureType() function in the Game DLL interface. Any MOD code should feature this function. You feed it with the texture name char pointer, and it will return the character describing what type of material it is, according to what's specified in your materials.txt file.

Here's what I am doing:
Code:

                // ask the engine for the texture name on pGroundEntity under the player's feet
                texture_name = TRACE_TEXTURE (pGroundEntity, pPlayer->v_origin, Vector (0, 0, -9999));
                // if the engine found the texture, ask the game DLL for the texture type
                if (texture_name != NULL)
                        texture_type = MDLL_PM_FindTextureType ((char *) texture_name); // ask for texture type

The MDLL_ prefix before PM_FindTextureType is metamod's syntax. If you don't use metamod, don't use the MDLL_ macros and directly call PM_FindTextureType.


All times are GMT +2. The time now is 17:37.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.