convert bool to const char*

I'm getting compile errors while trying to do a simple string compare.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  			if (mo->player && gravity > 0 && -zmove > OOF_SPEED && ! fly_or_swim)
			{
				// Squat down. Decrease viewheight for a moment after hitting the
				// ground (hard), and utter appropriate sound.
				mo->player->deltaviewheight = zmove / 8.0f;
				S_StartFX(mo->info->oof_sound, P_MobjGetSfxCategory(mo), mo);
				
				///if (strncmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image), 8) < 0)
					///S_StartFX(mo->info->oof_sound, P_MobjGetSfxCategory(mo), mo);
				//#define W_ImageGetName(b) ((b)?"0":"1")
					if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image) != 0))
				      //strcmp(W_ImageGetName(mo->subsector->sector->floor.image), 'FWATER1') == 1);
				      S_StartFX(mo->info->oof_sound, P_MobjGetSfxCategory(mo), mo);
			}


So the problem here is that I want the engine to look up if the particular name (in this case, FWATER1) is found: if so, spawn a sound effect.

In a different file, ImageGetName is defined as such:
1
2
3
4
5
6
7
8
const char *W_ImageGetName(const image_c *image)
{
	const image_c *rim;

	rim = (const image_c *) image;

	return rim->name;
}


So clearly it's a const char, but I have to use a bool so it can lookup the name. When compiling, though, I get this error:

obj_win32/edge/p_mobj.o -c src/p_mobj.cc
src/p_mobj.cc: In function 'void P_ZMovement(mobj_t*, const region_properties_t*
)':
src/p_mobj.cc:1214:83: error: cannot convert 'bool' to 'const char*' for argumen
t '2' to 'int strcmp(const char*, const char*)'
if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image) !
= 0))

^


Maybe I'm not writing this correctly? Any help is appreciated!
Parenthesis in the wrong place.

if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image)) != 0)
Thanks for the help! =)

While it compiles great, it seems any surface the player steps on with floor.image will spawn the sound effect.

So it doesn't appear that it's working properly, is it because I need two or more string compares? So let's just assume there are a bunch of floor.images, and it only needs to detect if the player steps on "FWATER1", then it plays the sound.

This is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
		if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image)) != 0)
		{
				//if (strncmp(mo->subsector->sector->floor.image, "FWATER1"))
				I_Printf("FWATER1 detected\n");
				      //strcmp(W_ImageGetName(mo->subsector->sector->floor.image), 'FWATER1') == 1);
				      S_StartFX(mo->info->painsound, P_MobjGetSfxCategory(mo), mo);
		}
		else
		if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image)) == 0)
				{
				I_Printf("Hitting normal floor\n");
				mo->z = mo->floorz;
				}


Any ideas?
strcmp returns 0 when both strings are equal, it looks like you are assuming the opposite? Can't tell what else it could be otherwise.
> Maybe I'm not writing this correctly?

Parentheses!
1
2
// if (strcmp("FWATER1", W_ImageGetName(mo->subsector->sector->floor.image) != 0))
if ( strcmp( "FWATER1", W_ImageGetName(mo->subsector->sector->floor.image) ) != 0 )
Topic archived. No new replies allowed.