MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Player_CacheFromPrevLevel

Function Player_CacheFromPrevLevel

code/game/g_client.cpp:636–672  ·  view source on GitHub ↗

============ Player_CacheFromPrevLevel Description : just need to grab the weapon items we're going to have when we spawn so they'll be cached Return type : void Argument : void ============ */

Source from the content-addressed store, hash-verified

634============
635*/
636void Player_CacheFromPrevLevel(void)
637{
638 char s[MAX_STRING_CHARS];
639 int i;
640
641 gi.Cvar_VariableStringBuffer( sCVARNAME_PLAYERSAVE, s, sizeof(s) );
642
643 if (s[0]) // actually this would be safe anyway because of the way sscanf() works, but this is clearer
644 {
645 int iDummy, bits, ibits;
646
647 sscanf( s, "%i %i %i %i",
648 &iDummy,//client->ps.stats[STAT_HEALTH],
649 &iDummy,//client->ps.stats[STAT_ARMOR],
650 &bits, //client->ps.stats[STAT_WEAPONS]
651 &ibits //client->ps.stats[STAT_ITEMS]
652 );
653
654 for ( i = 1 ; i < 16 ; i++ )
655 {
656 if ( bits & ( 1 << i ) )
657 {
658 RegisterItem( FindItemForWeapon( (weapon_t)i ) );
659 }
660 }
661
662extern gitem_t *FindItemForInventory( int inv );
663
664 for ( i = 0 ; i < 16 ; i++ )
665 {
666 if ( ibits & ( 1 << i ) )
667 {
668 RegisterItem( FindItemForInventory( i ));
669 }
670 }
671 }
672}
673
674/*
675============

Callers 1

ClearRegisteredItemsFunction · 0.70

Calls 4

sscanfFunction · 0.85
RegisterItemFunction · 0.70
FindItemForWeaponFunction · 0.70
FindItemForInventoryFunction · 0.70

Tested by

no test coverage detected