Ru-MaNGOS

Вернуться   Ru-MaNGOS > Ядро > Патчи > Принятые патчи

Важная информация

Принятые патчи Иногда выкладывают патчи, которые потом в итоге все-таки принимают в ядро.

Повод для гордости.

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.05.2011, 20:52   #1
Den
Ученый
 
Регистрация: 10.03.2010
Адрес: Бобруйск
Сообщений: 284
Сказал(а) спасибо: 213
Поблагодарили 98 раз(а) в 84 сообщениях
Den Скоро придёт к известностиDen Скоро придёт к известности
По умолчанию [11439] Cleanup codestyle in Bag.cpp & Bag.h

Код:
diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp
index 5a32a83..5797f6d 100644
--- a/src/game/Bag.cpp
+++ b/src/game/Bag.cpp
@@ -22,19 +22,19 @@
 #include "Log.h"
 #include "UpdateData.h"
 
-Bag::Bag( ): Item()
+Bag::Bag(): Item()
 {
     m_objectType |= (TYPEMASK_ITEM | TYPEMASK_CONTAINER);
     m_objectTypeId = TYPEID_CONTAINER;
 
     m_valuesCount = CONTAINER_END;
 
-    memset(m_bagslot, 0, sizeof(Item *) * MAX_BAG_SIZE);
+    memset(m_bagslot, 0, sizeof(Item*) * MAX_BAG_SIZE);
 }
 
 Bag::~Bag()
 {
-    for(int i = 0; i < MAX_BAG_SIZE; ++i)
+    for (int i = 0; i < MAX_BAG_SIZE; ++i)
         if (m_bagslot[i])
             delete m_bagslot[i];
 }
@@ -43,15 +43,15 @@ void Bag::AddToWorld()
 {
     Item::AddToWorld();
 
-    for(uint32 i = 0;  i < GetBagSize(); ++i)
-        if(m_bagslot[i])
+    for (uint32 i = 0;  i < GetBagSize(); ++i)
+        if (m_bagslot[i])
             m_bagslot[i]->AddToWorld();
 }
 
 void Bag::RemoveFromWorld()
 {
-    for(uint32 i = 0; i < GetBagSize(); ++i)
-        if(m_bagslot[i])
+    for (uint32 i = 0; i < GetBagSize(); ++i)
+        if (m_bagslot[i])
             m_bagslot[i]->RemoveFromWorld();
 
     Item::RemoveFromWorld();
@@ -59,12 +59,12 @@ void Bag::RemoveFromWorld()
 
 bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
 {
-    ItemPrototype const * itemProto = ObjectMgr::GetItemPrototype(itemid);
+    ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
 
-    if(!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
+    if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
         return false;
 
-    Object::_Create( guidlow, 0, HIGHGUID_CONTAINER );
+    Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
 
     SetEntry(itemid);
     SetObjectScale(DEFAULT_OBJECT_SCALE);
@@ -82,7 +82,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
     // Cleaning 20 slots
     for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
     {
-        SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid());
+        SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid());
         m_bagslot[i] = NULL;
     }
 
@@ -94,7 +94,7 @@ void Bag::SaveToDB()
     Item::SaveToDB();
 }
 
-bool Bag::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
+bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
 {
     if (!Item::LoadFromDB(guidLow, fields, ownerGuid))
         return false;
@@ -102,7 +102,7 @@ bool Bag::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
     // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
     for (int i = 0; i < MAX_BAG_SIZE; ++i)
     {
-        SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid());
+        SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid());
         if (m_bagslot[i])
         {
             delete m_bagslot[i];
@@ -125,14 +125,14 @@ void Bag::DeleteFromDB()
 uint32 Bag::GetFreeSlots() const
 {
     uint32 slots = 0;
-    for (uint32 i=0; i < GetBagSize(); ++i)
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (!m_bagslot[i])
             ++slots;
 
     return slots;
 }
 
-void Bag::RemoveItem( uint8 slot, bool /*update*/ )
+void Bag::RemoveItem(uint8 slot, bool /*update*/)
 {
     MANGOS_ASSERT(slot < MAX_BAG_SIZE);
 
@@ -140,14 +140,14 @@ void Bag::RemoveItem( uint8 slot, bool /*update*/ )
         m_bagslot[slot]->SetContainer(NULL);
 
     m_bagslot[slot] = NULL;
-    SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot*2), ObjectGuid());
+    SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid());
 }
 
-void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
+void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
 {
     MANGOS_ASSERT(slot < MAX_BAG_SIZE);
 
-    if( pItem )
+    if (pItem)
     {
         m_bagslot[slot] = pItem;
         SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetObjectGuid());
@@ -158,28 +158,28 @@ void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ )
     }
 }
 
-void Bag::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const
+void Bag::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
 {
-    Item::BuildCreateUpdateBlockForPlayer( data, target );
+    Item::BuildCreateUpdateBlockForPlayer(data, target);
 
     for (uint32 i = 0; i < GetBagSize(); ++i)
-        if(m_bagslot[i])
-            m_bagslot[i]->BuildCreateUpdateBlockForPlayer( data, target );
+        if (m_bagslot[i])
+            m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target);
 }
 
 // If the bag is empty returns true
 bool Bag::IsEmpty() const
 {
-    for(uint32 i = 0; i < GetBagSize(); ++i)
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i])
             return false;
 
     return true;
 }
 
