Skip to content

Commit

Permalink
Excluded unnecessary stuff.
Browse files Browse the repository at this point in the history
git-svn-id: https://cvet.by:8443/svn/FOnlineSource/Main@1202 c2c6a35e-ad2b-4e1f-bb64-97b989be360b

Former-commit-id: a7a87e67da3cbeb4064e12c8d1ff4d199f1879b5
  • Loading branch information
cvet authored and cvet committed Oct 30, 2018
1 parent 3fafc2f commit 3bc7be0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 314 deletions.
38 changes: 0 additions & 38 deletions Source/Critter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,37 +1224,6 @@ Item* Critter::GetItemByPidInvPriority( hash item_pid )
return nullptr;
}

Item* Critter::GetAmmoForWeapon( Item* weap )
{
if( !weap->IsWeapon() )
return nullptr;

Item* ammo = GetItemByPid( weap->GetAmmoPid() );
if( ammo )
return ammo;
ammo = GetItemByPid( weap->GetWeapon_DefaultAmmoPid() );
if( ammo )
return ammo;
ammo = GetAmmo( weap->GetWeapon_Caliber() );

// Already synchronized
return ammo;
}

Item* Critter::GetAmmo( int caliber )
{
for( auto it = invItems.begin(), end = invItems.end(); it != end; ++it )
{
Item* item = *it;
if( item->GetType() == ITEM_TYPE_AMMO && item->GetAmmo_Caliber() == caliber )
{
SYNC_LOCK( item );
return item;
}
}
return nullptr;
}

Item* Critter::GetItemCar()
{
for( auto it = invItems.begin(), end = invItems.end(); it != end; ++it )
Expand Down Expand Up @@ -3981,13 +3950,6 @@ void Npc::RefreshBag()
pids[ item->GetProtoId() ] += item->GetCount();
else
pids[ item->GetProtoId() ] = item->GetCount();

// Repair/reload item in slots
if( item->GetCritSlot() != SLOT_INV )
{
if( item->IsWeapon() && item->GetWeapon_MaxAmmoCount() && item->WeapIsEmpty() )
item->WeapLoadHolder();
}
}

// Item garbager
Expand Down
2 changes: 0 additions & 2 deletions Source/Critter.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ class Critter: public Entity
Item* GetItemByPid( hash item_pid );
Item* GetItemByPidInvPriority( hash item_pid );
Item* GetItemByPidSlot( hash item_pid, int slot );
Item* GetAmmoForWeapon( Item* weap );
Item* GetAmmo( int caliber );
Item* GetItemCar();
Item* GetItemSlot( int slot );
void GetItemsSlot( int slot, ItemVec& items, bool lock );
Expand Down
58 changes: 2 additions & 56 deletions Source/CritterCl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,6 @@ Item* CritterCl::GetItemByPidSlot( hash item_pid, int slot )
return nullptr;
}

Item* CritterCl::GetAmmo( uint caliber )
{
for( auto it = InvItems.begin(), end = InvItems.end(); it != end; ++it )
if( ( *it )->IsAmmo() && ( *it )->GetAmmo_Caliber() == (int) caliber )
return *it;
return nullptr;
}

Item* CritterCl::GetItemSlot( int slot )
{
for( auto it = InvItems.begin(), end = InvItems.end(); it != end; ++it )
Expand Down Expand Up @@ -355,41 +347,6 @@ uint CritterCl::CountItemType( uchar type )
return res;
}

Item* CritterCl::GetSlotUse( uchar num_slot, uchar& use )
{
Item* item = nullptr;
switch( num_slot )
{
case SLOT_HAND1:
item = ItemSlotMain;
use = GetUse();
break;
case SLOT_HAND2:
item = ItemSlotExt;
if( item->IsWeapon() )
use = USE_PRIMARY;
else if( item->GetIsCanUse() || item->GetIsCanUseOnSmth() )
use = USE_USE;
else
use = 0xF;
break;
default:
break;
}
return item;
}

bool CritterCl::IsItemAim( uchar num_slot )
{
uchar use;
Item* item = GetSlotUse( num_slot, use );
if( !item )
return false;
if( item->IsWeapon() && use < MAX_USES )
return ( use == 0 ? item->GetWeapon_Aim_0() : ( use == 1 ? item->GetWeapon_Aim_1() : item->GetWeapon_Aim_2() ) ) != 0;
return false;
}

