Skip to content

Commit

Permalink
Fix secondary weapon models registering (#346)
Browse files Browse the repository at this point in the history
* Fix secondary weapon models registering
* Fix weapon secondary models registering in UI
  • Loading branch information
NoiseByNorthwest authored Jun 23, 2024
1 parent d371ff1 commit 025d283
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
30 changes: 10 additions & 20 deletions code/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,7 @@ void CG_RegisterWeapon( int weaponNum )
weaponInfo->ammoModel = trap_R_RegisterModel( ammo->world_model[0] );
}

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash.md3" );
weaponInfo->flashModel = trap_R_RegisterModel( path );

Expand All @@ -866,39 +865,32 @@ void CG_RegisterWeapon( int weaponNum )

// leilei - additional flash styles

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash1.md3" );
weaponInfo->flashModel_type1 = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash2.md3" );
weaponInfo->flashModel_type2 = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash2a.md3" );
weaponInfo->flashModel_type2a = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash3.md3" );
weaponInfo->flashModel_type3 = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash4.md3" );
weaponInfo->flashModel_type4 = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash5.md3" );
weaponInfo->flashModel_type5 = trap_R_RegisterModel( path );


Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_flash5a.md3" );
weaponInfo->flashModel_type5a = trap_R_RegisterModel( path );

Expand All @@ -917,13 +909,11 @@ void CG_RegisterWeapon( int weaponNum )
if (!weaponInfo->flashModel_type5) weaponInfo->flashModel_type5 = trap_R_RegisterModel( "models/muzzle/flash5.md3" );
if (!weaponInfo->flashModel_type5a) weaponInfo->flashModel_type5a = trap_R_RegisterModel( "models/muzzle/flash5a.md3" );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_barrel.md3" );
weaponInfo->barrelModel = trap_R_RegisterModel( path );

Q_strncpyz( path, item->world_model[0], MAX_QPATH );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
Q_strcat( path, sizeof(path), "_hand.md3" );
weaponInfo->handsModel = trap_R_RegisterModel( path );

Expand Down
6 changes: 2 additions & 4 deletions code/q3_ui/ui_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {
}

if ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {
strcpy( path, item->world_model[0] );
COM_StripExtension( path, path, sizeof(path) );
COM_StripExtension( item->world_model[0], path, sizeof(path) );
strcat( path, "_barrel.md3" );
pi->barrelModel = trap_R_RegisterModel( path );
}

strcpy( path, item->world_model[0] );
COM_StripExtension( path, path, sizeof(path) );
COM_StripExtension( item->world_model[0], path, sizeof(path) );
strcat( path, "_flash.md3" );
pi->flashModel = trap_R_RegisterModel( path );

Expand Down
6 changes: 2 additions & 4 deletions code/ui/ui_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,12 @@ static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {
}

if ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {
strcpy( path, item->world_model[0] );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
strcat( path, "_barrel.md3" );
pi->barrelModel = trap_R_RegisterModel( path );
}

strcpy( path, item->world_model[0] );
COM_StripExtension(path, path, sizeof(path));
COM_StripExtension(item->world_model[0], path, sizeof(path));
strcat( path, "_flash.md3" );
pi->flashModel = trap_R_RegisterModel( path );

Expand Down

0 comments on commit 025d283

Please sign in to comment.