| 1739 | } |
| 1740 | |
| 1741 | void G_SetG2PlayerModel( gentity_t * const ent, const char *modelName, const char *customSkin, const char *surfOff, const char *surfOn ) |
| 1742 | { |
| 1743 | char skinName[MAX_QPATH]; |
| 1744 | |
| 1745 | //ok, lets register the skin name, and then pass that name to the config strings so the client can get it too. |
| 1746 | if ( !customSkin ) |
| 1747 | {//use the default |
| 1748 | Com_sprintf( skinName, sizeof( skinName ), "models/players/%s/model_default.skin", modelName ); |
| 1749 | } |
| 1750 | else |
| 1751 | { |
| 1752 | if (strchr(customSkin, '|')) |
| 1753 | {//three part skin |
| 1754 | Com_sprintf( skinName, sizeof( skinName ), "models/players/%s/|%s", modelName, customSkin ); |
| 1755 | } |
| 1756 | else |
| 1757 | { |
| 1758 | Com_sprintf( skinName, sizeof( skinName ), "models/players/%s/model_%s.skin", modelName, customSkin ); |
| 1759 | } |
| 1760 | } |
| 1761 | int skin = gi.RE_RegisterSkin( skinName ); |
| 1762 | //now generate the ghoul2 model this client should be. |
| 1763 | if ( ent->client->NPC_class == CLASS_VEHICLE ) |
| 1764 | {//vehicles actually grab their model from the appropriate vehicle data entry |
| 1765 | |
| 1766 | // This will register the model and other assets. |
| 1767 | Vehicle_t *pVeh = ent->m_pVehicle; |
| 1768 | pVeh->m_pVehicleInfo->RegisterAssets( pVeh ); |
| 1769 | ent->playerModel = gi.G2API_InitGhoul2Model( ent->ghoul2, va("models/players/%s/model.glm", modelName), pVeh->m_pVehicleInfo->modelIndex, G_SkinIndex( skinName ), NULL_HANDLE, 0, 0 ); |
| 1770 | } |
| 1771 | else |
| 1772 | { |
| 1773 | //NOTE: it still loads the default skin's tga's because they're referenced in the .glm. |
| 1774 | ent->playerModel = gi.G2API_InitGhoul2Model( ent->ghoul2, va("models/players/%s/model.glm", modelName), G_ModelIndex( va("models/players/%s/model.glm", modelName) ), G_SkinIndex( skinName ), NULL_HANDLE, 0, 0 ); |
| 1775 | } |
| 1776 | if (ent->playerModel == -1) |
| 1777 | {//try the stormtrooper as a default |
| 1778 | gi.Printf( S_COLOR_RED"G_SetG2PlayerModel: cannot load model %s\n", modelName ); |
| 1779 | modelName = "stormtrooper"; |
| 1780 | Com_sprintf( skinName, sizeof( skinName ), "models/players/%s/model_default.skin", modelName ); |
| 1781 | skin = gi.RE_RegisterSkin( skinName ); |
| 1782 | ent->playerModel = gi.G2API_InitGhoul2Model( ent->ghoul2, va("models/players/%s/model.glm", modelName), G_ModelIndex( va("models/players/%s/model.glm", modelName) ), NULL_HANDLE, NULL_HANDLE, 0, 0 ); |
| 1783 | } |
| 1784 | if (ent->playerModel == -1) |
| 1785 | {//very bad thing here! |
| 1786 | Com_Error(ERR_DROP, "Cannot fall back to default model %s!", modelName); |
| 1787 | } |
| 1788 | |
| 1789 | gi.G2API_SetSkin( &ent->ghoul2[ent->playerModel], G_SkinIndex( skinName ), skin );//this is going to set the surfs on/off matching the skin file |
| 1790 | |
| 1791 | // did we find a ghoul2 model? if so, load the animation.cfg file |
| 1792 | if ( !G_SetG2PlayerModelInfo( ent, modelName, customSkin, surfOff, surfOn ) ) |
| 1793 | {//couldn't set g2 info, fall back to a mouse md3 |
| 1794 | NPC_ParseParms( "mouse", ent ); |
| 1795 | Com_Printf( S_COLOR_RED"couldn't load playerModel %s!\n", va("models/players/%s/model.glm", modelName) ); |
| 1796 | } |
| 1797 | } |
| 1798 | /* |
no test coverage detected