-Item* Bag::GetItemByEntry( uint32 item ) const
+Item* Bag::GetItemByEntry(uint32 item) const
 {
-    for(uint32 i = 0; i < GetBagSize(); ++i)
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item)
             return m_bagslot[i];
 
@@ -188,7 +188,7 @@ Item* Bag::GetItemByEntry( uint32 item ) const
 
 Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const
 {
-    for(uint32 i = 0; i < GetBagSize(); ++i)
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i] && m_bagslot[i]->GetProto()->ItemLimitCategory == limitedCategory)
             return m_bagslot[i];
 
@@ -198,13 +198,14 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const
 uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
 {
     uint32 count = 0;
-    for(uint32 i=0; i < GetBagSize(); ++i)
+
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i])
             if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)
                 count += m_bagslot[i]->GetCount();
 
     if (eItem && eItem->GetProto()->GemProperties)
-        for(uint32 i=0; i < GetBagSize(); ++i)
+        for (uint32 i = 0; i < GetBagSize(); ++i)
             if (m_bagslot[i])
                 if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->Socket[0].Color)
                     count += m_bagslot[i]->GetGemCountWithID(item);
@@ -215,7 +216,8 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
 uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) const
 {
     uint32 count = 0;
-    for(uint32 i = 0; i < GetBagSize(); ++i)
+
+    for (uint32 i = 0; i < GetBagSize(); ++i)
         if (m_bagslot[i])
             if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory )
                 count += m_bagslot[i]->GetCount();
@@ -225,17 +227,17 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) con
 
 uint8 Bag::GetSlotByItemGUID(uint64 guid) const
 {
-    for(uint32 i = 0; i < GetBagSize(); ++i)
-        if(m_bagslot[i] != 0)
-            if(m_bagslot[i]->GetGUID() == guid)
+    for (uint32 i = 0; i < GetBagSize(); ++i)
+        if (m_bagslot[i] != 0)
+            if (m_bagslot[i]->GetGUID() == guid)
                 return i;
 
     return NULL_SLOT;
 }
 
-Item* Bag::GetItemByPos( uint8 slot ) const
+Item* Bag::GetItemByPos(uint8 slot) const
 {
-    if( slot < GetBagSize() )
+    if (slot < GetBagSize())
         return m_bagslot[slot];
 
     return NULL;
diff --git a/src/game/Bag.h b/src/game/Bag.h
index 86e86ef..0cf283f 100644
--- a/src/game/Bag.h
+++ b/src/game/Bag.h
@@ -39,11 +39,11 @@ class Bag : public Item
         bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
 
         void Clear();
-        void StoreItem( uint8 slot, Item *pItem, bool update );
-        void RemoveItem( uint8 slot, bool update );
+        void StoreItem(uint8 slot, Item *pItem, bool update);
+        void RemoveItem(uint8 slot, bool update);
 
-        Item* GetItemByPos( uint8 slot ) const;
-        Item* GetItemByEntry( uint32 item ) const;
+        Item* GetItemByPos(uint8 slot) const;
+        Item* GetItemByEntry(uint32 item) const;
         Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
         uint32 GetItemCount(uint32 item, Item* eItem = NULL) const;
         uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem = NULL) const;
@@ -57,11 +57,11 @@ class Bag : public Item
         // overwrite virtual Item::SaveToDB
         void SaveToDB();
         // overwrite virtual Item::LoadFromDB
-        bool LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid = ObjectGuid());
+        bool LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid = ObjectGuid());
         // overwrite virtual Item::DeleteFromDB
         void DeleteFromDB();
 
-        void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const;
+        void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const;
 
     protected:
 
@@ -69,7 +69,7 @@ class Bag : public Item
         Item* m_bagslot[MAX_BAG_SIZE];
 };
 
-inline Item* NewItemOrBag(ItemPrototype const * proto)
+inline Item* NewItemOrBag(ItemPrototype const* proto)
 {
     if (proto->InventoryType == INVTYPE_BAG)
         return new Bag;
Den вне форума  
Пользователь сказал cпасибо:
Vladimir (08.05.2011)
Старый 08.05.2011, 05:11   #2
Vladimir
MaNGOS Dev
 
Регистрация: 09.02.2010
Сообщений: 594
Сказал(а) спасибо: 315
Поблагодарили 438 раз(а) в 181 сообщениях
Vladimir Как свет с небесVladimir Как свет с небесVladimir Как свет с небесVladimir Как свет с небесVladimir Как свет с небесVladimir Как свет с небес
По умолчанию

В [11439]. Спасибо
__________________
Так как устал объяснять знайте ICQ не пользуюсь
Vladimir вне форума  
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.



Текущее время: 06:20. Часовой пояс GMT +3.


ru-mangos.ru - Русское сообщество MaNGOS
Главная цель проекта MaNGOS - обучающая, поэтому разрешается использовать исходный код и собранную программу только для образовательных целей.
Вы не можете использовать MaNGOS в коммерческих целях, а также не разрешается устанавливать публичные серверы на базе MaNGOS.
Любое копирование материалов, информации в любом виде без указания источника - форума Ru-MaNGOS будет считаться нарушением авторских прав и нарушением Уголовного Кодекса РФ, ст. 146 ст. 147.
Перевод vBulletin: zCarot