bool CritterCl::IsCombatMode()
{
return IS_TIMEOUT( GetTimeoutBattle() );
Expand Down Expand Up @@ -424,14 +381,13 @@ uint CritterCl::GetUseApCost( Item* item, uchar rate )

uint CritterCl::GetAttackDist()
{
uchar use;
Item* weap = GetSlotUse( SLOT_HAND1, use );
Item* weap = ItemSlotMain;
if( !weap->IsWeapon() )
return 0;

uint dist = 0;
#ifdef FONLINE_CLIENT
Script::RaiseInternalEvent( ClientFunctions.CritterGetAttackDistantion, this, weap, use, &dist );
Script::RaiseInternalEvent( ClientFunctions.CritterGetAttackDistantion, this, weap, weap->GetMode(), &dist );
#endif
return dist;
}
Expand Down Expand Up @@ -488,16 +444,6 @@ void CritterCl::DrawStay( Rect r )
}
}

Item* CritterCl::GetAmmoAvialble( Item* weap )
{
Item* ammo = GetItemByPid( weap->GetAmmoPid() );
if( !ammo && weap->WeapIsEmpty() )
ammo = GetItemByPid( weap->GetWeapon_DefaultAmmoPid() );
if( !ammo && weap->WeapIsEmpty() )
ammo = GetAmmo( weap->GetWeapon_Caliber() );
return ammo;
}

bool CritterCl::IsLastHexes()
{
return !LastHexX.empty() && !LastHexY.empty();
Expand Down
6 changes: 0 additions & 6 deletions Source/CritterCl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,13 @@ class CritterCl: public Entity
Item* GetItemByPid( hash item_pid );
Item* GetItemByPidInvPriority( hash item_pid );
Item* GetItemByPidSlot( hash item_pid, int slot );
Item* GetAmmo( uint caliber );
Item* GetItemSlot( int slot );
void GetItemsSlot( int slot, ItemVec& items );
void GetItemsType( int slot, ItemVec& items );
uint CountItemPid( hash item_pid );
uint CountItemType( uchar type );
bool IsHaveLightSources();
Item* GetSlotUse( uchar num_slot, uchar& use );
bool IsItemAim( uchar num_slot );
uchar GetUse() { return ItemSlotMain->GetMode() & 0xF; }
uchar GetFullRate() { return ItemSlotMain->GetMode(); }
uint GetUseApCost( Item* item, uchar rate );
Item* GetAmmoAvialble( Item* weap );

// Moving
public:
Expand Down
117 changes: 0 additions & 117 deletions Source/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
#endif

CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, int, Type );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, int, Grid_Type );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, hash, PicMap );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, hash, PicInv );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, bool, Stackable );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, bool, Weapon_IsUnarmed );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, uint, Weapon_Anim1 );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, short, OffsetX );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, short, OffsetY );
CLASS_PROPERTY_ALIAS_IMPL( ProtoItem, Item, uchar, Slot );
Expand Down Expand Up @@ -87,41 +84,7 @@ CLASS_PROPERTY_IMPL( Item, ChildLines_1 );
CLASS_PROPERTY_IMPL( Item, ChildLines_2 );
CLASS_PROPERTY_IMPL( Item, ChildLines_3 );
CLASS_PROPERTY_IMPL( Item, ChildLines_4 );
CLASS_PROPERTY_IMPL( Item, Weapon_IsUnarmed );
CLASS_PROPERTY_IMPL( Item, Weapon_UnarmedMinAgility );
CLASS_PROPERTY_IMPL( Item, Weapon_UnarmedMinUnarmed );
CLASS_PROPERTY_IMPL( Item, Weapon_UnarmedMinLevel );
CLASS_PROPERTY_IMPL( Item, Weapon_Anim1 );
CLASS_PROPERTY_IMPL( Item, Weapon_MaxAmmoCount );
CLASS_PROPERTY_IMPL( Item, Weapon_Caliber );
CLASS_PROPERTY_IMPL( Item, Weapon_DefaultAmmoPid );
CLASS_PROPERTY_IMPL( Item, Weapon_MinStrength );
CLASS_PROPERTY_IMPL( Item, Weapon_Perk );
CLASS_PROPERTY_IMPL( Item, Weapon_IsTwoHanded );
CLASS_PROPERTY_IMPL( Item, Weapon_ActiveUses );
CLASS_PROPERTY_IMPL( Item, Weapon_Skill_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_Skill_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_Skill_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_PicUse_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_PicUse_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_PicUse_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_MaxDist_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_MaxDist_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_MaxDist_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_Round_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_Round_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_Round_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_ApCost_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_ApCost_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_ApCost_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_Aim_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_Aim_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_Aim_2 );
CLASS_PROPERTY_IMPL( Item, Weapon_SoundId_0 );
CLASS_PROPERTY_IMPL( Item, Weapon_SoundId_1 );
CLASS_PROPERTY_IMPL( Item, Weapon_SoundId_2 );
CLASS_PROPERTY_IMPL( Item, Ammo_Caliber );
CLASS_PROPERTY_IMPL( Item, Grid_Type );
CLASS_PROPERTY_IMPL( Item, Grid_ToMap );
CLASS_PROPERTY_IMPL( Item, Grid_ToMapEntire );
CLASS_PROPERTY_IMPL( Item, Grid_ToMapDir );
Expand Down Expand Up @@ -166,16 +129,6 @@ CLASS_PROPERTY_IMPL( Item, SortValue );
CLASS_PROPERTY_IMPL( Item, Indicator );
CLASS_PROPERTY_IMPL( Item, Mode );
CLASS_PROPERTY_IMPL( Item, Count );
CLASS_PROPERTY_IMPL( Item, Val0 );
CLASS_PROPERTY_IMPL( Item, Val1 );
CLASS_PROPERTY_IMPL( Item, Val2 );
CLASS_PROPERTY_IMPL( Item, Val3 );
CLASS_PROPERTY_IMPL( Item, Val4 );
CLASS_PROPERTY_IMPL( Item, Val5 );
CLASS_PROPERTY_IMPL( Item, Val6 );
CLASS_PROPERTY_IMPL( Item, Val7 );
CLASS_PROPERTY_IMPL( Item, Val8 );
CLASS_PROPERTY_IMPL( Item, Val9 );
CLASS_PROPERTY_IMPL( Item, AmmoPid );
CLASS_PROPERTY_IMPL( Item, AmmoCount );
CLASS_PROPERTY_IMPL( Item, TrapValue );
Expand Down Expand Up @@ -315,69 +268,6 @@ void Item::ChangeCount( int val )
SetCount( GetCount() + val );
}

