|
20 | 20 | #include "tier1/KeyValues.h" |
21 | 21 | #include "toolframework/itoolframework.h" |
22 | 22 | #include "toolframework_client.h" |
23 | | -#include "mapentities_shared.h" |
24 | | -#include "gamestringpool.h" |
25 | 23 |
|
26 | 24 | // memdbgon must be the last include file in a .cpp file!!! |
27 | 25 | #include "tier0/memdbgon.h" |
@@ -501,199 +499,3 @@ void CSprite::GetToolRecordingState( KeyValues *msg ) |
501 | 499 |
|
502 | 500 | msg->SetPtr( "sprite", &state ); |
503 | 501 | } |
504 | | - |
505 | | -CUtlVector< CSprite * > g_ClientsideSprites; |
506 | | - |
507 | | -// ===================== For clientside spawning of sprites ===================== |
508 | | -void CSprite::RecreateAllClientside() |
509 | | -{ |
510 | | - DestroyAllClientside(); |
511 | | - ParseAllClientsideEntities( engine->GetMapEntitiesString() ); |
512 | | -} |
513 | | - |
514 | | -void CSprite::DestroyAllClientside() |
515 | | -{ |
516 | | - // This only gets called during LevelInitPostEntity and LevelShutdown so we're going to use |
517 | | - // Release() instead of Remove() or UTIL_Remove |
518 | | - while ( g_ClientsideSprites.Count() > 0 ) |
519 | | - { |
520 | | - CSprite *p = g_ClientsideSprites[0]; |
521 | | - |
522 | | - // This will call into CSprite::~CSprite in sprite.cpp, which will FindAndRemove this sprite from the array |
523 | | - p->Release(); |
524 | | - } |
525 | | -} |
526 | | - |
527 | | -bool CSprite::InitializeClientside() |
528 | | -{ |
529 | | - if ( InitializeAsClientEntity( STRING( GetModelName() ), false ) == false ) |
530 | | - { |
531 | | - return false; |
532 | | - } |
533 | | - |
534 | | - m_bClientOnly = true; |
535 | | - g_ClientsideSprites.AddToTail( this ); |
536 | | - |
537 | | - Spawn(); |
538 | | - |
539 | | - const model_t *mod = GetModel(); |
540 | | - if ( mod ) |
541 | | - { |
542 | | - Vector mins, maxs; |
543 | | - modelinfo->GetModelBounds( mod, mins, maxs ); |
544 | | - SetCollisionBounds( mins, maxs ); |
545 | | - } |
546 | | - |
547 | | - SetBlocksLOS( false ); // this should be a small object |
548 | | - SetNextClientThink( CLIENT_THINK_NEVER ); |
549 | | - |
550 | | - return true; |
551 | | -} |
552 | | - |
553 | | - |
554 | | -const char *CSprite::ParseClientsideEntity( const char *pEntData ) |
555 | | -{ |
556 | | - CEntityMapData entData( (char*)pEntData ); |
557 | | - char className[MAPKEY_MAXLENGTH]; |
558 | | - |
559 | | - MDLCACHE_CRITICAL_SECTION(); |
560 | | - |
561 | | - if ( !entData.ExtractValue( "classname", className ) ) |
562 | | - { |
563 | | - Error( "classname missing from entity!\n" ); |
564 | | - } |
565 | | - |
566 | | - if ( !Q_strcmp( className, "env_sprite_clientside" )) |
567 | | - { |
568 | | - char targetName[MAPKEY_MAXLENGTH]{}; |
569 | | - char parentName[MAPKEY_MAXLENGTH]{}; |
570 | | - entData.ExtractValue( "targetname", targetName ); |
571 | | - entData.ExtractValue( "parentname", parentName ); |
572 | | - if ( targetName[0] != '\0' || parentName[0] != '\0' ) |
573 | | - { |
574 | | - //simply skip |
575 | | - } |
576 | | - else |
577 | | - { |
578 | | - // always force clientside entities placed in maps |
579 | | - CSprite* pEntity = new CSprite(); |
580 | | - |
581 | | - if ( pEntity ) |
582 | | - { |
583 | | - // Set up keyvalues. |
584 | | - pEntity->ParseMapData(&entData); |
585 | | - |
586 | | - if ( !pEntity->InitializeClientside() ) |
587 | | - pEntity->Release(); |
588 | | - |
589 | | - return entData.CurrentBufferPosition(); |
590 | | - } |
591 | | - } |
592 | | - } |
593 | | - |
594 | | - |
595 | | - // Just skip past all the keys. |
596 | | - char keyName[MAPKEY_MAXLENGTH]; |
597 | | - char value[MAPKEY_MAXLENGTH]; |
598 | | - if ( entData.GetFirstKey(keyName, value) ) |
599 | | - { |
600 | | - do |
601 | | - { |
602 | | - } |
603 | | - while ( entData.GetNextKey(keyName, value) ); |
604 | | - } |
605 | | - |
606 | | - // |
607 | | - // Return the current parser position in the data block |
608 | | - // |
609 | | - return entData.CurrentBufferPosition(); |
610 | | -} |
611 | | - |
612 | | -bool CSprite::KeyValue( const char *szKeyName, const char *szValue ) |
613 | | -{ |
614 | | - if ( FStrEq( szKeyName, "scale" ) ) |
615 | | - { |
616 | | - m_flSpriteScale = atof(szValue); |
617 | | - } |
618 | | - else if ( FStrEq( szKeyName, "framerate" ) ) |
619 | | - { |
620 | | - m_flSpriteFramerate = atof(szValue); |
621 | | - } |
622 | | - else if ( FStrEq( szKeyName, "GlowProxySize" ) ) |
623 | | - { |
624 | | - m_flGlowProxySize = atof(szValue); |
625 | | - } |
626 | | - else if ( FStrEq( szKeyName, "frame" ) ) |
627 | | - { |
628 | | - m_flFrame = atof(szValue); |
629 | | - } |
630 | | - else if ( FStrEq( szKeyName, "HDRColorScale" ) ) |
631 | | - { |
632 | | - m_flHDRColorScale = atof(szValue); |
633 | | - } |
634 | | - else if ( FStrEq( szKeyName, "rendermode" ) ) |
635 | | - { |
636 | | - SetRenderMode( (RenderMode_t) atoi( szValue ) ); |
637 | | - } |
638 | | - else if ( FStrEq( szKeyName, "model" ) ) |
639 | | - { |
640 | | - SetModelName( AllocPooledString( szValue ) ); |
641 | | - } |
642 | | - else if ( FStrEq( szKeyName, "spritecontroller" ) ) |
643 | | - { |
644 | | - m_iszSpriteControllerName = AllocPooledString( szValue ); |
645 | | - } |
646 | | - else if ( ( FStrEq( szKeyName, "targetname" ) || FStrEq( szKeyName, "parentname" ) ) && *szValue ) |
647 | | - { |
648 | | - Warning( "LEVEL DESIGN ERROR: env_sprite_clientside has %s '%s' - use env_sprite instead.\n", szKeyName, szValue ); |
649 | | - } |
650 | | - else |
651 | | - { |
652 | | - return BaseClass::KeyValue( szKeyName, szValue ); |
653 | | - } |
654 | | - |
655 | | - return true; |
656 | | -} |
657 | | - |
658 | | -//----------------------------------------------------------------------------- |
659 | | -// Purpose: Only called on BSP load. Parses and spawns all the entities in the BSP. |
660 | | -// Input : pMapData - Pointer to the entity data block to parse. |
661 | | -//----------------------------------------------------------------------------- |
662 | | -void CSprite::ParseAllClientsideEntities(const char *pMapData) |
663 | | -{ |
664 | | - int nEntities = 0; |
665 | | - |
666 | | - char szTokenBuffer[MAPKEY_MAXLENGTH]; |
667 | | - |
668 | | - // |
669 | | - // Loop through all entities in the map data, creating each. |
670 | | - // |
671 | | - for ( ; true; pMapData = MapEntity_SkipToNextEntity( pMapData, szTokenBuffer ) ) |
672 | | - { |
673 | | - // |
674 | | - // Parse the opening brace. |
675 | | - // |
676 | | - char token[MAPKEY_MAXLENGTH]; |
677 | | - pMapData = MapEntity_ParseToken( pMapData, token ); |
678 | | - |
679 | | - // |
680 | | - // Check to see if we've finished or not. |
681 | | - // |
682 | | - if ( !pMapData ) |
683 | | - break; |
684 | | - |
685 | | - if ( token[0] != '{' ) |
686 | | - { |
687 | | - Error( "CSprite::ParseAllEntities: found %s when expecting {", token); |
688 | | - continue; |
689 | | - } |
690 | | - |
691 | | - // |
692 | | - // Parse the entity and add it to the spawn list. |
693 | | - // |
694 | | - |
695 | | - pMapData = ParseClientsideEntity( pMapData ); |
696 | | - |
697 | | - nEntities++; |
698 | | - } |
699 | | -} |
0 commit comments