Beispiel #1
0
qhandle_t RE_RegisterSkin( const char *name ) {
    qhandle_t	hSkin;
    skin_t		*skin;

    if ( !name || !name[0] ) {
        Com_Printf( "Empty name passed to RE_RegisterSkin\n" );
        return 0;
    }

    if ( strlen( name ) >= MAX_QPATH ) {
        Com_Printf( "Skin name exceeds MAX_QPATH\n" );
        return 0;
    }

    // see if the skin is already loaded
    for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) {
        skin = tr.skins[hSkin];
        if ( !Q_stricmp( skin->name, name ) ) {
            if( skin->numSurfaces == 0 ) {
                return 0;		// default skin
            }
            return hSkin;
        }
    }

    // allocate a new skin
    if ( tr.numSkins == MAX_SKINS ) {
        Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name );
        return 0;
    }
    tr.numSkins++;
    skin = (struct skin_s *)Hunk_Alloc( sizeof( skin_t ), h_low );
    tr.skins[hSkin] = skin;
    Q_strncpyz( skin->name, name, sizeof( skin->name ) );
    skin->numSurfaces = 0;

    // make sure the render thread is stopped
    R_IssuePendingRenderCommands();

    // If not a .skin file, load as a single shader
    if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) {
        /*		skin->numSurfaces = 1;
        		skin->surfaces[0] = (skinSurface_t *)Hunk_Alloc( sizeof(skin->surfaces[0]), h_low );
        		skin->surfaces[0]->shader = R_FindShader( name, lightmapsNone, stylesDefault, qtrue );
        		return hSkin;
        */
    }

    char skinhead[MAX_QPATH]= {0};
    char skintorso[MAX_QPATH]= {0};
    char skinlower[MAX_QPATH]= {0};
    if ( RE_SplitSkins(name, (char*)&skinhead, (char*)&skintorso, (char*)&skinlower ) )
    {   //three part
        hSkin = RE_RegisterIndividualSkin(skinhead, hSkin);
        if (hSkin)
        {
            hSkin = RE_RegisterIndividualSkin(skintorso, hSkin);
            if (hSkin)
            {
                hSkin = RE_RegisterIndividualSkin(skinlower, hSkin);
            }
        }
    }
    else
    {   //single skin
        hSkin = RE_RegisterIndividualSkin(name, hSkin);
    }
    return(hSkin);
}
Beispiel #2
0
/*
===============
RE_RegisterSkin

===============
*/
qhandle_t RE_RegisterSkin( const char *name) {
	qhandle_t	hSkin;
	skin_t		*skin;

//	if (!cls.cgameStarted && !cls.uiStarted)
//	{
		//rww - added uiStarted exception because we want ghoul2 models in the menus.
		// gwg well we need our skins to set surfaces on and off, so we gotta get em
		//return 1;	// cope with Ghoul2's calling-the-renderer-before-its-even-started hackery, must be any NZ amount here to trigger configstring setting
//	}

	if (!tr.numSkins)
	{
		R_InitSkins(); //make sure we have numSkins set to at least one.
	}

	if ( !name || !name[0] ) {
		Com_Printf( "Empty name passed to RE_RegisterSkin\n" );
		return 0;
	}

	if ( strlen( name ) >= MAX_QPATH ) {
		Com_Printf( "Skin name exceeds MAX_QPATH\n" );
		return 0;
	}

	// see if the skin is already loaded
	for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) {
		skin = tr.skins[hSkin];
		if ( !Q_stricmp( skin->name, name ) ) {
			if( skin->numSurfaces == 0 ) {
				return 0;		// default skin
			}
			return hSkin;
		}
	}

	if ( tr.numSkins == MAX_SKINS )	{
		ri.Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name );
		return 0;
	}
	// allocate a new skin
	tr.numSkins++;
	skin = (skin_t*) R_Hunk_Alloc( sizeof( skin_t ), qtrue );
	tr.skins[hSkin] = skin;
	Q_strncpyz( skin->name, name, sizeof( skin->name ) );	//always make one so it won't search for it again

	// If not a .skin file, load as a single shader	- then return
	if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) {
#ifdef JK2_MODE
		skin->numSurfaces = 1;
		skin->surfaces[0] = (skinSurface_t *) R_Hunk_Alloc( sizeof(skin->surfaces[0]), qtrue );
		skin->surfaces[0]->shader = R_FindShader( name, lightmapsNone, stylesDefault, qtrue );
		return hSkin;
#endif
/*		skin->numSurfaces = 1;
		skin->surfaces[0] = (skinSurface_t *) R_Hunk_Alloc( sizeof(skin->surfaces[0]), qtrue );
		skin->surfaces[0]->shader = R_FindShader( name, lightmapsNone, stylesDefault, qtrue );
		return hSkin;
*/
	}

	char skinhead[MAX_QPATH]={0};
	char skintorso[MAX_QPATH]={0};
	char skinlower[MAX_QPATH]={0};
	if ( RE_SplitSkins(name, (char*)&skinhead, (char*)&skintorso, (char*)&skinlower ) )
	{//three part
		hSkin = RE_RegisterIndividualSkin(skinhead, hSkin);
		if (hSkin && strcmp(skinhead, skintorso))
		{
			hSkin = RE_RegisterIndividualSkin(skintorso, hSkin);
		}

		if (hSkin && strcmp(skinhead, skinlower) && strcmp(skintorso, skinlower))
		{
			hSkin = RE_RegisterIndividualSkin(skinlower, hSkin);
		}
	}
	else
	{//single skin
		hSkin = RE_RegisterIndividualSkin(name, hSkin);
	}
	return(hSkin);
}