From 1e6aee5a7bbb8f8283f2fee37747c9cd1af536f4 Mon Sep 17 00:00:00 2001 From: g-cont Date: Fri, 2 Jan 2009 00:00:00 +0300 Subject: [PATCH] 02 Jan 2009 --- client/global/enginecallback.h | 3 +- client/hud/hud.cpp | 6 +- client/hud/hud_ammo.cpp | 181 ++++++++++++++++++++++----------- client/hud/hud_ammohistory.h | 1 - client/hud/hud_health.cpp | 3 +- client/hud/hud_iface.h | 3 + client/hud/hud_train.cpp | 2 +- client/hud/hud_utils.cpp | 112 ++++++++++++++++---- client/hud/hud_warhead.cpp | 11 +- client/hud/hud_zoom.cpp | 4 +- engine/client/cl_game.c | 2 +- engine/client/cl_scrn.c | 1 + engine/client/client.h | 2 +- engine/common/engfuncs.c | 11 ++ public/clgame_api.h | 2 +- server/ents/basebrush.cpp | 69 ++++++------- server/game/sound.cpp | 12 +-- todo.log | 1 + 18 files changed, 285 insertions(+), 141 deletions(-) diff --git a/client/global/enginecallback.h b/client/global/enginecallback.h index 73af4b0c..ef7afec7 100644 --- a/client/global/enginecallback.h +++ b/client/global/enginecallback.h @@ -69,7 +69,8 @@ inline void CL_PlaySound( int iSound, float flVolume, Vector &pos ) #define RANDOM_LONG (*g_engfuncs.pfnRandomLong) #define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) #define LOAD_FILE (*g_engfuncs.pfnLoadFile) -#define FREE_FILE (*g_engfuncs.pfnFreeFile) +#define FILE_EXISTS (*g_engfuncs.pfnFileExists) +#define FREE_FILE FREE #define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) #define HOST_ERROR (*g_engfuncs.pfnHostError) diff --git a/client/hud/hud.cpp b/client/hud/hud.cpp index 3e86678c..7830e8cb 100644 --- a/client/hud/hud.cpp +++ b/client/hud/hud.cpp @@ -73,6 +73,8 @@ void CHud :: VidInit( void ) m_hsprCursor = 0; m_hHudError = 0; + Draw_VidInit(); + // setup screen info m_scrinfo.iWidth = CVAR_GET_FLOAT( "width" ); m_scrinfo.iHeight = CVAR_GET_FLOAT( "height" ); @@ -86,7 +88,7 @@ void CHud :: VidInit( void ) if ( !m_pSpriteList ) { // we need to load the hud.txt, and all sprites within - m_pSpriteList = SPR_GetList( "scripts/hud.shader", &m_iSpriteCount ); + m_pSpriteList = SPR_GetList( "scripts/hud.txt", &m_iSpriteCount ); if( m_pSpriteList ) { @@ -118,7 +120,7 @@ void CHud :: VidInit( void ) client_sprite_t *p = m_pSpriteList; for( int j = 0; j < m_iSpriteCount; j++ ) { - m_rghSprites[j] = SPR_Load( p->szName ); + m_rghSprites[j] = SPR_Load( p->szSprite ); p++; } } diff --git a/client/hud/hud_ammo.cpp b/client/hud/hud_ammo.cpp index 773b8c30..c15ca848 100644 --- a/client/hud/hud_ammo.cpp +++ b/client/hud/hud_ammo.cpp @@ -25,62 +25,13 @@ WEAPON *gpActiveSel; // NULL means off, 1 means just the menu bar, otherwise WEAPON *gpLastSel; // Last weapon menu selection +client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iCount ); WeaponsResource gWR; int g_weaponselect = 0; -void WeaponsResource :: LoadWeaponSprite( WEAPON *pWeapon, const char *type ) -{ - if( !pWeapon ) return; - - // fmt - HSPRITE hSprite = LOAD_SHADER( va( "%s::%s\n", pWeapon->szName, type )); - - if( !strcmp( type, "crosshair" )) - { - pWeapon->hCrosshair = hSprite; - pWeapon->rcCrosshair = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "autoaim" )) - { - pWeapon->hAutoaim = hSprite; - pWeapon->rcAutoaim = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "zoom" )) - { - pWeapon->hZoomedCrosshair = hSprite; - pWeapon->rcZoomedCrosshair = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "zoom_autoaim" )) - { - pWeapon->hZoomedAutoaim = hSprite; - pWeapon->rcZoomedAutoaim = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "weapon" )) - { - pWeapon->hInactive = hSprite; - pWeapon->rcInactive = gHUD.GetSpriteRect( hSprite ); - gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); - } - else if( !strcmp( type, "weapon_s" )) - { - pWeapon->hActive = hSprite; - pWeapon->rcActive = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "ammo" )) - { - pWeapon->hAmmo = hSprite; - pWeapon->rcAmmo = gHUD.GetSpriteRect( hSprite ); - } - else if( !strcmp( type, "ammo2" )) - { - pWeapon->hAmmo2 = hSprite; - pWeapon->rcAmmo2 = gHUD.GetSpriteRect( hSprite ); - } -} - void WeaponsResource :: LoadAllWeaponSprites( void ) { - for (int i = 0; i < MAX_WEAPONS; i++) + for( int i = 0; i < MAX_WEAPONS; i++ ) { if ( rgWeapons[i].iId ) LoadWeaponSprites( &rgWeapons[i] ); } @@ -111,6 +62,9 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) { if( !pWeapon ) return; + int i; + char sz[256]; + memset( &pWeapon->rcActive, 0, sizeof( wrect_t )); memset( &pWeapon->rcInactive, 0, sizeof( wrect_t )); memset( &pWeapon->rcAmmo, 0, sizeof( wrect_t )); @@ -119,16 +73,98 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) pWeapon->hActive = 0; pWeapon->hAmmo = 0; pWeapon->hAmmo2 = 0; + + sprintf( sz, "scripts/weapons/%s.txt", pWeapon->szName ); + client_sprite_t *pList = SPR_GetList( sz, &i ); + + if( !pList ) return; + + client_sprite_t *p; + + p = GetSpriteList( pList, "crosshair", i ); + if( p ) + { + pWeapon->hCrosshair = p->hSprite; + pWeapon->rcCrosshair = p->rc; + } + else pWeapon->hCrosshair = 0; + + p = GetSpriteList( pList, "autoaim", i ); + if( p ) + { + pWeapon->hAutoaim = p->hSprite; + pWeapon->rcAutoaim = p->rc; + } + else pWeapon->hAutoaim = 0; + + p = GetSpriteList( pList, "zoom", i ); + if( p ) + { + pWeapon->hZoomedCrosshair = p->hSprite; + pWeapon->rcZoomedCrosshair = p->rc; + } + else + { + pWeapon->hZoomedCrosshair = pWeapon->hCrosshair; // default to non-zoomed crosshair + pWeapon->rcZoomedCrosshair = pWeapon->rcCrosshair; + } + + p = GetSpriteList( pList, "zoom_autoaim", i ); + if( p ) + { + pWeapon->hZoomedAutoaim = p->hSprite; + pWeapon->rcZoomedAutoaim = p->rc; + } + else + { + pWeapon->hZoomedAutoaim = pWeapon->hZoomedCrosshair; // default to zoomed crosshair + pWeapon->rcZoomedAutoaim = pWeapon->rcZoomedCrosshair; + } + + p = GetSpriteList( pList, "weapon", i ); + if( p ) + { + pWeapon->hInactive = p->hSprite; + pWeapon->rcInactive = p->rc; + gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); + } + else + { + pWeapon->hInactive = gHUD.m_hHudError; + pWeapon->rcInactive = gHUD.GetSpriteRect( gHUD.m_HUD_error ); + gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); + } + + p = GetSpriteList( pList, "weapon_s", i ); + if( p ) + { + pWeapon->hActive = p->hSprite; + pWeapon->rcActive = p->rc; + } + else + { + pWeapon->hActive = gHUD.m_hHudError; + pWeapon->rcActive = gHUD.GetSpriteRect( gHUD.m_HUD_error ); + } + + p = GetSpriteList( pList, "ammo", i ); + if( p ) + { + pWeapon->hAmmo = p->hSprite; + pWeapon->rcAmmo = p->rc; + gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); + } + else pWeapon->hAmmo = 0; + + p = GetSpriteList( pList, "ammo2", i ); + if( p ) + { + pWeapon->hAmmo2 = p->hSprite; + pWeapon->rcAmmo2 = p->rc; + gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); + } + else pWeapon->hAmmo2 = 0; - // find specified shaders - LoadWeaponSprite( pWeapon, "crosshair" ); - LoadWeaponSprite( pWeapon, "autoaim" ); - LoadWeaponSprite( pWeapon, "zoom" ); - LoadWeaponSprite( pWeapon, "zoom_autoaim" ); - LoadWeaponSprite( pWeapon, "weapon" ); - LoadWeaponSprite( pWeapon, "weapon_s" ); - LoadWeaponSprite( pWeapon, "ammo" ); - LoadWeaponSprite( pWeapon, "ammo2" ); } // Returns the first weapon for a given slot. @@ -1186,4 +1222,29 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi END_READ(); return 1; +} + +/* +================================= + GetSpriteList + +Finds and returns the matching +sprite name 'psz' in the given sprite list 'pList' +iCount is the number of items in the pList +================================= +*/ +client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iCount ) +{ + if( !pList ) return NULL; + + int i = iCount; + client_sprite_t *p = pList; + + while( i-- ) + { + if( !strcmp( psz, p->szName )) + return p; + p++; + } + return NULL; } \ No newline at end of file diff --git a/client/hud/hud_ammohistory.h b/client/hud/hud_ammohistory.h index b74103c1..78913bdb 100644 --- a/client/hud/hud_ammohistory.h +++ b/client/hud/hud_ammohistory.h @@ -76,7 +76,6 @@ public: WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; } - void LoadWeaponSprite( WEAPON *p, const char *type ); void LoadWeaponSprites( WEAPON* wp ); void LoadAllWeaponSprites( void ); WEAPON* GetFirstPos( int iSlot ); diff --git a/client/hud/hud_health.cpp b/client/hud/hud_health.cpp index 09adbeb1..d8c28531 100644 --- a/client/hud/hud_health.cpp +++ b/client/hud/hud_health.cpp @@ -25,8 +25,7 @@ DECLARE_MESSAGE( m_Health, Health ) DECLARE_MESSAGE( m_Health, Damage ) -#define PAIN_NAME "hud_pain" -#define DAMAGE_NAME "sprites/%d_dmg.spr" +#define PAIN_NAME "sprites/pain.spr" int giDmgHeight, giDmgWidth; diff --git a/client/hud/hud_iface.h b/client/hud/hud_iface.h index 5dc11a5d..1c0020dc 100644 --- a/client/hud/hud_iface.h +++ b/client/hud/hud_iface.h @@ -34,6 +34,7 @@ typedef struct rect_s typedef struct client_sprite_s { char szName[64]; // shader name and sprite name are matched + char szSprite[64]; HSPRITE hSprite; wrect_t rc; } client_sprite_t; @@ -149,6 +150,7 @@ extern int SPR_Frames( HSPRITE hPic ); extern int SPR_Height( HSPRITE hPic, int frame ); extern int SPR_Width( HSPRITE hPic, int frame ); extern client_sprite_t *SPR_GetList( const char *name, int *count ); +extern void ParseHudSprite( const char **pfile, char *psz, client_sprite_t *result ); extern void SPR_Set( HSPRITE hPic, int r, int g, int b ); extern void SPR_Draw( int frame, int x, int y, const wrect_t *prc ); extern void SPR_Draw( int frame, int x, int y, int width, int height ); @@ -165,6 +167,7 @@ extern void DrawImageBar( float percent, HSPRITE hImage, int w, int h ); extern void DrawImageBar( float percent, HSPRITE hImage, int x, int y, int w, int h ); extern void DrawGenericBar( float percent, int w, int h ); extern void DrawGenericBar( float percent, int x, int y, int w, int h ); +extern void Draw_VidInit( void ); // from cl_view.c extern void V_RenderSplash( void ); diff --git a/client/hud/hud_train.cpp b/client/hud/hud_train.cpp index 8a7c2caf..aa74606e 100644 --- a/client/hud/hud_train.cpp +++ b/client/hud/hud_train.cpp @@ -44,7 +44,7 @@ int CHudTrain::VidInit( void ) int CHudTrain::Draw(float fTime) { if( !m_hSprite ) - m_hSprite = LOAD_SHADER( "hud_train" ); + m_hSprite = SPR_Load( "sprites/train.spr" ); if( m_iPos ) { diff --git a/client/hud/hud_utils.cpp b/client/hud/hud_utils.cpp index ebd7d810..33168b30 100644 --- a/client/hud/hud_utils.cpp +++ b/client/hud/hud_utils.cpp @@ -208,6 +208,87 @@ int SPR_Width( HSPRITE hPic, int frame ) return Width; } +void Draw_VidInit( void ) +{ + memset( &ds, 0, sizeof( ds )); +} + +/* +==================== +SPRITE_GetList + +==================== +*/ +void ParseHudSprite( const char **pfile, char *psz, client_sprite_t *result ) +{ + int x = 0, y = 0, width = 0, height = 0; + client_sprite_t p; + int section = 0; + char *token; + + memset( &p, 0, sizeof( client_sprite_t )); + + while(( token = COM_ParseToken( pfile )) != NULL ) + { + if( !stricmp( token, psz )) + { + token = COM_ParseToken( pfile ); + if( !stricmp( token, "{" )) section = 1; + } + if( section ) // parse section + { + if( !stricmp( token, "}" )) break; // end section + + if( !stricmp( token, "file" )) + { + token = COM_ParseToken( pfile ); + strncpy( p.szSprite, token, 64 ); + + // fill structure at default + p.hSprite = SPR_Load( p.szSprite ); + width = SPR_Width( p.hSprite, 0 ); + height = SPR_Height( p.hSprite, 0 ); + x = y = 0; + } + else if ( !stricmp( token, "name" )) + { + token = COM_ParseToken( pfile ); + strncpy( p.szName, token, 64 ); + } + else if ( !stricmp( token, "x" )) + { + token = COM_ParseToken( pfile ); + x = atoi( token ); + } + else if ( !stricmp( token, "y" )) + { + token = COM_ParseToken( pfile ); + y = atoi( token ); + } + else if ( !stricmp( token, "width" )) + { + token = COM_ParseToken( pfile ); + width = atoi( token ); + } + else if ( !stricmp( token, "height" )) + { + token = COM_ParseToken( pfile ); + height = atoi( token ); + } + } + } + + if( !section ) return; // data not found + + // calculate sprite position + p.rc.left = x; + p.rc.right = x + width; + p.rc.top = y; + p.rc.bottom = y + height; + + memcpy( result, &p, sizeof( client_sprite_t )); +} + client_sprite_t *SPR_GetList( const char *psz, int *piCount ) { char *pfile = (char *)LOAD_FILE( psz, NULL ); @@ -227,33 +308,24 @@ client_sprite_t *SPR_GetList( const char *psz, int *piCount ) { if( !stricmp( token, "{" )) depth++; else if( !stricmp( token, "}" )) depth--; - else if( depth == 0 ) iSprCount++; + else if( depth == 0 && !strcmp( token, "hudsprite" )) + iSprCount++; } - client_sprite_t *phud, *p; + client_sprite_t *phud; plist = pfile; - phud = p = new client_sprite_t[iSprCount]; + phud = new client_sprite_t[iSprCount]; - if( depth != 0 ) ALERT( at_console, "hud.sprite EOF without closing brace\n" ); - depth = 0; - - while(( token = COM_ParseToken( &plist )) != NULL ) + if( depth != 0 ) ALERT( at_console, "%s EOF without closing brace\n", psz ); + + for( int i = 0; i < iSprCount; i++ ) //parse structures { - if( !stricmp( token, "{" )) depth++; - else if( !stricmp( token, "}" )) depth--; - else if( depth == 0 ) - { - strncpy( p->szName, token, sizeof( p->szName )); - p->hSprite = SPR_Load( p->szName ); - p->rc.left = p->rc.top = 0; - GetImageSize( &p->rc.right, &p->rc.bottom, 0, p->hSprite ); - p++; - } + ParseHudSprite( &plist, "hudsprite", &phud[i] ); } - - if( !iSprCount ) ALERT( at_console, "SPR_GetList: %s doesn't have sprites\n", psz ); - FREE_FILE( pfile ); + + if( !iSprCount ) ALERT( at_console, "SPR_GetList: %s doesn't have sprites\n", psz ); + FREE_FILE( pfile ); *piCount = iSprCount; return phud; diff --git a/client/hud/hud_warhead.cpp b/client/hud/hud_warhead.cpp index 6cfc3ae0..0adf8744 100644 --- a/client/hud/hud_warhead.cpp +++ b/client/hud/hud_warhead.cpp @@ -25,11 +25,11 @@ int CHudRedeemer::Init( void ) int CHudRedeemer :: VidInit( void ) { - m_hSprite = LOAD_SHADER( "wh_readout" ); - m_hCrosshair = LOAD_SHADER( "wh_guidedx"); - m_hStatic = LOAD_SHADER( "wh_static"); - m_hCamera = LOAD_SHADER( "wh_camera"); - m_hCamRec = LOAD_SHADER( "wh_cam_rec"); + m_hCrosshair = SPR_Load( "sprites/guidedx.spr" ); + m_hSprite = SPR_Load( "sprites/readout.spr" ); + m_hCamRec = SPR_Load( "sprites/cam_rec.spr" ); + m_hStatic = SPR_Load( "sprites/static.spr" ); + m_hCamera = SPR_Load( "sprites/camera.spr" ); m_iHudMode = 0; return 1; @@ -57,7 +57,6 @@ int CHudRedeemer :: Draw( float flTime ) if( m_iHudMode == 1 ) // draw crosshair and readout { - y = (ScreenWidth - GUIDE_S) / 2; x = (ScreenHeight - GUIDE_S) / 2; diff --git a/client/hud/hud_zoom.cpp b/client/hud/hud_zoom.cpp index 7f471e09..53416773 100644 --- a/client/hud/hud_zoom.cpp +++ b/client/hud/hud_zoom.cpp @@ -38,8 +38,8 @@ int CHudZoom :: Init( void ) int CHudZoom::VidInit( void ) { - m_hLines = LOAD_SHADER( "sniper_lines" ); - m_hCrosshair = LOAD_SHADER( "sniper_zoom" ); + m_hLines = SPR_Load( "sprites/snlines.spr" ); + m_hCrosshair = SPR_Load( "sprites/snzoom.spr" ); m_iHudMode = 0; return 1; } diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index ff5acd01..9a179abb 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -951,7 +951,7 @@ static cl_enginefuncs_t gEngfuncs = pfnRandomLong, pfnRandomFloat, pfnLoadFile, - pfnFreeFile, + pfnFileExists, pfnGetGameDir, Host_Error, &gTriApi diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 294e3509..ba01c5ac 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -323,6 +323,7 @@ void SCR_DrawFPS( void ) float *color; if( cls.state != ca_active ) return; + if( !cl_showfps->integer ) return; newtime = Sys_DoubleTime(); if (newtime >= nexttime) diff --git a/engine/client/client.h b/engine/client/client.h index 7205da66..1b11dbc1 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -476,7 +476,7 @@ void pfnGetGameDir( char *szGetGameDir ); long pfnRandomLong( long lLow, long lHigh ); float pfnRandomFloat( float flLow, float flHigh ); byte* pfnLoadFile( const char *filename, int *pLength ); -void pfnFreeFile( void *buffer ); +int pfnFileExists( const char *filename ); _inline edict_t *CL_EDICT_NUM( int n, const char *file, const int line ) { diff --git a/engine/common/engfuncs.c b/engine/common/engfuncs.c index 2f4011fa..3e5844cb 100644 --- a/engine/common/engfuncs.c +++ b/engine/common/engfuncs.c @@ -31,6 +31,17 @@ void pfnFreeFile( void *buffer ) if( buffer ) Mem_Free( buffer ); } +/* +============= +pfnFileExists + +============= +*/ +int pfnFileExists( const char *filename ) +{ + return FS_FileExists( filename ); +} + /* ============= pfnRandomLong diff --git a/public/clgame_api.h b/public/clgame_api.h index 8a3c6a90..4636d264 100644 --- a/public/clgame_api.h +++ b/public/clgame_api.h @@ -212,7 +212,7 @@ typedef struct cl_enginefuncs_s long (*pfnRandomLong)( long lLow, long lHigh ); float (*pfnRandomFloat)( float flLow, float flHigh ); byte* (*pfnLoadFile)( const char *filename, int *pLength ); - void (*pfnFreeFile)( void *buffer ); + int (*pfnFileExists)( const char *filename ); void (*pfnGetGameDir)( char *szGetGameDir ); void (*pfnHostError)( const char *szFmt, ... ); // invoke host error diff --git a/server/ents/basebrush.cpp b/server/ents/basebrush.cpp index 81a564ed..7c9a3e48 100644 --- a/server/ents/basebrush.cpp +++ b/server/ents/basebrush.cpp @@ -175,13 +175,13 @@ void CBaseBrush::PlayRandomSound( edict_t *pEdict, Materials soundMaterial, floa void CBaseBrush :: AxisDir( void ) { - //make backward compatibility - if ( pev->movedir != g_vecZero) return; + // make backward compatibility + if( pev->movedir != g_vecZero ) return; - //Don't change this! - if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS)) + // don't change this! + if( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS )) pev->movedir = Vector ( 0, 0, 1 ); // around z-axis - else if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS)) + else if( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS )) pev->movedir = Vector ( 1, 0, 0 ); // around x-axis else pev->movedir = Vector ( 0, 1, 0 ); // around y-axis } @@ -204,18 +204,18 @@ void CBaseBrush::KeyValue( KeyValueData* pkvd ) pev->health = atof(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spawnobject") ) + else if( FStrEq( pkvd->szKeyName, "spawnobject" )) { int namelen = strlen(pkvd->szValue) - 1; int obj = atoi( pkvd->szValue ); - //custom spawn object - if(namelen > 2) m_iSpawnObject = ALLOC_STRING( pkvd->szValue ); + // custom spawn object + if( namelen > 2 ) m_iSpawnObject = ALLOC_STRING( pkvd->szValue ); else if ( obj > 0 && obj < ARRAYSIZE(pSpawnObjects)) m_iSpawnObject = MAKE_STRING( pSpawnObjects[obj] ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "gibmodel")) + else if (FStrEq( pkvd->szKeyName, "gibmodel" )) { m_iGibModel = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; @@ -228,38 +228,33 @@ void CBaseBrush::KeyValue( KeyValueData* pkvd ) if (m_flVolume < 0.0) m_flVolume = 0.0; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "movesound") || FStrEq(pkvd->szKeyName, "movesnd")) + else if( FStrEq( pkvd->szKeyName, "movesound" )) { m_iMoveSound = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "stopsound") || FStrEq(pkvd->szKeyName, "stopsnd")) + else if( FStrEq( pkvd->szKeyName, "stopsound" )) { m_iStopSound = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "contents")) - { - pev->skin = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else CBaseLogic::KeyValue( pkvd ); + else CBaseLogic::KeyValue( pkvd ); } //Base functions TYPEDESCRIPTION CBaseBrush::m_SaveData[] = { - DEFINE_FIELD( CBaseBrush, m_flVolume, FIELD_FLOAT ), //volume of sounds - DEFINE_FIELD( CBaseBrush, m_pitch, FIELD_FLOAT ), //pitch of sound - DEFINE_FIELD( CBaseBrush, m_Material, FIELD_INTEGER ), //brush material - DEFINE_FIELD( CBaseBrush, m_iMagnitude, FIELD_INTEGER ), //explosion magnitude - DEFINE_FIELD( CBaseBrush, m_iMoveSound, FIELD_STRING ), //sound scheme like Quake - DEFINE_FIELD( CBaseBrush, m_iStartSound, FIELD_STRING ), //sound scheme like Quake - DEFINE_FIELD( CBaseBrush, m_iStopSound, FIELD_STRING ), //sound scheme like Quake - DEFINE_FIELD( CBaseBrush, m_iSpawnObject, FIELD_STRING ), //spawnobject index - DEFINE_FIELD( CBaseBrush, m_iGibModel, FIELD_STRING ), //custom gibname - DEFINE_FIELD( CBaseBrush, m_vecPlayerPos, FIELD_VECTOR ), //for controllable entity like tank - DEFINE_FIELD( CBaseBrush, m_pController, FIELD_CLASSPTR ), //for controllable entity like tank + DEFINE_FIELD( CBaseBrush, m_flVolume, FIELD_FLOAT ), // volume of sounds + DEFINE_FIELD( CBaseBrush, m_pitch, FIELD_FLOAT ), // pitch of sound + DEFINE_FIELD( CBaseBrush, m_Material, FIELD_INTEGER ), // brush material + DEFINE_FIELD( CBaseBrush, m_iMagnitude, FIELD_INTEGER ), // explosion magnitude + DEFINE_FIELD( CBaseBrush, m_iMoveSound, FIELD_STRING ), // sound scheme like Quake + DEFINE_FIELD( CBaseBrush, m_iStartSound, FIELD_STRING ), // sound scheme like Quake + DEFINE_FIELD( CBaseBrush, m_iStopSound, FIELD_STRING ), // sound scheme like Quake + DEFINE_FIELD( CBaseBrush, m_iSpawnObject, FIELD_STRING ), // spawnobject index + DEFINE_FIELD( CBaseBrush, m_iGibModel, FIELD_STRING ), // custom gibname + DEFINE_FIELD( CBaseBrush, m_vecPlayerPos, FIELD_VECTOR ), // for controllable entity like tank + DEFINE_FIELD( CBaseBrush, m_pController, FIELD_CLASSPTR ), // for controllable entity like tank }; IMPLEMENT_SAVERESTORE( CBaseBrush, CBaseLogic ); @@ -267,16 +262,16 @@ void CBaseBrush::Spawn( void ) { Precache(); - if (!m_flVolume)m_flVolume = 1.0;//just enable full volume + if( !m_flVolume ) m_flVolume = 1.0;//just enable full volume - //breacable brush (if mapmaker just set material - just play material sound) - if(IsBreakable()) - pev->takedamage = DAMAGE_YES; - else pev->takedamage = DAMAGE_NO; + // breacable brush (if mapmaker just set material - just play material sound) + if( IsBreakable()) + pev->takedamage = DAMAGE_YES; + else pev->takedamage = DAMAGE_NO; pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; - if (!m_pParent)pev->flags |= FL_WORLDBRUSH; + if( !m_pParent ) pev->flags |= FL_WORLDBRUSH; } void CBaseBrush::Precache( void ) @@ -358,10 +353,10 @@ void CBaseBrush::Precache( void ) MaterialSoundPrecache( m_Material ); if(IsBreakable()) { - m_idShard = UTIL_PrecacheModel( m_iGibModel, (char*)pGibName );//precache model - if(m_iSpawnObject)UTIL_PrecacheEntity( m_iSpawnObject ); + m_idShard = UTIL_PrecacheModel( m_iGibModel, (char*)pGibName ); // precache model + if( m_iSpawnObject ) UTIL_PrecacheEntity( m_iSpawnObject ); } - UTIL_PrecacheModel( pev->model );//can use *.mdl for any brush + UTIL_PrecacheModel( pev->model ); // can use *.mdl for any brush } void CBaseBrush :: DamageSound( void ) diff --git a/server/game/sound.cpp b/server/game/sound.cpp index 9e0e5af6..f4c7e1ac 100644 --- a/server/game/sound.cpp +++ b/server/game/sound.cpp @@ -1641,17 +1641,17 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int cnt = 4; break; case CHAR_TEX_WOOD: fvol = 0.9; fvolbar = 0.2; - rgsz[0] = "debris/wood1.wav"; - rgsz[1] = "debris/wood2.wav"; - rgsz[2] = "debris/wood3.wav"; + rgsz[0] = "materials/wood/wood1.wav"; + rgsz[1] = "materials/wood/wood2.wav"; + rgsz[2] = "materials/wood/wood3.wav"; cnt = 3; break; case CHAR_TEX_GLASS: case CHAR_TEX_COMPUTER: fvol = 0.8; fvolbar = 0.2; - rgsz[0] = "debris/glass1.wav"; - rgsz[1] = "debris/glass2.wav"; - rgsz[2] = "debris/glass3.wav"; + rgsz[0] = "materials/glass/glass1.wav"; + rgsz[1] = "materials/glass/glass2.wav"; + rgsz[2] = "materials/glass/glass3.wav"; cnt = 3; break; case CHAR_TEX_FLESH: diff --git a/todo.log b/todo.log index cbd1e2f2..f1742c58 100644 --- a/todo.log +++ b/todo.log @@ -34,6 +34,7 @@ Beta 13.12.08 13.hud_scale factor OK 14.move "loading" and "pause" into CHUD 15.Get Rid Of DrawImage +16.Copy Resources OK entity_state_t невидима для пользователя