void Item::SetWeaponMode( uchar mode )
{
if( !IsWeapon() )
{
mode &= 0xF;
if( mode == USE_USE && !GetIsCanUse() && !GetIsCanUseOnSmth() )
mode = USE_NONE;
else if( GetIsCanUse() || GetIsCanUseOnSmth() )
mode = USE_USE;
else
mode = USE_NONE;
}
else
{
uchar use = ( mode & 0xF );
uchar aim = ( mode >> 4 );

switch( use )
{
case USE_PRIMARY:
if( GetWeapon_ActiveUses() & 0x1 )
break;
use = 0xF;
aim = 0;
break;
case USE_SECONDARY:
if( GetWeapon_ActiveUses() & 0x2 )
break;
use = USE_PRIMARY;
aim = 0;
break;
case USE_THIRD:
if( GetWeapon_ActiveUses() & 0x4 )
break;
use = USE_PRIMARY;
aim = 0;
break;
case USE_RELOAD:
aim = 0;
if( GetWeapon_MaxAmmoCount() )
break;
use = USE_PRIMARY;
break;
case USE_USE:
aim = 0;
if( GetIsCanUseOnSmth() )
break;
use = USE_PRIMARY;
break;
default:
use = USE_PRIMARY;
aim = 0;
break;
}

if( use < MAX_USES && aim && !( use == 0 ? GetWeapon_Aim_0() : ( use == 1 ? GetWeapon_Aim_1() : GetWeapon_Aim_2() ) ) )
aim = 0;
mode = ( aim << 4 ) | ( use & 0xF );
}

SetMode( mode );
}

uint Item::GetCost1st()
{
uint cost = ( GetCost() ? GetCost() : GetCost() );
Expand All @@ -392,13 +282,6 @@ uint Item::GetCost1st()
return cost;
}

void Item::WeapLoadHolder()
{
if( !GetAmmoPid() )
SetAmmoPid( GetWeapon_DefaultAmmoPid() );
SetAmmoCount( (ushort) GetWeapon_MaxAmmoCount() );
}

#ifdef FONLINE_SERVER
void Item::ContAddItem( Item*& item, uint stack_id )
{
Expand Down
Loading

0 comments on commit 3bc7be0

Please sign in to comment.